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
Implement Kernel#exit #1972
Comments
sounds great @somedevfox. One other bit of implementation to help you along, since the argument to artichoke/artichoke-backend/src/extn/core/array/mruby.rs Lines 159 to 162 in acb5be8
|
This looks great @somedevfox. Feel free to get started working on this. If you have any questions, please reach out either in this ticket or on Discord. |
It looks like we'll need to do a fallible conversion to $ ruby -e 'exit(2**64 + 1)'
-e:1:in `exit': bignum too big to convert into `long' (RangeError)
from -e:1:in `<main>'
$ ruby -e 'exit(2**64)'
-e:1:in `exit': bignum too big to convert into `long' (RangeError)
from -e:1:in `<main>'
$ ruby -e 'exit(2**64-1)'
-e:1:in `exit': bignum too big to convert into `long' (RangeError)
from -e:1:in `<main>'
$ ruby -e 'exit(2**61)'
-e:1:in `exit': integer 2305843009213693952 too big to convert to `int' (RangeError)
from -e:1:in `<main>'
$ ruby -e 'exit(2**32)'
-e:1:in `exit': integer 4294967296 too big to convert to `int' (RangeError)
from -e:1:in `<main>'
$ ruby -e 'exit(2**31)'
-e:1:in `exit': integer 2147483648 too big to convert to `int' (RangeError)
from -e:1:in `<main>'
$ ruby -e 'exit(2**31-1)'
$ echo $?
255 |
hi @somedevfox, checking in here. Are you still working on this? |
Ah, yes, I am- One issue I ran into when I tried to implement #exit is that raising an exception would result in code after the raise being completely ignored. |
thanks for checking in @somedevfox no worries on the wait 😄 You'll want to check these places in the Ruby CLI entrypoint: Lines 133 to 147 in 4f03839
We'll probably have to check for The return value for the entrypoint will need to be tweaked to somehow return the exit code. |
if you're interested in adding a test for this behavior, you can check in the artichoke/ui-tests/tests/artichoke.rs Lines 32 to 35 in 4f03839
|
Hi @somedevfox, checking in here. Since its been a while I'm going to unassign this ticket from you. You're still free to work on it :) |
Kernel#exit
initiates a termination of application with a custom exit status (if set,status
argument is optional and it's default value istrue
) by raisingSystemExit
exception.Motivation behind method
ArtichokeRuby supports both native and wasm targets and for native, it's sometimes useful to have an ability to exit application in case of:
OneShot
and one of it's mods,OneShot: Fading Memory
, powered by MKXP Engine)Implementation
After implementing a method, it can be wired up to Artichoke like this:
artichoke/artichoke-backend/src/extn/core/kernel/mruby.rs
Lines 79 to 88 in 7bf3f03
artichoke/artichoke-backend/src/extn/core/kernel/trampoline.rs
Lines 22 to 31 in 7bf3f03
One should take
args
Value and convert it toi32
usingartichoke_backend::convert::implicitly_convert_to_int(interp, value)? as i32;
method.Implementation Notes
Method should be locked under a feature.
The text was updated successfully, but these errors were encountered: