コード例 #1
0
  public void writeInline(EmitContext emitContext, InstructionAdapter mv) {

    // Last check for assumption violations
    types.verifyFunctionAssumptions(runtimeState);

    Label exitLabel = new Label();

    for (BasicBlock basicBlock : cfg.getBasicBlocks()) {
      if (basicBlock != cfg.getEntry() && basicBlock != cfg.getExit()) {
        for (IRLabel label : basicBlock.getLabels()) {
          mv.visitLabel(emitContext.getAsmLabel(label));
        }
        for (Statement stmt : basicBlock.getStatements()) {
          try {
            if (stmt instanceof ReturnStatement) {
              // Instead of returning, just push the return value on the stack
              // and jump to the exit point for the function.
              stmt.getRHS().load(emitContext, mv);
              mv.goTo(exitLabel);

            } else {
              stmt.emit(emitContext, mv);
            }
          } catch (NotCompilableException e) {
            throw e;
          } catch (Exception e) {
            throw new InternalCompilerException("Exception compiling statement " + stmt, e);
          }
        }
      }
    }
    mv.mark(exitLabel);
  }
コード例 #2
0
  @Override
  public int load(EmitContext emitContext, InstructionAdapter mv) {
    int stackSizeIncrease =
        assertDouble(childAt(0)).load(emitContext, mv)
            + assertDouble(childAt(1)).load(emitContext, mv);

    mv.visitMethodInsn(
        Opcodes.INVOKESTATIC,
        Type.getInternalName(DoubleSequence.class),
        "fromTo",
        Type.getMethodDescriptor(
            Type.getType(AtomicVector.class), Type.DOUBLE_TYPE, Type.DOUBLE_TYPE),
        false);

    return stackSizeIncrease;
  }