Examples of VarDecl


Examples of ast.VarDecl

      define anything new.
       */
      if(decl instanceof FunctionDeclaration) {
        new FunctionCodeGenerator(this).generate((FunctionDeclaration)decl, klass);
      } else if(decl instanceof FieldDeclaration) {
        VarDecl vd = ((FieldDeclaration)decl).getVarDecl();
        String fieldName = vd.getName();
        Type fieldType = SootTypeUtil.getSootType(vd.getTypeName().getDescriptor());
        int fieldModifiers = getModifiers(decl);
        SootField sootField = new SootField(fieldName, fieldType, fieldModifiers);
        klass.addField(sootField);
      }
    }
View Full Code Here

Examples of ast.VarDecl

  }
 
  /** Generate code for a variable name. */
  @Override
  public Value visitVarName(VarName nd) {
    VarDecl decl = nd.decl();
    // determine whether this name refers to a local or to a field
    if(decl.isLocal()) {
      return fcg.getSootLocal(decl);
    } else {
      SootClass declaringClass = fcg.getModuleCodeGenerator().getProgramCodeGenerator().getSootClass(decl.getModule());
      Type fieldType = SootTypeUtil.getSootType(decl.getTypeName().getDescriptor());
      return Jimple.v().newStaticFieldRef(Scene.v().makeFieldRef(declaringClass, decl.getName(), fieldType, true));
    }
  }
View Full Code Here

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

Examples of org.allspice.structured.VarDecl

  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

Examples of org.allspice.structured.VarDecl

  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

Examples of org.allspice.structured.VarDecl

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

Examples of org.allspice.structured.VarDecl

  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

Examples of org.allspice.structured.VarDecl

  }

  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

Examples of org.allspice.structured.VarDecl

    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

Examples of org.allspice.structured.VarDecl

          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
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.