@agoric/xsnap 0.14.3-u13.0 → 0.14.3-u16.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.
- package/README.md +3 -3
- package/api.js +4 -2
- package/build.env +1 -1
- package/moddable/modules/data/base64/base64.js +28 -0
- package/moddable/modules/data/base64/manifest.json +11 -0
- package/moddable/modules/data/base64/modBase64.c +188 -0
- package/moddable/modules/data/binaryMessage/BinaryMessage.js +106 -0
- package/moddable/modules/data/crc/crc.c +205 -0
- package/moddable/modules/data/crc/crc.js +36 -0
- package/moddable/modules/data/crc/manifest.json +8 -0
- package/moddable/modules/data/hex/hex.js +28 -0
- package/moddable/modules/data/hex/manifest.json +11 -0
- package/moddable/modules/data/hex/modHex.c +139 -0
- package/moddable/modules/data/logical/logical.js +32 -0
- package/moddable/modules/data/logical/modLogical.c +98 -0
- package/moddable/modules/data/qrcode/manifest.json +9 -0
- package/moddable/modules/data/qrcode/qrcode.c +93 -0
- package/moddable/modules/data/qrcode/qrcode.js +23 -0
- package/moddable/modules/data/qrcode/qrcodegen.c +1025 -0
- package/moddable/modules/data/qrcode/qrcodegen.h +267 -0
- package/moddable/modules/data/text/decoder/manifest.json +8 -0
- package/moddable/modules/data/text/decoder/textdecoder.c +480 -0
- package/moddable/modules/data/text/decoder/textdecoder.js +27 -0
- package/moddable/modules/data/text/encoder/manifest.json +8 -0
- package/moddable/modules/data/text/encoder/textencoder.c +232 -0
- package/moddable/modules/data/text/encoder/textencoder.js +24 -0
- package/moddable/modules/data/tinyint/tinyint.c +150 -0
- package/moddable/modules/data/tinyint/tinyint.js +53 -0
- package/moddable/modules/data/url/manifest.json +17 -0
- package/moddable/modules/data/url/url.c +1959 -0
- package/moddable/modules/data/url/url.js +210 -0
- package/moddable/modules/data/wavreader/manifest.json +8 -0
- package/moddable/modules/data/wavreader/wavreader.js +128 -0
- package/moddable/modules/data/zlib/deflate.c +161 -0
- package/moddable/modules/data/zlib/deflate.js +63 -0
- package/moddable/modules/data/zlib/inflate.c +145 -0
- package/moddable/modules/data/zlib/inflate.js +66 -0
- package/moddable/modules/data/zlib/manifest_deflate.json +9 -0
- package/moddable/modules/data/zlib/manifest_inflate.json +9 -0
- package/moddable/modules/data/zlib/miniz.c +4924 -0
- package/moddable/xs/includes/xs.d.ts +73 -0
- package/moddable/xs/includes/xs.h +1533 -0
- package/moddable/xs/includes/xsmc.h +206 -0
- package/moddable/xs/makefiles/lin/makefile +33 -0
- package/moddable/xs/makefiles/lin/xsc.mk +118 -0
- package/moddable/xs/makefiles/lin/xsid.mk +90 -0
- package/moddable/xs/makefiles/lin/xsl.mk +168 -0
- package/moddable/xs/makefiles/lin/xst.mk +201 -0
- package/moddable/xs/makefiles/mac/makefile +33 -0
- package/moddable/xs/makefiles/mac/xsc.mk +130 -0
- package/moddable/xs/makefiles/mac/xsid.mk +102 -0
- package/moddable/xs/makefiles/mac/xsl.mk +177 -0
- package/moddable/xs/makefiles/mac/xst.mk +203 -0
- package/moddable/xs/makefiles/mac/xst_no_asan.txt +52 -0
- package/moddable/xs/makefiles/win/build.bat +26 -0
- package/moddable/xs/makefiles/win/xsc.mak +142 -0
- package/moddable/xs/makefiles/win/xsid.mak +113 -0
- package/moddable/xs/makefiles/win/xsl.mak +186 -0
- package/moddable/xs/makefiles/win/xst.mak +195 -0
- package/moddable/xs/platforms/lin_xs.h +99 -0
- package/moddable/xs/platforms/mac_xs.h +97 -0
- package/moddable/xs/platforms/wasm_xs.h +79 -0
- package/moddable/xs/platforms/win_xs.h +104 -0
- package/moddable/xs/platforms/xsHost.h +63 -0
- package/moddable/xs/platforms/xsPlatform.h +618 -0
- package/moddable/xs/sources/xsAPI.c +2555 -0
- package/moddable/xs/sources/xsAll.c +294 -0
- package/moddable/xs/sources/xsAll.h +2741 -0
- package/moddable/xs/sources/xsArguments.c +222 -0
- package/moddable/xs/sources/xsArray.c +2657 -0
- package/moddable/xs/sources/xsAtomics.c +844 -0
- package/moddable/xs/sources/xsBigInt.c +1859 -0
- package/moddable/xs/sources/xsBoolean.c +109 -0
- package/moddable/xs/sources/xsCode.c +4493 -0
- package/moddable/xs/sources/xsCommon.c +1710 -0
- package/moddable/xs/sources/xsCommon.h +1142 -0
- package/moddable/xs/sources/xsDataView.c +2890 -0
- package/moddable/xs/sources/xsDate.c +1541 -0
- package/moddable/xs/sources/xsDebug.c +2710 -0
- package/moddable/xs/sources/xsDefaults.c +134 -0
- package/moddable/xs/sources/xsError.c +353 -0
- package/moddable/xs/sources/xsFunction.c +776 -0
- package/moddable/xs/sources/xsGenerator.c +865 -0
- package/moddable/xs/sources/xsGlobal.c +839 -0
- package/moddable/xs/sources/xsJSON.c +1091 -0
- package/moddable/xs/sources/xsLexical.c +1969 -0
- package/moddable/xs/sources/xsLockdown.c +933 -0
- package/moddable/xs/sources/xsMapSet.c +1649 -0
- package/moddable/xs/sources/xsMarshall.c +1020 -0
- package/moddable/xs/sources/xsMath.c +624 -0
- package/moddable/xs/sources/xsMemory.c +1941 -0
- package/moddable/xs/sources/xsModule.c +3101 -0
- package/moddable/xs/sources/xsNumber.c +560 -0
- package/moddable/xs/sources/xsObject.c +1102 -0
- package/moddable/xs/sources/xsPlatforms.c +480 -0
- package/moddable/xs/sources/xsProfile.c +577 -0
- package/moddable/xs/sources/xsPromise.c +1199 -0
- package/moddable/xs/sources/xsProperty.c +636 -0
- package/moddable/xs/sources/xsProxy.c +1014 -0
- package/moddable/xs/sources/xsRegExp.c +1168 -0
- package/moddable/xs/sources/xsRun.c +4889 -0
- package/moddable/xs/sources/xsScope.c +1293 -0
- package/moddable/xs/sources/xsScript.c +288 -0
- package/moddable/xs/sources/xsScript.h +1186 -0
- package/moddable/xs/sources/xsSnapshot.c +2161 -0
- package/moddable/xs/sources/xsSnapshot.h +51 -0
- package/moddable/xs/sources/xsSourceMap.c +218 -0
- package/moddable/xs/sources/xsString.c +3332 -0
- package/moddable/xs/sources/xsSymbol.c +503 -0
- package/moddable/xs/sources/xsSyntaxical.c +4193 -0
- package/moddable/xs/sources/xsTree.c +1893 -0
- package/moddable/xs/sources/xsType.c +1488 -0
- package/moddable/xs/sources/xsdtoa.c +6672 -0
- package/moddable/xs/sources/xsmc.c +340 -0
- package/moddable/xs/sources/xsre.c +7578 -0
- package/package.json +39 -22
- package/scripts/get_xsnap_version.sh +14 -0
- package/scripts/test-package.sh +21 -0
- package/src/avaAssertXS.js +6 -2
- package/src/avaHandler.cjs +2 -5
- package/src/avaXS.js +7 -8
- package/src/build.js +161 -28
- package/src/replay.js +0 -3
- package/src/xsnap.js +105 -91
- package/src/xsrepl.js +2 -3
- package/xsnap-native/xsnap/makefiles/lin/makefile +10 -0
- package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +156 -0
- package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +144 -0
- package/xsnap-native/xsnap/makefiles/mac/makefile +10 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +165 -0
- package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +153 -0
- package/xsnap-native/xsnap/sources/xsnap-worker.c +1008 -0
- package/xsnap-native/xsnap/sources/xsnap.c +717 -0
- package/xsnap-native/xsnap/sources/xsnap.h +142 -0
- package/xsnap-native/xsnap/sources/xsnapPlatform.c +1501 -0
- package/xsnap-native/xsnap/sources/xsnapPlatform.h +105 -0
- package/CHANGELOG.md +0 -646
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2018 Moddable Tech, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Runtime.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Runtime is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Runtime is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU Lesser General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
* along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#include "xsAll.h"
|
|
22
|
+
#include "xsScript.h"
|
|
23
|
+
|
|
24
|
+
typedef struct sxProjection txProjection;
|
|
25
|
+
typedef struct sxSnapshot txSnapshot;
|
|
26
|
+
|
|
27
|
+
struct sxProjection {
|
|
28
|
+
txProjection* nextProjection;
|
|
29
|
+
txSlot* heap;
|
|
30
|
+
txSlot* limit;
|
|
31
|
+
size_t indexes[1];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
struct sxSnapshot {
|
|
35
|
+
char* signature;
|
|
36
|
+
int signatureLength;
|
|
37
|
+
txCallback* callbacks;
|
|
38
|
+
int callbacksLength;
|
|
39
|
+
int (*read)(void* stream, void* address, size_t size);
|
|
40
|
+
int (*write)(void* stream, void* address, size_t size);
|
|
41
|
+
void* stream;
|
|
42
|
+
int error;
|
|
43
|
+
txByte* firstChunk;
|
|
44
|
+
txProjection* firstProjection;
|
|
45
|
+
txSlot* firstSlot;
|
|
46
|
+
txSize slotSize;
|
|
47
|
+
txSlot** slots;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
extern txMachine* fxReadSnapshot(txSnapshot* snapshot, txString theName, void* theContext);
|
|
51
|
+
extern int fxWriteSnapshot(txMachine* the, txSnapshot* snapshot);
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2022 Moddable Tech, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the Moddable SDK Runtime.
|
|
5
|
+
*
|
|
6
|
+
* The Moddable SDK Runtime is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* The Moddable SDK Runtime is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU Lesser General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
* along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*
|
|
19
|
+
* This file incorporates work covered by the following copyright and
|
|
20
|
+
* permission notice:
|
|
21
|
+
*
|
|
22
|
+
* Copyright (C) 2010-2016 Marvell International Ltd.
|
|
23
|
+
* Copyright (C) 2002-2010 Kinoma, Inc.
|
|
24
|
+
*
|
|
25
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License.
|
|
27
|
+
* You may obtain a copy of the License at
|
|
28
|
+
*
|
|
29
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
+
* See the License for the specific language governing permissions and
|
|
35
|
+
* limitations under the License.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
#include "xsScript.h"
|
|
39
|
+
|
|
40
|
+
static void fxSourceMapLines(txParser* parser, txString mappings);
|
|
41
|
+
static txInteger fxSourceMapValue(txParser* parser, txString* p);
|
|
42
|
+
|
|
43
|
+
#define mxAssert(ASSERTION,MESSAGE) if (!(ASSERTION)) { fxReportParserError(parser, parser->line, MESSAGE); return; }
|
|
44
|
+
|
|
45
|
+
void fxParserSourceMap(txParser* parser, void* theStream, txGetter theGetter, txUnsigned flags, txString* name)
|
|
46
|
+
{
|
|
47
|
+
txInteger line = parser->line;
|
|
48
|
+
txNode* root = parser->root;
|
|
49
|
+
txNode* object;
|
|
50
|
+
txNode* item;
|
|
51
|
+
txNode* node;
|
|
52
|
+
txPropertyAtNode* property;
|
|
53
|
+
txString id;
|
|
54
|
+
txInteger version = 0;
|
|
55
|
+
txString source = NULL;
|
|
56
|
+
txString mappings = NULL;
|
|
57
|
+
|
|
58
|
+
parser->line = 0;
|
|
59
|
+
parser->root = NULL;
|
|
60
|
+
parser->stream = theStream;
|
|
61
|
+
parser->getter = theGetter;
|
|
62
|
+
|
|
63
|
+
parser->line2 = 1;
|
|
64
|
+
parser->crlf2 = 0;
|
|
65
|
+
parser->escaped2 = 0;
|
|
66
|
+
parser->integer2 = 0;
|
|
67
|
+
parser->modifierLength2 = 0;
|
|
68
|
+
parser->modifier2 = parser->emptyString;
|
|
69
|
+
parser->number2 = 0;
|
|
70
|
+
parser->stringLength2 = 0;
|
|
71
|
+
parser->string2 = parser->emptyString;
|
|
72
|
+
parser->symbol2 = C_NULL;
|
|
73
|
+
parser->token2 = XS_NO_TOKEN;
|
|
74
|
+
|
|
75
|
+
parser->lookahead = 0;
|
|
76
|
+
#if mxCESU8
|
|
77
|
+
parser->surrogate = 0;
|
|
78
|
+
#endif
|
|
79
|
+
fxGetNextCharacter(parser);
|
|
80
|
+
fxGetNextCharacter(parser);
|
|
81
|
+
fxGetNextTokenJSON(parser);
|
|
82
|
+
fxGetNextTokenJSON(parser);
|
|
83
|
+
fxJSONValue(parser);
|
|
84
|
+
if (parser->errorCount)
|
|
85
|
+
return;
|
|
86
|
+
object = parser->root;
|
|
87
|
+
parser->line = line;
|
|
88
|
+
parser->root = root;
|
|
89
|
+
|
|
90
|
+
mxAssert(object->description->token == XS_TOKEN_OBJECT, "source map: no object");
|
|
91
|
+
mxAssert(((txObjectNode*)object)->items, "source map: no properties");
|
|
92
|
+
item = ((txObjectNode*)object)->items->first;
|
|
93
|
+
while (item) {
|
|
94
|
+
mxAssert(item->description->token == XS_TOKEN_PROPERTY_AT, "source map: no property");
|
|
95
|
+
property = (txPropertyAtNode*)item;
|
|
96
|
+
mxAssert(property->at->description->token == XS_TOKEN_STRING, "source map: no property name");
|
|
97
|
+
id = ((txStringNode*)(property->at))->value;
|
|
98
|
+
if (!c_strcmp(id, "version")) {
|
|
99
|
+
mxAssert(property->value->description->token == XS_TOKEN_INTEGER, "source map: version is no integer");
|
|
100
|
+
version = ((txIntegerNode*)(property->value))->value;
|
|
101
|
+
}
|
|
102
|
+
else if (!c_strcmp(id, "sources")) {
|
|
103
|
+
mxAssert(property->value->description->token == XS_TOKEN_ARRAY, "source map: sources is no array");
|
|
104
|
+
node = ((txArrayNode*)(property->value))->items->first;
|
|
105
|
+
mxAssert(node->description->token == XS_TOKEN_STRING, "source map: sources[0] is no string");
|
|
106
|
+
source = ((txStringNode*)(node))->value;
|
|
107
|
+
}
|
|
108
|
+
else if (!c_strcmp(id, "mappings")) {
|
|
109
|
+
mxAssert(property->value->description->token == XS_TOKEN_STRING, "source map: mappings is no string");
|
|
110
|
+
mappings = ((txStringNode*)(property->value))->value;
|
|
111
|
+
}
|
|
112
|
+
item = item->next;
|
|
113
|
+
}
|
|
114
|
+
mxAssert(version == 3, "source map: version is not 3");
|
|
115
|
+
mxAssert(source, "source map: no source");
|
|
116
|
+
mxAssert(mappings, "source map: no mappings");
|
|
117
|
+
|
|
118
|
+
parser->lines = fxNewParserChunkClear(parser, (1 + line) * sizeof(txInteger));
|
|
119
|
+
|
|
120
|
+
fxSourceMapLines(parser, mappings);
|
|
121
|
+
*name = source;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void fxSourceMapLines(txParser* parser, txString mappings)
|
|
125
|
+
{
|
|
126
|
+
enum { BEGIN, SOURCE, LINE, COLUMN, NAME, END };
|
|
127
|
+
txInteger generatedLine = 0;
|
|
128
|
+
// txInteger generatedColumn = 0;
|
|
129
|
+
// txInteger name = 0;
|
|
130
|
+
// txInteger source = 0;
|
|
131
|
+
txInteger sourceLine = 0;
|
|
132
|
+
// txInteger sourceColumn = 0;
|
|
133
|
+
txInteger state = BEGIN;
|
|
134
|
+
txString p = mappings;
|
|
135
|
+
char c;
|
|
136
|
+
while ((c = *p)) {
|
|
137
|
+
if (c == ';') {
|
|
138
|
+
p++;
|
|
139
|
+
if ((state >= NAME) && (generatedLine < parser->line))
|
|
140
|
+
parser->lines[1 + generatedLine] = 1 + sourceLine;
|
|
141
|
+
generatedLine++;
|
|
142
|
+
// generatedColumn = 0;
|
|
143
|
+
state = BEGIN;
|
|
144
|
+
}
|
|
145
|
+
else if (c == ',') {
|
|
146
|
+
p++;
|
|
147
|
+
if ((state >= NAME) && (generatedLine < parser->line))
|
|
148
|
+
parser->lines[1 + generatedLine] = 1 + sourceLine;
|
|
149
|
+
state = BEGIN;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
txInteger value = fxSourceMapValue(parser, &p);
|
|
153
|
+
switch(state) {
|
|
154
|
+
case BEGIN:
|
|
155
|
+
// generatedColumn += value;
|
|
156
|
+
state = SOURCE;
|
|
157
|
+
break;
|
|
158
|
+
case SOURCE:
|
|
159
|
+
// source += value;
|
|
160
|
+
state = LINE;
|
|
161
|
+
break;
|
|
162
|
+
case LINE:
|
|
163
|
+
sourceLine += value;
|
|
164
|
+
state = COLUMN;
|
|
165
|
+
break;
|
|
166
|
+
case COLUMN:
|
|
167
|
+
// sourceColumn += value;
|
|
168
|
+
state = NAME;
|
|
169
|
+
break;
|
|
170
|
+
case NAME:
|
|
171
|
+
// name += value;
|
|
172
|
+
state = END;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#define VLQ_SHIFT 5
|
|
180
|
+
// binary: 100000
|
|
181
|
+
#define VLQ_CONTINUATION_BIT (1 << VLQ_SHIFT)
|
|
182
|
+
// binary: 011111
|
|
183
|
+
#define VLQ_MASK_BITS (VLQ_CONTINUATION_BIT - 1)
|
|
184
|
+
|
|
185
|
+
txInteger fxSourceMapValue(txParser* parser, txString* p)
|
|
186
|
+
{
|
|
187
|
+
txInteger continuation, digit, result = 0, shift = 0;
|
|
188
|
+
txString q = *p;
|
|
189
|
+
do {
|
|
190
|
+
char c = *q++;
|
|
191
|
+
if (('A' <= c) && (c <= 'Z'))
|
|
192
|
+
digit = c - 'A';
|
|
193
|
+
else if (('a' <= c) && (c <= 'z'))
|
|
194
|
+
digit = c - 'a' + 26;
|
|
195
|
+
else if (('0' <= c) && (c <= '9'))
|
|
196
|
+
digit = c - '0' + 52;
|
|
197
|
+
else if (c == '+')
|
|
198
|
+
digit = 62;
|
|
199
|
+
else if (c == '/')
|
|
200
|
+
digit = 63;
|
|
201
|
+
else
|
|
202
|
+
fxReportParserError(parser, parser->line, "source map: unexpected character");
|
|
203
|
+
continuation = digit & VLQ_CONTINUATION_BIT;
|
|
204
|
+
digit &= VLQ_MASK_BITS;
|
|
205
|
+
result += (digit << shift);
|
|
206
|
+
shift += VLQ_SHIFT;
|
|
207
|
+
} while (continuation);
|
|
208
|
+
*p = q;
|
|
209
|
+
shift = result >> 1;
|
|
210
|
+
return ((result & 1) == 1) ? -shift : shift;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|