You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/04/11 15:59:53 UTC
[26/50] git commit: [flex-falcon]
[refs/heads/feature/maven-migration] - a mapping can't exist on multiple
lines, so simply finish the starting line
a mapping can't exist on multiple lines, so simply finish the starting line
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/c1999209
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/c1999209
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/c1999209
Branch: refs/heads/feature/maven-migration
Commit: c1999209bd5ed1f98a6dce91cb7572a578bad4ba
Parents: 739bef7
Author: Josh Tynjala <jo...@apache.org>
Authored: Fri Apr 1 18:02:38 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Fri Apr 1 18:02:38 2016 -0700
----------------------------------------------------------------------
.../js/sourcemaps/TestSourceMapExpressions.java | 16 ++++++
.../internal/test/SourceMapTestBase.java | 6 +-
.../flex/compiler/codegen/js/IJSEmitter.java | 6 +-
.../compiler/internal/codegen/js/JSEmitter.java | 60 +++++++-------------
.../internal/codegen/js/jx/AsIsEmitter.java | 6 +-
.../codegen/js/jx/BinaryOperatorEmitter.java | 6 +-
.../codegen/js/jx/MemberAccessEmitter.java | 2 +-
.../codegen/js/jx/VarDeclarationEmitter.java | 6 +-
8 files changed, 55 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/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 5a94d96..d2dd1dd 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
@@ -588,6 +588,22 @@ public class TestSourceMapExpressions extends SourceMapTestBase
}
@Test
+ public void testVisitArrayLiteral_4()
+ {
+ ArrayLiteralNode node = (ArrayLiteralNode) getExpressionNode(
+ "a = [0,\n123, 45]", ArrayLiteralNode.class);
+ asBlockWalker.visitLiteral(node);
+ //[0, 123, 45]
+ 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, 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 ]
+ }
+
+ @Test
public void testVisitUnaryOperatorNode_Typeof()
{
IUnaryOperatorNode node = getUnaryNode("typeof(a)");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/SourceMapTestBase.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
index a7b18cf..9843267 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
@@ -24,7 +24,11 @@ public class SourceMapTestBase extends ASTestBase
int outStartLine, int outStartColumn, int outEndLine, int outEndColumn)
{
int sourceStartLine = nodeStartLine + node.getLine();
- int sourceStartColumn = nodeStartColumn + node.getColumn();
+ int sourceStartColumn = nodeStartColumn;
+ if (nodeStartLine == 0)
+ {
+ sourceStartColumn += node.getColumn();
+ }
boolean foundMapping = false;
List<IJSEmitter.SourceMapMapping> mappings = jsEmitter.getSourceMapMappings();
for (IJSEmitter.SourceMapMapping mapping : mappings)
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/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 d42abe1..82cb7d7 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
@@ -57,10 +57,10 @@ public interface IJSEmitter extends IASEmitter
void startMapping(ISourceLocation node, int line, int column);
/**
- * Adds a node to the source map using the space between two nodes instead
- * of the node's own line and column.
+ * 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 previousNode, ISourceLocation nextNode);
+ void startMapping(ISourceLocation node, ISourceLocation nodeBeforeMapping);
/**
* Commits a mapping to the source map.
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/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 ba7cbdf..6839f9e 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
@@ -176,8 +176,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
//we're mapping the comma to the container, but we use the
//parameter line/column in case the comma is not on the same
//line as the opening (
- startMapping(node, parameterNode.getLine(),
- parameterNode.getColumn() + parameterNode.getAbsoluteEnd() - parameterNode.getAbsoluteStart());
+ startMapping(node, parameterNode);
writeToken(ASEmitterTokens.COMMA);
endMapping(node);
}
@@ -213,8 +212,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
//we're mapping the comma to the container, but we use the
//parameter line/column in case the comma is not on the same
//line as the opening (
- startMapping(node, argumentNode.getLine(),
- argumentNode.getColumn() + argumentNode.getAbsoluteEnd() - argumentNode.getAbsoluteStart());
+ startMapping(node, argumentNode);
writeToken(ASEmitterTokens.COMMA);
endMapping(node);
}
@@ -275,10 +273,10 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
getWalker().walk(child);
if (i < len - 1)
{
- //we're mapping the comma to the literal container, but we use
- //the child line/column in case the comma is not on the same
- //line as the opening { or [
- startMapping(node, child.getLine(), child.getColumn() + child.getAbsoluteEnd() - child.getAbsoluteStart());
+ //we're mapping the comma to the literal container, but we fill
+ //the space between the current child and the next because we
+ //don't know exactly where the comma appears in ActionScript
+ startMapping(node, child);
writeToken(ASEmitterTokens.COMMA);
endMapping(node);
}
@@ -308,11 +306,11 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
endMapping(nameNode);
}
- IExpressionNode valueNode = node.getValueNode();
- startMapping(sourceLocationNode, nameNode, valueNode);
+ startMapping(sourceLocationNode, nameNode);
write(ASEmitterTokens.COLON);
endMapping(sourceLocationNode);
-
+
+ IExpressionNode valueNode = node.getValueNode();
getWalker().walk(valueNode);
}
@@ -348,16 +346,14 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
IExpressionNode leftOperandNode = node.getLeftOperandNode();
getWalker().walk(leftOperandNode);
- startMapping(node, leftOperandNode.getLine(),
- leftOperandNode.getColumn() + leftOperandNode.getEnd() - leftOperandNode.getStart());
+ startMapping(node, leftOperandNode);
write(ASEmitterTokens.SQUARE_OPEN);
endMapping(node);
IExpressionNode rightOperandNode = node.getRightOperandNode();
getWalker().walk(rightOperandNode);
- startMapping(node, rightOperandNode.getLine(),
- rightOperandNode.getColumn() + rightOperandNode.getEnd() - rightOperandNode.getStart());
+ startMapping(node, rightOperandNode);
write(ASEmitterTokens.SQUARE_CLOSE);
endMapping(node);
}
@@ -408,9 +404,9 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
IASNode conditionalExpression = node.getChild(0);
getWalker().walk(conditionalExpression);
- IContainerNode xnode = (IContainerNode) node.getStatementContentsNode();
- startMapping(node, conditionalExpression, xnode);
+ startMapping(node, conditionalExpression);
write(ASEmitterTokens.PAREN_CLOSE);
+ IContainerNode xnode = (IContainerNode) node.getStatementContentsNode();
if (!isImplicit(xnode))
write(ASEmitterTokens.SPACE);
endMapping(node);
@@ -449,7 +445,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
getWalker().walk(conditionalNode);
IExpressionNode leftOperandNode = node.getLeftOperandNode();
- startMapping(node, conditionalNode, leftOperandNode);
+ startMapping(node, conditionalNode);
write(ASEmitterTokens.SPACE);
writeToken(ASEmitterTokens.TERNARY);
endMapping(node);
@@ -457,7 +453,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
getWalker().walk(leftOperandNode);
IExpressionNode rightOperandNode = node.getRightOperandNode();
- startMapping(node, leftOperandNode, rightOperandNode);
+ startMapping(node, leftOperandNode);
write(ASEmitterTokens.SPACE);
writeToken(ASEmitterTokens.COLON);
endMapping(node);
@@ -482,7 +478,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
getWalker().walk(conditionalExpression);
IASNode statementContentsNode = node.getStatementContentsNode();
- startMapping(node, conditionalExpression, statementContentsNode);
+ startMapping(node, conditionalExpression);
write(ASEmitterTokens.PAREN_CLOSE);
if (!isImplicit(cnode))
write(ASEmitterTokens.SPACE);
@@ -506,7 +502,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
getWalker().walk(statementContents);
IASNode conditionalExpressionNode = node.getConditionalExpressionNode();
- startMapping(node, statementContents, conditionalExpressionNode);
+ startMapping(node, statementContents);
if (!isImplicit(cnode))
write(ASEmitterTokens.SPACE);
else
@@ -518,7 +514,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
getWalker().walk(conditionalExpressionNode);
- startMapping(node, conditionalExpressionNode, conditionalExpressionNode.getSucceedingNode(1));
+ startMapping(node, conditionalExpressionNode);
write(ASEmitterTokens.PAREN_CLOSE);
write(ASEmitterTokens.SEMICOLON);
endMapping(node);
@@ -539,7 +535,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
{
IExpressionNode operandNode = node.getOperandNode();
getWalker().walk(operandNode);
- startMapping(node, operandNode.getLine(), operandNode.getColumn() + operandNode.getAbsoluteEnd() - operandNode.getAbsoluteStart());
+ startMapping(node, operandNode);
write(node.getOperator().getOperatorText());
endMapping(node);
}
@@ -638,21 +634,9 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
startMapping(node, node.getLine(), node.getColumn());
}
- public void startMapping(ISourceLocation node, ISourceLocation previousNode, ISourceLocation nextNode)
+ public void startMapping(ISourceLocation node, ISourceLocation nodeBeforeMapping)
{
- if(previousNode.getLine() == nextNode.getLine())
- {
- //start at the end of the previous node
- startMapping(node, previousNode.getLine(), previousNode.getColumn() + previousNode.getAbsoluteEnd() - previousNode.getAbsoluteStart());
- }
- else
- {
- //fill the rest of the line with the previous node
- startMapping(node, previousNode.getLine(), previousNode.getColumn() + previousNode.getAbsoluteEnd() - previousNode.getAbsoluteStart());
- endMapping(node);
- //fill the beginning of the line with the next node
- startMapping(node, nextNode.getLine(), 0);
- }
+ startMapping(node, nodeBeforeMapping.getLine(), nodeBeforeMapping.getColumn() + nodeBeforeMapping.getAbsoluteEnd() - nodeBeforeMapping.getAbsoluteStart());
}
public void startMapping(ISourceLocation node, int line, int column)
@@ -703,7 +687,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
{
throw new IllegalStateException("Cannot end mapping when a mapping has not been started");
}
-
+
lastMapping.destEndPosition = new FilePosition(getCurrentLine(), getCurrentColumn());
sourceMapMappings.add(lastMapping);
lastMapping = null;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
index 18c2e05..36e2cd0 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/AsIsEmitter.java
@@ -136,7 +136,7 @@ public class AsIsEmitter extends JSSubEmitter
if (node instanceof IBinaryOperatorNode)
{
IBinaryOperatorNode binaryOperatorNode = (IBinaryOperatorNode) node;
- getEmitter().startMapping(node, binaryOperatorNode.getLeftOperandNode(), binaryOperatorNode.getRightOperandNode());
+ getEmitter().startMapping(node, binaryOperatorNode.getLeftOperandNode());
}
else
{
@@ -157,7 +157,7 @@ public class AsIsEmitter extends JSSubEmitter
if (node instanceof IBinaryOperatorNode)
{
IBinaryOperatorNode binaryOperatorNode = (IBinaryOperatorNode) node;
- getEmitter().startMapping(node, binaryOperatorNode.getLeftOperandNode(), binaryOperatorNode.getRightOperandNode());
+ getEmitter().startMapping(node, binaryOperatorNode.getLeftOperandNode());
}
else
{
@@ -180,7 +180,7 @@ public class AsIsEmitter extends JSSubEmitter
if (node instanceof IBinaryOperatorNode)
{
IBinaryOperatorNode binaryOperatorNode = (IBinaryOperatorNode) node;
- getEmitter().startMapping(node, binaryOperatorNode.getLeftOperandNode(), binaryOperatorNode.getRightOperandNode());
+ getEmitter().startMapping(node, binaryOperatorNode.getLeftOperandNode());
}
else
{
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
index b056177..d97c20a 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
@@ -71,7 +71,7 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
{
getWalker().walk(node.getLeftOperandNode());
- getEmitter().startMapping(node, node.getLeftOperandNode(), node.getRightOperandNode());
+ getEmitter().startMapping(node, node.getLeftOperandNode());
write(ASEmitterTokens.SPACE);
writeToken(ASEmitterTokens.INSTANCEOF);
getEmitter().endMapping(node);
@@ -330,7 +330,7 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
{
getWalker().walk(node.getLeftOperandNode());
- getEmitter().startMapping(node, node.getLeftOperandNode(), node.getRightOperandNode());
+ getEmitter().startMapping(node, node.getLeftOperandNode());
if (id != ASTNodeID.Op_CommaID)
write(ASEmitterTokens.SPACE);
@@ -346,7 +346,7 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
getEmitter().endMapping(node);
write(lnode.getName());
- getEmitter().startMapping(node, node.getLeftOperandNode(), node.getRightOperandNode());
+ getEmitter().startMapping(node, node.getLeftOperandNode());
write(ASEmitterTokens.SPACE);
write((id == ASTNodeID.Op_LogicalAndAssignID) ? ASEmitterTokens.LOGICAL_AND
: ASEmitterTokens.LOGICAL_OR);
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
index e5f9a58..1756487 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
@@ -246,7 +246,7 @@ public class MemberAccessEmitter extends JSSubEmitter implements
continueWalk = writeLeftSide(node, leftNode, rightNode);
if (continueWalk)
{
- getEmitter().startMapping(node, node.getLeftOperandNode(), node.getRightOperandNode());
+ getEmitter().startMapping(node, node.getLeftOperandNode());
write(node.getOperator().getOperatorText());
getEmitter().endMapping(node);
}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c1999209/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 aed9671..322c778 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
@@ -95,7 +95,7 @@ public class VarDeclarationEmitter extends JSSubEmitter implements
fjs.emitDeclarationName(node);
if (avnode != null && !(avnode instanceof IEmbedNode))
{
- getEmitter().startMapping(node, node.getVariableTypeNode(), avnode);
+ getEmitter().startMapping(node, node.getVariableTypeNode());
write(ASEmitterTokens.SPACE);
writeToken(ASEmitterTokens.EQUAL);
getEmitter().endMapping(node);
@@ -111,9 +111,7 @@ public class VarDeclarationEmitter extends JSSubEmitter implements
IASNode child = node.getChild(i);
if (child instanceof ChainedVariableNode)
{
- getEmitter().startMapping(node,
- node.getChild(i - 1),
- child);
+ getEmitter().startMapping(node, node.getChild(i - 1));
writeToken(ASEmitterTokens.COMMA);
getEmitter().endMapping(node);
fjs.emitVarDeclaration((IVariableNode) child);