flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [44/50] git commit: [flex-falcon] [refs/heads/feature/maven-migration] - added source maps for some semicolons
Date Mon, 11 Apr 2016 14:00:11 GMT
added source maps for some semicolons


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

Branch: refs/heads/feature/maven-migration
Commit: 584f433777beb32087f7d159346320e7f06468eb
Parents: c759afd
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Fri Apr 8 14:12:41 2016 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Fri Apr 8 14:12:41 2016 -0700

----------------------------------------------------------------------
 .../compiler/internal/codegen/js/JSEmitter.java |  8 +++
 .../internal/codegen/js/jx/ClassEmitter.java    |  4 ++
 .../codegen/js/jx/StatementEmitter.java         | 55 ++++++++++++++++++++
 3 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/584f4337/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
index 65a8e63..2ab71b3 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
@@ -44,6 +44,7 @@ import org.apache.flex.compiler.internal.codegen.js.jx.ParameterEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.ParametersEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.ReturnEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.SourceMapDirectiveEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.StatementEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.TernaryOperatorEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.UnaryOperatorEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.WhileLoopEmitter;
@@ -95,6 +96,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
     public DoWhileLoopEmitter doWhileLoopEmitter;
     public ForLoopEmitter forLoopEmitter;
     public IterationFlowEmitter interationFlowEmitter;
+    public StatementEmitter statementEmitter;
     public SourceMapDirectiveEmitter sourceMapDirectiveEmitter;
     
     @Override
@@ -137,6 +139,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
         doWhileLoopEmitter = new DoWhileLoopEmitter(this);
         forLoopEmitter = new ForLoopEmitter(this);
         interationFlowEmitter = new IterationFlowEmitter(this);
+        statementEmitter = new StatementEmitter(this);
         sourceMapDirectiveEmitter = new SourceMapDirectiveEmitter(this);
     }
 
@@ -255,6 +258,11 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
     {
         ternaryOperatorEmitter.emit(node);
     }
+    @Override
+    public void emitStatement(IASNode node)
+    {
+        statementEmitter.emit(node);
+    }
 
     @Override
     public void emitIf(IIfNode node)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/584f4337/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
index 6bf01b7..fe0bc7e 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java
@@ -105,7 +105,9 @@ public class ClassEmitter extends JSSubEmitter implements
                 writeNewline();
                 writeNewline();
                 getEmitter().emitField((IVariableNode) dnode);
+                startMapping(dnode, dnode);
                 write(ASEmitterTokens.SEMICOLON);
+                endMapping(dnode);
             }
             else if (dnode.getNodeID() == ASTNodeID.FunctionID)
             {
@@ -135,7 +137,9 @@ public class ClassEmitter extends JSSubEmitter implements
                 writeNewline();
                 writeNewline();
                 getEmitter().emitField((IVariableNode) dnode);
+                startMapping(dnode, dnode);
                 write(ASEmitterTokens.SEMICOLON);
+                endMapping(dnode);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/584f4337/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
new file mode 100644
index 0000000..7cf897c
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/StatementEmitter.java
@@ -0,0 +1,55 @@
+package org.apache.flex.compiler.internal.codegen.js.jx;
+
+import org.apache.flex.compiler.codegen.ISubEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IStatementNode;
+
+public class StatementEmitter extends JSSubEmitter implements
+        ISubEmitter<IASNode>
+{
+    public StatementEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IASNode node)
+    {
+        getWalker().walk(node);
+
+        // XXX (mschmalle) this should be in the after handler?
+        if (node.getParent().getNodeID() != ASTNodeID.LabledStatementID
+                && node.getNodeID() != ASTNodeID.ConfigBlockID
+                && !(node instanceof IStatementNode))
+        {
+            startMapping(node, node);
+            write(ASEmitterTokens.SEMICOLON);
+            endMapping(node);
+        }
+
+        if (!isLastStatement(node))
+            writeNewline();
+    }
+
+    protected static boolean isLastStatement(IASNode node)
+    {
+        return getChildIndex(node.getParent(), node) == node.getParent()
+                .getChildCount() - 1;
+    }
+
+    // this is not fair that we have to do this if (i < len - 1)
+    private static int getChildIndex(IASNode parent, IASNode node)
+    {
+        final int len = parent.getChildCount();
+        for (int i = 0; i < len; i++)
+        {
+            if (parent.getChild(i) == node)
+                return i;
+        }
+        return -1;
+    }
+}


Mime
View raw message