Esempio n. 1
0
 /** Code */
 void codeBranch(Environment env, Context ctx, Assembler asm, Label lbl, boolean whenTrue) {
   left.codeValue(env, ctx, asm);
   switch (left.type.getTypeCode()) {
     case TC_INT:
       if (!right.equals(0)) {
         right.codeValue(env, ctx, asm);
         asm.add(where, whenTrue ? opc_if_icmpgt : opc_if_icmple, lbl, whenTrue);
         return;
       }
       break;
     case TC_LONG:
       right.codeValue(env, ctx, asm);
       asm.add(where, opc_lcmp);
       break;
     case TC_FLOAT:
       right.codeValue(env, ctx, asm);
       asm.add(where, opc_fcmpl);
       break;
     case TC_DOUBLE:
       right.codeValue(env, ctx, asm);
       asm.add(where, opc_dcmpl);
       break;
     default:
       throw new CompilerError("Unexpected Type");
   }
   asm.add(where, whenTrue ? opc_ifgt : opc_ifle, lbl, whenTrue);
 }
Esempio n. 2
0
 /** Code */
 public void codeValue(Environment env, Context ctx, Assembler asm) {
   right.codeValue(env, ctx, asm);
   if (type.isType(TC_INT)) {
     asm.add(where, opc_ldc, -1);
     asm.add(where, opc_ixor);
   } else {
     asm.add(where, opc_ldc2_w, -1L);
     asm.add(where, opc_lxor);
   }
 }
Esempio n. 3
0
 /** Code */
 public void code(Environment env, Context ctx, Assembler asm) {
   if (expr == null) {
     codeFinally(env, ctx, asm, null, null);
     asm.add(where, opc_return);
   } else {
     expr.codeValue(env, ctx, asm);
     codeFinally(env, ctx, asm, null, expr.type);
     asm.add(where, opc_ireturn + expr.type.getTypeCodeOffset());
   }
 }
  /** Code */
  public void code(Environment env, Context ctx, Assembler asm) {
    CodeContext newctx = new CodeContext(ctx, this);

    Label l1 = new Label();
    cond.codeBranch(env, newctx, asm, l1, false);
    ifTrue.code(env, newctx, asm);
    if (ifFalse != null) {
      Label l2 = new Label();
      asm.add(true, where, opc_goto, l2);
      asm.add(l1);
      ifFalse.code(env, newctx, asm);
      asm.add(l2);
    } else {
      asm.add(l1);
    }

    asm.add(newctx.breakLabel);
  }
Esempio n. 5
0
 /** Code */
 public void codeValue(Environment env, Context ctx, Assembler asm) {
   asm.add(where, opc_aconst_null);
 }