Examples of ArrayCreation


Examples of com.bacoder.parser.java.api.ArrayCreation

              getAdapter(ArrayInitializerAdapter.class).adapt(arrayInitializerContext);
        }
      }

      if (arrayDimensions != null) {
        ArrayCreation arrayCreation = createNode(context, ArrayCreation.class);
        arrayCreation.setElementType(instantiableType);
        arrayCreation.setDimensions(arrayDimensions);
        arrayCreation.setInitializer(arrayInitializer);
        return arrayCreation;
      } else {
        ClassInstantiation newInvocation = createNode(context, ClassInstantiation.class);
        newInvocation.setTypeArguments(nonWildcardTypeArguments);
        newInvocation.setType(instantiableType);
View Full Code Here

Examples of com.dragome.compiler.ast.ArrayCreation

        String componentSignature= BasicType.getType(bytes.readByte()).getSignature();

        List<ASTNode> dimensions= new ArrayList<ASTNode>();
        dimensions.add(stack.pop());
        ArrayCreation ac= new ArrayCreation(methodDecl, new ObjectType("[" + componentSignature), dimensions);
        instruction= ac;
        break;
      }

      case Const.ANEWARRAY:
      {

        ConstantClass c= (ConstantClass) constantPool.getConstant(bytes.readUnsignedShort());
        String componentSignature= c.getBytes(constantPool).replace('/', '.');
        Type arrayType;
        if (componentSignature.startsWith("["))
        {
          arrayType= new ObjectType("[" + componentSignature);
        }
        else
        {
          arrayType= new ObjectType("[L" + componentSignature + ";");
        }

        List<ASTNode> dimensions= new ArrayList<ASTNode>();
        dimensions.add(stack.pop());
        ArrayCreation ac= new ArrayCreation(methodDecl, arrayType, dimensions);
        instruction= ac;
        break;
      }

      case Const.MULTIANEWARRAY:
      {

        ConstantClass c= (ConstantClass) constantPool.getConstant(bytes.readUnsignedShort());
        ObjectType arrayType= new ObjectType(c.getBytes(constantPool).replace('/', '.'));

        int dimCount= bytes.readUnsignedByte();
        opStackDelta= 1 - dimCount;
        List<ASTNode> dimensions= new ArrayList<ASTNode>();
        for (int i= 0; i < dimCount; i++)
        {

          dimensions.add(0, stack.pop());
        }
        ArrayCreation ac= new ArrayCreation(methodDecl, arrayType, dimensions);
        instruction= ac;
        break;
      }

      case Const.PUTSTATIC:

      case Const.PUTFIELD:
      {

        Assignment a= new Assignment(Assignment.Operator.ASSIGN);
        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;
      }

      case Const.WIDE:

        wide= true;
        return new NoOperation();

      case Const.ILOAD_0:

      case Const.ILOAD_1:

      case Const.ILOAD_2:

      case Const.ILOAD_3:
      {

        VariableBinding reference= createVariableBinding(opcode - Const.ILOAD_0, Type.INT, false);
        reference.setField(false);
        instruction= reference;
        break;
      }

      case Const.LLOAD_0:

      case Const.LLOAD_1:

      case Const.LLOAD_2:

      case Const.LLOAD_3:
      {

        VariableBinding reference= createVariableBinding(opcode - Const.LLOAD_0, Type.LONG, false);
        reference.setField(false);
        instruction= reference;
        break;
      }

      case Const.FLOAD_0:

      case Const.FLOAD_1:

      case Const.FLOAD_2:

      case Const.FLOAD_3:
      {

        VariableBinding reference= createVariableBinding(opcode - Const.FLOAD_0, Type.FLOAT, false);
        reference.setField(false);
        instruction= reference;
        break;
      }

      case Const.DLOAD_0:

      case Const.DLOAD_1:

      case Const.DLOAD_2:

      case Const.DLOAD_3:
      {

        VariableBinding reference= createVariableBinding(opcode - Const.DLOAD_0, Type.DOUBLE, false);
        reference.setField(false);
        instruction= reference;
        break;
      }

      case Const.ALOAD_0:

      case Const.ALOAD_1:

      case Const.ALOAD_2:

      case Const.ALOAD_3:
      {

        if (opcode == Const.ALOAD_0 && !Modifier.isStatic(methodDecl.getAccess()))
        {
          ThisExpression reference= new ThisExpression();
          instruction= reference;
        }
        else
        {
          VariableBinding reference= createVariableBinding(opcode - Const.ALOAD_0, Type.OBJECT, false);
          reference.setField(true);
          instruction= reference;
        }
        break;
      }

      case Const.ILOAD:

      case Const.LLOAD:

      case Const.FLOAD:

      case Const.DLOAD:
      {

        VariableBinding reference= createVariableBinding(readUnsigned(), form.getResultType(), false);
        reference.setField(false);
        instruction= reference;
        break;
      }

      case Const.ALOAD:
      {

        VariableBinding reference= createVariableBinding(readUnsigned(), Type.OBJECT, false);
        reference.setField(true);
        instruction= reference;
        break;
      }

      case Const.BALOAD:

      case Const.CALOAD:

      case Const.SALOAD:

      case Const.IALOAD:

      case Const.LALOAD:

      case Const.FALOAD:

      case Const.DALOAD:

      case Const.AALOAD:
      {

        Expression index= stack.pop();
        Expression arrayRef= stack.pop();
        ArrayAccess aa;
        aa= new ArrayAccess();
        aa.setTypeBinding(form.getResultType());
        aa.setArray(arrayRef);
        aa.setIndex(index);

        instruction= aa;
        break;
      }

      case Const.BASTORE:

      case Const.CASTORE:

      case Const.SASTORE:

      case Const.IASTORE:

      case Const.LASTORE:

      case Const.FASTORE:

      case Const.DASTORE:

      case Const.AASTORE:
      {

        Expression value= stack.pop();
        Expression index= stack.pop();
        Expression arrayRef= stack.pop();
        if (arrayRef instanceof ArrayCreation)
        {
          ArrayCreation ac= (ArrayCreation) arrayRef;
          if (ac.getInitializer() == null)
          {
            ac.setInitializer(new ArrayInitializer());
          }
          ac.getInitializer().getExpressions().add(value);
          instruction= new NoOperation();
          break;
        }
        Assignment a= new Assignment(Assignment.Operator.ASSIGN);
View Full Code Here

Examples of lombok.ast.ArrayCreation

      if (node.getType() == null) {
        set(node, init == null ? new ArrayInitializer() : init);
        return;
      }
     
      ArrayCreation crea = new ArrayCreation();
      JCTree type = node.getType();
      java.util.List<Position> inits = Lists.newArrayList();
      while (type instanceof JCArrayTypeTree) {
        inits.add(getPosition(type));
        type = ((JCArrayTypeTree) type).getType();
      }
     
      crea.rawComponentTypeReference(toTree(type, FlagKey.TYPE_REFERENCE));
      if (node.getDimensions() != null) for (JCExpression dim : node.getDimensions()) {
        crea.astDimensions().addToEnd(setPos(dim, new ArrayDimension().rawDimension(toTree(dim))));
      }
     
      if (init != null) crea.astDimensions().addToEnd(new ArrayDimension());
     
      // new boolean [][][] {} in javac has one less dimension for some reason.
      for (Position i : inits) {
        ArrayDimension dim = new ArrayDimension();
        dim.setPosition(i);
        crea.astDimensions().addToEnd(dim);
      }
     
      crea.astInitializer(init);
      set(node, crea);
    }
View Full Code Here

Examples of lombok.ast.ArrayCreation

    if (arrayOpen != null) d.setPosition(new Position(arrayOpen.getStartIndex(), currentPos()));
    return d;
  }
 
  public Node createArrayCreationExpression(Node type, List<Node> dimensions, Node initializer) {
    ArrayCreation ac = new ArrayCreation().rawComponentTypeReference(type).rawInitializer(initializer);
    if (dimensions != null) for (Node d : dimensions) {
      if (d != null) ac.rawDimensions().addToEnd(d);
    }
   
    return posify(ac);
  }
View Full Code Here

Examples of org.candle.decompiler.intermediate.expression.ArrayCreation

   */
  public void visitNEWARRAY(NEWARRAY instruction) {
    //first, check to see if the next instruction is a DUP.  If so,
    //this is probably a constant array value.
    Expression count = context.getExpressions().pop();
    ArrayCreation nai = null;
   
    if(context.getCurrentInstruction().getNext().getInstruction() instanceof DUP) {
      nai = new NewConstantArrayInstance(context.getCurrentInstruction(), instruction.getType(), count);
    }
    else {
      nai = new ArrayCreation(context.getCurrentInstruction(), instruction.getType(), count);
    }
   
    context.getExpressions().push(nai)
   
  }
View Full Code Here

Examples of org.candle.decompiler.intermediate.expression.ArrayCreation

   */
  public void visitANEWARRAY(ANEWARRAY instruction) {
    Type type = instruction.getType(context.getMethodGen().getConstantPool());
    Expression count = context.getExpressions().pop();

    ArrayCreation nai = null;
   
    if(context.getCurrentInstruction().getNext().getInstruction() instanceof DUP) {
      nai = new NewConstantArrayInstance(context.getCurrentInstruction(), type, count);
    }
    else {
      nai = new ArrayCreation(context.getCurrentInstruction(), type, count);
    }
   
    context.getExpressions().push(nai);
  }
View Full Code Here

Examples of org.candle.decompiler.intermediate.expression.ArrayCreation

   
    for(int i=0; i<provided; i++) {
      counts.addFirst(context.getExpressions().pop());
    }
   
    ArrayCreation nai = new ArrayCreation(context.getCurrentInstruction(), type, counts);
    context.getExpressions().push(nai);
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ArrayCreation

     *
     * @param type base type name
     * @return array creation
     */
    public NewArrayBuilder newArrayBuilder(String type) {
        ArrayCreation create = getAST().newArrayCreation();
        create.setType(getAST().newArrayType(m_source.createType(type)));
        return new NewArrayBuilder(this, create);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ArrayCreation

        // If there are indices, create an integer array of those indices,
        // and add it as an argument.
        if (indices == 0) {
            recordInvocation.arguments().add(ast.newNullLiteral());
        } else {
            ArrayCreation arrayCreation = ast.newArrayCreation();
            ArrayType arrayType = ast.newArrayType(ast
                    .newPrimitiveType(PrimitiveType.INT));
            ArrayInitializer initializer = ast.newArrayInitializer();

            for (int i = 0; i < indices; i++) {
                initializer.expressions().add(ast.newSimpleName("index" + i));
            }

            arrayCreation.setType(arrayType);
            arrayCreation.setInitializer(initializer);
            recordInvocation.arguments().add(arrayCreation);
        }

        // If there are indices, add them ("index0", "index1", ...) after the
        // field.
View Full Code Here

Examples of org.eclipse.jdt.core.dom.ArrayCreation

        backup.setName(ast.newSimpleName("backup"));

        if (indices == 0) {
            backup.arguments().add(ast.newNullLiteral());
        } else {
            ArrayCreation arrayCreation = ast.newArrayCreation();
            ArrayType arrayType = ast.newArrayType(ast
                    .newPrimitiveType(PrimitiveType.INT));
            ArrayInitializer initializer = ast.newArrayInitializer();

            for (int i = 0; i < indices; i++) {
                initializer.expressions().add(ast.newSimpleName("index" + i));
            }

            arrayCreation.setType(arrayType);
            arrayCreation.setInitializer(initializer);
            backup.arguments().add(arrayCreation);
        }

        //If there are indices, add them ("index0", "index1", ...) after the
        // field.
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.