@Override public int getConstantValue(Object o) { if (o instanceof Integer) { return getUnderlyingSymtab().getConstant(((Integer) o).intValue()); } else if (o instanceof Float) { return getUnderlyingSymtab().getConstant(((Float) o).floatValue()); } else if (o instanceof Double) { return getUnderlyingSymtab().getConstant(((Double) o).doubleValue()); } else if (o instanceof Long) { return getUnderlyingSymtab().getConstant(((Long) o).longValue()); } else if (o instanceof String) { return getUnderlyingSymtab().getConstant((String) o); } else if (o instanceof Boolean) { return getUnderlyingSymtab().getConstant((Boolean) o); } else if (o instanceof Character) { return getUnderlyingSymtab().getConstant(((Character) o).charValue()); } else if (o instanceof Byte) { return getUnderlyingSymtab().getConstant(((Byte) o).byteValue()); } else if (o instanceof Short) { return getUnderlyingSymtab().getConstant(((Short) o).shortValue()); } else if (o == null) { return getUnderlyingSymtab().getNullConstant(); } else if (o == CAstControlFlowMap.SWITCH_DEFAULT) { return getUnderlyingSymtab().getConstant("__default label"); } else { System.err.println(("cannot handle constant " + o)); Assertions.UNREACHABLE(); return -1; } }
@Override public int getConstantValue(Object o) { if (o instanceof Integer) { return getUnderlyingSymtab().getConstant(((Integer) o).intValue()); } else if (o instanceof Float) { return getUnderlyingSymtab().getConstant(((Float) o).floatValue()); } else if (o instanceof Double) { return getUnderlyingSymtab().getConstant(((Double) o).doubleValue()); } else if (o instanceof Long) { return getUnderlyingSymtab().getConstant(((Long) o).longValue()); } else if (o instanceof String) { return getUnderlyingSymtab().getConstant((String) o); } else if (o instanceof Boolean) { return getUnderlyingSymtab().getConstant((Boolean) o); } else if (o instanceof Character) { return getUnderlyingSymtab().getConstant(((Character) o).charValue()); } else if (o instanceof Byte) { return getUnderlyingSymtab().getConstant(((Byte) o).byteValue()); } else if (o instanceof Short) { return getUnderlyingSymtab().getConstant(((Short) o).shortValue()); } else if (o == null) { return getUnderlyingSymtab().getNullConstant(); } else if (o == CAstControlFlowMap.SWITCH_DEFAULT) { return getUnderlyingSymtab().getConstant("__default label"); } else { System.err.println(("cannot handle constant " + o)); Assertions.UNREACHABLE(); return -1; } }
int index = symbolTable.getConstant(i); int arrayRef = workingState.getLocal(instruction.array); TypeReference t = instruction.getType(); value = symbolTable.getConstant((char) ae.intValue()); else if (t.equals(TypeReference.Byte)) value = symbolTable.getConstant(ae.byteValue()); else if (t.equals(TypeReference.Short)) value = symbolTable.getConstant(ae.shortValue()); else if (t.equals(TypeReference.Int)) value = symbolTable.getConstant(ae.intValue()); else if (t.equals(TypeReference.Long)) value = symbolTable.getConstant(ae.longValue()); else if (t.equals(TypeReference.Float)) value = symbolTable.getConstant(ae.floatValue()); else if (t.equals(TypeReference.Double)) value = symbolTable.getConstant(ae.doubleValue()); else if (t.equals(TypeReference.Boolean)) value = symbolTable.getConstant(ae.intValue() != 0); else
int index = symbolTable.getConstant(i); int arrayRef = workingState.getLocal(instruction.array); TypeReference t = instruction.getType(); value = symbolTable.getConstant((char) ae.intValue()); else if (t.equals(TypeReference.Byte)) value = symbolTable.getConstant(ae.byteValue()); else if (t.equals(TypeReference.Short)) value = symbolTable.getConstant(ae.shortValue()); else if (t.equals(TypeReference.Int)) value = symbolTable.getConstant(ae.intValue()); else if (t.equals(TypeReference.Long)) value = symbolTable.getConstant(ae.longValue()); else if (t.equals(TypeReference.Float)) value = symbolTable.getConstant(ae.floatValue()); else if (t.equals(TypeReference.Double)) value = symbolTable.getConstant(ae.doubleValue()); else if (t.equals(TypeReference.Boolean)) value = symbolTable.getConstant(ae.intValue() != 0); else
symbol = symbolTable.getConstant(((Constant.IntConstant)instruction).value); symbol = symbolTable.getConstant(((Constant.LongConstant)instruction).value); symbol = symbolTable.getConstant(((Constant.StringConstant)instruction).value);
symbol = symbolTable.getConstant(((Constant.IntConstant)instruction).value); symbol = symbolTable.getConstant(((Constant.LongConstant)instruction).value); symbol = symbolTable.getConstant(((Constant.StringConstant)instruction).value);
@Override public void visitNewArrayFilled(NewArrayFilled instruction) { int dest = instruction.destination; int result = reuseOrCreateDef(); int[] sizes = new int[instruction.sizes.length]; for(int i = 0; i < instruction.sizes.length; i++) { sizes[i] = symbolTable.getConstant(instruction.sizes[i]); } emitInstruction(insts.NewInstruction(getCurrentInstructionIndex(), result, instruction.newSiteRef, sizes)); setLocal(dest, result); /* * we need to emit these instructions somehow, but for now this clobbers the emitInstruction mechanism * for (int i = 0; i < instruction.args.length; i++) { int value = workingState.getLocal(instruction.args[i]); int index = symbolTable.getConstant(i); int arrayRef = result; TypeReference t = instruction.myType; emitInstruction(insts.ArrayStoreInstruction(getCurrentInstructionIndex(), arrayRef, index, value, t)); } */ }
@Override public void visitNewArrayFilled(NewArrayFilled instruction) { int dest = instruction.destination; int result = reuseOrCreateDef(); int[] sizes = new int[instruction.sizes.length]; for(int i = 0; i < instruction.sizes.length; i++) { sizes[i] = symbolTable.getConstant(instruction.sizes[i]); } emitInstruction(insts.NewInstruction(getCurrentInstructionIndex(), result, instruction.newSiteRef, sizes)); setLocal(dest, result); /* * we need to emit these instructions somehow, but for now this clobbers the emitInstruction mechanism * for (int i = 0; i < instruction.args.length; i++) { int value = workingState.getLocal(instruction.args[i]); int index = symbolTable.getConstant(i); int arrayRef = result; TypeReference t = instruction.myType; emitInstruction(insts.ArrayStoreInstruction(getCurrentInstructionIndex(), arrayRef, index, value, t)); } */ }
val2 = symbolTable.getConstant(((Literal.IntLiteral)lit).value); else if (lit instanceof Literal.LongLiteral) val2 = symbolTable.getConstant(((Literal.LongLiteral)lit).value); else if (lit instanceof Literal.DoubleLiteral) val2 = symbolTable.getConstant(((Literal.DoubleLiteral)lit).value); else val2 = symbolTable.getConstant(((Literal.FloatLiteral)lit).value);
val2 = symbolTable.getConstant(((Literal.IntLiteral)lit).value); else if (lit instanceof Literal.LongLiteral) val2 = symbolTable.getConstant(((Literal.LongLiteral)lit).value); else if (lit instanceof Literal.DoubleLiteral) val2 = symbolTable.getConstant(((Literal.DoubleLiteral)lit).value); else val2 = symbolTable.getConstant(((Literal.FloatLiteral)lit).value);
} else if (l.isIntType(type)) { Integer value = (Integer) instruction.getValue(); symbol = symbolTable.getConstant(value.intValue()); } else if (l.isLongType(type)) { Long value = (Long) instruction.getValue(); symbol = symbolTable.getConstant(value.longValue()); } else if (l.isFloatType(type)) { Float value = (Float) instruction.getValue(); symbol = symbolTable.getConstant(value.floatValue()); } else if (l.isDoubleType(type)) { Double value = (Double) instruction.getValue(); symbol = symbolTable.getConstant(value.doubleValue()); } else if (l.isStringType(type)) { String value = (String) instruction.getValue(); symbol = symbolTable.getConstant(value); } else if (l.isMetadataType(type)) { Object rval = l.getMetadataToken(instruction.getValue());
} else if (l.isIntType(type)) { Integer value = (Integer) instruction.getValue(); symbol = symbolTable.getConstant(value.intValue()); } else if (l.isLongType(type)) { Long value = (Long) instruction.getValue(); symbol = symbolTable.getConstant(value.longValue()); } else if (l.isFloatType(type)) { Float value = (Float) instruction.getValue(); symbol = symbolTable.getConstant(value.floatValue()); } else if (l.isDoubleType(type)) { Double value = (Double) instruction.getValue(); symbol = symbolTable.getConstant(value.doubleValue()); } else if (l.isStringType(type)) { String value = (String) instruction.getValue(); symbol = symbolTable.getConstant(value); } else if (l.isMetadataType(type)) { Object rval = l.getMetadataToken(instruction.getValue());
/** * @see com.ibm.wala.shrikeBT.IInstruction.Visitor#visitConditionalBranch(IConditionalBranchInstruction) */ @Override public void visitBranch(Branch instruction) { if(instruction instanceof Branch.BinaryBranch) { Branch.BinaryBranch bbranch = (Branch.BinaryBranch)instruction; int val2 = workingState.getLocal(bbranch.oper2); int val1 = workingState.getLocal(bbranch.oper1); // int val2 = workingState.pop(); // int val1 = workingState.pop(); TypeReference t = TypeReference.Int; emitInstruction(insts.ConditionalBranchInstruction(getCurrentInstructionIndex(), instruction.getOperator(), t, val1, val2, -1)); } else if(instruction instanceof Branch.UnaryBranch) { Branch.UnaryBranch ubranch = (Branch.UnaryBranch)instruction; int val2 = symbolTable.getConstant(0); int val1 = workingState.getLocal(ubranch.oper1); TypeReference t = TypeReference.Int; emitInstruction(insts.ConditionalBranchInstruction(getCurrentInstructionIndex(), instruction.getOperator(), t, val1, val2, -1)); } else { throw new IllegalArgumentException("instruction is of an unknown subtype of Branch"); } }
/** * @see com.ibm.wala.shrikeBT.IInstruction.Visitor#visitConditionalBranch(IConditionalBranchInstruction) */ @Override public void visitBranch(Branch instruction) { if(instruction instanceof Branch.BinaryBranch) { Branch.BinaryBranch bbranch = (Branch.BinaryBranch)instruction; int val2 = workingState.getLocal(bbranch.oper2); int val1 = workingState.getLocal(bbranch.oper1); // int val2 = workingState.pop(); // int val1 = workingState.pop(); TypeReference t = TypeReference.Int; emitInstruction(insts.ConditionalBranchInstruction(getCurrentInstructionIndex(), instruction.getOperator(), t, val1, val2, -1)); } else if(instruction instanceof Branch.UnaryBranch) { Branch.UnaryBranch ubranch = (Branch.UnaryBranch)instruction; int val2 = symbolTable.getConstant(0); int val1 = workingState.getLocal(ubranch.oper1); TypeReference t = TypeReference.Int; emitInstruction(insts.ConditionalBranchInstruction(getCurrentInstructionIndex(), instruction.getOperator(), t, val1, val2, -1)); } else { throw new IllegalArgumentException("instruction is of an unknown subtype of Branch"); } }
@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); } }