Exemple #1
0
    @Specialization
    public Object parseTree() {
      notDesignedForCompilation();

      final org.jruby.ast.Node parseTree =
          RubyCallStack.getCurrentMethod().getSharedMethodInfo().getParseTree();

      if (parseTree == null) {
        return NilPlaceholder.INSTANCE;
      } else {
        return getContext().makeString(parseTree.toString(true, 0));
      }
    }
  public MethodDefinitionNode compileClassNode(
      SourceSection sourceSection, String name, org.jruby.ast.Node bodyNode) {
    environment.addMethodDeclarationSlots();

    RubyNode body;

    if (bodyNode != null) {
      parentSourceSection = sourceSection;

      try {
        body = bodyNode.accept(this);
      } finally {
        parentSourceSection = null;
      }
    } else {
      body = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject());
    }

    if (environment.getFlipFlopStates().size() > 0) {
      body = SequenceNode.sequence(context, sourceSection, initFlipFlopStates(sourceSection), body);
    }

    body = new CatchReturnPlaceholderNode(context, sourceSection, body, environment.getReturnID());

    final RubyRootNode rootNode =
        new RubyRootNode(
            context,
            sourceSection,
            environment.getFrameDescriptor(),
            environment.getSharedMethodInfo(),
            body);

    return new MethodDefinitionNode(
        context,
        sourceSection,
        environment.getSharedMethodInfo().getName(),
        environment.getSharedMethodInfo(),
        environment.needsDeclarationFrame(),
        rootNode,
        false);
  }