[fpc-pascal] FPC and WebAssembly

Michael Van Canneyt michael at freepascal.org
Fri Dec 24 15:46:58 CET 2021



On Fri, 24 Dec 2021, Ryan Joseph via fpc-pascal wrote:

>
>
>> On Dec 24, 2021, at 8:13 PM, Michael Van Canneyt via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>> 
>> Our little contribution to a Merry Christmas for everyone...
>
> Nice work. I have a hard time wrapping my head around this. Can you just write plain HTML to STDOUT using writeln and that's enough?

Write(ln) is a special call in Pascal.
In pas2js the handler for writeln is pluggable, and there is a unit that
installs a hook. The hook creates DIV's from the output, with special CSS.

The writeln() in WebAssembly works with imported file descriptor output 
calls from the hosting environment.

What the pas2js environment does is catch the stdout file descriptor 
and convert the strings to writeln() statements, which are then caught 
by the hook and displayed.

Michael.


More information about the fpc-pascal mailing list