[Gambas-user] Are "On ... Gosub" implemented with a jump table?
Tobias Boege
taboege at gmail.com
Wed May 22 10:10:00 CEST 2019
On Tue, 21 May 2019, Cedron Dawg wrote:
> In other words are they efficient or syntax sugar?
>
If you compile a project with `gbc3 -av` you recompile all classes and
do it verbosely. This will emit the generated bytecode in plain text.
There you can see that the "On" part of the instruction compiles to an
inline jump table. That's as far as I looked.
Next step would be to go into main/gbx/gbx_exec_loop.c and trace the
implementation of that instruction from the big bytecode jump_table,
if you *really* care about what it does exactly.
Anyway, it's not syntactic sugar. It's a dedicated instruction.
Interestingly, in the bytecode, the ON part seems to do the jumping
and the GOSUB part afterwards just handles the "fall-through" case.
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list