public void visitBlockStatement(BlockStatement block) { VariableScope oldScope = currentScope; currentScope = block.getVariableScope(); super.visitBlockStatement(block); currentScope = oldScope; }
@Override public void visitBlockStatement(BlockStatement stat) { super.visitBlockStatement(stat); AstUtil.fixUpLocalVariables(dataProcessorVars, stat.getVariableScope(), false); } }
@Override public void visitBlockStatement(BlockStatement stat) { super.visitBlockStatement(stat); if (resources.getCurrentMethod() instanceof FeatureMethod) { AstUtil.fixUpLocalVariables(resources.getCurrentMethod().getAst().getParameters(), stat.getVariableScope(), false); } }
BlockStatement newBlock = new BlockStatement(statements, block.getVariableScope()); newBlock.setSourcePosition(block); constructorNode.setCode(newBlock);
if (!list.isEmpty()) { int idx = list.size() - 1; Statement last = addReturnsIfNeeded((Statement) list.get(idx), block.getVariableScope()); if (doAdd) list.set(idx, last); if (!statementReturns(last)) { BlockStatement newBlock = new BlockStatement(list, block.getVariableScope()); newBlock.setSourcePosition(block); return newBlock;
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(); // GROOVY-7647 if (block.getLastLineNumber() > 0) { MethodVisitor mv = controller.getMethodVisitor(); Label blockEnd = new Label(); mv.visitLabel(blockEnd); mv.visitLineNumber(block.getLastLineNumber(), blockEnd); } controller.getOperandStack().popDownTo(mark); }
public void visitMethod(MethodNode node) { Statement statement = node.getCode(); if (!node.isVoidMethod()) { if (statement != null) // it happens with @interface methods { final Statement code = addReturnsIfNeeded(statement, node.getVariableScope()); if (doAdd) node.setCode(code); } } else if (!node.isAbstract() && node.getReturnType().redirect()!=ClassHelper.VOID_TYPE) { if (!(statement instanceof BytecodeSequence)) { BlockStatement newBlock = new BlockStatement(); Statement code = node.getCode(); if (code instanceof BlockStatement) { newBlock.setVariableScope(((BlockStatement) code).getVariableScope()); } if (statement instanceof BlockStatement) { newBlock.addStatements(((BlockStatement)statement).getStatements()); } else { newBlock.addStatement(statement); } final ReturnStatement returnStatement = ReturnStatement.RETURN_NULL_OR_VOID; listener.returnStatementAdded(returnStatement); newBlock.addStatement(returnStatement); newBlock.setSourcePosition(statement); if (doAdd) node.setCode(newBlock); } } }
block.getVariableScope().putReferencedLocalVariable(outer); VariableExpression thisObject = new VariableExpression("_thisObject", classNode); thisObject.setSourcePosition(expression); block.getVariableScope().putReferencedLocalVariable(thisObject); TupleExpression conArgs = new TupleExpression(outer, thisObject); block.addStatement(
public void visitBlockStatement(BlockStatement block) { VariableScope oldScope = currentScope; currentScope = block.getVariableScope(); super.visitBlockStatement(block); currentScope = oldScope; }
public void visitBlockStatement(BlockStatement block) { VariableScope oldScope = currentScope; currentScope = block.getVariableScope(); super.visitBlockStatement(block); currentScope = oldScope; }
public void visitBlockStatement(BlockStatement block) { VariableScope oldScope = currentScope; currentScope = block.getVariableScope(); super.visitBlockStatement(block); currentScope = oldScope; }
public void visitBlockStatement(BlockStatement block) { VariableScope oldScope = currentScope; currentScope = block.getVariableScope(); super.visitBlockStatement(block); currentScope = oldScope; }
public void visitBlockStatement(BlockStatement block) { VariableScope oldScope = currentScope; currentScope = block.getVariableScope(); super.visitBlockStatement(block); currentScope = oldScope; }
public void visitBlockStatement(BlockStatement block) { onLineNumber(block, "visitBlockStatement"); visitStatement(block); compileStack.pushVariableScope(block.getVariableScope()); super.visitBlockStatement(block); compileStack.pop(); }
public void visitBlockStatement(BlockStatement block) { onLineNumber(block, "visitBlockStatement"); visitStatement(block); compileStack.pushVariableScope(block.getVariableScope()); super.visitBlockStatement(block); compileStack.pop(); }
public void visitBlockStatement(BlockStatement block) { onLineNumber(block, "visitBlockStatement"); visitStatement(block); compileStack.pushVariableScope(block.getVariableScope()); super.visitBlockStatement(block); compileStack.pop(); }
@Override public void visitBlockStatement(BlockStatement block) { blockStatement = block; blockStatementCopy = new BlockStatement(new ArrayList<Statement>(blockStatement.getStatements()), blockStatement.getVariableScope()); blockStatementCopy.copyNodeMetaData(blockStatement); blockStatementCopy.setSourcePosition(blockStatement); for (Statement statement : blockStatementCopy.getStatements()) { if (statement == returnStatement) { blockStatement.getStatements().remove(statement); blockStatement.addStatements(assertionCallStatement.getStatements()); VariableExpression variableExpression = new VariableExpression("result", returnType); variableExpression.setAccessedVariable(variableExpression); blockStatement.addStatement(new ReturnStatement(variableExpression)); return; // we found the return statement under target, let's cancel tree traversal } } super.visitBlockStatement(blockStatement); } }
@Override public void visitBlockStatement(BlockStatement block) { blockStatement = block; blockStatementCopy = new BlockStatement(new ArrayList<Statement>(blockStatement.getStatements()), blockStatement.getVariableScope()); blockStatementCopy.copyNodeMetaData(blockStatement); blockStatementCopy.setSourcePosition(blockStatement); for (Statement statement : blockStatementCopy.getStatements()) { if (statement == returnStatement) { blockStatement.getStatements().remove(statement); final VariableExpression $_gc_result = new VariableExpression("$_gc_result", ClassHelper.DYNAMIC_TYPE); $_gc_result.setAccessedVariable($_gc_result); blockStatement.addStatement(new ExpressionStatement( new DeclarationExpression($_gc_result, Token.newSymbol(Types.ASSIGN, -1, -1), returnStatement.getExpression()) )); blockStatement.addStatement(assertionCallStatement); ReturnStatement gcResultReturn = new ReturnStatement($_gc_result); gcResultReturn.setSourcePosition(returnStatement); blockStatement.addStatement(gcResultReturn); return; // we found the return statement under target, let's cancel tree traversal } } super.visitBlockStatement(blockStatement); } }
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); }
private static Statement wrapStatements(Statement code, String threadingMethod) { // TODO deal with non-block statements if (!(code instanceof BlockStatement)) { return code; } BlockStatement codeBlock = (BlockStatement) code; List<Statement> statements = codeBlock.getStatements(); if (statements.isEmpty()) { return code; } VariableScope variableScope = codeBlock.getVariableScope(); BlockStatement block = new BlockStatement(); VariableScope blockScope = variableScope.copy(); makeVariablesShared(blockScope); block.setVariableScope(blockScope); ClosureExpression closure = new ClosureExpression(Parameter.EMPTY_ARRAY, code); VariableScope closureScope = variableScope.copy(); makeVariablesShared(closureScope); closure.setVariableScope(closureScope); block.addStatement(stmnt(new MethodCallExpression(THIS, threadingMethod, args(closure)))); return block; }