Examples of FieldAccess


Examples of com.dragome.compiler.ast.FieldAccess

        Expression rhs= stack.pop();

        int index= bytes.readUnsignedShort();
        ConstantFieldref fieldRef= (ConstantFieldref) constantPool.getConstant(index, Constants.CONSTANT_Fieldref);

        FieldAccess fa= new FieldWrite();
        fa.setName(getFieldName(fieldRef));
        fa.setType(new ObjectType(fieldRef.getClass(constantPool)));
        fa.initialize(methodDecl);

        if (opcode == Const.PUTFIELD)
        {
          fa.setExpression(stack.pop());
        }

        a.setLeftHandSide(fa);
        a.setRightHandSide(rhs);

        instruction= a;
        break;
      }

      case Const.GETFIELD:
      {

        int index= bytes.readUnsignedShort();
        ConstantFieldref fieldRef= (ConstantFieldref) constantPool.getConstant(index, Constants.CONSTANT_Fieldref);

        Expression ex= stack.pop();
        FieldAccess fa= new FieldRead();
        fa.setType(new ObjectType(fieldRef.getClass(constantPool)));
        fa.setName(getFieldName(fieldRef));
        fa.setExpression(ex);
        fa.initialize(methodDecl);
        instruction= fa;
        break;
      }

      case Const.GETSTATIC:
      {

        int index= bytes.readUnsignedShort();
        ConstantFieldref fieldRef= (ConstantFieldref) constantPool.getConstant(index, Constants.CONSTANT_Fieldref);

        FieldAccess fa= new FieldRead();
        fa.setType(new ObjectType(fieldRef.getClass(constantPool)));
        fa.setName(getFieldName(fieldRef));
        fa.initialize(methodDecl);

        instruction= fa;
        break;
      }

      case Const.DUP:
      {

        dup1();
        instruction= stack.pop();
        break;
      }

      case Const.DUP2:

        if (form.getIndex() == 0)
        {
          dup2();
          instruction= stack.pop();
        }
        else
        {
          dup1();
          instruction= stack.pop();
        }
        break;

      case Const.DUP_X1:
      {

        dup1();
        stack.rotate(2);
        instruction= stack.pop();
        break;
      }

      case Const.DUP_X2:
      {

        if (form.getIndex() == 0)
        {
          dup1();
          stack.rotate(3);
        }
        else
        {
          dup1();
          stack.rotate(2);
        }
        instruction= stack.pop();
        break;
      }

      case Const.DUP2_X1:

        if (form.getIndex() == 0)
        {
          dup2();
          stack.rotate(4);
          stack.rotate(4);
        }
        else
        {
          dup1();
          stack.rotate(2);
        }
        instruction= stack.pop();
        break;

      case Const.DUP2_X2:

        if (form.getIndex() == 0)
        {
          dup2();
          stack.rotate(5);
          stack.rotate(5);
        }
        else if (form.getIndex() == 1)
        {
          dup1();
          stack.rotate(3);
        }
        else if (form.getIndex() == 2)
        {
          dup2();
          stack.rotate(4);
          stack.rotate(4);
        }
        else
        {
          dup1();
          stack.rotate(2);
        }

        instruction= stack.pop();
        break;

      case Const.SWAP:
      {

        stack.rotate(1);
        instruction= new NoOperation();
        break;
      }

      case Const.I2S:

      case Const.I2F:

      case Const.L2I:

      case Const.F2I:

      case Const.F2L:

      case Const.L2F:

      case Const.L2D:

      case Const.D2I:

      case Const.D2L:

      case Const.D2F:

      case Const.I2B:

      case Const.I2C:

        instruction= new PrimitiveCast(opcode, stack.pop(), form.getResultType());
        break;

      case Const.I2L:

        stack.peek().setTypeBinding(Type.LONG);
        instruction= new NoOperation();
        break;
      case Const.I2D:

      case Const.F2D:

        stack.peek().setTypeBinding(Type.DOUBLE);
        instruction= new NoOperation();
        break;

      case Const.INEG:

      case Const.LNEG:

      case Const.FNEG:

      case Const.DNEG:

        instruction= createPrefix(PrefixExpression.MINUS, stack.pop(), form.getResultType());
        break;

      case Const.ISHR:

      case Const.LSHR:

        instruction= createInfixRightLeft(InfixExpression.Operator.RIGHT_SHIFT_SIGNED, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.ISHL:

      case Const.LSHL:

        instruction= createInfixRightLeft(InfixExpression.Operator.LEFT_SHIFT, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IUSHR:

      case Const.LUSHR:

        instruction= createInfixRightLeft(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IADD:

      case Const.LADD:

      case Const.FADD:

      case Const.DADD:

        instruction= createInfixRightLeft(InfixExpression.Operator.PLUS, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.ISUB:

      case Const.LSUB:

      case Const.FSUB:

      case Const.DSUB:

        instruction= createInfixRightLeft(InfixExpression.Operator.MINUS, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IMUL:

      case Const.LMUL:

      case Const.FMUL:

      case Const.DMUL:

        instruction= createInfixRightLeft(InfixExpression.Operator.TIMES, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IDIV:

      case Const.LDIV:

      case Const.FDIV:

      case Const.DDIV:

        instruction= createInfixRightLeft(InfixExpression.Operator.DIVIDE, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IREM:

      case Const.LREM:

      case Const.FREM:

      case Const.DREM:

        instruction= createInfixRightLeft(InfixExpression.Operator.REMAINDER, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IXOR:

      case Const.LXOR:

        instruction= createInfixRightLeft(InfixExpression.Operator.XOR, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IAND:

      case Const.LAND:

        instruction= createInfixRightLeft(InfixExpression.Operator.AND, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IOR:

      case Const.LOR:

        instruction= createInfixRightLeft(InfixExpression.Operator.OR, stack.pop(), stack.pop(), form.getResultType());
        break;

      case Const.IINC:
      {

        boolean isWide= wide;
        int index= readUnsigned();

        wide= isWide;
        int constByte= readSigned();

        VariableBinding reference= createVariableBinding(index, Type.INT, true);
        reference.setField(false);

        Assignment assign= new Assignment(Assignment.Operator.PLUS_ASSIGN);
        assign.setLeftHandSide(reference);
        assign.setRightHandSide(NumberLiteral.create(new Integer(constByte)));
        instruction= assign;
        break;
      }

      case Const.ARRAYLENGTH:
      {

        Expression arrayRef= stack.pop();
        FieldAccess access= new FieldRead();
        access.setExpression(arrayRef);
        access.setName("length");

        instruction= access;
        break;
      }
View Full Code Here

Examples of com.esotericsoftware.reflectasm.FieldAccess

  }

  public void copy (Object original, Object copy) {
    try {
      if (accessIndex != -1) {
        FieldAccess access = (FieldAccess)fieldSerializer.access;
        access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex)));
      } else
        setField(copy, kryo.copy(getField(original)));
    } catch (IllegalAccessException ex) {
      throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex);
    } catch (KryoException ex) {
View Full Code Here

Examples of com.esotericsoftware.reflectasm.FieldAccess

public class FieldAccessBenchmark extends Benchmark {
  public FieldAccessBenchmark () throws Exception {
    int count = 1000000;
    Object[] dontCompileMeAway = new Object[count];

    FieldAccess access = FieldAccess.get(SomeClass.class);
    SomeClass someObject = new SomeClass();
    int index = access.getIndex("name");

    Field field = SomeClass.class.getField("name");

    for (int i = 0; i < 100; i++) {
      for (int ii = 0; ii < count; ii++) {
        access.set(someObject, index, "first");
        dontCompileMeAway[ii] = access.get(someObject, index);
      }
      for (int ii = 0; ii < count; ii++) {
        field.set(someObject, "first");
        dontCompileMeAway[ii] = field.get(someObject);
      }
    }
    warmup = false;

    for (int i = 0; i < 100; i++) {
      start();
      for (int ii = 0; ii < count; ii++) {
        access.set(someObject, index, "first");
        dontCompileMeAway[ii] = access.get(someObject, index);
      }
      end("FieldAccess");
    }
    for (int i = 0; i < 100; i++) {
      start();
View Full Code Here

Examples of com.esotericsoftware.reflectasm.FieldAccess

    }

    public void copy (Object original, Object copy) {
      try {
        if (accessIndex != -1) {
          FieldAccess access = (FieldAccess)FieldSerializer.this.access;
          access.set(copy, accessIndex, access.get(original, accessIndex));
        } else
          field.set(copy, field.get(original));
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex);
      } catch (KryoException ex) {
View Full Code Here

Examples of com.esotericsoftware.reflectasm.FieldAccess

public class FieldAccessBenchmark extends Benchmark {
  public FieldAccessBenchmark () throws Exception {
    int count = 1000000;
    Object[] dontCompileMeAway = new Object[count];

    FieldAccess access = FieldAccess.get(SomeClass.class);
    SomeClass someObject = new SomeClass();
    int index = access.getIndex("name");

    Field field = SomeClass.class.getField("name");

    for (int i = 0; i < 100; i++) {
      for (int ii = 0; ii < count; ii++) {
        access.set(someObject, index, "first");
        dontCompileMeAway[ii] = access.get(someObject, index);
      }
      for (int ii = 0; ii < count; ii++) {
        field.set(someObject, "first");
        dontCompileMeAway[ii] = field.get(someObject);
      }
    }
    warmup = false;

    for (int i = 0; i < 100; i++) {
      start();
      for (int ii = 0; ii < count; ii++) {
        access.set(someObject, index, "first");
        dontCompileMeAway[ii] = access.get(someObject, index);
      }
      end("FieldAccess");
    }
    for (int i = 0; i < 100; i++) {
      start();
View Full Code Here

Examples of com.esotericsoftware.reflectasm.FieldAccess

    }

    public void copy (Object original, Object copy) {
      try {
        if (accessIndex != -1) {
          FieldAccess access = (FieldAccess)FieldSerializer.this.access;
          access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex)));
        } else
          field.set(copy, kryo.copy(field.get(original)));
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex);
      } catch (KryoException ex) {
View Full Code Here

Examples of openjava.ptree.FieldAccess

     */
    public static FieldAccess makeFieldAccess(
        int ordinal,
        int field)
    {
        return new FieldAccess(
            new Variable(makeName(ordinal)),
            OJSyntheticClass.makeField(field));
    }
View Full Code Here

Examples of openjava.ptree.FieldAccess

     */
    public static FieldAccess makeFieldAccess(
        Expression expr,
        int field)
    {
        return new FieldAccess(
            expr,
            OJSyntheticClass.makeField(field));
    }
View Full Code Here

Examples of org.apache.bval.util.FieldAccess

                factory.getAnnotationIgnores().setIgnoreAnnotationsOnMember(field);
            }

            // valid
            if (fieldType.getValid() != null) {
                factory.addValid(beanClass, new FieldAccess(field));
            }

            // constraints
            for (ConstraintType constraintType : fieldType.getConstraint()) {
                MetaConstraint<?, ?> constraint =
View Full Code Here

Examples of org.apache.bval.util.FieldAccess

            if (!factoryContext.getFactory().getAnnotationIgnores()
                  .isIgnoreAnnotations(field)) {
                if (metaProperty == null) {
                    metaProperty = addMetaProperty(metabean, field.getName(), field.getType());
                    processAnnotations(metaProperty, beanClass, field,
                          new FieldAccess(field),
                          new AppendValidationToMeta(metaProperty));//) {
                } else {
                    processAnnotations(metaProperty, beanClass, field,
                          new FieldAccess(field),
                          new AppendValidationToMeta(metaProperty));
                }
            }
        }
        final Method[] methods = SecureActions.getDeclaredMethods(beanClass);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.