Hi Josh,
I'm not sure if it's related but I just build two applications using latest
sources and both of them are not working. I'm getting following error in
console [1]
It happened in function:
org.apache.royale.utils.Language.string = function(value) {
return org.apache.royale.utils.Language.string(value == null ? null :
value.toString());
};
[1] https://imgur.com/a/XemjI5P
Thanks,
Piotr
wt., 29 sty 2019 o 00:25 <[email protected]> napisaĆ(a):
> This is an automated email from the ASF dual-hosted git repository.
>
> joshtynjala pushed a commit to branch develop
> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
>
>
> The following commit(s) were added to refs/heads/develop by this push:
> new afb00e4 compiler-jx: Assigning a value to an int or uint coerces
> it so that variables don't store decimal values (closes #74)
> afb00e4 is described below
>
> commit afb00e48c74476618811bfb37cc830e78e700753
> Author: Josh Tynjala <[email protected]>
> AuthorDate: Mon Jan 28 15:18:56 2019 -0800
>
> compiler-jx: Assigning a value to an int or uint coerces it so that
> variables don't store decimal values (closes #74)
>
> Applies to variable declarations, the assignment binary operator,
> returning a value from a function, and passing an argument to a function.
>
> In the case of return statements and parameters, I included some other
> basic coercions to make it more consistent with what was already there for
> variable declarations and assignment. There was some coercion related to
> dynamic array access and XML that should probably also be shared, but I
> left that out for now because those ones in particular could use some
> cleanup. The new return statements and parameters currently call a shared
> IJSEmitter.emitAssignmentCoercion(). Ideally, all four [...]
> ---
> .../royale/compiler/codegen/js/IJSEmitter.java | 3 +
> .../compiler/internal/codegen/js/JSEmitter.java | 87 ++++++++++++
> .../codegen/js/jx/BinaryOperatorEmitter.java | 116 ++++++++++++----
> .../js/jx/FunctionCallArgumentsEmitter.java | 29 +++-
> .../internal/codegen/js/jx/ReturnEmitter.java | 14 +-
> .../codegen/js/jx/VarDeclarationEmitter.java | 86 ++++++++++--
> .../codegen/js/goog/TestGoogAccessorMembers.java | 4 +-
> .../internal/codegen/js/goog/TestGoogEmitter.java | 2 +-
> .../codegen/js/royale/TestRoyaleClass.java | 36 +++++
> .../codegen/js/royale/TestRoyaleEmitter.java | 2 +-
> .../codegen/js/royale/TestRoyaleExpressions.java | 152
> +++++++++++++++------
> .../codegen/js/royale/TestRoyaleGlobalClasses.java | 10 +-
> .../js/royale/TestRoyaleGlobalFunctions.java | 4 +-
> .../codegen/js/royale/TestRoyaleMethodMembers.java | 4 +-
> .../codegen/js/royale/TestRoyaleStatements.java | 18 +++
> 15 files changed, 473 insertions(+), 94 deletions(-)
>
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/IJSEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/IJSEmitter.java
> index 5dffb4d..b68f9f0 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/IJSEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/IJSEmitter.java
> @@ -25,6 +25,7 @@ import org.apache.royale.compiler.codegen.as.IASEmitter;
> import org.apache.royale.compiler.definitions.IDefinition;
> import org.apache.royale.compiler.internal.codegen.js.JSSessionModel;
> import org.apache.royale.compiler.tree.as.IASNode;
> +import org.apache.royale.compiler.tree.as.IExpressionNode;
> import org.apache.royale.compiler.tree.as.ITypeNode;
> import org.apache.royale.compiler.visitor.IASNodeStrategy;
>
> @@ -45,4 +46,6 @@ public interface IJSEmitter extends IASEmitter,
> IMappingEmitter
>
> void emitClosureStart();
> void emitClosureEnd(IASNode node, IDefinition nodeDef);
> +
> + void emitAssignmentCoercion(IExpressionNode assignedNode, IDefinition
> definition);
> }
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> index 6b2b8e2..997c562 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> @@ -28,6 +28,7 @@ import org.apache.royale.compiler.codegen.ISubEmitter;
> import org.apache.royale.compiler.codegen.js.IJSEmitter;
> import org.apache.royale.compiler.codegen.js.IMappingEmitter;
> import org.apache.royale.compiler.common.ISourceLocation;
> +import
> org.apache.royale.compiler.constants.IASLanguageConstants.BuiltinType;
> import org.apache.royale.compiler.definitions.IDefinition;
> import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
> import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
> @@ -58,11 +59,13 @@ import
> org.apache.royale.compiler.internal.codegen.js.jx.UnaryOperatorEmitter;
> import org.apache.royale.compiler.internal.codegen.js.jx.WhileLoopEmitter;
> import org.apache.royale.compiler.internal.codegen.js.jx.WithEmitter;
> import org.apache.royale.compiler.internal.tree.as.FunctionNode;
> +import org.apache.royale.compiler.projects.ICompilerProject;
> import org.apache.royale.compiler.tree.as.IASNode;
> import org.apache.royale.compiler.tree.as.ICatchNode;
> import org.apache.royale.compiler.tree.as.IContainerNode;
> import org.apache.royale.compiler.tree.as.IDefinitionNode;
> import org.apache.royale.compiler.tree.as.IDynamicAccessNode;
> +import org.apache.royale.compiler.tree.as.IExpressionNode;
> import org.apache.royale.compiler.tree.as.IForLoopNode;
> import org.apache.royale.compiler.tree.as.IFunctionNode;
> import org.apache.royale.compiler.tree.as.IFunctionObjectNode;
> @@ -515,4 +518,88 @@ public class JSEmitter extends ASEmitter implements
> IJSEmitter
> return className.replace(".", "_") + "_" + name;
> }
>
> + public void emitAssignmentCoercion(IExpressionNode assignedNode,
> IDefinition definition)
> + {
> + IDefinition assignedDef = null;
> + ICompilerProject project = getWalker().getProject();
> + if (assignedNode != null)
> + {
> + assignedDef = assignedNode.resolveType(project);
> + }
> + String coercionStart = null;
> + String coercionEnd = null;
> + if
> (project.getBuiltinType(BuiltinType.INT).equals(definition))
> + {
> + boolean needsCoercion = false;
> + if (assignedNode instanceof INumericLiteralNode)
> + {
> + INumericLiteralNode numericLiteral =
> (INumericLiteralNode) assignedNode;
> + if
> (!BuiltinType.INT.equals(numericLiteral.getNumericValue().getAssumedType()))
> + {
> + needsCoercion = true;
> + }
> + }
> + else
> if(!project.getBuiltinType(BuiltinType.INT).equals(assignedDef))
> + {
> + needsCoercion = true;
> + }
> + if (needsCoercion)
> + {
> + coercionStart = "(";
> + coercionEnd = ") >> 0";
> + }
> + }
> + else if
> (project.getBuiltinType(BuiltinType.UINT).equals(definition))
> + {
> + boolean needsCoercion = false;
> + if (assignedNode instanceof INumericLiteralNode)
> + {
> + INumericLiteralNode numericLiteral =
> (INumericLiteralNode) assignedNode;
> + if
> (!BuiltinType.UINT.equals(numericLiteral.getNumericValue().getAssumedType()))
> + {
> + needsCoercion = true;
> + }
> + }
> + else
> if(!project.getBuiltinType(BuiltinType.UINT).equals(assignedDef))
> + {
> + needsCoercion = true;
> + }
> + if (needsCoercion)
> + {
> + coercionStart = "(";
> + coercionEnd = ") >>> 0";
> + }
> + }
> + else if
> (project.getBuiltinType(BuiltinType.NUMBER).equals(definition)
> + &&
> !project.getBuiltinType(BuiltinType.NUMBER).equals(assignedDef)
> + &&
> !project.getBuiltinType(BuiltinType.INT).equals(assignedDef)
> + &&
> !project.getBuiltinType(BuiltinType.UINT).equals(assignedDef))
> + {
> + coercionStart = "Number(";
> + }
> + else if
> (project.getBuiltinType(BuiltinType.STRING).equals(definition)
> + &&
> !project.getBuiltinType(BuiltinType.STRING).equals(assignedDef)
> + &&
> !project.getBuiltinType(BuiltinType.NULL).equals(assignedDef))
> + {
> + coercionStart = "org.apache.royale.utils.Language.string(";
> + }
> +
> + if (coercionStart != null)
> + {
> + write(coercionStart);
> + }
> + getWalker().walk(assignedNode);
> + if (coercionStart != null)
> + {
> + if (coercionEnd != null)
> + {
> + write(coercionEnd);
> + }
> + else
> + {
> + write(")");
> + }
> + }
> + }
> +
> }
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
> index 756c3d8..ff09dd4 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
> @@ -22,6 +22,7 @@ package
> org.apache.royale.compiler.internal.codegen.js.jx;
> import org.apache.royale.compiler.codegen.ISubEmitter;
> import org.apache.royale.compiler.codegen.js.IJSEmitter;
> import org.apache.royale.compiler.constants.IASLanguageConstants;
> +import
> org.apache.royale.compiler.constants.IASLanguageConstants.BuiltinType;
> import org.apache.royale.compiler.definitions.IDefinition;
> import org.apache.royale.compiler.definitions.ITypeDefinition;
> import org.apache.royale.compiler.definitions.metadata.IMetaTag;
> @@ -45,6 +46,7 @@ import
> org.apache.royale.compiler.tree.as.IBinaryOperatorNode;
> import org.apache.royale.compiler.tree.as.IClassNode;
> import org.apache.royale.compiler.tree.as.IExpressionNode;
> import org.apache.royale.compiler.tree.as.IIdentifierNode;
> +import org.apache.royale.compiler.tree.as.INumericLiteralNode;
> import org.apache.royale.compiler.utils.ASNodeUtils;
>
> public class BinaryOperatorEmitter extends JSSubEmitter implements
> @@ -444,32 +446,91 @@ public class BinaryOperatorEmitter extends
> JSSubEmitter implements
> }
> }
> }
> - String coercion = (leftIsNumber && !rightIsNumber &&
> isAssignment) ? "Number(" : "";
> - if (isAssignment && leftDef != null &&
> leftDef.getQualifiedName().equals(IASLanguageConstants.String))
> + String coercionStart = null;
> + String coercionEnd = null;
> + if (isAssignment)
> {
> - if (rNode.getNodeID() != ASTNodeID.LiteralStringID &&
> - rNode.getNodeID() !=
> ASTNodeID.LiteralNullID)
> - {
> - if (rightDef == null ||
> -
> (!(rightDef.getQualifiedName().equals(IASLanguageConstants.String) ||
> -
> (rightDef.getQualifiedName().equals(IASLanguageConstants.ANY_TYPE)
> - && rNode.getNodeID() ==
> ASTNodeID.FunctionCallID &&
> - isToString(rNode)) ||
> - // if not an assignment
> we don't need to coerce numbers
> - (!isAssignment &&
> rightIsNumber) ||
> -
> rightDef.getQualifiedName().equals(IASLanguageConstants.Null))))
> - {
> - JSRoyaleDocEmitter docEmitter =
> (JSRoyaleDocEmitter)(getEmitter().getDocEmitter());
> - if
> (docEmitter.emitStringConversions)
> - {
> - coercion =
> "org.apache.royale.utils.Language.string(";
> - }
> - }
> - }
> + if
> (getProject().getBuiltinType(BuiltinType.INT).equals(leftDef))
> + {
> + boolean needsCoercion = false;
> + if (rNode instanceof
> INumericLiteralNode)
> + {
> + INumericLiteralNode
> rNumber = (INumericLiteralNode) rNode;
> + if
> (!BuiltinType.INT.equals(rNumber.getNumericValue().getAssumedType()))
> + {
> + needsCoercion =
> true;
> + }
> + }
> + else
> if(!getProject().getBuiltinType(BuiltinType.INT).equals(rightDef))
> + {
> + needsCoercion = true;
> + }
> + if (needsCoercion)
> + {
> + coercionStart = "(";
> + coercionEnd = ") >> 0";
> + }
> + }
> + else if
> (getProject().getBuiltinType(BuiltinType.UINT).equals(leftDef))
> + {
> + boolean needsCoercion = false;
> + if (rNode instanceof
> INumericLiteralNode)
> + {
> + INumericLiteralNode
> rNumber = (INumericLiteralNode) rNode;
> + if
> (!BuiltinType.UINT.equals(rNumber.getNumericValue().getAssumedType()))
> + {
> + needsCoercion =
> true;
> + }
> + }
> + else
> if(!getProject().getBuiltinType(BuiltinType.UINT).equals(rightDef))
> + {
> + needsCoercion = true;
> + }
> + if (needsCoercion)
> + {
> + coercionStart = "(";
> + coercionEnd = ") >>> 0";
> + }
> + }
> + else if (leftIsNumber && !rightIsNumber)
> + {
> + coercionStart = "Number(";
> + }
> + else if
> (getProject().getBuiltinType(BuiltinType.STRING).equals(leftDef))
> + {
> + if (rNode.getNodeID() !=
> ASTNodeID.LiteralStringID &&
> + rNode.getNodeID()
> != ASTNodeID.LiteralNullID)
> + {
> + if (rightDef == null ||
> +
> (!(rightDef.getQualifiedName().equals(IASLanguageConstants.String) ||
> +
> (rightDef.getQualifiedName().equals(IASLanguageConstants.ANY_TYPE)
> +
> && rNode.getNodeID() == ASTNodeID.FunctionCallID &&
> +
> isToString(rNode)) ||
> + // if not
> an assignment we don't need to coerce numbers
> +
> (!isAssignment && rightIsNumber) ||
> +
> rightDef.getQualifiedName().equals(IASLanguageConstants.Null))))
> + {
> + JSRoyaleDocEmitter
> docEmitter = (JSRoyaleDocEmitter)(getEmitter().getDocEmitter());
> + if
> (docEmitter.emitStringConversions)
> + {
> +
> coercionStart = "org.apache.royale.utils.Language.string(";
> + }
> + }
> + }
> + }
> }
> - super_emitBinaryOperator(node, coercion);
> - if (coercion.length() > 0)
> - write(")");
> + super_emitBinaryOperator(node, coercionStart);
> + if (coercionStart != null)
> + {
> + if (coercionEnd != null)
> + {
> + write(coercionEnd);
> + }
> + else
> + {
> + write(")");
> + }
> + }
>
> /*
> IExpressionNode leftSide = node.getLeftOperandNode();
> @@ -550,7 +611,7 @@ public class BinaryOperatorEmitter extends
> JSSubEmitter implements
> return false;
> }
>
> - private void super_emitBinaryOperator(IBinaryOperatorNode node,
> String coercion)
> + private void super_emitBinaryOperator(IBinaryOperatorNode node,
> String coercionStart)
> {
> if (ASNodeUtils.hasParenOpen(node))
> write(ASEmitterTokens.PAREN_OPEN);
> @@ -617,7 +678,10 @@ public class BinaryOperatorEmitter extends
> JSSubEmitter implements
> write(ASEmitterTokens.SPACE);
> endMapping(node);
>
> - write(coercion);
> + if (coercionStart != null)
> + {
> + write(coercionStart);
> + }
> /*
> IDefinition definition =
> node.getRightOperandNode().resolve(getProject());
> if (definition instanceof FunctionDefinition &&
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallArgumentsEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallArgumentsEmitter.java
> index bca4c59..40b6302 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallArgumentsEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallArgumentsEmitter.java
> @@ -21,10 +21,14 @@ package
> org.apache.royale.compiler.internal.codegen.js.jx;
>
> import org.apache.royale.compiler.codegen.ISubEmitter;
> import org.apache.royale.compiler.codegen.js.IJSEmitter;
> +import org.apache.royale.compiler.definitions.IDefinition;
> +import org.apache.royale.compiler.definitions.IFunctionDefinition;
> +import org.apache.royale.compiler.definitions.IParameterDefinition;
> import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
> import org.apache.royale.compiler.internal.codegen.js.JSSubEmitter;
> import org.apache.royale.compiler.tree.as.IContainerNode;
> import org.apache.royale.compiler.tree.as.IExpressionNode;
> +import org.apache.royale.compiler.tree.as.IFunctionCallNode;
>
> public class FunctionCallArgumentsEmitter extends JSSubEmitter implements
> ISubEmitter<IContainerNode>
> @@ -41,11 +45,34 @@ public class FunctionCallArgumentsEmitter extends
> JSSubEmitter implements
> write(ASEmitterTokens.PAREN_OPEN);
> endMapping(node);
>
> + IParameterDefinition[] paramDefs = null;
> + IFunctionCallNode functionCallNode = (IFunctionCallNode)
> node.getAncestorOfType(IFunctionCallNode.class);
> + if (functionCallNode != null)
> + {
> + IDefinition calledDef =
> functionCallNode.resolveCalledExpression(getProject());
> + if (calledDef instanceof IFunctionDefinition)
> + {
> + IFunctionDefinition functionDef = (IFunctionDefinition)
> calledDef;
> + paramDefs = functionDef.getParameters();
> + }
> + }
> +
> int len = node.getChildCount();
> for (int i = 0; i < len; i++)
> {
> IExpressionNode argumentNode = (IExpressionNode)
> node.getChild(i);
> - getWalker().walk(argumentNode);
> + IParameterDefinition paramDef = null;
> + if (paramDefs != null && paramDefs.length > i)
> + {
> + paramDef = paramDefs[i];
> + if (paramDef.isRest())
> + {
> + paramDef = null;
> + }
> + }
> +
> + getEmitter().emitAssignmentCoercion(argumentNode, paramDef);
> +
> if (i < len - 1)
> {
> //we're mapping the comma to the container, but we use the
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ReturnEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ReturnEmitter.java
> index a7f5d7e..0573110 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ReturnEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ReturnEmitter.java
> @@ -21,10 +21,12 @@ package
> org.apache.royale.compiler.internal.codegen.js.jx;
>
> import org.apache.royale.compiler.codegen.ISubEmitter;
> import org.apache.royale.compiler.codegen.js.IJSEmitter;
> +import org.apache.royale.compiler.definitions.IDefinition;
> import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
> import org.apache.royale.compiler.internal.codegen.js.JSSubEmitter;
> import org.apache.royale.compiler.tree.ASTNodeID;
> import org.apache.royale.compiler.tree.as.IExpressionNode;
> +import org.apache.royale.compiler.tree.as.IFunctionNode;
> import org.apache.royale.compiler.tree.as.IReturnNode;
>
> public class ReturnEmitter extends JSSubEmitter implements
> @@ -51,7 +53,17 @@ public class ReturnEmitter extends JSSubEmitter
> implements
>
> if (hasReturnValue)
> {
> - getWalker().walk(rnode);
> + IDefinition returnDef = null;
> + IFunctionNode parentFn = (IFunctionNode)
> node.getAncestorOfType(IFunctionNode.class);
> + if (parentFn != null)
> + {
> + IExpressionNode returnTypeNode =
> parentFn.getReturnTypeNode();
> + if (returnTypeNode != null)
> + {
> + returnDef = returnTypeNode.resolve(getProject());
> + }
> + }
> + getEmitter().emitAssignmentCoercion(rnode, returnDef);
> }
> }
> }
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
> index 90dbd7b..01c4a6f 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
> @@ -23,6 +23,7 @@ import org.apache.royale.compiler.codegen.ISubEmitter;
> import org.apache.royale.compiler.codegen.js.IJSEmitter;
> import org.apache.royale.compiler.constants.IASKeywordConstants;
> import org.apache.royale.compiler.constants.IASLanguageConstants;
> +import
> org.apache.royale.compiler.constants.IASLanguageConstants.BuiltinType;
> import org.apache.royale.compiler.definitions.IDefinition;
> import org.apache.royale.compiler.definitions.metadata.IMetaTag;
> import org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
> @@ -40,6 +41,7 @@ import org.apache.royale.compiler.tree.ASTNodeID;
> import org.apache.royale.compiler.tree.as.IASNode;
> import org.apache.royale.compiler.tree.as.IEmbedNode;
> import org.apache.royale.compiler.tree.as.IExpressionNode;
> +import org.apache.royale.compiler.tree.as.INumericLiteralNode;
> import org.apache.royale.compiler.tree.as.IVariableNode;
>
> public class VarDeclarationEmitter extends JSSubEmitter implements
> @@ -65,9 +67,11 @@ public class VarDeclarationEmitter extends JSSubEmitter
> implements
> }
>
> IExpressionNode variableTypeNode = node.getVariableTypeNode();
> + IDefinition variableDef = null;
> boolean hasVariableType = variableTypeNode.getLine() >= 0;
> if(hasVariableType)
> {
> + variableDef = variableTypeNode.resolve(getProject());
> startMapping(variableTypeNode,
> variableTypeNode.getLine(),
> variableTypeNode.getColumn() - 1); //include the :
> @@ -173,20 +177,76 @@ public class VarDeclarationEmitter extends
> JSSubEmitter implements
> }
> }
> }
> - String coercion = "";
> - if (varIsNumber && !valIsNumber)
> - coercion = "Number(";
> - //else if (varIsNumber && valIsNumber && varIsInt &&
> !valIsInt)
> - // coercion = "Math.floor(";
> - if (variableTypeNode.getNodeID() == ASTNodeID.IdentifierID &&
> -
>
> ((IdentifierNode)variableTypeNode).getName().equals(IASLanguageConstants.String)
> &&
> - (avdef == null ||
> (!avdef.getQualifiedName().equals(IASLanguageConstants.String) &&
> -
> !avdef.getQualifiedName().equals(IASLanguageConstants.Null))))
> - coercion =
> "org.apache.royale.utils.Language.string(";
> - write(coercion);
> + String coercionStart = null;
> + String coercionEnd = null;
> + if
> (getProject().getBuiltinType(BuiltinType.INT).equals(variableDef))
> + {
> + boolean needsCoercion = false;
> + if (avnode instanceof INumericLiteralNode)
> + {
> + INumericLiteralNode numericLiteral =
> (INumericLiteralNode) avnode;
> + if
> (!BuiltinType.INT.equals(numericLiteral.getNumericValue().getAssumedType()))
> + {
> + needsCoercion = true;
> + }
> + }
> + else
> if(!getProject().getBuiltinType(BuiltinType.INT).equals(avdef))
> + {
> + needsCoercion = true;
> + }
> + if (needsCoercion)
> + {
> + coercionStart = "(";
> + coercionEnd = ") >> 0";
> + }
> + }
> + else if
> (getProject().getBuiltinType(BuiltinType.UINT).equals(variableDef))
> + {
> + boolean needsCoercion = false;
> + if (avnode instanceof INumericLiteralNode)
> + {
> + INumericLiteralNode numericLiteral =
> (INumericLiteralNode) avnode;
> + if
> (!BuiltinType.UINT.equals(numericLiteral.getNumericValue().getAssumedType()))
> + {
> + needsCoercion = true;
> + }
> + }
> + else
> if(!getProject().getBuiltinType(BuiltinType.UINT).equals(avdef))
> + {
> + needsCoercion = true;
> + }
> + if (needsCoercion)
> + {
> + coercionStart = "(";
> + coercionEnd = ") >>> 0";
> + }
> + }
> + else if (varIsNumber && !valIsNumber)
> + {
> + coercionStart = "Number(";
> + }
> + else if
> (getProject().getBuiltinType(BuiltinType.STRING).equals(variableDef) &&
> +
> !getProject().getBuiltinType(BuiltinType.STRING).equals(avdef) &&
> +
> !getProject().getBuiltinType(BuiltinType.NULL).equals(avdef))
> + {
> + coercionStart =
> "org.apache.royale.utils.Language.string(";
> + }
> + if (coercionStart != null)
> + {
> + write(coercionStart);
> + }
> fjs.emitAssignedValue(avnode);
> - if (coercion.length() > 0)
> - write(")");
> + if (coercionStart != null)
> + {
> + if (coercionEnd != null)
> + {
> + write(coercionEnd);
> + }
> + else
> + {
> + write(")");
> + }
> + }
> }
> if (avnode == null)
> {
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java
> index 3fd051d..69ae550 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogAccessorMembers.java
> @@ -98,10 +98,10 @@ public class TestGoogAccessorMembers extends
> TestAccessorMembers
> @Test
> public void testSetAccessor_withBody()
> {
> - ISetterNode node = (ISetterNode) getAccessor("function set
> foo(value:int):void{trace('haai');}");
> + ISetterNode node = (ISetterNode) getAccessor("function set
> foo(value:int):void{'haai';}");
> asBlockWalker.visitSetter(node);
> assertOut("Object.defineProperty(\n\tRoyaleTest_A.prototype,
> \n\t'foo', "
> - + "\n\t{set:function(value) {\n\t\tvar self =
> this;\n\t\ttrace('haai');\n\t}, configurable:true}\n)");
> + + "\n\t{set:function(value) {\n\t\tvar self =
> this;\n\t\t'haai';\n\t}, configurable:true}\n)");
> }
>
> @Override
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java
> index 6fe906d..c40adb9 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/goog/TestGoogEmitter.java
> @@ -111,7 +111,7 @@ public class TestGoogEmitter extends ASTestBase
> @Test
> public void testDefaultParameter()
> {
> - IFunctionNode node = getMethodWithPackage("function
> method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 +
> p4;}");
> + IFunctionNode node = getMethodWithPackage("function
> method1(p1:Number, p2:Number, p3:Number = 3, p4:Number = 4):Number{return
> p1 + p2 + p3 + p4;}");
> asBlockWalker.visitFunction(node);
> assertOut("/**\n * @param {number} p1\n * @param {number} p2\n *
> @param {number=} p3\n * @param {number=} p4\n * @return {number}\n */\n"
> + "foo.bar.RoyaleTest_A.prototype.method1 = function(p1,
> p2, p3, p4) {\n"
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
> index f496a4e..ecc034a 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
> @@ -149,6 +149,42 @@ public class TestRoyaleClass extends TestGoogClass
> }
>
> @Test
> + public void testMethod_returnInt()
> + {
> + IClassNode node = getClassNode("public class B {public function
> B() {}; public function foo():int { var a:Number = 123.4; return a; };}");
> + asBlockWalker.visitClass(node);
> + String expected = "/**\n * @constructor\n */\norg.apache.royale.B
> = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for
> reflection.\n */\ngoog.exportSymbol('org.apache.royale.B',
> org.apache.royale.B);\n\n\n/**\n * @export\n
> */\norg.apache.royale.B.prototype.foo = function() {\n var a /** @type
> {number} */ = 123.4;\n return (a) >> 0;\n};";
> + assertOut(expected);
> + }
> +
> + @Test
> + public void testMethod_returnIntLiteral()
> + {
> + IClassNode node = getClassNode("public class B {public function
> B() {}; public function foo():int { return 123.4 };}");
> + asBlockWalker.visitClass(node);
> + String expected = "/**\n * @constructor\n */\norg.apache.royale.B
> = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for
> reflection.\n */\ngoog.exportSymbol('org.apache.royale.B',
> org.apache.royale.B);\n\n\n/**\n * @export\n
> */\norg.apache.royale.B.prototype.foo = function() {\n return (123.4) >>
> 0;\n};";
> + assertOut(expected);
> + }
> +
> + @Test
> + public void testMethod_returnUint()
> + {
> + IClassNode node = getClassNode("public class B {public function
> B() {}; public function foo():uint { var a:Number = 123.4; return a; };}");
> + asBlockWalker.visitClass(node);
> + String expected = "/**\n * @constructor\n */\norg.apache.royale.B
> = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for
> reflection.\n */\ngoog.exportSymbol('org.apache.royale.B',
> org.apache.royale.B);\n\n\n/**\n * @export\n
> */\norg.apache.royale.B.prototype.foo = function() {\n var a /** @type
> {number} */ = 123.4;\n return (a) >>> 0;\n};";
> + assertOut(expected);
> + }
> +
> + @Test
> + public void testMethod_returnUintLiteral()
> + {
> + IClassNode node = getClassNode("public class B {public function
> B() {}; public function foo():uint { return 123.4 };}");
> + asBlockWalker.visitClass(node);
> + String expected = "/**\n * @constructor\n */\norg.apache.royale.B
> = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for
> reflection.\n */\ngoog.exportSymbol('org.apache.royale.B',
> org.apache.royale.B);\n\n\n/**\n * @export\n
> */\norg.apache.royale.B.prototype.foo = function() {\n return (123.4) >>>
> 0;\n};";
> + assertOut(expected);
> + }
> +
> + @Test
> public void testMethod_override()
> {
> IClassNode node = getClassNode("public class B {public function
> B() {}; override public function foo():void {};}");
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
> index e8c40a8..25fccbb 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
> @@ -330,7 +330,7 @@ public class TestRoyaleEmitter extends TestGoogEmitter
> @Test
> public void testDefaultParameter()
> {
> - IFunctionNode node = getMethodWithPackage("function
> method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 +
> p4;}");
> + IFunctionNode node = getMethodWithPackage("function
> method1(p1:Number, p2:Number, p3:Number = 3, p4:Number = 4):Number{return
> p1 + p2 + p3 + p4;}");
> asBlockWalker.visitFunction(node);
> assertOut("/**\n * @param {number} p1\n * @param {number} p2\n *
> @param {number=} p3\n * @param {number=} p4\n * @return {number}\n */\n"
> + "foo.bar.RoyaleTest_A.prototype.method1 = function(p1,
> p2, p3, p4) {\n"
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
> index 713c26f..7aeb0f6 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
> @@ -269,10 +269,82 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> }
>
> @Test
> + public void testVisitBinaryOperatorNode_AssignmentIntVarToInt()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var integer1:int;var
> integer2:int;integer1 = integer2");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("integer1 = integer2");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentNumberVarToInt()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var integer:int;var
> number:Number;integer = number");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("integer = (number) >> 0");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentUintVarToInt()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var integer:int;var
> unsigned_integer:uint;integer = unsigned_integer");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("integer = (unsigned_integer) >> 0");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentNumberLiteralToInt()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var
> numToInt:int;numToInt = 123.4");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("numToInt = (123.4) >> 0");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentIntLiteralToInt()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var
> numToInt:int;numToInt = 321");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("numToInt = 321");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentUintVarToUint()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var
> unsigned_integer1:uint;var unsigned_integer2:uint;unsigned_integer1 =
> unsigned_integer2");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("unsigned_integer1 = unsigned_integer2");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentNumberVarToUint()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var
> unsigned_integer:uint;var number:Number;unsigned_integer = number");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("unsigned_integer = (number) >>> 0");
> + }
> +
> + @Test
> + public void testVisitBinaryOperatorNode_AssignmentIntVarToUint()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var
> unsigned_integer:uint;var integer:int;unsigned_integer = integer");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("unsigned_integer = (integer) >>> 0");
> + }
> +
> + @Test
> + public void
> testVisitBinaryOperatorNode_AssignmentNumberLiteralToUint()
> + {
> + IBinaryOperatorNode node = getBinaryNode("var
> numToUint:uint;numToUint = 123.4");
> + asBlockWalker.visitBinaryOperator(node);
> + assertOut("numToUint = (123.4) >>> 0");
> + }
> +
> + @Test
> public void testVisitBinaryOperatorNode_setterAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function c() { b = 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function c() { b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -282,7 +354,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_setterAssignmentWithThis()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function c() { this.b = 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function c() { this.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -292,7 +364,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_setterAssignmentPrivate()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function get b():int { return 0;
> } private function set b(value:int):void {}; public function test() {
> this.b = 1; }}",
> + "public class B {public function get b():Number { return
> 0; } private function set b(value:Number):void {}; public function test() {
> this.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -302,7 +374,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_setterAssignmentPrivateWithNamespace()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function get b():int { return 0;
> } private function set b(value:int):void {}; public function test() {
> this.private::b = 1; }}",
> + "public class B {public function get b():Number { return
> 0; } private function set b(value:Number):void {}; public function test() {
> this.private::b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -316,7 +388,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> // disconnect fileNode from parent
> // set thisclass on emitter to class def
> IFileNode node = (IFileNode) getNode(
> - "public class B { public function c() { this.b = 1; };
> public function set b(value:int):void {}}",
> + "public class B { public function c() { this.b = 1; };
> public function set b(value:Number):void {}}",
> IFileNode.class, WRAP_LEVEL_PACKAGE, true);
> IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
> node, IFunctionNode.class);
> @@ -340,7 +412,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> // disconnect fileNode from parent
> // set thisclass on emitter to class def
> IFileNode node = (IFileNode) getNode(
> - "public class B { public function c() { b = 1; }; public
> function set b(value:int):void {}}",
> + "public class B { public function c() { b = 1; }; public
> function set b(value:Number):void {}}",
> IFileNode.class, WRAP_LEVEL_PACKAGE, true);
> IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
> node, IFunctionNode.class);
> @@ -360,7 +432,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_setterAssignmentOtherInstance()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function c(other:B) { other.b = 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function c(other:B) { other.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("other.b = 1");
> @@ -370,7 +442,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_nestedSetterAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function get d():B {}; public function c(other:B) { d.d.b = 1;
> }}",
> + "public class B {public function set b(value:Number):void
> {}; public function get d():B {}; public function c(other:B) { d.d.b = 1;
> }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.d.d.b = 1");
> @@ -380,7 +452,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_nestedSetterAssignmentOtherInstance()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function get d():B {}; public function c(other:B) { other.d.b =
> 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function get d():B {}; public function c(other:B) { other.d.b =
> 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("other.d.b = 1");
> @@ -390,7 +462,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_setterAssignmentFromGetter()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function c() { b = b + 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function c() { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = this.b + 1");
> @@ -400,7 +472,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_setterAssignmentFromGetterMaskedByLocal()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function c() { var b:int; b = b + 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function c() { var b:Number; b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("b = b + 1");
> @@ -410,7 +482,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_setterAssignmentFromGetterMaskedByParam()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public function set b(value:int):void
> {}; public function c(b:int) { b = b + 1; }}",
> + "public class B {public function set b(value:Number):void
> {}; public function c(b:Number) { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("b = b + 1");
> @@ -420,7 +492,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_setterAssignmentFromInternalVar()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {var b:int; public function c() { b = b +
> 1; }}",
> + "public class B {var b:Number; public function c() { b =
> b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = this.b + 1");
> @@ -430,7 +502,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_staticSetterAssignmentFromInternalVar()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {static var b:int; public function c() {
> b = b + 1; }}",
> + "public class B {static var b:Number; public function c()
> { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("B.b = B.b + 1");
> @@ -440,7 +512,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_bindableAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public
> function c() { b = 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> function c() { b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -450,7 +522,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_bindableAssignmentWithThis()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public
> function c() { this.b = 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> function c() { this.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -460,7 +532,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_bindableAssignmentOtherInstance()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public
> function c(other:B) { other.b = 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> function c(other:B) { other.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("other.b = 1");
> @@ -470,7 +542,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_bindableSetterAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; [Bindable]
> public var d:B; public function c(other:B) { d.d.b = 1; }}",
> + "public class B {[Bindable] public var b:Number;
> [Bindable] public var d:B; public function c(other:B) { d.d.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.d.d.b = 1");
> @@ -480,7 +552,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_bindableSetterAssignmentOtherInstance()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; [Bindable]
> public var d:B; public function c(other:B) { other.d.b = 1; }}",
> + "public class B {[Bindable] public var b:Number;
> [Bindable] public var d:B; public function c(other:B) { other.d.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("other.d.b = 1");
> @@ -490,7 +562,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_bindableAssignmentFromGetter()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public
> function c() { b = b + 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> function c() { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = this.b + 1");
> @@ -500,7 +572,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_bindableAssignmentFromGetterMaskedByLocal()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public
> function c() { var b:int; b = b + 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> function c() { var b:Number; b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("b = b + 1");
> @@ -510,7 +582,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_bindableAssignmentFromGetterMaskedByParam()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public
> function c(b:int) { b = b + 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> function c(b:Number) { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("b = b + 1");
> @@ -520,7 +592,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_varAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public function c() {
> b = 1; }}",
> + "public class B {public var b:Number; public function c()
> { b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -530,7 +602,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_varAssignmentWithThis()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public function c() {
> this.b = 1; }}",
> + "public class B {public var b:Number; public function c()
> { this.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = 1");
> @@ -540,7 +612,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_varAssignmentOtherInstance()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public function
> c(other:B) { other.b = 1; }}",
> + "public class B {public var b:Number; public function
> c(other:B) { other.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("other.b = 1");
> @@ -550,7 +622,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_varSetterAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public var
> d:B; public function c(other:B) { d.d.b = 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> var d:B; public function c(other:B) { d.d.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.d.d.b = 1");
> @@ -560,7 +632,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_varVarAssignment()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public var d:B; public
> function c(other:B) { d.d.b = 1; }}",
> + "public class B {public var b:Number; public var d:B;
> public function c(other:B) { d.d.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.d.d.b = 1");
> @@ -570,7 +642,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_varSetterAssignmentOtherInstance()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {[Bindable] public var b:int; public var
> d:B; public function c(other:B) { other.d.b = 1; }}",
> + "public class B {[Bindable] public var b:Number; public
> var d:B; public function c(other:B) { other.d.b = 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("other.d.b = 1");
> @@ -580,7 +652,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_varAssignmentFromVar()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public function c() {
> b = b + 1; }}",
> + "public class B {public var b:Number; public function c()
> { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("this.b = this.b + 1");
> @@ -590,7 +662,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_varAssignmentFromVarMaskedByLocal()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public function c() {
> var b:int; b = b + 1; }}",
> + "public class B {public var b:Number; public function c()
> { var b:Number; b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("b = b + 1");
> @@ -600,7 +672,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_varAssignmentFromVarMaskedByParam()
> {
> IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
> - "public class B {public var b:int; public function
> c(b:int) { b = b + 1; }}",
> + "public class B {public var b:Number; public function
> c(b:Number) { b = b + 1; }}",
> IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
> asBlockWalker.visitBinaryOperator(node);
> assertOut("b = b + 1");
> @@ -610,7 +682,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testVisitBinaryOperatorNode_staticSetterAssignment()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function c() { b = 1; }; public
> static function set b(value:int):void {}}",
> + "public class B {public function c() { b = 1; }; public
> static function set b(value:Number):void {}}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> IBinaryOperatorNode bnode = (IBinaryOperatorNode)
> findFirstDescendantOfType(
> node, IBinaryOperatorNode.class);
> @@ -622,7 +694,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_staticSetterAssignmentWithPath()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function c() { foo.bar.B.b = 1;
> }; public static function set b(value:int):void {}}",
> + "public class B {public function c() { foo.bar.B.b = 1;
> }; public static function set b(value:Number):void {}}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> IBinaryOperatorNode bnode = (IBinaryOperatorNode)
> findFirstDescendantOfType(
> node, IBinaryOperatorNode.class);
> @@ -634,7 +706,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_staticSetterAssignmentOtherInstance()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function c() { d.b = 1; }; public
> function set b(value:int):void {}; public static function get d():B {}}",
> + "public class B {public function c() { d.b = 1; }; public
> function set b(value:Number):void {}; public static function get d():B {}}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> IBinaryOperatorNode bnode = (IBinaryOperatorNode)
> findFirstDescendantOfType(
> node, IBinaryOperatorNode.class);
> @@ -650,7 +722,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> // disconnect fileNode from parent
> // set thisclass on emitter to class def
> IFileNode node = (IFileNode) getNode(
> - "public class B {public function c() { d.b = 1; }; public
> function set b(value:int):void {}; public static function get d():B {}}",
> + "public class B {public function c() { d.b = 1; }; public
> function set b(value:Number):void {}; public static function get d():B {}}",
> IFileNode.class, WRAP_LEVEL_PACKAGE, true);
> IFunctionNode fnode = (IFunctionNode) findFirstDescendantOfType(
> node, IFunctionNode.class);
> @@ -670,7 +742,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_staticSetterAssignmentFromGetter()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function c() { b = b + 1; };
> public static function set b(value:int):void {}; public static function get
> b():int {}}",
> + "public class B {public function c() { b = b + 1; };
> public static function set b(value:Number):void {}; public static function
> get b():Number {}}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> IBinaryOperatorNode bnode = (IBinaryOperatorNode)
> findFirstDescendantOfType(
> node, IBinaryOperatorNode.class);
> @@ -682,7 +754,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_staticSetterAssignmentFromGetterMaskedByLocal()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function c() { var b:int; b = b +
> 1; }; public static function set b(value:int):void {}; public static
> function get b():int {}}",
> + "public class B {public function c() { var b:Number; b =
> b + 1; }; public static function set b(value:Number):void {}; public static
> function get b():Number {}}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> IBinaryOperatorNode bnode = (IBinaryOperatorNode)
> findFirstDescendantOfType(
> node, IBinaryOperatorNode.class);
> @@ -694,7 +766,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void
> testVisitBinaryOperatorNode_staticSetterAssignmentFromGetterMaskedByParam()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function c(b:int) { b = b + 1; };
> public static function set b(value:int):void {}; public static function get
> b():int {}}",
> + "public class B {public function c(b:Number) { b = b + 1;
> }; public static function set b(value:Number):void {}; public static
> function get b():Number {}}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> IBinaryOperatorNode bnode = (IBinaryOperatorNode)
> findFirstDescendantOfType(
> node, IBinaryOperatorNode.class);
> @@ -1036,7 +1108,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testNativeGetter()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function b():int { var s:String;
> return s.length; }}",
> + "public class B {public function b():Number { var
> s:String; return s.length; }}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> asBlockWalker.visitFunction(node);
> // String.length is a getter but is a property in JS, so don't
> generate set_length() call.
> @@ -1047,7 +1119,7 @@ public class TestRoyaleExpressions extends
> TestGoogExpressions
> public void testNativeVectorGetter()
> {
> IFunctionNode node = (IFunctionNode) getNode(
> - "public class B {public function b():int { var
> a:Vector.<String>; return a.length; }}",
> + "public class B {public function b():Number { var
> a:Vector.<String>; return a.length; }}",
> IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
> asBlockWalker.visitFunction(node);
> // String.length is a getter but is a property in JS, so don't
> generate set_length() call.
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
> index 77d148c..f823df8 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalClasses.java
> @@ -675,7 +675,7 @@ public class TestRoyaleGlobalClasses extends
> TestGoogGlobalClasses
> IASNode parentNode = node.getParent();
> node = (IVariableNode) parentNode.getChild(1);
> asBlockWalker.visitVariable(node);
> - assertOut("var /** @type {number} */ b =
> a.child('child').length()");
> + assertOut("var /** @type {number} */ b =
> (a.child('child').length()) >> 0");
> }
>
> @Test
> @@ -939,7 +939,7 @@ public class TestRoyaleGlobalClasses extends
> TestGoogGlobalClasses
> {
> IForLoopNode node = getForLoopNode("var a:XML = new XML(\"<top
> attr1='cat'><child attr2='dog'><grandchild
> attr3='fish'>text</grandchild></child></top>\");for each (var p:XMLList in
> a) var i:int = p.length();");
> asBlockWalker.visitForLoop(node);
> - assertOut("var foreachiter0_target = a;\nfor (var foreachiter0 in
> foreachiter0_target.elementNames()) \n{\nvar p =
> foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i =
> p.length();}\n");
> + assertOut("var foreachiter0_target = a;\nfor (var foreachiter0 in
> foreachiter0_target.elementNames()) \n{\nvar p =
> foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i =
> (p.length()) >> 0;}\n");
> }
>
> @Test
> @@ -947,7 +947,7 @@ public class TestRoyaleGlobalClasses extends
> TestGoogGlobalClasses
> {
> IForLoopNode node = getForLoopNode("var a:*;for each (var p:XML in
> (a as XMLList)) var i:int = p.length();");
> asBlockWalker.visitForLoop(node);
> - assertOut("var foreachiter0_target =
> org.apache.royale.utils.Language.as(a, XMLList);\nfor (var foreachiter0
> in foreachiter0_target.elementNames()) \n{\nvar p =
> foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i =
> p.length();}\n");
> + assertOut("var foreachiter0_target =
> org.apache.royale.utils.Language.as(a, XMLList);\nfor (var foreachiter0
> in foreachiter0_target.elementNames()) \n{\nvar p =
> foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i =
> (p.length()) >> 0;}\n");
> }
>
> @Test
> @@ -955,7 +955,7 @@ public class TestRoyaleGlobalClasses extends
> TestGoogGlobalClasses
> {
> IForLoopNode node = getForLoopNode("var a:*;for each (var p:XML in
> XMLList(a)) var i:int = p.length();");
> asBlockWalker.visitForLoop(node);
> - assertOut("var foreachiter0_target = XMLList(a);\nfor (var
> foreachiter0 in foreachiter0_target.elementNames()) \n{\nvar p =
> foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i =
> p.length();}\n");
> + assertOut("var foreachiter0_target = XMLList(a);\nfor (var
> foreachiter0 in foreachiter0_target.elementNames()) \n{\nvar p =
> foreachiter0_target[foreachiter0];\n\n var /** @type {number} */ i =
> (p.length()) >> 0;}\n");
> }
>
> @Test
> @@ -1074,7 +1074,7 @@ public class TestRoyaleGlobalClasses extends
> TestGoogGlobalClasses
> "import custom.TestProxy; public class B {public function
> b() { var a:TestProxy = new TestProxy();for each (var p:String in a) var
> i:int = p.length; }}",
> IForLoopNode.class, WRAP_LEVEL_PACKAGE, true);
> asBlockWalker.visitForLoop(node);
> - assertOut("var foreachiter0_target = a;\nfor (var foreachiter0 in
> foreachiter0_target.propertyNames()) \n{\nvar p =
> foreachiter0_target.getProperty(foreachiter0);\n\n var /** @type {number}
> */ i = p.length;}\n");
> + assertOut("var foreachiter0_target = a;\nfor (var foreachiter0 in
> foreachiter0_target.propertyNames()) \n{\nvar p =
> foreachiter0_target.getProperty(foreachiter0);\n\n var /** @type {number}
> */ i = (p.length) >> 0;}\n");
> }
>
> @Test
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
> index 2c6eaf7..8f2f9d1 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleGlobalFunctions.java
> @@ -104,7 +104,7 @@ public class TestRoyaleGlobalFunctions extends
> TestGoogGlobalFunctions
> @Test
> public void testParseInt()
> {
> - IVariableNode node = getVariable("var a:int = parseInt('1.8');");
> + IVariableNode node = getVariable("var a:Number =
> parseInt('1.8');");
> asBlockWalker.visitVariable(node);
> assertOut("var /** @type {number} */ a = parseInt('1.8',
> undefined)");
> }
> @@ -112,7 +112,7 @@ public class TestRoyaleGlobalFunctions extends
> TestGoogGlobalFunctions
> @Test
> public void testParseIntTwoArgs()
> {
> - IVariableNode node = getVariable("var a:int = parseInt('1.8',
> 16);");
> + IVariableNode node = getVariable("var a:Number = parseInt('1.8',
> 16);");
> asBlockWalker.visitVariable(node);
> assertOut("var /** @type {number} */ a = parseInt('1.8', 16)");
> }
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
> index dc251a3..78cdcaf 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java
> @@ -147,7 +147,7 @@ public class TestRoyaleMethodMembers extends
> TestGoogMethodMembers
> {
> IClassNode node = (IClassNode) getNode("public function
> RoyaleTest_A(){}; private function foo(value:int):String{return value;};
> private function bar():String{if(true){while(i){return this.foo(42);}}};",
> IClassNode.class, WRAP_LEVEL_CLASS);
> asBlockWalker.visitClass(node);
> - assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
> {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n
> */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n *
> @private\n * @param {number} value\n * @return {string}\n
> */\nRoyaleTest_A.prototype.foo = function(value) {\n return
> value;\n};\n\n\n/**\n * @private\n * @return {string}\n
> */\nRoyaleTest_A.prototype.bar = function() {\n if (true) {\n while (i)
> {\n return this.foo(42);\n [...]
> + assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
> {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n
> */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n *
> @private\n * @param {number} value\n * @return {string}\n
> */\nRoyaleTest_A.prototype.foo = function(value) {\n return
> org.apache.royale.utils.Language.string(value);\n};\n\n\n/**\n * @private\n
> * @return {string}\n */\nRoyaleTest_A.prototype.bar = function() {\n if
> (true) {\n w [...]
> }
>
> @Test
> @@ -155,7 +155,7 @@ public class TestRoyaleMethodMembers extends
> TestGoogMethodMembers
> {
> IClassNode node = (IClassNode) getNode("public function
> RoyaleTest_A(){}; private function foo(value:int):String{return value;};
> private function bar():void{if(true){while(i){foo(42);}}};",
> IClassNode.class, WRAP_LEVEL_CLASS);
> asBlockWalker.visitClass(node);
> - assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
> {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n
> */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n *
> @private\n * @param {number} value\n * @return {string}\n
> */\nRoyaleTest_A.prototype.foo = function(value) {\n return
> value;\n};\n\n\n/**\n * @private\n */\nRoyaleTest_A.prototype.bar =
> function() {\n if (true) {\n while (i) {\n this.foo(42);\n }\n
> }\n};");
> + assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
> {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n
> */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n *
> @private\n * @param {number} value\n * @return {string}\n
> */\nRoyaleTest_A.prototype.foo = function(value) {\n return
> org.apache.royale.utils.Language.string(value);\n};\n\n\n/**\n * @private\n
> */\nRoyaleTest_A.prototype.bar = function() {\n if (true) {\n while (i)
> {\n thi [...]
> }
>
> @Override
> diff --git
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
> index 9de87f5..2f82899 100644
> ---
> a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
> +++
> b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleStatements.java
> @@ -96,6 +96,24 @@ public class TestRoyaleStatements extends
> TestGoogStatements
> assertOut("var /** @type {number} */ a = 0");
> }
>
> + @Test
> + public void testVarDeclaration_withTypeIntAndAssignedNumber()
> + {
> + IVariableNode node = (IVariableNode) getNode("var a:int = 123.4;",
> + IVariableNode.class);
> + asBlockWalker.visitVariable(node);
> + assertOut("var /** @type {number} */ a = (123.4) >> 0");
> + }
> +
> + @Test
> + public void testVarDeclaration_withTypeUintAndAssignedNumber()
> + {
> + IVariableNode node = (IVariableNode) getNode("var a:uint =
> 123.4;",
> + IVariableNode.class);
> + asBlockWalker.visitVariable(node);
> + assertOut("var /** @type {number} */ a = (123.4) >>> 0");
> + }
> +
> //----------------------------------
> // const declaration
> //----------------------------------
>
>
--
Piotr Zarzycki
Patreon: *https://www.patreon.com/piotrzarzycki
<https://www.patreon.com/piotrzarzycki>*