[DGD] happycode in DGD
Raymond Jennings
shentino at gmail.com
Sat Sep 7 01:55:49 CEST 2013
thanks to an enlightening chitchat with aidil, I think I have a basic
gameplan for implmeenting happycode in DGD
First off, each happycode snippet is compiled on the spot along with the
rest of the source code it is with.
Second, happycode snippets are split off into their own heavyweight objects
after being morphed into bytecode for the vm.
Third, code in the defining object that emits function pointers is tagged
with a reference to the happycode object in question.
Fourth, function pointers use that tag to know which happycode object to
execute when they are referenced.
Fifth, happycode objects are garbage collected similiarly to kfuns, and
automatically nuked when they are proven to be orphaned.
Sixth, destructing a source object also nils out any happycode objects
built from it.
Seventh, it is an error to recompile an object in such a way that happycode
objects refering to it lose track of variables. So if you have happycode
refering to object scope variables, you can't remove those vars in the new
program.
Eighth, new happycode objects are generated as needed each time a source
object is recompiled. I decided to avoid the entire conhjflict between
closures and recompiling by "freezing" the bytecode inside the happycode
object when it's compiled. So happycode never recompiles. I tjust floats
until it becomes unreferenced.
Basically, a happycode object is like a clone of its source object, and has
references to both the master object whose code defined it, but also the
normal object whose data it may have a reference on.
I still need to learn how to parse happycode, but so far I think I have a
good plan. Comments appreciated.
More information about the DGD
mailing list