Package com.google.test.metric

Examples of com.google.test.metric.FieldInfo


      if (leftVar != null && rightVar != null) {
        Node leftParent = leftDeclaration.getParent();
        if (leftParent instanceof ClassDeclaration) {
          ClassInfo classInfo = repository.getClass(leftDeclaration.getName());
          Type fieldType = CppType.fromName(leftDeclaration.getType());
          FieldInfo fieldInfo = new FieldInfo(classInfo, leftDeclaration
              .getName(), fieldType, false, false, false);
          operations.add(new FieldAssignment(assignmentExpression
              .getLineNumber(), leftVar, fieldInfo, rightVar));
        } else {
          operations.add(new LocalAssignment(assignmentExpression
View Full Code Here


    Block main = new Block("main");
    Block sub = new Block("sub");

    main.addOp(new Load(0, new Variable("this", JavaType.OBJECT, false, false)));
    main.addOp(new JSR(0, sub));
    main.addOp(new PutField(0, new FieldInfo(null, "a", JavaType.INT, false, false,
        false)));

    sub.addOp(new Load(0, new Constant(1, JavaType.INT)));
    sub.addOp(new Return(0, JavaType.VOID));
View Full Code Here

      String desc, String signature, Object value) {
    boolean isStatic = (access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC;
    boolean isPrivate = JavaVisibility.valueFromJavaBytecode(access) == Visibility.PRIVATE;
    boolean isFinal = (access & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL;
    Type type = JavaType.fromDesc(desc);
    classInfo.addField(new FieldInfo(classInfo, name, type, isFinal,
        isStatic, isPrivate));
  }
View Full Code Here

  }

  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

  }

  public void addField(String name, Type type, Visibility visibility,
      boolean isGlobal, boolean isFinal) {
    boolean isPrivate = Visibility.PRIVATE == visibility;
    FieldInfo fieldInfo = new FieldInfo(info, name, type, isFinal, isGlobal,
        isPrivate);
    info.addField(fieldInfo);
  }
View Full Code Here

  }

  public void testVariableStaticAssignment() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var(1)));
    block.addOp(new PutField(-1, new FieldInfo(null, "abc", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }
View Full Code Here

  public void testVariableAssignment() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var("this"))); // this
    block.addOp(new Load(-1, var(1)));
    block.addOp(new PutField(-1, new FieldInfo(null, "abc", OBJECT,
        false, false, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }
View Full Code Here

    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }

  public void testGetField() throws Exception {
    Block block = new Block("1");
    block.addOp(new GetField(-1, new FieldInfo(null, "src", OBJECT,
        false, true, false)));
    block.addOp(new PutField(-1, new FieldInfo(null, "dst", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.dst{java.lang.Object} <- null.src{java.lang.Object}]", operations
        .toString());
View Full Code Here

  }

  public void testMethodInvocation() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var("methodThis"))); // this
    block.addOp(new GetField(-1, new FieldInfo(null, "p1", OBJECT,
        false, true, false)));
    block.addOp(new GetField(-1, new FieldInfo(null, "p2", OBJECT,
        false, true, false)));
    block.addOp(new Invoke(-1, null, "int methodA(int, int)", asList(JavaType.INT,
        JavaType.INT), false, OBJECT));
    block.addOp(new PutField(-1, new FieldInfo(null, "dst", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null:int methodA(int, int), null.dst{java.lang.Object} <- ?{java.lang.Object}]",
        operations.toString());
View Full Code Here

      this.fieldDesc = desc;
      this.isStatic = isStatic;
    }

    public void run() {
      FieldInfo field = null;
      ClassInfo ownerClass = repository.getClass(fieldOwner);
      try {
        field = ownerClass.getField(fieldName);
      } catch (FieldNotFoundException e) {
        field =
            new FieldInfo(ownerClass, "FAKE:" + fieldName, JavaType
                .fromDesc(fieldDesc), false, isStatic, false);
      }
      block.addOp(new com.google.test.metric.method.op.stack.PutField(
          lineNumber, field));
    }
View Full Code Here

TOP

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

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.