Package org.allspice.bytecode

Examples of org.allspice.bytecode.LValue


      throw new UndefinedVariable(var) ;
    }
  }

  public static LValue createVarLValue(EvaluationContext context, String var, InstList l) throws CompilerException {
    final LValue v = context.getVar(var);
    if (v instanceof FieldRef) {
      LValue c = context.getVar("this");
      if (c == null) {
        throw new StaticReferenceToMember(context.classDef.getTypeName(),var) ;
      }
      l.add(new Load(c)) ;
    }
View Full Code Here


    }
    else {
      final VarDecl varDecl = new VarDecl(context.methodDef.returnType,"$$ret$$",e);
      final VarStack vars = context.decls.addLocalVar(context.getFileUnitInfo(),new FIFO<VarDecl>(varDecl));
      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

      l.add(new Return(TypeCode.getType(context.methodDef.returnType))) ;
    }
  }
 
  public static LValue createSetValueExpr(EvaluationContext context,Expr lhs,Expr e,InstList l) throws CompilerException {
    LValue v = context.compileLValue(lhs, l);
    l.add(new Dup(TypeCode.VOID,v.getRefType())) ;
    makeInit(context,e,v.getType(),l) ;
    l.add(new Store(v)) ;
    return v ;
  }
View Full Code Here

    makeInit(context,e,v.getType(),l) ;
    l.add(new Store(v)) ;
    return v ;
  }
  public static void createSetValueExprNoReturn(EvaluationContext context,Expr lhs,Expr e,InstList l) throws CompilerException {
    LValue v = context.compileLValue(lhs, l);
    makeInit(context,e,v.getType(),l) ;
    l.add(new Store(v)) ;
  }
View Full Code Here

  }

  public static void createInstanceCall(EvaluationContext context,Expr decl, String name, Collection<Expr> args,Collection<TypeName> types,
      Inst i,InstList l) throws CompilerException {
    if (decl instanceof VarExpr) {
      LValue c = context.getVar("this");
      if (c == null) {
        throw new StaticReferenceToMember(context.classDef.getTypeName(),name) ;
      }
      l.add(new Load(c)) ;
    }
View Full Code Here

  }
  public static void createDeclStatement(EvaluationContext context,
      final Collection<VarDecl> varList, final Collection<Statement> statements, InstList l) throws CompilerException {
    EvaluationContext newContext = context.setVars(context.decls.addLocalVar(context.getFileUnitInfo(),varList)) ;
    for(VarDecl vd: varList) {
      LValue v = newContext.getVar(vd.name) ;
      makeInit(newContext,vd.init,v.getType(),l) ;
      l.add(new Store(v)) ;
    }
    for(Statement s: statements) {
      newContext.compile(s,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

    l.add(inst) ;
    l.add(new Store(v)) ;
  }

  public static LValue createInPlace(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 Dup(TypeCode.VOID,v.getRefType())) ;
    l.add(new Load(v)) ;
    createConvert(context, inc, v.getType(),l) ;
    l.add(inst) ;
    l.add(new Store(v)) ;
    return v ;
  }
View Full Code Here

    }
    FieldStub fd = context.getField(type, name) ;
    if (fd == null) {
      throw new UndefinedField(type.getTypeName().toString(),name) ;
    }
    LValue v = createLValue(context, e, name, l, fd) ;
    l.add(new Load(v)) ;
  }
View Full Code Here

  public void compile(TypeName forwardType, T t, EvaluationContext context, InstList l) throws CompilerException {
    if (forwardType != null && TypeCode.getType(forwardType) == TypeCode.VOID) {
      compileLValueNoReturn(t,context,l) ;
      return ;
    }
    LValue v = compileLValue(t, context, l) ;
    l.add(new Load(v)) ;
    StdJavaExpressions.convertResult(context,t,forwardType,l) ;
  }
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.LValue

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.