Package org.jruby.ast

Examples of org.jruby.ast.OpElementAsgnNode


        // TODO: don't require pop
        if (!expr) context.consumeCurrentValue();
    }

    public void compileOpElementAsgnWithMethod(Node node, BodyCompiler context, boolean expr) {
        final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;

        CompilerCallback receiverCallback = new CompilerCallback() {
            public void call(BodyCompiler context) {
                compile(opElementAsgnNode.getReceiverNode(), context,true);
            }
        };

        ArgumentsCallback argsCallback = getArgsCallback(opElementAsgnNode.getArgsNode());

        CompilerCallback valueCallback = new CompilerCallback() {
            public void call(BodyCompiler context) {
                compile(opElementAsgnNode.getValueNode(), context,true);
            }
        };

        context.getInvocationCompiler().opElementAsgnWithMethod(receiverCallback, argsCallback, valueCallback, opElementAsgnNode.getOperatorName());
        // TODO: don't require pop
        if (!expr) context.consumeCurrentValue();
    }
View Full Code Here


            return true;
        }
    }

    public Operand buildOpElementAsgn(Node node, IRScope m) {
        final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
       
        if (opElementAsgnNode.getOperatorName() == "||") {
            return buildOpElementAsgnWithOr(node, m);
        } else if (opElementAsgnNode.getOperatorName() == "&&") {
            return buildOpElementAsgnWithAnd(node, m);
        } else {
            return buildOpElementAsgnWithMethod(node, m);
        }
    }
View Full Code Here

    //    val = build(n) <-- val
    //    buildCall([]= tmp, arg, val)
    // L:
    //
    public Operand buildOpElementAsgnWithOr(Node node, IRScope s) {
        final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
        Operand array = build(opElementAsgnNode.getReceiverNode(), s);
        Label    l     = s.getNewLabel();
        Variable elt   = s.getNewTemporaryVariable();
        Variable flag  = s.getNewTemporaryVariable();
        List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
        // SSS FIXME: Verify with Tom that I am not missing something here
        assert args.size() == 1;
        Operand  index = args.get(0);
        s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null));
        s.addInstr(new IsTrueInstr(flag, elt));
        s.addInstr(new BEQInstr(flag, BooleanLiteral.TRUE, l));
        Operand value = build(opElementAsgnNode.getValueNode(), s);
        s.addInstr(new CallInstr(elt, new MethAddr("[]="), array, new Operand[] { index, value }, null));
        s.addInstr(new CopyInstr(elt, value));
        s.addInstr(new LABEL_Instr(l));
        return elt;
    }
View Full Code Here

        return elt;
    }

    // Translate "a[x] &&= n" --> "a[x] = n if is_true(a[x])"
    public Operand buildOpElementAsgnWithAnd(Node node, IRScope s) {
        final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;
        Operand array = build(opElementAsgnNode.getReceiverNode(), s);
        Label    l     = s.getNewLabel();
        Variable elt   = s.getNewTemporaryVariable();
        Variable flag  = s.getNewTemporaryVariable();
        List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
        // SSS FIXME: Verify with Tom that I am not missing something here
        assert args.size() == 1;
        Operand  index = args.get(0);
        s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null));
        s.addInstr(new IsTrueInstr(flag, elt));
        s.addInstr(new BEQInstr(flag, BooleanLiteral.FALSE, l));
        Operand value = build(opElementAsgnNode.getValueNode(), s);
        s.addInstr(new CallInstr(elt, new MethAddr("[]="), array, new Operand[] { index, value }, null));
        s.addInstr(new CopyInstr(elt, value));
        s.addInstr(new LABEL_Instr(l));
        return elt;
    }
View Full Code Here

    //    elt = buildCall([], arr, arg)
    //    val = build(n) <-- val
    //    val = buildCall(METH, elt, val)
    //    val = buildCall([]=, arr, arg, val)
    public Operand buildOpElementAsgnWithMethod(Node node, IRScope s) {
        final OpElementAsgnNode opElementAsgnNode = (OpElementAsgnNode) node;

        Operand array = build(opElementAsgnNode.getReceiverNode(), s);
        List<Operand> args = setupCallArgs(opElementAsgnNode.getArgsNode(), s);
        // SSS FIXME: Verify with Tom that I am not missing something here
        assert args.size() == 1;
        Operand  index = args.get(0);
        Variable elt   = s.getNewTemporaryVariable();
        s.addInstr(new CallInstr(elt, new MethAddr("[]"), array, new Operand[] { index }, null));         // elt = a[index]
        Operand value = build(opElementAsgnNode.getValueNode(), s);                                       // Load 'value'
        String  operation = opElementAsgnNode.getOperatorName();
        s.addInstr(new CallInstr(elt, new MethAddr(operation), elt, new Operand[] { value }, null));      // elt = elt.OPERATION(value)
        // SSS: do not load the call result into 'elt' to eliminate the RAW dependency on the call
        // We already know what the result is going be .. we are just storing it back into the array
        Variable tmp = s.getNewTemporaryVariable();
        s.addInstr(new CallInstr(tmp, new MethAddr("[]="), array, new Operand[] { index, elt }, null));   // a[index] = elt
View Full Code Here

                } else {
                    return new OpElementOneArgAsgnNode(position, receiverNode, operatorName, array, valueNode);
                }
            }
        }
        return new OpElementAsgnNode(position, receiverNode, operatorName, argsNode, valueNode);
    }
View Full Code Here

TOP

Related Classes of org.jruby.ast.OpElementAsgnNode

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.