public ASArrayAccessExpression newArrayAccessExpression(Expression target, Expression subscript) { LinkedListTree ast = ASTUtils.newImaginaryAST(AS3Parser.ARRAY_ACC); LinkedListTree targetExpr = ast(target); ASTBuilder.assertNoParent("target expression", targetExpr); // TODO: recursively check the given subexpression ast.addChildWithTokens(targetExpr); ast.appendToken(TokenBuilder.newLBrack()); LinkedListTree subscriptExpr = ast(subscript); ASTBuilder.assertNoParent("subscript expression", subscriptExpr); ast.addChildWithTokens(subscriptExpr); ast.appendToken(TokenBuilder.newRBrack()); ASTASArrayAccessExpression result = new ASTASArrayAccessExpression(ast); return result; }
public ASInvocationExpression newInvocationExpression(Expression sub, List args) { LinkedListTree ast = ASTUtils.newImaginaryAST(AS3Parser.METHOD_CALL); LinkedListTree subExpr = ast(sub); ASTBuilder.assertNoParent("sub-expression", subExpr); // TODO: recursively check the given subexpression ast.addChildWithTokens(subExpr); LinkedListTree arguments = ASTUtils.newParentheticAST( AS3Parser.ARGUMENTS, AS3Parser.LPAREN, "(", AS3Parser.RPAREN, ")"); ast.addChildWithTokens(arguments); ASTASInvocationExpression result = new ASTASInvocationExpression(ast); result.setArguments(args); return result; }
public ASNewExpression newNewExpression(Expression subexpression, List args) { LinkedListTree ast = ASTUtils.newAST(AS3Parser.NEW, "new"); ast.appendToken(TokenBuilder.newSpace()); LinkedListTree subExpr = ast(subexpression); ASTBuilder.assertNoParent("sub-expression", subExpr); // TODO: recursively check the given subexpression ast.addChildWithTokens(subExpr); LinkedListTree arguments = ASTUtils.newParentheticAST( AS3Parser.ARGUMENTS, AS3Parser.LPAREN, "(", AS3Parser.RPAREN, ")"); ast.addChildWithTokens(arguments); ASTASNewExpression result = new ASTASNewExpression(ast); result.setArguments(args); return result; }
private ASPrefixExpression newPrefixExpression(LinkedListToken op, Expression sub) { LinkedListTree ast = ASTUtils.newAST(op); LinkedListTree subExpr = ast(sub); ASTBuilder.assertNoParent("sub-expression", subExpr); ast.addChildWithTokens(subExpr); return new ASTASPrefixExpression(ast); }
/** * @param argumentNode the ARGUMENTS AST node * @param args list of ASExpression objects to be used as the new argument list */ public static void overwriteArgsWithExpressionList(LinkedListTree argumentNode, List args) { // get rid of any old arguments, ASTUtils.deleteAllChildren(argumentNode); // add the new arguments, for (Iterator i = args.iterator(); i.hasNext(); ) { ASTExpression arg = (ASTExpression) i.next(); argumentNode.addChildWithTokens(arg.getAST()); if (i.hasNext()) { argumentNode.appendToken(TokenBuilder.newComma()); argumentNode.appendToken(TokenBuilder.newSpace()); } } }