Package org.allspice.structured.expr

Examples of org.allspice.structured.expr.VarExpr


    public int[] meth(int arg0) ;
  }
  public void test1() throws Exception {
    SimpleArrayTest obj = makeObject(SimpleArrayTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int[]","i",new ArrayOfExpr(null,new FIFO<Expr>(ARG0)),false)),
        new FIFO<Statement>(new ReturnStatement(new VarExpr("i",null),null)),
        null
      )) ;
    assertTrue(Arrays.equals(obj.meth(5),new int[]{5})) ;
    assertTrue(Arrays.equals(obj.meth(0),new int[]{0})) ;
  }
View Full Code Here


  }
  public static Expr makeFCall(PositionRange range,Expr factor,ImmutableCollection<Expr> elist_opt) {
      final Expr v ;
    if (factor instanceof VarExpr) {
      VarExpr ve = (VarExpr)factor ;
      if (ve.var.equals("this")) {
        v = new FieldVarExpr(ve,"<init>",range) ;
      }
      else if (ve.var.equals("super")) {
        v = new FieldVarExpr(ve,"<init>",range) ;
View Full Code Here

  private static void modifyConstructor(EvaluationContext context,
      final ArrayList<Statement> body) throws CompilerException {
    boolean foundInit = firstIsSuperInit(body);
    if (!foundInit) {
      body.add(0,new ExprStatement(new CallExpr(new FieldVarExpr(new VarExpr("super",null),"<init>",null),new FIFO<Expr>(),null),null)) ;
    }
    StubResolver resolver = context.classDef ;
    int pos = 1 ;
    ClassStub stub = resolver.getStub() ;
    for(FieldStub def: stub.fields.values()) {
      if (!def.isStatic) {
        if (def.initializer != null) {
          SetValueExpr se = new SetValueExpr(new FieldVarExpr(new VarExpr("this",null),def.nm,null),def.initializer,null) ;
          body.add(pos++,new ExprStatement(se,null)) ;
        }
      }
    }
  }
View Full Code Here

            if (fvar.name.equals("<init>")) {
              return true ;
            }
          }
          else if (ve instanceof VarExpr) {
            VarExpr fvar = (VarExpr)ve ;
            if (fvar.var.equals("<init>")) {
              return true ;
            }
          }
        }
View Full Code Here

    boolean issuper = false ;
    if (fld instanceof FieldVarExpr) {
      final FieldVarExpr fve = (FieldVarExpr)fld;
      type = getClassReference(context, fve.object) ;
      if (fve.object instanceof VarExpr) {
        VarExpr ve = (VarExpr)fve.object ;
        issuper = ve.var.equals("super") ;
      }
      name = fve.name ;
    }
    else if (fld instanceof VarExpr){
      final VarExpr ve = (VarExpr)fld;
      type = context.classDef ;
      name = ve.var ;
    }
    else {
      throw new OnlyIdenfitierReferenceAllowed() ;
View Full Code Here

    public int meth() ;
  }
  public void test1() throws Exception {
    SimpleArrayTest obj = makeObject(SimpleArrayTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int","i",new ConstExpr(Integer.valueOf(5),null))),
        new FIFO<Statement>(new ReturnStatement(new VarExpr("i",null),null)),
        null
      )) ;
    assertEquals(obj.meth(),5) ;
  }
View Full Code Here

                  new ConstExpr(Integer.valueOf(5),null),
                  new ConstExpr(Integer.valueOf(7),null)
                  )))
              ),
            false)),
        new FIFO<Statement>(new ReturnStatement(new VarExpr("i",null),null)),
        null
      )) ;
    final int[][] meth = obj.meth();
    assertTrue(Arrays.deepEquals(meth,new int[][]{{6,9},{5,7}})) ;
  }
View Full Code Here

TOP

Related Classes of org.allspice.structured.expr.VarExpr

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.