@Override public CAstSourcePositionMap getSourceMap() { return e.getSourceMap(); } }, e.getAST());
@Override public CAstSourcePositionMap getSourceMap() { return N.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return e.getSourceMap(); } }, e.getAST());
@Override public CAstSourcePositionMap getSourceMap() { return base.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return copy.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return N.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return base.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return top.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return top.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return copy.getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return top().getSourceMap(); }
@Override public CAstSourcePositionMap getSourceMap() { return top().getSourceMap(); }
protected void doPrintTo(CAstEntity e, Writer w) { try { w.write(getEntityKindAsString(e.getKind())); w.write(": "); w.write(e.getName()); w.write('\n'); if (e.getArgumentNames().length > 0) { w.write("("); String[] names = e.getArgumentNames(); for (String name : names) { w.write(" " + name); } w.write(" )\n"); } if (e.getAST() != null) { doPrintTo(e.getAST(), e.getSourceMap(), w); w.write('\n'); } for (Collection<CAstEntity> collection : e.getAllScopedEntities().values()) { for (CAstEntity entity : collection) { doPrintTo(entity, w); } } w.flush(); } catch (IOException e1) { System.err.println("unexpected I/O exception " + e1); } } }
protected void doPrintTo(CAstEntity e, Writer w) { try { w.write(getEntityKindAsString(e.getKind())); w.write(": "); w.write(e.getName()); w.write('\n'); if (e.getArgumentNames().length > 0) { w.write("("); String[] names = e.getArgumentNames(); for (String name : names) { w.write(" " + name); } w.write(" )\n"); } if (e.getAST() != null) { doPrintTo(e.getAST(), e.getSourceMap(), w); w.write('\n'); } for (Collection<CAstEntity> collection : e.getAllScopedEntities().values()) { for (CAstEntity entity : collection) { doPrintTo(entity, w); } } w.flush(); } catch (IOException e1) { System.err.println("unexpected I/O exception " + e1); } } }
private static Set<ChildPos> findNodesAtPos(int kind, Position pos, CAstEntity entity) { Set<ChildPos> res = HashSetFactory.make(); CAstSourcePositionMap spmap = entity.getSourceMap(); CAstNode ast = entity.getAST(); for(int i=0;i<ast.getChildCount();++i) findNodesAtPos(kind, pos, spmap, new ChildPos(ast, i, new RootPos()), res); return res; }
private static Set<ChildPos> findNodesAtPos(int kind, Position pos, CAstEntity entity) { Set<ChildPos> res = HashSetFactory.make(); CAstSourcePositionMap spmap = entity.getSourceMap(); CAstNode ast = entity.getAST(); for(int i=0;i<ast.getChildCount();++i) findNodesAtPos(kind, pos, spmap, new ChildPos(ast, i, new RootPos()), res); return res; }
/** * assign rval to nm as appropriate, depending on the scope of ls */ protected void assignValue(CAstNode n, WalkContext context, Symbol ls, String nm, int rval) { if (context.currentScope().isGlobal(ls)) doGlobalWrite(context, nm, makeType(ls.type()), rval); else if (context.currentScope().isLexicallyScoped(ls)) { doLexicallyScopedWrite(context, nm, makeType(ls.type()), rval); } else { assert rval != -1 : CAstPrinter.print(n, context.top().getSourceMap()); doLocalWrite(context, nm, makeType(ls.type()), rval); } }
/** * assign rval to nm as appropriate, depending on the scope of ls */ protected void assignValue(CAstNode n, WalkContext context, Symbol ls, String nm, int rval) { if (context.currentScope().isGlobal(ls)) doGlobalWrite(context, nm, makeType(ls.type()), rval); else if (context.currentScope().isLexicallyScoped(ls)) { doLexicallyScopedWrite(context, nm, makeType(ls.type()), rval); } else { assert rval != -1 : CAstPrinter.print(n, context.top().getSourceMap()); doLocalWrite(context, nm, makeType(ls.type()), rval); } }
@Override protected boolean visitLoop(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) { WalkContext context = c; // loop test block context.cfg().newBlock(true); PreBasicBlock headerB = context.cfg().getCurrentBlock(); visitor.visit(n.getChild(0), context, visitor); assert c.getValue(n.getChild(0)) != -1 : "error in loop test " + CAstPrinter.print(n.getChild(0), context.top().getSourceMap()) + " of loop " + CAstPrinter.print(n, context.top().getSourceMap()); context.cfg().addInstruction( insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, c.getValue(n.getChild(0)), context .currentScope().getConstantValue(Integer.valueOf(0)), -1)); PreBasicBlock branchB = context.cfg().getCurrentBlock(); // loop body context.cfg().newBlock(true); visitor.visit(n.getChild(1), context, visitor); if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) { context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1)); PreBasicBlock bodyB = context.cfg().getCurrentBlock(); context.cfg().addEdge(bodyB, headerB); // next block context.cfg().newBlock(false); } PreBasicBlock nextB = context.cfg().getCurrentBlock(); // control flow mapping; context.cfg().addEdge(branchB, nextB); return true; }
@Override protected boolean visitLoop(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) { WalkContext context = c; // loop test block context.cfg().newBlock(true); PreBasicBlock headerB = context.cfg().getCurrentBlock(); visitor.visit(n.getChild(0), context, visitor); assert c.getValue(n.getChild(0)) != -1 : "error in loop test " + CAstPrinter.print(n.getChild(0), context.top().getSourceMap()) + " of loop " + CAstPrinter.print(n, context.top().getSourceMap()); context.cfg().addInstruction( insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, c.getValue(n.getChild(0)), context .currentScope().getConstantValue(Integer.valueOf(0)), -1)); PreBasicBlock branchB = context.cfg().getCurrentBlock(); // loop body context.cfg().newBlock(true); visitor.visit(n.getChild(1), context, visitor); if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) { context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1)); PreBasicBlock bodyB = context.cfg().getCurrentBlock(); context.cfg().addEdge(bodyB, headerB); // next block context.cfg().newBlock(false); } PreBasicBlock nextB = context.cfg().getCurrentBlock(); // control flow mapping; context.cfg().addEdge(branchB, nextB); return true; }