public Operand buildTrue() { return manager.getTrue(); }
public Operand buildTrue(Node node, IRScope s) { return manager.getTrue(); }
public Operand buildTrue() { return manager.getTrue(); }
public Operand buildTrue(Node node, IRScope s) { return manager.getTrue(); }
private Operand flipLogical(IRScope scope, BooleanLiteral value) { return value.isTrue() ? scope.getManager().getFalse() : scope.getManager().getTrue(); }
private Operand flipLogical(IRScope scope, BooleanLiteral value) { return value.isTrue() ? scope.getManager().getFalse() : scope.getManager().getTrue(); }
private void outputExceptionCheck(Operand excType, Operand excObj, Label caughtLabel) { Variable eqqResult = addResultInstr(new RescueEQQInstr(createTemporaryVariable(), excType, excObj)); addInstr(createBranch(eqqResult, manager.getTrue(), caughtLabel)); }
private void outputExceptionCheck(IRScope s, Operand excType, Operand excObj, Label caughtLabel) { Variable eqqResult = s.getNewTemporaryVariable(); s.addInstr(new RescueEQQInstr(eqqResult, excType, excObj)); s.addInstr(BEQInstr.create(eqqResult, manager.getTrue(), caughtLabel)); }
private void outputExceptionCheck(IRScope s, Operand excType, Operand excObj, Label caughtLabel) { Variable eqqResult = s.getNewTemporaryVariable(); s.addInstr(new RescueEQQInstr(eqqResult, excType, excObj)); s.addInstr(BEQInstr.create(eqqResult, manager.getTrue(), caughtLabel)); }
private void outputExceptionCheck(Operand excType, Operand excObj, Label caughtLabel) { Variable eqqResult = addResultInstr(new RescueEQQInstr(createTemporaryVariable(), excType, excObj)); addInstr(createBranch(eqqResult, manager.getTrue(), caughtLabel)); }
public Operand buildOpElementAsgn(OpElementAsgnNode node) { // Translate "a[x] ||= n" --> "a[x] = n if !is_true(a[x])" if (node.isOr()) return buildOpElementAsgnWith(node, manager.getTrue()); // Translate "a[x] &&= n" --> "a[x] = n if is_true(a[x])" if (node.isAnd()) return buildOpElementAsgnWith(node, manager.getFalse()); // a[i] *= n, etc. anything that is not "a[i] &&= .. or a[i] ||= .." return buildOpElementAsgnWithMethod(node); }
public Operand buildOpElementAsgn(OpElementAsgnNode node) { // Translate "a[x] ||= n" --> "a[x] = n if !is_true(a[x])" if (node.isOr()) return buildOpElementAsgnWith(node, manager.getTrue()); // Translate "a[x] &&= n" --> "a[x] = n if is_true(a[x])" if (node.isAnd()) return buildOpElementAsgnWith(node, manager.getFalse()); // a[i] *= n, etc. anything that is not "a[i] &&= .. or a[i] ||= .." return buildOpElementAsgnWithMethod(node); }
public static Boolean decode(IRReaderDecoder d) { return d.decodeBoolean() ? d.getCurrentScope().getManager().getTrue() : d.getCurrentScope().getManager().getFalse(); }
public static Boolean decode(IRReaderDecoder d) { return d.decodeBoolean() ? d.getCurrentScope().getManager().getTrue() : d.getCurrentScope().getManager().getFalse(); }
public Operand buildOpElementAsgnWithOr(OpElementAsgnNode opElementAsgnNode, IRScope s) { Operand array = build(opElementAsgnNode.getReceiverNode(), s); Label l = s.getNewLabel(); Variable elt = s.getNewTemporaryVariable(); List<Operand> argList = setupCallArgs(opElementAsgnNode.getArgsNode(), s); s.addInstr(CallInstr.create(elt, new MethAddr("[]"), array, argList.toArray(new Operand[argList.size()]), null)); s.addInstr(BEQInstr.create(elt, manager.getTrue(), l)); Operand value = build(opElementAsgnNode.getValueNode(), s); argList.add(value); s.addInstr(CallInstr.create(elt, new MethAddr("[]="), array, argList.toArray(new Operand[argList.size()]), null)); s.addInstr(new CopyInstr(elt, value)); s.addInstr(new LabelInstr(l)); return elt; }
public Operand buildOpElementAsgnWithOr(OpElementAsgnNode opElementAsgnNode, IRScope s) { Operand array = build(opElementAsgnNode.getReceiverNode(), s); Label l = s.getNewLabel(); Variable elt = s.getNewTemporaryVariable(); List<Operand> argList = setupCallArgs(opElementAsgnNode.getArgsNode(), s); s.addInstr(CallInstr.create(elt, new MethAddr("[]"), array, argList.toArray(new Operand[argList.size()]), null)); s.addInstr(BEQInstr.create(elt, manager.getTrue(), l)); Operand value = build(opElementAsgnNode.getValueNode(), s); argList.add(value); s.addInstr(CallInstr.create(elt, new MethAddr("[]="), array, argList.toArray(new Operand[argList.size()]), null)); s.addInstr(new CopyInstr(elt, value)); s.addInstr(new LabelInstr(l)); return elt; }
public void buildVersionSpecificAssignment(Node node, IRScope s, Variable v) { switch (node.getNodeType()) { case MULTIPLEASGNNODE: { Operand valuesArg; MultipleAsgnNode childNode = (MultipleAsgnNode) node; if (childNode.getHeadNode() != null && ((ListNode)childNode.getHeadNode()).childNodes().size() > 0) { // Invoke to_ary on the operand only if it is not an array already Variable result = s.getNewTemporaryVariable(); s.addInstr(new ToAryInstr(result, v, manager.getTrue())); valuesArg = result; } else { s.addInstr(new EnsureRubyArrayInstr(v, v)); valuesArg = v; } buildMultipleAsgnAssignment(childNode, s, null, valuesArg); break; } default: throw new NotCompilableException("Can't build assignment node: " + node); } }
public Operand buildOr(final OrNode orNode) { // lazy evaluation opt. Don't bother building rhs of expr is lhs is unconditionally true. if (orNode.getFirstNode().getNodeType().alwaysTrue()) return build(orNode.getFirstNode()); // lazy evaluation opt. Eliminate conditional logic if we know lhs is always false. if (orNode.getFirstNode().getNodeType().alwaysFalse()) { build(orNode.getFirstNode()); // needs to be executed for potential side-effects return build(orNode.getSecondNode()); // but we return rhs for result. } Label endOfExprLabel = getNewLabel(); Operand left = build(orNode.getFirstNode()); Variable result = getValueInTemporaryVariable(left); addInstr(createBranch(left, manager.getTrue(), endOfExprLabel)); Operand right = build(orNode.getSecondNode()); addInstr(new CopyInstr(result, right)); addInstr(new LabelInstr(endOfExprLabel)); return result; }
public Operand buildOr(final OrNode orNode) { // lazy evaluation opt. Don't bother building rhs of expr is lhs is unconditionally true. if (orNode.getFirstNode().getNodeType().alwaysTrue()) return build(orNode.getFirstNode()); // lazy evaluation opt. Eliminate conditional logic if we know lhs is always false. if (orNode.getFirstNode().getNodeType().alwaysFalse()) { build(orNode.getFirstNode()); // needs to be executed for potential side-effects return build(orNode.getSecondNode()); // but we return rhs for result. } Label endOfExprLabel = getNewLabel(); Operand left = build(orNode.getFirstNode()); Variable result = getValueInTemporaryVariable(left); addInstr(createBranch(left, manager.getTrue(), endOfExprLabel)); Operand right = build(orNode.getSecondNode()); addInstr(new CopyInstr(result, right)); addInstr(new LabelInstr(endOfExprLabel)); return result; }
public Operand buildOr(final OrNode orNode, IRScope s) { if (orNode.getFirstNode().getNodeType().alwaysTrue()) { // build first node only and return true return build(orNode.getFirstNode(), s); } else if (orNode.getFirstNode().getNodeType().alwaysFalse()) { // build first node as non-expr and build second node build(orNode.getFirstNode(), s); return build(orNode.getSecondNode(), s); } else { Label l = s.getNewLabel(); Operand v1 = build(orNode.getFirstNode(), s); Variable ret = getValueInTemporaryVariable(s, v1); s.addInstr(BEQInstr.create(v1, manager.getTrue(), l)); Operand v2 = build(orNode.getSecondNode(), s); s.addInstr(new CopyInstr(ret, v2)); s.addInstr(new LabelInstr(l)); return ret; } }