@live-codes/pascal-wasm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +501 -0
  2. package/README.md +278 -0
  3. package/THIRD-PARTY-NOTICES.md +48 -0
  4. package/assets/pas2js.wasm +0 -0
  5. package/assets/rtl/Rtl.BrowserLoadHelper.pas +179 -0
  6. package/assets/rtl/browserconsole.pas +190 -0
  7. package/assets/rtl/classes.pas +11371 -0
  8. package/assets/rtl/js.pas +2211 -0
  9. package/assets/rtl/manifest.json +19 -0
  10. package/assets/rtl/math.pas +903 -0
  11. package/assets/rtl/p2jsres.pp +334 -0
  12. package/assets/rtl/rtl.js +1563 -0
  13. package/assets/rtl/rtlconsts.pas +97 -0
  14. package/assets/rtl/simplelinkedlist.pas +152 -0
  15. package/assets/rtl/system.pas +1166 -0
  16. package/assets/rtl/sysutils.pas +8959 -0
  17. package/assets/rtl/types.pas +2296 -0
  18. package/assets/rtl/typinfo.pas +1680 -0
  19. package/assets/rtl/web.pas +3586 -0
  20. package/assets/rtl/weborworker.pas +2101 -0
  21. package/dist/pascal-wasm.iife.min.js +6 -0
  22. package/dist/pascal-wasm.iife.min.js.map +7 -0
  23. package/package.json +54 -0
  24. package/src/assets.js +119 -0
  25. package/src/compiler.js +142 -0
  26. package/src/config.js +24 -0
  27. package/src/iife.js +27 -0
  28. package/src/index.js +130 -0
  29. package/src/vendor/browser_wasi_shim/debug.js +1 -0
  30. package/src/vendor/browser_wasi_shim/fd.js +1 -0
  31. package/src/vendor/browser_wasi_shim/fs_mem.js +1 -0
  32. package/src/vendor/browser_wasi_shim/fs_opfs.js +1 -0
  33. package/src/vendor/browser_wasi_shim/index.js +1 -0
  34. package/src/vendor/browser_wasi_shim/strace.js +1 -0
  35. package/src/vendor/browser_wasi_shim/wasi.js +1 -0
  36. package/src/vendor/browser_wasi_shim/wasi_defs.js +1 -0
  37. package/types/index.d.ts +89 -0
@@ -0,0 +1,97 @@
1
+ {
2
+ This file is part of the Pas2JS run time library.
3
+ Copyright (c) 2017 by Mattias Gaertner
4
+
5
+ See the file COPYING.FPC, included in this distribution,
6
+ for details about the copyright.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
+
12
+ **********************************************************************}
13
+ {$IFNDEF FPC_DOTTEDUNITS}
14
+ unit RTLConsts;
15
+ {$ENDIF}
16
+
17
+ interface
18
+
19
+ Resourcestring
20
+ SArgumentMissing = 'Missing argument in format "%s"';
21
+ SInvalidFormat = 'Invalid format specifier : "%s"';
22
+ SInvalidArgIndex = 'Invalid argument index in format: "%s"';
23
+ SListCapacityError = 'List capacity (%s) exceeded.';
24
+ SListCountError = 'List count (%s) out of bounds.';
25
+ SMapKeyError = 'Key not found : %s';
26
+ SListIndexError = 'List index (%s) out of bounds';
27
+ SSortedListError = 'Operation not allowed on sorted list';
28
+ SDuplicateString = 'String list does not allow duplicates';
29
+ SDuplicateItem = 'ThreadList does not allow duplicates';
30
+ SErrFindNeedsSortedList = 'Cannot use find on unsorted list';
31
+
32
+ SInvalidName = 'Invalid component name: "%s"';
33
+ SInvalidBoolean = '"%s" is not a valid boolean.';
34
+ SDuplicateName = 'Duplicate component name: "%s"';
35
+
36
+ SErrInvalidDate = 'Invalid date: "%s"';
37
+ SErrInvalidTimeFormat = 'Invalid time format: "%s"';
38
+ SInvalidDateFormat = 'Invalid date format: "%s"';
39
+
40
+ SCantReadPropertyS = 'Cannot read property "%s"';
41
+ SCantWritePropertyS = 'Cannot write property "%s"';
42
+ SErrPropertyNotFound = 'Unknown property: "%s"';
43
+ SIndexedPropertyNeedsParams = 'Indexed property "%s" needs parameters';
44
+ SErrInvalidTypecast = 'Invalid class typecast';
45
+
46
+ SErrInvalidInteger = 'Invalid integer value: "%s"';
47
+ SErrInvalidFloat = 'Invalid floating-point value: "%s"';
48
+ SInvalidDateTime = 'Invalid date-time value: %s';
49
+ SInvalidCurrency = 'Invalid currency value: %s';
50
+ SErrInvalidDayOfWeek = '%d is not a valid day of the week';
51
+ SErrInvalidTimeStamp = 'Invalid date/timestamp : "%s"';
52
+ SErrInvalidDateWeek = '%d %d %d is not a valid dateweek';
53
+ SErrInvalidDayOfYear = 'Year %d does not have a day number %d';
54
+ SErrInvalidDateMonthWeek = 'Year %d, month %d, Week %d and day %d is not a valid date.';
55
+ SErrInvalidDayOfWeekInMonth = 'Year %d Month %d NDow %d DOW %d is not a valid date';
56
+ SInvalidJulianDate = '%f Julian cannot be represented as a DateTime';
57
+ SErrInvalidHourMinuteSecMsec = '%d:%d:%d.%d is not a valid time specification';
58
+
59
+ SInvalidGUID = '"%s" is not a valid GUID value';
60
+
61
+ SEmptyStreamIllegalReader = 'Illegal Nil stream for TReader constructor';
62
+ SInvalidPropertyValue = 'Invalid value for property';
63
+ SInvalidImage = 'Invalid stream format';
64
+ SUnknownProperty = 'Unknown property: "%s"';
65
+ SUnknownPropertyType = 'Unknown property type %s';
66
+ SAncestorNotFound = 'Ancestor class for "%s" not found.';
67
+ SUnsupportedPropertyVariantType = 'Unsupported property variant type %d';
68
+ SPropertyException = 'Error reading %s%s%s: %s';
69
+ SInvalidPropertyPath = 'Invalid property path';
70
+ SReadOnlyProperty = 'Property is read-only';
71
+ SClassNotFound = 'Class "%s" not found';
72
+
73
+ SEmptyStreamIllegalWriter = 'Illegal Nil stream for TWriter constructor';
74
+ SErrInvalidPropertyType = 'Invalid property type from streamed property: %d';
75
+ SParserExpected = 'Wrong token type: %s expected';
76
+ SParserInvalidFloat = 'Invalid floating point number: %s';
77
+ SParserInvalidInteger = 'Invalid integer number: %s';
78
+ SParserUnterminatedString = 'Unterminated string';
79
+ SParserWrongTokenType = 'Wrong token type: %s expected but %s found';
80
+ SParserWrongTokenSymbol = 'Wrong token symbol: %s expected but %s found';
81
+ SParserLocInfo = ' (at %d,%d, stream offset %.8x)';
82
+ SParserUnterminatedBinValue = 'Unterminated byte value';
83
+ SParserInvalidProperty = 'Invalid property';
84
+ SRangeError = 'Range error';
85
+
86
+ SParamIsNegative = 'Parameter "%s" cannot be negative.';
87
+
88
+ SErrNoStreaming = 'Failed to initialize component class "%s": No streaming method available.';
89
+ SResNotFound = 'Resource %s not found';
90
+ SErrResourceStreamNoWrite = 'Cannot write to resource stream';
91
+ SErrResourceNotBase64 = 'Resource %s is not base64 encoded';
92
+ SErrUnknownResourceEncoding = 'Unknown encoding for resource: "%s"';
93
+
94
+ implementation
95
+
96
+ end.
97
+
@@ -0,0 +1,152 @@
1
+ {
2
+ This file is part of the Pas2JS run time library.
3
+ Copyright (c) 2022 by Michael Van Canneyt
4
+
5
+ Simple Linked List implementation.
6
+
7
+ See the file COPYING.FPC, included in this distribution,
8
+ for details about the copyright.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+
14
+ **********************************************************************}
15
+
16
+ {$IFNDEF FPC_DOTTEDUNITS}
17
+ unit simplelinkedlist;
18
+ {$ENDIF}
19
+
20
+ {$mode objfpc}
21
+
22
+ interface
23
+
24
+ Type
25
+ TLinkedListItem = Class
26
+ Public
27
+ Next : TLinkedListItem;
28
+ end;
29
+ TLinkedListItemClass = Class of TLinkedListItem;
30
+
31
+ { TLinkedListVisitor }
32
+
33
+ TLinkedListVisitor = Class
34
+ Function Visit(Item : TLinkedListItem) : Boolean; virtual; abstract;
35
+ end;
36
+ { TLinkedList }
37
+
38
+ TLinkedList = Class
39
+ private
40
+ FItemClass: TLinkedListItemClass;
41
+ FRoot: TLinkedListItem;
42
+ function GetCount: Integer;
43
+ Public
44
+ Constructor Create(AnItemClass : TLinkedListItemClass); virtual;
45
+ Destructor Destroy; override;
46
+ Procedure Clear;
47
+ Function Add : TLinkedListItem;
48
+ Procedure ForEach(Visitor: TLinkedListVisitor);
49
+ Procedure RemoveItem(Item : TLinkedListItem; FreeItem : Boolean = False);
50
+ Property Root : TLinkedListItem Read FRoot;
51
+ Property ItemClass : TLinkedListItemClass Read FItemClass;
52
+ Property Count : Integer Read GetCount;
53
+ end;
54
+
55
+ implementation
56
+
57
+ {$IFDEF FPC_DOTTEDUNITS}
58
+ uses System.SysUtils;
59
+ {$ELSE}
60
+ uses sysutils;
61
+ {$ENDIF}
62
+
63
+ { TLinkedList }
64
+
65
+ function TLinkedList.GetCount: Integer;
66
+
67
+ Var
68
+ I : TLinkedListItem;
69
+
70
+ begin
71
+ I:=FRoot;
72
+ Result:=0;
73
+ While I<>Nil do
74
+ begin
75
+ I:=I.Next;
76
+ Inc(Result);
77
+ end;
78
+ end;
79
+
80
+ constructor TLinkedList.Create(AnItemClass: TLinkedListItemClass);
81
+ begin
82
+ FItemClass:=AnItemClass;
83
+ end;
84
+
85
+ destructor TLinkedList.Destroy;
86
+ begin
87
+ Clear;
88
+ inherited Destroy;
89
+ end;
90
+
91
+ procedure TLinkedList.Clear;
92
+
93
+ Var
94
+ I : TLinkedListItem;
95
+
96
+ begin
97
+ // Can't use visitor, because it'd kill the next pointer...
98
+ I:=FRoot;
99
+ While I<>Nil do
100
+ begin
101
+ FRoot:=I;
102
+ I:=I.Next;
103
+ FRoot.Next:=Nil;
104
+ FreeAndNil(FRoot);
105
+ end;
106
+ end;
107
+
108
+ function TLinkedList.Add: TLinkedListItem;
109
+ begin
110
+ Result:=FItemClass.Create;
111
+ Result.Next:=FRoot;
112
+ FRoot:=Result;
113
+ end;
114
+
115
+ procedure TLinkedList.ForEach(Visitor : TLinkedListVisitor);
116
+
117
+ Var
118
+ I : TLinkedListItem;
119
+
120
+ begin
121
+ I:=FRoot;
122
+ While (I<>Nil) and Visitor.Visit(I) do
123
+ I:=I.Next;
124
+ end;
125
+
126
+ procedure TLinkedList.RemoveItem(Item: TLinkedListItem; FreeItem : Boolean = False);
127
+
128
+ Var
129
+ I : TLinkedListItem;
130
+
131
+ begin
132
+ If (Item<>Nil) and (FRoot<>Nil) then
133
+ begin
134
+ If (Item=FRoot) then
135
+ FRoot:=Item.Next
136
+ else
137
+ begin
138
+ I:=FRoot;
139
+ While (I.Next<>Nil) and (I.Next<>Item) do
140
+ I:=I.Next;
141
+ If (I.Next=Item) then
142
+ I.Next:=Item.Next;
143
+ end;
144
+ If FreeItem Then
145
+ Item.Free;
146
+ end;
147
+ end;
148
+
149
+
150
+
151
+ end.
152
+