Package org.allspice.bytecode

Examples of org.allspice.bytecode.Var


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

    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

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

    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() ;
    Mark end_pc = new Mark() ;
    Mark handler = new Mark() ;
    l.add(new Nop(start_pc)) ;
View Full Code Here

    Mark the_end = new Mark() ;
    l.add(new Goto(the_end)) ;
    for(CatchBlock cb: catchBlocks) {
      final VarStack vars = context.decls.addLocalVar(context.getFileUnitInfo(),new FIFO<VarDecl>(cb.ex));
      EvaluationContext newContext = context.setVars(vars) ;
      Var v = (Var)newContext.getVar(cb.ex.name);
      final String extype = cb.ex.type;
      Mark handler = new Mark() ;
      l.add(new ExceptionHandler(start_pc,end_pc,handler,context.fullyQualified(extype))) ;
      l.add(new Nop(handler)) ;
      l.add(new Store(v)) ;
View Full Code Here

        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$$") ;
    makeInit(newContext,varDecl.init,v.getType(),l) ;
    l.add(new Dup(TypeCode.VOID,TypeCode.OBJECT)) ;
    l.add(new Store(v)) ;
    l.add(new MonitorEnter()) ;
    Mark the_end = new Mark() ;
View Full Code Here

    {
      // constructor called <init>
      // must call superclass's <init>
      // Returns nothing
      MethodDef md = new MethodDef(TypeName.VOID,"<init>").addInstructions(
          new Load(new Var(0,new TypeName("TestClass"))),
          new InvokeSpecial(new MethodRef(cd.superClass,TypeName.VOID,"<init>")),
          new Return(TypeCode.VOID)
      ) ;
      // Watch it!  ClassDef is immutable
      cd = cd.addMethod(md) ;
    }
    {
      // Two variables, x & y
      // Index 0 is "this"
      Var x = new Var(1,TypeName.INT) ; // index 1
      Var y = new Var(2,TypeName.INT) ; // index 2
      MethodDef md = new MethodDef(TypeName.INT,"add",x,y).addInstructions(
          new Load(x),
          new Load(y),
          new Add(TypeCode.INT),
          new Return(TypeCode.INT)
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.Var

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.