Ejemplo n.º 1
0
  public static Expression initializeStaticField(
      FieldInfo staticField, ClassInfo ci, ThreadInfo ti, String suffix) {

    Expression sym_v = null;
    String name = "";

    name = staticField.getName();
    String fullName = ci.getName() + "." + name + suffix; // + "_init";
    if (staticField instanceof IntegerFieldInfo || staticField instanceof LongFieldInfo) {
      sym_v = new SymbolicInteger(fullName);
    } else if (staticField instanceof FloatFieldInfo || staticField instanceof DoubleFieldInfo) {
      sym_v = new SymbolicReal(fullName);
    } else if (staticField instanceof ReferenceFieldInfo) {
      if (staticField.getType().equals("java.lang.String")) sym_v = new StringSymbolic(fullName);
      else sym_v = new SymbolicInteger(fullName);
    } else if (staticField instanceof BooleanFieldInfo) {
      //						treat boolean as an integer with range [0,1]
      sym_v = new SymbolicInteger(fullName, 0, 1);
    }
    StaticElementInfo sei = ci.getModifiableStaticElementInfo();
    if (sei == null) {
      ci.registerClass(ti);
      sei = ci.getStaticElementInfo();
    }
    if (sei.getFieldAttr(staticField) == null) {
      sei.setFieldAttr(staticField, sym_v);
    }
    return sym_v;
  }
Ejemplo n.º 2
0
  public static Expression initializeInstanceField(
      FieldInfo field, ElementInfo eiRef, String refChain, String suffix) {
    Expression sym_v = null;
    String name = "";

    name = field.getName();
    String fullName = refChain + "." + name + suffix;
    if (field instanceof IntegerFieldInfo || field instanceof LongFieldInfo) {
      sym_v = new SymbolicInteger(fullName);
    } else if (field instanceof FloatFieldInfo || field instanceof DoubleFieldInfo) {
      sym_v = new SymbolicReal(fullName);
    } else if (field instanceof ReferenceFieldInfo) {
      if (field.getType().equals("java.lang.String")) sym_v = new StringSymbolic(fullName);
      else sym_v = new SymbolicInteger(fullName);
    } else if (field instanceof BooleanFieldInfo) {
      //	treat boolean as an integer with range [0,1]
      sym_v = new SymbolicInteger(fullName, 0, 1);
    }
    eiRef.setFieldAttr(field, sym_v);
    return sym_v;
  }