You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/06/14 17:01:08 UTC

git commit: [flex-falcon] [refs/heads/develop] - add our first JX compiler error and plumbing to pass it up to the output

Repository: flex-falcon
Updated Branches:
  refs/heads/develop 2ee843330 -> 40020689c


add our first JX compiler error and plumbing to pass it up to the output


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

Branch: refs/heads/develop
Commit: 40020689c60dba57bc7f83051bbc0a6e788ee0de
Parents: 2ee8433
Author: Alex Harui <ah...@apache.org>
Authored: Sat Jun 14 08:00:53 2014 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Sat Jun 14 08:00:53 2014 -0700

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/COMPJSC.java   | 12 ++++++--
 .../internal/codegen/as/ASBlockWalker.java      |  6 ++--
 .../compiler/internal/codegen/as/ASEmitter.java |  8 ++---
 .../internal/codegen/js/amd/JSAMDEmitter.java   |  2 +-
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 12 ++++++--
 .../internal/codegen/js/goog/JSGoogEmitter.java |  2 +-
 .../UnsupportedLanguageFeatureProblem.java      | 32 ++++++++++++++++++++
 .../compiler/visitor/as/IASBlockWalker.java     |  7 +++++
 8 files changed, 65 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
index f0eaa3b..dc45c6b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
@@ -192,7 +192,7 @@ public class COMPJSC extends MXMLJSC
                                     project, (List<ICompilerProblem>) errors,
                                     unit, false);
                         }
-
+                        problems.addAll(errors);
                         BufferedOutputStream out = new BufferedOutputStream(
                                 new FileOutputStream(outputClassFile));
                         writer.writeTo(out);
@@ -286,7 +286,15 @@ public class COMPJSC extends MXMLJSC
                     .concat(extension);
         }
         else
-            return config.getOutput();
+        {
+            String outputFolderName = config.getOutput();
+            if (outputFolderName.endsWith(".swc"))
+            {
+                File outputFolder = new File(outputFolderName);
+                outputFolderName = outputFolder.getParent();
+            }
+            return outputFolderName;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
index ec94c86..d8b68f6 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
@@ -103,7 +103,7 @@ public class ASBlockWalker implements IASBlockVisitor, IASBlockWalker
 
     private final List<ICompilerProblem> errors;
 
-    List<ICompilerProblem> getErrors()
+    public List<ICompilerProblem> getErrors()
     {
         return errors;
     }
@@ -424,6 +424,7 @@ public class ASBlockWalker implements IASBlockVisitor, IASBlockWalker
                 || node.getLiteralType() == LiteralType.NUMBER
                 || node.getLiteralType() == LiteralType.REGEXP
                 || node.getLiteralType() == LiteralType.STRING
+                || node.getLiteralType() == LiteralType.XML
                 || node.getLiteralType() == LiteralType.VOID)
         {
             emitter.emitLiteral(node);
@@ -431,8 +432,7 @@ public class ASBlockWalker implements IASBlockVisitor, IASBlockWalker
         else if (node.getLiteralType() == LiteralType.ARRAY
                 || node.getLiteralType() == LiteralType.OBJECT
                 || node.getLiteralType() == LiteralType.VECTOR
-                || node.getLiteralType() == LiteralType.XMLLIST
-                || node.getLiteralType() == LiteralType.XML)
+                || node.getLiteralType() == LiteralType.XMLLIST)
         {
             emitter.emitLiteralContainer((ILiteralContainerNode) node);
         }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
index f634e60..379e86e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
@@ -21,7 +21,6 @@ package org.apache.flex.compiler.internal.codegen.as;
 
 import java.io.FilterWriter;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -133,13 +132,11 @@ public class ASEmitter implements IASEmitter, IEmitter
         builder.setLength(0);
     }
 
-    protected List<ICompilerProblem> problems;
-
     // (mschmalle) think about how this should be implemented, we can add our
     // own problems to this, they don't just have to be parse problems
     public List<ICompilerProblem> getProblems()
     {
-        return problems;
+        return walker.getErrors();
     }
 
     private int currentIndent = 0;
@@ -178,7 +175,6 @@ public class ASEmitter implements IASEmitter, IEmitter
     {
         this.out = out;
         builder = new StringBuilder();
-        problems = new ArrayList<ICompilerProblem>();
     }
 
     @Override
@@ -581,7 +577,7 @@ public class ASEmitter implements IASEmitter, IEmitter
         }
 
         FunctionNode fn = (FunctionNode) node;
-        fn.parseFunctionBody(problems);
+        fn.parseFunctionBody(getProblems());
 
         IFunctionDefinition definition = node.getDefinition();
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
index da2f959..bc45058 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/amd/JSAMDEmitter.java
@@ -180,7 +180,7 @@ public class JSAMDEmitter extends JSEmitter implements IJSAMDEmitter
     private void emitConstructor(IFunctionNode node)
     {
         FunctionNode fn = (FunctionNode) node;
-        fn.parseFunctionBody(problems);
+        fn.parseFunctionBody(getProblems());
 
         //IFunctionDefinition definition = node.getDefinition();
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index e2d26f1..cf3d43b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -61,7 +61,7 @@ import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.internal.tree.as.ParameterNode;
 import org.apache.flex.compiler.internal.tree.as.RegExpLiteralNode;
-import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.UnsupportedLanguageFeatureProblem;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.scopes.IASScope;
 import org.apache.flex.compiler.tree.ASTNodeID;
@@ -86,6 +86,7 @@ import org.apache.flex.compiler.tree.as.ITypeNode;
 import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
 import org.apache.flex.compiler.tree.as.IVariableExpressionNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.tree.as.ILiteralNode.LiteralType;
 import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.utils.ASNodeUtils;
 import org.apache.flex.compiler.utils.NativeUtils;
@@ -371,7 +372,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     public void emitMethod(IFunctionNode node)
     {
         FunctionNode fn = (FunctionNode) node;
-        fn.parseFunctionBody(new ArrayList<ICompilerProblem>());
+        fn.parseFunctionBody(getProblems());
 
         ICompilerProject project = getWalker().getProject();
 
@@ -1123,7 +1124,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
     protected void emitObjectDefineProperty(IAccessorNode node)
     {
         FunctionNode fn = (FunctionNode) node;
-        fn.parseFunctionBody(problems);
+        fn.parseFunctionBody(getProblems());
 
         IFunctionDefinition definition = node.getDefinition();
         ITypeDefinition type = (ITypeDefinition) definition.getParent();
@@ -1524,6 +1525,11 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         String s = node.getValue(true);
         if (!(node instanceof RegExpLiteralNode))
         {
+            if (node.getLiteralType() == LiteralType.XML)
+            {
+                UnsupportedLanguageFeatureProblem problem = new UnsupportedLanguageFeatureProblem(node, "XML");
+                getProblems().add(problem);
+            }
             s = s.replaceAll("\n", "__NEWLINE_PLACEHOLDER__");
             s = s.replaceAll("\r", "__CR_PLACEHOLDER__");
             s = s.replaceAll("\t", "__TAB_PLACEHOLDER__");

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
index 65c591c..4f7cb56 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogEmitter.java
@@ -973,7 +973,7 @@ public class JSGoogEmitter extends JSEmitter implements IJSGoogEmitter
         */
 
         FunctionNode fn = (FunctionNode) node;
-        fn.parseFunctionBody(problems);
+        fn.parseFunctionBody(getProblems());
 
         // head
         write(JSGoogEmitterTokens.OBJECT);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/problems/UnsupportedLanguageFeatureProblem.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/problems/UnsupportedLanguageFeatureProblem.java b/compiler.jx/src/org/apache/flex/compiler/problems/UnsupportedLanguageFeatureProblem.java
new file mode 100644
index 0000000..a6da3e5
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/problems/UnsupportedLanguageFeatureProblem.java
@@ -0,0 +1,32 @@
+package org.apache.flex.compiler.problems;
+
+import org.apache.flex.compiler.common.ISourceLocation;
+import org.apache.flex.compiler.internal.parsing.as.ASToken;
+import org.apache.flex.compiler.problems.annotations.ProblemClassification;
+
+@ProblemClassification(CompilerProblemClassification.SYNTAX_ERROR)
+public class UnsupportedLanguageFeatureProblem extends CodegenProblem
+{
+
+    public static final String DESCRIPTION =
+        "'${tokenText}' cannot be cross-compiled.";
+    
+    public UnsupportedLanguageFeatureProblem(ISourceLocation site, String text)
+    {
+        super(site);
+        tokenText = text;
+    }
+    
+    public UnsupportedLanguageFeatureProblem(ASToken site, String text) 
+    {
+        super(site);
+        tokenText = text;
+    }
+    
+    public UnsupportedLanguageFeatureProblem(ASToken token)
+    {
+        this(token, token.getText());
+    }
+    
+    public final String tokenText;
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/40020689/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockWalker.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockWalker.java b/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockWalker.java
index 0c61693..f97b9ad 100644
--- a/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockWalker.java
+++ b/compiler.jx/src/org/apache/flex/compiler/visitor/as/IASBlockWalker.java
@@ -19,7 +19,10 @@
 
 package org.apache.flex.compiler.visitor.as;
 
+import java.util.List;
+
 import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.visitor.IBlockWalker;
 
 /**
@@ -33,4 +36,8 @@ public interface IASBlockWalker extends IASBlockVisitor, IBlockWalker
      */
     IASEmitter getEmitter();
 
+    /**
+     * The current project errors.
+     */
+    List<ICompilerProblem> getErrors();
 }