Package org.allspice.bytecode

Examples of org.allspice.bytecode.TypeName


public class TestField extends MyTestCase {
  public ClassDef defadd(String type) {
    ClassDef cd = makeClass() ;
   
    FieldDef fd = new FieldDef(Scope.PUBLIC,new TypeName(type),"foo") ;
    cd = cd.addField(fd) ;
    {
      Var x = new Var(1,new TypeName(type)) ;
      MethodDef md = new MethodDef(TypeName.VOID,"setFoo",x) ;
      md = md.addInstructions(
          new Load(new Var(0,new TypeName("TestClass"))),
          new Load(x),
          new Store(new FieldRef(cd.name,new TypeName(type),"foo")),
          new Return(TypeCode.VOID)
          ) ;
      cd = cd.addMethod(md) ;
    }
    {
      MethodDef md = new MethodDef(new TypeName(type),"getFoo") ;
      md = md.addInstructions(
          new Load(new Var(0,new TypeName("TestClass"))),
          new Load(new FieldRef(cd.name,new TypeName(type),"foo")),
          new Return(TypeCode.getType(type))
          ) ;
      cd = cd.addMethod(md) ;
    }
    return cd ;
View Full Code Here


import org.allspice.bytecode.instructions.Return;

public class TestCompare extends MyTestCase {
  public ClassDef defadd(String type,int i1) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(1,new TypeName(type)) ;
    Var y = new Var(i1,new TypeName(type)) ;
    MethodDef md = new MethodDef(TypeName.INT,"meth",x,y) ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
        new Compare(TypeCode.getType(type)),
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestArrIncrement extends MyTestCase {
  public ClassDef defadd(Number inc) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(1,new TypeName("int[]")) ;
    MethodDef md = new MethodDef(TypeName.VOID,"meth",x) ;
    md = md.addInstructions(
        new Load(x),
        new Const(0),
        new Increment(new ArrLValue(TypeName.INT),inc),
View Full Code Here

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

public class TestNew extends MyTestCase {
  public ClassDef defadd() {
    ClassDef cd = makeClassDef() ;
    {
      MethodRef mref = new MethodRef(
          new TypeName("TestClass"),TypeName.VOID,"<init>") ;
      MethodDef md = new MethodDef(new TypeName("TestClass"),"getFoo") ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new New(new TypeName("TestClass")),
          new org.allspice.bytecode.instructions.Dup(TypeCode.VOID,TypeCode.OBJECT),
          new InvokeSpecial(mref),
          new Return(TypeCode.OBJECT)
          ) ;
      cd = cd.addMethod(md) ;
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFGT0 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 IfGreaterThan0(TypeCode.getType(type),one),
View Full Code Here

import org.allspice.bytecode.instructions.Subtract;

public class TestSub 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 Subtract(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFEQ0 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 IfEquals0(TypeCode.getType(type),one),
View Full Code Here

import org.allspice.bytecode.instructions.Return;

public class TestIFLE0 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 IfLessThanEq0(TypeCode.getType(type),one),
View Full Code Here

  public ClassDef defadd() {
    ClassDef cd = makeClass() ;
    Var x = new Var(1,TypeName.INT) ;
    Var y = new Var(2,TypeName.INT) ;
    Var z = new Var(3,TypeName.INT) ;
    Var vret = new Var(4,new TypeName("returnAddress")) ;
    MethodDef md = new MethodDef(TypeName.INT,"meth",x,y) ;
    Mark sub = new Mark() ;
    md = md.addInstructions(
        new JumpSub(sub),
        new Load(z),
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.TypeName

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.