Package com.google.test.metric

Examples of com.google.test.metric.Variable


  public void testVariableFormatting() throws Exception {
    Type type = JavaType.fromJava("com.google.test.metric.example.MutableGlobalState." +
        "FinalGlobalExample$Gadget");
    FieldInfo field = new FieldInfo(null, "finalInstance", type, false, false, false);
    LocalField localField = new LocalField(new Variable(
        "com.google.test.metric.example.MutableGlobalState.FinalGlobalExample$" +
            "FinalGlobal.finalInstance",
        type, false, false), field);
    assertEquals("FinalGlobalExample$Gadget finalInstance", localField.getDescription());
  }
View Full Code Here


     * }
     */
    Label lTry = new Label();
    Load l1 = load(1);
    Load l2 = load(2);
    Store store = new Store(-1, new Variable("a", JavaType.INT, false, false));
    Return ret = new Return(1, JavaType.INT);
    Label lTryEnd = new Label();
    Label lHandle = new Label();

    BlockDecomposer decomposer = new BlockDecomposer();
View Full Code Here

    Label runtimeHandler = new Label();
    Label catchEnd = new Label();
    Label finallyHandler = new Label();
    Label l20 = new Label();
    Label l22 = new Label();
    Variable b = new LocalVariableInfo("b", JavaType.INT);
    Variable e = new LocalVariableInfo("e", JavaType.OBJECT);
    Variable any = new LocalVariableInfo("any", JavaType.OBJECT);
    decomposer.tryCatchBlock(tryStart, tryEnd, runtimeHandler, "java/lang/RuntimeException");
    decomposer.tryCatchBlock(tryStart, catchEnd, finallyHandler, null);

    /* 0*/ decomposer.addOp(new Load(0, new Constant(1, JavaType.INT)));
    /* 1*/ decomposer.addOp(new Store(1, b));
View Full Code Here

  }

  protected void assertValid(List<Variable> variables) {
    Iterator<Variable> iter = variables.iterator();
    while (iter.hasNext()) {
      final Variable variable = iter.next();
      if (JavaType.isDoubleSlot(variable.getType())) {
        Variable varNext = iter.hasNext() ? iter.next() : null;
        if (variable != varNext) {
          throw new IllegalStateException("Variable list '" + variables
              + "' contanins variable '" + variable
              + "' which is a double but the next "
              + "variable in the list is not a duplicate.");
View Full Code Here

  }

  @Override
  public Operation toOperation(List<Variable> input) {
    if (fieldInfo.isGlobal()) {
      Variable value = input.get(0);
      return new FieldAssignment(lineNumber, null, fieldInfo, value);
    } else {
      Variable instance = input.get(0);
      Variable value = input.get(1);
      return new FieldAssignment(lineNumber, instance, fieldInfo, value);
    }
  }
View Full Code Here

    return fieldInfo.isGlobal() ? 0 : 1;
  }

  @Override
  public List<Variable> apply(List<Variable> input) {
    Variable instance = fieldInfo.isGlobal() ? null : input.get(0);
    return list(new LocalField(instance, fieldInfo));
  }
View Full Code Here

  }

  public void visitLocalVariable(String name, String desc, String signature,
      Label start, Label end, int slotNum) {
    Type type = JavaType.fromDesc(desc);
    Variable variable = slots.get(slotNum);
    if (variable == null) {
      LocalVariableInfo localVar = new LocalVariableInfo(name, type);
      slots.put(slotNum, localVar);
      localVariables.add(localVar);
    } else {
      variable.setName(name);
    }
  }
View Full Code Here

      }
    });
  }

  private Variable variable(int varIndex, Type type) {
    Variable variable = slots.get(varIndex);
    if (variable == null) {
      LocalVariableInfo localVar = new LocalVariableInfo("local_" + varIndex, type);
      slots.put(varIndex, localVar);
      localVariables.add(localVar);
      variable = localVar;
    }
    Type varType = variable.getType();
    if (!varType.equals(type) && (type.isPrimitive() || varType.isPrimitive())) {
      // Apparently the compiler reuses local variables and it is possible
      // that the types change. So if types change we have to drop
      // the variable and try again.
      slots.put(varIndex, null);
View Full Code Here

  }

  public void visitIincInsn(final int var, final int increment) {
    recorder.add(new Runnable() {
      public void run() {
        Variable variable = variable(var, JavaType.INT);
        block.addOp(new Increment(lineNumber, increment, variable));
      }
    });
  }
View Full Code Here

    return JavaType.isDoubleSlot(from) ? 2 : 1;
  }

  @Override
  public List<Variable> apply(List<Variable> input) {
    Variable variable = input.get(0);
    return list(new Constant(variable.getName(), to));
  }
View Full Code Here

TOP

Related Classes of com.google.test.metric.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.