当前位置: 首页>>代码示例>>Java>>正文


Java Statement.visit方法代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.stmt.Statement.visit方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.visit方法的具体用法?Java Statement.visit怎么用?Java Statement.visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.groovy.ast.stmt.Statement的用法示例。


在下文中一共展示了Statement.visit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformClosureExpression

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
protected Expression transformClosureExpression(ClosureExpression ce) {
    boolean oldInClosure = inClosure;
    inClosure = true;
    Parameter[] paras = ce.getParameters();
    if (paras != null) {
        for (Parameter para : paras) {
            ClassNode t = para.getType();
            resolveOrFail(t, ce);
            visitAnnotations(para);
            if (para.hasInitialExpression()) {
                Object initialVal = para.getInitialExpression();
                if (initialVal instanceof Expression) {
                    para.setInitialExpression(transform((Expression) initialVal));
                }
            }
            visitAnnotations(para);
        }
    }
    Statement code = ce.getCode();
    if (code != null) {
        code.visit(this);
    }
    inClosure = oldInClosure;
    return ce;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:26,代码来源:GradleResolveVisitor.java

示例2: visit

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
private static void visit(Closure closure, CodeVisitorSupport visitor) {
    if (closure != null) {
        ClassNode classNode = closure.getMetaClass().getClassNode();
        if (classNode == null) {
            throw new GroovyRuntimeException(
                    "DataSet unable to evaluate expression. AST not available for closure: " + closure.getMetaClass().getTheClass().getName() +
                            ". Is the source code on the classpath?");
        }
        List methods = classNode.getDeclaredMethods("doCall");
        if (!methods.isEmpty()) {
            MethodNode method = (MethodNode) methods.get(0);
            if (method != null) {
                Statement statement = method.getCode();
                if (statement != null) {
                    statement.visit(visitor);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:DataSet.java

示例3: transformClosureExpression

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
protected Expression transformClosureExpression(ClosureExpression ce) {
    boolean oldInClosure = inClosure;
    inClosure = true;
    Parameter[] paras = ce.getParameters();
    if (paras != null) {
        for (Parameter para : paras) {
            ClassNode t = para.getType();
            resolveOrFail(t, ce);
            visitAnnotations(para);
            if (para.hasInitialExpression()) {
                Object initialVal = para.getInitialExpression();
                if (initialVal instanceof Expression) {
                    para.setInitialExpression(transform((Expression) initialVal));
                }
            }
            visitAnnotations(para);
        }
    }
    Statement code = ce.getCode();
    if (code != null) code.visit(this);
    inClosure = oldInClosure;
    return ce;
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:ResolveVisitor.java

示例4: visitBlockStatement

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
@Override
public void visitBlockStatement(BlockStatement block) {
    opt.push();
    boolean optAll = true;
    for (Statement statement : block.getStatements()) {
        opt.push();
        statement.visit(this);
        optAll = optAll && opt.canOptimize();
        opt.pop(true);
    }
    if (block.isEmpty()) {
        opt.chainCanOptimize(true);
        opt.pop(true);
    } else {
        opt.chainShouldOptimize(optAll);
        if (optAll) addMeta(block,opt);
        opt.pop(optAll);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:OptimizingStatementWriter.java

示例5: visitBytecodeSequence

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
public void visitBytecodeSequence(BytecodeSequence bytecodeSequence) {
    MethodVisitor mv = controller.getMethodVisitor();
    List instructions = bytecodeSequence.getInstructions();
    int mark = controller.getOperandStack().getStackLength();
    for (Iterator iterator = instructions.iterator(); iterator.hasNext();) {
        Object part = iterator.next();
        if (part == EmptyExpression.INSTANCE) {
            mv.visitInsn(ACONST_NULL);
        } else if (part instanceof Expression) {
            ((Expression) part).visit(this);
        } else if (part instanceof Statement) {
            Statement stm = (Statement) part;
            stm.visit(this);
            mv.visitInsn(ACONST_NULL);
        } else {
            BytecodeInstruction runner = (BytecodeInstruction) part;
            runner.visit(mv);
        }
    }
    controller.getOperandStack().remove(mark-controller.getOperandStack().getStackLength());
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AsmClassGenerator.java

示例6: visitBlockStatement

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
@Override
public void visitBlockStatement(BlockStatement block) {
    block.setNodeMetaData(AST_NODE_METADATA_KEY, true);

    for (Statement statement : block.getStatements()) {
        statement.visit(this);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:RulesVisitor.java

示例7: writeBlockStatement

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
public void writeBlockStatement(BlockStatement block) {
    CompileStack compileStack = controller.getCompileStack();

    //GROOVY-4505 use no line number information for the block
    writeStatementLabel(block);
    
    int mark = controller.getOperandStack().getStackLength();
    compileStack.pushVariableScope(block.getVariableScope());
    for (Statement statement : block.getStatements()) {
        statement.visit(controller.getAcg());
    }
    compileStack.pop();

    controller.getOperandStack().popDownTo(mark);
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:StatementWriter.java

示例8: transformClosureExpression

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
protected Expression transformClosureExpression(ClosureExpression ce) {
    boolean oldInClosure = inClosure;
    inClosure = true;
    if (ce.getParameters() != null) {
        for (Parameter p : ce.getParameters()) {
            if (p.hasInitialExpression()) {
                p.setInitialExpression(transform(p.getInitialExpression()));
            }
        }
    }
    Statement code = ce.getCode();
    if (code != null) code.visit(this);
    inClosure = oldInClosure;
    return ce;
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:StaticImportVisitor.java

示例9: visitStatement

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void visitStatement(final Statement statement) {
    if (criteria.call(statement)) {
        transformStatement((T) statement);
        return;
    }
    statement.visit(this);
}
 
开发者ID:grooviter,项目名称:asteroid,代码行数:12,代码来源:AbstractStatementTransformer.java

示例10: visitIfElse

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
public void visitIfElse(final IfStatement ifElse) {
    assertStatementAuthorized(ifElse);
    ifElse.getBooleanExpression().visit(this);
    ifElse.getIfBlock().visit(this);

    Statement elseBlock = ifElse.getElseBlock();
    if (elseBlock instanceof EmptyStatement) {
        // dispatching to EmptyStatement will not call back visitor,
        // must call our visitEmptyStatement explicitly
        visitEmptyStatement((EmptyStatement) elseBlock);
    } else {
        elseBlock.visit(this);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:SecureASTCustomizer.java

示例11: visitTryCatchFinally

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
public void visitTryCatchFinally(final TryCatchStatement statement) {
    assertStatementAuthorized(statement);
    statement.getTryStatement().visit(this);
    for (CatchStatement catchStatement : statement.getCatchStatements()) {
        catchStatement.visit(this);
    }
    Statement finallyStatement = statement.getFinallyStatement();
    if (finallyStatement instanceof EmptyStatement) {
        // dispatching to EmptyStatement will not call back visitor,
        // must call our visitEmptyStatement explicitly
        visitEmptyStatement((EmptyStatement) finallyStatement);
    } else {
        finallyStatement.visit(this);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:SecureASTCustomizer.java

示例12: makeBlockRecorder

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
private BlockRecorder makeBlockRecorder(final Statement finallyStatement) {
    final BlockRecorder block = new BlockRecorder();
    Runnable tryRunner = new Runnable() {
        public void run() {
            controller.getCompileStack().pushBlockRecorderVisit(block);
            finallyStatement.visit(controller.getAcg());
            controller.getCompileStack().popBlockRecorderVisit(block);
        }
    };
    block.excludedStatement = tryRunner;
    controller.getCompileStack().pushBlockRecorder(block);
    return block;
}
 
开发者ID:apache,项目名称:groovy,代码行数:14,代码来源:StatementWriter.java

示例13: visitIfElse

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
@Override
public void visitIfElse(final IfStatement ifElse) {
    Map<VariableExpression, List<ClassNode>> oldTracker = pushAssignmentTracking();

    try {
        // create a new temporary element in the if-then-else type info
        typeCheckingContext.pushTemporaryTypeInfo();
        visitStatement(ifElse);
        ifElse.getBooleanExpression().visit(this);
        ifElse.getIfBlock().visit(this);

        // pop if-then-else temporary type info
        typeCheckingContext.popTemporaryTypeInfo();

        // GROOVY-6099: restore assignment info as before the if branch
        restoreTypeBeforeConditional();

        Statement elseBlock = ifElse.getElseBlock();
        if (elseBlock instanceof EmptyStatement) {
            // dispatching to EmptyStatement will not call back visitor,
            // must call our visitEmptyStatement explicitly
            visitEmptyStatement((EmptyStatement) elseBlock);
        } else {
            elseBlock.visit(this);
        }
    } finally {
        popAssignmentTracking(oldTracker);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:30,代码来源:StaticTypeCheckingVisitor.java

示例14: processBody

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
private Statement processBody(VariableExpression thisObject, Statement code, ClassNode trait, ClassNode traitHelper, ClassNode fieldHelper, Collection<String> knownFields) {
    if (code == null) return null;
    NAryOperationRewriter operationRewriter = new NAryOperationRewriter(unit, knownFields);
    code.visit(operationRewriter);
    SuperCallTraitTransformer superTrn = new SuperCallTraitTransformer(unit);
    code.visit(superTrn);
    TraitReceiverTransformer trn = new TraitReceiverTransformer(thisObject, unit, trait, traitHelper, fieldHelper, knownFields);
    code.visit(trn);
    return code;
}
 
开发者ID:apache,项目名称:groovy,代码行数:11,代码来源:TraitASTTransformation.java

示例15: visitTryCatchFinally

import org.codehaus.groovy.ast.stmt.Statement; //导入方法依赖的package包/类
public void visitTryCatchFinally(TryCatchStatement statement) {
    statement.getTryStatement().visit(this);
    for (CatchStatement catchStatement : statement.getCatchStatements()) {
        catchStatement.visit(this);
    }
    Statement finallyStatement = statement.getFinallyStatement();
    if (finallyStatement instanceof EmptyStatement) {
        // dispatching to EmptyStatement will not call back visitor, 
        // must call our visitEmptyStatement explicitly
        visitEmptyStatement((EmptyStatement) finallyStatement);
    } else {
        finallyStatement.visit(this);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:CodeVisitorSupport.java


注:本文中的org.codehaus.groovy.ast.stmt.Statement.visit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。