You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/04/18 08:27:26 UTC

[1/9] git commit: [flex-falcon] [refs/heads/develop] - VarDeclarationEmitter: fixed sourcemap for assignment when type is omitted

Repository: flex-falcon
Updated Branches:
  refs/heads/develop bc19c66a4 -> e9fd628e5


VarDeclarationEmitter: fixed sourcemap for assignment when type is omitted


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

Branch: refs/heads/develop
Commit: e36c544cf9ebe6900dfb84ddffd2bdc9bd94733c
Parents: bc19c66
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 14:03:18 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 14:03:18 2016 -0700

----------------------------------------------------------------------
 .../js/sourcemaps/TestSourceMapStatements.java        | 14 ++++++++++++++
 .../internal/codegen/js/jx/VarDeclarationEmitter.java | 12 ++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e36c544c/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 3c25d07..8f4cf77 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -27,6 +27,20 @@ public class TestSourceMapStatements extends SourceMapTestBase
     }
 
     @Test
+    public void testVarDeclaration_withAssignedValue()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        //var /** @type {*} */ a = 42
+        assertMapping(node, 0, 0, 0, 0, 0, 4);   // var
+        assertMapping(node, 0, 4, 0, 21, 0, 22); // a
+        assertMapping(node, 0, 5, 0, 4, 0, 21);  // (type)
+        assertMapping(node, 0, 5, 0, 22, 0, 25); // =
+        assertMapping(node, 0, 8, 0, 25, 0, 27); // 42
+    }
+
+    @Test
     public void testVarDeclaration_withType()
     {
         IVariableNode node = (IVariableNode) getNode("var a:int;",

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e36c544c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
index f43b288..911a280 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
@@ -54,7 +54,8 @@ public class VarDeclarationEmitter extends JSSubEmitter implements
         }
 
         IExpressionNode variableTypeNode = node.getVariableTypeNode();
-        if(variableTypeNode.getLine() >= 0)
+        boolean hasVariableType = variableTypeNode.getLine() >= 0;
+        if(hasVariableType)
         {
             startMapping(variableTypeNode,
                     variableTypeNode.getLine(),
@@ -95,7 +96,14 @@ public class VarDeclarationEmitter extends JSSubEmitter implements
         fjs.emitDeclarationName(node);
         if (avnode != null && !(avnode instanceof IEmbedNode))
         {
-            startMapping(node, node.getVariableTypeNode());
+            if (hasVariableType)
+            {
+                startMapping(node, node.getVariableTypeNode());
+            }
+            else
+            {
+                startMapping(node, node.getNameExpressionNode());
+            }
             write(ASEmitterTokens.SPACE);
             writeToken(ASEmitterTokens.EQUAL);
             endMapping(node);


[5/9] git commit: [flex-falcon] [refs/heads/develop] - TestSourceMapStatements: added block open { to tested mappings

Posted by jo...@apache.org.
TestSourceMapStatements: added block open { to tested mappings


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

Branch: refs/heads/develop
Commit: c22e5a075e3fc760b68fd273fcfcdb1f3c389f3b
Parents: 6705005
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 15:54:21 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 15:54:21 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/sourcemaps/TestSourceMapStatements.java      | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c22e5a07/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 5d11227..436ee15 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -127,6 +127,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 18, 0, 36, 0, 38); // ;
         assertMapping(node, 0, 27, 0, 45, 0, 47); // ;
         assertMapping(node, 0, 32, 0, 50, 0, 52); // )
+        assertMapping(node, 0, 34, 0, 52, 0, 53); // {
     }
 
     @Test
@@ -153,6 +154,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 5, 0, 5, 0, 6); // ;
         assertMapping(node, 0, 6, 0, 6, 0, 7); // ;
         assertMapping(node, 0, 7, 0, 7, 0, 9); // )
+        assertMapping(node, 0, 9, 0, 9, 0, 10); // {
     }
 
     @Test
@@ -165,6 +167,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 0, 0, 0, 0, 5);    // for (
         assertMapping(node, 0, 14, 0, 32, 0, 36); // in
         assertMapping(node, 0, 21, 0, 39, 0, 41); // )
+        assertMapping(node, 0, 23, 0, 41, 0, 42); // {
     }
 
     @Test
@@ -235,6 +238,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
         assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
         assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
+        assertMapping(node, 0, 7, 0, 7, 0, 8);    // {
     }
 
     @Test
@@ -247,7 +251,9 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
         assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
         assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
+        assertMapping(node, 0, 7, 0, 7, 0, 8);    // {
         assertMapping(node, 0, 16, 2, 2, 2, 7);   // else
+        assertMapping(node, 0, 21, 2, 7, 2, 8);   // {
     }
 
     @Test
@@ -261,9 +267,12 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
         assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
         assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
+        assertMapping(node, 0, 7, 0, 7, 0, 8);    // {
         assertMapping(node, 0, 16, 2, 2, 2, 11);  // else if(
         assertMapping(node, 0, 26, 2, 12, 2, 14); // )
+        assertMapping(node, 0, 28, 2, 14, 2, 15); // {
         assertMapping(node, 0, 37, 4, 2, 4, 7);   // else
+        assertMapping(node, 0, 42, 4, 7, 4, 8);    // {
     }
 
     @Test


[3/9] git commit: [flex-falcon] [refs/heads/develop] - compiler.jx: curly braces to open and close blocks have been moved to the emitter

Posted by jo...@apache.org.
compiler.jx: curly braces to open and close blocks have been moved to the emitter


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

Branch: refs/heads/develop
Commit: 8c393616b508426fa621e20c8d2b10d7a473b721
Parents: a9a399b
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 15:17:13 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 15:17:13 2016 -0700

----------------------------------------------------------------------
 .../org/apache/flex/compiler/codegen/as/IASEmitter.java |  6 +++++-
 .../internal/codegen/as/ASAfterNodeStrategy.java        |  4 ++--
 .../internal/codegen/as/ASBeforeNodeStrategy.java       |  4 ++--
 .../flex/compiler/internal/codegen/as/ASEmitter.java    | 12 ++++++++++++
 4 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8c393616/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
index bd0d1eb..2fe9eea 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
@@ -86,7 +86,7 @@ public interface IASEmitter extends IEmitter
     void setDocEmitter(IDocEmitter value);
 
     String postProcess(String output);
-    
+
     void emitImport(IImportNode node);
 
     void emitPackageHeader(IPackageDefinition definition);
@@ -366,4 +366,8 @@ public interface IASEmitter extends IEmitter
 
     void emitUseNamespace(IUseNamespaceNode node);
 
+    void emitBlockOpen(IContainerNode node);
+
+    void emitBlockClose(IContainerNode node);
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8c393616/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASAfterNodeStrategy.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASAfterNodeStrategy.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASAfterNodeStrategy.java
index 1ac85f7..b274b57 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASAfterNodeStrategy.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASAfterNodeStrategy.java
@@ -59,10 +59,10 @@ public class ASAfterNodeStrategy implements IASNodeStrategy
                 if (node.getChildCount() != 0)
                 {
                     emitter.indentPop();
-                    ((IEmitter) emitter).writeNewline();
+                    emitter.writeNewline();
                 }
 
-                ((IEmitter) emitter).write(ASEmitterTokens.BLOCK_CLOSE);
+                emitter.emitBlockClose(container);
             }
             else if (type == ContainerType.IMPLICIT
                     || type == ContainerType.SYNTHESIZED)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8c393616/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBeforeNodeStrategy.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBeforeNodeStrategy.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBeforeNodeStrategy.java
index d481573..d960057 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBeforeNodeStrategy.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBeforeNodeStrategy.java
@@ -61,12 +61,12 @@ public class ASBeforeNodeStrategy implements IASNodeStrategy
             if (type != ContainerType.IMPLICIT
                     && type != ContainerType.SYNTHESIZED)
             {
-                ((IEmitter) emitter).write(ASEmitterTokens.BLOCK_OPEN);
+                emitter.emitBlockOpen(container);
             }
 
             if (parent.getNodeID() != ASTNodeID.LabledStatementID)
             {
-                ((IEmitter) emitter).writeNewline();
+                emitter.writeNewline();
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8c393616/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 875d1d2..6f48f8e 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
@@ -1524,6 +1524,18 @@ public class ASEmitter implements IASEmitter, IEmitter
     }
 
     @Override
+    public void emitBlockOpen(IContainerNode node)
+    {
+        write(ASEmitterTokens.BLOCK_OPEN);
+    }
+
+    @Override
+    public void emitBlockClose(IContainerNode node)
+    {
+        write(ASEmitterTokens.BLOCK_CLOSE);
+    }
+
+    @Override
     public String stringifyNode(IASNode node)
     {
         boolean oldBufferWrite = isBufferWrite();


[2/9] git commit: [flex-falcon] [refs/heads/develop] - compiler.jx.tests: added some tests for if statement source maps

Posted by jo...@apache.org.
compiler.jx.tests: added some tests for if statement source maps


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

Branch: refs/heads/develop
Commit: a9a399be7217b2632d41916a6338a0b4e1310ecd
Parents: e36c544
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 14:58:23 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 14:58:23 2016 -0700

----------------------------------------------------------------------
 .../js/sourcemaps/TestSourceMapStatements.java  | 104 +++++++++++++++++++
 1 file changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9a399be/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 8f4cf77..5d11227 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -4,6 +4,7 @@ import org.apache.flex.compiler.driver.IBackend;
 import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend;
 import org.apache.flex.compiler.internal.test.SourceMapTestBase;
 import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
 
 import org.junit.Test;
@@ -178,6 +179,109 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 21, 0, 39, 0, 40); // )
     }
 
+    //----------------------------------
+    // if ()
+    //----------------------------------
+
+    @Test
+    public void testVisitIf_1()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) b++;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a)\n  b++;
+        assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
+        assertMapping(node, 0, 5, 0, 5, 0, 6);    // )
+    }
+
+    @Test
+    public void testVisitIf_2()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) b++; else c++;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a)\n  b++;\nelse\n  c++;
+        assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
+        assertMapping(node, 0, 5, 0, 5, 0, 6);    // )
+        assertMapping(node, 0, 12, 2, 0, 2, 4);   // else
+    }
+
+    @Test
+    public void testVisitIf_4()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) b++; else if (c) d++; else if(e) --f;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a)\n  b++;\nelse if (c)\n  d++;\nelse if (e)\n  --f;
+        assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
+        assertMapping(node, 0, 5, 0, 5, 0, 6);    // )
+        assertMapping(node, 0, 12, 2, 0, 2, 9);   // else if (
+        assertMapping(node, 0, 22, 2, 10, 2, 11); // )
+        assertMapping(node, 0, 29, 4, 0, 4, 9);   // else if (
+        assertMapping(node, 0, 38, 4, 10, 4, 11); // )
+    }
+
+    //----------------------------------
+    // if () { }
+    //----------------------------------
+
+    @Test
+    public void testVisitIf_1a()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) { b++; }", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a) {\n  b++;\n}
+        assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
+        assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
+    }
+
+    @Test
+    public void testVisitIf_1b()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) { b++; } else { c++; }",
+                IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a) {\n  b++;\n} else {\n  c++;\n}
+        assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
+        assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
+        assertMapping(node, 0, 16, 2, 2, 2, 7);   // else
+    }
+
+    @Test
+    public void testVisitIf_1c()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) { b++; } else if (b) { c++; } else { d++; }",
+                IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a) {\n  b++;\n} else if (b) {\n  c++;\n} else {\n  d++;\n}
+        assertMapping(node, 0, 0, 0, 0, 0, 4);    // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
+        assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
+        assertMapping(node, 0, 16, 2, 2, 2, 11);  // else if(
+        assertMapping(node, 0, 26, 2, 12, 2, 14); // )
+        assertMapping(node, 0, 37, 4, 2, 4, 7);   // else
+    }
+
+    @Test
+    public void testVisitIf_3()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) b++; else if (c) d++; else --e;", IIfNode.class);
+        asBlockWalker.visitIf(node);
+        //if (a)\n  b++;\nelse if (c)\n  d++;\nelse\n  --e;
+        assertMapping(node, 0, 0, 0, 0, 0, 4);     // if (
+        assertMapping(node, 0, 4, 0, 4, 0, 5);     // a
+        assertMapping(node, 0, 5, 0, 5, 0, 6);     // )
+        assertMapping(node, 0, 12, 2, 0, 2, 9);    // else if (
+        assertMapping(node, 0, 21, 2, 9, 2, 10);   // c
+        assertMapping(node, 0, 22, 2, 10, 2, 11);  // )
+        assertMapping(node, 0, 29, 4, 0, 4, 4);    // else
+    }
+
     protected IBackend createBackend()
     {
         return new FlexJSBackend();


[4/9] git commit: [flex-falcon] [refs/heads/develop] - JSEmitter: overrides emitBlockOpen() and emitBlockClose() so that it can generate source maps

Posted by jo...@apache.org.
JSEmitter: overrides emitBlockOpen() and emitBlockClose() so that it can generate source maps


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

Branch: refs/heads/develop
Commit: 6705005c66ea099c9c3e8010731731ac50d931d0
Parents: 8c39361
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 15:42:33 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 15:42:33 2016 -0700

----------------------------------------------------------------------
 .../compiler/internal/codegen/js/JSEmitter.java | 18 ++++++++
 .../codegen/js/jx/BlockCloseEmitter.java        | 43 ++++++++++++++++++++
 .../codegen/js/jx/BlockOpenEmitter.java         | 43 ++++++++++++++++++++
 3 files changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6705005c/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 a50e288..1a73cf6 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
@@ -30,6 +30,8 @@ import org.apache.flex.compiler.common.ISourceLocation;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitter;
 import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.jx.BlockCloseEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.BlockOpenEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.DoWhileLoopEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.DynamicAccessEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.ForLoopEmitter;
@@ -82,6 +84,8 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
 {
     private JSSessionModel model;
     
+    public BlockOpenEmitter blockOpenEmitter;
+    public BlockCloseEmitter blockCloseEmitter;
     public NumericLiteralEmitter numericLiteralEmitter;
     public ParametersEmitter parametersEmitter;
     public ParameterEmitter parameterEmitter;
@@ -126,6 +130,8 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
         model = new JSSessionModel();
         sourceMapMappings = new ArrayList<SourceMapMapping>();
 
+        blockOpenEmitter = new BlockOpenEmitter(this);
+        blockCloseEmitter = new BlockCloseEmitter(this);
         numericLiteralEmitter = new NumericLiteralEmitter(this);
         parametersEmitter = new ParametersEmitter(this);
         parameterEmitter = new ParameterEmitter(this);
@@ -305,6 +311,18 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
         interationFlowEmitter.emit(node);
     }
 
+    @Override
+    public void emitBlockOpen(IContainerNode node)
+    {
+        blockOpenEmitter.emit(node);
+    }
+
+    @Override
+    public void emitBlockClose(IContainerNode node)
+    {
+        blockCloseEmitter.emit(node);
+    }
+
     public void pushSourceMapName(ISourceLocation node)
     {
         boolean isValidMappingScope = node instanceof ITypeNode

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6705005c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
new file mode 100644
index 0000000..3099eda
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+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.as.IContainerNode;
+
+public class BlockCloseEmitter extends JSSubEmitter implements
+        ISubEmitter<IContainerNode>
+{
+    public BlockCloseEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IContainerNode node)
+    {
+        startMapping(node);
+        write(ASEmitterTokens.BLOCK_CLOSE);
+        endMapping(node);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6705005c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockOpenEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockOpenEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockOpenEmitter.java
new file mode 100644
index 0000000..5487d9c
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockOpenEmitter.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+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.as.IContainerNode;
+
+public class BlockOpenEmitter extends JSSubEmitter implements
+        ISubEmitter<IContainerNode>
+{
+    public BlockOpenEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IContainerNode node)
+    {
+        startMapping(node, node.getLine(), node.getColumn() - 1);
+        write(ASEmitterTokens.BLOCK_OPEN);
+        endMapping(node);
+    }
+}


[9/9] git commit: [flex-falcon] [refs/heads/develop] - compiler.jx.tests: expanded source map tests to include some missing mappings

Posted by jo...@apache.org.
compiler.jx.tests: expanded source map tests to include some missing mappings


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

Branch: refs/heads/develop
Commit: e9fd628e5305a651f4cf0be0b744b885aee68b39
Parents: 01629b2
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 23:27:10 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 23:27:10 2016 -0700

----------------------------------------------------------------------
 .../js/sourcemaps/TestSourceMapExpressions.java | 181 +++++++++++--------
 .../js/sourcemaps/TestSourceMapStatements.java  |  19 +-
 2 files changed, 124 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e9fd628e/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
index 57ab17b..90aab08 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
@@ -31,7 +31,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a + b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // +
     }
 
     @Test
@@ -39,7 +39,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a - b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // -
     }
 
     @Test
@@ -47,7 +47,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a / b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // /
     }
 
     @Test
@@ -55,7 +55,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a % b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // %
     }
 
     @Test
@@ -63,7 +63,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a * b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // *
     }
 
     @Test
@@ -71,7 +71,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("a++");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 3);
+        assertMapping(node, 0, 1, 0, 1, 0, 3); // ++
     }
 
     @Test
@@ -79,7 +79,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("++a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 2);
+        assertMapping(node, 0, 0, 0, 0, 0, 2); // +
     }
 
     @Test
@@ -87,7 +87,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("a--");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 3);
+        assertMapping(node, 0, 1, 0, 1, 0, 3); // --
     }
 
     @Test
@@ -95,7 +95,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("--a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 2);
+        assertMapping(node, 0, 0, 0, 0, 0, 2); // --
     }
 
     //----------------------------------
@@ -151,7 +151,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a = b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // =
     }
 
     //----------------------------------
@@ -163,7 +163,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a & b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // &
     }
 
     @Test
@@ -171,7 +171,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a << b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // <<
     }
 
     @Test
@@ -179,7 +179,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("~a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 1);
+        assertMapping(node, 0, 0, 0, 0, 0, 1); // ~
     }
 
     @Test
@@ -187,7 +187,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a | b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // |
     }
 
     @Test
@@ -195,7 +195,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a >> b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // >>
     }
 
     @Test
@@ -203,7 +203,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a >>> b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 6);
+        assertMapping(node, 0, 1, 0, 1, 0, 6); // >>>
     }
 
     @Test
@@ -211,7 +211,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a ^ b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // ^
     }
 
     //----------------------------------
@@ -275,7 +275,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a == b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // ==
     }
 
     @Test
@@ -283,7 +283,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a > b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // >
     }
 
     @Test
@@ -291,7 +291,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a >= b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // >=
     }
 
     @Test
@@ -299,7 +299,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a != b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // !=
     }
 
     @Test
@@ -307,7 +307,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a < b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // <
     }
 
     @Test
@@ -315,7 +315,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a <= b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // <=
     }
 
     @Test
@@ -323,7 +323,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a === b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 6);
+        assertMapping(node, 0, 1, 0, 1, 0, 6); // ===
     }
 
     @Test
@@ -331,7 +331,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a !== b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 6);
+        assertMapping(node, 0, 1, 0, 1, 0, 6); // !==
     }
 
     //----------------------------------
@@ -343,7 +343,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a && b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // &&
     }
 
     @Test
@@ -352,8 +352,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IBinaryOperatorNode node = getBinaryNode("a &&= b");
         asBlockWalker.visitBinaryOperator(node);
         //a = a && b
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
-        assertMapping(node, 0, 1, 0, 5, 0, 9);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // =
+        assertMapping(node, 0, 1, 0, 5, 0, 9); // &&
     }
 
     @Test
@@ -361,7 +361,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("!a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 1);
+        assertMapping(node, 0, 0, 0, 0, 0, 1); // !
     }
 
     @Test
@@ -369,7 +369,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a || b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // ||
     }
 
     @Test
@@ -378,8 +378,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IBinaryOperatorNode node = getBinaryNode("a ||= b");
         asBlockWalker.visitBinaryOperator(node);
         //a = a || b
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
-        assertMapping(node, 0, 1, 0, 5, 0, 9);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // =
+        assertMapping(node, 0, 1, 0, 5, 0, 9); // ||
     }
 
     //----------------------------------
@@ -391,8 +391,10 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IDynamicAccessNode node = getDynamicAccessNode("a[b]");
         asBlockWalker.visitDynamicAccess(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
-        assertMapping(node, 0, 3, 0, 3, 0, 4);
+        assertMapping(node, 0, 0, 0, 0, 0, 1); // a
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // [
+        assertMapping(node, 0, 2, 0, 2, 0, 3); // b
+        assertMapping(node, 0, 3, 0, 3, 0, 4); // ]
     }
 
     @Test
@@ -400,12 +402,16 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IDynamicAccessNode node = getDynamicAccessNode("a[b[c][d]]");
         asBlockWalker.visitDynamicAccess(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
-        assertMapping(node, 0, 3, 0, 3, 0, 4);
-        assertMapping(node, 0, 5, 0, 5, 0, 6);
-        assertMapping(node, 0, 6, 0, 6, 0, 7);
-        assertMapping(node, 0, 8, 0, 8, 0, 9);
-        assertMapping(node, 0, 9, 0, 9, 0, 10);
+        assertMapping(node, 0, 0, 0, 0, 0, 1);   // a
+        assertMapping(node, 0, 1, 0, 1, 0, 2);   // [
+        assertMapping(node, 0, 2, 0, 2, 0, 3);   // b
+        assertMapping(node, 0, 3, 0, 3, 0, 4);   // [
+        assertMapping(node, 0, 4, 0, 4, 0, 5);   // c
+        assertMapping(node, 0, 5, 0, 5, 0, 6);   // ]
+        assertMapping(node, 0, 6, 0, 6, 0, 7);   // [
+        assertMapping(node, 0, 7, 0, 7, 0, 8);   // d
+        assertMapping(node, 0, 8, 0, 8, 0, 9);   // ]
+        assertMapping(node, 0, 9, 0, 9, 0, 10);  // ]
     }
 
     @Test
@@ -413,7 +419,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a, b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 3);
+        assertMapping(node, 0, 1, 0, 1, 0, 3); // ,
     }
 
     @Test
@@ -422,8 +428,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         ITernaryOperatorNode node = (ITernaryOperatorNode) getExpressionNode(
                 "a ? b : c", ITernaryOperatorNode.class);
         asBlockWalker.visitTernaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 4);
-        assertMapping(node, 0, 5, 0, 5, 0, 8);
+        assertMapping(node, 0, 1, 0, 1, 0, 4); // ?
+        assertMapping(node, 0, 5, 0, 5, 0, 8); // :
     }
 
     @Test
@@ -431,7 +437,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("delete a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 7);
+        assertMapping(node, 0, 0, 0, 0, 0, 7); // delete
     }
 
     @Test
@@ -440,7 +446,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IMemberAccessExpressionNode node = (IMemberAccessExpressionNode) getExpressionNode(
                 "a.b", IMemberAccessExpressionNode.class);
         asBlockWalker.visitMemberAccessExpression(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // .
     }
 
     @Test
@@ -449,9 +455,9 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IMemberAccessExpressionNode node = (IMemberAccessExpressionNode) getExpressionNode(
                 "a.b.c.d", IMemberAccessExpressionNode.class);
         asBlockWalker.visitMemberAccessExpression(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
-        assertMapping(node, 0, 3, 0, 3, 0, 4);
-        assertMapping(node, 0, 5, 0, 5, 0, 6);
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // .
+        assertMapping(node, 0, 3, 0, 3, 0, 4); // .
+        assertMapping(node, 0, 5, 0, 5, 0, 6); // .
     }
 
     @Test
@@ -459,7 +465,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a in b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 5);
+        assertMapping(node, 0, 1, 0, 1, 0, 5); // in
     }
 
     @Test
@@ -467,7 +473,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IBinaryOperatorNode node = getBinaryNode("a instanceof b");
         asBlockWalker.visitBinaryOperator(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 13);
+        assertMapping(node, 0, 1, 0, 1, 0, 13); // instanceof
     }
 
     @Test
@@ -476,7 +482,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IFunctionCallNode node = (IFunctionCallNode) getExpressionNode(
                 "new Object()", IFunctionCallNode.class);
         asBlockWalker.visitFunctionCall(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 4);
+        assertMapping(node, 0, 0, 0, 0, 0, 4); // new
     }
 
     @Test
@@ -485,6 +491,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         ObjectLiteralNode node = (ObjectLiteralNode) getExpressionNode(
                 "a = {a:1}", ObjectLiteralNode.class);
         asBlockWalker.visitLiteral(node);
+        //{a: 1}
         assertMapping(node, 0, 0, 0, 0, 0, 1); // {
         assertMapping(node, 0, 1, 0, 1, 0, 2); // a
         assertMapping(node, 0, 2, 0, 2, 0, 3); // :
@@ -536,6 +543,24 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     }
 
     @Test
+    public void testVisitObjectLiteral_4()
+    {
+        ObjectLiteralNode node = (ObjectLiteralNode) getExpressionNode(
+                "a = {a:1,\nb:2}", ObjectLiteralNode.class);
+        asBlockWalker.visitLiteral(node);
+        //{a:1, b:2}
+        assertMapping(node, 0, 0, 0, 0, 0, 1);   // {
+        assertMapping(node, 0, 1, 0, 1, 0, 2);   // a
+        assertMapping(node, 0, 2, 0, 2, 0, 3);   // :
+        assertMapping(node, 0, 3, 0, 3, 0, 4);   // 1
+        assertMapping(node, 0, 4, 0, 4, 0, 6);   // ,
+        assertMapping(node, 1, 0, 0, 6, 0, 7);   // b
+        assertMapping(node, 1, 1, 0, 7, 0, 8);   // :
+        assertMapping(node, 1, 2, 0, 8, 0, 9);   // 2
+        assertMapping(node, 1, 3, 0, 9, 0, 10);  // }
+    }
+
+    @Test
     public void testVisitArrayLiteral_1()
     {
         ArrayLiteralNode node = (ArrayLiteralNode) getExpressionNode(
@@ -543,8 +568,11 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         asBlockWalker.visitLiteral(node);
         //[0, 1, 2]
         assertMapping(node, 0, 0, 0, 0, 0, 1); // [
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // 0
         assertMapping(node, 0, 2, 0, 2, 0, 4); // ,
+        assertMapping(node, 0, 3, 0, 4, 0, 5); // 1
         assertMapping(node, 0, 4, 0, 5, 0, 7); // ,
+        assertMapping(node, 0, 5, 0, 7, 0, 8); // 2
         assertMapping(node, 0, 6, 0, 8, 0, 9); // ]
     }
 
@@ -598,8 +626,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         assertMapping(node, 0, 2, 0, 2, 0, 4);    // ,
         assertMapping(node, 1, 0, 0, 4, 0, 7);    // 123
         assertMapping(node, 1, 3, 0, 7, 0, 9);    // ,
-        assertMapping(node, 1, 5, 0, 9, 0, 11);    // 45
-        //TODO: figure out how to place the ] 
+        assertMapping(node, 1, 5, 0, 9, 0, 11);   // 45
+        assertMapping(node, 1, 7, 0, 11, 0, 12);  // 45
     }
 
     @Test
@@ -607,8 +635,9 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("typeof(a)");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 7);
-        assertMapping(node, 0, 0, 0, 8, 0, 9);
+        //typeof(a)
+        assertMapping(node, 0, 0, 0, 0, 0, 7); // typeof(
+        assertMapping(node, 0, 0, 0, 8, 0, 9); // )
     }
 
     @Test
@@ -617,8 +646,9 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         // TODO (mschmalle) the notation without parenthesis is also valid in AS/JS
         IUnaryOperatorNode node = getUnaryNode("typeof a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 7);
-        assertMapping(node, 0, 0, 0, 8, 0, 9);
+        //typeof(a)
+        assertMapping(node, 0, 0, 0, 0, 0, 7); // typeof(
+        assertMapping(node, 0, 0, 0, 8, 0, 9); // )
     }
 
     @Test
@@ -626,7 +656,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IUnaryOperatorNode node = getUnaryNode("void a");
         asBlockWalker.visitUnaryOperator(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 5);
+        assertMapping(node, 0, 0, 0, 0, 0, 5); // void
     }
 
     @Test
@@ -635,7 +665,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IIterationFlowNode node = (IIterationFlowNode) getNode("break",
                 IIterationFlowNode.class);
         asBlockWalker.visitIterationFlow(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 5);
+        assertMapping(node, 0, 0, 0, 0, 0, 5); // break
     }
 
     @Test
@@ -644,7 +674,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IIterationFlowNode node = (IIterationFlowNode) getNode("break label",
                 IIterationFlowNode.class);
         asBlockWalker.visitIterationFlow(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 6);
+        assertMapping(node, 0, 0, 0, 0, 0, 6);  // break
+        assertMapping(node, 0, 6, 0, 6, 0, 11); // label
     }
 
     @Test
@@ -653,7 +684,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IIterationFlowNode node = (IIterationFlowNode) getNode("continue",
                 IIterationFlowNode.class);
         asBlockWalker.visitIterationFlow(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 8);
+        assertMapping(node, 0, 0, 0, 0, 0, 8); // continue
     }
 
     @Test
@@ -662,7 +693,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
         IIterationFlowNode node = (IIterationFlowNode) getNode("continue label",
                 IIterationFlowNode.class);
         asBlockWalker.visitIterationFlow(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 9);
+        assertMapping(node, 0, 0, 0, 0, 0, 9); // continue
+        assertMapping(node, 0, 9, 0, 9, 0, 14); // label
     }
 
     @Test
@@ -670,7 +702,7 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IReturnNode node = (IReturnNode) getNode("return", IReturnNode.class);
         asBlockWalker.visitReturn(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 6);
+        assertMapping(node, 0, 0, 0, 0, 0, 6); // return
     }
 
     @Test
@@ -678,7 +710,8 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IReturnNode node = (IReturnNode) getNode("return 0", IReturnNode.class);
         asBlockWalker.visitReturn(node);
-        assertMapping(node, 0, 0, 0, 0, 0, 7);
+        assertMapping(node, 0, 0, 0, 0, 0, 7); // return
+        assertMapping(node, 0, 7, 0, 7, 0, 8); // 0
     }
 
     @Test
@@ -686,8 +719,9 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IFunctionCallNode node = (IFunctionCallNode) getNode("a()", IFunctionCallNode.class);
         asBlockWalker.visitFunctionCall(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
-        assertMapping(node, 0, 2, 0, 2, 0, 3);
+        assertMapping(node, 0, 0, 0, 0, 0, 1); // a
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // (
+        assertMapping(node, 0, 2, 0, 2, 0, 3); // )
     }
 
     @Test
@@ -695,8 +729,10 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IFunctionCallNode node = (IFunctionCallNode) getNode("a(b)", IFunctionCallNode.class);
         asBlockWalker.visitFunctionCall(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
-        assertMapping(node, 0, 3, 0, 3, 0, 4);
+        assertMapping(node, 0, 0, 0, 0, 0, 1); // a
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // (
+        assertMapping(node, 0, 2, 0, 2, 0, 3); // b
+        assertMapping(node, 0, 3, 0, 3, 0, 4); // )
     }
 
     @Test
@@ -704,9 +740,12 @@ public class TestSourceMapExpressions extends SourceMapTestBase
     {
         IFunctionCallNode node = (IFunctionCallNode) getNode("a(b, c)", IFunctionCallNode.class);
         asBlockWalker.visitFunctionCall(node);
-        assertMapping(node, 0, 1, 0, 1, 0, 2);
-        assertMapping(node, 0, 3, 0, 3, 0, 5);
-        assertMapping(node, 0, 6, 0, 6, 0, 7);
+        assertMapping(node, 0, 0, 0, 0, 0, 1); // a
+        assertMapping(node, 0, 1, 0, 1, 0, 2); // (
+        assertMapping(node, 0, 2, 0, 2, 0, 3); // b
+        assertMapping(node, 0, 3, 0, 3, 0, 5); // ,
+        assertMapping(node, 0, 5, 0, 5, 0, 6); // c
+        assertMapping(node, 0, 6, 0, 6, 0, 7); // )
     }
 
     protected IBackend createBackend()

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e9fd628e/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 436ee15..265b94c 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -128,6 +128,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 27, 0, 45, 0, 47); // ;
         assertMapping(node, 0, 32, 0, 50, 0, 52); // )
         assertMapping(node, 0, 34, 0, 52, 0, 53); // {
+        assertMapping(node, 0, 43, 2, 0, 2, 1);   // }
     }
 
     @Test
@@ -150,11 +151,12 @@ public class TestSourceMapStatements extends SourceMapTestBase
                 IForLoopNode.class);
         asBlockWalker.visitForLoop(node);
         //for (;;) {\n  break;\n}
-        assertMapping(node, 0, 0, 0, 0, 0, 5); // for (
-        assertMapping(node, 0, 5, 0, 5, 0, 6); // ;
-        assertMapping(node, 0, 6, 0, 6, 0, 7); // ;
-        assertMapping(node, 0, 7, 0, 7, 0, 9); // )
+        assertMapping(node, 0, 0, 0, 0, 0, 5);  // for (
+        assertMapping(node, 0, 5, 0, 5, 0, 6);  // ;
+        assertMapping(node, 0, 6, 0, 6, 0, 7);  // ;
+        assertMapping(node, 0, 7, 0, 7, 0, 9);  // )
         assertMapping(node, 0, 9, 0, 9, 0, 10); // {
+        assertMapping(node, 0, 18, 2, 0, 2, 1); // }
     }
 
     @Test
@@ -168,6 +170,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 14, 0, 32, 0, 36); // in
         assertMapping(node, 0, 21, 0, 39, 0, 41); // )
         assertMapping(node, 0, 23, 0, 41, 0, 42); // {
+        assertMapping(node, 0, 32, 2, 0, 2, 1);   // }
     }
 
     @Test
@@ -239,6 +242,7 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
         assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
         assertMapping(node, 0, 7, 0, 7, 0, 8);    // {
+        assertMapping(node, 0, 14, 2, 0, 2, 1);   // }
     }
 
     @Test
@@ -252,8 +256,10 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
         assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
         assertMapping(node, 0, 7, 0, 7, 0, 8);    // {
+        assertMapping(node, 0, 14, 2, 0, 2, 1);   // }
         assertMapping(node, 0, 16, 2, 2, 2, 7);   // else
         assertMapping(node, 0, 21, 2, 7, 2, 8);   // {
+        assertMapping(node, 0, 28, 4, 0, 4, 1);   // }
     }
 
     @Test
@@ -268,11 +274,14 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 4, 0, 4, 0, 5);    // a
         assertMapping(node, 0, 5, 0, 5, 0, 7);    // )
         assertMapping(node, 0, 7, 0, 7, 0, 8);    // {
+        assertMapping(node, 0, 14, 2, 0, 2, 1);   // }
         assertMapping(node, 0, 16, 2, 2, 2, 11);  // else if(
         assertMapping(node, 0, 26, 2, 12, 2, 14); // )
         assertMapping(node, 0, 28, 2, 14, 2, 15); // {
+        assertMapping(node, 0, 35, 4, 0, 4, 1);   // }
         assertMapping(node, 0, 37, 4, 2, 4, 7);   // else
-        assertMapping(node, 0, 42, 4, 7, 4, 8);    // {
+        assertMapping(node, 0, 42, 4, 7, 4, 8);   // {
+        assertMapping(node, 0, 49, 6, 0, 6, 1);   // {
     }
 
     @Test


[8/9] git commit: [flex-falcon] [refs/heads/develop] - compiler.jx: updated JSEmitter to support new getEndLine() and getEndColumn(), and tweaked some sub-emitters to use this change

Posted by jo...@apache.org.
compiler.jx: updated JSEmitter to support new getEndLine() and getEndColumn(), and tweaked some sub-emitters to use this change


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

Branch: refs/heads/develop
Commit: 01629b238544b16f934a91e863f0300956ba6d94
Parents: af3e883
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 22:46:54 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 22:46:54 2016 -0700

----------------------------------------------------------------------
 .../org/apache/flex/compiler/codegen/js/IJSEmitter.java   |  2 +-
 .../flex/compiler/internal/codegen/js/JSEmitter.java      | 10 +++++-----
 .../flex/compiler/internal/codegen/js/JSSubEmitter.java   |  4 ++--
 .../internal/codegen/js/jx/BlockCloseEmitter.java         |  2 +-
 .../internal/codegen/js/jx/LiteralContainerEmitter.java   |  2 +-
 .../codegen/js/jx/ObjectLiteralValuePairEmitter.java      |  6 +++---
 6 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/01629b23/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
index 218b5be..287b8c8 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
@@ -59,7 +59,7 @@ public interface IJSEmitter extends IASEmitter
      * Adds a node to the source map after a particular node instead using the
      * node's own line and column.
      */
-    void startMapping(ISourceLocation node, ISourceLocation nodeBeforeMapping);
+    void startMapping(ISourceLocation node, ISourceLocation afterNode);
 
     /**
      * Commits a mapping to the source map.

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/01629b23/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 1a73cf6..d0a4aa8 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
@@ -366,11 +366,6 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
     {
         startMapping(node, node.getLine(), node.getColumn());
     }
-
-    public void startMapping(ISourceLocation node, ISourceLocation nodeBeforeMapping)
-    {
-        startMapping(node, nodeBeforeMapping.getLine(), nodeBeforeMapping.getColumn() + nodeBeforeMapping.getAbsoluteEnd() - nodeBeforeMapping.getAbsoluteStart());
-    }
     
     public void startMapping(ISourceLocation node, int line, int column)
     {
@@ -414,6 +409,11 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
         lastMapping = mapping;
     }
 
+    public void startMapping(ISourceLocation node, ISourceLocation afterNode)
+    {
+        startMapping(node, afterNode.getEndLine(), afterNode.getEndColumn());
+    }
+
     public void endMapping(ISourceLocation node)
     {
         if (lastMapping == null)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/01629b23/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
index be0b9d1..f947af6 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSSubEmitter.java
@@ -114,9 +114,9 @@ public class JSSubEmitter
         emitter.startMapping(node, line, column);
     }
 
-    protected void startMapping(ISourceLocation node, ISourceLocation nodeBeforeMapping)
+    protected void startMapping(ISourceLocation node, ISourceLocation afterNode)
     {
-        emitter.startMapping(node, nodeBeforeMapping);
+        emitter.startMapping(node, afterNode);
     }
 
     protected void endMapping(ISourceLocation node)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/01629b23/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
index 3099eda..058d132 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BlockCloseEmitter.java
@@ -36,7 +36,7 @@ public class BlockCloseEmitter extends JSSubEmitter implements
     @Override
     public void emit(IContainerNode node)
     {
-        startMapping(node);
+        startMapping(node, node);
         write(ASEmitterTokens.BLOCK_CLOSE);
         endMapping(node);
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/01629b23/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
index d1d24fd..5e0fdce 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralContainerEmitter.java
@@ -88,7 +88,7 @@ public class LiteralContainerEmitter extends JSSubEmitter implements
 
         if (postFix != null)
         {
-            startMapping(node, node.getLine(), node.getColumn() + node.getAbsoluteEnd() - node.getAbsoluteStart() - 1);
+            startMapping(node, node.getEndLine(), node.getEndColumn() - postFix.length());
             write(postFix);
             endMapping(node);
         }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/01629b23/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ObjectLiteralValuePairEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ObjectLiteralValuePairEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ObjectLiteralValuePairEmitter.java
index d93d701..ad12b77 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ObjectLiteralValuePairEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ObjectLiteralValuePairEmitter.java
@@ -38,14 +38,14 @@ public class ObjectLiteralValuePairEmitter extends JSSubEmitter implements
     @Override
     public void emit(IObjectLiteralValuePairNode node)
     {
-        ISourceLocation sourceLocationNode = (ISourceLocation) node;
+        ISourceLocation location = (ISourceLocation) node;
 
         IExpressionNode nameNode = node.getNameNode();
         getWalker().walk(nameNode);
 
-        startMapping(sourceLocationNode, nameNode);
+        startMapping(location, nameNode);
         write(ASEmitterTokens.COLON);
-        endMapping(sourceLocationNode);
+        endMapping(location);
 
         IExpressionNode valueNode = node.getValueNode();
         getWalker().walk(valueNode);


[7/9] git commit: [flex-falcon] [refs/heads/develop] - compiler: added getEndLine() and getEndColumn() to ISourceLocation

Posted by jo...@apache.org.
compiler: added getEndLine() and getEndColumn() to ISourceLocation


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

Branch: refs/heads/develop
Commit: af3e883d75a1e270d2174e35007f48698822085c
Parents: b2bfa2c
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 22:44:59 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 22:44:59 2016 -0700

----------------------------------------------------------------------
 .../flex/compiler/common/ISourceLocation.java   | 10 ++++
 .../flex/compiler/common/SourceLocation.java    | 54 ++++++++++++++++++++
 .../internal/definitions/metadata/MetaTag.java  | 12 +++++
 .../compiler/internal/parsing/TokenBase.java    | 44 ++++++++++++++++
 .../compiler/internal/tree/as/NodeBase.java     | 17 ++++--
 .../internal/tree/as/OperatorNodeBase.java      |  2 +
 .../flex/compiler/problems/CompilerProblem.java | 12 +++++
 7 files changed, 148 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java b/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
index 738bdf3..25f6b6d 100644
--- a/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
+++ b/compiler/src/org/apache/flex/compiler/common/ISourceLocation.java
@@ -64,6 +64,16 @@ public interface ISourceLocation
     int getColumn();
     
     /**
+     * Gets the local line number at the end. It is zero-based.
+     */
+    int getEndLine();
+
+    /**
+     * Gets the local column number at the end. It is zero-based.
+     */
+    int getEndColumn();
+    
+    /**
      * Gets the absolute starting offset. It is zero-based.
      */
     int getAbsoluteStart();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/common/SourceLocation.java b/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
index 88998b7..0d0e1b0 100644
--- a/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
+++ b/compiler/src/org/apache/flex/compiler/common/SourceLocation.java
@@ -37,6 +37,8 @@ public class SourceLocation implements ISourceLocation
         this.end = end;
         this.line = line;
         this.column = column;
+        this.endLine = UNKNOWN;
+        this.endColumn = UNKNOWN;
     }
     
     /**
@@ -93,6 +95,16 @@ public class SourceLocation implements ISourceLocation
      * Corresponds to start, not end.
      */
     private int column;
+
+    /**
+     * Zero-based line number that corresponds to end.
+     */
+    private int endLine;
+
+    /**
+     * Zero-based column number that corresponds to end.
+     */
+    private int endColumn;
     
     /**
      * Copies source location information from another instance
@@ -106,6 +118,8 @@ public class SourceLocation implements ISourceLocation
         this.end = src.getEnd();
         this.line = src.getLine();
         this.column = src.getColumn();
+        this.endLine = src.getEndLine();
+        this.endColumn = src.getEndColumn();
         this.sourcePath = src.getSourcePath();
     }
 
@@ -212,6 +226,44 @@ public class SourceLocation implements ISourceLocation
     }
 
     /**
+     * Get the line number where this node ends.
+     * Line numbers start at 0, not 1.
+     * @return The line number
+     */
+    public int getEndLine()
+    {
+        return endLine;
+    }
+
+    /**
+     * Set the line number where this node ends.
+     * Column numbers start at 0, not 1.
+     * @param line The line number
+     */
+    public void setEndLine(int line)
+    {
+        this.endLine = line;
+    }
+
+    /**
+     * Get the column number where this node ends.
+     * @return The column number
+     */
+    public int getEndColumn()
+    {
+        return endColumn;
+    }
+
+    /**
+     * Set the column number where this node ends.
+     * @param column The column number
+     */
+    public void setEndColumn(int column)
+    {
+        this.endColumn = column;
+    }
+
+    /**
      * Get the source path for this node.
      * @return The source path for this node
      */
@@ -346,6 +398,8 @@ public class SourceLocation implements ISourceLocation
         setEnd(end.getEnd());
         setLine(start.getLine());
         setColumn(start.getColumn());
+        setEndLine(end.getEndLine());
+        setEndColumn(end.getEndColumn());
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java b/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
index 92b9350..5b0b18e 100644
--- a/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
+++ b/compiler/src/org/apache/flex/compiler/internal/definitions/metadata/MetaTag.java
@@ -230,6 +230,18 @@ public class MetaTag implements IMetaTag
     }
 
     @Override
+    public int getEndLine()
+    {
+        return line;
+    }
+
+    @Override
+    public int getEndColumn()
+    {
+        return column;
+    }
+
+    @Override
     public int getAbsoluteStart()
     {
         return absoluteStart;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java b/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
index 68a76eb..ff726da 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/TokenBase.java
@@ -50,6 +50,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
         this.line = line;
         this.column = column;
         this.text = text;
+        this.endLine = line;
+        this.endColumn = column + end - start;
 
         if (Counter.COUNT_TOKENS)
             countTokens();
@@ -67,6 +69,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
         end = o.end;
         line = o.line;
         column = o.column;
+        endLine = o.endLine;
+        endColumn = o.endColumn;
         text = o.text;
 
         localStart = o.localStart;
@@ -103,6 +107,16 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
     private int column;
 
     /**
+     * End line of this token
+     */
+    private int endLine;
+
+    /**
+     * End column of this token
+     */
+    private int endColumn;
+
+    /**
      * Flag to determine if this token is locked
      */
     private boolean locked;
@@ -143,6 +157,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
         this.end = end;
         this.line = line;
         this.column = column;
+        this.endLine = line;
+        this.endColumn = column + end - start;
         this.text = text;
     }
 
@@ -222,6 +238,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
         this.end = end;
         this.line = line;
         this.column = column;
+        this.endLine = line;
+        this.endColumn = column + end - start;
     }
 
     @Override
@@ -275,6 +293,28 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
         this.column = column;
     }
 
+    @Override
+    public int getEndLine()
+    {
+        return endLine;
+    }
+
+    public void setEndLine(int line)
+    {
+        endLine = line;
+    }
+
+    @Override
+    public int getEndColumn()
+    {
+        return endColumn;
+    }
+
+    public void setEndColumn(int column)
+    {
+        endColumn = column;
+    }
+
     /**
      * Determine whether or not this token is bogus (i.e. the start and end
      * offsets are the same, which implies that it was inserted from an included
@@ -439,6 +479,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
         end += offsetAdjustment;
         line += lineAdjustment;
         column += columnAdjustment;
+        endLine += lineAdjustment;
+        endColumn += columnAdjustment;
     }
 
     /**
@@ -485,6 +527,8 @@ public abstract class TokenBase extends Token implements ICMToken, ISourceLocati
             assert getEnd() != UNKNOWN : "Token has unknown end: " + toString();
             assert getLine() != UNKNOWN : "Token has an unknown line: " + toString();
             assert getColumn() != UNKNOWN : "Token has an unknown column: " + toString();
+            assert getEndLine() != UNKNOWN : "Token has an unknown end line: " + toString();
+            assert getEndColumn() != UNKNOWN : "Token has an unknown end column: " + toString();
         }
 
         return true;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java b/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
index be0510d..8dd4fb6 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/as/NodeBase.java
@@ -337,7 +337,6 @@ public abstract class NodeBase extends SourceLocation implements IASNode
         if (token instanceof ISourceLocation)
         {
             startAfter((ISourceLocation) token);
-            setColumn(getColumn() + token.getText().length());
         }
     }
     
@@ -354,8 +353,8 @@ public abstract class NodeBase extends SourceLocation implements IASNode
         {
             setSourcePath(location.getSourcePath());
             setStart(end);
-            setLine(location.getLine());
-            setColumn(location.getColumn());
+            setLine(location.getEndLine());
+            setColumn(location.getEndColumn());
         }
     }
 
@@ -411,7 +410,11 @@ public abstract class NodeBase extends SourceLocation implements IASNode
     {
         final int end = location.getEnd();
         if (end != UNKNOWN)
+        {
             setEnd(end);
+            setEndLine(location.getEndLine());
+            setEndColumn(location.getEndColumn());
+        }
     }
 
     /**
@@ -436,7 +439,11 @@ public abstract class NodeBase extends SourceLocation implements IASNode
     {
         final int start = location.getStart();
         if (start != UNKNOWN)
+        {
             setEnd(start);
+            setEndLine(location.getLine());
+            setEndColumn(location.getColumn());
+        }
     }
 
     /**
@@ -620,7 +627,11 @@ public abstract class NodeBase extends SourceLocation implements IASNode
                 if (childEnd != -1)
                 {
                     if (end < childEnd)
+                    {
                         setEnd(childEnd);
+                        setEndLine(child.getEndLine());
+                        setEndColumn(child.getEndColumn());
+                    }
                     break;
                 }
             }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java b/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
index 5de6521..51eb0fc 100644
--- a/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
+++ b/compiler/src/org/apache/flex/compiler/internal/tree/as/OperatorNodeBase.java
@@ -41,6 +41,8 @@ public abstract class OperatorNodeBase extends ExpressionNodeBase implements IOp
             operatorStart = operator.getStart();
             setLine(operator.getLine());
             setColumn(operator.getColumn());
+            setEndLine(operator.getEndLine());
+            setEndColumn(operator.getEndColumn());
             setSourcePath(operator.getSourcePath());
         }
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/af3e883d/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java b/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
index ee9c9a1..d2e9366 100644
--- a/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
+++ b/compiler/src/org/apache/flex/compiler/problems/CompilerProblem.java
@@ -189,6 +189,18 @@ public abstract class CompilerProblem implements ICompilerProblem
     }
 
     @Override
+    public int getEndLine()
+    {
+        return line;
+    }
+
+    @Override
+    public int getEndColumn()
+    {
+        return column;
+    }
+
+    @Override
     public int getAbsoluteStart()
     {
         return start;


[6/9] git commit: [flex-falcon] [refs/heads/develop] - ASParser: array contents start after [ and before ], and ArrayLiteralNode includes them

Posted by jo...@apache.org.
ASParser: array contents start after [ and before ], and ArrayLiteralNode includes them


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

Branch: refs/heads/develop
Commit: b2bfa2c9a6a7da9ebe5363117f6e6438e5ddc6a4
Parents: c22e5a0
Author: Josh Tynjala <jo...@apache.org>
Authored: Sun Apr 17 19:39:31 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Sun Apr 17 19:39:31 2016 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/compiler/internal/parsing/as/ASParser.g  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b2bfa2c9/compiler/src/org/apache/flex/compiler/internal/parsing/as/ASParser.g
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/parsing/as/ASParser.g b/compiler/src/org/apache/flex/compiler/internal/parsing/as/ASParser.g
index 34cb240..4d4936b 100644
--- a/compiler/src/org/apache/flex/compiler/internal/parsing/as/ASParser.g
+++ b/compiler/src/org/apache/flex/compiler/internal/parsing/as/ASParser.g
@@ -2481,9 +2481,9 @@ arrayInitializer [ArrayLiteralNode node]
     {
         final ContainerNode contents = node.getContentsNode(); 
     }
-    :   open:TOKEN_SQUARE_OPEN            { contents.startBefore(open); }
+    :   open:TOKEN_SQUARE_OPEN            { node.startBefore(open); contents.startAfter(open); }
         arrayElements[contents]
-        close:TOKEN_SQUARE_CLOSE          { contents.endAfter(close); }
+        close:TOKEN_SQUARE_CLOSE          { node.endAfter(close); contents.endBefore(close); }
     ;	
     exception catch [RecognitionException ex] 
     {