protected void emitCoerceOrNullMethod(Variable variable, Compilation compilation) {
   compilation = compilation.getCode();
   if (variable != null) {
     compilation.emitLoad(variable);
   }
   compilation.emitPushString(target);
   compilation.emitInvokeStatic(coerceOrNullMethod);
 }
Ejemplo n.º 2
0
 public void emitTestIf(Variable incoming, Declaration decl, Compilation comp) {
   CodeAttr code = comp.getCode();
   if (incoming != null) code.emitLoad(incoming);
   if (decl != null) {
     code.emitDup();
     decl.compileStore(comp);
   }
   comp.compileConstant(this);
   code.emitSwap();
   code.emitInvokeVirtual(isInstanceMethod);
   code.emitIfIntNotZero();
 }
 public void compile(ApplyExp paramApplyExp, Compilation paramCompilation, Target paramTarget) {
   paramCompilation.getCode();
   paramApplyExp = paramApplyExp.getArgs();
   int j = paramApplyExp.length;
   int i;
   if (((this.blockTarget instanceof IgnoreTarget))
       || ((this.blockTarget instanceof ConsumerTarget))) {
     i = 1;
     if (i == 0) {
       break label90;
     }
   }
   for (; ; ) {
     if ((i == 0) && (j != 1)) {
       break label98;
     }
     i = 0;
     while (i < j) {
       paramApplyExp[i].compileWithPosition(paramCompilation, this.blockTarget);
       i += 1;
     }
     i = 0;
     break;
     label90:
     paramTarget.getType();
   }
   label98:
   paramTarget = AppendValues.appendValues;
   paramTarget.compile(
       new ApplyExp(paramTarget, paramApplyExp), paramCompilation, this.blockTarget);
   this.exitableBlock.exit();
 }
Ejemplo n.º 4
0
 public static Expression rewrite(Object paramObject1, Object paramObject2) {
   Translator localTranslator = (Translator) Compilation.getCurrent();
   Expression localExpression = localTranslator.rewrite(paramObject1);
   Object localObject = null;
   paramObject1 = null;
   FVector localFVector = (FVector) paramObject2;
   int j = localFVector.size();
   int i = 0;
   paramObject2 = localObject;
   if (i < j) {
     localObject = SchemeCompilation.lambda.rewrite(localFVector.get(i), localTranslator);
     if ((localObject instanceof ErrorExp)) {
       return (Expression) localObject;
     }
     if (!(localObject instanceof LambdaExp)) {
       return localTranslator.syntaxError("internal error with try-catch");
     }
     localObject = new CatchClause((LambdaExp) localObject);
     if (paramObject2 == null) {
       paramObject1 = localObject;
     }
     for (; ; ) {
       paramObject2 = localObject;
       i += 1;
       break;
       ((CatchClause) paramObject2).setNext((CatchClause) localObject);
     }
   }
   if ((localExpression instanceof ErrorExp)) {
     return localExpression;
   }
   paramObject2 = new TryExp(localExpression, null);
   ((TryExp) paramObject2).setCatchClauses((CatchClause) paramObject1);
   return (Expression) paramObject2;
 }
  public void compile(ApplyExp applyexp, Compilation compilation, Target target) {
    Expression aexpression[] = applyexp.getArgs();
    CodeAttr codeattr = compilation.getCode();
    codeattr.pushScope();
    gnu.bytecode.Variable variable = codeattr.addLocal(Type.pointer_type);
    aexpression[0].compile(compilation, Target.pushObject);
    codeattr.emitStore(variable);
    for (int i = 1; i < aexpression.length; ) {
      if (i > 1) {
        codeattr.emitElse();
      }
      int k = i + 1;
      applyexp = aexpression[i];
      if (applyexp instanceof LambdaExp) {
        LambdaExp lambdaexp = (LambdaExp) applyexp;
        applyexp = lambdaexp.firstDecl();
        Type type = applyexp.getType();
        if (!applyexp.getCanRead()) {
          applyexp = null;
        } else {
          applyexp.allocateVariable(codeattr);
        }
        if (type instanceof TypeValue) {
          ((TypeValue) type).emitTestIf(variable, applyexp, compilation);
        } else {
          if (k < aexpression.length) {
            codeattr.emitLoad(variable);
            type.emitIsInstance(codeattr);
            codeattr.emitIfIntNotZero();
          }
          if (applyexp != null) {
            codeattr.emitLoad(variable);
            applyexp.compileStore(compilation);
          }
        }
        lambdaexp.allocChildClasses(compilation);
        lambdaexp.body.compileWithPosition(compilation, target);
        i = k;
      } else {
        throw new Error("not implemented: typeswitch arg not LambdaExp");
      }
    }

    int j = aexpression.length - 2;
    do {
      j--;
      if (j >= 0) {
        codeattr.emitFi();
      } else {
        codeattr.popScope();
        return;
      }
    } while (true);
  }
 public static TemplateScope make() {
   return make((Translator) Compilation.getCurrent());
 }