-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Small_Integer and Big_Integer types #7636
Merge Small_Integer and Big_Integer types #7636
Conversation
Test.specify "should be able to invoke methods on Integer via static method call" <| | ||
Integer.+ 1 2 . should_equal 3 | ||
Integer.+ 1 2.5 . should_equal 3.5 | ||
Test.expect_panic_with (Integer.+ 1.5 1) Type_Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This results in Type_Error
because self is 1.5 which is Decimal, and not Integer
70cd83f
to
6adb207
Compare
@Specialization | ||
boolean doDouble(EnsoBigInteger self, double that) { | ||
return BigIntegerOps.toDouble(self.getValue()) < that; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we rename these to avoid overloads?
I'm not sure if this has any implications for the compilation, probably no.
But still, it feels cleaner and more consistent to have names be unique - AFAIK in other places all of our specializations do have unique names.
...ntime/src/main/java/org/enso/interpreter/node/expression/builtin/number/integer/ModNode.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'd like to see a test as mentioned in one of the comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually OK. If tests are passing and benchmarks are sane, then let's integrate!
|
||
@BuiltinMethod(type = "Small_Integer", name = "abs", description = "Absolute value of a number") | ||
@BuiltinMethod(type = "Integer", name = "abs", description = "Absolute value of a number") | ||
public abstract class AbsNode extends Node { | ||
private @Child ToEnsoNumberNode toEnsoNumberNode = ToEnsoNumberNode.create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make ToEnsoNumberNode
inlineable. Otherwise all integer nodes will have two nodes - the main one and the ToEnsoNumberNode
one.
import org.enso.interpreter.runtime.error.PanicException; | ||
import org.enso.interpreter.runtime.library.dispatch.TypesLibrary; | ||
|
||
public final class IntegerUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider merging BigIntegerOps
and IntegerUtils
into a single class.
} | ||
|
||
@TruffleBoundary | ||
static PanicException throwTypeErrorIfNotInt(Object self, Node node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this doesn't have to be behind @TruffleBoundary
- all of the operations can run on fast path. But maybe such errors are infrequent and we don't need them to run at full speed.
Engine benchmarks scheduled at https://github.com/enso-org/enso/actions/runs/6118815952, stdlib benches at https://github.com/enso-org/enso/actions/runs/6118827261
|
Benchmark results are stable. Merging .... |
Closes #6959
Pull Request Description
Merge
Small_Integer
andBig_Integer
types into a singleInteger
type. BothSmall_Integer
andBig_Integer
used to be the only internal types that were not visible in Enso, i.e., typingSmall_Integer
in REPL resulted in an identifier not found error.Important Notes
Integer
as static ones, e.g.,Integer.+
,Integer.*
, etc.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,