private String buildNewDescriptor(boolean isField, String descriptor) { if (isField) { return FieldDescriptor.parseDescriptor(descriptor).buildNewDescriptor(this); } else { return MethodDescriptor.parseDescriptor(descriptor).buildNewDescriptor(this); } } }
public String buildNewDescriptor(NewClassNameBuilder builder) { if (type.type == CodeConstants.TYPE_OBJECT) { String newClassName = builder.buildNewClassname(type.value); if (newClassName != null) { return new VarType(type.type, type.arrayDim, newClassName).toString(); } } return null; }
private static VarType buildNewType(VarType type, NewClassNameBuilder builder) { if (type.type == CodeConstants.TYPE_OBJECT) { String newClassName = builder.buildNewClassname(type.value); if (newClassName != null) { return new VarType(type.type, type.arrayDim, newClassName); } } return null; }
public static DataPoint getInitialDataPoint(StructMethod mt) { DataPoint point = new DataPoint(); MethodDescriptor md = MethodDescriptor.parseDescriptor(mt.getDescriptor()); int k = 0; if (!mt.hasModifier(CodeConstants.ACC_STATIC)) { point.setVariable(k++, new VarType(CodeConstants.TYPE_OBJECT, 0, null)); } for (int i = 0; i < md.params.length; i++) { VarType var = md.params[i]; point.setVariable(k++, var); if (var.stackSize == 2) { point.setVariable(k++, new VarType(CodeConstants.TYPE_GROUP2EMPTY)); } } return point; }
@Override public VarType getExprType() { VarType exprType = array.getExprType(); if (exprType.equals(VarType.VARTYPE_NULL)) { return hardType.copy(); } else { return exprType.decreaseArrayDim(); } }
private static boolean isNarrowedIntType(VarType type) { return VarType.VARTYPE_INT.isStrictSuperset(type) || type.equals(VarType.VARTYPE_BYTE_OBJ) || type.equals(VarType.VARTYPE_SHORT_OBJ); } }
public VarType(int type, int arrayDim, String value) { this(type, arrayDim, value, getFamily(type, arrayDim), getStackSize(type, arrayDim), false); }
public VarType decreaseArrayDim() { if (arrayDim > 0) { return new VarType(type, arrayDim - 1, value); } else { //throw new RuntimeException("array dimension equals 0!"); FIXME: investigate this case return this; } }
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof FieldDescriptor)) return false; FieldDescriptor fd = (FieldDescriptor)o; return type.equals(fd.type); }
public static FieldDescriptor parseDescriptor(String descriptor) { return new FieldDescriptor(descriptor); }
public VarType(int type, int arrayDim) { this(type, arrayDim, getChar(type)); }
public VarType copy() { return copy(false); }
public FieldExprent(LinkConstant cn, Exprent instance, Set<Integer> bytecodeOffsets) { this(cn.elementname, cn.classname, instance == null, instance, FieldDescriptor.parseDescriptor(cn.descriptor), bytecodeOffsets); }
private String buildNewDescriptor(boolean isField, String descriptor) { String newDescriptor; if (isField) { newDescriptor = FieldDescriptor.parseDescriptor(descriptor).buildNewDescriptor(this); } else { newDescriptor = MethodDescriptor.parseDescriptor(descriptor).buildNewDescriptor(this); } return newDescriptor != null ? newDescriptor : descriptor; }
public boolean isSuperset(VarType val) { return this.equals(val) || this.isStrictSuperset(val); }
private FieldDescriptor(String descriptor) { type = new VarType(descriptor); descriptorString = descriptor; }
public VarType copy(boolean forceFalseBoolean) { return new VarType(type, arrayDim, value, typeFamily, stackSize, falseBoolean || forceFalseBoolean); }
public VarType resizeArrayDim(int newArrayDim) { return new VarType(type, newArrayDim, value, typeFamily, stackSize, falseBoolean); }
public VarType getVariable(int index) { if (index < localVariables.size()) { return localVariables.get(index); } else { return new VarType(CodeConstants.TYPE_NOTINITIALIZED); } }
public void setVariable(int index, VarType value) { if (index >= localVariables.size()) { for (int i = localVariables.size(); i <= index; i++) { localVariables.add(new VarType(CodeConstants.TYPE_NOTINITIALIZED)); } } localVariables.set(index, value); }