@Override public CAstControlFlowMap getControlFlow() { return copy.getControlFlow(); } }, visitor);
@Override public CAstControlFlowMap getControlFlow() { return copy.getControlFlow(); } }, visitor);
@Override public CAstControlFlowMap getControlFlow() { return N.getControlFlow(); }
@Override public CAstControlFlowMap getControlFlow() { return N.getControlFlow(); }
@Override public CAstControlFlowMap getControlFlow() { return base.getControlFlow(); }
@Override public CAstControlFlowMap getControlFlow() { return base.getControlFlow(); }
protected boolean isFlowDeleted(CAstNode node, CAstEntity entity) { CAstControlFlowMap flow = entity.getControlFlow(); return flow_to_delete.containsKey(flow) && flow_to_delete.get(flow).contains(node); }
protected boolean isFlowDeleted(CAstNode node, CAstEntity entity) { CAstControlFlowMap flow = entity.getControlFlow(); return flow_to_delete.containsKey(flow) && flow_to_delete.get(flow).contains(node); }
@Override public CAstControlFlowMap getControlFlow() { return top().getControlFlow(); }
public void deleteFlow(CAstNode node, CAstEntity entity) { CAstControlFlowMap flow = entity.getControlFlow(); Set<CAstNode> tmp = flow_to_delete.get(flow); if(tmp == null) flow_to_delete.put(flow, tmp = HashSetFactory.make()); tmp.add(node); }
public void deleteFlow(CAstNode node, CAstEntity entity) { CAstControlFlowMap flow = entity.getControlFlow(); Set<CAstNode> tmp = flow_to_delete.get(flow); if(tmp == null) flow_to_delete.put(flow, tmp = HashSetFactory.make()); tmp.add(node); }
@Override public CAstControlFlowMap getControlFlow() { return top().getControlFlow(); }
private CAstNode addExnFlow(CAstNode node, Object label, CAstEntity entity, NodePos pos) { return addExnFlow(node, label, entity.getControlFlow(), pos); }
private CAstNode addExnFlow(CAstNode node, Object label, CAstEntity entity, NodePos pos) { return addExnFlow(node, label, entity.getControlFlow(), pos); }
private void dump(CAstEntity entity, int indent, StringBuilder buf) { Collection<CAstEntity> scopedEntities = Collections.emptySet(); if(entity.getKind() == CAstEntity.SCRIPT_ENTITY) { buf.append(indent(indent)).append(entity.getName()).append(":\n"); scopedEntities = dumpScopedEntities(entity, indent+2, buf); dump(entity.getAST(), indent, buf, entity.getControlFlow()); } else if(entity.getKind() == CAstEntity.FUNCTION_ENTITY) { buf.append(indent(indent)).append("function ").append(entity.getName()).append('('); for(int i=0;i<entity.getArgumentCount();++i) { if(i>0) buf.append(", "); buf.append(entity.getArgumentNames()[i]); } buf.append(") {\n"); scopedEntities = dumpScopedEntities(entity, indent+2, buf); dump(entity.getAST(), indent+2, buf, entity.getControlFlow()); buf.append(indent(indent)).append("}\n\n"); } else { throw new Error("Unknown entity kind " + entity.getKind()); } for(CAstEntity scopedEntity : scopedEntities) dump(scopedEntity, indent, buf); }
private CAstNode copyGoto(CAstNode root, CAstControlFlowMap cfg, NodePos context, Map<Pair<CAstNode, NoKey>, CAstNode> nodeMap) { CAstNode target = getCurrentEntity().getControlFlow().getTarget(root, null); ExtractionPos epos = ExtractionPos.getEnclosingExtractionPos(context); if(epos != null && !NodePos.inSubtree(target, epos.getParent())) { epos.addGotoTarget(root.getChildCount() > 0 ? (String)root.getChild(0).getValue(): null, target); int label = labeller.addNode(target); // return { type: 'goto', target: <label> } CAstNode returnLit = addNode( Ast.makeNode(OBJECT_LITERAL, addExnFlow( Ast.makeNode(CALL, addExnFlow(makeVarRef("Object"), JavaScriptTypes.ReferenceError, getCurrentEntity(), context), Ast.makeConstant("ctor")), null, getCurrentEntity(), context), Ast.makeConstant("type"), Ast.makeConstant("goto"), Ast.makeConstant("target"), Ast.makeConstant(String.valueOf((double) label))), getCurrentEntity().getControlFlow()); addNode(returnLit, getCurrentEntity().getControlFlow()); CAstNode newNode = Ast.makeNode(RETURN, returnLit); // remove outgoing cfg edges of the old node deleteFlow(root, getCurrentEntity()); nodeMap.put(Pair.make(root, context.key()), newNode); return newNode; } else { return copyNode(root, cfg, context, nodeMap); } }
private CAstNode copyGoto(CAstNode root, CAstControlFlowMap cfg, NodePos context, Map<Pair<CAstNode, NoKey>, CAstNode> nodeMap) { CAstNode target = getCurrentEntity().getControlFlow().getTarget(root, null); ExtractionPos epos = ExtractionPos.getEnclosingExtractionPos(context); if(epos != null && !NodePos.inSubtree(target, epos.getParent())) { epos.addGotoTarget(root.getChildCount() > 0 ? (String)root.getChild(0).getValue(): null, target); int label = labeller.addNode(target); // return { type: 'goto', target: <label> } CAstNode returnLit = addNode( Ast.makeNode(OBJECT_LITERAL, addExnFlow( Ast.makeNode(CALL, addExnFlow(makeVarRef("Object"), JavaScriptTypes.ReferenceError, getCurrentEntity(), context), Ast.makeConstant("ctor")), null, getCurrentEntity(), context), Ast.makeConstant("type"), Ast.makeConstant("goto"), Ast.makeConstant("target"), Ast.makeConstant(String.valueOf((double) label))), getCurrentEntity().getControlFlow()); addNode(returnLit, getCurrentEntity().getControlFlow()); CAstNode newNode = Ast.makeNode(RETURN, returnLit); // remove outgoing cfg edges of the old node deleteFlow(root, getCurrentEntity()); nodeMap.put(Pair.make(root, context.key()), newNode); return newNode; } else { return copyNode(root, cfg, context, nodeMap); } }
CAstControlFlowMap cfg = entity.getControlFlow(); for(int i=start;i<end;++i) { CAstNode stmt = block.getChild(i);
else then_branch = Ast.makeNode(GOTO); addFlow(then_branch, null, goto_target.snd, entity.getControlFlow()); if(fixup != null) fixup = Ast.makeNode(IF_STMT, cond, then_branch, fixup);
else then_branch = Ast.makeNode(GOTO); addFlow(then_branch, null, goto_target.snd, entity.getControlFlow()); if(fixup != null) fixup = Ast.makeNode(IF_STMT, cond, then_branch, fixup);