Package org.allspice.bytecode

Examples of org.allspice.bytecode.ClassDef


    m = obj.getMethod("getFoo") ;
    assertEquals(m.invoke(null),(short)42) ;
  }
  public void test7() throws Exception {
   
    ClassDef cd = defadd("char") ;
    Class<?> obj = makeClass(cd) ;
    Method m = obj.getMethod("setFoo",char.class) ;
    m.invoke(null,(char)42) ;
    Field f = obj.getField("foo") ;
    assertEquals(f.get(null),(char)42) ;
View Full Code Here


    m = obj.getMethod("getFoo") ;
    assertEquals(m.invoke(null),(char)42) ;
  }
  public void test8() throws Exception {
   
    ClassDef cd = defadd("boolean") ;
    Class<?> obj = makeClass(cd) ;
    Method m = obj.getMethod("setFoo",boolean.class) ;
    m.invoke(null,true) ;
    Field f = obj.getField("foo") ;
    assertEquals(f.get(null),true) ;
View Full Code Here

    m = obj.getMethod("getFoo") ;
    assertEquals(m.invoke(null),true) ;
  }
  public void test9() throws Exception {
   
    ClassDef cd = defadd("java.lang.String") ;
    Class<?> obj = makeClass(cd) ;
    Method m = obj.getMethod("setFoo",String.class) ;
    m.invoke(null,"abc") ;
    Field f = obj.getField("foo") ;
    assertEquals(f.get(null),"abc") ;
View Full Code Here

import org.allspice.bytecode.instructions.Load;
import org.allspice.bytecode.instructions.Return;

public class TestDiv extends MyTestCase {
  public ClassDef defadd(String ret,String type,int i1,int i2) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    Var y = new Var(i2,new TypeName(type)) ;
    MethodDef md = new MethodDef(new TypeName(ret),"meth",x,y) ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
        new Divide(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
        ) ;
    return cd.addMethod(md)
  }
View Full Code Here

        ) ;
    return cd.addMethod(md)
  }
  public void test1() throws Exception {
   
    ClassDef cd = defadd("double","double",1,3) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",double.class,double.class) ;
    Object o = m.invoke(obj,7.0,2.0) ;
    assertEquals(o,7.0 / 2.0) ;
  }
View Full Code Here

    Object o = m.invoke(obj,7.0,2.0) ;
    assertEquals(o,7.0 / 2.0) ;
  }
  public void test2() throws Exception {
   
    ClassDef cd = defadd("long","long",1,3) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",long.class,long.class) ;
    Object o = m.invoke(obj,7L,2L) ;
    assertEquals(o,7L / 2L) ;
  }
View Full Code Here

    Object o = m.invoke(obj,7L,2L) ;
    assertEquals(o,7L / 2L) ;
  }
  public void test3() throws Exception {
   
    ClassDef cd = defadd("float","float",1,2) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",float.class,float.class) ;
    Object o = m.invoke(obj,7.0F,2.0F) ;
    assertEquals(o,7.0F / 2.0F) ;
  }
View Full Code Here

    Object o = m.invoke(obj,7.0F,2.0F) ;
    assertEquals(o,7.0F / 2.0F) ;
  }
  public void test4() throws Exception {
   
    ClassDef cd = defadd("int","int",1,2) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",int.class,int.class) ;
    Object o = m.invoke(obj,7,2) ;
    assertEquals(o,7 / 2) ;
  }
View Full Code Here

    Object o = m.invoke(obj,7,2) ;
    assertEquals(o,7 / 2) ;
  }
  public void test5() throws Exception {
   
    ClassDef cd = defadd("int","short",1,2) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",short.class,short.class) ;
    {
      Object o = m.invoke(obj,(short)7,(short)2) ;
      assertEquals(o,(short)7 / (short)2) ;
View Full Code Here

import org.allspice.bytecode.instructions.Nop;
import org.allspice.bytecode.instructions.Return;

public class TestIFGE0 extends MyTestCase {
  public ClassDef defadd(String type,int i1) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    MethodDef md = new MethodDef(TypeName.BOOLEAN,"meth",x) ;
    Mark one = new Mark() ;
    md = md.addInstructions(
        new Load(x),
        new IfGreaterThanEq0(TypeCode.getType(type),one),
        new Const(false),
        new Return(TypeCode.BOOLEAN),
        new Nop(one),
        new Const(true),
        new Return(TypeCode.BOOLEAN)
        ) ;
    return cd.addMethod(md)
  }
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.ClassDef

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.