int pos = 0; Iterator statements = method.getStatementIterator(); while (statements.hasNext()) { JStatement stmt = (JStatement)statements.next(); if (!(stmt instanceof JVariableDeclarationStatement)) { List newStmts = new LinkedList(); newStmts.add(new LIRWorkEntry (LoweringConstants.getStreamContext())); method.addAllStatements(pos, newStmts); break; } pos++; }
method.addStatementFirst(new LIRWorkEntry (LoweringConstants.getStreamContext()));
    private void addEntryExit(JMethodDeclaration method)    {        // add the entry node after all of the variable declarations        int pos = 0;        Iterator statements = method.getStatementIterator();        while (statements.hasNext()) {            JStatement stmt = (JStatement)statements.next();            if (!(stmt instanceof JVariableDeclarationStatement))            {                List newStmts = new LinkedList();                newStmts.add(new LIRWorkEntry                             (LoweringConstants.getStreamContext()));                method.addAllStatements(pos, newStmts);                break;            }            pos++;        }        // append an exit node        method.addStatement(new LIRWorkExit                            (LoweringConstants.getStreamContext()));        // prepend exit nodes before any return statements, too        method.accept(new SLIRReplacingVisitor() {                public Object visitReturnStatement(JReturnStatement self,                                                   JExpression expr)                {                    JStatement[] stmts = new JStatement[2];                    stmts[0] =                        new LIRWorkExit(LoweringConstants.getStreamContext());                    stmts[1] = self;                    return new JBlock(self.getTokenReference(), stmts, null);                }            });    }