Examples of CopyInstr


Examples of org.jruby.compiler.ir.instructions.CopyInstr

                break;
            case DASGNNODE: {
                DAsgnNode variable = (DAsgnNode) node;
                int depth = variable.getDepth();
                // SSS FIXME: Isn't it sufficient to use "getLocalVariable(variable.getName())"?
                s.addInstr(new CopyInstr(getScopeNDown(s, depth).getLocalVariable(variable.getName()), v));
                break;
            }
            case GLOBALASGNNODE:
                s.addInstr(new PutGlobalVarInstr(((GlobalAsgnNode)node).getName(), v));
                break;
            case INSTASGNNODE:
                // NOTE: if 's' happens to the a class, this is effectively an assignment of a class instance variable
                s.addInstr(new PutFieldInstr(getSelf(s), ((InstAsgnNode)node).getName(), v));
                break;
            case LOCALASGNNODE: {
                LocalAsgnNode localVariable = (LocalAsgnNode) node;
                int depth = localVariable.getDepth();
                // SSS FIXME: Isn't it sufficient to use "getLocalVariable(variable.getName())"?
                s.addInstr(new CopyInstr(getScopeNDown(s, depth).getLocalVariable(localVariable.getName()), v));
                break;
            }
            case MULTIPLEASGNNODE:
                buildMultipleAsgnAssignment((MultipleAsgnNode) node, s, v);
                break;
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

            return BooleanLiteral.FALSE;
        } else {
            Variable ret = m.getNewTemporaryVariable();
            Label    l   = m.getNewLabel();
            Operand  v1  = build(andNode.getFirstNode(), m);
            m.addInstr(new CopyInstr(ret, BooleanLiteral.FALSE));
            m.addInstr(new BEQInstr(v1, BooleanLiteral.FALSE, l));
            Operand  v2  = build(andNode.getSecondNode(), m);
            m.addInstr(new CopyInstr(ret, v2));
            m.addInstr(new LABEL_Instr(l));
            return ret;
        }
    }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

               if (bodyValue instanceof BreakResult) {
                   BreakResult br = (BreakResult)bodyValue;
                   bodyValue = br._result;
                   tgt = br._jumpTarget;
               }
               m.addInstr(new CopyInstr(result, bodyValue));
               m.addInstr(new JumpInstr(tgt));
            }
        }

        // close it out
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

        // Protected region code
        m.addInstr(new LABEL_Instr(rBeginLabel));
        m.addInstr(new ExceptionRegionStartMarkerInstr(rBeginLabel, rEndLabel, rescueLabels));
        Object v1 = protectedCode.run(protectedCodeArgs); // YIELD: Run the protected code block
        m.addInstr(new CopyInstr(rv, (Operand)v1));
        m.addInstr(new JumpInstr(rEndLabel));
        m.addInstr(new ExceptionRegionEndMarkerInstr());

        // Rescue code
        Label rbLabel = m.getNewLabel();
        rescueLabels.add(rbLabel);
        m.addInstr(new LABEL_Instr(rbLabel));
        Object v2 = rescueBlock.run(rescueBlockArgs); // YIELD: Run the protected code block
        if (v2 != null) m.addInstr(new CopyInstr(rv, (Operand)v1));

        // End
        m.addInstr(new LABEL_Instr(rEndLabel));

        return rv;
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

                }
            } else {
                Operand def = buildGetDefinition(node, m);
                m.addInstr(new BEQInstr(def, Nil.NIL, failLabel));
            }
            m.addInstr(new CopyInstr(rv, new StringLiteral(type)));
            m.addInstr(new JumpInstr(doneLabel));
            m.addInstr(new LABEL_Instr(failLabel));
            m.addInstr(new CopyInstr(rv, Nil.NIL));
            m.addInstr(new LABEL_Instr(doneLabel));
            return rv;
        }
    }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

    private void buildDefinitionCheck(IRScope s, Variable tmpVar, String definedReturnValue) {
        Label undefLabel = s.getNewLabel();
        Label defLabel   = s.getNewLabel();
        s.addInstr(new BEQInstr(tmpVar, BooleanLiteral.FALSE, undefLabel));
        s.addInstr(new CopyInstr(tmpVar, new StringLiteral(definedReturnValue)));
        s.addInstr(new JumpInstr(defLabel));
        s.addInstr(new LABEL_Instr(undefLabel));
        s.addInstr(new CopyInstr(tmpVar, Nil.NIL));
        s.addInstr(new LABEL_Instr(defLabel));
    }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

                Label defLabel   = s.getNewLabel();
                StringLiteral mName = new StringLiteral(((FCallNode)node).getName());
                Instr callInstr  = new JRubyImplCallInstr(tmpVar, new MethAddr("isMethodBound"), tmpVar, new Operand[]{mName, BooleanLiteral.FALSE});
                s.addInstr(callInstr);
                s.addInstr(new BEQInstr(tmpVar, BooleanLiteral.FALSE, undefLabel));
                s.addInstr(new CopyInstr(tmpVar, buildGetArgumentDefinition(((FCallNode) node).getArgsNode(), s, "method")));
                s.addInstr(new JumpInstr(defLabel));
                s.addInstr(new LABEL_Instr(undefLabel));
                s.addInstr(new CopyInstr(tmpVar, Nil.NIL));
                s.addInstr(new LABEL_Instr(defLabel));
                return tmpVar;
            }
            case COLON3NODE:
            case COLON2NODE:
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

        // assignments to block variables within a block.  As far as the IR is concerned,
        // this is just a simple copy
        int depth = dasgnNode.getDepth();
        // SSS FIXME: Isn't it sufficient to use "getLocalVariable(variable.getName())"?
        Variable arg = getScopeNDown(s, depth).getLocalVariable(dasgnNode.getName());
        s.addInstr(new CopyInstr(arg, build(dasgnNode.getValueNode(), s)));
        return arg;
    }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

                if (thenResult instanceof BreakResult) {
                    BreakResult br = (BreakResult)thenResult;
                    thenResult = br._result;
                    tgt = br._jumpTarget;
                }
                s.addInstr(new CopyInstr(result, thenResult));
                s.addInstr(new JumpInstr(tgt));
            }
            else {
                thenUnil = true;
            }
        }
        else {
            thenNull = true;
            s.addInstr(new CopyInstr(result, Nil.NIL));
            s.addInstr(new JumpInstr(doneLabel));
        }

        // Build the else part of the if-statement
        s.addInstr(new LABEL_Instr(falseLabel));
        if (ifNode.getElseBody() != null) {
            Operand elseResult = build(ifNode.getElseBody(), s);
            // elseResult can be U_NIL if then-body ended with a return!
            if (elseResult != U_NIL) {
                s.addInstr(new CopyInstr(result, elseResult));
            }
            else {
                elseUnil = true;
            }
        }
        else {
            elseNull = true;
            s.addInstr(new CopyInstr(result, Nil.NIL));
        }

        if (thenNull && elseNull) {
            return Nil.NIL;
        }
View Full Code Here

Examples of org.jruby.compiler.ir.instructions.CopyInstr

        return new StringLiteral(literalNode.getName());
    }

    public Operand buildLocalAsgn(LocalAsgnNode localAsgnNode, IRScope s) {
        Operand value = build(localAsgnNode.getValueNode(), s);
        s.addInstr(new CopyInstr(s.getLocalVariable(localAsgnNode.getName()), value));

        return value;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.