NetRPG
NetRPG copied to clipboard
Internal APIs need passby check
Due to some fairly poor design on my part, we need a way to define an internal functions (BIFs, system APIs) pass type, e.g. by value/const or by reference.
It's different for user defined features because the VM handles whether it's a value or reference (at runtime):
- Handles passing by ref or value here (no typecheck): https://github.com/worksofbarry/NetRPG/blob/master/NetRPG/Language/Reader.cs#L1127
- Handles converting to/from ref (kind of type check?): https://github.com/worksofbarry/NetRPG/blob/master/NetRPG/Runtime/VM.cs#L169
Moral of the story is that Reader.cs somehow needs to know all the internal functions and their reference types in order to construct a correct bytecode, otherwise we may be stuck writing all internal functions as pass by reference only (and I don't think there are any BIFs that have that)
- https://github.com/worksofbarry/NetRPG/blob/master/NetRPG/Language/Reader.cs#L1076
- https://github.com/worksofbarry/NetRPG/blob/master/NetRPG/Language/Reader.cs#L1122
It's possible that each internal API can handle this situation actually.