flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - compiler-jx: new -js-default-initializers option works for member variables too
Date Wed, 02 Aug 2017 22:35:53 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop c500b3fe5 -> d51eb8a48


compiler-jx: new -js-default-initializers option works for member variables too


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/d51eb8a4
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d51eb8a4
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d51eb8a4

Branch: refs/heads/develop
Commit: d51eb8a48acc357bc592ef5c965e9c1995fdb689
Parents: c500b3f
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Wed Aug 2 15:35:47 2017 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Wed Aug 2 15:35:47 2017 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/jx/FieldEmitter.java    | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d51eb8a4/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
index ef62ad2..0f11c0d 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/FieldEmitter.java
@@ -24,6 +24,7 @@ import org.apache.flex.compiler.codegen.js.IJSEmitter;
 import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
 import org.apache.flex.compiler.common.ASModifier;
 import org.apache.flex.compiler.common.ModifiersSet;
+import org.apache.flex.compiler.constants.IASKeywordConstants;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.IVariableDefinition;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
@@ -32,9 +33,11 @@ import org.apache.flex.compiler.internal.codegen.js.JSSessionModel.BindableVarIn
 import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
 import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.tree.ASTNodeID;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.as.IExpressionNode;
@@ -165,6 +168,40 @@ public class FieldEmitter extends JSSubEmitter implements
                 writeToken(ASEmitterTokens.EQUAL);
                 write("0");
         	}
+            boolean defaultInitializers = false;
+            ICompilerProject project = getProject();
+            if(project instanceof FlexJSProject)
+            {
+                FlexJSProject fjsProject = (FlexJSProject) project;
+                if(fjsProject.config != null)
+                {
+                    defaultInitializers = fjsProject.config.getJsDefaultInitializers();
+                }
+            }
+            if (defaultInitializers)
+            {
+                if (defName.equals("Number"))
+                {
+                    write(ASEmitterTokens.SPACE);
+                    writeToken(ASEmitterTokens.EQUAL);
+                    write(IASKeywordConstants.NA_N);
+                }
+                else if (defName.equals("Boolean"))
+                {
+                    write(ASEmitterTokens.SPACE);
+                    writeToken(ASEmitterTokens.EQUAL);
+                    write(IASKeywordConstants.FALSE);
+                }
+                else if (!defName.equals("*"))
+                {
+                    //type * is meant to default to undefined, so it
+                    //doesn't need to be initialized, but everything
+                    //else should default to null
+                    write(ASEmitterTokens.SPACE);
+                    writeToken(ASEmitterTokens.EQUAL);
+                    write(IASKeywordConstants.NULL);
+                }
+            }
         }
 
         if (!(node instanceof ChainedVariableNode))


Mime
View raw message