flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [4/8] git commit: [flex-falcon] [refs/heads/develop] - source maps for with
Date Fri, 29 Apr 2016 23:18:51 GMT
source maps for with


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

Branch: refs/heads/develop
Commit: b20a5d5d189e931ff5e63ede5e856e93a250c500
Parents: b0ccb16
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Fri Apr 29 14:43:47 2016 -0700
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Fri Apr 29 14:43:47 2016 -0700

----------------------------------------------------------------------
 .../compiler/internal/codegen/js/JSEmitter.java | 10 ++++
 .../internal/codegen/js/jx/WithEmitter.java     | 56 ++++++++++++++++++++
 .../js/sourcemaps/TestSourceMapStatements.java  | 34 ++++++++++++
 3 files changed, 100 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b20a5d5d/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
index ece92d7..41ea685 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
@@ -56,6 +56,7 @@ import org.apache.flex.compiler.internal.codegen.js.jx.ThrowEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.TryEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.UnaryOperatorEmitter;
 import org.apache.flex.compiler.internal.codegen.js.jx.WhileLoopEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.WithEmitter;
 import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.flex.compiler.internal.tree.as.FunctionNode;
 import org.apache.flex.compiler.tree.as.IASNode;
@@ -84,6 +85,7 @@ import org.apache.flex.compiler.tree.as.ITypeNode;
 import org.apache.flex.compiler.tree.as.ITypedExpressionNode;
 import org.apache.flex.compiler.tree.as.IUnaryOperatorNode;
 import org.apache.flex.compiler.tree.as.IWhileLoopNode;
+import org.apache.flex.compiler.tree.as.IWithNode;
 
 import com.google.debugging.sourcemap.FilePosition;
 
@@ -116,6 +118,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
     public ISubEmitter<ITryNode> tryEmitter;
     public ISubEmitter<ICatchNode> catchEmitter;
     public ISubEmitter<IThrowNode> throwEmitter;
+    public ISubEmitter<IWithNode> withEmitter;
     public ISubEmitter<IASNode> statementEmitter;
     public ISubEmitter<ILanguageIdentifierNode> languageIdentifierEmitter;
     public SourceMapDirectiveEmitter sourceMapDirectiveEmitter;
@@ -166,6 +169,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
         tryEmitter = new TryEmitter(this);
         catchEmitter = new CatchEmitter(this);
         throwEmitter = new ThrowEmitter(this);
+        withEmitter = new WithEmitter(this);
         statementEmitter = new StatementEmitter(this);
         languageIdentifierEmitter = new LanguageIdentifierEmitter(this);
         sourceMapDirectiveEmitter = new SourceMapDirectiveEmitter(this);
@@ -264,6 +268,12 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
     }
 
     @Override
+    public void emitWith(IWithNode node)
+    {
+        withEmitter.emit(node);
+    }
+
+    @Override
     public void emitThrow(IThrowNode node)
     {
         throwEmitter.emit(node);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b20a5d5d/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WithEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WithEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WithEmitter.java
new file mode 100644
index 0000000..934bfab
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/WithEmitter.java
@@ -0,0 +1,56 @@
+/*
+ *
+ *  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.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IWithNode;
+
+public class WithEmitter extends JSSubEmitter implements
+        ISubEmitter<IWithNode>
+{
+    public WithEmitter(IJSEmitter emitter)
+    {
+        super(emitter);
+    }
+
+    @Override
+    public void emit(IWithNode node)
+    {
+        IContainerNode cnode = (IContainerNode) node.getChild(1);
+        startMapping(node);
+        writeToken(ASEmitterTokens.WITH);
+        write(ASEmitterTokens.PAREN_OPEN);
+        endMapping(node);
+        IExpressionNode targetNode = node.getTargetNode();
+        getWalker().walk(targetNode);
+        startMapping(node, targetNode);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        if (!EmitterUtils.isImplicit(cnode))
+            write(ASEmitterTokens.SPACE);
+        endMapping(node);
+        getWalker().walk(node.getStatementContentsNode());
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b20a5d5d/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 629f06a..11d8b4b 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -26,6 +26,7 @@ import org.apache.flex.compiler.tree.as.IIfNode;
 import org.apache.flex.compiler.tree.as.ISwitchNode;
 import org.apache.flex.compiler.tree.as.ITryNode;
 import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.tree.as.IWithNode;
 
 import org.junit.Test;
 
@@ -572,6 +573,39 @@ public class TestSourceMapStatements extends SourceMapTestBase
         assertMapping(node, 0, 29, 4, 0, 4, 4);    // else
     }
 
+    //----------------------------------
+    // with () {}
+    //----------------------------------
+
+    @Test
+    public void testVisitWith()
+    {
+        IWithNode node = (IWithNode) getNode("with (a) { b; }", IWithNode.class);
+        asBlockWalker.visitWith(node);
+        //with (a) {\n  b;\n}
+        assertMapping(node, 0, 0, 0, 0, 0, 6);     // with (
+        assertMapping(node, 0, 6, 0, 6, 0, 7);     // a
+        assertMapping(node, 0, 7, 0, 7, 0, 9);     // )
+        assertMapping(node, 0, 9, 0, 9, 0, 10);    // {
+        assertMapping(node, 0, 11, 1, 2, 1, 3);     // b
+        assertMapping(node, 0, 12, 1, 3, 1, 4);    // ;
+        assertMapping(node, 0, 14, 2, 0, 2, 1);    // }
+    }
+
+    @Test
+    public void testVisitWith_1a()
+    {
+        IWithNode node = (IWithNode) getNode("with (a) b;", IWithNode.class);
+        asBlockWalker.visitWith(node);
+        //with (a)\n  b;
+        assertMapping(node, 0, 0, 0, 0, 0, 6);     // with (
+        assertMapping(node, 0, 6, 0, 6, 0, 7);     // a
+        assertMapping(node, 0, 7, 0, 7, 0, 8);     // )
+        assertMapping(node, 0, 9, 1, 2, 1, 3);     // b
+        assertMapping(node, 0, 10, 1, 3, 1, 4);    // ;
+    }
+
+
     protected IBackend createBackend()
     {
         return new FlexJSBackend();


Mime
View raw message