nsensfel / tonkadur

Narrative scripting/programming tool. Write stories in your favorite editor using a feature-rich language, compile them into a very small and simple language to easily integrate them into your game.
https://tonkadur.of.tacticians.online
Apache License 2.0
2 stars 0 forks source link

No memory modification through computations should also hold in Wyrd (currently violated by 'new' computation) #37

Closed nsensfel closed 2 years ago

nsensfel commented 2 years ago

Similarly to https://github.com/nsensfel/tonkadur/issues/18, the new computation in Wyrd should be converted to an instruction. This makes the interpreter much simpler to implement when not relying on global variable or class members, and is just better design overall.

nsensfel commented 2 years ago

Possible solution: next_allocable_address is a computation returning an unused address. Multiple calls to this computation may yield the same result, as long as the address is still unused. (set! reg0 (new <TYPE>)) is then:

(set! reg0 (next_allocable_address))
(initialize! reg0 <TYPE>)
nsensfel commented 2 years ago

Done in https://github.com/nsensfel/tonkadur/commit/bd5fd411691410d2ddb37f108810353b725eb0b1.