Package org.allspice.bytecode.instructions

Examples of org.allspice.bytecode.instructions.Nop


  public static void createTryCatch(EvaluationContext context,
      Collection<Statement> statements, Collection<CatchBlock> catchBlocks, InstList l) throws CompilerException {
    Mark start_pc = new Mark() ;
    Mark end_pc = new Mark() ;
    l.add(new Nop(start_pc)) ;
    for(Statement s: statements) {
      context.compile(s,l) ;
    }
    l.add(new Nop(end_pc)) ;
    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)) ;
      for(Statement s1: cb.statements) {
        newContext.compile(s1,l) ;
      }
      l.add(new Goto(the_end)) ;
    }
    l.add(new Nop(the_end)) ;
  }
View Full Code Here


    l.add(new MonitorEnter()) ;
    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)) ;
    for(Statement s: statements) {
      newContext.compile(s,l) ;
    }
    l.add(new Nop(end_pc)) ;
    l.add(new JumpSub(finallyMark)) ;
    l.add(new Goto(the_end)) ;
    {
      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

    Mark endmark = new Mark() ;
    Mark elsemark = new Mark() ;
    l.add(new IfEquals0(context.getTypeCode(cond),elsemark)) ;
    createConvert(context, thenst, type,l) ;
    l.add(new Goto(endmark)) ;
    l.add(new Nop(elsemark)) ;
    createConvert(context, elsest, type,l) ;
    l.add(new Nop(endmark)) ;
  }
View Full Code Here

  public static void createDoWhile(EvaluationContext context,Expr cond,Collection<Statement> thenst, InstList l) throws CompilerException {
    Mark beginmark = new Mark() ;
    Mark endmark = new Mark() ;
    EvaluationContext newContext = context.setBreak(endmark).setContinue(beginmark) ;
    l.add(new Nop(beginmark)) ;
    for(Statement s: thenst) {
      newContext.compile(s,l) ;
    }
    context.compile(null,cond, l) ;
    l.add(new IfNotEquals0(context.getTypeCode(cond),beginmark)) ;
    l.add(new Nop(endmark)) ;
  }
View Full Code Here

  public static void createWhile(EvaluationContext context,Expr cond,Collection<Statement> thenst, InstList l) throws CompilerException {
    Mark beginmark = new Mark() ;
    Mark endmark = new Mark() ;
    EvaluationContext newContext = context.setBreak(endmark).setContinue(beginmark) ;
    l.add(new Nop(beginmark)) ;
    context.compile(null,cond, l) ;
    l.add(new IfEquals0(context.getTypeCode(cond),endmark)) ;
    for(Statement s: thenst) {
      newContext.compile(s,l) ;
    }
    l.add(new Goto(beginmark)) ;
    l.add(new Nop(endmark)) ;
  }
View Full Code Here

    l.add(new IfEquals0(context.getTypeCode(cond),elsemark)) ;
    for(Statement st: thenst) {
      context.compile(st,l) ;
    }
    l.add(new Goto(endmark)) ;
    l.add(new Nop(elsemark)) ;
    for(Statement st: elsest) {
      context.compile(st,l) ;
    }
    l.add(new Nop(endmark)) ;
  }
View Full Code Here

    Mark isZero = new Mark() ;
    Mark end = new Mark() ;
    l.add(new IfEquals0(context.getTypeCode(e),isZero)) ;
    l.add(new Const(Boolean.FALSE)) ;
    l.add(new Goto(end)) ;
    l.add(new Nop(isZero)) ;
    l.add(new Const(Boolean.TRUE)) ;
    l.add(new Nop(end)) ;
  }
View Full Code Here

  protected <T extends CompiledItem> void _compile(TypeName forwardType,T inst,EvaluationContext context,InstList il) {
    try {
      ExprCompiler<T> tconv = getCompiler(inst) ;
      PositionRange range = inst.getPositionRange() ;
      if (range != null) {
        il.add(new Nop(range.start.lineno)) ;
      }
      tconv.compile(forwardType, inst, context, il) ;
    } catch (CompilerException e) {
      e.range = inst.getPositionRange() ;
      il.addError(e) ;
View Full Code Here

TOP

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

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.