Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e1cf5f6f7b4e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 79d9a4d54948
Choose a head ref
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Oct 29, 2014

  1. Copy the full SHA
    3cbf819 View commit details
  2. Copy the full SHA
    b251a22 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    79d9a4d View commit details
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ast/RationalNode.java
Original file line number Diff line number Diff line change
@@ -37,4 +37,8 @@ public List<Node> childNodes() {
public NodeType getNodeType() {
return NodeType.RATIONALNODE;
}

public long getNumerator() {
return numerator;
}
}
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -425,6 +425,7 @@ private Operand buildOperand(Node node, IRScope s) throws NotCompilableException
case ORNODE: return buildOr((OrNode) node, s);
case PREEXENODE: return buildPreExe((PreExeNode) node, s);
case POSTEXENODE: return buildPostExe((PostExeNode) node, s);
case RATIONALNODE: return buildRational((RationalNode) node, s);
case REDONODE: return buildRedo(node, s);
case REGEXPNODE: return buildRegexp((RegexpNode) node, s);
case RESCUEBODYNODE:
@@ -2988,6 +2989,10 @@ public Operand buildPreExe(PreExeNode preExeNode, IRScope s) {
return manager.getNil();
}

public Operand buildRational(RationalNode rationalNode, IRScope s) {
return new Rational(rationalNode.getNumerator());
}

public Operand buildRedo(Node node, IRScope s) {
// If in a loop, a redo is a jump to the beginning of the loop.
// If not, for closures, a redo is a jump to the beginning of the closure.
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/ir/IREvalScript.java
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.log.Logger;
@@ -85,15 +84,15 @@ public boolean isModuleOrInstanceEval() {
/* Record a begin block -- not all scope implementations can handle them */
@Override
public void recordBeginBlock(IRClosure beginBlockClosure) {
if (beginBlocks == null) beginBlocks = new ArrayList<IRClosure>();
if (beginBlocks == null) beginBlocks = new ArrayList<>();
beginBlockClosure.setBeginEndBlock();
beginBlocks.add(beginBlockClosure);
}

/* Record an end block -- not all scope implementations can handle them */
@Override
public void recordEndBlock(IRClosure endBlockClosure) {
if (endBlocks == null) endBlocks = new ArrayList<IRClosure>();
if (endBlocks == null) endBlocks = new ArrayList<>();
endBlockClosure.setBeginEndBlock();
endBlocks.add(endBlockClosure);
}
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/IRVisitor.java
Original file line number Diff line number Diff line change
@@ -156,6 +156,7 @@ private void error(Object object) {
public void NthRef(NthRef nthref) { error(nthref); }
public void ObjectClass(ObjectClass objectclass) { error(objectclass); }
public void Range(Range range) { error(range); }
public void Rational(Rational rational) { error(rational); }
public void Regexp(Regexp regexp) { error(regexp); }
public void ScopeModule(ScopeModule scopemodule) { error(scopemodule); }
public void Self(Self self) { error(self); }
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/ir/operands/Float.java
Original file line number Diff line number Diff line change
@@ -12,11 +12,6 @@ public Float(double value) {
this.value = value;
}

@Override
public boolean hasKnownValue() {
return true;
}

@Override
public Object createCacheObject(ThreadContext context) {
return context.runtime.newFloat(value);
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/operands/OperandType.java
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ public enum OperandType {
NTH_REF((byte) '1'),
OBJECT_CLASS((byte) 'O'),
RANGE((byte) '.'),
RATIONAL((byte) 'r'),
REGEXP((byte) '/'),
SCOPE_MODULE((byte) '_'),
SELF((byte) 'S'),
36 changes: 36 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Rational.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.runtime.ThreadContext;

/**
* Literal Rational number.
*/
public class Rational extends ImmutableLiteral {
private long numerator;

public Rational(long numerator) {
super(OperandType.ARRAY);

this.numerator = numerator;
}

@Override
public Object createCacheObject(ThreadContext context) {
return context.runtime.newRational(numerator, 1);
}

@Override
public String toString() {
return "Rational:" + numerator + "/1";
}

@Override
public void visit(IRVisitor visitor) {
visitor.Rational(this);
}

public double getNumerator() {
return numerator;
}
}