/** * @return the unique name that identifies the programming language * from which this class loader loads code. */ @Override public Language getLanguage() { return parent.getLanguage(); }
public static boolean representsNullType(InstanceKey key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key == null"); } IClass cls = key.getConcreteType(); Language L = cls.getClassLoader().getLanguage(); return L.isNullType(cls.getReference()); }
/** * Create an {@link InducedCFG} from an instruction array. * * NOTE: SIDE EFFECT!!! ... nulls out phi instructions in the instruction array! */ public InducedCFG makeControlFlowGraph(SSAInstruction[] instructions) { return this.getDeclaringClass().getClassLoader().getLanguage().makeInducedCFG(instructions, this, Everywhere.EVERYWHERE); }
@Override public Collection<IClass> getAllImplementedInterfaces() { HashSet<IClass> result = HashSetFactory.make(2); for (TypeReference ref : getClassLoader().getLanguage().getArrayInterfaces()) { IClass klass = loader.lookupClass(ref.getName()); if (klass != null) { result.add(klass); } } return result; }
protected ModVisitor<T, ? extends ExtendedHeapModel> makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) { return n.getMethod().getDeclaringClass().getClassLoader().getLanguage().makeModVisitor(n, result, pa, h, ignoreAllocHeapDefs); //return new ModVisitor<>(n, result, h, pa, ignoreAllocHeapDefs); }
/** * Generate a {@link MethodSummary} which is the "standard" representation of a method * that does nothing. Subclasses may override this method to implement alternative semantics * concerning what "do nothing" means. */ public MethodSummary generateNoOp(MethodReference m, boolean isStatic) { Language l = cha.resolveMethod(m).getDeclaringClass().getClassLoader().getLanguage(); return new NoOpSummary(l, m, isStatic); }
protected ModVisitor<T, ? extends ExtendedHeapModel> makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<T> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) { return n.getMethod().getDeclaringClass().getClassLoader().getLanguage().makeModVisitor(n, result, pa, h, ignoreAllocHeapDefs); //return new ModVisitor<>(n, result, h, pa, ignoreAllocHeapDefs); }
private void computeSuperclass() { superclassComputed = true; if (superName == null) { if (!getReference().equals(loader.getLanguage().getRootType())) { superClass = loader.lookupClass(loader.getLanguage().getRootType().getName()); } return; } superClass = loader.lookupClass(TypeName.findOrCreate(superName)); }
/** * if F is a supported constant representing a field, return the corresponding {@link InstanceFieldKey} for I. Otherwise, return {@code null}. */ protected PointerKey getInstanceFieldPointerKeyForConstant(InstanceKey I, ConstantKey<?> F) { Object v = F.getValue(); // FIXME: current only constant string are handled if (I.getConcreteType().getClassLoader().getLanguage().modelConstant(v)) { IField f = I.getConcreteType().getField(Atom.findOrCreateUnicodeAtom(String.valueOf(v))); return getPointerKeyForInstanceField(I, f); } return null; }
/** * if F is a supported constant representing a field, return the corresponding {@link InstanceFieldKey} for I. Otherwise, return {@code null}. */ protected PointerKey getInstanceFieldPointerKeyForConstant(InstanceKey I, ConstantKey<?> F) { Object v = F.getValue(); // FIXME: current only constant string are handled if (I.getConcreteType().getClassLoader().getLanguage().modelConstant(v)) { IField f = I.getConcreteType().getField(Atom.findOrCreateUnicodeAtom(String.valueOf(v))); return getPointerKeyForInstanceField(I, f); } return null; }
/** * Add constraints to represent the flow of exceptions to the exceptional return value for this node */ protected void addNodePassthruExceptionConstraints(CGNode node, IRView ir, DefUse du) { // add constraints relating to thrown exceptions that reach the exit block. List<ProgramCounter> peis = getIncomingPEIs(ir, ir.getExitBlock()); PointerKey exception = getPointerKeyForExceptionalReturnValue(node); TypeReference throwableType = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().getThrowableType(); IClass c = node.getClassHierarchy().lookupClass(throwableType); addExceptionDefConstraints(ir, du, node, peis, exception, Collections.singleton(c)); }
protected TypeInference(IR ir, boolean doPrimitives) { if (ir == null) { throw new IllegalArgumentException("ir is null"); } this.language = ir.getMethod().getDeclaringClass().getClassLoader().getLanguage(); this.cha = ir.getMethod().getDeclaringClass().getClassHierarchy(); this.ir = ir; this.doPrimitives = doPrimitives; this.BOTTOM = new ConeType(cha.getRootClass()); initialize(); solve(); }
/** * Add constraints to represent the flow of exceptions to the exceptional return value for this node */ protected void addNodePassthruExceptionConstraints(CGNode node, IRView ir, DefUse du) { // add constraints relating to thrown exceptions that reach the exit block. List<ProgramCounter> peis = getIncomingPEIs(ir, ir.getExitBlock()); PointerKey exception = getPointerKeyForExceptionalReturnValue(node); TypeReference throwableType = node.getMethod().getDeclaringClass().getClassLoader().getLanguage().getThrowableType(); IClass c = node.getClassHierarchy().lookupClass(throwableType); addExceptionDefConstraints(ir, du, node, peis, exception, Collections.singleton(c)); }
@Override public void visitInvoke(IInvokeInstruction instruction) { IClassLoader loader = getDeclaringClass().getClassLoader(); MethodReference m = MethodReference.findOrCreate(loader.getLanguage(), loader.getReference(), instruction.getClassType(), instruction.getMethodName(), instruction.getMethodSignature()); int programCounter = 0; programCounter = getProgramCounter(); CallSiteReference site = null; site = CallSiteReference.make(programCounter, m, instruction.getInvocationCode()); callSites.add(site); }
@Override protected void processCallingConstraints(CGNode caller, SSAAbstractInvokeInstruction instruction, CGNode target, InstanceKey[][] constParams, PointerKey uniqueCatchKey) { if (JavaScriptLoader.JS.equals(caller.getMethod().getDeclaringClass().getClassLoader().getLanguage())) { JSSSAPropagationCallGraphBuilder.processCallingConstraintsInternal(this, caller, instruction, target, constParams, uniqueCatchKey); } else { super.processCallingConstraints(caller, instruction, target, constParams, uniqueCatchKey); } }
private MethodReference computeMethodReference() { try { Atom name = Atom.findOrCreateUnicodeAtom(getMethodName()); ImmutableByteArray desc = ImmutableByteArray.make(getMethodSignature()); Descriptor D = Descriptor.findOrCreate(declaringClass.getClassLoader().getLanguage(), desc); return MethodReference.findOrCreate(declaringClass.getReference(), name, D); } catch (InvalidClassFileException e) { Assertions.UNREACHABLE(); return null; } }
private MethodReference computeMethodReference() { try { Atom name = Atom.findOrCreateUnicodeAtom(getMethodName()); ImmutableByteArray desc = ImmutableByteArray.make(getMethodSignature()); Descriptor D = Descriptor.findOrCreate(declaringClass.getClassLoader().getLanguage(), desc); return MethodReference.findOrCreate(declaringClass.getReference(), name, D); } catch (InvalidClassFileException e) { Assertions.UNREACHABLE(); return null; } }
@Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { MutableIntSet s = IntSetUtil.make(); for(int i = 0; i < caller.getIR().getCalls(site)[0].getNumberOfUses(); i++) { if (!caller.getMethod().getDeclaringClass().getClassLoader().getLanguage().methodsHaveDeclaredParameterTypes() || dispatchIndex(site, i)) { s.add(i); } } return s; }
@Override protected boolean sameMethod(CGNode opNode, String definingMethod) { if (JavaScriptLoader.JS.equals(opNode.getMethod().getDeclaringClass().getClassLoader().getLanguage())) { return definingMethod.equals(opNode.getMethod().getReference().getDeclaringClass().getName().toString()); } else { return false; } }
@Override protected void leaveTypeLiteralExpr(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) { WalkContext wc = c; assert n.getChild(0).getKind() == CAstNode.CONSTANT; String typeNameStr = (String) n.getChild(0).getValue(); TypeName typeName = TypeName.string2TypeName(typeNameStr); TypeReference typeRef = TypeReference.findOrCreate(loader.getReference(), typeName); int result = wc.currentScope().allocateTempValue(); c.setValue(n, result); wc.cfg().addInstruction(insts.LoadMetadataInstruction(wc.cfg().currentInstruction, result, loader.getLanguage().getConstantType(typeRef), typeRef)); }