Expand/Shrink

opCallOnceYeNot

Syntax:
#ilASM{ jmp :!opCallOnceYeNot
        ...
      }
Description: Ensures a builtins/VM component has compiled correctly.

Suppose you have a file my_include.e (normal, hll) as follows:

puts(1,"Hi\n")
global procedure bye()
    puts(1,"Bye\n")
end procedure
puts(1,"There\n")

And a little test program:

include my_include.e
bye()

Now, obviously you would expect the "Hi" (and "There") to be displayed before the "Bye".
Each file generates a hidden top-level subroutine, which the compiler invokes, but only when it needs to.
There are hundreds of files in builtins\VM so the last thing we want is to call hundreds of empty top-level subroutines that do nothing, when each and every program starts. Now while I can optimise that away (and have), equally we don’t want each and every program to be invoking lots of such piddly little routines from builtins\VM, and this is the mechanism I use to stop myself accidentally adding (more of) them.

The definition of :!opCallOnceYeNot is simply just an int3 statement, and there is not much point making that a more human-readable error with a source code line number, since jumping to that definition is not actually very helpful, and jumping to the point of cause, especially for an auto-include, wouldn’t be either.

An example of something that can trigger this error is adding say

constant something = somefunc()

to a builtins/VM source file (above the jmp). Of course that sort of thing is fine if really needed, in which case you probably want to replace the jmp :!opCallOnceYeNot with

#ilASM{ jmp :fin
        ...
        ::fin
      }

However, in most cases [in builtins/VM] it is probably better to defer such initialisation until it is actually needed, and it should be no big deal to make that private "constant something" into a private variable instead, given that it does not actually help for the compiler to re-check you are not accidentally modifying it, every single time it runs, from now until the end of time.
Defined in: builtins\VM\pUnassigned.e