LOG(DEBUG, "DEBUG", "\tinst: " + instr.toString()); int derefValueNumber = -1; if (instr instanceof SSAGetInstruction && !((SSAGetInstruction) instr).isStatic()) { derefValueNumber = ((SSAGetInstruction) instr).getRef(); } else if (instr instanceof SSAPutInstruction
@Override public int getNumberOfUses() { return (isStatic()) ? 0 : 1; }
@Override public int getNumberOfUses() { return (isStatic()) ? 0 : 1; }
@Override public void visitGet(SSAGetInstruction instruction) { if (!instruction.isStatic()) { this.varNumNew = instruction.getRef(); } }
@Override public void visitGet(SSAGetInstruction instruction) { if (!instruction.isStatic()) { this.varNumNew = instruction.getRef(); } }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { visitGetInternal(instruction.getDef(), instruction.getRef(), instruction.isStatic(), instruction.getDeclaredField()); }
@Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (isStatic()) return insts.GetInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], getDeclaredField()); else return insts.GetInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], uses == null ? getRef() : uses[0], getDeclaredField()); }
@Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (isStatic()) return insts.GetInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], getDeclaredField()); else return insts.GetInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], uses == null ? getRef() : uses[0], getDeclaredField()); }
@Override public void visitGet(SSAGetInstruction instruction) { if (!instruction.isStatic()) { final int ssaVar = instruction.getRef(); noIdentity = true; transfer1 = NullPointerState.denullifyFunction(ssaVar); transfer2 = NullPointerState.nullifyFunction(ssaVar); } else { noIdentity = false; transfer1 = NullPointerState.identityFunction(); transfer2 = NullPointerState.identityFunction(); } }
@Override public String toString(SymbolTable symbolTable) { if (isStatic()) { return getValueString(symbolTable, result) + " = getstatic " + getDeclaredField(); } else { return getValueString(symbolTable, result) + " = getfield " + getDeclaredField() + ' ' + getValueString(symbolTable, getRef()); } }
@Override public String toString(SymbolTable symbolTable) { if (isStatic()) { return getValueString(symbolTable, result) + " = getstatic " + getDeclaredField(); } else { return getValueString(symbolTable, result) + " = getfield " + getDeclaredField() + ' ' + getValueString(symbolTable, getRef()); } }
public static int countGetfields(Collection<Statement> slice) { int count = 0; for (Statement s : slice) { if (s.getKind().equals(Statement.Kind.NORMAL)) { NormalStatement ns = (NormalStatement) s; if (ns.getInstruction() instanceof SSAGetInstruction) { SSAGetInstruction p = (SSAGetInstruction) ns.getInstruction(); if (!p.isStatic()) { count++; } } } } return count; }
@Test public void testQualifiedStatic() throws IllegalArgumentException, CancelException, IOException { runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), Collections.singletonList( cg -> { MethodReference mref = descriptorToMethodRef("Source#QualifiedStatic#main#([Ljava/lang/String;)V", cg.getClassHierarchy()); CGNode node = cg.getNodes(mref).iterator().next(); SSAInstruction s = node.getIR().getInstructions()[4]; Assert.assertTrue("Did not find a getstatic instruction.", s instanceof SSAGetInstruction && ((SSAGetInstruction) s).isStatic()); final FieldReference field = ((SSAGetInstruction) s).getDeclaredField(); Assert.assertEquals("Expected a getstatic for 'value'.", field.getName().toString(), "value"); Assert.assertEquals("Expected a getstatic for 'value'.", field.getDeclaringClass().getName().toString(), "LFooQ"); }), true, null); }