-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
pointerof lib external #5398
pointerof lib external #5398
Conversation
@ysbaddaden can you test this PR with your original usecase? |
Could you add a spec that:
|
0d87d4b
to
f92b3b0
Compare
updated. found one can test c code interaction, so use that |
y = ptr.value | ||
|
||
x + y | ||
), &.to_i.should eq(11)) |
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.
I'd prefer this spec to be more robust: we should check the value of LibFoo.external_var
after setting it too. I think there should be a way to return multiple values from the test. Does returning a tuple work?
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.
Actually use a bool to coalesce the multiple tests.
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 check the value of LibFoo.external_var after setting it too
test does that:
ptr.value = 10
y = ptr.value
not understand
no way to test tuple. maybe you write test, i copy?
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.
It checks ptr.value
, but not LibFoo.external_var
.
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.
good point. updated
f92b3b0
to
9dc6a8b
Compare
Constants are initialized into the DATA and BSS sections, so the collector must mark from these roots, in addition to fiber stacks. Since we can't access the address of an extern, we rely on a small C helper script to access some linker symbols (`__data_start`, `__bss_start` and `_end`).
fixes #4845
first pr so maybe not good. tried with libc environ, worked.
implement mostly by copy other code. LibType has
add_var
for externals with primitive "external_var_get". so for pointerof calllookup_var
ifpointerof(LibType.var)
. only if looks like that, not if has args or block or named args.codegen not sure. in semantic bind to var, which stored in
dependencies
. only one dependency, so that dependency is the external.codegen_primitive_external_var_get
has code for get pointer of external. so use that, refactor a bit. callcheck_c_fun
not sure, i think thats if external var has fun type, but didn't try. but if works with regular vars already improvement over existing code.