Package org.allspice.structured.statement

Examples of org.allspice.structured.statement.DeclareStatement


public class TestDeclareSimpleArray extends MyTestCase {
  public static interface SimpleArrayTest {
    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})) ;
View Full Code Here


  private static final VarExpr I = new VarExpr("i",null);
  public static interface DoWhileTest {
    public int meth(int arg0) ;
  }
  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(
View Full Code Here

        return new FIFO<Statement>(
          new ExprStatement(e,e.getPositionRange()),
          whileState) ;
    }
    ImmutableCollection<VarDecl> vardecls = ((DeclarationForInit)init).vardecls ;
    return new FIFO<Statement>(new DeclareStatement(
      vardecls,
      new FIFO<Statement>(whileState),
      range)) ;

  }
View Full Code Here

          ),
          new ReturnStatement(new ConstExpr(Integer.valueOf(-1),null),null)) ;
    assertEquals(obj.meth(),0) ;
  }
  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)),
View Full Code Here

        new ReturnStatement(X,null)),
        null)) ;
    assertEquals(obj.meth(),8) ;
  }
  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>(),
View Full Code Here

public class TestDeclareSimple extends MyTestCase {
  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

public class TestDeclareComplexArray extends MyTestCase {
  public static interface ComplexArrayTest {
    public int[][] meth() ;
  }
  public void test1() throws Exception {
    ComplexArrayTest obj = makeObject(ComplexArrayTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int[][]","i",new ArrayOfExpr(null,
            new FIFO<Expr>(
              new ArrayOfExpr(null,new FIFO<Expr>(
                  new ConstExpr(Integer.valueOf(6),null),
                  new ConstExpr(Integer.valueOf(9),null)
View Full Code Here

  private static final VarExpr I = new VarExpr("i",null);
  public static interface WhileTest {
    public int meth(int arg0) ;
  }
  public void test1() throws Exception {
    WhileTest obj = makeObject(WhileTest.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 WhileStatement(
View Full Code Here

**/
private static final ImmutableCollection<Statement> reduce120(PositionRange range,Parser parser,ParserState state) {
      ImmutableCollection<VarDecl> typedlist = (ImmutableCollection<VarDecl>)state.reductions.tail.tail.head.o ;
      ImmutableCollection<Statement> statement_list = (ImmutableCollection<Statement>)state.reductions.head.o ;
{
  DeclareStatement decl = new DeclareStatement(typedlist,statement_list,range) ;
  return new FIFO<Statement>(decl) ;
}
}
View Full Code Here

TOP

Related Classes of org.allspice.structured.statement.DeclareStatement

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.