You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ms...@apache.org on 2013/03/06 20:47:35 UTC
svn commit: r1453513 - in /flex/falcon/trunk:
compiler.jx/src/org/apache/flex/compiler/codegen/as/
compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/
compiler/src/org/apache/flex/compiler/internal/tree/as/
compiler/src/org/apache/flex/compil...
Author: mschmalle
Date: Wed Mar 6 19:47:35 2013
New Revision: 1453513
URL: http://svn.apache.org/r1453513
Log:
Flex:Falcon
- added ILiteralContainerNode API
FalconJx
- finalized visitLiteral() in ASEmitter
Added:
flex/falcon/trunk/compiler/src/org/apache/flex/compiler/tree/as/ILiteralContainerNode.java (with props)
Modified:
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/as/BaseLiteralContainerNode.java
Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java?rev=1453513&r1=1453512&r2=1453513&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java (original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/codegen/as/IASEmitter.java Wed Mar 6 19:47:35 2013
@@ -31,7 +31,6 @@ import org.apache.flex.compiler.tree.as.
import org.apache.flex.compiler.tree.as.IBlockNode;
import org.apache.flex.compiler.tree.as.ICatchNode;
import org.apache.flex.compiler.tree.as.IClassNode;
-import org.apache.flex.compiler.tree.as.IContainerNode;
import org.apache.flex.compiler.tree.as.IDynamicAccessNode;
import org.apache.flex.compiler.tree.as.IForLoopNode;
import org.apache.flex.compiler.tree.as.IFunctionCallNode;
@@ -45,6 +44,7 @@ import org.apache.flex.compiler.tree.as.
import org.apache.flex.compiler.tree.as.IIterationFlowNode;
import org.apache.flex.compiler.tree.as.IKeywordNode;
import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
+import org.apache.flex.compiler.tree.as.ILiteralContainerNode;
import org.apache.flex.compiler.tree.as.ILiteralNode;
import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
import org.apache.flex.compiler.tree.as.INamespaceNode;
@@ -311,7 +311,7 @@ public interface IASEmitter extends IEmi
void emitLiteral(ILiteralNode node);
- void emitLiteralContainer(IContainerNode node);
+ void emitLiteralContainer(ILiteralContainerNode node);
void emitNumericLiteral(INumericLiteralNode node);
Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java?rev=1453513&r1=1453512&r2=1453513&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java (original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASBlockWalker.java Wed Mar 6 19:47:35 2013
@@ -24,7 +24,6 @@ import java.util.List;
import org.apache.flex.compiler.codegen.as.IASEmitter;
import org.apache.flex.compiler.definitions.IPackageDefinition;
import org.apache.flex.compiler.internal.semantics.SemanticUtils;
-import org.apache.flex.compiler.internal.tree.as.BaseLiteralContainerNode;
import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
import org.apache.flex.compiler.internal.tree.as.VariableExpressionNode;
@@ -55,6 +54,7 @@ import org.apache.flex.compiler.tree.as.
import org.apache.flex.compiler.tree.as.IIterationFlowNode;
import org.apache.flex.compiler.tree.as.IKeywordNode;
import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
+import org.apache.flex.compiler.tree.as.ILiteralContainerNode;
import org.apache.flex.compiler.tree.as.ILiteralNode;
import org.apache.flex.compiler.tree.as.ILiteralNode.LiteralType;
import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
@@ -415,7 +415,6 @@ public class ASBlockWalker implements IA
public void visitLiteral(ILiteralNode node)
{
debug("visitLiteral(" + node.getValue() + ")");
- // TODO (mschmalle) visitLiteral()
if (node.getLiteralType() == LiteralType.NUMBER
|| node.getLiteralType() == LiteralType.BOOLEAN
|| node.getLiteralType() == LiteralType.NULL
@@ -427,11 +426,12 @@ public class ASBlockWalker implements IA
emitter.emitLiteral(node);
}
else if (node.getLiteralType() == LiteralType.ARRAY
- || node.getLiteralType() == LiteralType.OBJECT)
+ || node.getLiteralType() == LiteralType.OBJECT
+ || node.getLiteralType() == LiteralType.VECTOR
+ || node.getLiteralType() == LiteralType.XMLLIST
+ || node.getLiteralType() == LiteralType.XML)
{
- BaseLiteralContainerNode anode = (BaseLiteralContainerNode) node;
- IContainerNode cnode = anode.getContentsNode();
- emitter.emitLiteralContainer(cnode);
+ emitter.emitLiteralContainer((ILiteralContainerNode) node);
}
}
Modified: flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java?rev=1453513&r1=1453512&r2=1453513&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java (original)
+++ flex/falcon/trunk/compiler.jx/src/org/apache/flex/compiler/internal/codegen/as/ASEmitter.java Wed Mar 6 19:47:35 2013
@@ -39,6 +39,7 @@ import org.apache.flex.compiler.definiti
import org.apache.flex.compiler.definitions.ITypeDefinition;
import org.apache.flex.compiler.definitions.IVariableDefinition;
import org.apache.flex.compiler.internal.tree.as.ChainedVariableNode;
+import org.apache.flex.compiler.internal.tree.as.ContainerNode;
import org.apache.flex.compiler.internal.tree.as.FunctionNode;
import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
import org.apache.flex.compiler.internal.tree.as.NamespaceAccessExpressionNode;
@@ -67,6 +68,7 @@ import org.apache.flex.compiler.tree.as.
import org.apache.flex.compiler.tree.as.IIterationFlowNode;
import org.apache.flex.compiler.tree.as.IKeywordNode;
import org.apache.flex.compiler.tree.as.ILanguageIdentifierNode;
+import org.apache.flex.compiler.tree.as.ILiteralContainerNode;
import org.apache.flex.compiler.tree.as.ILiteralNode;
import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
import org.apache.flex.compiler.tree.as.INamespaceNode;
@@ -1215,9 +1217,10 @@ public class ASEmitter implements IASEmi
}
@Override
- public void emitLiteralContainer(IContainerNode node)
+ public void emitLiteralContainer(ILiteralContainerNode node)
{
- ContainerType type = node.getContainerType();
+ final ContainerNode cnode = node.getContentsNode();
+ final ContainerType type = cnode.getContainerType();
String postFix = "";
if (type == ContainerType.BRACES)
@@ -1240,10 +1243,10 @@ public class ASEmitter implements IASEmi
postFix = ASEmitterTokens.PAREN_CLOSE.getToken();
}
- final int len = node.getChildCount();
+ final int len = cnode.getChildCount();
for (int i = 0; i < len; i++)
{
- IASNode child = node.getChild(i);
+ IASNode child = cnode.getChild(i);
getWalker().walk(child);
if (i < len - 1)
writeToken(ASEmitterTokens.COMMA);
Modified: flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/as/BaseLiteralContainerNode.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/as/BaseLiteralContainerNode.java?rev=1453513&r1=1453512&r2=1453513&view=diff
==============================================================================
--- flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/as/BaseLiteralContainerNode.java (original)
+++ flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/as/BaseLiteralContainerNode.java Wed Mar 6 19:47:35 2013
@@ -23,6 +23,7 @@ import org.apache.flex.compiler.internal
import org.apache.flex.compiler.parsing.IASToken;
import org.apache.flex.compiler.tree.ASTNodeID;
import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.ILiteralContainerNode;
import org.apache.flex.compiler.tree.as.ILiteralNode;
import org.apache.flex.compiler.tree.as.IContainerNode.ContainerType;
@@ -30,8 +31,8 @@ import org.apache.flex.compiler.tree.as.
* Base container node for a literal that is made up of other literals, like XML
* or arrays
*/
-// TODO Create ILiteralContainerNode with getBaseType() and getContents()?
-public abstract class BaseLiteralContainerNode extends ExpressionNodeBase implements ILiteralNode
+public abstract class BaseLiteralContainerNode extends ExpressionNodeBase
+ implements ILiteralContainerNode
{
/**
* Constructor.
@@ -44,20 +45,20 @@ public abstract class BaseLiteralContain
contentsNode = new ContainerNode();
switch (baseTypeNode.getLiteralType())
{
- case ARRAY:
+ case ARRAY:
{
contentsNode.setContainerType(ContainerType.BRACKETS);
break;
}
case OBJECT:
- case VECTOR:
+ case VECTOR:
{
contentsNode.setContainerType(ContainerType.BRACES);
break;
}
}
}
-
+
/**
* Copy constructor.
*
@@ -67,7 +68,7 @@ public abstract class BaseLiteralContain
{
super(other);
}
-
+
protected LiteralNode baseTypeNode;
protected ContainerNode contentsNode;
@@ -87,7 +88,7 @@ public abstract class BaseLiteralContain
{
return i == 0 ? contentsNode : null;
}
-
+
@Override
protected void setChildren(boolean fillInOffsets)
{
@@ -98,7 +99,7 @@ public abstract class BaseLiteralContain
//
// FixedChildrenNode overrides
//
-
+
@Override
public boolean isTerminal()
{
@@ -125,25 +126,23 @@ public abstract class BaseLiteralContain
IASNode child = getContentsNode().getChild(i);
if (child instanceof ILiteralNode)
{
- builder.append(((ILiteralNode)child).getValue(rawValue));
+ builder.append(((ILiteralNode) child).getValue(rawValue));
}
}
return builder.toString();
}
-
+
//
- // Other methods
+ // ILiteralContainerNode implementations
//
- /**
- * Gets a node that represents this node's type,
- * Note that this is not considered a child node.
- */
+ @Override
public LiteralNode getBaseTypeNode()
{
return baseTypeNode;
}
+ @Override
public ContainerNode getContentsNode()
{
return contentsNode;
@@ -168,16 +167,17 @@ public abstract class BaseLiteralContain
final IASNode lastLiteralNode = contents.getChild(size - 1);
if (lastLiteralNode.getNodeID() == ASTNodeID.LiteralXMLID)
{
- final LiteralNode appendTarget = (LiteralNode)lastLiteralNode;
+ final LiteralNode appendTarget = (LiteralNode) lastLiteralNode;
if (!appendTarget.value.equals("<>"))
{
- appendTarget.value = appendTarget.value.concat(token.getText());
- appendTarget.endAfter((IASToken)token);
+ appendTarget.value = appendTarget.value.concat(token
+ .getText());
+ appendTarget.endAfter((IASToken) token);
return;
}
}
}
-
+
// Did not find a node to append the token to.
final LiteralNode newNode = new LiteralNode(token, LiteralType.XML);
contents.addItem(newNode);
Added: flex/falcon/trunk/compiler/src/org/apache/flex/compiler/tree/as/ILiteralContainerNode.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/tree/as/ILiteralContainerNode.java?rev=1453513&view=auto
==============================================================================
--- flex/falcon/trunk/compiler/src/org/apache/flex/compiler/tree/as/ILiteralContainerNode.java (added)
+++ flex/falcon/trunk/compiler/src/org/apache/flex/compiler/tree/as/ILiteralContainerNode.java Wed Mar 6 19:47:35 2013
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.tree.as;
+
+import org.apache.flex.compiler.internal.tree.as.ContainerNode;
+import org.apache.flex.compiler.internal.tree.as.LiteralNode;
+
+/**
+ * Base container node for a literal that is made up of other literals, like XML
+ * or arrays
+ */
+public interface ILiteralContainerNode extends ILiteralNode
+{
+ /**
+ * @return The node that represents this node's type, Note that this is not
+ * considered a child node.
+ */
+ LiteralNode getBaseTypeNode();
+
+ /**
+ * @return The container node that holds the {@link LiteralNode}.
+ */
+ ContainerNode getContentsNode();
+}
Propchange: flex/falcon/trunk/compiler/src/org/apache/flex/compiler/tree/as/ILiteralContainerNode.java
------------------------------------------------------------------------------
svn:eol-style = native