本文整理汇总了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;
}
示例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);
}
}
}
}
}
示例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;
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}