Package org.jruby.ast

Examples of org.jruby.ast.Node


            } catch (IOException ioe) {
                // TODO: log something?
            }

            // script was not found in cache above, so proceed to compile
            Node scriptNode = parseFile(readStream, filename, null);
            if (script == null) {
                script = tryCompile(scriptNode, className, new JRubyClassLoader(jrubyClassLoader), false);
            }

            if (script == null) {
View Full Code Here


        Frame lastFrame = context.preEvalWithBinding(binding);
        try {
            // Binding provided for scope, use it
            RubyString source = src.convertToString();
            Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine());

            return INTERPRET_EVAL(runtime, context, binding.getFile(), binding.getLine(), node, binding.getMethod(), self, binding.getFrame().getBlock());
        } catch (JumpException.BreakJump bj) {
            throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, (IRubyObject)bj.getValue(), "unexpected break");
        } catch (JumpException.RedoJump rj) {
View Full Code Here

       
        DynamicScope evalScope = context.getCurrentScope().getEvalScope();
        evalScope.getStaticScope().determineModule();
       
        try {
            Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);

            return INTERPRET_EVAL(runtime, context, file, lineNumber, node, "(eval)", self, Block.NULL_BLOCK);
        } catch (JumpException.BreakJump bj) {
            throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, (IRubyObject)bj.getValue(), "unexpected break");
        } catch (StackOverflowError soe) {
View Full Code Here

        assert false: "Trying to get block from something which cannot deliver";
        return null;
    }

    private static Block getBlockPassBlock(Node blockNode, Ruby runtime, ThreadContext context, IRubyObject self, Block currentBlock) {
        Node bodyNode = ((BlockPassNode) blockNode).getBodyNode();
        IRubyObject proc;
        if (bodyNode == null) {
            proc = runtime.getNil();
        } else {
            proc = bodyNode.interpret(runtime, context, self, currentBlock);
        }

        return RuntimeHelpers.getBlockFromBlockPassBody(proc, currentBlock);
    }
View Full Code Here

            } else {
                node.getPre().get(offset).assign(runtime, context, self, value.eltInternal(offset), Block.NULL_BLOCK, false);
            }
        }

        Node restArgument = node.getRest();
        if (restArgument != null) {
            int restLen = valueLen - varLen;
            if (restLen > 0) {
                restArgument.assign(runtime, context, self, value.subseqLight(offset, restLen), Block.NULL_BLOCK, false);
                offset += restLen;
            } else {
                restArgument.assign(runtime, context, self, RubyArray.newEmptyArray(runtime), Block.NULL_BLOCK, false);
            }
        }

        for (int i = 0; i < node.getPostCount(); i++) {
            offset += i;
View Full Code Here

        if (checkArity && j < varLen) {
            throw runtime.newArgumentError("Wrong # of arguments (" + valueLen + " for " + varLen + ")");
        }

        Node argsNode = node.getArgsNode();
        if (argsNode != null) {
            if (argsNode.getNodeType() == NodeType.STARNODE) {
                // no check for '*'
            } else if (varLen < valueLen) {
                argsNode.assign(runtime, context, self, value.subseqLight(varLen, valueLen), Block.NULL_BLOCK, checkArity);
            } else {
                argsNode.assign(runtime, context, self, RubyArray.newEmptyArray(runtime), Block.NULL_BLOCK, checkArity);
            }
        } else if (checkArity && valueLen < varLen) {
            throw runtime.newArgumentError("Wrong # of arguments (" + valueLen + " for " + varLen + ")");
        }

View Full Code Here

        int j = 0;
        for (; j < valueLen && j < preCount; j++) {
            pre.get(j).assign(runtime, context, self, value.eltInternal(j), Block.NULL_BLOCK, false);
        }

        Node rest = node.getRest();
        if (rest != null) {
            if (rest.getNodeType() == NodeType.STARNODE) {
                // no check for '*'
            } else if (preCount + postCount < valueLen) {
                rest.assign(runtime, context, self, value.subseqLight(preCount, valueLen - preCount - postCount), Block.NULL_BLOCK, false);
            } else {
                rest.assign(runtime, context, self, RubyArray.newEmptyArray(runtime), Block.NULL_BLOCK, false);
            }

            // FIXME: This is wrong
            int postIndexBase = valueLen - postCount;
            for (int i = 0; i < valueLen && i < postCount; i++) {
View Full Code Here

   * @throws JumpException in case of JRuby parsing failure
   */
  public static Object createJRubyObject(String scriptSource, Class[] interfaces, ClassLoader classLoader) {
    Ruby ruby = initializeRuntime();

    Node scriptRootNode = (oldParseMethod != null ?
        (Node) ReflectionUtils.invokeMethod(oldParseMethod, ruby, new Object[] {scriptSource, "", null}) :
        ruby.parse(scriptSource, "", null, 0));
    IRubyObject rubyObject = ruby.eval(scriptRootNode);

    if (rubyObject instanceof RubyNil) {
View Full Code Here

    if (node instanceof ClassNode) {
      return (ClassNode) node;
    }
    List children = node.childNodes();
    for (int i = 0; i < children.size(); i++) {
      Node child = (Node) children.get(i);
      if (child instanceof ClassNode) {
        return (ClassNode) child;
      } else if (child instanceof NewlineNode) {
        NewlineNode nn = (NewlineNode) child;
        Node found = findClassNode(nn.getNextNode());
        if (found instanceof ClassNode) {
          return (ClassNode) found;
        }
      }
    }
    for (int i = 0; i < children.size(); i++) {
      Node child = (Node) children.get(i);
      Node found = findClassNode(child);
      if (found instanceof ClassNode) {
        return (ClassNode) found;
      }
    }
    return null;
View Full Code Here

        // Refactoring should make this fixable.
        if (result.getScope() != null) {
            result.getScope().growIfNeeded();
        }

        Node ast = result.getAST();
       
        totalTime += System.nanoTime() - startTime;
        totalBytes += lexerSource.getOffset();

        return ast;
View Full Code Here

TOP

Related Classes of org.jruby.ast.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.