예제 #1
0
  /* (non-Javadoc)
   * @see gov.nasa.jpf.vm.IStackHandler#pushLongLocal(de.fosd.typechef.featureexpr.FeatureExpr, int)
   */
  @Override
  public void pushLongLocal(FeatureExpr ctx, int index) {
    Conditional<Entry> value = locals[index];
    if (value == null) {
      value = new One<>(new Entry(0, false));
    }
    stack.pushEntry(ctx, value);

    value = locals[index + 1];
    if (value == null) {
      value = new One<>(new Entry(0, false));
    }
    stack.pushEntry(ctx, value);
  }
예제 #2
0
  /* (non-Javadoc)
   * @see gov.nasa.jpf.vm.IStackHandler#getSlots(de.fosd.typechef.featureexpr.FeatureExpr)
   */
  @Override
  public int[] getSlots(FeatureExpr ctx) {
    int[] slots = new int[length];
    int i = 0;
    for (Conditional<Entry> l : locals) {
      if (l == null) {
        slots[i++] = MJIEnv.NULL;
        continue;
      }
      slots[i++] = l.simplify(ctx).getValue(true).value;
    }
    int[] stackSlots;
    stackSlots = stack.getSlots(ctx);
    if (stackSlots.length == 0) return slots;
    int j = 0;
    while (i < length && j < stackSlots.length) {
      slots[i++] = stackSlots[j++];
    }

    while (i < length) {
      slots[i++] = MJIEnv.NULL;
    }

    return slots;
  }
예제 #3
0
 @SuppressWarnings("unchecked")
 public StackHandler(FeatureExpr ctx, Stack st, Entry[] locals) {
   stack = StackFactory.createVStack();
   this.setCtx(ctx);
   stack.init(st);
   this.locals = new Conditional[locals.length];
   for (int i = 0; i < locals.length; i++) {
     this.locals[i] = new One<>(locals[i]);
   }
   length = st.slots.length + locals.length;
 }
예제 #4
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#hasAnyRef(de.fosd.typechef.featureexpr.FeatureExpr)
  */
 @Override
 public boolean hasAnyRef(FeatureExpr ctx) {
   for (Conditional<Entry> local : locals) {
     if (local == null) {
       continue;
     }
     for (Entry entry : local.simplify(ctx).toList()) {
       if (entry.isRef) {
         return true;
       }
     }
   }
   return false || stack.hasAnyRef(ctx);
 }
예제 #5
0
  @Override
  public Set<Integer> getAllReferences() {
    Set<Integer> references = new HashSet<>();
    for (Conditional<Entry> cl : locals) {
      for (Entry l : cl.toList()) {
        if (l.isRef) {
          references.add(l.value);
        }
      }
    }
    references.addAll(stack.getAllReferences());

    return references;
  }
예제 #6
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#getLocal(de.fosd.typechef.featureexpr.FeatureExpr, int)
  */
 @Override
 public Conditional<Integer> getLocal(FeatureExpr ctx, final int index) {
   if (index < 0) {
     return new One<>(-1);
   }
   if (index < locals.length) {
     if (locals[index] == null) {
       return One.MJIEnvNULL;
     }
     return locals[index].simplify(ctx).map(GetLocal).simplifyValues();
   } else {
     final int i = index - locals.length;
     return stack.getInteger(ctx, i);
   }
 }
예제 #7
0
  @SuppressWarnings("unchecked")
  public StackHandler(FeatureExpr ctx, int nLocals, int nOperands) {
    if (ctx == null) {
      // if loading class inside jetty, the ctx is null
      System.err.println("CAUTIOUS! CTX == NULL, creating True");
      ctx = FeatureExprFactory.True();
      //      throw new RuntimeException("CTX == NULL");
    }
    length = nLocals + nOperands;
    locals = new Conditional[nLocals];
    Arrays.fill(locals, nullValue);

    // stack = new One<>(new Stack(nOperands));
    stack = StackFactory.createVStack(nOperands);
    stack.setCtx(ctx);
  }
예제 #8
0
  /* (non-Javadoc)
   * @see gov.nasa.jpf.vm.IStackHandler#isRefLocal(de.fosd.typechef.featureexpr.FeatureExpr, int)
   */
  @Override
  public boolean isRefLocal(FeatureExpr ctx, final int index) {
    if (index < 0) {
      return false;
    }

    if (index < locals.length) {
      if (locals[index] == null) {
        return false;
      }
      // TODO check calls of isRefLocal
      for (boolean b : locals[index].simplify(ctx).map(IsRefLocal).toList()) {
        if (b) {
          return true;
        }
      }
      return false;
      //      return locals[index].simplify(ctx).map(new IsRefLocal()).simplifyValues().getValue();
    } else {
      final int i = index - locals.length;
      return stack.isRefLocal(ctx, i);
    }
  }
예제 #9
0
 @Override
 public Conditional<Stack> getStack() {
   return stack.getStack();
 }
예제 #10
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#swap(de.fosd.typechef.featureexpr.FeatureExpr)
  */
 @Override
 public void swap(final FeatureExpr ctx) {
   stack.swap(ctx);
 }
예제 #11
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#dup_x2(de.fosd.typechef.featureexpr.FeatureExpr)
  */
 @Override
 public void dup_x2(final FeatureExpr ctx) {
   stack.dup_x2(ctx);
 }
예제 #12
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#dup2_x1(de.fosd.typechef.featureexpr.FeatureExpr)
  */
 @Override
 public void dup2_x1(final FeatureExpr ctx) {
   stack.dup2_x1(ctx);
 }
예제 #13
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#push(de.fosd.typechef.featureexpr.FeatureExpr, java.lang.Object, boolean)
  */
 @Override
 @SuppressWarnings("unchecked")
 public void push(final FeatureExpr ctx, final Object value, final boolean isRef) {
   stack.push(ctx, value, isRef);
 }
예제 #14
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#setTop(de.fosd.typechef.featureexpr.FeatureExpr, int)
  */
 @Override
 public void setTop(final FeatureExpr ctx, final int i) {
   stack.setTop(ctx, i);
 }
예제 #15
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#getStackWidth()
  */
 @Override
 public int getStackWidth() {
   return stack.getStackWidth();
 }
예제 #16
0
 @SuppressWarnings("unchecked")
 public StackHandler() {
   locals = new Conditional[0];
   stack = StackFactory.createVStack();
   stack.setCtx(FeatureExprFactory.True());
 }
예제 #17
0
 @Override
 public void setCtx(FeatureExpr ctx) {
   stack.setCtx(ctx);
 }
예제 #18
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#isRef(de.fosd.typechef.featureexpr.FeatureExpr, int)
  */
 @Override
 public boolean isRef(final FeatureExpr ctx, final int offset) { // change to Conditional<Boolean>
   return stack.isRef(ctx, offset);
 }
예제 #19
0
 protected <T> Conditional<T> peek(FeatureExpr ctx, final int offset, final Type t) {
   return stack.peek(ctx, offset, t);
 }
예제 #20
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#pop(de.fosd.typechef.featureexpr.FeatureExpr, int)
  */
 @Override
 public void pop(FeatureExpr ctx, final int n) {
   stack.pop(ctx, n);
 }
예제 #21
0
 private Conditional<Entry> popEntry(FeatureExpr ctx, final boolean copyRef) {
   return stack.popEntry(ctx, copyRef);
 }
예제 #22
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#clear(de.fosd.typechef.featureexpr.FeatureExpr)
  */
 @Override
 public void clear(final FeatureExpr ctx) {
   stack.clear(ctx);
 }
예제 #23
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#set(de.fosd.typechef.featureexpr.FeatureExpr, int, int, boolean)
  */
 @Override
 public void set(final FeatureExpr ctx, final int offset, final int value, final boolean isRef) {
   stack.set(ctx, offset, value, isRef);
 }
예제 #24
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#pop(de.fosd.typechef.featureexpr.FeatureExpr, gov.nasa.jpf.vm.StackHandler.Type)
  */
 @Override
 public <T> Conditional<T> pop(final FeatureExpr ctx, final Type t) {
   return stack.pop(ctx, t);
 }
예제 #25
0
 /* (non-Javadoc)
  * @see gov.nasa.jpf.vm.IStackHandler#getTop()
  */
 @Override
 public Conditional<Integer> getTop() {
   return stack.getTop();
 }
예제 #26
0
 @Override
 public FeatureExpr getCtx() {
   return stack.getCtx();
 }