Package org.jruby.ast

Examples of org.jruby.ast.Node


        }
        return ((DStrNode) head).add(tail);
    }
   
    public Node newEvStrNode(ISourcePosition position, Node node) {
        Node head = node;
        while (true) {
            if (node == null) break;
           
            if (node instanceof StrNode || node instanceof DStrNode || node instanceof EvStrNode) {
                return node;
View Full Code Here


  }
 
  // This might lead to a problem with comments
  public void visitAndPrintWithSeparator(Iterator<Node> it) {
    while (it.hasNext()) {
      Node n = (Node) it.next();
      if(n instanceof ArgumentNode) {
        config.getOutput().print(((ArgumentNode) n).getName());
      } else {
        visitNode(n);
      }
View Full Code Here

        assertEquals(ReWriteVisitor.unescapeChar('\t'), "t");
        assertEquals(ReWriteVisitor.unescapeChar('n'), null);
    }

    public void testArgumentNode() {
        Node node = new ArgumentNode(new IDESourcePosition(), "name");
        assertEquals("name", ReWriteVisitor.createCodeFromNode(node, ""));
    }
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

        if (required > 0) {
            requiredAssignment = new ArrayCallback() {
                public void nextValue(BodyCompiler context, Object object, int index) {
                    ArrayNode arguments = (ArrayNode)object;
                    Node argNode = arguments.get(index);
                    switch (argNode.getNodeType()) {
                    case ARGUMENTNODE:
                        int varIndex = ((ArgumentNode)argNode).getIndex();
                        context.getVariableCompiler().assignLocalVariable(varIndex, false);
                        break;
                    case MULTIPLEASGN19NODE:
View Full Code Here

        ArrayCallback prePostAssignCallback = new ArrayCallback() {

                    public void nextValue(BodyCompiler context, Object sourceArray,
                            int index) {
                        ListNode nodes = (ListNode) sourceArray;
                        Node assignNode = nodes.get(index);

                        // perform assignment for the next node
                        compileAssignment(assignNode, context, false);
                    }
                };

        CompilerCallback restCallback = new CompilerCallback() {

                    public void call(BodyCompiler context) {
                        Node argsNode = multipleAsgn19Node.getRest();
                        if (argsNode instanceof StarNode) {
                            // done processing args
                            context.consumeCurrentValue();
                        } else {
                            // assign to appropriate variable
View Full Code Here

        // XXX: const lookup can trigger const_missing; is that enough to warrant it always being executed?
    }

    public void compileColon2(Node node, BodyCompiler context, boolean expr) {
        final Colon2Node iVisited = (Colon2Node) node;
        Node leftNode = iVisited.getLeftNode();
        final String name = iVisited.getName();

        if (leftNode == null) {
            context.loadObject();
            context.retrieveConstantFromModule(name);
View Full Code Here

        if (node == null) {
            context.pushByteList(ByteList.create(type));
        } else if (node instanceof ArrayNode) {
            Object endToken = context.getNewEnding();
            for (int i = 0; i < ((ArrayNode) node).size(); i++) {
                Node iterNode = ((ArrayNode) node).get(i);
                compileGetDefinition(iterNode, context);
                context.ifNull(endToken);
            }
            context.pushByteList(ByteList.create(type));
            Object realToken = context.getNewEnding();
View Full Code Here

                    BranchCallback setup = new BranchCallback() {

                                public void branch(BodyCompiler context) {
                                    if (iVisited instanceof Colon2Node) {
                                        final Node leftNode = ((Colon2Node) iVisited).getLeftNode();
                                        compile(leftNode, context,true);
                                    } else {
                                        context.loadObject();
                                    }
                                }
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.