@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,933 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2020-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 "xsAll.h"
|
|
39
|
+
#include "xsScript.h"
|
|
40
|
+
|
|
41
|
+
void fxSetHostFunctionProperty(txMachine* the, txSlot* property, txCallback call, txInteger length, txID id)
|
|
42
|
+
{
|
|
43
|
+
txSlot* home = the->stack;
|
|
44
|
+
txSlot* function = fxNewHostFunction(the, call, length, id, XS_NO_ID);
|
|
45
|
+
txSlot* slot = mxFunctionInstanceHome(function);
|
|
46
|
+
slot->value.home.object = home->value.reference;
|
|
47
|
+
property->kind = the->stack->kind;
|
|
48
|
+
property->value = the->stack->value;
|
|
49
|
+
mxPop();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void fx_lockdown(txMachine* the)
|
|
53
|
+
{
|
|
54
|
+
#define mxHardenBuiltInCall \
|
|
55
|
+
mxPush(mxGlobal); \
|
|
56
|
+
mxPushSlot(harden); \
|
|
57
|
+
mxCall()
|
|
58
|
+
#define mxHardenBuiltInRun \
|
|
59
|
+
mxRunCount(1); \
|
|
60
|
+
mxPop()
|
|
61
|
+
|
|
62
|
+
txSlot* instance;
|
|
63
|
+
txSlot* property;
|
|
64
|
+
txSlot* item;
|
|
65
|
+
txSlot* harden;
|
|
66
|
+
txInteger id;
|
|
67
|
+
|
|
68
|
+
if (mxProgram.value.reference->flag & XS_DONT_MARSHALL_FLAG)
|
|
69
|
+
mxTypeError("lockdown already called");
|
|
70
|
+
mxProgram.value.reference->flag |= XS_DONT_MARSHALL_FLAG;
|
|
71
|
+
|
|
72
|
+
property = mxBehaviorSetProperty(the, mxAsyncFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
|
|
73
|
+
if (property) {
|
|
74
|
+
property->kind = mxThrowTypeErrorFunction.kind;
|
|
75
|
+
property->value = mxThrowTypeErrorFunction.value;
|
|
76
|
+
}
|
|
77
|
+
property = mxBehaviorSetProperty(the, mxAsyncGeneratorFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
|
|
78
|
+
if (property) {
|
|
79
|
+
property->kind = mxThrowTypeErrorFunction.kind;
|
|
80
|
+
property->value = mxThrowTypeErrorFunction.value;
|
|
81
|
+
}
|
|
82
|
+
property = mxBehaviorSetProperty(the, mxFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
|
|
83
|
+
if (property) {
|
|
84
|
+
property->kind = mxThrowTypeErrorFunction.kind;
|
|
85
|
+
property->value = mxThrowTypeErrorFunction.value;
|
|
86
|
+
}
|
|
87
|
+
property = mxBehaviorSetProperty(the, mxGeneratorFunctionPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
|
|
88
|
+
if (property) {
|
|
89
|
+
property->kind = mxThrowTypeErrorFunction.kind;
|
|
90
|
+
property->value = mxThrowTypeErrorFunction.value;
|
|
91
|
+
}
|
|
92
|
+
property = mxBehaviorSetProperty(the, mxCompartmentPrototype.value.reference, mxID(_constructor), 0, XS_OWN);
|
|
93
|
+
if (property) {
|
|
94
|
+
property->kind = mxThrowTypeErrorFunction.kind;
|
|
95
|
+
property->value = mxThrowTypeErrorFunction.value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
instance = fxNewArray(the, _Compartment);
|
|
99
|
+
property = the->stackPrototypes - 1;
|
|
100
|
+
item = instance->next->value.array.address;
|
|
101
|
+
for (id = 0; id < XS_SYMBOL_ID_COUNT; id++) {
|
|
102
|
+
*((txIndex*)item) = id;
|
|
103
|
+
property--;
|
|
104
|
+
item++;
|
|
105
|
+
}
|
|
106
|
+
for (; id < _Compartment; id++) {
|
|
107
|
+
*((txIndex*)item) = id;
|
|
108
|
+
item->kind = property->kind;
|
|
109
|
+
item->value = property->value;
|
|
110
|
+
property--;
|
|
111
|
+
item++;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
fxDuplicateInstance(the, mxDateConstructor.value.reference);
|
|
115
|
+
property = mxFunctionInstanceCode(the->stack->value.reference);
|
|
116
|
+
property->value.callback.address = mxCallback(fx_Date_secure);
|
|
117
|
+
property = mxBehaviorSetProperty(the, the->stack->value.reference, mxID(_now), 0, XS_OWN);
|
|
118
|
+
fxSetHostFunctionProperty(the, property, mxCallback(fx_Date_now_secure), 0, mxID(_now));
|
|
119
|
+
property = mxBehaviorSetProperty(the, mxDatePrototype.value.reference, mxID(_constructor), 0, XS_OWN);
|
|
120
|
+
if (property) {
|
|
121
|
+
property->kind = mxThrowTypeErrorFunction.kind;
|
|
122
|
+
property->value = mxThrowTypeErrorFunction.value;
|
|
123
|
+
}
|
|
124
|
+
mxPull(instance->next->value.array.address[_Date]);
|
|
125
|
+
|
|
126
|
+
fxDuplicateInstance(the, mxMathObject.value.reference);
|
|
127
|
+
property = mxBehaviorSetProperty(the, the->stack->value.reference, mxID(_random), 0, XS_OWN);
|
|
128
|
+
fxSetHostFunctionProperty(the, property, mxCallback(fx_Math_random_secure), 0, mxID(_random));
|
|
129
|
+
mxPull(instance->next->value.array.address[_Math]);
|
|
130
|
+
|
|
131
|
+
mxPull(mxCompartmentGlobal);
|
|
132
|
+
|
|
133
|
+
mxTemporary(harden);
|
|
134
|
+
mxPush(mxGlobal);
|
|
135
|
+
fxGetID(the, fxID(the, "harden"));
|
|
136
|
+
mxPullSlot(harden);
|
|
137
|
+
|
|
138
|
+
for (id = XS_SYMBOL_ID_COUNT; id < _Infinity; id++) {
|
|
139
|
+
mxHardenBuiltInCall; mxPush(the->stackPrototypes[-1 - id]); mxHardenBuiltInRun;
|
|
140
|
+
}
|
|
141
|
+
for (id = _Compartment; id < XS_INTRINSICS_COUNT; id++) {
|
|
142
|
+
mxHardenBuiltInCall; mxPush(the->stackPrototypes[-1 - id]); mxHardenBuiltInRun;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
mxHardenBuiltInCall; mxPush(mxArgumentsSloppyPrototype); mxHardenBuiltInRun;
|
|
146
|
+
mxHardenBuiltInCall; mxPush(mxArgumentsStrictPrototype); mxHardenBuiltInRun;
|
|
147
|
+
mxHardenBuiltInCall; mxPush(mxArrayIteratorPrototype); mxHardenBuiltInRun;
|
|
148
|
+
mxHardenBuiltInCall; mxPush(mxAsyncFromSyncIteratorPrototype); mxHardenBuiltInRun;
|
|
149
|
+
mxHardenBuiltInCall; mxPush(mxAsyncFunctionPrototype); mxHardenBuiltInRun;
|
|
150
|
+
mxHardenBuiltInCall; mxPush(mxAsyncGeneratorFunctionPrototype); mxHardenBuiltInRun;
|
|
151
|
+
mxHardenBuiltInCall; mxPush(mxAsyncGeneratorPrototype); mxHardenBuiltInRun;
|
|
152
|
+
mxHardenBuiltInCall; mxPush(mxAsyncIteratorPrototype); mxHardenBuiltInRun;
|
|
153
|
+
mxHardenBuiltInCall; mxPush(mxGeneratorFunctionPrototype); mxHardenBuiltInRun;
|
|
154
|
+
mxHardenBuiltInCall; mxPush(mxGeneratorPrototype); mxHardenBuiltInRun;
|
|
155
|
+
mxHardenBuiltInCall; mxPush(mxHostPrototype); mxHardenBuiltInRun;
|
|
156
|
+
mxHardenBuiltInCall; mxPush(mxIteratorPrototype); mxHardenBuiltInRun;
|
|
157
|
+
mxHardenBuiltInCall; mxPush(mxMapIteratorPrototype); mxHardenBuiltInRun;
|
|
158
|
+
mxHardenBuiltInCall; mxPush(mxModulePrototype); mxHardenBuiltInRun;
|
|
159
|
+
mxHardenBuiltInCall; mxPush(mxRegExpStringIteratorPrototype); mxHardenBuiltInRun;
|
|
160
|
+
mxHardenBuiltInCall; mxPush(mxSetIteratorPrototype); mxHardenBuiltInRun;
|
|
161
|
+
mxHardenBuiltInCall; mxPush(mxStringIteratorPrototype); mxHardenBuiltInRun;
|
|
162
|
+
mxHardenBuiltInCall; mxPush(mxTransferPrototype); mxHardenBuiltInRun;
|
|
163
|
+
mxHardenBuiltInCall; mxPush(mxTypedArrayPrototype); mxHardenBuiltInRun;
|
|
164
|
+
|
|
165
|
+
mxHardenBuiltInCall; mxPush(mxAssignObjectFunction); mxHardenBuiltInRun;
|
|
166
|
+
mxHardenBuiltInCall; mxPush(mxCopyObjectFunction); mxHardenBuiltInRun;
|
|
167
|
+
mxHardenBuiltInCall; mxPush(mxEnumeratorFunction); mxHardenBuiltInRun;
|
|
168
|
+
mxHardenBuiltInCall; mxPush(mxInitializeRegExpFunction); mxHardenBuiltInRun;
|
|
169
|
+
mxHardenBuiltInCall; mxPush(mxOnRejectedPromiseFunction); mxHardenBuiltInRun;
|
|
170
|
+
mxHardenBuiltInCall; mxPush(mxOnResolvedPromiseFunction); mxHardenBuiltInRun;
|
|
171
|
+
mxHardenBuiltInCall; mxPush(mxOnThenableFunction); mxHardenBuiltInRun;
|
|
172
|
+
|
|
173
|
+
mxHardenBuiltInCall; mxPushReference(mxArrayLengthAccessor.value.accessor.getter); mxHardenBuiltInRun;
|
|
174
|
+
mxHardenBuiltInCall; mxPushReference(mxArrayLengthAccessor.value.accessor.setter); mxHardenBuiltInRun;
|
|
175
|
+
mxHardenBuiltInCall; mxPushReference(mxModuleAccessor.value.accessor.getter); mxHardenBuiltInRun;
|
|
176
|
+
mxHardenBuiltInCall; mxPushReference(mxStringAccessor.value.accessor.getter); mxHardenBuiltInRun;
|
|
177
|
+
mxHardenBuiltInCall; mxPushReference(mxStringAccessor.value.accessor.setter); mxHardenBuiltInRun;
|
|
178
|
+
if (mxProxyAccessor.value.accessor.getter) {
|
|
179
|
+
mxHardenBuiltInCall; mxPushReference(mxProxyAccessor.value.accessor.getter); mxHardenBuiltInRun;
|
|
180
|
+
}
|
|
181
|
+
if (mxProxyAccessor.value.accessor.setter) {
|
|
182
|
+
mxHardenBuiltInCall; mxPushReference(mxProxyAccessor.value.accessor.setter); mxHardenBuiltInRun;
|
|
183
|
+
}
|
|
184
|
+
mxHardenBuiltInCall; mxPushReference(mxTypedArrayAccessor.value.accessor.getter); mxHardenBuiltInRun;
|
|
185
|
+
mxHardenBuiltInCall; mxPushReference(mxTypedArrayAccessor.value.accessor.setter); mxHardenBuiltInRun;
|
|
186
|
+
|
|
187
|
+
mxHardenBuiltInCall; mxPush(mxArrayPrototype); fxGetID(the, mxID(_Symbol_unscopables)); mxHardenBuiltInRun;
|
|
188
|
+
|
|
189
|
+
mxHardenBuiltInCall; mxPush(mxCompartmentGlobal); mxHardenBuiltInRun;
|
|
190
|
+
|
|
191
|
+
mxFunctionInstanceCode(mxThrowTypeErrorFunction.value.reference)->ID = XS_NO_ID;
|
|
192
|
+
mxFunctionInstanceHome(mxThrowTypeErrorFunction.value.reference)->value.home.object = NULL;
|
|
193
|
+
|
|
194
|
+
mxPop();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static void fx_hardenQueue(txMachine* the, txSlot* list, txSlot* instance, txFlag flag)
|
|
198
|
+
{
|
|
199
|
+
txSlot* item;
|
|
200
|
+
if (instance->flag & flag)
|
|
201
|
+
return;
|
|
202
|
+
item = fxNewSlot(the);
|
|
203
|
+
item->value.reference = instance;
|
|
204
|
+
item->kind = XS_REFERENCE_KIND;
|
|
205
|
+
list->value.list.last->next = item;
|
|
206
|
+
list->value.list.last = item;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static void fx_hardenFreezeAndTraverse(txMachine* the, txSlot* reference, txSlot* freeze, txSlot* list, txFlag flag)
|
|
210
|
+
{
|
|
211
|
+
txSlot* instance = reference->value.reference;
|
|
212
|
+
txSlot* property;
|
|
213
|
+
txBoolean useIndexes = 1;
|
|
214
|
+
txSlot* at;
|
|
215
|
+
// txSlot* slot;
|
|
216
|
+
|
|
217
|
+
if (!mxBehaviorPreventExtensions(the, instance))
|
|
218
|
+
mxTypeError("extensible object");
|
|
219
|
+
|
|
220
|
+
property = instance->next;
|
|
221
|
+
if (property && (property->flag & XS_INTERNAL_FLAG) && (property->kind == XS_TYPED_ARRAY_KIND)) {
|
|
222
|
+
useIndexes = 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
at = fxNewInstance(the);
|
|
226
|
+
mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
|
|
227
|
+
mxPushUndefined();
|
|
228
|
+
property = the->stack;
|
|
229
|
+
while ((at = at->next)) {
|
|
230
|
+
if ((at->value.at.id != XS_NO_ID) || useIndexes) {
|
|
231
|
+
if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
|
|
232
|
+
txFlag mask = XS_DONT_DELETE_FLAG;
|
|
233
|
+
property->flag |= XS_DONT_DELETE_FLAG;
|
|
234
|
+
if (property->kind != XS_ACCESSOR_KIND) {
|
|
235
|
+
mask |= XS_DONT_SET_FLAG;
|
|
236
|
+
property->flag |= XS_DONT_SET_FLAG;
|
|
237
|
+
}
|
|
238
|
+
property->kind = XS_UNINITIALIZED_KIND;
|
|
239
|
+
if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, property, mask))
|
|
240
|
+
mxTypeError("cannot configure property");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
mxPop();
|
|
245
|
+
mxPop();
|
|
246
|
+
|
|
247
|
+
// if (flag == XS_DONT_MODIFY_FLAG) {
|
|
248
|
+
// property = instance->next;
|
|
249
|
+
// while (property) {
|
|
250
|
+
// if (property->flag & XS_INTERNAL_FLAG) {
|
|
251
|
+
// switch (property->kind) {
|
|
252
|
+
// case XS_ARRAY_BUFFER_KIND:
|
|
253
|
+
// case XS_DATE_KIND:
|
|
254
|
+
// case XS_MAP_KIND:
|
|
255
|
+
// case XS_SET_KIND:
|
|
256
|
+
// case XS_WEAK_MAP_KIND:
|
|
257
|
+
// case XS_WEAK_SET_KIND:
|
|
258
|
+
// property->flag |= XS_DONT_SET_FLAG;
|
|
259
|
+
// break;
|
|
260
|
+
// case XS_PRIVATE_KIND:
|
|
261
|
+
// slot = property->value.private.first;
|
|
262
|
+
// while (slot) {
|
|
263
|
+
// if (slot->kind != XS_ACCESSOR_KIND)
|
|
264
|
+
// slot->flag |= XS_DONT_SET_FLAG;
|
|
265
|
+
// slot->flag |= XS_DONT_DELETE_FLAG;
|
|
266
|
+
// slot = slot->next;
|
|
267
|
+
// }
|
|
268
|
+
// break;
|
|
269
|
+
// }
|
|
270
|
+
// }
|
|
271
|
+
// property = property->next;
|
|
272
|
+
// }
|
|
273
|
+
// }
|
|
274
|
+
instance->flag |= flag;
|
|
275
|
+
|
|
276
|
+
at = fxNewInstance(the);
|
|
277
|
+
mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
|
|
278
|
+
|
|
279
|
+
mxTemporary(property);
|
|
280
|
+
mxBehaviorGetPrototype(the, instance, property);
|
|
281
|
+
if (property->kind == XS_REFERENCE_KIND)
|
|
282
|
+
fx_hardenQueue(the, list, property->value.reference, flag);
|
|
283
|
+
|
|
284
|
+
while ((at = at->next)) {
|
|
285
|
+
if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
|
|
286
|
+
if (property->kind == XS_REFERENCE_KIND)
|
|
287
|
+
fx_hardenQueue(the, list, property->value.reference, flag);
|
|
288
|
+
else if (property->kind == XS_ACCESSOR_KIND) {
|
|
289
|
+
if (property->value.accessor.getter)
|
|
290
|
+
fx_hardenQueue(the, list, property->value.accessor.getter, flag);
|
|
291
|
+
if (property->value.accessor.setter)
|
|
292
|
+
fx_hardenQueue(the, list, property->value.accessor.setter, flag);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// if (flag == XS_DONT_MODIFY_FLAG) {
|
|
298
|
+
// property = instance->next;
|
|
299
|
+
// while (property) {
|
|
300
|
+
// if (property->flag & XS_INTERNAL_FLAG) {
|
|
301
|
+
// if (property->kind == XS_PRIVATE_KIND) {
|
|
302
|
+
// txSlot* item = property->value.private.first;
|
|
303
|
+
// while (item) {
|
|
304
|
+
// if (property->kind == XS_REFERENCE_KIND)
|
|
305
|
+
// fx_hardenQueue(the, list, property->value.reference, flag);
|
|
306
|
+
// else if (property->kind == XS_ACCESSOR_KIND) {
|
|
307
|
+
// if (property->value.accessor.getter)
|
|
308
|
+
// fx_hardenQueue(the, list, property->value.accessor.getter, flag);
|
|
309
|
+
// if (property->value.accessor.setter)
|
|
310
|
+
// fx_hardenQueue(the, list, property->value.accessor.setter, flag);
|
|
311
|
+
// }
|
|
312
|
+
// item = item->next;
|
|
313
|
+
// }
|
|
314
|
+
// }
|
|
315
|
+
// else if (property->kind == XS_DATA_VIEW_KIND) {
|
|
316
|
+
// property = property->next;
|
|
317
|
+
// fx_hardenQueue(the, list, property->value.reference, flag);
|
|
318
|
+
// }
|
|
319
|
+
// }
|
|
320
|
+
// property = property->next;
|
|
321
|
+
// }
|
|
322
|
+
// }
|
|
323
|
+
|
|
324
|
+
mxPop();
|
|
325
|
+
mxPop();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
void fx_harden(txMachine* the)
|
|
329
|
+
{
|
|
330
|
+
txFlag flag = XS_DONT_MARSHALL_FLAG;
|
|
331
|
+
txSlot* freeze;
|
|
332
|
+
txSlot* slot;
|
|
333
|
+
txSlot* list;
|
|
334
|
+
txSlot* item;
|
|
335
|
+
|
|
336
|
+
// if (!(mxProgram.value.reference->flag & XS_DONT_MARSHALL_FLAG))
|
|
337
|
+
// mxTypeError("call lockdown before harden");
|
|
338
|
+
|
|
339
|
+
if (mxArgc == 0)
|
|
340
|
+
return;
|
|
341
|
+
|
|
342
|
+
*mxResult = *mxArgv(0);
|
|
343
|
+
|
|
344
|
+
slot = mxArgv(0);
|
|
345
|
+
if (slot->kind != XS_REFERENCE_KIND)
|
|
346
|
+
return;
|
|
347
|
+
// if (mxArgc > 1) {
|
|
348
|
+
// txString string = fxToString(the, mxArgv(1));
|
|
349
|
+
// if (c_strcmp(string, "freeze") == 0)
|
|
350
|
+
// flag = XS_DONT_MARSHALL_FLAG;
|
|
351
|
+
// else if (c_strcmp(string, "petrify") == 0)
|
|
352
|
+
// flag = XS_DONT_MODIFY_FLAG;
|
|
353
|
+
// else
|
|
354
|
+
// mxTypeError("invalid integrity");
|
|
355
|
+
// }
|
|
356
|
+
slot = slot->value.reference;
|
|
357
|
+
if (slot->flag & flag)
|
|
358
|
+
return;
|
|
359
|
+
|
|
360
|
+
mxTemporary(freeze);
|
|
361
|
+
mxPush(mxObjectConstructor);
|
|
362
|
+
mxGetID(mxID(_freeze));
|
|
363
|
+
mxPullSlot(freeze);
|
|
364
|
+
|
|
365
|
+
mxTemporary(list);
|
|
366
|
+
list->value.list.first = C_NULL;
|
|
367
|
+
list->value.list.last = C_NULL;
|
|
368
|
+
list->kind = XS_LIST_KIND;
|
|
369
|
+
|
|
370
|
+
item = fxNewSlot(the);
|
|
371
|
+
item->value.reference = slot;
|
|
372
|
+
item->kind = XS_REFERENCE_KIND;
|
|
373
|
+
list->value.list.first = item;
|
|
374
|
+
list->value.list.last = item;
|
|
375
|
+
|
|
376
|
+
{
|
|
377
|
+
mxTry(the) {
|
|
378
|
+
while (item) {
|
|
379
|
+
fx_hardenFreezeAndTraverse(the, item, freeze, list, flag);
|
|
380
|
+
item = item->next;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
mxCatch(the) {
|
|
384
|
+
item = list->value.list.first;
|
|
385
|
+
while (item) {
|
|
386
|
+
item->value.reference->flag &= ~flag;
|
|
387
|
+
item = item->next;
|
|
388
|
+
}
|
|
389
|
+
fxJump(the);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
mxPop();
|
|
394
|
+
mxPop();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
void fx_petrify(txMachine* the)
|
|
398
|
+
{
|
|
399
|
+
txSlot* slot;
|
|
400
|
+
txSlot* instance;
|
|
401
|
+
txBoolean useIndexes = 1;
|
|
402
|
+
txSlot* at;
|
|
403
|
+
txSlot* property;
|
|
404
|
+
if (mxArgc == 0)
|
|
405
|
+
return;
|
|
406
|
+
slot = mxArgv(0);
|
|
407
|
+
*mxResult = *slot;
|
|
408
|
+
if (slot->kind != XS_REFERENCE_KIND)
|
|
409
|
+
return;
|
|
410
|
+
instance = slot->value.reference;
|
|
411
|
+
if (!mxBehaviorPreventExtensions(the, instance))
|
|
412
|
+
mxTypeError("extensible object");
|
|
413
|
+
slot = instance->next;
|
|
414
|
+
if (slot && (slot->flag & XS_INTERNAL_FLAG)) {
|
|
415
|
+
if ((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (slot->kind == XS_TYPED_ARRAY_KIND))
|
|
416
|
+
useIndexes = 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
at = fxNewInstance(the);
|
|
420
|
+
mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
|
|
421
|
+
mxPushUndefined();
|
|
422
|
+
property = the->stack;
|
|
423
|
+
while ((at = at->next)) {
|
|
424
|
+
if ((at->value.at.id != XS_NO_ID) || useIndexes) {
|
|
425
|
+
if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
|
|
426
|
+
txFlag mask = XS_DONT_DELETE_FLAG;
|
|
427
|
+
property->flag |= XS_DONT_DELETE_FLAG;
|
|
428
|
+
if (property->kind != XS_ACCESSOR_KIND) {
|
|
429
|
+
mask |= XS_DONT_SET_FLAG;
|
|
430
|
+
property->flag |= XS_DONT_SET_FLAG;
|
|
431
|
+
}
|
|
432
|
+
property->kind = XS_UNINITIALIZED_KIND;
|
|
433
|
+
if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, property, mask))
|
|
434
|
+
mxTypeError("cannot configure property");
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
mxPop();
|
|
439
|
+
|
|
440
|
+
property = instance->next;
|
|
441
|
+
while (property) {
|
|
442
|
+
if (property->flag & XS_INTERNAL_FLAG) {
|
|
443
|
+
switch (property->kind) {
|
|
444
|
+
case XS_ARRAY_BUFFER_KIND:
|
|
445
|
+
case XS_DATE_KIND:
|
|
446
|
+
case XS_MAP_KIND:
|
|
447
|
+
case XS_SET_KIND:
|
|
448
|
+
case XS_WEAK_MAP_KIND:
|
|
449
|
+
case XS_WEAK_SET_KIND:
|
|
450
|
+
property->flag |= XS_DONT_SET_FLAG;
|
|
451
|
+
break;
|
|
452
|
+
case XS_PRIVATE_KIND:
|
|
453
|
+
slot = property->value.private.first;
|
|
454
|
+
while (slot) {
|
|
455
|
+
if (slot->kind != XS_ACCESSOR_KIND)
|
|
456
|
+
slot->flag |= XS_DONT_SET_FLAG;
|
|
457
|
+
slot->flag |= XS_DONT_DELETE_FLAG;
|
|
458
|
+
slot = slot->next;
|
|
459
|
+
}
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
property = property->next;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
static void fxVerifyCode(txMachine* the, txSlot* list, txSlot* path, txByte* codeBuffer, txSize codeSize);
|
|
468
|
+
static void fxVerifyError(txMachine* the, txSlot* path, txID id, txIndex index, txString name);
|
|
469
|
+
static void fxVerifyErrorString(txMachine* the, txSlot* slot, txID id, txIndex index, txString name);
|
|
470
|
+
static void fxVerifyInstance(txMachine* the, txSlot* list, txSlot* path, txSlot* instance);
|
|
471
|
+
static void fxVerifyProperty(txMachine* the, txSlot *list, txSlot *path, txSlot* property, txID id);
|
|
472
|
+
static void fxVerifyPropertyError(txMachine* the, txSlot *list, txSlot *path, txSlot* property, txID id, txIndex index);
|
|
473
|
+
static void fxVerifyQueue(txMachine* the, txSlot* list, txSlot* path, txSlot* instance, txID id, txIndex index, txString name);
|
|
474
|
+
|
|
475
|
+
void fx_mutabilities(txMachine* the)
|
|
476
|
+
{
|
|
477
|
+
txSlot* instance;
|
|
478
|
+
txSlot* module;
|
|
479
|
+
txSlot* realm;
|
|
480
|
+
txSlot* slot;
|
|
481
|
+
txSlot* list;
|
|
482
|
+
txSlot* item;
|
|
483
|
+
|
|
484
|
+
fxVars(the, 2);
|
|
485
|
+
|
|
486
|
+
mxPush(mxArrayPrototype);
|
|
487
|
+
instance = fxNewArrayInstance(the);
|
|
488
|
+
mxPullSlot(mxResult);
|
|
489
|
+
|
|
490
|
+
fxNewHostObject(the, NULL);
|
|
491
|
+
fxSetHostChunk(the, the->stack, NULL, the->keyIndex);
|
|
492
|
+
mxPullSlot(mxVarv(0));
|
|
493
|
+
|
|
494
|
+
module = mxFunctionInstanceHome(mxFunction->value.reference)->value.home.module;
|
|
495
|
+
if (!module) module = mxProgram.value.reference;
|
|
496
|
+
realm = mxModuleInstanceInternal(module)->value.module.realm;
|
|
497
|
+
mxPushSlot(mxRealmGlobal(realm));
|
|
498
|
+
mxPullSlot(mxVarv(1));
|
|
499
|
+
|
|
500
|
+
if (mxArgc == 0)
|
|
501
|
+
return;
|
|
502
|
+
slot = mxArgv(0);
|
|
503
|
+
if (slot->kind != XS_REFERENCE_KIND)
|
|
504
|
+
return;
|
|
505
|
+
|
|
506
|
+
mxTemporary(list);
|
|
507
|
+
list->value.list.first = C_NULL;
|
|
508
|
+
list->value.list.last = C_NULL;
|
|
509
|
+
list->kind = XS_LIST_KIND;
|
|
510
|
+
|
|
511
|
+
item = fxNewSlot(the);
|
|
512
|
+
item->value.list.first = C_NULL;
|
|
513
|
+
item->value.list.last = slot->value.reference;
|
|
514
|
+
item->kind = XS_LIST_KIND;
|
|
515
|
+
list->value.list.first = item;
|
|
516
|
+
list->value.list.last = item;
|
|
517
|
+
|
|
518
|
+
{
|
|
519
|
+
mxTry(the) {
|
|
520
|
+
while (item) {
|
|
521
|
+
fxVerifyInstance(the, list, item->value.list.first, item->value.list.last);
|
|
522
|
+
item = item->next;
|
|
523
|
+
}
|
|
524
|
+
item = list->value.list.first;
|
|
525
|
+
while (item) {
|
|
526
|
+
item->value.list.last->flag &= ~XS_LEVEL_FLAG;
|
|
527
|
+
item = item->next;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
mxCatch(the) {
|
|
531
|
+
item = list->value.list.first;
|
|
532
|
+
while (item) {
|
|
533
|
+
item->value.list.last->flag &= ~XS_LEVEL_FLAG;
|
|
534
|
+
item = item->next;
|
|
535
|
+
}
|
|
536
|
+
fxJump(the);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
mxPop(); // list
|
|
541
|
+
|
|
542
|
+
fxCacheArray(the, instance);
|
|
543
|
+
mxPushSlot(mxResult);
|
|
544
|
+
mxPushSlot(mxResult);
|
|
545
|
+
mxGetID(mxID(_sort));
|
|
546
|
+
mxCall();
|
|
547
|
+
mxRunCount(0);
|
|
548
|
+
mxPullSlot(mxResult);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
void fxVerifyCode(txMachine* the, txSlot* list, txSlot* path, txByte* codeBuffer, txSize codeSize)
|
|
552
|
+
{
|
|
553
|
+
const txS1* bytes = gxCodeSizes;
|
|
554
|
+
txByte* p = codeBuffer;
|
|
555
|
+
txByte* q = p + codeSize;
|
|
556
|
+
txU1 byte;
|
|
557
|
+
txS1 offset;
|
|
558
|
+
txID id;
|
|
559
|
+
txInteger count = 0;
|
|
560
|
+
txByte flag = 0;
|
|
561
|
+
txByte* flags = fxGetHostChunk(the, mxVarv(0));
|
|
562
|
+
while (p < q) {
|
|
563
|
+
// fprintf(stderr, "%s", gxCodeNames[*((txU1*)p)]);
|
|
564
|
+
byte = (txU1)c_read8(p);
|
|
565
|
+
offset = (txS1)c_read8(bytes + byte);
|
|
566
|
+
if (0 < offset) {
|
|
567
|
+
p += offset;
|
|
568
|
+
}
|
|
569
|
+
else if (0 == offset) {
|
|
570
|
+
p++;
|
|
571
|
+
mxDecodeID(p, id);
|
|
572
|
+
if (byte == XS_CODE_PROGRAM_REFERENCE) {
|
|
573
|
+
flag = 1;
|
|
574
|
+
flags[id] = 1;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else if (-1 == offset) {
|
|
578
|
+
txU1 index;
|
|
579
|
+
p++;
|
|
580
|
+
index = *((txU1*)p);
|
|
581
|
+
p += 1 + index;
|
|
582
|
+
}
|
|
583
|
+
else if (-2 == offset) {
|
|
584
|
+
txU2 index;
|
|
585
|
+
p++;
|
|
586
|
+
mxDecode2(p, index);
|
|
587
|
+
p += index;
|
|
588
|
+
}
|
|
589
|
+
else if (-4 == offset) {
|
|
590
|
+
txS4 index;
|
|
591
|
+
p++;
|
|
592
|
+
mxDecode4(p, index);
|
|
593
|
+
p += index;
|
|
594
|
+
}
|
|
595
|
+
// fprintf(stderr, "\n");
|
|
596
|
+
if ((XS_CODE_BEGIN_SLOPPY <= byte) && (byte <= XS_CODE_BEGIN_STRICT_FIELD)) {
|
|
597
|
+
count++;
|
|
598
|
+
}
|
|
599
|
+
else if ((XS_CODE_END <= byte) && (byte <= XS_CODE_END_DERIVED)) {
|
|
600
|
+
count--;
|
|
601
|
+
if (count == 0)
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (flag) {
|
|
606
|
+
txSlot* instance = fxGetInstance(the, mxVarv(1));
|
|
607
|
+
txSlot* item;
|
|
608
|
+
txSlot* name;
|
|
609
|
+
|
|
610
|
+
mxTemporary(item);
|
|
611
|
+
|
|
612
|
+
item->value.list.first = name = fxNewSlot(the);
|
|
613
|
+
item->value.list.last = C_NULL;
|
|
614
|
+
item->kind = XS_LIST_KIND;
|
|
615
|
+
|
|
616
|
+
name->value.string = "GlobalEnvironment";
|
|
617
|
+
name->kind = XS_STRING_X_KIND;
|
|
618
|
+
name->next = path;
|
|
619
|
+
|
|
620
|
+
flags = fxGetHostChunk(the, mxVarv(0));
|
|
621
|
+
id = 0;
|
|
622
|
+
while (id < the->keyIndex) {
|
|
623
|
+
if (flags[id]) {
|
|
624
|
+
txSlot* property = mxBehaviorGetProperty(the, instance, id, 0, XS_OWN);
|
|
625
|
+
if (property)
|
|
626
|
+
fxVerifyProperty(the, list, name, property, id);
|
|
627
|
+
flags = fxGetHostChunk(the, mxVarv(0));
|
|
628
|
+
flags[id]= 0;
|
|
629
|
+
}
|
|
630
|
+
id++;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
mxPop();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
void fxVerifyError(txMachine* the, txSlot* path, txID id, txIndex index, txString string)
|
|
638
|
+
{
|
|
639
|
+
txSlot* array;
|
|
640
|
+
txSlot* slot;
|
|
641
|
+
txSlot* stack;
|
|
642
|
+
|
|
643
|
+
array = mxResult->value.reference->next;
|
|
644
|
+
slot = fxNewSlot(the);
|
|
645
|
+
slot->next = array->next;
|
|
646
|
+
array->next = slot;
|
|
647
|
+
array->value.array.length++;
|
|
648
|
+
fxString(the, slot, "");
|
|
649
|
+
|
|
650
|
+
stack = the->stack;
|
|
651
|
+
while (path) {
|
|
652
|
+
mxPushSlot(path);
|
|
653
|
+
path = path->next;
|
|
654
|
+
}
|
|
655
|
+
while (the->stack < stack) {
|
|
656
|
+
if (the->stack->kind == XS_STRING_X_KIND) {
|
|
657
|
+
fxVerifyErrorString(the, slot, XS_NO_ID, 0, the->stack->value.string);
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
fxVerifyErrorString(the, slot, the->stack->value.at.id, the->stack->value.at.index, C_NULL);
|
|
661
|
+
}
|
|
662
|
+
mxPop();
|
|
663
|
+
}
|
|
664
|
+
fxVerifyErrorString(the, slot, id, index, string);
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
// current = path;
|
|
668
|
+
// next = C_NULL;
|
|
669
|
+
// previous = C_NULL;
|
|
670
|
+
// while (current) {
|
|
671
|
+
// next = current->next;
|
|
672
|
+
// current->next = previous;
|
|
673
|
+
// previous = current;
|
|
674
|
+
// current = next;
|
|
675
|
+
// }
|
|
676
|
+
//
|
|
677
|
+
// path = previous;
|
|
678
|
+
// current = path;
|
|
679
|
+
// while (current) {
|
|
680
|
+
// if (current->kind == XS_STRING_X_KIND) {
|
|
681
|
+
// fxVerifyErrorString(the, slot, XS_NO_ID, 0, current->value.string);
|
|
682
|
+
// }
|
|
683
|
+
// else {
|
|
684
|
+
// fxVerifyErrorString(the, slot, current->value.at.id, current->value.at.index, C_NULL);
|
|
685
|
+
// }
|
|
686
|
+
// current = current->next;
|
|
687
|
+
// }
|
|
688
|
+
// fxVerifyErrorString(the, slot, id, index, string);
|
|
689
|
+
//
|
|
690
|
+
// current = path;
|
|
691
|
+
// next = C_NULL;
|
|
692
|
+
// previous = C_NULL;
|
|
693
|
+
// while (current) {
|
|
694
|
+
// next = current->next;
|
|
695
|
+
// current->next = previous;
|
|
696
|
+
// previous = current;
|
|
697
|
+
// current = next;
|
|
698
|
+
// }
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
void fxVerifyErrorString(txMachine* the, txSlot* slot, txID id, txIndex index, txString string)
|
|
702
|
+
{
|
|
703
|
+
if (string) {
|
|
704
|
+
fxConcatStringC(the, slot, "[[");
|
|
705
|
+
fxConcatStringC(the, slot, string);
|
|
706
|
+
fxConcatStringC(the, slot, "]]");
|
|
707
|
+
}
|
|
708
|
+
else if (id != XS_NO_ID) {
|
|
709
|
+
txSlot* key = fxGetKey(the, id);
|
|
710
|
+
if (key) {
|
|
711
|
+
if (key->flag & XS_DONT_ENUM_FLAG) {
|
|
712
|
+
c_snprintf(the->nameBuffer, sizeof(the->nameBuffer), "%s", key->value.key.string);
|
|
713
|
+
fxConcatStringC(the, slot, ".");
|
|
714
|
+
fxConcatStringC(the, slot, the->nameBuffer);
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
if ((key->kind == XS_KEY_KIND) || (key->kind == XS_KEY_X_KIND))
|
|
718
|
+
c_snprintf(the->nameBuffer, sizeof(the->nameBuffer), "%s", key->value.key.string);
|
|
719
|
+
else if ((key->kind == XS_STRING_KIND) || (key->kind == XS_STRING_X_KIND))
|
|
720
|
+
c_snprintf(the->nameBuffer, sizeof(the->nameBuffer), "%s", key->value.string);
|
|
721
|
+
else
|
|
722
|
+
the->nameBuffer[0] = 0;
|
|
723
|
+
fxConcatStringC(the, slot, "[Symbol(");
|
|
724
|
+
fxConcatStringC(the, slot, the->nameBuffer);
|
|
725
|
+
fxConcatStringC(the, slot, ")]");
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
fxConcatStringC(the, slot, "[Symbol()]");
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
fxNumberToString(the->dtoa, index, the->nameBuffer, sizeof(the->nameBuffer), 0, 0);
|
|
734
|
+
fxConcatStringC(the, slot, "[");
|
|
735
|
+
fxConcatStringC(the, slot, the->nameBuffer);
|
|
736
|
+
fxConcatStringC(the, slot, "]");
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
void fxVerifyInstance(txMachine* the, txSlot* list, txSlot* path, txSlot* instance)
|
|
741
|
+
{
|
|
742
|
+
txSlot* property;
|
|
743
|
+
txSlot* prototype;
|
|
744
|
+
|
|
745
|
+
instance->flag |= XS_LEVEL_FLAG;
|
|
746
|
+
|
|
747
|
+
if (instance->next && (instance->next->ID == XS_ENVIRONMENT_BEHAVIOR)) {
|
|
748
|
+
property = instance->next->next;
|
|
749
|
+
while (property) {
|
|
750
|
+
if ((property->kind == XS_CLOSURE_KIND) && (property->ID != XS_NO_ID)) { // skip private fields initializers
|
|
751
|
+
txSlot* closure = property->value.closure;
|
|
752
|
+
if (!(closure->flag & XS_DONT_SET_FLAG)) {
|
|
753
|
+
fxVerifyError(the, path, property->ID, 0, C_NULL);
|
|
754
|
+
}
|
|
755
|
+
if (closure->kind == XS_REFERENCE_KIND) {
|
|
756
|
+
fxVerifyQueue(the, list, path, closure->value.reference, property->ID, 0, C_NULL);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
property = property->next;
|
|
760
|
+
}
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
if (!(instance->flag & XS_DONT_PATCH_FLAG)) {
|
|
765
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "Extensible");
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
prototype = fxGetPrototype(the, instance);
|
|
769
|
+
if (prototype) {
|
|
770
|
+
fxVerifyQueue(the, list, path, prototype, mxID(___proto__), 0, C_NULL);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
property = instance->next;
|
|
774
|
+
while (property) {
|
|
775
|
+
if (property->flag & XS_INTERNAL_FLAG) {
|
|
776
|
+
switch (property->kind) {
|
|
777
|
+
case XS_ARRAY_KIND:
|
|
778
|
+
{
|
|
779
|
+
txSlot* address = property->value.array.address;
|
|
780
|
+
if (address) {
|
|
781
|
+
txIndex index, offset = 0, size = (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
|
|
782
|
+
while (offset < size) {
|
|
783
|
+
address = property->value.array.address + offset;
|
|
784
|
+
index = *((txIndex*)address);
|
|
785
|
+
fxVerifyPropertyError(the, list, path, address, XS_NO_ID, index);
|
|
786
|
+
address = property->value.array.address + offset;
|
|
787
|
+
if (address->kind == XS_REFERENCE_KIND)
|
|
788
|
+
fxVerifyQueue(the, list, path, address->value.reference, XS_NO_ID, index, C_NULL);
|
|
789
|
+
else if (address->kind == XS_ACCESSOR_KIND) {
|
|
790
|
+
if (address->value.accessor.getter)
|
|
791
|
+
fxVerifyQueue(the, list, path, address->value.accessor.getter, XS_NO_ID, index, C_NULL);
|
|
792
|
+
address = property->value.array.address + offset;
|
|
793
|
+
if (address->value.accessor.setter)
|
|
794
|
+
fxVerifyQueue(the, list, path, address->value.accessor.setter, XS_NO_ID, index, C_NULL);
|
|
795
|
+
}
|
|
796
|
+
offset++;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
break;
|
|
801
|
+
case XS_ARRAY_BUFFER_KIND:
|
|
802
|
+
if (!(property->flag & XS_DONT_SET_FLAG)) {
|
|
803
|
+
if (property->value.arrayBuffer.address != C_NULL)
|
|
804
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "ArrayBufferData");
|
|
805
|
+
}
|
|
806
|
+
break;
|
|
807
|
+
case XS_CODE_KIND:
|
|
808
|
+
case XS_CODE_X_KIND:
|
|
809
|
+
if (property->value.code.closures)
|
|
810
|
+
fxVerifyQueue(the, list, path, property->value.code.closures, XS_NO_ID, 0, "Environment");
|
|
811
|
+
fxVerifyCode(the, list, path, property->value.code.address, ((txChunk*)(((txByte*)(property->value.code.address)) - sizeof(txChunk)))->size);
|
|
812
|
+
break;
|
|
813
|
+
case XS_DATA_VIEW_KIND:
|
|
814
|
+
property = property->next;
|
|
815
|
+
fxVerifyQueue(the, list, path, property->value.reference, XS_NO_ID, 0, "ViewedArrayBuffer");
|
|
816
|
+
break;
|
|
817
|
+
case XS_DATE_KIND:
|
|
818
|
+
if (!(property->flag & XS_DONT_SET_FLAG))
|
|
819
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "DateValue");
|
|
820
|
+
break;
|
|
821
|
+
case XS_REGEXP_KIND:
|
|
822
|
+
break;
|
|
823
|
+
case XS_MAP_KIND:
|
|
824
|
+
if (!(property->flag & XS_DONT_SET_FLAG))
|
|
825
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "MapData");
|
|
826
|
+
break;
|
|
827
|
+
case XS_MODULE_KIND:
|
|
828
|
+
{
|
|
829
|
+
txSlot* exports = mxModuleInstanceExports(instance);
|
|
830
|
+
if (mxIsReference(exports)) {
|
|
831
|
+
txSlot* property = exports->value.reference->next;
|
|
832
|
+
while (property) {
|
|
833
|
+
if (property->value.export.closure) {
|
|
834
|
+
txSlot* closure = property->value.export.closure;
|
|
835
|
+
closure->flag |= XS_DONT_DELETE_FLAG;
|
|
836
|
+
fxVerifyProperty(the, list, path, closure, property->ID);
|
|
837
|
+
closure->flag &= ~XS_DONT_DELETE_FLAG;
|
|
838
|
+
}
|
|
839
|
+
property = property->next;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
break;
|
|
844
|
+
case XS_PRIVATE_KIND:
|
|
845
|
+
{
|
|
846
|
+
txSlot* item = property->value.private.first;
|
|
847
|
+
while (item) {
|
|
848
|
+
fxVerifyProperty(the, list, path, item, item->ID);
|
|
849
|
+
item = item->next;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
break;
|
|
853
|
+
case XS_PROXY_KIND:
|
|
854
|
+
if (property->value.proxy.handler) {
|
|
855
|
+
fxVerifyQueue(the, list, path, property->value.proxy.target, XS_NO_ID, 0, "ProxyHandler");
|
|
856
|
+
}
|
|
857
|
+
if (property->value.proxy.target) {
|
|
858
|
+
fxVerifyQueue(the, list, path, property->value.proxy.target, XS_NO_ID, 0, "ProxyTarget");
|
|
859
|
+
}
|
|
860
|
+
break;
|
|
861
|
+
case XS_SET_KIND:
|
|
862
|
+
if (!(property->flag & XS_DONT_SET_FLAG))
|
|
863
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "SetData");
|
|
864
|
+
break;
|
|
865
|
+
case XS_WEAK_MAP_KIND:
|
|
866
|
+
if (!(property->flag & XS_DONT_SET_FLAG))
|
|
867
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "WeakMapData");
|
|
868
|
+
break;
|
|
869
|
+
case XS_WEAK_SET_KIND:
|
|
870
|
+
if (!(property->flag & XS_DONT_SET_FLAG))
|
|
871
|
+
fxVerifyError(the, path, XS_NO_ID, 0, "WeakSetData");
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
fxVerifyProperty(the, list, path, property, property->ID);
|
|
877
|
+
}
|
|
878
|
+
property = property->next;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
void fxVerifyProperty(txMachine* the, txSlot *list, txSlot *path, txSlot* property, txID id)
|
|
883
|
+
{
|
|
884
|
+
fxVerifyPropertyError(the, list, path, property, id, 0);
|
|
885
|
+
if (property->kind == XS_REFERENCE_KIND)
|
|
886
|
+
fxVerifyQueue(the, list, path, property->value.reference, id, 0, C_NULL);
|
|
887
|
+
else if (property->kind == XS_ACCESSOR_KIND) {
|
|
888
|
+
if (property->value.accessor.getter)
|
|
889
|
+
fxVerifyQueue(the, list, path, property->value.accessor.getter, id, 0, C_NULL);
|
|
890
|
+
if (property->value.accessor.setter)
|
|
891
|
+
fxVerifyQueue(the, list, path, property->value.accessor.setter, id, 0, C_NULL);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
void fxVerifyPropertyError(txMachine* the, txSlot *list, txSlot *path, txSlot* property, txID id, txIndex index)
|
|
896
|
+
{
|
|
897
|
+
txBoolean immutable = 1;
|
|
898
|
+
if (property->kind != XS_ACCESSOR_KIND)
|
|
899
|
+
if (!(property->flag & XS_DONT_SET_FLAG))
|
|
900
|
+
immutable = 0;
|
|
901
|
+
if (!(property->flag & XS_DONT_DELETE_FLAG))
|
|
902
|
+
immutable = 0;
|
|
903
|
+
if (!immutable)
|
|
904
|
+
fxVerifyError(the, path, id, index, C_NULL);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
void fxVerifyQueue(txMachine* the, txSlot* list, txSlot* path, txSlot* instance, txID id, txIndex index, txString string)
|
|
908
|
+
{
|
|
909
|
+
txSlot* item;
|
|
910
|
+
txSlot* name;
|
|
911
|
+
if (instance->kind != XS_INSTANCE_KIND)
|
|
912
|
+
return;
|
|
913
|
+
if (instance->flag & XS_LEVEL_FLAG)
|
|
914
|
+
return;
|
|
915
|
+
item = fxNewSlot(the);
|
|
916
|
+
item->value.list.first = C_NULL;
|
|
917
|
+
item->value.list.last = instance;
|
|
918
|
+
item->kind = XS_LIST_KIND;
|
|
919
|
+
list->value.list.last->next = item;
|
|
920
|
+
list->value.list.last = item;
|
|
921
|
+
|
|
922
|
+
item->value.list.first = name = fxNewSlot(the);
|
|
923
|
+
if (string) {
|
|
924
|
+
name->value.string = string;
|
|
925
|
+
name->kind = XS_STRING_X_KIND;
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
name->value.at.id = id;
|
|
929
|
+
name->value.at.index = index;
|
|
930
|
+
name->kind = XS_AT_KIND;
|
|
931
|
+
}
|
|
932
|
+
name->next = path;
|
|
933
|
+
}
|