Package org.allspice.bytecode

Examples of org.allspice.bytecode.TypeName


import org.allspice.bytecode.instructions.UnsignedShiftRight;

public class TestUSHR 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,TypeName.INT) ;
    MethodDef md = new MethodDef(new TypeName(ret),"meth",x,y) ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
        new UnsignedShiftRight(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
View Full Code Here


import org.allspice.bytecode.instructions.Store;

public class TestArrStr extends MyTestCase {
  public ClassDef defadd(String type) {
    ClassDef cd = makeClassDef() ;
    FieldDef fd = new FieldDef(Scope.PUBLIC,new TypeName(type),"foo") ;
    fd = fd.setStatic(true) ;
    cd = cd.addField(fd) ;
    {
      Var x = new Var(0,new TypeName(type+"[]")) ;
      Var y = new Var(1,TypeName.INT) ;
      Var z = new Var(2,new TypeName(type)) ;
      MethodDef md = new MethodDef(TypeName.VOID,"setFoo",x,y,z) ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new Load(x),
          new Load(y),
          new Load(z),
          new Store(new ArrLValue(new TypeName(type))),
          new Return(TypeCode.VOID)
          ) ;
      cd = cd.addMethod(md) ;
    }
    return cd ;
View Full Code Here

import org.allspice.bytecode.instructions.Throw;

public class TestException extends MyTestCase {
  public ClassDef defadd() {
    ClassDef cd = makeClass() ;
    Var x = new Var(1,new TypeName("java.lang.Exception")) ;
    Var ex = new Var(2,new TypeName("java.lang.Exception")) ;
    MethodDef md = new MethodDef(TypeName.INT,"meth",x) ;
    Mark start_pc = new Mark() ;
    Mark end_pc = new Mark() ;
    Mark the_end = new Mark() ;
    Mark handler = new Mark() ;
    md = md.addInstructions(
        new Nop(start_pc),
        new Load(x),
        new Throw(),
        new Nop(end_pc),
        new Goto(the_end),
        new ExceptionHandler(start_pc,end_pc,handler,new TypeName("java.lang.Exception")),
        new Nop(handler),
        new Store(ex),
        new Const(1),
        new Return(TypeCode.INT),
        new Nop(the_end),
View Full Code Here

public class TestStore extends MyTestCase {
  public ClassDef defadd01(String type,int i1) {
    ClassDef cd = makeClassDef() ;
    {
      Var x = new Var(0,new TypeName(type)) ;
      Var y = new Var(i1,new TypeName(type)) ;
      MethodDef md = new MethodDef(new TypeName(type),"getFoo",x) ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new Load(x),
          new Store(y),
          new Load(y),
View Full Code Here

import org.allspice.bytecode.instructions.Return;

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

import org.allspice.bytecode.instructions.Return;

public class TestArrLen extends MyTestCase {
  public ClassDef defadd(String type) {
    ClassDef cd = makeClassDef() ;
    FieldDef fd = new FieldDef(Scope.PUBLIC,new TypeName(type),"foo") ;
    fd = fd.setStatic(true) ;
    cd = cd.addField(fd) ;
    {
      Var x = new Var(0,new TypeName(type+"[]")) ;
      MethodDef md = new MethodDef(TypeName.INT,"getFoo",x) ;
      md = md.setStatic(true) ;
      md = md.addInstructions(
          new Load(x),
          new ArrLen(),
View Full Code Here

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

import org.allspice.bytecode.instructions.Xor;

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

  public static void createConditional(EvaluationContext context,
      Expr cond, Expr thenst, Expr elsest,InstList l ) throws CompilerException {
    StubResolver td1 = context.getType(thenst) ;
    StubResolver td2 = context.getType(elsest) ;
    TypeCode t1 = condTable.get(new TypePair(td1.getTypeCode(),td2.getTypeCode())) ;
    TypeName type = (t1 != null) ? TypeName.valueOf(t1) : null ;
    context.compile(null,cond, l) ;
    Mark endmark = new Mark() ;
    Mark elsemark = new Mark() ;
    l.add(new IfEquals0(context.getTypeCode(cond),elsemark)) ;
    createConvert(context, thenst, type,l) ;
View Full Code Here

    vs = vs.addLocalVar(fuinfo,mdecl.parameters) ;
    return vs ;
  }

  public static void createNew(EvaluationContext context, final String type, final Collection<Expr> args, InstList l) throws CompilerException {
    TypeName fqtype = context.fullyQualified(type) ;
    l.add(new New(fqtype)) ;
    l.add(new Dup(TypeCode.VOID,TypeCode.getType(type))) ;
    MethodStub fd = context.getMethod(context.makeTypeRef(fqtype), "<init>", args) ;
    if (fd == null) {
      throw new UndefinedMethod("<init>") ;
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.