@agoric/xsnap 0.14.3-dev-b047af2.0 → 0.14.3-dev-3eb4230.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/api.js +1 -1
- package/package.json +16 -23
- package/src/build.js +4 -61
- package/moddable/modules/data/base64/base64.js +0 -28
- package/moddable/modules/data/base64/manifest.json +0 -11
- package/moddable/modules/data/base64/modBase64.c +0 -188
- package/moddable/modules/data/binaryMessage/BinaryMessage.js +0 -106
- package/moddable/modules/data/crc/crc.c +0 -205
- package/moddable/modules/data/crc/crc.js +0 -36
- package/moddable/modules/data/crc/manifest.json +0 -8
- package/moddable/modules/data/hex/hex.js +0 -28
- package/moddable/modules/data/hex/manifest.json +0 -11
- package/moddable/modules/data/hex/modHex.c +0 -139
- package/moddable/modules/data/logical/logical.js +0 -32
- package/moddable/modules/data/logical/modLogical.c +0 -98
- package/moddable/modules/data/qrcode/manifest.json +0 -9
- package/moddable/modules/data/qrcode/qrcode.c +0 -93
- package/moddable/modules/data/qrcode/qrcode.js +0 -23
- package/moddable/modules/data/qrcode/qrcodegen.c +0 -1025
- package/moddable/modules/data/qrcode/qrcodegen.h +0 -267
- package/moddable/modules/data/text/decoder/manifest.json +0 -8
- package/moddable/modules/data/text/decoder/textdecoder.c +0 -480
- package/moddable/modules/data/text/decoder/textdecoder.js +0 -27
- package/moddable/modules/data/text/encoder/manifest.json +0 -8
- package/moddable/modules/data/text/encoder/textencoder.c +0 -232
- package/moddable/modules/data/text/encoder/textencoder.js +0 -24
- package/moddable/modules/data/tinyint/tinyint.c +0 -150
- package/moddable/modules/data/tinyint/tinyint.js +0 -53
- package/moddable/modules/data/url/manifest.json +0 -17
- package/moddable/modules/data/url/url.c +0 -1959
- package/moddable/modules/data/url/url.js +0 -210
- package/moddable/modules/data/wavreader/manifest.json +0 -8
- package/moddable/modules/data/wavreader/wavreader.js +0 -128
- package/moddable/modules/data/zlib/deflate.c +0 -161
- package/moddable/modules/data/zlib/deflate.js +0 -63
- package/moddable/modules/data/zlib/inflate.c +0 -145
- package/moddable/modules/data/zlib/inflate.js +0 -66
- package/moddable/modules/data/zlib/manifest_deflate.json +0 -9
- package/moddable/modules/data/zlib/manifest_inflate.json +0 -9
- package/moddable/modules/data/zlib/miniz.c +0 -4924
- package/moddable/xs/includes/xs.d.ts +0 -73
- package/moddable/xs/includes/xs.h +0 -1533
- package/moddable/xs/includes/xsmc.h +0 -206
- package/moddable/xs/makefiles/lin/makefile +0 -33
- package/moddable/xs/makefiles/lin/xsc.mk +0 -118
- package/moddable/xs/makefiles/lin/xsid.mk +0 -90
- package/moddable/xs/makefiles/lin/xsl.mk +0 -168
- package/moddable/xs/makefiles/lin/xst.mk +0 -201
- package/moddable/xs/makefiles/mac/makefile +0 -33
- package/moddable/xs/makefiles/mac/xsc.mk +0 -130
- package/moddable/xs/makefiles/mac/xsid.mk +0 -102
- package/moddable/xs/makefiles/mac/xsl.mk +0 -177
- package/moddable/xs/makefiles/mac/xst.mk +0 -203
- package/moddable/xs/makefiles/mac/xst_no_asan.txt +0 -52
- package/moddable/xs/makefiles/win/build.bat +0 -26
- package/moddable/xs/makefiles/win/xsc.mak +0 -142
- package/moddable/xs/makefiles/win/xsid.mak +0 -113
- package/moddable/xs/makefiles/win/xsl.mak +0 -186
- package/moddable/xs/makefiles/win/xst.mak +0 -195
- package/moddable/xs/platforms/lin_xs.h +0 -99
- package/moddable/xs/platforms/mac_xs.h +0 -97
- package/moddable/xs/platforms/wasm_xs.h +0 -79
- package/moddable/xs/platforms/win_xs.h +0 -104
- package/moddable/xs/platforms/xsHost.h +0 -63
- package/moddable/xs/platforms/xsPlatform.h +0 -618
- package/moddable/xs/sources/xsAPI.c +0 -2555
- package/moddable/xs/sources/xsAll.c +0 -294
- package/moddable/xs/sources/xsAll.h +0 -2741
- package/moddable/xs/sources/xsArguments.c +0 -222
- package/moddable/xs/sources/xsArray.c +0 -2657
- package/moddable/xs/sources/xsAtomics.c +0 -844
- package/moddable/xs/sources/xsBigInt.c +0 -1859
- package/moddable/xs/sources/xsBoolean.c +0 -109
- package/moddable/xs/sources/xsCode.c +0 -4493
- package/moddable/xs/sources/xsCommon.c +0 -1710
- package/moddable/xs/sources/xsCommon.h +0 -1142
- package/moddable/xs/sources/xsDataView.c +0 -2890
- package/moddable/xs/sources/xsDate.c +0 -1541
- package/moddable/xs/sources/xsDebug.c +0 -2710
- package/moddable/xs/sources/xsDefaults.c +0 -134
- package/moddable/xs/sources/xsError.c +0 -353
- package/moddable/xs/sources/xsFunction.c +0 -776
- package/moddable/xs/sources/xsGenerator.c +0 -865
- package/moddable/xs/sources/xsGlobal.c +0 -839
- package/moddable/xs/sources/xsJSON.c +0 -1091
- package/moddable/xs/sources/xsLexical.c +0 -1969
- package/moddable/xs/sources/xsLockdown.c +0 -933
- package/moddable/xs/sources/xsMapSet.c +0 -1649
- package/moddable/xs/sources/xsMarshall.c +0 -1020
- package/moddable/xs/sources/xsMath.c +0 -624
- package/moddable/xs/sources/xsMemory.c +0 -1941
- package/moddable/xs/sources/xsModule.c +0 -3101
- package/moddable/xs/sources/xsNumber.c +0 -560
- package/moddable/xs/sources/xsObject.c +0 -1102
- package/moddable/xs/sources/xsPlatforms.c +0 -480
- package/moddable/xs/sources/xsProfile.c +0 -577
- package/moddable/xs/sources/xsPromise.c +0 -1199
- package/moddable/xs/sources/xsProperty.c +0 -636
- package/moddable/xs/sources/xsProxy.c +0 -1014
- package/moddable/xs/sources/xsRegExp.c +0 -1168
- package/moddable/xs/sources/xsRun.c +0 -4889
- package/moddable/xs/sources/xsScope.c +0 -1293
- package/moddable/xs/sources/xsScript.c +0 -288
- package/moddable/xs/sources/xsScript.h +0 -1186
- package/moddable/xs/sources/xsSnapshot.c +0 -2161
- package/moddable/xs/sources/xsSnapshot.h +0 -51
- package/moddable/xs/sources/xsSourceMap.c +0 -218
- package/moddable/xs/sources/xsString.c +0 -3332
- package/moddable/xs/sources/xsSymbol.c +0 -503
- package/moddable/xs/sources/xsSyntaxical.c +0 -4193
- package/moddable/xs/sources/xsTree.c +0 -1893
- package/moddable/xs/sources/xsType.c +0 -1488
- package/moddable/xs/sources/xsdtoa.c +0 -6672
- package/moddable/xs/sources/xsmc.c +0 -340
- package/moddable/xs/sources/xsre.c +0 -7578
- package/xsnap-native/xsnap/makefiles/lin/makefile +0 -10
- package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +0 -153
- package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +0 -144
- package/xsnap-native/xsnap/makefiles/mac/makefile +0 -10
- package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +0 -162
- package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +0 -153
- package/xsnap-native/xsnap/sources/xsnap-worker.c +0 -996
- package/xsnap-native/xsnap/sources/xsnap.c +0 -716
- package/xsnap-native/xsnap/sources/xsnap.h +0 -142
- package/xsnap-native/xsnap/sources/xsnapPlatform.c +0 -1496
- package/xsnap-native/xsnap/sources/xsnapPlatform.h +0 -105
|
@@ -1,636 +0,0 @@
|
|
|
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
|
-
txSlot* fxLastProperty(txMachine* the, txSlot* slot)
|
|
41
|
-
{
|
|
42
|
-
txSlot* property;
|
|
43
|
-
while ((property = slot->next))
|
|
44
|
-
slot = property;
|
|
45
|
-
return slot;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
#ifndef mxLink
|
|
49
|
-
txSlot* fxNextHostAccessorProperty(txMachine* the, txSlot* property, txCallback get, txCallback set, txID id, txFlag flag)
|
|
50
|
-
{
|
|
51
|
-
txSlot *getter = NULL, *setter = NULL, *home = the->stack, *slot;
|
|
52
|
-
if (get) {
|
|
53
|
-
getter = fxBuildHostFunction(the, get, 0, XS_NO_ID);
|
|
54
|
-
slot = mxFunctionInstanceHome(getter);
|
|
55
|
-
slot->value.home.object = home->value.reference;
|
|
56
|
-
fxRenameFunction(the, getter, id, 0, XS_NO_ID, "get ");
|
|
57
|
-
}
|
|
58
|
-
if (set) {
|
|
59
|
-
setter = fxBuildHostFunction(the, set, 1, XS_NO_ID);
|
|
60
|
-
slot = mxFunctionInstanceHome(setter);
|
|
61
|
-
slot->value.home.object = home->value.reference;
|
|
62
|
-
fxRenameFunction(the, setter, id, 0, XS_NO_ID, "set ");
|
|
63
|
-
}
|
|
64
|
-
property = property->next = fxNewSlot(the);
|
|
65
|
-
property->flag = flag;
|
|
66
|
-
property->ID = id;
|
|
67
|
-
property->kind = XS_ACCESSOR_KIND;
|
|
68
|
-
property->value.accessor.getter = getter;
|
|
69
|
-
property->value.accessor.setter = setter;
|
|
70
|
-
if (set)
|
|
71
|
-
mxPop();
|
|
72
|
-
if (get)
|
|
73
|
-
mxPop();
|
|
74
|
-
return property;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
txSlot* fxNextHostFunctionProperty(txMachine* the, txSlot* property, txCallback call, txInteger length, txID id, txFlag flag)
|
|
78
|
-
{
|
|
79
|
-
txSlot *function, *home = the->stack, *slot;
|
|
80
|
-
function = fxNewHostFunction(the, call, length, id, XS_NO_ID);
|
|
81
|
-
slot = mxFunctionInstanceHome(function);
|
|
82
|
-
slot->value.home.object = home->value.reference;
|
|
83
|
-
property = property->next = fxNewSlot(the);
|
|
84
|
-
property->flag = flag;
|
|
85
|
-
property->ID = id;
|
|
86
|
-
property->kind = the->stack->kind;
|
|
87
|
-
property->value = the->stack->value;
|
|
88
|
-
mxPop();
|
|
89
|
-
return property;
|
|
90
|
-
}
|
|
91
|
-
#endif
|
|
92
|
-
|
|
93
|
-
txSlot* fxNextUndefinedProperty(txMachine* the, txSlot* property, txID id, txFlag flag)
|
|
94
|
-
{
|
|
95
|
-
property = property->next = fxNewSlot(the);
|
|
96
|
-
property->flag = flag;
|
|
97
|
-
property->ID = id;
|
|
98
|
-
property->kind = XS_UNDEFINED_KIND;
|
|
99
|
-
return property;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
txSlot* fxNextNullProperty(txMachine* the, txSlot* property, txID id, txFlag flag)
|
|
103
|
-
{
|
|
104
|
-
property = property->next = fxNewSlot(the);
|
|
105
|
-
property->flag = flag;
|
|
106
|
-
property->ID = id;
|
|
107
|
-
property->kind = XS_NULL_KIND;
|
|
108
|
-
return property;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
txSlot* fxNextBooleanProperty(txMachine* the, txSlot* property, txBoolean boolean, txID id, txFlag flag)
|
|
112
|
-
{
|
|
113
|
-
property = property->next = fxNewSlot(the);
|
|
114
|
-
property->flag = flag;
|
|
115
|
-
property->ID = id;
|
|
116
|
-
property->kind = XS_BOOLEAN_KIND;
|
|
117
|
-
property->value.boolean = boolean;
|
|
118
|
-
return property;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
txSlot* fxNextIntegerProperty(txMachine* the, txSlot* property, txInteger integer, txID id, txFlag flag)
|
|
122
|
-
{
|
|
123
|
-
property = property->next = fxNewSlot(the);
|
|
124
|
-
property->flag = flag;
|
|
125
|
-
property->ID = id;
|
|
126
|
-
property->kind = XS_INTEGER_KIND;
|
|
127
|
-
property->value.integer = integer;
|
|
128
|
-
return property;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
txSlot* fxNextNumberProperty(txMachine* the, txSlot* property, txNumber number, txID id, txFlag flag)
|
|
132
|
-
{
|
|
133
|
-
property = property->next = fxNewSlot(the);
|
|
134
|
-
property->flag = flag;
|
|
135
|
-
property->ID = id;
|
|
136
|
-
property->kind = XS_NUMBER_KIND;
|
|
137
|
-
property->value.number = number;
|
|
138
|
-
return property;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
txSlot* fxNextReferenceProperty(txMachine* the, txSlot* property, txSlot* slot, txID id, txFlag flag)
|
|
142
|
-
{
|
|
143
|
-
property = property->next = fxNewSlot(the);
|
|
144
|
-
property->flag = flag;
|
|
145
|
-
property->ID = id;
|
|
146
|
-
property->kind = XS_REFERENCE_KIND;
|
|
147
|
-
property->value.reference = slot;
|
|
148
|
-
return property;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
txSlot* fxNextSlotProperty(txMachine* the, txSlot* property, txSlot* slot, txID id, txFlag flag)
|
|
152
|
-
{
|
|
153
|
-
property = property->next = fxNewSlot(the);
|
|
154
|
-
property->flag = flag;
|
|
155
|
-
property->ID = id;
|
|
156
|
-
property->kind = slot->kind;
|
|
157
|
-
property->value = slot->value;
|
|
158
|
-
return property;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
txSlot* fxNextStringProperty(txMachine* the, txSlot* property, txString string, txID id, txFlag flag)
|
|
162
|
-
{
|
|
163
|
-
property = property->next = fxNewSlot(the);
|
|
164
|
-
property->flag = flag;
|
|
165
|
-
property->ID = id;
|
|
166
|
-
fxCopyStringC(the, property, string);
|
|
167
|
-
return property;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
txSlot* fxNextStringXProperty(txMachine* the, txSlot* property, txString string, txID id, txFlag flag)
|
|
171
|
-
{
|
|
172
|
-
property = property->next = fxNewSlot(the);
|
|
173
|
-
property->flag = flag;
|
|
174
|
-
property->ID = id;
|
|
175
|
-
#ifdef mxSnapshot
|
|
176
|
-
fxCopyStringC(the, property, string);
|
|
177
|
-
#else
|
|
178
|
-
property->kind = XS_STRING_X_KIND;
|
|
179
|
-
property->value.string = string;
|
|
180
|
-
#endif
|
|
181
|
-
return property;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
txSlot* fxNextSymbolProperty(txMachine* the, txSlot* property, txID symbol, txID id, txFlag flag)
|
|
186
|
-
{
|
|
187
|
-
property = property->next = fxNewSlot(the);
|
|
188
|
-
property->flag = flag;
|
|
189
|
-
property->ID = id;
|
|
190
|
-
property->kind = XS_SYMBOL_KIND;
|
|
191
|
-
property->value.symbol = symbol;
|
|
192
|
-
return property;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
txSlot* fxNextTypeDispatchProperty(txMachine* the, txSlot* property, txTypeDispatch* dispatch, txTypeAtomics* atomics, txID id, txFlag flag)
|
|
196
|
-
{
|
|
197
|
-
property = property->next = fxNewSlot(the);
|
|
198
|
-
property->flag = flag;
|
|
199
|
-
property->ID = id;
|
|
200
|
-
property->kind = XS_TYPED_ARRAY_KIND;
|
|
201
|
-
property->value.typedArray.dispatch = dispatch;
|
|
202
|
-
property->value.typedArray.atomics = atomics;
|
|
203
|
-
return property;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
txSlot* fxQueueKey(txMachine* the, txID id, txIndex index, txSlot* keys)
|
|
207
|
-
{
|
|
208
|
-
keys = keys->next = fxNewSlot(the);
|
|
209
|
-
keys->kind = XS_AT_KIND;
|
|
210
|
-
keys->value.at.id = id;
|
|
211
|
-
keys->value.at.index = index;
|
|
212
|
-
return keys;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
txSlot* fxQueueIDKeys(txMachine* the, txSlot* first, txFlag flag, txSlot* keys)
|
|
216
|
-
{
|
|
217
|
-
if (flag & XS_EACH_NAME_FLAG) {
|
|
218
|
-
txSlot* property = first;
|
|
219
|
-
while (property) {
|
|
220
|
-
if (!(property->flag & XS_INTERNAL_FLAG) && fxIsKeyName(the, property->ID))
|
|
221
|
-
keys = fxQueueKey(the, property->ID, 0, keys);
|
|
222
|
-
property = property->next;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
if (flag & XS_EACH_SYMBOL_FLAG) {
|
|
226
|
-
txSlot* property = first;
|
|
227
|
-
while (property) {
|
|
228
|
-
if (!(property->flag & XS_INTERNAL_FLAG) && fxIsKeySymbol(the, property->ID))
|
|
229
|
-
keys = fxQueueKey(the, property->ID, 0, keys);
|
|
230
|
-
property = property->next;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return keys;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// INDEX
|
|
237
|
-
|
|
238
|
-
static txSize fxSizeToCapacity(txMachine* the, txSize size)
|
|
239
|
-
{
|
|
240
|
-
return fxAddChunkSizes(the, size, size / 3);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
txBoolean fxDeleteIndexProperty(txMachine* the, txSlot* array, txIndex index)
|
|
244
|
-
{
|
|
245
|
-
txSlot* address = array->value.array.address;
|
|
246
|
-
if (address) {
|
|
247
|
-
txIndex length = array->value.array.length;
|
|
248
|
-
txIndex size = (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
|
|
249
|
-
txSlot* result = address;
|
|
250
|
-
txSlot* limit = result + size;
|
|
251
|
-
if (length == size)
|
|
252
|
-
result = address + index;
|
|
253
|
-
else {
|
|
254
|
-
txIndex at;
|
|
255
|
-
while (result < limit) {
|
|
256
|
-
at = *((txIndex*)result);
|
|
257
|
-
if (at == index)
|
|
258
|
-
break;
|
|
259
|
-
if (at > index)
|
|
260
|
-
return 1;
|
|
261
|
-
result++;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (result < limit) {
|
|
265
|
-
if (result->flag & XS_DONT_DELETE_FLAG)
|
|
266
|
-
return 0;
|
|
267
|
-
index = (txIndex)(result - address);
|
|
268
|
-
size--;
|
|
269
|
-
if (size > 0) {
|
|
270
|
-
txSlot* chunk = (txSlot*)fxNewChunk(the, size * sizeof(txSlot));
|
|
271
|
-
address = array->value.array.address;
|
|
272
|
-
if (index > 0)
|
|
273
|
-
c_memcpy(chunk, address, index * sizeof(txSlot));
|
|
274
|
-
if (index < size)
|
|
275
|
-
c_memcpy(chunk + index, address + index + 1, (size - index) * sizeof(txSlot));
|
|
276
|
-
array->value.array.address = chunk;
|
|
277
|
-
}
|
|
278
|
-
else
|
|
279
|
-
array->value.array.address = C_NULL;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return 1;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
txSlot* fxGetIndexProperty(txMachine* the, txSlot* array, txIndex index)
|
|
286
|
-
{
|
|
287
|
-
txSlot* address = array->value.array.address;
|
|
288
|
-
if (address) {
|
|
289
|
-
txIndex length = array->value.array.length;
|
|
290
|
-
txIndex size = (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
|
|
291
|
-
if (length == size) {
|
|
292
|
-
if (index < length)
|
|
293
|
-
return address + index;
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
txSlot* result = address;
|
|
297
|
-
txSlot* limit = result + size;
|
|
298
|
-
txIndex at;
|
|
299
|
-
while (result < limit) {
|
|
300
|
-
at = *((txIndex*)result);
|
|
301
|
-
if (at == index)
|
|
302
|
-
return result;
|
|
303
|
-
result++;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return C_NULL;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
txIndex fxGetIndexSize(txMachine* the, txSlot* array)
|
|
311
|
-
{
|
|
312
|
-
txSlot* address = array->value.array.address;
|
|
313
|
-
if (address)
|
|
314
|
-
return (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot);
|
|
315
|
-
return 0;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
txSlot* fxQueueIndexKeys(txMachine* the, txSlot* array, txFlag flag, txSlot* keys)
|
|
319
|
-
{
|
|
320
|
-
if (flag & XS_EACH_NAME_FLAG) {
|
|
321
|
-
if (array->value.array.address) {
|
|
322
|
-
txSize offset = 0;
|
|
323
|
-
txSize size = (((txChunk*)(((txByte*)array->value.array.address) - sizeof(txChunk)))->size) / sizeof(txSlot);
|
|
324
|
-
while (offset < size) {
|
|
325
|
-
txSlot* slot = array->value.array.address + offset;
|
|
326
|
-
txIndex index = *((txIndex*)slot);
|
|
327
|
-
keys = fxQueueKey(the, 0, index, keys);
|
|
328
|
-
offset++;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
return keys;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
txSlot* fxSetIndexProperty(txMachine* the, txSlot* instance, txSlot* array, txIndex index)
|
|
336
|
-
{
|
|
337
|
-
txSlot* address = array->value.array.address;
|
|
338
|
-
txSlot* chunk = address;
|
|
339
|
-
txIndex length = array->value.array.length;
|
|
340
|
-
txIndex current;
|
|
341
|
-
txSize size;
|
|
342
|
-
txSlot* result;
|
|
343
|
-
txSlot* limit;
|
|
344
|
-
txIndex at;
|
|
345
|
-
if (address) {
|
|
346
|
-
current = (((txChunk*)(((txByte*)chunk) - sizeof(txChunk)))->size) / sizeof(txSlot);
|
|
347
|
-
if (length == current) {
|
|
348
|
-
if (index < length)
|
|
349
|
-
return address + index;
|
|
350
|
-
if (instance->flag & XS_DONT_PATCH_FLAG)
|
|
351
|
-
return C_NULL;
|
|
352
|
-
if (array->flag & XS_DONT_SET_FLAG)
|
|
353
|
-
return C_NULL;
|
|
354
|
-
current++;
|
|
355
|
-
size = fxMultiplyChunkSizes(the, current, sizeof(txSlot));
|
|
356
|
-
chunk = (txSlot*)fxRenewChunk(the, address, size);
|
|
357
|
-
if (!chunk) {
|
|
358
|
-
#ifndef mxNoArrayOverallocation
|
|
359
|
-
if (array->ID == XS_ARRAY_BEHAVIOR) {
|
|
360
|
-
txSize capacity = fxSizeToCapacity(the, size);
|
|
361
|
-
chunk = (txSlot*)fxNewGrowableChunk(the, size, capacity);
|
|
362
|
-
}
|
|
363
|
-
else
|
|
364
|
-
#endif
|
|
365
|
-
chunk = (txSlot*)fxNewChunk(the, size);
|
|
366
|
-
address = array->value.array.address;
|
|
367
|
-
c_memcpy(chunk, address, length * sizeof(txSlot));
|
|
368
|
-
}
|
|
369
|
-
result = chunk + length;
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
result = address;
|
|
373
|
-
limit = result + current;
|
|
374
|
-
while (result < limit) {
|
|
375
|
-
at = *((txIndex*)result);
|
|
376
|
-
if (at == index)
|
|
377
|
-
return result;
|
|
378
|
-
if (at > index)
|
|
379
|
-
break;
|
|
380
|
-
result++;
|
|
381
|
-
}
|
|
382
|
-
if (instance->flag & XS_DONT_PATCH_FLAG)
|
|
383
|
-
return C_NULL;
|
|
384
|
-
if ((array->flag & XS_DONT_SET_FLAG) && (index >= length))
|
|
385
|
-
return C_NULL;
|
|
386
|
-
at = mxPtrDiff(result - address);
|
|
387
|
-
current++;
|
|
388
|
-
size = fxMultiplyChunkSizes(the, current, sizeof(txSlot));
|
|
389
|
-
chunk = (txSlot*)fxNewChunk(the, size);
|
|
390
|
-
address = array->value.array.address;
|
|
391
|
-
result = address + at;
|
|
392
|
-
limit = address + current - 1;
|
|
393
|
-
if (result > address)
|
|
394
|
-
c_memcpy(chunk, address, (result - address) * sizeof(txSlot));
|
|
395
|
-
if (result < limit)
|
|
396
|
-
c_memcpy(chunk + (result - address) + 1, result, (limit - result) * sizeof(txSlot));
|
|
397
|
-
result = chunk + (result - address);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
if (instance->flag & XS_DONT_PATCH_FLAG)
|
|
402
|
-
return C_NULL;
|
|
403
|
-
if ((array->flag & XS_DONT_SET_FLAG) && (index >= length))
|
|
404
|
-
return C_NULL;
|
|
405
|
-
current = 1;
|
|
406
|
-
chunk = (txSlot*)fxNewChunk(the, sizeof(txSlot));
|
|
407
|
-
result = chunk;
|
|
408
|
-
}
|
|
409
|
-
result->next = C_NULL;
|
|
410
|
-
result->ID = XS_NO_ID;
|
|
411
|
-
result->flag = XS_NO_FLAG;
|
|
412
|
-
result->kind = XS_UNDEFINED_KIND;
|
|
413
|
-
*((txIndex*)result) = index;
|
|
414
|
-
array->value.array.address = chunk;
|
|
415
|
-
if (index >= length) {
|
|
416
|
-
array->value.array.length = index + 1;
|
|
417
|
-
}
|
|
418
|
-
return result;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
void fxSetIndexSize(txMachine* the, txSlot* array, txIndex target, txBoolean growable)
|
|
422
|
-
{
|
|
423
|
-
txSlot* address = array->value.array.address;
|
|
424
|
-
txSlot* chunk = C_NULL;
|
|
425
|
-
txIndex current = (address) ? (((txChunk*)(((txByte*)address) - sizeof(txChunk)))->size) / sizeof(txSlot) : 0;
|
|
426
|
-
txSize size;
|
|
427
|
-
if (current != target) {
|
|
428
|
-
if (array->flag & XS_DONT_SET_FLAG)
|
|
429
|
-
mxTypeError("set length: not writable");
|
|
430
|
-
size = fxMultiplyChunkSizes(the, target, sizeof(txSlot));
|
|
431
|
-
if (address) {
|
|
432
|
-
if (target) {
|
|
433
|
-
chunk = (txSlot*)fxRenewChunk(the, address, size);
|
|
434
|
-
if (!chunk) {
|
|
435
|
-
#ifndef mxNoArrayOverallocation
|
|
436
|
-
if (growable) {
|
|
437
|
-
txSize capacity = fxSizeToCapacity(the, size);
|
|
438
|
-
chunk = (txSlot*)fxNewGrowableChunk(the, size, capacity);
|
|
439
|
-
}
|
|
440
|
-
else
|
|
441
|
-
#endif
|
|
442
|
-
chunk = (txSlot*)fxNewChunk(the, size);
|
|
443
|
-
address = array->value.array.address;
|
|
444
|
-
if (current < target)
|
|
445
|
-
c_memcpy(chunk, address, current * sizeof(txSlot));
|
|
446
|
-
else
|
|
447
|
-
c_memcpy(chunk, address, size);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
#ifndef mxNoArrayOverallocation
|
|
453
|
-
if (growable) {
|
|
454
|
-
txSize capacity = fxSizeToCapacity(the, size);
|
|
455
|
-
chunk = (txSlot*)fxNewGrowableChunk(the, size, capacity);
|
|
456
|
-
}
|
|
457
|
-
else
|
|
458
|
-
#endif
|
|
459
|
-
chunk = (txSlot*)fxNewChunk(the, size);
|
|
460
|
-
}
|
|
461
|
-
if (current < target)
|
|
462
|
-
c_memset(chunk + current, 0, (target - current) * sizeof(txSlot));
|
|
463
|
-
array->value.array.length = target;
|
|
464
|
-
array->value.array.address = chunk;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
txBoolean fxDefinePrivateProperty(txMachine* the, txSlot* instance, txSlot* check, txID id, txSlot* slot, txFlag mask)
|
|
469
|
-
{
|
|
470
|
-
txSlot** address;
|
|
471
|
-
txSlot* property;
|
|
472
|
-
mxCheck(the, instance->kind == XS_INSTANCE_KIND);
|
|
473
|
-
address = &(instance->next);
|
|
474
|
-
while ((property = *address)) {
|
|
475
|
-
if (!(property->flag & XS_INTERNAL_FLAG)) {
|
|
476
|
-
property = C_NULL;
|
|
477
|
-
break;
|
|
478
|
-
}
|
|
479
|
-
if (property->kind == XS_PRIVATE_KIND) {
|
|
480
|
-
if (property->value.private.check == check) {
|
|
481
|
-
break;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
address = &(property->next);
|
|
485
|
-
}
|
|
486
|
-
if (!property) {
|
|
487
|
-
property = fxNewSlot(the);
|
|
488
|
-
property->next = *address;
|
|
489
|
-
property->flag = XS_INTERNAL_FLAG;
|
|
490
|
-
property->kind = XS_PRIVATE_KIND;
|
|
491
|
-
property->value.private.check = check;
|
|
492
|
-
property->value.private.first = C_NULL;
|
|
493
|
-
*address = property;
|
|
494
|
-
}
|
|
495
|
-
address = &(property->value.private.first);
|
|
496
|
-
while ((property = *address)) {
|
|
497
|
-
if (property->ID == id)
|
|
498
|
-
break;
|
|
499
|
-
address = &(property->next);
|
|
500
|
-
}
|
|
501
|
-
if (mask & XS_ACCESSOR_FLAG) {
|
|
502
|
-
if (property) {
|
|
503
|
-
if (property->kind != XS_ACCESSOR_KIND)
|
|
504
|
-
return 0;
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
*address = property = fxNewSlot(the);
|
|
508
|
-
property->ID = id;
|
|
509
|
-
property->kind = XS_ACCESSOR_KIND;
|
|
510
|
-
property->value.accessor.getter = C_NULL;
|
|
511
|
-
property->value.accessor.setter = C_NULL;
|
|
512
|
-
}
|
|
513
|
-
if (mask & XS_GETTER_FLAG) {
|
|
514
|
-
txSlot* function = slot->value.accessor.getter;
|
|
515
|
-
if (property->value.accessor.getter)
|
|
516
|
-
return 0;
|
|
517
|
-
property->value.accessor.getter = function;
|
|
518
|
-
if (mxIsFunction(function)) {
|
|
519
|
-
if (((mask & XS_METHOD_FLAG) && (function->flag & XS_MARK_FLAG) == 0)) {
|
|
520
|
-
txSlot* home = mxFunctionInstanceHome(function);
|
|
521
|
-
home->value.home.object = instance;
|
|
522
|
-
}
|
|
523
|
-
if ((mask & XS_NAME_FLAG) && ((function->flag & XS_MARK_FLAG) == 0))
|
|
524
|
-
fxRenameFunction(the, function, id, 0, mxID(_get), "get ");
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
txSlot* function = slot->value.accessor.setter;
|
|
529
|
-
if (property->value.accessor.setter)
|
|
530
|
-
return 0;
|
|
531
|
-
property->value.accessor.setter = function;
|
|
532
|
-
if (mxIsFunction(function)) {
|
|
533
|
-
if (((mask & XS_METHOD_FLAG) && (function->flag & XS_MARK_FLAG) == 0)) {
|
|
534
|
-
txSlot* home = mxFunctionInstanceHome(function);
|
|
535
|
-
home->value.home.object = instance;
|
|
536
|
-
}
|
|
537
|
-
if ((mask & XS_NAME_FLAG) && ((function->flag & XS_MARK_FLAG) == 0))
|
|
538
|
-
fxRenameFunction(the, function, id, 0, mxID(_set), "set ");
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
if (property)
|
|
544
|
-
return 0;
|
|
545
|
-
*address = property = fxNewSlot(the);
|
|
546
|
-
property->flag = (mask & XS_METHOD_FLAG) ? XS_DONT_SET_FLAG : XS_NO_FLAG;
|
|
547
|
-
property->ID = id;
|
|
548
|
-
property->kind = slot->kind;
|
|
549
|
-
property->value = slot->value;
|
|
550
|
-
if (property->kind == XS_REFERENCE_KIND) {
|
|
551
|
-
txSlot* function = slot->value.reference;
|
|
552
|
-
if (mxIsFunction(function)) {
|
|
553
|
-
if ((mask & XS_METHOD_FLAG) && ((function->flag & XS_MARK_FLAG) == 0)) {
|
|
554
|
-
txSlot* home = mxFunctionInstanceHome(function);
|
|
555
|
-
home->value.home.object = instance;
|
|
556
|
-
}
|
|
557
|
-
if ((mask & XS_NAME_FLAG) && ((function->flag & XS_MARK_FLAG) == 0))
|
|
558
|
-
fxRenameFunction(the, function, id, 0, mxID(_value), C_NULL);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
return 1;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
txSlot* fxGetPrivateProperty(txMachine* the, txSlot* instance, txSlot* check, txID id)
|
|
566
|
-
{
|
|
567
|
-
txSlot* result;
|
|
568
|
-
mxCheck(the, instance->kind == XS_INSTANCE_KIND);
|
|
569
|
-
if (instance->ID) {
|
|
570
|
-
txSlot* alias = the->aliasArray[instance->ID];
|
|
571
|
-
if (alias)
|
|
572
|
-
instance = alias;
|
|
573
|
-
}
|
|
574
|
-
result = instance->next;
|
|
575
|
-
while (result) {
|
|
576
|
-
if (result->kind == XS_PRIVATE_KIND) {
|
|
577
|
-
if (result->value.private.check == check)
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
580
|
-
result = result->next;
|
|
581
|
-
}
|
|
582
|
-
if (result) {
|
|
583
|
-
result = result->value.private.first;
|
|
584
|
-
while (result) {
|
|
585
|
-
if (result->ID == id)
|
|
586
|
-
break;
|
|
587
|
-
result = result->next;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
if (result) {
|
|
591
|
-
if ((result->kind == XS_ACCESSOR_KIND) && (result->value.accessor.getter == C_NULL))
|
|
592
|
-
result = C_NULL;
|
|
593
|
-
}
|
|
594
|
-
return result;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
txSlot* fxSetPrivateProperty(txMachine* the, txSlot* instance, txSlot* check, txID id)
|
|
598
|
-
{
|
|
599
|
-
txSlot* result;
|
|
600
|
-
mxCheck(the, instance->kind == XS_INSTANCE_KIND);
|
|
601
|
-
if (instance->ID) {
|
|
602
|
-
txSlot* alias = the->aliasArray[instance->ID];
|
|
603
|
-
if (alias)
|
|
604
|
-
instance = alias;
|
|
605
|
-
else
|
|
606
|
-
instance = fxAliasInstance(the, instance);
|
|
607
|
-
}
|
|
608
|
-
result = instance->next;
|
|
609
|
-
while (result) {
|
|
610
|
-
if (result->kind == XS_PRIVATE_KIND) {
|
|
611
|
-
if (result->value.private.check == check)
|
|
612
|
-
break;
|
|
613
|
-
}
|
|
614
|
-
result = result->next;
|
|
615
|
-
}
|
|
616
|
-
if (result) {
|
|
617
|
-
result = result->value.private.first;
|
|
618
|
-
while (result) {
|
|
619
|
-
if (result->ID == id)
|
|
620
|
-
break;
|
|
621
|
-
result = result->next;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
if (result) {
|
|
625
|
-
if ((result->kind == XS_ACCESSOR_KIND) && (result->value.accessor.setter == C_NULL))
|
|
626
|
-
result = C_NULL;
|
|
627
|
-
}
|
|
628
|
-
return result;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|