Comments (12)
Interesting. I wonder if we need another cast in the middle there to explicitly truncate it down to 32 bits. I can't repro this locally, but I can explain what's happening if that will help you look into this. Wren stores all values as a union of a Nan-tagged double and a 64-bit uint. The .bits
gets the value as a 64-bit uint. The & ~(SIGN_BIT | QNAN)
masks off all of the Nan stuff, leaving a 32-bit pointer stored in the rightmost bits of the 32-bit uint. Then we cast that to a pointer.
Can you try changing that line to:
#define AS_OBJ(value) ((Obj*)(uint32_t)((value).bits & ~(SIGN_BIT | QNAN)))
And see if that helps?
from wren.
it worked, but I also had to modify wren_value.h:L667, change 64 to 32.:
return (Value)(SIGN_BIT | QNAN | (uint32_t)(obj));
on another (not serious) point, I also hade to remove -fPIC
since ยซ all code is position independent ยป.
from wren.
FWIW removing -Werror also makes it compile just fine (passes all tests).
from wren.
I may still need to do a fix here, but I just landed a bunch of patches to make Wren compile as C++. That involves changing the value representation, so this might be fixed. Or, who knows, made worse.
Any chance you could retest?
Thanks!
from wren.
it does not compile with g++, I get src/main.c:183:3: sorry, unimplemented: non-trivial designated initializers not supported
.
If had to make a few changes to to make it compile:
change the C++ standard to C++11 and change the initialization of "config" to:
WrenConfiguration config { // no equals sign
reallocateFn: NULL, // field in the same order as the struct
// Since we're running in a standalone process, be generous with memory.
initialHeapSize: 1024 * 1024 * 100,
minHeapSize: 0,
heapGrowthPercent: 0
};
Also I know how to fix what causes the segfault of my first post, but I have no idea why. Just print the value of pinned
in wrapPinObj
:
void wrenPinObj(WrenVM* vm, Obj* obj, WrenPinnedObj* pinned)
{
printf("%p\n", pinned); // <-- remove this line and it will segfault
pinned->obj = obj;
pinned->previous = vm->pinned;
vm->pinned = pinned;
}
from wren.
I'd like to not require C++11 (although, of course, it should allow that). I just went ahead and removed that initializer and initialized the struct manually. Does that help?
from wren.
it does to compile in C++98 now.
About the casting in AS_OBJ
and wrenObjectToValue
, maybe using uintptr_t
could help.
from wren.
it does to compile in C++98 now.
\o/
About the casting in AS_OBJ and wrenObjectToValue, maybe using uintptr_t could help.
Maybe, I think just truncating works too. I'll try to get a fix in soon for that.
from wren.
uintptr_t
would help because it should equivalent to uint32_t on x86 and to uint64_t on x86_64. No need to another #if/#else
to avoid the cast [...] of different size
.
ps: I read the standard and it says that uintptr_t
is optional, but so is uintN_t
.
from wren.
OK, I think I got it. If not, let me know.
from wren.
compiled perfectly (C & C++) \o/
from wren.
๐
from wren.
Related Issues (20)
- List.count returns a negative value for huge lists HOT 2
- [Feature] Pipe Operator for Function Calls HOT 53
- [RFC] Object.responds(_) method HOT 10
- [RFC] Add routines for degrees/radians conversions HOT 21
- [RFC] Adding a `Tuple` with language support HOT 11
- [RFC] Adding `const` versions of `Object`s. HOT 9
- Class reflection for embedding HOT 3
- [RFC] `veery` lang transpiler to `wren` lang HOT 3
- [RFC] Object method message passing syntax HOT 28
- [RFC] Add `static Object.typeOf(_)` (and deprecate `Object.type` ?) HOT 9
- How can i stop wren script running? HOT 3
- Calling wren method handle from inside a bound foreign method body HOT 5
- Whitespace bugs? HOT 4
- Serialize (suspended) fibers or serialize the vm HOT 4
- wren_debug.c should use vm->config.writeFn instead of printf HOT 1
- Should we document this aspect of for loop control variable behavior?
- How do I pass a foreign object to a function call? HOT 3
- is Wren dead? HOT 2
- Where causes code to be called twice HOT 3
- How to return other foreign class obj from a foreign class ? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wren.