Skip to content

Commit f66d751

Browse files
committed
[Truffle] Implement just enough of Rational and Complex for language specs.
1 parent 5ea7533 commit f66d751

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,14 @@ private RubyNode translateCPath(SourceSection sourceSection, org.jruby.ast.Colon
658658
}
659659
}
660660

661+
@Override
662+
public RubyNode visitComplexNode(ComplexNode node) {
663+
final SourceSection sourceSection = translate(node.getPosition());
664+
665+
// TODO: implement Complex
666+
return node.getNumber().accept(this);
667+
}
668+
661669
@Override
662670
public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
663671
final SourceSection sourceSection = translate(node.getPosition());
@@ -1834,6 +1842,14 @@ public RubyNode visitPostExeNode(PostExeNode node) {
18341842
return node.getBodyNode().accept(this);
18351843
}
18361844

1845+
@Override
1846+
public RubyNode visitRationalNode(RationalNode node) {
1847+
final SourceSection sourceSection = translate(node.getPosition());
1848+
1849+
// TODO: implement Rational
1850+
return new FixnumLiteralNode.LongFixnumLiteralNode(context, sourceSection, node.getNumerator());
1851+
}
1852+
18371853
@Override
18381854
public RubyNode visitRedoNode(org.jruby.ast.RedoNode node) {
18391855
return new RedoNode(context, translate(node.getPosition()));

core/src/main/ruby/jruby/truffle/core/kernel.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ def puts(*args)
3333
end
3434
end
3535

36+
# Minimal support for language specs
37+
def Rational(numerator, denominator)
38+
numerator
39+
end
40+
41+
def Complex(real, imaginary)
42+
imaginary
43+
end
44+
3645
end
3746

3847
def STDOUT.internal_encoding

spec/truffle/tags/language/numbers_tags.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)