Package org.allspice.structured.expr

Examples of org.allspice.structured.expr.ConstExpr


        }
        else {
          o = null ;
        }
        if (o != null) {
          final FieldStub fldDef = new FieldStub(fld.getName(),myStub,fldstub,isStatic,isFinal,new ConstExpr(o,null));
          stub = stub.addField(fldDef) ;
          continue ;
        }
      }
      stub = stub.addField(new FieldStub(fld.getName(),myStub,fldstub,isStatic,isFinal,null));
View Full Code Here


    TryFinally obj = makeObject(TryFinally.class,new TryCatchStatement(
        new FIFO<Statement>(new ThrowStatement(ARG0,null)),
        new FIFO<CatchBlock>(new CatchBlock(
            new VarDecl("java.lang.Exception","ex"),
            new FIFO<Statement>(
                new ReturnStatement(new ConstExpr(Integer.valueOf(1),null),null)
            )
            )),
        new FIFO<Statement>(),null)) ;

    assertEquals(obj.meth(new Exception()),1) ;
View Full Code Here

  }
  public void test1() throws Exception {
    DoWhileTest obj = makeObject(DoWhileTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int","i"),new VarDecl("int","total")),
        new FIFO<Statement>(
            new ExprStatement(new SetValueExpr(I,new ConstExpr(Integer.valueOf(0),null),null),null),
            new ExprStatement(new SetValueExpr(TOTAL,new ConstExpr(Integer.valueOf(0),null),null),null),
            new DoWhileStatement(
                new LTExpr(I,ARG0,null),
                new FIFO<Statement>(
                  new ExprStatement(new AddInPlaceExpr(I,new ConstExpr(Integer.valueOf(1),null),null),null),
                  new ExprStatement(new AddInPlaceExpr(TOTAL,new ConstExpr(Integer.valueOf(2),null),null),null)
                ),
                null),
            new ReturnStatement(TOTAL,null)
      ),null)) ;
    assertEquals(obj.meth(5),10) ;
View Full Code Here

    if (inc != null) {
      whilebody = whilebody.insert(new ExprStatement(inc,inc.getPositionRange())) ;
    }
    Expr test ;
    if (term == null) {
      test = new ConstExpr(Boolean.TRUE,range) ;
    }
    else {
        test = term ;
    }
    Statement whileState = new WhileStatement(test,whilebody,range) ;
View Full Code Here

  public static interface MethTest {
    public int meth() ;
  }
  public void test0() throws Exception {
    MethTest obj = makeObject(MethTest.class,new TryCatchStatement(
            new FIFO<Statement>(new ReturnStatement(new ConstExpr(Integer.valueOf(0),null),null)),
            new FIFO<CatchBlock>(),
            new FIFO<Statement>(new ExprStatement(new ConstExpr(Integer.valueOf(5),null),null)),
            null
          ),
          new ReturnStatement(new ConstExpr(Integer.valueOf(-1),null),null)) ;
    assertEquals(obj.meth(),0) ;
  }
View Full Code Here

  }
  public void test1() throws Exception {
    MethTest obj = makeObject(MethTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int","x")),
        new FIFO<Statement>(new TryCatchStatement(
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new ConstExpr(Integer.valueOf(7),null),null),null)),
            new FIFO<CatchBlock>(),
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new PlusExpr(X,new ConstExpr(Integer.valueOf(1),null),null),null),null)),
            null
          ),
        new ReturnStatement(X,null)),
        null)) ;
    assertEquals(obj.meth(),8) ;
View Full Code Here

  public void test2() throws Exception {
    MethTest obj = makeObject(MethTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int","x")),
        new FIFO<Statement>(
          new TryCatchStatement(
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new ConstExpr(Integer.valueOf(7),null),null),null),new ReturnStatement(X,null)),
            new FIFO<CatchBlock>(),
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new PlusExpr(X,new ConstExpr(Integer.valueOf(1),null),null),null),null)),
            null
          ),
          new ReturnStatement(new ConstExpr(Integer.valueOf(-1),null),null)),
          null)) ;
    assertEquals(obj.meth(),7) ;
  }
View Full Code Here

  public static interface SimpleArrayTest {
    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

      Collection<Expr> arrinit = t.arr ;
      if (!vtype.isArray()) {
        throw new InvalidInitializer() ;
      }
      TypeName baseType = vtype.getArrayBase() ;
      createNewArray(context,Arrays.asList(new ConstExpr(Integer.valueOf(arrinit.size()),null)),vtype,l) ;
      int i = 0 ;
      for(Expr arrval: arrinit) {
        l.add(new Dup(TypeCode.VOID,TypeCode.getType(vtype))) ;
        l.add(new Const(Integer.valueOf(i))) ;
        context.compile(baseType, arrval, l) ;
View Full Code Here

    public int meth(boolean arg0) ;
  }
  public void test1() throws Exception {
    IfTest obj = makeObject(IfTest.class,new IfThenElseStatement(
        ARG0,
        new FIFO<Statement>(new ReturnStatement(new ConstExpr(Integer.valueOf(3),null),null)),
        new FIFO<Statement>(new ReturnStatement(new ConstExpr(Integer.valueOf(2),null),null)),
        null)) ;
    assertEquals(obj.meth(true),3) ;
    assertEquals(obj.meth(false),2) ;
  }
View Full Code Here

TOP

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

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.