Examples of DeclareStatement


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

Examples of org.allspice.structured.statement.DeclareStatement

  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

Examples of org.allspice.structured.statement.DeclareStatement

        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

Examples of org.allspice.structured.statement.DeclareStatement

          ),
          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

Examples of org.allspice.structured.statement.DeclareStatement

        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

Examples of org.allspice.structured.statement.DeclareStatement

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

Examples of org.allspice.structured.statement.DeclareStatement

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

Examples of org.allspice.structured.statement.DeclareStatement

  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

Examples of org.allspice.structured.statement.DeclareStatement

**/
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

Examples of org.teiid.query.sql.proc.DeclareStatement

   
    @Test public void testOptionalFromClause10(){
        //declare var1
        ElementSymbol var1 = new ElementSymbol("var1"); //$NON-NLS-1$
        String shortType = new String("short"); //$NON-NLS-1$
        Statement declStmt = new DeclareStatement(var1, shortType);
       
        //ifblock
        List symbols = new ArrayList();
        symbols.add(new ElementSymbol("a1"))//$NON-NLS-1$
        Select select = new Select(symbols);      
       
        From from = new From();
        from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
       
        Criteria criteria = new CompareCriteria(new ElementSymbol("a2"), CompareCriteria.EQ,  //$NON-NLS-1$
            new Constant(new Integer(5)));
       
        Query query = new Query();
        query.setSelect(select);
        query.setFrom(from);
        query.setCriteria(criteria);
       
        AssignmentStatement queryStmt = new AssignmentStatement(var1, query);
             
        Block ifBlock = new Block();     
        ifBlock.addStatement(queryStmt);
       
        //else block
        ElementSymbol var2 = new ElementSymbol("var2"); //$NON-NLS-1$
        Statement elseDeclStmt = new DeclareStatement(var2, shortType);    
       
        List elseSymbols = new ArrayList();
        elseSymbols.add(new ElementSymbol("b1"))//$NON-NLS-1$
        Select elseSelect = new Select(elseSymbols);
   
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.