Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-12

FPC and WebAssembly

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

I'm glad to anncounce that FPC now covers working with webassembly in the browser.

Because pictures say more than a thousand words, 3 demos:

A modest "hello, world" variation:

https://www.freepascal.org/~michael/pas2js-demos/wasienv/simple/

A (limited) terminal emulation:

https://www.freepascal.org/~michael/pas2js-demos/wasienv/terminal/

And yes, we can do graphics too:

https://www.freepascal.org/~michael/pas2js-demos/wasienv/terminal/

In all 3 cases:
- The webassembly program was created with the FPC webassembly target.

- The hosting environment is created using pas2js.

This is just initial hosting support, there is lots of work to be done.

The webassembly compiler works very well, and is integrated in the compiler testsuite.

More info can be found in:
https://wiki.freepascal.org/WebAssembly/Compiler
https://wiki.freepascal.org/WebAssembly/Roadmap

Our little contribution to a Merry Christmas for everyone...

Michael.

Reply by email

Unknown author
to Michael Van Canneyt

Congratulations!

and

Frohe Weihnachten

Markus

Earlier message 30 lines
--- original message --- On December 24, 2021, 2:16 PM GMT+1 wrote: >> And yes, we can do graphics too: >> >> https://www.freepascal.org/~michael/pas2js-demos/wasienv/terminal/ > That should obviously be: > https://www.freepascal.org/~michael/pas2js-demos/wasienv/canvas/ > My apologies for the mistake. > Michael. > _______________________________________________ > fpc-pascal maillist - > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal --- end of original message ---

Reply by email

Michael Van Canneyt
to Ryan Joseph
Ryan Joseph wrote 7 lines
> On Dec 24, 2021, at 8:13 PM, Michael Van Canneyt via fpc-pascal 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.

Reply by email

Tarnyko
to Michael Van Canneyt: That should obviously be: https://www.freepascal.org/~michael/pas2js-demos/wasienv/canvas/

Thanks, I was specifically looking for this demo!

Happy new year, and kudos for the great work.

Regards; Tarnyko

Michael Van Canneyt wrote 18 lines
> And yes, we can do graphics too: > > https://www.freepascal.org/~michael/pas2js-demos/wasienv/terminal/ That should obviously be: https://www.freepascal.org/~michael/pas2js-demos/wasienv/canvas/ My apologies for the mistake. Michael. -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

Reply by email