private int getOrInsertString(int utf8Index) throws IOException { int stringIndex = constantPool.lookForString(utf8Index); if (stringIndex == -1) { stringIndex = constantPool.poolSize() + 1; StringConstant stringConstant = new StringConstant(utf8Index); constantPool.add(stringConstant); stringConstant.serializeToStream(constantStream); } return stringIndex; }
public void visitStringConstant(Clazz clazz, StringConstant stringConstant) { if (shouldBeMarkedAsUsed(stringConstant)) { markAsUsed(stringConstant); markConstant(clazz, stringConstant.u2stringIndex); // Mark the referenced class and class member, if any. stringConstant.referencedClassAccept(this); stringConstant.referencedMemberAccept(this); } }
public void visitStringConstant(Clazz clazz, StringConstant stringConstant) { if (shouldBeMarkedAsUsed(stringConstant)) { markAsUsed(stringConstant); markConstant(clazz, stringConstant.u2stringIndex); // Mark the referenced class and its parameterless constructor, // if the string is being used in a Class.forName construct. // stringConstant.referencedClassAccept(dynamicClassMarker); // Mark the referenced class or class member, if any. stringConstant.referencedClassAccept(this); stringConstant.referencedMemberAccept(this); } }
private static void generateConstantStub(StringBuilder builder, Constant constant) { final String name = StringUtil.capitalize(constant.getName()); builder.append(name).append(" = "); if (constant instanceof Enum) { builder.append(((Enum) constant).getValue()); } else if (constant instanceof StringConstant) { builder.append("\'").append(((StringConstant) constant).getValue()).append("\'"); } else { builder.append("nil"); } builder.append("\n\n"); }
public void outAStringConstant(AStringConstant node) { String s = (String) mProductions.removeLast(); mProductions.addLast(StringConstant.v(s)); /* try { String t = StringTools.getUnEscapedStringOf(s); mProductions.push(StringConstant.v(t)); } catch(RuntimeException e) { G.v().out.println(s); throw e; } */ }
@Test public void various() throws Exception { MatchingFiltersFactory filters = new MatchingFiltersFactory(Module.LUCENE, Target.LUCENE); for (Predicate filter : filters.string(title, StringConstant.create("jurassic park"))) { if (unsupportedOperation(filter)) { continue; } testQuery(filter, 1); } for (Predicate filter : filters.string(author, StringConstant.create("michael crichton"))) { if (unsupportedOperation(filter)) { continue; } testQuery(filter, 1); } for (Predicate filter : filters.string(title, StringConstant.create("1990"))) { if (unsupportedOperation(filter)) { continue; } testQuery(filter, 0); } }
public void visitStringConstant(Clazz clazz, StringConstant stringConstant) { // Mark the referenced field, if any. stringConstant.referencedMemberAccept(this); }
Object decodeDefaultValue() { Object value = null; // u1 tag; int tag = u1At(this.readOffset); this.readOffset++; int constValueOffset = -1; switch (tag) { case 'Z': // boolean constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = BooleanConstant.fromValue(i4At(constValueOffset + 1) == 1); this.readOffset += 2; break; case 'I': // integer constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = IntConstant.fromValue(i4At(constValueOffset + 1)); this.readOffset += 2; break; case 'C': // char constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = CharConstant.fromValue((char) i4At(constValueOffset + 1)); this.readOffset += 2; break; case 'B': // byte constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = ByteConstant.fromValue((byte) i4At(constValueOffset + 1)); this.readOffset += 2; break; case 'S': // short constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = ShortConstant.fromValue((short) i4At(constValueOffset + 1)); this.readOffset += 2; break; case 'D': // double constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = DoubleConstant.fromValue(doubleAt(constValueOffset + 1)); this.readOffset += 2; break; case 'F': // float constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = FloatConstant.fromValue(floatAt(constValueOffset + 1)); this.readOffset += 2; break; case 'J': // long constant constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = LongConstant.fromValue(i8At(constValueOffset + 1)); this.readOffset += 2; break; case 's': // String constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; value = StringConstant.fromValue( String.valueOf(utf8At(constValueOffset + 3, u2At(constValueOffset + 1)))); this.readOffset += 2; break; case 'e': constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; char[] typeName = utf8At(constValueOffset + 3, u2At(constValueOffset + 1)); this.readOffset += 2; constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; char[] constName = utf8At(constValueOffset + 3, u2At(constValueOffset + 1)); this.readOffset += 2; value = new EnumConstantSignature(typeName, constName); break; case 'c': constValueOffset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset; char[] className = utf8At(constValueOffset + 3, u2At(constValueOffset + 1)); value = new ClassSignature(className); this.readOffset += 2; break; case '@': value = new AnnotationInfo( this.reference, this.constantPoolOffsets, this.readOffset + this.structOffset, false, true); this.readOffset += ((AnnotationInfo) value).readOffset; break; case '[': int numberOfValues = u2At(this.readOffset); this.readOffset += 2; if (numberOfValues == 0) { value = EmptyValueArray; } else { Object[] arrayElements = new Object[numberOfValues]; value = arrayElements; for (int i = 0; i < numberOfValues; i++) arrayElements[i] = decodeDefaultValue(); } break; default: throw new IllegalStateException("Unrecognized tag " + (char) tag); // $NON-NLS-1$ } return value; }
/* * Generates the sequence of instructions needed to instrument ifStmtUnit * * @param ifStmtUnit: the unit to be instrumented * @return A Chain of Units that represent the instrumentation of ifStmtUnit */ private static Chain<Unit> generateInstrumentationUnits(Unit ifStmtUnit, Body b) { AbstractBinopExpr expression = (AbstractBinopExpr) ((JIfStmt) ifStmtUnit).getCondition(); // implementation of AbstractBinopExpr Value operand1 = expression.getOp1(); Value operand2 = expression.getOp2(); JimpleLocal op1Local = (JimpleLocal) operand1; // Local localOperand = Jimple.v().newLocal("op1", operand1.getType()); // b.getLocals().add(localOperand); // We need to use these operand as Locals or constants /** * JimpleLocal test; if(operand1 instanceof soot.jimple.internal.JimpleLocal) test = * (JimpleLocal)operand1; else test = null; */ String op = expression.getClass().toString(); Chain<Unit> resultUnits = new HashChain<Unit>(); Local tmpRef; // Add locals directely on the top of the body, java.io.printStream tmpRef tmpRef = Jimple.v().newLocal("tmpRef", RefType.v("java.io.PrintStream")); b.getLocals().addFirst(tmpRef); // add "tmpRef = java.lang.System.out" resultUnits.add( Jimple.v() .newAssignStmt( tmpRef, Jimple.v() .newStaticFieldRef( Scene.v() .getField("<java.lang.System: java.io.PrintStream out>") .makeRef()))); { SootMethod toCall = Scene.v().getMethod("<java.io.PrintStream: void println(java.lang.String)>"); resultUnits.add( Jimple.v() .newInvokeStmt( Jimple.v() .newVirtualInvokeExpr( tmpRef, toCall.makeRef(), StringConstant.v("Operande 1: ")))); resultUnits.add( Jimple.v() .newInvokeStmt( Jimple.v() .newVirtualInvokeExpr( tmpRef, toCall.makeRef(), StringConstant.v(operand1.getClass().toString())))); resultUnits.add( Jimple.v() .newInvokeStmt( Jimple.v() .newVirtualInvokeExpr( tmpRef, toCall.makeRef(), StringConstant.v("Operande 2:")))); resultUnits.add( Jimple.v() .newInvokeStmt( Jimple.v() .newVirtualInvokeExpr( tmpRef, toCall.makeRef(), StringConstant.v(operand2.getClass().toString())))); resultUnits.add( Jimple.v() .newInvokeStmt( Jimple.v() .newVirtualInvokeExpr( tmpRef, toCall.makeRef(), StringConstant.v("Operateur: ")))); resultUnits.add( Jimple.v() .newInvokeStmt( Jimple.v().newVirtualInvokeExpr(tmpRef, toCall.makeRef(), StringConstant.v(op)))); } return resultUnits; }
public void visitStringConstant(Clazz clazz, StringConstant stringConstant) { // Let the visitor visit the class referenced in the string constant. stringConstant.referencedClassAccept(classVisitor); }