PLAIN – Events

Events have so far only been a mechanism in the high level language, but I want to support it in the assembly. Events are as mentioned return conditions. We create functions with multiple exit paths where each exit is a “return” with its own event code and separate list of return parameters. To enable this we need a “Raise” statement, but we also need a “Event” to catch this in the calling code.

Func MyFunc
            Raise MyFunc2

Func MyFunc2
            Raise Error
Event Error
            // Default processing
Call MyFunc
Event Error
            // Overrides error processing

In this example we call “MyFunc” that Raise MyFunc2 that again Raise Error. The returning event will in this case be Error. Raise behaves like a Call, but do not create a return entry on the stack. A call creates a stack return entry causing processing to continue with the next instruction – raise preserve the existing stack entry.

If a function reaches End without raising an event that is the same as “Raise Continue” that can be processed with “Event Continue”. The Event statement in the function declare the event and its parameters.

Notice that while Call and Raise are actual assembly instructions, Func, Event and End are syntax needed by the assembler only. Need to dig into how I detect Events thought … 

At this point I need to write my little VM to consolidate the design concept …

Leave a Reply