-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I currently look at how we can support classes.
Example:
Assemblyscript
export class example {
constructor(private s: string) {}
public getString() { return this.s }
}
In JS:
const e = new exports.example('answer: 42')
console.log(e.getString()) // "answer: 42"
This in combination with #64 would allow some cool things!
To do that I would wrap the full class in a JS-Class that calls the correspondig function by runtime and loader.
FinalizationRegistry
I want to do the following to get full garbage collection (in a wrapper function for the classes):
const classPtr = new exports.Foo()
exports.__pin(classPtr)
const foo = Foo.wrap(classPtr)
// We only need one of these for all classes
const registry = new FinalizationRegistry(ptr => {
exports.__unpin(ptr)
});
registry.register(foo, classPtr);
This would allow full GarbageCollection for Browsers that support FinalizationRegistry
(see https://caniuse.com/mdn-javascript_builtins_finalizationregistry). Without FinalizationRegistry
I see no way to add this wrapping without memory leaks (any ideas?).
But in that case the developer can allways call __unpin
so I think there is nothing to worry about.
torch2424, munrocket and jerrygreentorch2424 and munrockettorch2424 and munrockettorch2424 and munrocket
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request