/** * generate prologue code for each function body */ protected void doPrologue(WalkContext context) { // perform a lexical write to copy the value stored in the local // associated with each parameter to the lexical name final CAstEntity entity = context.top(); Set<String> exposedNames = entity2ExposedNames.get(entity); if (exposedNames != null) { int i = 0; for (String arg : entity.getArgumentNames()) { if (exposedNames.contains(arg)) { final Scope currentScope = context.currentScope(); Symbol symbol = currentScope.lookup(arg); assert symbol.getDefiningScope() == currentScope; int argVN = symbol.valueNumber(); CAstType type = (entity.getType() instanceof CAstType.Method)? (CAstType)((CAstType.Method)entity.getType()).getArgumentTypes().get(i): topType(); Access A = new Access(arg, context.getEntityName(entity), makeType(type), argVN); context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A)); } } } }
@Override protected void declareFunction(CAstEntity N, WalkContext definingContext) { CAstType.Method methodType = (Method) N.getType(); CAstType owningType = methodType.getDeclaringType(); IClass owner = loader.lookupClass(makeType(owningType).getName()); assert owner != null || exclusions.contains(owningType.getName()) : makeType(owningType).getName().toString() + " not found in " + loader; if (owner != null && N.getQualifiers().contains(CAstQualifier.ABSTRACT)) { ((JavaSourceLoaderImpl) loader).defineAbstractFunction(N, owner); } }
/** * generate prologue code for each function body */ protected void doPrologue(WalkContext context) { // perform a lexical write to copy the value stored in the local // associated with each parameter to the lexical name final CAstEntity entity = context.top(); Set<String> exposedNames = entity2ExposedNames.get(entity); if (exposedNames != null) { int i = 0; for (String arg : entity.getArgumentNames()) { if (exposedNames.contains(arg)) { final Scope currentScope = context.currentScope(); Symbol symbol = currentScope.lookup(arg); assert symbol.getDefiningScope() == currentScope; int argVN = symbol.valueNumber(); CAstType type = (entity.getType() instanceof CAstType.Method)? (CAstType)((CAstType.Method)entity.getType()).getArgumentTypes().get(i): topType(); Access A = new Access(arg, context.getEntityName(entity), makeType(type), argVN); context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A)); } } } }
@Override protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { // N.B.: base class may actually ask to create a synthetic type to wrap // code bodies, so we may see other things than TYPE_ENTITY here. CAstType.Method methodType = (Method) N.getType(); CAstType owningType = methodType.getDeclaringType(); TypeName typeName = makeType(owningType).getName(); IClass owner = loader.lookupClass(typeName); assert owner != null || exclusions.contains(owningType.getName()) : typeName.toString() + " not found in " + loader; if (owner != null) { symtab.getConstant(0); symtab.getNullConstant(); ((JavaSourceLoaderImpl) loader).defineFunction(N, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo); } }
@Override protected void defineFunction(CAstEntity N, WalkContext definingContext, AbstractCFG<SSAInstruction, ? extends IBasicBlock<SSAInstruction>> cfg, SymbolTable symtab, boolean hasCatchBlock, Map<IBasicBlock<SSAInstruction>,TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { // N.B.: base class may actually ask to create a synthetic type to wrap // code bodies, so we may see other things than TYPE_ENTITY here. CAstType.Method methodType = (Method) N.getType(); CAstType owningType = methodType.getDeclaringType(); TypeName typeName = makeType(owningType).getName(); IClass owner = loader.lookupClass(typeName); assert owner != null || exclusions.contains(owningType.getName()) : typeName.toString() + " not found in " + loader; if (owner != null) { symtab.getConstant(0); symtab.getNullConstant(); ((JavaSourceLoaderImpl) loader).defineFunction(N, owner, cfg, symtab, hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo); } }
@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 void declareFunction(CAstEntity N, WalkContext definingContext) { CAstType.Method methodType = (Method) N.getType(); CAstType owningType = methodType.getDeclaringType(); IClass owner = loader.lookupClass(makeType(owningType).getName()); assert owner != null || exclusions.contains(owningType.getName()) : makeType(owningType).getName().toString() + " not found in " + loader; if (owner != null && N.getQualifiers().contains(CAstQualifier.ABSTRACT)) { ((JavaSourceLoaderImpl) loader).defineAbstractFunction(N, owner); } }
@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; } }