Package org.allspice.structured.expr

Examples of org.allspice.structured.expr.SetValueExpr


  }
  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)
View Full Code Here


          }
        }
        else if (fom instanceof FieldDecl) {
          FieldDecl fdecl = (FieldDecl)fom ;
          if (fdecl.fieldAttrs.isStatic && fdecl.intializer != null) {
            SetValueExpr se = new SetValueExpr(new FieldVarExpr(cname.toString(),fdecl.name,null),fdecl.intializer,null) ;
            body = body.insert(new ExprStatement(se,null)) ;         
          }
        }
      }
      MethodDecl clinit = new MethodDecl(fa,"void","<clinit>",new FIFO<VarDecl>(),new FIFO<String>(),body) ;
View Full Code Here

    int pos = 1 ;
    ClassStub stub = resolver.getStub() ;
    for(FieldStub def: stub.fields.values()) {
      if (!def.isStatic) {
        if (def.initializer != null) {
          SetValueExpr se = new SetValueExpr(new FieldVarExpr(new VarExpr("this",null),def.nm,null),def.initializer,null) ;
          body.add(pos++,new ExprStatement(se,null)) ;
        }
      }
    }
  }
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 class TestSetStaticField extends MyTestCase {
  public static interface BooleanSetFieldTest {
    public void meth(boolean arg1) ;
  }
  public void test0() throws Exception {
    Statement st = new ExprStatement(new SetValueExpr(
        new FieldVarExpr("org.allspice.structuredtobc.test.StaticFieldTestClass","boolean_field",null),ARG0,null),null) ;
    BooleanSetFieldTest obj = makeObject(BooleanSetFieldTest.class,st,new ReturnStatement(null)) ;
    obj.meth(true) ;
    assertEquals(StaticFieldTestClass.boolean_field,true) ;
    obj.meth(false) ;
View Full Code Here

  }
  public static interface ByteSetFieldTest {
    public void meth(byte arg1) ;
  }
  public void test1() throws Exception {
    Statement st = new ExprStatement(new SetValueExpr(
        new FieldVarExpr("org.allspice.structuredtobc.test.StaticFieldTestClass","byte_field",null),ARG0,null),null) ;
    ByteSetFieldTest obj = makeObject(ByteSetFieldTest.class,st,new ReturnStatement(null)) ;
    obj.meth((byte)45) ;
    assertEquals(StaticFieldTestClass.byte_field,(byte)45) ;
  }
View Full Code Here

  }
  public static interface ShortSetFieldTest {
    public void meth(short arg1) ;
  }
  public void test2() throws Exception {
    Statement st = new ExprStatement(new SetValueExpr(
        new FieldVarExpr("org.allspice.structuredtobc.test.StaticFieldTestClass","short_field",null),ARG0,null),null) ;
    ShortSetFieldTest obj = makeObject(ShortSetFieldTest.class,st,new ReturnStatement(null)) ;
    obj.meth((short)45) ;
    assertEquals(StaticFieldTestClass.short_field,(short)45) ;
  }
View Full Code Here

  }
  public static interface CharSetFieldTest {
    public void meth(char arg1) ;
  }
  public void test3() throws Exception {
    Statement st = new ExprStatement(new SetValueExpr(
        new FieldVarExpr("org.allspice.structuredtobc.test.StaticFieldTestClass","char_field",null),ARG0,null),null) ;
    CharSetFieldTest obj = makeObject(CharSetFieldTest.class,st,new ReturnStatement(null)) ;
    obj.meth((char)45) ;
    assertEquals(StaticFieldTestClass.char_field,(char)45) ;
  }
View Full Code Here

  }
  public static interface IntSetFieldTest {
    public void meth(int arg1) ;
  }
  public void test5() throws Exception {
    Statement st = new ExprStatement(new SetValueExpr(
        new FieldVarExpr("org.allspice.structuredtobc.test.StaticFieldTestClass","int_field",null),ARG0,null),null) ;
    IntSetFieldTest obj = makeObject(IntSetFieldTest.class,st,new ReturnStatement(null)) ;
    obj.meth(5) ;
    assertEquals(StaticFieldTestClass.int_field,5) ;
  }
View Full Code Here

TOP

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

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.