@Override protected int getMaxValueNumber() { return symtab.getMaxValueNumber(); }
@Override protected int getMaxValueNumber() { return symtab.getMaxValueNumber(); }
public String getValueString(int valueNumber) { if (valueNumber < 0 || valueNumber > getMaxValueNumber() || values[valueNumber] == null || values[valueNumber] instanceof PhiValue) { return "v" + valueNumber; } else { return "v" + valueNumber + ':' + values[valueNumber].toString(); } }
public String getValueString(int valueNumber) { if (valueNumber < 0 || valueNumber > getMaxValueNumber() || values[valueNumber] == null || values[valueNumber] instanceof PhiValue) { return "v" + valueNumber; } else { return "v" + valueNumber + ':' + values[valueNumber].toString(); } }
/** * Create a dataflow variable for each value number */ private void createVariables(VariableFactory factory) { vars = new IVariable[symbolTable.getMaxValueNumber() + 1]; for (int i = 1; i < vars.length; i++) { vars[i] = factory.makeVariable(i); } }
@Override public int size() { return getUnderlyingSymtab().getMaxValueNumber() + 1; }
/** * Create a dataflow variable for each value number */ private void createVariables(VariableFactory factory) { vars = new IVariable[symbolTable.getMaxValueNumber() + 1]; for (int i = 1; i < vars.length; i++) { vars[i] = factory.makeVariable(i); } }
/** * @return the maximum value number in a particular IR */ protected int getMaxValueNumber() { return ir.getSymbolTable().getMaxValueNumber(); }
/** * @return the maximum value number in a particular IR */ protected int getMaxValueNumber() { return ir.getSymbolTable().getMaxValueNumber(); }
protected void setLocal(int dest, int result) { assert result <= symbolTable.getMaxValueNumber(); workingState.setLocal(dest, result); }
protected void setLocal(int dest, int result) { assert result <= symbolTable.getMaxValueNumber(); workingState.setLocal(dest, result); }
@Override public int size() { return getUnderlyingSymtab().getMaxValueNumber() + 1; }
IntraprocNullPointerAnalysis(IR ir, ControlFlowGraph<SSAInstruction, T> cfg, TypeReference[] ignoreExceptions, ParameterState initialState, MethodState mState) { this.cfg = cfg; this.ir = ir; if (ir == null || ir.isEmptyIR()) { maxVarNum = -1; } else { maxVarNum = ir.getSymbolTable().getMaxValueNumber(); } this.ignoreExceptions = new HashSet<>(); if (ignoreExceptions != null) { this.ignoreExceptions.addAll(Arrays.asList(ignoreExceptions)); } this.initialState = initialState; this.mState = mState; }
IntraprocNullPointerAnalysis(IR ir, ControlFlowGraph<SSAInstruction, T> cfg, TypeReference[] ignoreExceptions, ParameterState initialState, MethodState mState) { this.cfg = cfg; this.ir = ir; if (ir == null || ir.isEmptyIR()) { maxVarNum = -1; } else { maxVarNum = ir.getSymbolTable().getMaxValueNumber(); } this.ignoreExceptions = new HashSet<>(); if (ignoreExceptions != null) { this.ignoreExceptions.addAll(Arrays.asList(ignoreExceptions)); } this.initialState = initialState; this.mState = mState; }
/** * Extract all results of the type inference analysis. * * @return an array, where the i'th variable holds the type abstraction of the i'th value number. */ public TypeAbstraction[] extractAllResults() { int numberOfVars = ir.getSymbolTable().getMaxValueNumber() + 1; TypeAbstraction[] ret = new TypeAbstraction[numberOfVars]; for (int i = 0; i < numberOfVars; ++i) { TypeVariable var = getVariable(i); ret[i] = var == null ? null : var.getType(); } return ret; }
/** * Extract all results of the type inference analysis. * * @return an array, where the i'th variable holds the type abstraction of the i'th value number. */ public TypeAbstraction[] extractAllResults() { int numberOfVars = ir.getSymbolTable().getMaxValueNumber() + 1; TypeAbstraction[] ret = new TypeAbstraction[numberOfVars]; for (int i = 0; i < numberOfVars; ++i) { TypeVariable var = getVariable(i); ret[i] = var == null ? null : var.getType(); } return ret; }
protected TypeInference makeTypeInference(IR ir, IClassHierarchy cha) { TypeInference ti = new JSTypeInference(ir, cha); if (DEBUG_TYPE_INFERENCE) { System.err.println(("IR of " + ir.getMethod())); System.err.println(ir); System.err.println(("TypeInference of " + ir.getMethod())); for (int i = 0; i <= ir.getSymbolTable().getMaxValueNumber(); i++) { if (ti.isUndefined(i)) { System.err.println((" value " + i + " is undefined")); } else { System.err.println((" value " + i + " has type " + ti.getType(i))); } } } return ti; }
protected TypeInference makeTypeInference(IR ir, IClassHierarchy cha) { TypeInference ti = new JSTypeInference(ir, cha); if (DEBUG_TYPE_INFERENCE) { System.err.println(("IR of " + ir.getMethod())); System.err.println(ir); System.err.println(("TypeInference of " + ir.getMethod())); for (int i = 0; i <= ir.getSymbolTable().getMaxValueNumber(); i++) { if (ti.isUndefined(i)) { System.err.println((" value " + i + " is undefined")); } else { System.err.println((" value " + i + " has type " + ti.getType(i))); } } } return ti; }
public IntraproceduralNullPointerAnalysis(IR ir) { if (ir == null || ir.isEmptyIR()) { throw new IllegalArgumentException("IR may not be null or empty."); } this.ir = ir; final int maxVarNum = ir.getSymbolTable().getMaxValueNumber(); SSACFG cfg = ir.getControlFlowGraph(); final NullPointerFrameWork<ISSABasicBlock> problem = new NullPointerFrameWork<>( cfg, ir); this.solver = new NullPointerSolver<>(problem, maxVarNum, ir, cfg.entry()); try { this.solver.solve(NO_PROGRESS_MONITOR); } catch (final CancelException e) { // can't happen as we have no monitor } }
@Test public void test1() { MethodReference method = scope.findMethod(AnalysisScope.APPLICATION, "LtypeInference/TI", Atom.findOrCreateUnicodeAtom("foo"), new ImmutableByteArray(UTF8Convert.toUTF8("()V"))); Assert.assertNotNull("method not found", method); IMethod imethod = cha.resolveMethod(method); Assert.assertNotNull("imethod not found", imethod); IR ir = cache.getIRFactory().makeIR(imethod, Everywhere.EVERYWHERE, options.getSSAOptions()); System.out.println(ir); TypeInference ti = TypeInference.make(ir, false); for (int i = 1; i <= ir.getSymbolTable().getMaxValueNumber(); i++) { System.err.println(i + " " + ti.getType(i)); } }