Package org.jruby.ast

Examples of org.jruby.ast.ArrayNode


        } else {
            return new ZYieldNode(position);
        }

        if (state && node instanceof ArrayNode) {
            ArrayNode args = (ArrayNode) node;

            switch (args.size()) {
                case 0:
                    return new ZYieldNode(position);
                case 1:
                    return new YieldOneNode(position, args);
                case 2:
View Full Code Here


        return lexer.isIdentifierChar(name.charAt(0));
    }

    // 1.9
    public ListNode list_append(Node list, Node item) {
        if (list == null) return new ArrayNode(item.getPosition(), item);
        if (!(list instanceof ListNode)) return new ArrayNode(list.getPosition(), list).add(item);

        return ((ListNode) list).add(item);
    }
View Full Code Here

            } else {
                return ((ListNode) first).addAll(second);
            }
        }

        return new ArrayNode(first.getPosition(), first).add(second);
    }
View Full Code Here

        return null;
    }

    // 1.9
    public Node arg_append(Node node1, Node node2) {
        if (node1 == null) return new ArrayNode(node2.getPosition(), node2);
        if (node1 instanceof ListNode) return ((ListNode) node1).add(node2);
        if (node1 instanceof BlockPassNode) return arg_append(((BlockPassNode) node1).getBodyNode(), node2);
        if (node1 instanceof ArgsPushNode) {
            ArgsPushNode pushNode = (ArgsPushNode) node1;
            Node body = pushNode.getSecondNode();

            return new ArgsCatNode(pushNode.getPosition(), pushNode.getFirstNode(),
                    new ArrayNode(body.getPosition(), body).add(node2));
        }

        return new ArgsPushNode(position(node1, node2), node1, node2);
    }
View Full Code Here

            throw new SyntaxException(PID.BLOCK_ARG_UNEXPECTED, node.getPosition(),
                    lexer.getCurrentLine(), "Block argument should not be given.");
        }

        if (node instanceof ArrayNode) {
            ArrayNode args = (ArrayNode) node;

            switch (args.size()) {
                case 0:
                    return new ZYieldNode(position);
                case 1:
                    return new YieldOneNode(position, args);
                case 2:
View Full Code Here

    public static RubyString getArgumentDefinition(Ruby runtime, ThreadContext context, Node node, RubyString type, IRubyObject self, Block block) {
        if (node == null) return type;
           
        if (node instanceof ArrayNode) {
            ArrayNode list = (ArrayNode) node;
            int size = list.size();

            for (int i = 0; i < size; i++) {
                if (list.get(i).definition(runtime, context, self, block) == null) return null;
            }
        } else if (node.definition(runtime, context, self, block) == null) {
            return null;
        }
View Full Code Here

    public static IRubyObject[] setupArgs(Ruby runtime, ThreadContext context, Node node, IRubyObject self, Block aBlock) {
        if (node == null) return IRubyObject.NULL_ARRAY;

        if (node instanceof ArrayNode) {
            ArrayNode argsArrayNode = (ArrayNode) node;
            String savedFile = context.getFile();
            int savedLine = context.getLine();
            int size = argsArrayNode.size();
            IRubyObject[] argsArray = new IRubyObject[size];

            for (int i = 0; i < size; i++) {
                argsArray[i] = argsArrayNode.get(i).interpret(runtime, context, self, aBlock);
            }

            context.setFileAndLine(savedFile, savedLine);

            return argsArray;
View Full Code Here

        CompilerCallback blockAssignment = null;

        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;
View Full Code Here

                    if (normalAssigns) {
                        // only supports simple parallel assignment of up to 4 values to the same number of assignees
                        int size = multipleAsgn19Node.getPreCount();
                        if (size >= 2 && size <= 10) {
                            ArrayNode values = (ArrayNode)multipleAsgn19Node.getValueNode();
                            for (Node value : values.childNodes()) {
                                compile(value, context, true);
                            }
                            context.reverseValues(size);
                            for (Node asgn : multipleAsgn19Node.getPre().childNodes()) {
                                compileAssignment(asgn, context, false);
View Full Code Here

TOP

Related Classes of org.jruby.ast.ArrayNode

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.