Package org.allspice.structured

Examples of org.allspice.structured.VarDecl


  }
  public void test1() throws Exception {
    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)) ;
View Full Code Here


  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})) ;
    assertTrue(Arrays.equals(obj.meth(0),new int[]{0})) ;
View Full Code Here

  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(
                new LTExpr(I,ARG0,null),
View Full Code Here

public class JavaGrammarUtils {
  public static ImmutableCollection<VarDecl> makeVarDecls(boolean isFinal,String type,ImmutableCollection<VarRec> declarationlist) {
    ImmutableCollection<VarDecl> vardecls = new FIFO<VarDecl>() ;
    for(VarRec vrec: declarationlist) {
      vardecls = vardecls.insert(new VarDecl(type+vrec.arraydims,vrec.id,vrec.init_opt,isFinal)) ;
    }
    return vardecls ;

  }
View Full Code Here

  public static void createFinally(EvaluationContext context,
      Collection<Statement> statements, Collection<CatchBlock> catchBlocks, Collection<Statement> finallyStatements,InstList l) throws CompilerException {
    Mark finallyMark = new Mark() ;
    final VarStack vars = context.decls.addLocalVar(context.getFileUnitInfo(),
        new FIFO<VarDecl>(
        new VarDecl("java.lang.Throwable","$$ex$$"),
        new VarDecl("returnAddress","$$ra$$")));
    EvaluationContext newContext = context.addFinallyDest(finallyMark).setVars(vars) ;
    Var ex = (Var)newContext.getVar("$$ex$$") ;
    Var vret = (Var)newContext.getVar("$$ra$$") ;
    Mark the_end = new Mark() ;
    Mark start_pc = new Mark() ;
View Full Code Here

  }

  public static void createSynchronizedStatement(
      EvaluationContext context, Expr monitor, Collection<Statement> statements, InstList l) throws CompilerException {
    Mark finallyMark = new Mark() ;
    final VarDecl varDecl = new VarDecl("Object","$$mon$$",monitor);
    final VarStack vars = context.decls.addLocalVar(context.getFileUnitInfo(),
        new FIFO<VarDecl>(
        varDecl,
        new VarDecl("Throwable","$$ex$$"),
        new VarDecl("returnAddress","$$ra$$"))
        );
    EvaluationContext newContext = context.addFinallyDest(finallyMark).setVars(vars) ;
    LValue v = newContext.getVar("$$mon$$") ;
    Var ex = (Var)newContext.getVar("$$ex$$") ;
    Var vret = (Var)newContext.getVar("$$ra$$") ;
View Full Code Here

    if (context.returnInst == null) {
      createConvert(context, e, context.fullyQualified(context.methodDef.returnType), l) ;
      l.add(new Return(TypeCode.getType(context.methodDef.returnType))) ;
    }
    else {
      final VarDecl varDecl = new VarDecl(context.methodDef.returnType,"$$ret$$",e);
      final VarStack vars = context.decls.addLocalVar(context.getFileUnitInfo(),new FIFO<VarDecl>(varDecl));
      EvaluationContext newContext = context.setVars(vars) ;
      LValue v = newContext.getVar("$$ret$$") ;
      makeInit(newContext,varDecl.init,v.getType(),l) ;
      l.add(new Store(v)) ;
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)),
            null
View Full Code Here

        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>(),
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new PlusExpr(X,new ConstExpr(Integer.valueOf(1),null),null),null),null)),
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

TOP

Related Classes of org.allspice.structured.VarDecl

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.