2
0

libadd.pp 590 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // ppcrosswasm32 -Twasi -oadd.wasm add.pas
  2. library libadd;
  3. {$mode objfpc}
  4. type
  5. TConnection = class
  6. private
  7. n : Integer;
  8. public
  9. constructor Create;
  10. function DoAdd(a1,a2 : integer) : Integer;
  11. end;
  12. constructor TConnection.Create;
  13. begin
  14. n := 4711;
  15. end;
  16. function TConnection.Doadd( a1, a2 : Integer ) : Integer;
  17. begin
  18. result:=a1+a2+n;
  19. end;
  20. function add( a1, a2 : Integer ) : Integer;
  21. var
  22. connection : TConnection;
  23. begin
  24. connection := TConnection.Create;
  25. Result := connection.DoAdd(a1,a2);
  26. connection.free;
  27. end;
  28. exports
  29. add name 'add';
  30. end.