Package org.allspice.bytecode.instructions

Examples of org.allspice.bytecode.instructions.Load


    {
      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(),
          new Return(TypeCode.INT)
          ) ;
      cd = cd.addMethod(md) ;
    }
View Full Code Here


    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))
        ) ;
    return cd.addMethod(md)
  }
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)
      ) ;
      // Watch it!  ClassDef is immutable
      cd = cd.addMethod(md) ;
View Full Code Here

    {
      l.add(new ExceptionHandler(start_pc,end_pc,handler,TypeName.THROWABLE)) ;
      l.add(new Nop(handler)) ;
      l.add(new Store(ex)) ;
      l.add(new JumpSub(finallyMark)) ;
      l.add(new Load(ex)) ;
      l.add(new Throw()) ;
    }
    l.add(new Nop(finallyMark)) ;
    l.add(new Store(vret)) ;
    for(Statement s: finallyStatements) {
View Full Code Here

    {
      l.add(new ExceptionHandler(start_pc,end_pc,handler,TypeName.THROWABLE)) ;
      l.add(new Nop(handler)) ;
      l.add(new Store(ex)) ;
      l.add(new JumpSub(finallyMark)) ;
      l.add(new Load(ex)) ;
      l.add(new Throw()) ;
    }
    l.add(new Nop(finallyMark)) ;
    l.add(new Store(vret)) ;
    l.add(new Load(v)) ;
    l.add(new MonitorExit()) ;
    l.add(new ReturnVar(vret.index)) ;
    l.add(new Nop(the_end))
  }
View Full Code Here

    if (TypeCode.getType(forwardType) == TypeCode.VOID) {
      l.add(new Increment(v,inc)) ;
    }
    else {
      l.add(new Dup(TypeCode.VOID,v.getRefType())) ;
      l.add(new Load(v)) ;
      final TypeCode tc = TypeCode.getType(v.getType());
      l.add(new Dup(v.getRefType(),tc)) ;
      l.add(new Pop(tc)) ;
      l.add(new Increment(v,inc)) ;
      convert(context,context.getType(e),forwardType,l) ;
View Full Code Here

    if (v instanceof FieldRef) {
      LValue c = context.getVar("this");
      if (c == null) {
        throw new StaticReferenceToMember(context.classDef.getTypeName(),var) ;
      }
      l.add(new Load(c)) ;
    }
    return v ;
  }
View Full Code Here

      EvaluationContext newContext = context.setVars(vars) ;
      LValue v = newContext.getVar("$$ret$$") ;
      makeInit(newContext,varDecl.init,v.getType(),l) ;
      l.add(new Store(v)) ;
      l.add(context.returnInst) ;
      l.add(new Load(v)) ;
      l.add(new Return(TypeCode.getType(context.methodDef.returnType))) ;
    }
  }
View Full Code Here

    if (decl instanceof VarExpr) {
      LValue c = context.getVar("this");
      if (c == null) {
        throw new StaticReferenceToMember(context.classDef.getTypeName(),name) ;
      }
      l.add(new Load(c)) ;
    }
    else if (decl instanceof FieldVarExpr){
      Expr object = ((FieldVarExpr)decl).object ;
      context.compile(null,object, l) ;
    }
View Full Code Here

  }

  public static void createInPlaceNoReturn(EvaluationContext context, Expr inc, final Expr var, final Inst inst,InstList l ) throws CompilerException {
    LValue v = context.compileLValue(var, l);
    l.add(new Dup(TypeCode.VOID,v.getRefType())) ;
    l.add(new Load(v)) ;
    createConvert(context, inc, v.getType(),l) ;
    l.add(inst) ;
    l.add(new Store(v)) ;
  }
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.instructions.Load

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.