You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2020/07/01 16:32:45 UTC
[royale-compiler] branch develop updated:
prevent-rename-internal-symbols and export-internal-symbols compiler
options
This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/develop by this push:
new b043b9b prevent-rename-internal-symbols and export-internal-symbols compiler options
b043b9b is described below
commit b043b9b4ca1769754360e644425049c86163ccb4
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Wed Jul 1 09:32:36 2020 -0700
prevent-rename-internal-symbols and export-internal-symbols compiler options
---
.../codegen/js/royale/JSRoyaleDocEmitter.java | 27 +++++++++++++++
.../driver/js/goog/JSGoogCompcConfiguration.java | 19 ++++++++++
.../driver/js/goog/JSGoogConfiguration.java | 40 ++++++++++++++++++++++
.../apache/royale/compiler/utils/ClosureUtils.java | 16 +++++++--
4 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
index e3c584d..070edbf 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
@@ -59,6 +59,7 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
public boolean emitStringConversions = true;
private boolean emitExports = true;
private boolean exportProtected = false;
+ private boolean exportInternal = false;
private boolean suppressClosure = false;
@@ -141,11 +142,13 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
{
emitExports = !suppressExports && fjp.config.getExportPublicSymbols();
exportProtected = !suppressExports && fjp.config.getExportProtectedSymbols();
+ exportInternal = !suppressExports && fjp.config.getExportInternalSymbols();
}
else
{
emitExports = !suppressExports;
exportProtected = false;
+ exportInternal = false;
}
if (node.getAncestorOfType(IClassNode.class) != null)
{
@@ -576,6 +579,14 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
emitNoCollapse(node);
}
}
+ else if (ns == IASKeywordConstants.INTERNAL)
+ {
+ boolean preventRenameInternal = fjp.config != null && fjp.config.getPreventRenameInternalSymbols();
+ if (preventRenameInternal)
+ {
+ emitNoCollapse(node);
+ }
+ }
else if(ns != IASKeywordConstants.PRIVATE) // public or custom namespace
{
boolean preventRenamePublic = fjp.config != null && fjp.config.getPreventRenamePublicSymbols();
@@ -612,11 +623,13 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
{
emitExports = !suppressExports && fjp.config.getExportPublicSymbols();
exportProtected = !suppressExports && fjp.config.getExportProtectedSymbols();
+ exportInternal = !suppressExports && fjp.config.getExportInternalSymbols();
}
else
{
emitExports = !suppressExports;
exportProtected = false;
+ exportInternal = false;
}
emitExports = emitExports && !node.getVariableClassification().equals(VariableClassification.PACKAGE_MEMBER);
@@ -639,6 +652,11 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
else if (ns == IASKeywordConstants.INTERNAL)
{
emitInternal(node);
+ boolean preventRename = fjp.config != null && fjp.config.getPreventRenameInternalSymbols();
+ if (preventRename)
+ {
+ emitNoCollapse(node);
+ }
}
else
{
@@ -714,6 +732,15 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
else
super.emitProtected(node);
}
+
+ @Override
+ public void emitInternal(IASNode node)
+ {
+ if (exportInternal)
+ super.emitPublic(node);
+ else
+ super.emitInternal(node);
+ }
@Override
public void emitPublic(IASNode node)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java
index a63a741..53ee681 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java
@@ -441,6 +441,25 @@ public class JSGoogCompcConfiguration extends JSConfiguration
exportProtectedSymbols = value;
}
+ //
+ // 'export-internal-symbols'
+ //
+
+ private boolean exportInternalSymbols = false;
+
+ public boolean getExportInternalSymbols()
+ {
+ return exportInternalSymbols;
+ }
+
+ @Config
+ @Mapping("export-internal-symbols")
+ public void setExportInternalSymbols(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ exportInternalSymbols = value;
+ }
+
//
// 'warn-public-vars'
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
index 1d813e4..ff05246 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -444,6 +444,25 @@ public class JSGoogConfiguration extends JSConfiguration
{
exportProtectedSymbols = value;
}
+
+ //
+ // 'export-internal-symbols'
+ //
+
+ private boolean exportInternalSymbols = false;
+
+ public boolean getExportInternalSymbols()
+ {
+ return exportInternalSymbols;
+ }
+
+ @Config
+ @Mapping("export-internal-symbols")
+ public void setExportInternalSymbols(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ exportInternalSymbols = value;
+ }
//
// 'prevent-rename-public-symbols'
@@ -483,6 +502,25 @@ public class JSGoogConfiguration extends JSConfiguration
preventRenameProtectedSymbols = value;
}
+ //
+ // 'prevent-rename-internal-symbols'
+ //
+
+ private boolean preventRenameInternalSymbols = true;
+
+ public boolean getPreventRenameInternalSymbols()
+ {
+ return preventRenameInternalSymbols;
+ }
+
+ @Config
+ @Mapping("prevent-rename-internal-symbols")
+ public void setPreventRenameInternalSymbols(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ preventRenameInternalSymbols = value;
+ }
+
//
// 'warn-public-vars'
@@ -539,12 +577,14 @@ public class JSGoogConfiguration extends JSConfiguration
final int HAS_KEEP_CODE_WITH_METADATA = 4;
final int HAS_EXPORT_PUBLIC_SYMBOLS = 8;
final int EXPORT_PROTECTED_SYMBOLS = 16;
+ final int EXPORT_INTERNAL_SYMBOLS = 32;
if (getJsDefaultInitializers()) ret |= WITH_DEFAULT_INITIALIZERS;
if (getCompilerKeepAs3Metadata().size() > 0) ret |= HAS_KEEP_AS3_METADATA;
if (getCompilerKeepCodeWithMetadata().size() > 0) ret |= HAS_KEEP_CODE_WITH_METADATA;
if (getExportPublicSymbols()) ret |= HAS_EXPORT_PUBLIC_SYMBOLS;
if (getExportProtectedSymbols()) ret |= EXPORT_PROTECTED_SYMBOLS;
+ if (getExportInternalSymbols()) ret |= EXPORT_INTERNAL_SYMBOLS;
return ret;
}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
index 9d6e81f..41e94e9 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
@@ -48,8 +48,10 @@ public class ClosureUtils
}
boolean preventRenamePublic = project.config != null && project.config.getPreventRenamePublicSymbols();
boolean preventRenameProtected = project.config != null && project.config.getPreventRenameProtectedSymbols();
+ boolean preventRenameInternal = project.config != null && project.config.getPreventRenameInternalSymbols();
boolean exportPublic = project.config != null && project.config.getExportPublicSymbols();
boolean exportProtected = project.config != null && project.config.getExportProtectedSymbols();
+ boolean exportInternal = project.config != null && project.config.getExportInternalSymbols();
try
{
for(IASScope scope : cu.getFileScopeRequest().get().getScopes())
@@ -94,13 +96,17 @@ public class ClosureUtils
boolean isPublic = nsRef instanceof INamespaceDefinition.IPublicNamespaceDefinition;
boolean isProtected = nsRef instanceof INamespaceDefinition.IProtectedNamespaceDefinition
|| nsRef instanceof INamespaceDefinition.IStaticProtectedNamespaceDefinition;
+ boolean isInternal = nsRef instanceof INamespaceDefinition.IInternalNamespaceDefinition;
- if ((isPublic && preventRenamePublic) || (isProtected && preventRenameProtected))
+ if ((isPublic && preventRenamePublic)
+ || (isProtected && preventRenameProtected)
+ || (isInternal && preventRenameInternal))
{
if (localDef instanceof IAccessorDefinition)
{
/* disabled temporarily until AccessorEmitter handles @export
- (isProtected && exportProtected) */
+ (isProtected && exportProtected)
+ (isInternal && exportInternal) */
if ((isPublic && exportPublic))
{
//if an accessor is exported, we don't
@@ -129,6 +135,7 @@ public class ClosureUtils
}
boolean exportPublic = project.config != null && project.config.getExportPublicSymbols();
boolean exportProtected = project.config != null && project.config.getExportProtectedSymbols();
+ boolean exportInternal = project.config != null && project.config.getExportInternalSymbols();
try
{
String parentQName = null;
@@ -188,13 +195,16 @@ public class ClosureUtils
boolean isPublic = nsRef instanceof INamespaceDefinition.IPublicNamespaceDefinition;
boolean isProtected = nsRef instanceof INamespaceDefinition.IProtectedNamespaceDefinition
|| nsRef instanceof INamespaceDefinition.IStaticProtectedNamespaceDefinition;
+ boolean isInternal = nsRef instanceof INamespaceDefinition.IInternalNamespaceDefinition;
if (localDef instanceof IFunctionDefinition
&& !(localDef instanceof IAccessorDefinition)
// the next condition is temporary, and more
// symbols will be exported in the future
&& isPublic)
{
- if ((isPublic && exportPublic) || (isProtected && exportProtected))
+ if ((isPublic && exportPublic)
+ || (isProtected && exportProtected)
+ || (isInternal && exportInternal))
{
if (isFilePrivate)
{