@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,134 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2017 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 "xsAll.h"
|
|
39
|
+
|
|
40
|
+
const txDefaults ICACHE_FLASH_ATTR gxDefaults = {
|
|
41
|
+
fxNewAsyncInstance,
|
|
42
|
+
fxRunAsync,
|
|
43
|
+
fxNewGeneratorInstance,
|
|
44
|
+
fxNewGeneratorFunctionInstance,
|
|
45
|
+
fxNewAsyncGeneratorInstance,
|
|
46
|
+
fxNewAsyncGeneratorFunctionInstance,
|
|
47
|
+
fxRunForAwaitOf,
|
|
48
|
+
fxNewArgumentsSloppyInstance,
|
|
49
|
+
fxNewArgumentsStrictInstance,
|
|
50
|
+
fxRunEval,
|
|
51
|
+
fxRunEvalEnvironment,
|
|
52
|
+
fxRunProgramEnvironment,
|
|
53
|
+
#ifdef mxMultipleThreads
|
|
54
|
+
C_NULL,
|
|
55
|
+
C_NULL,
|
|
56
|
+
#else
|
|
57
|
+
fxInitializeSharedCluster,
|
|
58
|
+
fxTerminateSharedCluster,
|
|
59
|
+
#endif
|
|
60
|
+
fxNewFunctionLength,
|
|
61
|
+
fxNewFunctionName,
|
|
62
|
+
fxRunImport,
|
|
63
|
+
fxDefinePrivateProperty,
|
|
64
|
+
fxGetPrivateProperty,
|
|
65
|
+
fxSetPrivateProperty,
|
|
66
|
+
fxCleanupFinalizationRegistries,
|
|
67
|
+
fxCaptureErrorStack,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const txBehavior* ICACHE_RAM_ATTR gxBehaviors[XS_BEHAVIOR_COUNT] = {
|
|
71
|
+
&gxOrdinaryBehavior,
|
|
72
|
+
&gxArgumentsSloppyBehavior,
|
|
73
|
+
&gxOrdinaryBehavior,
|
|
74
|
+
&gxArrayBehavior,
|
|
75
|
+
&gxEnvironmentBehavior,
|
|
76
|
+
&gxGlobalBehavior,
|
|
77
|
+
&gxModuleBehavior,
|
|
78
|
+
&gxProxyBehavior,
|
|
79
|
+
&gxStringBehavior,
|
|
80
|
+
&gxTypedArrayBehavior
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const txTypeDispatch ICACHE_FLASH_ATTR gxTypeDispatches[mxTypeArrayCount] = {
|
|
84
|
+
{ 8, 3, fxBigInt64Getter, fxBigInt64Setter, fxBigIntCoerce, fxBigInt64Compare, _getBigInt64, _setBigInt64, _BigInt64Array },
|
|
85
|
+
{ 8, 3, fxBigUint64Getter, fxBigUint64Setter, fxBigIntCoerce, fxBigUint64Compare, _getBigUint64, _setBigUint64, _BigUint64Array },
|
|
86
|
+
{ 4, 2, fxFloat32Getter, fxFloat32Setter, fxNumberCoerce, fxFloat32Compare, _getFloat32, _setFloat32, _Float32Array },
|
|
87
|
+
{ 8, 3, fxFloat64Getter, fxFloat64Setter, fxNumberCoerce, fxFloat64Compare, _getFloat64, _setFloat64, _Float64Array },
|
|
88
|
+
{ 1, 0, fxInt8Getter, fxInt8Setter, fxIntCoerce, fxInt8Compare, _getInt8, _setInt8, _Int8Array },
|
|
89
|
+
{ 2, 1, fxInt16Getter, fxInt16Setter, fxIntCoerce, fxInt16Compare, _getInt16, _setInt16, _Int16Array },
|
|
90
|
+
{ 4, 2, fxInt32Getter, fxInt32Setter, fxIntCoerce, fxInt32Compare, _getInt32, _setInt32, _Int32Array },
|
|
91
|
+
{ 1, 0, fxUint8Getter, fxUint8Setter, fxUintCoerce, fxUint8Compare, _getUint8, _setUint8, _Uint8Array },
|
|
92
|
+
{ 2, 1, fxUint16Getter, fxUint16Setter, fxUintCoerce, fxUint16Compare, _getUint16, _setUint16, _Uint16Array },
|
|
93
|
+
{ 4, 2, fxUint32Getter, fxUint32Setter, fxUintCoerce, fxUint32Compare, _getUint32, _setUint32, _Uint32Array },
|
|
94
|
+
{ 1, 0, fxUint8Getter, fxUint8ClampedSetter, fxNumberCoerce, fxUint8Compare, _getUint8, _setUint8, _Uint8ClampedArray }
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const txTypeAtomics ICACHE_FLASH_ATTR gxTypeAtomics[mxTypeArrayCount] = {
|
|
98
|
+
{ fxInt64Add, fxInt64And, fxInt64CompareExchange, fxInt64Exchange, fxInt64Load, fxInt64Or, fxInt64Store, fxInt64Sub, fxInt64Xor, fxInt64Wait },
|
|
99
|
+
{ fxUint64Add, fxUint64And, fxUint64CompareExchange, fxUint64Exchange, fxUint64Load, fxUint64Or, fxUint64Store, fxUint64Sub, fxUint64Xor, C_NULL },
|
|
100
|
+
{ C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL },
|
|
101
|
+
{ C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL },
|
|
102
|
+
{ fxInt8Add, fxInt8And, fxInt8CompareExchange, fxInt8Exchange, fxInt8Load, fxInt8Or, fxInt8Store, fxInt8Sub, fxInt8Xor, C_NULL },
|
|
103
|
+
{ fxInt16Add, fxInt16And, fxInt16CompareExchange, fxInt16Exchange, fxInt16Load, fxInt16Or, fxInt16Store, fxInt16Sub, fxInt16Xor, C_NULL },
|
|
104
|
+
{ fxInt32Add, fxInt32And, fxInt32CompareExchange, fxInt32Exchange, fxInt32Load, fxInt32Or, fxInt32Store, fxInt32Sub, fxInt32Xor, fxInt32Wait },
|
|
105
|
+
{ fxUint8Add, fxUint8And, fxUint8CompareExchange, fxUint8Exchange, fxUint8Load, fxUint8Or, fxUint8Store, fxUint8Sub, fxUint8Xor, C_NULL },
|
|
106
|
+
{ fxUint16Add, fxUint16And, fxUint16CompareExchange, fxUint16Exchange, fxUint16Load, fxUint16Or, fxUint16Store, fxUint16Sub, fxUint16Xor, C_NULL },
|
|
107
|
+
{ fxUint32Add, fxUint32And, fxUint32CompareExchange, fxUint32Exchange, fxUint32Load, fxUint32Or, fxUint32Store, fxUint32Sub, fxUint32Xor, C_NULL },
|
|
108
|
+
{ C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL, C_NULL }
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const txTypeBigInt ICACHE_FLASH_ATTR gxTypeBigInt = {
|
|
112
|
+
fxBigIntCompare,
|
|
113
|
+
fxBigIntDecode,
|
|
114
|
+
fxBigintToArrayBuffer,
|
|
115
|
+
fxBigIntToInstance,
|
|
116
|
+
fxBigIntToNumber,
|
|
117
|
+
fxBigintToString,
|
|
118
|
+
fxBigInt_add,
|
|
119
|
+
fxBigInt_and,
|
|
120
|
+
fxBigInt_dec,
|
|
121
|
+
fxBigInt_div,
|
|
122
|
+
fxBigInt_exp,
|
|
123
|
+
fxBigInt_inc,
|
|
124
|
+
fxBigInt_lsl,
|
|
125
|
+
fxBigInt_lsr,
|
|
126
|
+
fxBigInt_mul,
|
|
127
|
+
fxBigInt_neg,
|
|
128
|
+
fxBigInt_nop,
|
|
129
|
+
fxBigInt_not,
|
|
130
|
+
fxBigInt_or,
|
|
131
|
+
fxBigInt_rem,
|
|
132
|
+
fxBigInt_sub,
|
|
133
|
+
fxBigInt_xor,
|
|
134
|
+
};
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-2017 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 "xsAll.h"
|
|
39
|
+
|
|
40
|
+
static txSlot* fx_Error_aux(txMachine* the, txError error, txInteger i);
|
|
41
|
+
|
|
42
|
+
void fxBuildError(txMachine* the)
|
|
43
|
+
{
|
|
44
|
+
txSlot* slot;
|
|
45
|
+
txSlot* prototype;
|
|
46
|
+
txSlot* instance;
|
|
47
|
+
mxPush(mxObjectPrototype);
|
|
48
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
49
|
+
slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Error_toString), 0, mxID(_toString), XS_DONT_ENUM_FLAG);
|
|
50
|
+
slot = fxNextStringXProperty(the, slot, "Error", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
51
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
52
|
+
slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_Error_prototype_get_stack), C_NULL, mxID(_stack), XS_DONT_ENUM_FLAG);
|
|
53
|
+
mxErrorPrototype = *the->stack;
|
|
54
|
+
prototype = fxBuildHostConstructor(the, mxCallback(fx_Error), 1, mxID(_Error));
|
|
55
|
+
mxErrorConstructor = *the->stack;
|
|
56
|
+
mxPop();
|
|
57
|
+
mxPush(mxErrorPrototype);
|
|
58
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
59
|
+
slot = fxNextStringXProperty(the, slot, "AggregateError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
60
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
61
|
+
mxAggregateErrorPrototype = *the->stack;
|
|
62
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_AggregateError), 2, mxID(_AggregateError));
|
|
63
|
+
instance->value.instance.prototype = prototype;
|
|
64
|
+
mxAggregateErrorConstructor = *the->stack;
|
|
65
|
+
mxPop();
|
|
66
|
+
mxPush(mxErrorPrototype);
|
|
67
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
68
|
+
slot = fxNextStringXProperty(the, slot, "EvalError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
69
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
70
|
+
mxEvalErrorPrototype = *the->stack;
|
|
71
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_EvalError), 1, mxID(_EvalError));
|
|
72
|
+
instance->value.instance.prototype = prototype;
|
|
73
|
+
mxEvalErrorConstructor = *the->stack;
|
|
74
|
+
mxPop();
|
|
75
|
+
mxPush(mxErrorPrototype);
|
|
76
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
77
|
+
slot = fxNextStringXProperty(the, slot, "RangeError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
78
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
79
|
+
mxRangeErrorPrototype = *the->stack;
|
|
80
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_RangeError), 1, mxID(_RangeError));
|
|
81
|
+
instance->value.instance.prototype = prototype;
|
|
82
|
+
mxRangeErrorConstructor = *the->stack;
|
|
83
|
+
mxPop();
|
|
84
|
+
mxPush(mxErrorPrototype);
|
|
85
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
86
|
+
slot = fxNextStringXProperty(the, slot, "ReferenceError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
87
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
88
|
+
mxReferenceErrorPrototype = *the->stack;
|
|
89
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_ReferenceError), 1, mxID(_ReferenceError));
|
|
90
|
+
instance->value.instance.prototype = prototype;
|
|
91
|
+
mxReferenceErrorConstructor = *the->stack;
|
|
92
|
+
mxPop();
|
|
93
|
+
mxPush(mxErrorPrototype);
|
|
94
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
95
|
+
slot = fxNextStringXProperty(the, slot, "SyntaxError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
96
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
97
|
+
mxSyntaxErrorPrototype = *the->stack;
|
|
98
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_SyntaxError), 1, mxID(_SyntaxError));
|
|
99
|
+
instance->value.instance.prototype = prototype;
|
|
100
|
+
mxSyntaxErrorConstructor = *the->stack;
|
|
101
|
+
mxPop();
|
|
102
|
+
mxPush(mxErrorPrototype);
|
|
103
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
104
|
+
slot = fxNextStringXProperty(the, slot, "TypeError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
105
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
106
|
+
mxTypeErrorPrototype = *the->stack;
|
|
107
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_TypeError), 1, mxID(_TypeError));
|
|
108
|
+
instance->value.instance.prototype = prototype;
|
|
109
|
+
mxTypeErrorConstructor = *the->stack;
|
|
110
|
+
mxPop();
|
|
111
|
+
mxPush(mxErrorPrototype);
|
|
112
|
+
slot = fxLastProperty(the, fxNewObjectInstance(the));
|
|
113
|
+
slot = fxNextStringXProperty(the, slot, "URIError", mxID(_name), XS_DONT_ENUM_FLAG);
|
|
114
|
+
slot = fxNextStringXProperty(the, slot, "", mxID(_message), XS_DONT_ENUM_FLAG);
|
|
115
|
+
mxURIErrorPrototype = *the->stack;
|
|
116
|
+
instance = fxBuildHostConstructor(the, mxCallback(fx_URIError), 1, mxID(_URIError));
|
|
117
|
+
instance->value.instance.prototype = prototype;
|
|
118
|
+
mxURIErrorConstructor = *the->stack;
|
|
119
|
+
mxPop();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void fxCaptureErrorStack(txMachine* the, txSlot* internal, txSlot* frame)
|
|
123
|
+
{
|
|
124
|
+
txSlot* slot = internal->value.reference = fxNewSlot(the);
|
|
125
|
+
slot->kind = XS_INSTANCE_KIND;
|
|
126
|
+
slot->value.instance.garbage = C_NULL;
|
|
127
|
+
slot->value.instance.prototype = C_NULL;
|
|
128
|
+
while (frame->next) {
|
|
129
|
+
txSlot* environment = mxFrameToEnvironment(frame);
|
|
130
|
+
txSlot* function = frame + 3;
|
|
131
|
+
if (function->kind == XS_REFERENCE_KIND) {
|
|
132
|
+
function = function->value.reference;
|
|
133
|
+
if (mxIsFunction(function)) {
|
|
134
|
+
txSlot* name = mxBehaviorGetProperty(the, function, mxID(_name), 0, XS_OWN);
|
|
135
|
+
slot = slot->next = fxNewSlot(the);
|
|
136
|
+
slot->flag = XS_GET_ONLY;
|
|
137
|
+
slot->kind = XS_KEY_KIND;
|
|
138
|
+
slot->ID = environment->ID;
|
|
139
|
+
slot->value.key.string = C_NULL;
|
|
140
|
+
slot->value.key.sum = environment->value.environment.line;
|
|
141
|
+
if (name && ((name->kind == XS_STRING_KIND) || (name->kind == XS_STRING_X_KIND))) {
|
|
142
|
+
if (name->kind == XS_STRING_X_KIND)
|
|
143
|
+
slot->kind = XS_KEY_X_KIND;
|
|
144
|
+
slot->value.key.string = name->value.string;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
txSlot* code = mxFunctionInstanceCode(function);
|
|
148
|
+
if (code->ID != XS_NO_ID) {
|
|
149
|
+
txSlot* key = fxGetKey(the, code->ID);
|
|
150
|
+
if (key) {
|
|
151
|
+
if (key->kind == XS_KEY_X_KIND)
|
|
152
|
+
slot->kind = XS_KEY_X_KIND;
|
|
153
|
+
slot->value.key.string = key->value.key.string;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
frame = frame->next;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
void fx_Error(txMachine* the)
|
|
164
|
+
{
|
|
165
|
+
fx_Error_aux(the, XS_UNKNOWN_ERROR, 0);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
txSlot* fx_Error_aux(txMachine* the, txError error, txInteger i)
|
|
169
|
+
{
|
|
170
|
+
txSlot* instance;
|
|
171
|
+
txSlot* slot;
|
|
172
|
+
if (mxIsUndefined(mxTarget))
|
|
173
|
+
mxPushSlot(mxFunction);
|
|
174
|
+
else
|
|
175
|
+
mxPushSlot(mxTarget);
|
|
176
|
+
fxGetPrototypeFromConstructor(the, &mxErrorPrototypes(error));
|
|
177
|
+
instance = fxNewObjectInstance(the);
|
|
178
|
+
mxPullSlot(mxResult);
|
|
179
|
+
slot = instance->next = fxNewSlot(the);
|
|
180
|
+
slot->flag = XS_INTERNAL_FLAG;
|
|
181
|
+
slot->kind = XS_ERROR_KIND;
|
|
182
|
+
slot->value.error.info = C_NULL;
|
|
183
|
+
slot->value.error.which = error;
|
|
184
|
+
if (gxDefaults.captureErrorStack)
|
|
185
|
+
gxDefaults.captureErrorStack(the, slot, the->frame->next);
|
|
186
|
+
if ((mxArgc > i) && (mxArgv(i)->kind != XS_UNDEFINED_KIND)) {
|
|
187
|
+
fxToString(the, mxArgv(i));
|
|
188
|
+
slot = fxNextSlotProperty(the, slot, mxArgv(i), mxID(_message), XS_DONT_ENUM_FLAG);
|
|
189
|
+
}
|
|
190
|
+
i++;
|
|
191
|
+
if ((mxArgc > i) && (mxArgv(i)->kind == XS_REFERENCE_KIND)) {
|
|
192
|
+
if (mxBehaviorHasProperty(the, mxArgv(i)->value.reference, mxID(_cause), 0)) {
|
|
193
|
+
mxPushSlot(mxArgv(i));
|
|
194
|
+
mxGetID(mxID(_cause));
|
|
195
|
+
slot = fxNextSlotProperty(the, slot, the->stack, mxID(_cause), XS_DONT_ENUM_FLAG);
|
|
196
|
+
mxPop();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return slot;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
void fx_Error_toString(txMachine* the)
|
|
203
|
+
{
|
|
204
|
+
txSlot* name;
|
|
205
|
+
txSlot* message;
|
|
206
|
+
if (mxThis->kind != XS_REFERENCE_KIND)
|
|
207
|
+
mxTypeError("this is no Error instance");
|
|
208
|
+
mxPushSlot(mxThis);
|
|
209
|
+
mxGetID(mxID(_name));
|
|
210
|
+
if (the->stack->kind == XS_UNDEFINED_KIND)
|
|
211
|
+
fxStringX(the, the->stack, "Error");
|
|
212
|
+
else
|
|
213
|
+
fxToString(the, the->stack);
|
|
214
|
+
name = the->stack;
|
|
215
|
+
mxPushSlot(mxThis);
|
|
216
|
+
mxGetID(mxID(_message));
|
|
217
|
+
if (the->stack->kind == XS_UNDEFINED_KIND)
|
|
218
|
+
*the->stack = mxEmptyString;
|
|
219
|
+
else
|
|
220
|
+
fxToString(the, the->stack);
|
|
221
|
+
message = the->stack;
|
|
222
|
+
if (c_isEmpty(name->value.string))
|
|
223
|
+
*mxResult = *message;
|
|
224
|
+
else if (c_isEmpty(message->value.string))
|
|
225
|
+
*mxResult = *name;
|
|
226
|
+
else {
|
|
227
|
+
fxStringX(the, mxResult, "");
|
|
228
|
+
fxConcatString(the, mxResult, name);
|
|
229
|
+
fxConcatStringC(the, mxResult, ": ");
|
|
230
|
+
fxConcatString(the, mxResult, message);
|
|
231
|
+
}
|
|
232
|
+
the->stack += 2;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
void fx_AggregateError(txMachine* the)
|
|
236
|
+
{
|
|
237
|
+
txSlot* stack = the->stack;
|
|
238
|
+
txSlot* property = fx_Error_aux(the, XS_AGGREGATE_ERROR, 1);
|
|
239
|
+
txSlot* array;
|
|
240
|
+
txSlot** address;
|
|
241
|
+
txIndex length = 0;
|
|
242
|
+
txSlot* iterator;
|
|
243
|
+
txSlot* next;
|
|
244
|
+
txSlot* value;
|
|
245
|
+
txSlot* slot;
|
|
246
|
+
|
|
247
|
+
mxPush(mxArrayPrototype);
|
|
248
|
+
array = fxNewArrayInstance(the);
|
|
249
|
+
fxNextSlotProperty(the, property, the->stack, mxID(_errors), XS_DONT_ENUM_FLAG);
|
|
250
|
+
address = &array->next->next;
|
|
251
|
+
mxTemporary(iterator);
|
|
252
|
+
mxTemporary(next);
|
|
253
|
+
fxGetIterator(the, mxArgv(0), iterator, next, 0);
|
|
254
|
+
mxTemporary(value);
|
|
255
|
+
while (fxIteratorNext(the, iterator, next, value)) {
|
|
256
|
+
mxTry(the) {
|
|
257
|
+
*address = slot = fxNewSlot(the);
|
|
258
|
+
slot->kind = value->kind;
|
|
259
|
+
slot->value = value->value;
|
|
260
|
+
address = &slot->next;
|
|
261
|
+
length++;
|
|
262
|
+
}
|
|
263
|
+
mxCatch(the) {
|
|
264
|
+
fxIteratorReturn(the, iterator);
|
|
265
|
+
fxJump(the);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
array->next->value.array.length = length;
|
|
269
|
+
fxCacheArray(the, array);
|
|
270
|
+
|
|
271
|
+
the->stack = stack;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
void fx_EvalError(txMachine* the)
|
|
275
|
+
{
|
|
276
|
+
fx_Error_aux(the, XS_EVAL_ERROR, 0);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
void fx_RangeError(txMachine* the)
|
|
280
|
+
{
|
|
281
|
+
fx_Error_aux(the, XS_RANGE_ERROR, 0);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
void fx_ReferenceError(txMachine* the)
|
|
285
|
+
{
|
|
286
|
+
fx_Error_aux(the, XS_REFERENCE_ERROR, 0);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
void fx_SyntaxError(txMachine* the)
|
|
290
|
+
{
|
|
291
|
+
fx_Error_aux(the, XS_SYNTAX_ERROR, 0);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
void fx_TypeError(txMachine* the)
|
|
295
|
+
{
|
|
296
|
+
fx_Error_aux(the, XS_TYPE_ERROR, 0);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
void fx_URIError(txMachine* the)
|
|
300
|
+
{
|
|
301
|
+
fx_Error_aux(the, XS_URI_ERROR, 0);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void fx_Error_prototype_get_stack(txMachine* the)
|
|
305
|
+
{
|
|
306
|
+
txSlot* slot;
|
|
307
|
+
if (mxThis->kind != XS_REFERENCE_KIND)
|
|
308
|
+
mxTypeError("this is no Error instance");
|
|
309
|
+
slot = mxThis->value.reference->next;
|
|
310
|
+
if (slot && (slot->kind == XS_ERROR_KIND)) {
|
|
311
|
+
fxStringX(the, mxResult, "");
|
|
312
|
+
mxPushSlot(mxThis);
|
|
313
|
+
mxGetID(mxID(_name));
|
|
314
|
+
if (the->stack->kind != XS_UNDEFINED_KIND) {
|
|
315
|
+
fxToString(the, the->stack);
|
|
316
|
+
fxConcatString(the, mxResult, the->stack);
|
|
317
|
+
}
|
|
318
|
+
else
|
|
319
|
+
fxConcatStringC(the, mxResult, "Error");
|
|
320
|
+
mxPop();
|
|
321
|
+
mxPushSlot(mxThis);
|
|
322
|
+
mxGetID(mxID(_message));
|
|
323
|
+
if (the->stack->kind != XS_UNDEFINED_KIND) {
|
|
324
|
+
fxToString(the, the->stack);
|
|
325
|
+
if (!c_isEmpty(the->stack->value.string)) {
|
|
326
|
+
fxConcatStringC(the, mxResult, ": ");
|
|
327
|
+
fxConcatString(the, mxResult, the->stack);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
mxPop();
|
|
331
|
+
slot = slot->value.reference;
|
|
332
|
+
if (slot) {
|
|
333
|
+
slot = slot->next;
|
|
334
|
+
while (slot) {
|
|
335
|
+
fxConcatStringC(the, mxResult, "\n at");
|
|
336
|
+
if ((slot->value.key.string != C_NULL) && (mxStringLength(slot->value.key.string))) {
|
|
337
|
+
fxConcatStringC(the, mxResult, " ");
|
|
338
|
+
fxConcatString(the, mxResult, slot);
|
|
339
|
+
}
|
|
340
|
+
fxConcatStringC(the, mxResult, " (");
|
|
341
|
+
if (slot->ID != XS_NO_ID) {
|
|
342
|
+
fxIDToString(the, slot->ID, the->nameBuffer, sizeof(the->nameBuffer));
|
|
343
|
+
fxConcatStringC(the, mxResult, the->nameBuffer);
|
|
344
|
+
fxConcatStringC(the, mxResult, ":");
|
|
345
|
+
fxIntegerToString(the, (txInteger)slot->value.key.sum, the->nameBuffer, sizeof(the->nameBuffer));
|
|
346
|
+
fxConcatStringC(the, mxResult, the->nameBuffer);
|
|
347
|
+
}
|
|
348
|
+
fxConcatStringC(the, mxResult, ")");
|
|
349
|
+
slot = slot->next;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|