@Override public CAstSourcePositionMap.Position getPosition() { return base.getPosition(); }
@Override public CAstSourcePositionMap.Position getPosition() { return base.getPosition(); }
@Override public Position getPosition(int arg) { return base.getPosition(arg); }
@Override public Position getPosition(int arg) { return base.getPosition(arg); }
private static CorrelatedPairExtractionPolicy addCorrelations(CAstEntity entity, Map<Position, CorrelationSummary> summaries, CorrelatedPairExtractionPolicy policy) { // add correlations for this entity if(entity.getAST() != null && summaries.containsKey(entity.getPosition())) { CorrelationSummary correlations = summaries.get(entity.getPosition()); for(Correlation corr : correlations.getCorrelations()) policy.addCorrelation(entity, corr, correlations); } // recursively add correlations for scoped entities Map<CAstNode, Collection<CAstEntity>> allScopedEntities = entity.getAllScopedEntities(); for(Collection<CAstEntity> scopedEntities : allScopedEntities.values()) for(CAstEntity scopedEntity : scopedEntities) if(addCorrelations(scopedEntity, summaries, policy) == null) return null; return policy; }
private static CorrelatedPairExtractionPolicy addCorrelations(CAstEntity entity, Map<Position, CorrelationSummary> summaries, CorrelatedPairExtractionPolicy policy) { // add correlations for this entity if(entity.getAST() != null && summaries.containsKey(entity.getPosition())) { CorrelationSummary correlations = summaries.get(entity.getPosition()); for(Correlation corr : correlations.getCorrelations()) policy.addCorrelation(entity, corr, correlations); } // recursively add correlations for scoped entities Map<CAstNode, Collection<CAstEntity>> allScopedEntities = entity.getAllScopedEntities(); for(Collection<CAstEntity> scopedEntities : allScopedEntities.values()) for(CAstEntity scopedEntity : scopedEntities) if(addCorrelations(scopedEntity, summaries, policy) == null) return null; return policy; }
@Override protected Position[] getParameterPositions(CAstEntity e) { if (e.getKind() == CAstEntity.SCRIPT_ENTITY) { return new Position[0]; } else { Position[] ps = new Position[ e.getArgumentCount() ]; for(int i = 2; i < e.getArgumentCount(); i++) { ps[i] = e.getPosition(i-2); } return ps; } }
@Override protected void declareFunction(CAstEntity N, WalkContext context) { String fnName = composeEntityName(context, N); if (N.getKind() == CAstEntity.SCRIPT_ENTITY) { ((JavaScriptLoader) loader).defineScriptType('L' + fnName, N.getPosition(), N, context); } else if (N.getKind() == CAstEntity.FUNCTION_ENTITY) { ((JavaScriptLoader) loader).defineFunctionType('L' + fnName, N.getPosition(), N, context); } else { Assertions.UNREACHABLE(); } }
@Override protected void declareFunction(CAstEntity N, WalkContext context) { String fnName = composeEntityName(context, N); if (N.getKind() == CAstEntity.SCRIPT_ENTITY) { ((JavaScriptLoader) loader).defineScriptType('L' + fnName, N.getPosition(), N, context); } else if (N.getKind() == CAstEntity.FUNCTION_ENTITY) { ((JavaScriptLoader) loader).defineFunctionType('L' + fnName, N.getPosition(), N, context); } else { Assertions.UNREACHABLE(); } }
@Override protected Position[] getParameterPositions(CAstEntity e) { if (e.getKind() == CAstEntity.SCRIPT_ENTITY) { return new Position[0]; } else { Position[] ps = new Position[ e.getArgumentCount() ]; for(int i = 2; i < e.getArgumentCount(); i++) { ps[i] = e.getPosition(i-2); } return ps; } }
public IClass defineType(CAstEntity type, String typeName, CAstEntity owner) { Collection<TypeName> superTypeNames = new ArrayList<>(); for (CAstType superType : type.getType().getSupertypes()) { superTypeNames.add(toWALATypeName(superType)); } JavaClass javaClass = new JavaClass(typeName, superTypeNames, type.getPosition(), type.getQualifiers(), this, (owner != null) ? (JavaClass) fTypeMap.get(owner) : (JavaClass) null, getAnnotations(type)); if (getParent().lookupClass(javaClass.getName()) != null) { return null; } fTypeMap.put(type, javaClass); loadedClasses.put(javaClass.getName(), javaClass); return javaClass; }
public IClass defineType(CAstEntity type, String typeName, CAstEntity owner) { Collection<TypeName> superTypeNames = new ArrayList<>(); for (CAstType superType : type.getType().getSupertypes()) { superTypeNames.add(toWALATypeName(superType)); } JavaClass javaClass = new JavaClass(typeName, superTypeNames, type.getPosition(), type.getQualifiers(), this, (owner != null) ? (JavaClass) fTypeMap.get(owner) : (JavaClass) null, getAnnotations(type)); if (getParent().lookupClass(javaClass.getName()) != null) { return null; } fTypeMap.put(type, javaClass); loadedClasses.put(javaClass.getName(), javaClass); return javaClass; }
@Override protected Position[] getParameterPositions(CAstEntity n) { int offset = 0; Position[] parameterPositions = new Position[ n.getArgumentCount() ]; if ((n.getType() instanceof CAstType.Method) && !((CAstType.Method)n.getType()).isStatic()) { offset = 1; } for(int i = 0; i < n.getArgumentCount() - offset; i++) { parameterPositions[i+offset] = n.getPosition(i); } return parameterPositions; } }
@Override protected Position[] getParameterPositions(CAstEntity n) { int offset = 0; Position[] parameterPositions = new Position[ n.getArgumentCount() ]; if ((n.getType() instanceof CAstType.Method) && !((CAstType.Method)n.getType()).isStatic()) { offset = 1; } for(int i = 0; i < n.getArgumentCount() - offset; i++) { parameterPositions[i+offset] = n.getPosition(i); } return parameterPositions; } }
if(!entity.getPosition().getURL().equals(startPos.getURL())) return true; startNodes = findNodesAtPos(CAstNode.OBJECT_REF, startPos, entity);
if(!entity.getPosition().getURL().equals(startPos.getURL())) return true; startNodes = findNodesAtPos(CAstNode.OBJECT_REF, startPos, entity);
if (n.getPosition() != null) { currentPosition = n.getPosition(); } else { currentPosition = null;
if (n.getPosition() != null) { currentPosition = n.getPosition(); } else { currentPosition = null;
public void closeFunctionEntity(final CAstEntity n, WalkContext parentContext, WalkContext functionContext) { // exit block functionContext.cfg().makeExitBlock(functionContext.cfg().newBlock(true)); // create code entry stuff for this entity SymbolTable symtab = ((AbstractScope) functionContext.currentScope()).getUnderlyingSymtab(); Map<IBasicBlock<SSAInstruction>,TypeReference[]> catchTypes = functionContext.getCatchTypes(); AstCFG cfg = new AstCFG(n, functionContext.cfg(), symtab, insts); Position[] line = functionContext.cfg().getLinePositionMap(); Position[][] operand = functionContext.cfg().getOperandPositionMap(); boolean katch = functionContext.cfg().hasCatchBlock(); boolean monitor = functionContext.cfg().hasMonitorOp(); String[] nms = makeNameMap(n, functionContext.entityScopes(), cfg.getInstructions()); /* * Set reachableBlocks = DFS.getReachableNodes(cfg, * Collections.singleton(cfg.entry())); * Assertions._assert(reachableBlocks.size() == cfg.getNumberOfNodes(), * cfg.toString()); */ // (put here to allow subclasses to handle stuff in scoped entities) // assemble lexical information AstLexicalInformation LI = new AstLexicalInformation(functionContext.getEntityName(n), functionContext.currentScope(), cfg.getInstructions(), functionContext.exposeNameSet(n, false), functionContext.exposeNameSet(n, true), functionContext.getAccesses(n)); Position[] parameterPositions = getParameterPositions(n); DebuggingInformation DBG = new AstDebuggingInformation(n.getNamePosition(), n.getPosition(), line, operand, parameterPositions, nms); // actually make code body defineFunction(n, parentContext, cfg, symtab, katch, catchTypes, monitor, LI, DBG); }
public void closeFunctionEntity(final CAstEntity n, WalkContext parentContext, WalkContext functionContext) { // exit block functionContext.cfg().makeExitBlock(functionContext.cfg().newBlock(true)); // create code entry stuff for this entity SymbolTable symtab = ((AbstractScope) functionContext.currentScope()).getUnderlyingSymtab(); Map<IBasicBlock<SSAInstruction>,TypeReference[]> catchTypes = functionContext.getCatchTypes(); AstCFG cfg = new AstCFG(n, functionContext.cfg(), symtab, insts); Position[] line = functionContext.cfg().getLinePositionMap(); Position[][] operand = functionContext.cfg().getOperandPositionMap(); boolean katch = functionContext.cfg().hasCatchBlock(); boolean monitor = functionContext.cfg().hasMonitorOp(); String[] nms = makeNameMap(n, functionContext.entityScopes(), cfg.getInstructions()); /* * Set reachableBlocks = DFS.getReachableNodes(cfg, * Collections.singleton(cfg.entry())); * Assertions._assert(reachableBlocks.size() == cfg.getNumberOfNodes(), * cfg.toString()); */ // (put here to allow subclasses to handle stuff in scoped entities) // assemble lexical information AstLexicalInformation LI = new AstLexicalInformation(functionContext.getEntityName(n), functionContext.currentScope(), cfg.getInstructions(), functionContext.exposeNameSet(n, false), functionContext.exposeNameSet(n, true), functionContext.getAccesses(n)); Position[] parameterPositions = getParameterPositions(n); DebuggingInformation DBG = new AstDebuggingInformation(n.getNamePosition(), n.getPosition(), line, operand, parameterPositions, nms); // actually make code body defineFunction(n, parentContext, cfg, symtab, katch, catchTypes, monitor, LI, DBG); }