-
Notifications
You must be signed in to change notification settings - Fork 63
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
Introduce BigInt type with toString method (no arithmetics yet) #175
base: main
Are you sure you want to change the base?
Conversation
compiler/builtins.js
Outdated
[ Opcodes.i32_mul ] | ||
wasm: (_, { builtin }) => [ | ||
...number(pageSize, Valtype.i32), | ||
[16,builtin('__Porffor_allocateBytes')] |
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.
Opcodes.call
?
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.
Oh yeah, don't know how that happened.
|
||
export const BigInt = function (value: number): any { | ||
let result: BigInt = Porffor.wasm` | ||
local.get ${value} |
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.
Doesn't this need to cast the argument to a number first?
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.
Yes, again, it's incomplete currently.
runner/repl.js
Outdated
@@ -117,6 +117,8 @@ const run = (source, _context, _filename, callback, run = true) => { | |||
|
|||
const replServer = repl.start({ prompt: '> ', eval: run }); | |||
|
|||
replServer.on('reset', () => prev = ""); |
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.
Unrelated?
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.
Yeah, it's unrelated but also a good change.
compiler/builtins.js
Outdated
// size | ||
[ Opcodes.local_get, 2 ], | ||
|
||
[ ...Opcodes.memory_copy, 0x00, 0x00 ], |
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.
Why introduce __Porffor_copyMemory
if it goes unused?
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.
Yeah that's supposed to be for memory allocation stuff and I kinda just accidentally built off of that.
Maybe I'm missing something as well, but are the memory changes really related to BigInts? |
Yeah, I just had them in the same branch more or less accidentally. |
Then, either this PR's title should be changed, or that functionality should be separated into another PR (the better choice imo) |
Okay, this was slightly annoying to do but I now re-organized this branch to only contain bigint stuff |
This pull request adds basic support for the BigInt type (bigint literals, toString). However, this pull request also contains unfinished changes to memory allocation so bugs might occur (specifically, static and dynamic allocation can collide).