示例#1
0
 public void createBCode(CodeGeneration gen) {
   super.createBCode(gen);
   if (hasResult()) {
     TypeDecl type = null;
     BodyDecl b = enclosingBodyDecl();
     if (b instanceof MethodDecl) {
       type = ((MethodDecl) b).type();
     } else {
       throw new Error("Can not create code that returns value within non method");
     }
     getResult().createBCode(gen);
     getResult().type().emitCastTo(gen, type);
     if (!finallyList().isEmpty()) {
       type.emitStoreLocal(gen, resultSaveLocalNum());
     }
     for (Iterator iter = finallyList().iterator(); iter.hasNext(); ) {
       FinallyHost stmt = (FinallyHost) iter.next();
       gen.emitJsr(stmt.label_finally_block());
     }
     if (!finallyList().isEmpty()) {
       type.emitLoadLocal(gen, resultSaveLocalNum());
     }
     type.emitReturn(gen);
   } else {
     for (Iterator iter = finallyList().iterator(); iter.hasNext(); ) {
       FinallyHost stmt = (FinallyHost) iter.next();
       gen.emitJsr(stmt.label_finally_block());
     }
     gen.emitReturn();
   }
 }
示例#2
0
文件: IfStmt.java 项目: h-inoue/JCop
 public void createBCode(CodeGeneration gen) {
   super.createBCode(gen);
   int elseBranch = else_branch_label();
   int thenBranch = then_branch_label();
   int endBranch = hostType().constantPool().newLabel();
   getCondition().emitEvalBranch(gen);
   gen.addLabel(thenBranch);
   // if(getCondition().canBeTrue()) {
   getThen().createBCode(gen);
   if (getThen().canCompleteNormally() && hasElse() /*&& getCondition().canBeFalse()*/)
     gen.emitGoto(endBranch);
   // }
   gen.addLabel(elseBranch);
   if (hasElse() /*&& getCondition().canBeFalse()*/) getElse().createBCode(gen);
   gen.addLabel(endBranch);
 }
示例#3
0
 /**
  * @ast method
  * @aspect CreateBCode
  * @declaredat /home/uoji/JastAddJ/Java1.4Backend/CreateBCode.jrag:1189
  */
 public void createBCode(CodeGeneration gen) {
   super.createBCode(gen);
 }