Menu

scScript Intro 2

The screenshot below comes from a DEBUG version of scScript, compiled using the DEBUG option in its makefile. The image shows an expanded and scrolled *Output* pane. Both the mode line and *Output* header clearly indicate the Debug state and provide additional developer information.

Output window of Hello1.sc, showing bytecodes.

When in DEBUG mode, scScript can output parsed script sources (the AST in Lisp-like format) and their corresponding bytecodes on a line-by-line basis, showing exactly how it read and compiled the sources.

Here, the first executable line is Writeln(“Hello World!”). This is parsed as a Call to the 4th system function with one Input string, and generates three byteops. The first will Push the input string on the runtime stack, the second will Sys call the function (Writeln), and finally the third instruction will Pop the (unused) result returned by Writeln off the stack.

The leading underscore in (_Call 4 (Input...)) indicates its (returned) result will be ignored, hence the Pop1 on line 0003 to get rid of the value the called function returns on the run stack.