Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.VariableScope


        }
        MethodNode method =
                answer.addMethod("doCall", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, parameters, ClassNode.EMPTY_ARRAY, expression.getCode());
        method.setSourcePosition(expression);

        VariableScope varScope = expression.getVariableScope();
        if (varScope == null) {
            throw new RuntimeException(
                    "Must have a VariableScope by now! for expression: " + expression + " class: " + name);
        } else {
            method.setVariableScope(varScope.copy());
        }
        if (parameters.length > 1
                || (parameters.length == 1
                && parameters[0].getType() != null
                && parameters[0].getType() != ClassHelper.OBJECT_TYPE
View Full Code Here


        operandStack.remove(2);
        return true;
    }

    protected Parameter[] getClosureSharedVariables(ClosureExpression ce) {
        VariableScope scope = ce.getVariableScope();
        Parameter[] ret = new Parameter[scope.getReferencedLocalVariablesCount()];
        int index = 0;
        for (Iterator iter = scope.getReferencedLocalVariablesIterator(); iter.hasNext();) {
            Variable element = (org.codehaus.groovy.ast.Variable) iter.next();
            Parameter p = new Parameter(element.getType(), element.getName());
            p.setOriginType(element.getOriginType());
            p.setClosureSharedVariable(element.isClosureSharedVariable());
            ret[index] = p;
View Full Code Here

    private List<Statement> statements = new ArrayList<Statement>();
    private VariableScope scope;
   
    public BlockStatement() {
        this(new ArrayList<Statement>(), new VariableScope());
    }
View Full Code Here

            reformatted.setSafe(exp.isSafe());
            reformatted.setSpreadSafe(exp.isSpreadSafe());
            reformatted.setSourcePosition(exp);
            // wrap in a stringOf { ... } closure call
            ClosureExpression clos = new ClosureExpression(Parameter.EMPTY_ARRAY, new ExpressionStatement(reformatted));
            clos.setVariableScope(new VariableScope());
            MethodCallExpression stringOf = new MethodCallExpression(new VariableExpression("this"),
                    "stringOf",
                    clos);
            stringOf.setImplicitThis(true);
            stringOf.setSourcePosition(reformatted);
View Full Code Here

        super.visitClosureExpression(expression);
        if (inBuilderMethod) {
            Statement oldCode = expression.getCode();
            BlockStatement block = oldCode instanceof BlockStatement?
                    ((BlockStatement)oldCode):
                    new BlockStatement(Arrays.asList(oldCode), new VariableScope());
            List<Statement> statements = block.getStatements();
            if (!statements.isEmpty()) {
                Statement first = statements.get(0);
                Statement last = statements.get(statements.size()-1);
                if (expression.getLineNumber()<first.getLineNumber()) {
View Full Code Here

        new VariableExpression("test"), null, new ConstantExpression("test"));
    declarationExpression.addAnnotation(this.grabAnnotation);

    BlockStatement code = new BlockStatement(
        Arrays.asList((Statement) new ExpressionStatement(declarationExpression)),
        new VariableScope());

    MethodNode methodNode = new MethodNode("test", 0, new ClassNode(Void.class),
        new Parameter[0], new ClassNode[0], code);

    classNode.addMethod(methodNode);
View Full Code Here

                )
        );
    }

    protected static boolean isStatic(InnerClassNode node) {
        VariableScope scope = node.getVariableScope();
        if (scope != null) return scope.isInStaticContext();
        return (node.getModifiers() & Opcodes.ACC_STATIC) != 0;
    }
View Full Code Here

    private List<Statement> statements = new ArrayList<Statement>();
    private VariableScope scope;
   
    public BlockStatement() {
        this(new ArrayList<Statement>(), new VariableScope());
    }
View Full Code Here

        addCreator(getPath(scope, propertyPathExpression), creator);
    }

    private void addCreator(String path, Expression expression) {
        ClosureExpression wrappingClosure = new ClosureExpression(new Parameter[0], new ExpressionStatement(expression));
        wrappingClosure.setVariableScope(new VariableScope());
        addCreator(path, wrappingClosure);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.VariableScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.