Sign in Join

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

Mailing lists / fpc-pascal / 2023-10

fpc webassembly and node

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Unknown author

Hi guys,

i have a question concerning webassembly,
please let me know if this is the wrong list.

is it possible to use classes and compile to webassemly, the following code is working well but wen i uncomment the constructor line
the code can be compiled but will not run anymore

RuntimeError: memory access out of bounds

is the result

i compile with the following command

ppcrosswasm32 -Twasi -oadd.wasm add.pas

------------
library add;
{$mode objfpc}
type
   TConnection = class
   private
     n : Integer;
   public
     constructor Create;
   end;
constructor TConnection.Create;
begin
   n := 4711;
end;
function add( a1, a2 : Integer ) : Integer;
var
   connection : TConnection;
begin
   //connection := TConnection.Create;
   Result := 4711;
end;
exports
   add name 'add';
end.

Reply by email

Michael Van Canneyt
to Unknown author

Hello,

Either list is fine.

This should compile and work.

I'm using webassembly and classes quite a lot, even with threading, so I see no reason why this simple code should not run.

How did you start the webassembly ?
How much memory did you provide to the webassembly ? Did you use pas2js to start it ? What browser did you test ?

Michael.

k1 wrote 52 lines
Hi guys, i have a question concerning webassembly, please let me know if this is the wrong list. is it possible to use classes and compile to webassemly, the following code is working well but wen i uncomment the constructor line the code can be compiled but will not run anymore RuntimeError: memory access out of bounds is the result i compile with the following command ppcrosswasm32 -Twasi -oadd.wasm add.pas ------------ library add; {$mode objfpc} type TConnection = class private n : Integer; public constructor Create; end; constructor TConnection.Create; begin n := 4711; end; function add( a1, a2 : Integer ) : Integer; var connection : TConnection; begin //connection := TConnection.Create; Result := 4711; end; exports add name 'add'; end. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Michael Van Canneyt
to Michael Van Canneyt
Michael Van Canneyt wrote 13 lines
Hello, Either list is fine. This should compile and work. I'm using webassembly and classes quite a lot, even with threading, so I see no reason why this simple code should not run. How did you start the webassembly ? How much memory did you provide to the webassembly ? Did you use pas2js to start it ? What browser did you test ?

Disregard the last question, it's node of course, so the V8 engine.

Michael.

Reply by email