@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.
Files changed (126) hide show
  1. package/api.js +1 -1
  2. package/package.json +16 -23
  3. package/src/build.js +4 -61
  4. package/moddable/modules/data/base64/base64.js +0 -28
  5. package/moddable/modules/data/base64/manifest.json +0 -11
  6. package/moddable/modules/data/base64/modBase64.c +0 -188
  7. package/moddable/modules/data/binaryMessage/BinaryMessage.js +0 -106
  8. package/moddable/modules/data/crc/crc.c +0 -205
  9. package/moddable/modules/data/crc/crc.js +0 -36
  10. package/moddable/modules/data/crc/manifest.json +0 -8
  11. package/moddable/modules/data/hex/hex.js +0 -28
  12. package/moddable/modules/data/hex/manifest.json +0 -11
  13. package/moddable/modules/data/hex/modHex.c +0 -139
  14. package/moddable/modules/data/logical/logical.js +0 -32
  15. package/moddable/modules/data/logical/modLogical.c +0 -98
  16. package/moddable/modules/data/qrcode/manifest.json +0 -9
  17. package/moddable/modules/data/qrcode/qrcode.c +0 -93
  18. package/moddable/modules/data/qrcode/qrcode.js +0 -23
  19. package/moddable/modules/data/qrcode/qrcodegen.c +0 -1025
  20. package/moddable/modules/data/qrcode/qrcodegen.h +0 -267
  21. package/moddable/modules/data/text/decoder/manifest.json +0 -8
  22. package/moddable/modules/data/text/decoder/textdecoder.c +0 -480
  23. package/moddable/modules/data/text/decoder/textdecoder.js +0 -27
  24. package/moddable/modules/data/text/encoder/manifest.json +0 -8
  25. package/moddable/modules/data/text/encoder/textencoder.c +0 -232
  26. package/moddable/modules/data/text/encoder/textencoder.js +0 -24
  27. package/moddable/modules/data/tinyint/tinyint.c +0 -150
  28. package/moddable/modules/data/tinyint/tinyint.js +0 -53
  29. package/moddable/modules/data/url/manifest.json +0 -17
  30. package/moddable/modules/data/url/url.c +0 -1959
  31. package/moddable/modules/data/url/url.js +0 -210
  32. package/moddable/modules/data/wavreader/manifest.json +0 -8
  33. package/moddable/modules/data/wavreader/wavreader.js +0 -128
  34. package/moddable/modules/data/zlib/deflate.c +0 -161
  35. package/moddable/modules/data/zlib/deflate.js +0 -63
  36. package/moddable/modules/data/zlib/inflate.c +0 -145
  37. package/moddable/modules/data/zlib/inflate.js +0 -66
  38. package/moddable/modules/data/zlib/manifest_deflate.json +0 -9
  39. package/moddable/modules/data/zlib/manifest_inflate.json +0 -9
  40. package/moddable/modules/data/zlib/miniz.c +0 -4924
  41. package/moddable/xs/includes/xs.d.ts +0 -73
  42. package/moddable/xs/includes/xs.h +0 -1533
  43. package/moddable/xs/includes/xsmc.h +0 -206
  44. package/moddable/xs/makefiles/lin/makefile +0 -33
  45. package/moddable/xs/makefiles/lin/xsc.mk +0 -118
  46. package/moddable/xs/makefiles/lin/xsid.mk +0 -90
  47. package/moddable/xs/makefiles/lin/xsl.mk +0 -168
  48. package/moddable/xs/makefiles/lin/xst.mk +0 -201
  49. package/moddable/xs/makefiles/mac/makefile +0 -33
  50. package/moddable/xs/makefiles/mac/xsc.mk +0 -130
  51. package/moddable/xs/makefiles/mac/xsid.mk +0 -102
  52. package/moddable/xs/makefiles/mac/xsl.mk +0 -177
  53. package/moddable/xs/makefiles/mac/xst.mk +0 -203
  54. package/moddable/xs/makefiles/mac/xst_no_asan.txt +0 -52
  55. package/moddable/xs/makefiles/win/build.bat +0 -26
  56. package/moddable/xs/makefiles/win/xsc.mak +0 -142
  57. package/moddable/xs/makefiles/win/xsid.mak +0 -113
  58. package/moddable/xs/makefiles/win/xsl.mak +0 -186
  59. package/moddable/xs/makefiles/win/xst.mak +0 -195
  60. package/moddable/xs/platforms/lin_xs.h +0 -99
  61. package/moddable/xs/platforms/mac_xs.h +0 -97
  62. package/moddable/xs/platforms/wasm_xs.h +0 -79
  63. package/moddable/xs/platforms/win_xs.h +0 -104
  64. package/moddable/xs/platforms/xsHost.h +0 -63
  65. package/moddable/xs/platforms/xsPlatform.h +0 -618
  66. package/moddable/xs/sources/xsAPI.c +0 -2555
  67. package/moddable/xs/sources/xsAll.c +0 -294
  68. package/moddable/xs/sources/xsAll.h +0 -2741
  69. package/moddable/xs/sources/xsArguments.c +0 -222
  70. package/moddable/xs/sources/xsArray.c +0 -2657
  71. package/moddable/xs/sources/xsAtomics.c +0 -844
  72. package/moddable/xs/sources/xsBigInt.c +0 -1859
  73. package/moddable/xs/sources/xsBoolean.c +0 -109
  74. package/moddable/xs/sources/xsCode.c +0 -4493
  75. package/moddable/xs/sources/xsCommon.c +0 -1710
  76. package/moddable/xs/sources/xsCommon.h +0 -1142
  77. package/moddable/xs/sources/xsDataView.c +0 -2890
  78. package/moddable/xs/sources/xsDate.c +0 -1541
  79. package/moddable/xs/sources/xsDebug.c +0 -2710
  80. package/moddable/xs/sources/xsDefaults.c +0 -134
  81. package/moddable/xs/sources/xsError.c +0 -353
  82. package/moddable/xs/sources/xsFunction.c +0 -776
  83. package/moddable/xs/sources/xsGenerator.c +0 -865
  84. package/moddable/xs/sources/xsGlobal.c +0 -839
  85. package/moddable/xs/sources/xsJSON.c +0 -1091
  86. package/moddable/xs/sources/xsLexical.c +0 -1969
  87. package/moddable/xs/sources/xsLockdown.c +0 -933
  88. package/moddable/xs/sources/xsMapSet.c +0 -1649
  89. package/moddable/xs/sources/xsMarshall.c +0 -1020
  90. package/moddable/xs/sources/xsMath.c +0 -624
  91. package/moddable/xs/sources/xsMemory.c +0 -1941
  92. package/moddable/xs/sources/xsModule.c +0 -3101
  93. package/moddable/xs/sources/xsNumber.c +0 -560
  94. package/moddable/xs/sources/xsObject.c +0 -1102
  95. package/moddable/xs/sources/xsPlatforms.c +0 -480
  96. package/moddable/xs/sources/xsProfile.c +0 -577
  97. package/moddable/xs/sources/xsPromise.c +0 -1199
  98. package/moddable/xs/sources/xsProperty.c +0 -636
  99. package/moddable/xs/sources/xsProxy.c +0 -1014
  100. package/moddable/xs/sources/xsRegExp.c +0 -1168
  101. package/moddable/xs/sources/xsRun.c +0 -4889
  102. package/moddable/xs/sources/xsScope.c +0 -1293
  103. package/moddable/xs/sources/xsScript.c +0 -288
  104. package/moddable/xs/sources/xsScript.h +0 -1186
  105. package/moddable/xs/sources/xsSnapshot.c +0 -2161
  106. package/moddable/xs/sources/xsSnapshot.h +0 -51
  107. package/moddable/xs/sources/xsSourceMap.c +0 -218
  108. package/moddable/xs/sources/xsString.c +0 -3332
  109. package/moddable/xs/sources/xsSymbol.c +0 -503
  110. package/moddable/xs/sources/xsSyntaxical.c +0 -4193
  111. package/moddable/xs/sources/xsTree.c +0 -1893
  112. package/moddable/xs/sources/xsType.c +0 -1488
  113. package/moddable/xs/sources/xsdtoa.c +0 -6672
  114. package/moddable/xs/sources/xsmc.c +0 -340
  115. package/moddable/xs/sources/xsre.c +0 -7578
  116. package/xsnap-native/xsnap/makefiles/lin/makefile +0 -10
  117. package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +0 -153
  118. package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +0 -144
  119. package/xsnap-native/xsnap/makefiles/mac/makefile +0 -10
  120. package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +0 -162
  121. package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +0 -153
  122. package/xsnap-native/xsnap/sources/xsnap-worker.c +0 -996
  123. package/xsnap-native/xsnap/sources/xsnap.c +0 -716
  124. package/xsnap-native/xsnap/sources/xsnap.h +0 -142
  125. package/xsnap-native/xsnap/sources/xsnapPlatform.c +0 -1496
  126. package/xsnap-native/xsnap/sources/xsnapPlatform.h +0 -105
@@ -1,1102 +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
- void fxBuildObject(txMachine* the)
41
- {
42
- txSlot* slot;
43
- fxNewHostFunction(the, mxCallback(fx_Object_assign), 2, XS_NO_ID, XS_NO_ID);
44
- mxAssignObjectFunction = *the->stack;
45
- mxPop();
46
- fxNewHostFunction(the, mxCallback(fx_Object_copy), 2, XS_NO_ID, XS_NO_ID);
47
- mxCopyObjectFunction = *the->stack;
48
- mxPop();
49
- fxNewHostFunction(the, mxCallback(fxOrdinaryToPrimitive), 2, XS_NO_ID, XS_NO_ID);
50
- mxOrdinaryToPrimitiveFunction = *the->stack;
51
- mxPop();
52
-
53
- mxPush(mxObjectPrototype);
54
- slot = fxLastProperty(the, the->stack->value.reference);
55
- slot = fxNextHostAccessorProperty(the, slot, mxCallback(fx_Object_prototype___proto__get), mxCallback(fx_Object_prototype___proto__set), mxID(___proto__), XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG);
56
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype_hasOwnProperty), 1, mxID(_hasOwnProperty), XS_DONT_ENUM_FLAG);
57
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype___defineGetter__), 2, mxID(___defineGetter__), XS_DONT_ENUM_FLAG);
58
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype___defineSetter__), 2, mxID(___defineSetter__), XS_DONT_ENUM_FLAG);
59
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype___lookupGetter__), 1, mxID(___lookupGetter__), XS_DONT_ENUM_FLAG);
60
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype___lookupSetter__), 1, mxID(___lookupSetter__), XS_DONT_ENUM_FLAG);
61
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype_isPrototypeOf), 1, mxID(_isPrototypeOf), XS_DONT_ENUM_FLAG);
62
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype_propertyIsEnumerable), 1, mxID(_propertyIsEnumerable), XS_DONT_ENUM_FLAG);
63
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype_toLocaleString), 0, mxID(_toLocaleString), XS_DONT_ENUM_FLAG);
64
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype_toString), 0, mxID(_toString), XS_DONT_ENUM_FLAG);
65
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_prototype_valueOf), 0, mxID(_valueOf), XS_DONT_ENUM_FLAG);
66
- slot = fxBuildHostConstructor(the, mxCallback(fx_Object), 1, mxID(_Object));
67
- mxObjectConstructor = *the->stack;
68
- slot = fxLastProperty(the, slot);
69
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_assign), 2, mxID(_assign), XS_DONT_ENUM_FLAG);
70
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_create), 2, mxID(_create), XS_DONT_ENUM_FLAG);
71
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_defineProperties), 2, mxID(_defineProperties), XS_DONT_ENUM_FLAG);
72
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_defineProperty), 3, mxID(_defineProperty), XS_DONT_ENUM_FLAG);
73
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_entries), 1, mxID(_entries), XS_DONT_ENUM_FLAG);
74
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_freeze), 1, mxID(_freeze), XS_DONT_ENUM_FLAG);
75
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_fromEntries), 1, mxID(_fromEntries), XS_DONT_ENUM_FLAG);
76
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_getOwnPropertyDescriptor), 2, mxID(_getOwnPropertyDescriptor), XS_DONT_ENUM_FLAG);
77
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_getOwnPropertyDescriptors), 1, mxID(_getOwnPropertyDescriptors), XS_DONT_ENUM_FLAG);
78
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_getOwnPropertyNames), 1, mxID(_getOwnPropertyNames), XS_DONT_ENUM_FLAG);
79
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_getOwnPropertySymbols), 1, mxID(_getOwnPropertySymbols), XS_DONT_ENUM_FLAG);
80
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_getPrototypeOf), 1, mxID(_getPrototypeOf), XS_DONT_ENUM_FLAG);
81
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_hasOwn), 2, mxID(_hasOwn), XS_DONT_ENUM_FLAG);
82
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_is), 2, mxID(_is), XS_DONT_ENUM_FLAG);
83
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_isExtensible), 1, mxID(_isExtensible), XS_DONT_ENUM_FLAG);
84
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_isFrozen), 1, mxID(_isFrozen), XS_DONT_ENUM_FLAG);
85
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_isSealed), 1, mxID(_isSealed), XS_DONT_ENUM_FLAG);
86
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_keys), 1, mxID(_keys), XS_DONT_ENUM_FLAG);
87
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_preventExtensions), 1, mxID(_preventExtensions), XS_DONT_ENUM_FLAG);
88
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_seal), 1, mxID(_seal), XS_DONT_ENUM_FLAG);
89
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_setPrototypeOf), 2, mxID(_setPrototypeOf), XS_DONT_ENUM_FLAG);
90
- slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Object_values), 1, mxID(_values), XS_DONT_ENUM_FLAG);
91
- mxPop();
92
- }
93
-
94
-
95
- txSlot* fxNewObjectInstance(txMachine* the)
96
- {
97
- txSlot* instance;
98
- instance = fxNewSlot(the);
99
- instance->kind = XS_INSTANCE_KIND;
100
- instance->value.instance.garbage = C_NULL;
101
- instance->value.instance.prototype = the->stack->value.reference;
102
- the->stack->value.reference = instance;
103
- the->stack->kind = XS_REFERENCE_KIND;
104
- return instance;
105
- }
106
-
107
- void fx_Object(txMachine* the)
108
- {
109
- if (!mxIsUndefined(mxTarget) && !fxIsSameSlot(the, mxTarget, mxFunction)) {
110
- mxPushSlot(mxTarget);
111
- fxGetPrototypeFromConstructor(the, &mxObjectPrototype);
112
- fxNewObjectInstance(the);
113
- mxPullSlot(mxResult);
114
- return;
115
- }
116
- if ((mxArgc == 0) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND)) {
117
- mxPush(mxObjectPrototype);
118
- fxNewObjectInstance(the);
119
- mxPullSlot(mxResult);
120
- return;
121
- }
122
- *mxResult = *mxArgv(0);
123
- fxToInstance(the, mxResult);
124
- }
125
-
126
- void fx_Object_prototype___proto__get(txMachine* the)
127
- {
128
- if ((mxThis->kind == XS_UNDEFINED_KIND) || (mxThis->kind == XS_NULL_KIND))
129
- mxTypeError("invalid this");
130
- mxBehaviorGetPrototype(the, fxToInstance(the, mxThis), mxResult);
131
- }
132
-
133
- void fx_Object_prototype___proto__set(txMachine* the)
134
- {
135
- txSlot* instance;
136
- if ((mxThis->kind == XS_UNDEFINED_KIND) || (mxThis->kind == XS_NULL_KIND))
137
- mxTypeError("invalid this");
138
- if ((mxArgc < 1) || ((mxArgv(0)->kind != XS_NULL_KIND) && (mxArgv(0)->kind != XS_REFERENCE_KIND)))
139
- return;
140
- if (mxThis->kind == XS_REFERENCE_KIND) {
141
- instance = mxThis->value.reference;
142
- if (!mxBehaviorSetPrototype(the, instance, mxArgv(0)))
143
- mxTypeError("invalid prototype");
144
- }
145
- }
146
-
147
- void fx_Object_prototype___defineGetter__(txMachine* the)
148
- {
149
- txSlot* instance = fxToInstance(the, mxThis);
150
- txSlot* at;
151
- txSlot* slot;
152
- if ((mxArgc < 2) || (!fxIsCallable(the, mxArgv(1))))
153
- mxTypeError("invalid getter");
154
- at = fxAt(the, mxArgv(0));
155
- mxPushUndefined();
156
- slot = the->stack;
157
- slot->value.accessor.getter = fxToInstance(the, mxArgv(1));
158
- slot->value.accessor.setter = C_NULL;
159
- slot->kind = XS_ACCESSOR_KIND;
160
- slot->flag = XS_NO_FLAG;
161
- if(!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, slot, XS_GETTER_FLAG | XS_DONT_DELETE_FLAG| XS_DONT_ENUM_FLAG))
162
- mxTypeError("invalid descriptor");
163
- mxPop();
164
- }
165
-
166
- void fx_Object_prototype___defineSetter__(txMachine* the)
167
- {
168
- txSlot* instance = fxToInstance(the, mxThis);
169
- txSlot* at;
170
- txSlot* slot;
171
- if ((mxArgc < 2) || (!fxIsCallable(the, mxArgv(1))))
172
- mxTypeError("invalid setter");
173
- at = fxAt(the, mxArgv(0));
174
- mxPushUndefined();
175
- slot = the->stack;
176
- slot->value.accessor.getter = C_NULL;
177
- slot->value.accessor.setter = fxToInstance(the, mxArgv(1));
178
- slot->kind = XS_ACCESSOR_KIND;
179
- slot->flag = XS_NO_FLAG;
180
- if(!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, slot, XS_SETTER_FLAG | XS_DONT_DELETE_FLAG| XS_DONT_ENUM_FLAG))
181
- mxTypeError("invalid descriptor");
182
- mxPop();
183
- }
184
-
185
- void fx_Object_prototype___lookupGetter__(txMachine* the)
186
- {
187
- txSlot* instance = fxToInstance(the, mxThis);
188
- txSlot* at;
189
- txSlot* slot;
190
- if (mxArgc < 1)
191
- mxPushUndefined();
192
- else
193
- mxPushSlot(mxArgv(0));
194
- at = fxAt(the, the->stack);
195
- mxPushUndefined();
196
- slot = the->stack;
197
- again:
198
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, slot)) {
199
- if (slot->kind == XS_ACCESSOR_KIND) {
200
- if (slot->value.accessor.getter) {
201
- mxResult->kind = XS_REFERENCE_KIND;
202
- mxResult->value.reference = slot->value.accessor.getter;
203
- }
204
- }
205
- mxPop();
206
- return;
207
- }
208
- if (mxBehaviorGetPrototype(the, instance, slot)) {
209
- instance = slot->value.reference;
210
- goto again;
211
- }
212
- mxPop();
213
- mxPop();
214
- }
215
-
216
- void fx_Object_prototype___lookupSetter__(txMachine* the)
217
- {
218
- txSlot* instance = fxToInstance(the, mxThis);
219
- txSlot* at;
220
- txSlot* slot;
221
- if (mxArgc < 1)
222
- mxPushUndefined();
223
- else
224
- mxPushSlot(mxArgv(0));
225
- at = fxAt(the, the->stack);
226
- mxPushUndefined();
227
- slot = the->stack;
228
- again:
229
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, slot)) {
230
- if (slot->kind == XS_ACCESSOR_KIND) {
231
- if (slot->value.accessor.setter) {
232
- mxResult->kind = XS_REFERENCE_KIND;
233
- mxResult->value.reference = slot->value.accessor.setter;
234
- }
235
- }
236
- mxPop();
237
- return;
238
- }
239
- if (mxBehaviorGetPrototype(the, instance, slot)) {
240
- instance = slot->value.reference;
241
- goto again;
242
- }
243
- mxPop();
244
- mxPop();
245
- }
246
-
247
- void fx_Object_prototype_hasOwnProperty(txMachine* the)
248
- {
249
- txSlot* at;
250
- txSlot* instance;
251
- if (mxArgc < 1)
252
- mxPushUndefined();
253
- else
254
- mxPushSlot(mxArgv(0));
255
- at = fxAt(the, the->stack);
256
- instance = fxToInstance(the, mxThis);
257
- mxPushUndefined();
258
- mxResult->value.boolean = mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack);
259
- mxResult->kind = XS_BOOLEAN_KIND;
260
- mxPop();
261
- mxPop();
262
- }
263
-
264
- void fx_Object_prototype_isPrototypeOf(txMachine* the)
265
- {
266
- mxResult->kind = XS_BOOLEAN_KIND;
267
- mxResult->value.boolean = 0;
268
- if (mxArgc > 0) {
269
- txSlot* slot = mxArgv(0);
270
- if (slot->kind == XS_REFERENCE_KIND) {
271
- txSlot* prototype = fxToInstance(the, mxThis);
272
- while (mxBehaviorGetPrototype(the, slot->value.reference, slot)) {
273
- if (prototype == slot->value.reference) {
274
- mxResult->value.boolean = 1;
275
- break;
276
- }
277
- }
278
- }
279
- }
280
- }
281
-
282
- void fx_Object_prototype_propertyIsEnumerable(txMachine* the)
283
- {
284
- txSlot* at;
285
- txSlot* instance;
286
- if (mxArgc < 1)
287
- mxPushUndefined();
288
- else
289
- mxPushSlot(mxArgv(0));
290
- at = fxAt(the, the->stack);
291
- instance = fxToInstance(the, mxThis);
292
- mxPushUndefined();
293
- mxResult->value.boolean = mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack) && ((the->stack->flag & XS_DONT_ENUM_FLAG) == 0);
294
- mxResult->kind = XS_BOOLEAN_KIND;
295
- mxPop();
296
- mxPop();
297
- }
298
-
299
- void fx_Object_prototype_toLocaleString(txMachine* the)
300
- {
301
- mxPushSlot(mxThis);
302
- mxDub();
303
- mxGetID(mxID(_toString));
304
- mxCall();
305
- mxRunCount(0);
306
- mxPullSlot(mxResult);
307
- }
308
-
309
- void fx_Object_prototype_toString(txMachine* the)
310
- {
311
- txString tag = C_NULL;
312
- txSlot* instance = C_NULL;
313
- txSlot* slot;
314
- txSlot* target;
315
- switch (mxThis->kind) {
316
- case XS_UNDEFINED_KIND:
317
- tag = "Undefined";
318
- break;
319
- case XS_NULL_KIND:
320
- tag = "Null";
321
- break;
322
- case XS_BOOLEAN_KIND:
323
- instance = mxBooleanPrototype.value.reference;
324
- tag = "Boolean";
325
- break;
326
- case XS_INTEGER_KIND:
327
- case XS_NUMBER_KIND:
328
- instance = mxNumberPrototype.value.reference;
329
- tag = "Number";
330
- break;
331
- case XS_STRING_KIND:
332
- case XS_STRING_X_KIND:
333
- instance = mxStringPrototype.value.reference;
334
- tag = "String";
335
- break;
336
- case XS_SYMBOL_KIND:
337
- instance = mxSymbolPrototype.value.reference;
338
- tag = "Object";
339
- break;
340
- case XS_BIGINT_KIND:
341
- case XS_BIGINT_X_KIND:
342
- instance = mxBigIntPrototype.value.reference;
343
- tag = "Object";
344
- break;
345
- case XS_REFERENCE_KIND:
346
- instance = mxThis->value.reference;
347
- if (fxIsArray(the, instance))
348
- tag = "Array";
349
- else {
350
- slot = instance->next;
351
- if (slot) {
352
- if ((slot->ID == XS_ARGUMENTS_SLOPPY_BEHAVIOR) || (slot->ID == XS_ARGUMENTS_STRICT_BEHAVIOR))
353
- tag = "Arguments";
354
- else if (slot->flag & XS_INTERNAL_FLAG) {
355
- switch (slot->kind) {
356
- case XS_BOOLEAN_KIND:
357
- tag = "Boolean";
358
- break;
359
- case XS_CALLBACK_KIND:
360
- case XS_CALLBACK_X_KIND:
361
- case XS_CODE_KIND:
362
- case XS_CODE_X_KIND:
363
- tag = "Function";
364
- break;
365
- case XS_DATE_KIND:
366
- tag = "Date";
367
- break;
368
- case XS_ERROR_KIND:
369
- tag = "Error";
370
- break;
371
- case XS_GLOBAL_KIND:
372
- tag = "global";
373
- break;
374
- case XS_NUMBER_KIND:
375
- tag = "Number";
376
- break;
377
- case XS_REGEXP_KIND:
378
- tag = "RegExp";
379
- break;
380
- case XS_STRING_KIND:
381
- case XS_STRING_X_KIND:
382
- tag = "String";
383
- break;
384
- case XS_BIGINT_KIND:
385
- case XS_BIGINT_X_KIND:
386
- tag = "Object";
387
- break;
388
- case XS_PROXY_KIND:
389
- while ((target = slot->value.proxy.target)) {
390
- slot = target->next;
391
- if (!slot || (slot->kind != XS_PROXY_KIND))
392
- break;
393
- }
394
- if (mxIsFunction(target)) {
395
- instance = target;
396
- tag = "Function";
397
- }
398
- else
399
- tag = "Object";
400
- break;
401
- default:
402
- tag = "Object";
403
- break;
404
- }
405
- }
406
- else
407
- tag = "Object";
408
- }
409
- else
410
- tag = "Object";
411
- }
412
- break;
413
- #ifdef mxHostFunctionPrimitive
414
- case XS_HOST_FUNCTION_KIND:
415
- instance = mxFunctionPrototype.value.reference;
416
- tag = "Function";
417
- break;
418
- #endif
419
- default:
420
- tag = "Object";
421
- break;
422
- }
423
- fxStringX(the, mxResult, "[object ");
424
- if (instance) {
425
- mxPushReference(instance);
426
- mxGetID(mxID(_Symbol_toStringTag));
427
- if ((the->stack->kind == XS_STRING_KIND) || (the->stack->kind == XS_STRING_X_KIND))
428
- fxConcatString(the, mxResult, the->stack);
429
- else
430
- fxConcatStringC(the, mxResult, tag);
431
- }
432
- else
433
- fxConcatStringC(the, mxResult, tag);
434
- fxConcatStringC(the, mxResult, "]");
435
- }
436
-
437
- void fx_Object_prototype_valueOf(txMachine* the)
438
- {
439
- fxToInstance(the, mxThis);
440
- *mxResult = *mxThis;
441
- }
442
-
443
- void fx_Object_assign(txMachine* the)
444
- {
445
- txSlot* target;
446
- txInteger c, i;
447
- txSlot* instance;
448
- txSlot* at;
449
- txSlot* property;
450
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
451
- mxTypeError("invalid target");
452
- fxToInstance(the, mxArgv(0));
453
- target = mxArgv(0);
454
- c = mxArgc;
455
- for (i = 1; i < c; i++) {
456
- if ((mxArgv(i)->kind == XS_UNDEFINED_KIND) || (mxArgv(i)->kind == XS_NULL_KIND))
457
- continue;
458
- instance = fxToInstance(the, mxArgv(i));
459
- at = fxNewInstance(the);
460
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
461
- mxPushUndefined();
462
- property = the->stack;
463
- while ((at = at->next)) {
464
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
465
- mxPushReference(instance);
466
- mxGetAll(at->value.at.id, at->value.at.index);
467
- mxPushSlot(target);
468
- mxSetAll(at->value.at.id, at->value.at.index);
469
- mxPop();
470
- }
471
- }
472
- mxPop();
473
- mxPop();
474
- }
475
- *mxResult = *target;
476
- }
477
-
478
- void fx_Object_copy(txMachine* the)
479
- {
480
- txInteger c = mxArgc, i;
481
- txSlot* target;
482
- txSlot* source;
483
- txSlot* at;
484
- txSlot* property;
485
- if ((c < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
486
- mxTypeError("invalid object");
487
- target = fxToInstance(the, mxArgv(0));
488
- *mxResult = *mxArgv(0);
489
- if ((c < 2) || (mxArgv(1)->kind == XS_UNDEFINED_KIND) || (mxArgv(1)->kind == XS_NULL_KIND))
490
- return;
491
- source = fxToInstance(the, mxArgv(1));
492
- at = fxNewInstance(the);
493
- mxBehaviorOwnKeys(the, source, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
494
- mxPushUndefined();
495
- property = the->stack;
496
- while ((at = at->next)) {
497
- for (i = 2; i < c; i++) {
498
- txSlot* exclude = mxArgv(i);
499
- if ((exclude->value.at.id == at->value.at.id) && (exclude->value.at.index == at->value.at.index))
500
- break;
501
- }
502
- if (i == c) {
503
- if (mxBehaviorGetOwnProperty(the, source, at->value.at.id, at->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
504
- mxPushReference(source);
505
- mxGetAll(at->value.at.id, at->value.at.index);
506
- the->stack->flag = 0;
507
- mxBehaviorDefineOwnProperty(the, target, at->value.at.id, at->value.at.index, the->stack, XS_GET_ONLY);
508
- mxPop();
509
- }
510
- }
511
- }
512
- mxPop(); // property
513
- mxPop(); // at
514
- }
515
-
516
- void fx_Object_create(txMachine* the)
517
- {
518
- txSlot* instance;
519
- txSlot* properties;
520
- txSlot* at;
521
- txSlot* property;
522
- txFlag mask;
523
- if ((mxArgc < 1) || ((mxArgv(0)->kind != XS_NULL_KIND) && (mxArgv(0)->kind != XS_REFERENCE_KIND)))
524
- mxTypeError("invalid prototype");
525
- if (mxArgv(0)->kind == XS_NULL_KIND)
526
- fxNewInstance(the);
527
- else {
528
- mxPushSlot(mxArgv(0));
529
- fxNewHostInstance(the);
530
- }
531
- mxPullSlot(mxResult);
532
- instance = fxGetInstance(the, mxResult);
533
- if ((mxArgc > 1) && (mxArgv(1)->kind != XS_UNDEFINED_KIND)) {
534
- properties = fxToInstance(the, mxArgv(1));
535
- at = fxNewInstance(the);
536
- mxBehaviorOwnKeys(the, properties, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
537
- mxPushUndefined();
538
- property = the->stack;
539
- while ((at = at->next)) {
540
- if (mxBehaviorGetOwnProperty(the, properties, at->value.at.id, at->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
541
- mxPushReference(properties);
542
- mxGetAll(at->value.at.id, at->value.at.index);
543
- mask = fxDescriptorToSlot(the, the->stack);
544
- if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack, mask))
545
- mxTypeError("invalid descriptor");
546
- mxPop();
547
- }
548
- }
549
- mxPop();
550
- mxPop();
551
- }
552
- }
553
-
554
- void fx_Object_defineProperties(txMachine* the)
555
- {
556
- txSlot* instance;
557
- txSlot* properties;
558
- txSlot* at;
559
- txSlot* property;
560
- txFlag mask;
561
- if ((mxArgc < 1) || (mxArgv(0)->kind != XS_REFERENCE_KIND))
562
- mxTypeError("invalid object");
563
- if ((mxArgc < 2) || (mxArgv(1)->kind == XS_UNDEFINED_KIND))
564
- mxTypeError("invalid properties");
565
- instance = fxGetInstance(the, mxArgv(0));
566
- properties = fxToInstance(the, mxArgv(1));
567
- at = fxNewInstance(the);
568
- mxBehaviorOwnKeys(the, properties, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
569
- mxPushUndefined();
570
- property = the->stack;
571
- while ((at = at->next)) {
572
- if (mxBehaviorGetOwnProperty(the, properties, at->value.at.id, at->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
573
- mxPushReference(properties);
574
- mxGetAll(at->value.at.id, at->value.at.index);
575
- mask = fxDescriptorToSlot(the, the->stack);
576
- if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack, mask))
577
- mxTypeError("invalid descriptor");
578
- mxPop();
579
- }
580
- }
581
- mxPop();
582
- mxPop();
583
- *mxResult = *mxArgv(0);
584
- }
585
-
586
- void fx_Object_defineProperty(txMachine* the)
587
- {
588
- txSlot* at;
589
- txFlag mask;
590
- if ((mxArgc < 1) || (mxArgv(0)->kind != XS_REFERENCE_KIND))
591
- mxTypeError("invalid object");
592
- if (mxArgc < 2)
593
- mxTypeError("invalid key");
594
- at = fxAt(the, mxArgv(1));
595
- if ((mxArgc < 3) || (mxArgv(2)->kind != XS_REFERENCE_KIND))
596
- mxTypeError("invalid descriptor");
597
- mask = fxDescriptorToSlot(the, mxArgv(2));
598
- if(!mxBehaviorDefineOwnProperty(the, mxArgv(0)->value.reference, at->value.at.id, at->value.at.index, mxArgv(2), mask))
599
- mxTypeError("invalid descriptor");
600
- *mxResult = *mxArgv(0);
601
- }
602
-
603
- void fx_Object_entries(txMachine* the)
604
- {
605
- txSlot* instance;
606
- txSlot* result;
607
- txSlot* array;
608
- txSlot* property;
609
- txSlot** address;
610
- txSlot* item;
611
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
612
- mxTypeError("invalid object");
613
- instance = fxToInstance(the, mxArgv(0));
614
- mxPush(mxArrayPrototype);
615
- result = fxNewArrayInstance(the);
616
- mxPullSlot(mxResult);
617
- array = result->next;
618
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG, array);
619
- mxPushUndefined();
620
- property = the->stack;
621
- address = &array->next;
622
- while ((item = *address)) {
623
- if (mxBehaviorGetOwnProperty(the, instance, item->value.at.id, item->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
624
- array->value.array.length++;
625
- mxPushUndefined();
626
- fxKeyAt(the, item->value.at.id, item->value.at.index, the->stack);
627
- mxPushReference(instance);
628
- mxGetAll(item->value.at.id, item->value.at.index);
629
- fxConstructArrayEntry(the, item);
630
- address = &(item->next);
631
- }
632
- else
633
- *address = item->next;
634
- }
635
- mxPop();
636
- fxCacheArray(the, result);
637
- }
638
-
639
- void fx_Object_freeze(txMachine* the)
640
- {
641
- if (mxArgc > 0) {
642
- txSlot* slot = mxArgv(0);
643
- if (slot->kind == XS_REFERENCE_KIND) {
644
- txSlot* instance = slot->value.reference;
645
- txBoolean deep = 0;
646
- txSlot* at;
647
- txSlot* property;
648
- if (!mxBehaviorPreventExtensions(the, instance))
649
- mxTypeError("extensible object");
650
- if ((mxArgc > 1) && fxToBoolean(the, mxArgv(1)))
651
- deep = 1;
652
- at = fxNewInstance(the);
653
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
654
- mxPushUndefined();
655
- property = the->stack;
656
- while ((at = at->next)) {
657
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
658
- txFlag mask = XS_DONT_DELETE_FLAG;
659
- property->flag |= XS_DONT_DELETE_FLAG;
660
- if (property->kind != XS_ACCESSOR_KIND) {
661
- mask |= XS_DONT_SET_FLAG;
662
- property->flag |= XS_DONT_SET_FLAG;
663
- }
664
- property->kind = XS_UNINITIALIZED_KIND;
665
- if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, property, mask)) {
666
- if (!deep)
667
- mxTypeError("cannot configure property");
668
- }
669
- }
670
- }
671
- mxPop();
672
- if (deep) {
673
- at = the->stack->value.reference;
674
- mxPushUndefined();
675
- property = the->stack;
676
- while ((at = at->next)) {
677
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
678
- if (property->kind == XS_REFERENCE_KIND) {
679
- mxPushSlot(mxThis);
680
- mxDub();
681
- mxGetID(mxID(_isFrozen));
682
- mxCall();
683
- mxPushSlot(property);
684
- mxRunCount(1);
685
- if (!fxRunTest(the)) {
686
- mxPushSlot(mxThis);
687
- mxPushSlot(mxFunction);
688
- mxCall();
689
- mxPushSlot(property);
690
- mxPushBoolean(1);
691
- mxRunCount(2);
692
- mxPop();
693
- }
694
- }
695
- else if (property->kind == XS_ACCESSOR_KIND) {
696
- if (property->value.accessor.getter) {
697
- mxPushSlot(mxThis);
698
- mxDub();
699
- mxGetID(mxID(_isFrozen));
700
- mxCall();
701
- mxPushReference(property->value.accessor.getter);
702
- mxRunCount(1);
703
- if (!fxRunTest(the)) {
704
- mxPushSlot(mxThis);
705
- mxPushSlot(mxFunction);
706
- mxCall();
707
- mxPushReference(property->value.accessor.getter);
708
- mxPushBoolean(1);
709
- mxRunCount(2);
710
- mxPop();
711
- }
712
- }
713
- if (property->value.accessor.setter) {
714
- mxPushSlot(mxThis);
715
- mxDub();
716
- mxGetID(mxID(_isFrozen));
717
- mxCall();
718
- mxPushReference(property->value.accessor.setter);
719
- mxRunCount(1);
720
- if (!fxRunTest(the)) {
721
- mxPushSlot(mxThis);
722
- mxPushSlot(mxFunction);
723
- mxCall();
724
- mxPushReference(property->value.accessor.setter);
725
- mxPushBoolean(1);
726
- mxRunCount(2);
727
- mxPop();
728
- }
729
- }
730
- }
731
- }
732
- }
733
- mxPop();
734
- }
735
- mxPop();
736
- }
737
- *mxResult = *mxArgv(0);
738
- }
739
- }
740
-
741
- void fx_Object_fromEntries(txMachine* the)
742
- {
743
- txSlot *instance, *iterator, *next, *value, *at;
744
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
745
- mxTypeError("invalid iterable");
746
- mxPush(mxObjectPrototype);
747
- instance = fxNewObjectInstance(the);
748
- mxPullSlot(mxResult);
749
- mxTemporary(iterator);
750
- mxTemporary(next);
751
- fxGetIterator(the, mxArgv(0), iterator, next, 0);
752
- mxTemporary(value);
753
- while (fxIteratorNext(the, iterator, next, value)) {
754
- mxTry(the) {
755
- if (value->kind != XS_REFERENCE_KIND)
756
- mxTypeError("item is no object");
757
- mxPushSlot(value);
758
- mxGetIndex(0);
759
- mxPushSlot(value);
760
- mxGetIndex(1);
761
- at = fxAt(the, the->stack + 1);
762
- mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack, XS_GET_ONLY);
763
- mxPop();
764
- mxPop();
765
- }
766
- mxCatch(the) {
767
- fxIteratorReturn(the, iterator);
768
- fxJump(the);
769
- }
770
- }
771
- mxPop();
772
- }
773
-
774
- void fx_Object_getOwnPropertyDescriptor(txMachine* the)
775
- {
776
- txSlot* instance;
777
- txSlot* at;
778
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
779
- mxTypeError("invalid object");
780
- instance = fxToInstance(the, mxArgv(0));
781
- if (mxArgc < 2)
782
- mxPushUndefined();
783
- else
784
- mxPushSlot(mxArgv(1));
785
- at = fxAt(the, the->stack);
786
- mxPushUndefined();
787
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack)) {
788
- fxDescribeProperty(the, the->stack, XS_GET_ONLY);
789
- mxPullSlot(mxResult);
790
- }
791
- mxPop();
792
- mxPop();
793
- }
794
-
795
- void fx_Object_getOwnPropertyDescriptors(txMachine* the)
796
- {
797
- txSlot* instance;
798
- txSlot* result;
799
- txSlot* at;
800
- txSlot* property;
801
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
802
- mxTypeError("invalid object");
803
- instance = fxToInstance(the, mxArgv(0));
804
- mxPush(mxObjectPrototype);
805
- result = fxNewObjectInstance(the);
806
- mxPullSlot(mxResult);
807
- at = fxNewInstance(the);
808
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
809
- mxPushUndefined();
810
- property = the->stack;
811
- while ((at = at->next)) {
812
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
813
- fxDescribeProperty(the, property, XS_GET_ONLY);
814
- mxBehaviorDefineOwnProperty(the, result, at->value.at.id, at->value.at.index, the->stack, XS_GET_ONLY);
815
- mxPop();
816
- }
817
- }
818
- mxPop();
819
- }
820
-
821
- void fx_Object_getOwnPropertyNames(txMachine* the)
822
- {
823
- txSlot* instance;
824
- txSlot* result;
825
- txSlot* array;
826
- txSlot* item;
827
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
828
- mxTypeError("invalid object");
829
- instance = fxToInstance(the, mxArgv(0));
830
- mxPush(mxArrayPrototype);
831
- result = fxNewArrayInstance(the);
832
- mxPullSlot(mxResult);
833
- array = result->next;
834
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG, array);
835
- item = array;
836
- while ((item = item->next)) {
837
- array->value.array.length++;
838
- fxKeyAt(the, item->value.at.id, item->value.at.index, item);
839
- }
840
- fxCacheArray(the, result);
841
- }
842
-
843
- void fx_Object_getOwnPropertySymbols(txMachine* the)
844
- {
845
- txSlot* instance;
846
- txSlot* result;
847
- txSlot* array;
848
- txSlot* item;
849
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
850
- mxTypeError("invalid object");
851
- instance = fxToInstance(the, mxArgv(0));
852
- mxPush(mxArrayPrototype);
853
- result = fxNewArrayInstance(the);
854
- mxPullSlot(mxResult);
855
- array = result->next;
856
- mxBehaviorOwnKeys(the, instance, XS_EACH_SYMBOL_FLAG, array);
857
- item = array;
858
- while ((item = item->next)) {
859
- array->value.array.length++;
860
- fxKeyAt(the, item->value.at.id, item->value.at.index, item);
861
- }
862
- fxCacheArray(the, result);
863
- }
864
-
865
- void fx_Object_getPrototypeOf(txMachine* the)
866
- {
867
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
868
- mxTypeError("invalid object");
869
- mxBehaviorGetPrototype(the, fxToInstance(the, mxArgv(0)), mxResult);
870
- }
871
-
872
- void fx_Object_hasOwn(txMachine* the)
873
- {
874
- txSlot* instance;
875
- txSlot* at;
876
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
877
- mxTypeError("invalid object");
878
- instance = fxToInstance(the, mxArgv(0));
879
- if (mxArgc < 2)
880
- mxPushUndefined();
881
- else
882
- mxPushSlot(mxArgv(1));
883
- at = fxAt(the, the->stack);
884
- mxPushUndefined();
885
- mxResult->value.boolean = mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, the->stack);
886
- mxResult->kind = XS_BOOLEAN_KIND;
887
- mxPop();
888
- mxPop();
889
- }
890
-
891
- void fx_Object_is(txMachine* the)
892
- {
893
- if (mxArgc > 0)
894
- mxPushSlot(mxArgv(0));
895
- else
896
- mxPushUndefined();
897
- if (mxArgc > 1)
898
- mxPushSlot(mxArgv(1));
899
- else
900
- mxPushUndefined();
901
- mxResult->value.boolean = fxIsSameValue(the, the->stack + 1, the->stack, 0);
902
- mxResult->kind = XS_BOOLEAN_KIND;
903
- the->stack += 2;
904
- }
905
-
906
- void fx_Object_isExtensible(txMachine* the)
907
- {
908
- mxResult->kind = XS_BOOLEAN_KIND;
909
- mxResult->value.boolean = 0;
910
- if (mxArgc > 0) {
911
- txSlot* slot = mxArgv(0);
912
- if (slot->kind == XS_REFERENCE_KIND) {
913
- slot = slot->value.reference;
914
- mxResult->value.boolean = mxBehaviorIsExtensible(the, slot);
915
- }
916
- }
917
- }
918
-
919
- void fx_Object_isFrozen(txMachine* the)
920
- {
921
- mxResult->kind = XS_BOOLEAN_KIND;
922
- mxResult->value.boolean = 1;
923
- if (mxArgc > 0) {
924
- txSlot* slot = mxArgv(0);
925
- if (slot->kind == XS_REFERENCE_KIND) {
926
- txSlot* instance = slot->value.reference;
927
- mxResult->value.boolean = mxBehaviorIsExtensible(the, instance) ? 0 : 1;
928
- if (mxResult->value.boolean) {
929
- txSlot* at;
930
- txSlot* property;
931
- at = fxNewInstance(the);
932
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
933
- mxPushUndefined();
934
- property = the->stack;
935
- while ((at = at->next)) {
936
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
937
- if (property->kind != XS_ACCESSOR_KIND)
938
- if (!(property->flag & XS_DONT_SET_FLAG))
939
- mxResult->value.boolean = 0;
940
- if (!(property->flag & XS_DONT_DELETE_FLAG))
941
- mxResult->value.boolean = 0;
942
- }
943
- }
944
- mxPop();
945
- mxPop();
946
- }
947
- }
948
- }
949
- }
950
-
951
- void fx_Object_isSealed(txMachine* the)
952
- {
953
- mxResult->kind = XS_BOOLEAN_KIND;
954
- mxResult->value.boolean = 1;
955
- if (mxArgc > 0) {
956
- txSlot* slot = mxArgv(0);
957
- if (slot->kind == XS_REFERENCE_KIND) {
958
- txSlot* instance = slot->value.reference;
959
- mxResult->value.boolean = mxBehaviorIsExtensible(the, instance) ? 0 : 1;
960
- if (mxResult->value.boolean) {
961
- txSlot* at;
962
- txSlot* property;
963
- at = fxNewInstance(the);
964
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
965
- mxPushUndefined();
966
- property = the->stack;
967
- while ((at = at->next)) {
968
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
969
- if (!(property->flag & XS_DONT_DELETE_FLAG))
970
- mxResult->value.boolean = 0;
971
- }
972
- }
973
- mxPop();
974
- mxPop();
975
- }
976
- }
977
- }
978
- }
979
-
980
- void fx_Object_keys(txMachine* the)
981
- {
982
- txSlot* instance;
983
- txSlot* result;
984
- txSlot* array;
985
- txSlot* property;
986
- txSlot** address;
987
- txSlot* item;
988
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
989
- mxTypeError("invalid object");
990
- instance = fxToInstance(the, mxArgv(0));
991
- mxPush(mxArrayPrototype);
992
- result = fxNewArrayInstance(the);
993
- mxPullSlot(mxResult);
994
- array = result->next;
995
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG, array);
996
- mxPushUndefined();
997
- property = the->stack;
998
- address = &array->next;
999
- while ((item = *address)) {
1000
- if (mxBehaviorGetOwnProperty(the, instance, item->value.at.id, item->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
1001
- array->value.array.length++;
1002
- fxKeyAt(the, item->value.at.id, item->value.at.index, item);
1003
- address = &(item->next);
1004
- }
1005
- else
1006
- *address = item->next;
1007
- }
1008
- mxPop();
1009
- fxCacheArray(the, result);
1010
- }
1011
-
1012
- void fx_Object_preventExtensions(txMachine* the)
1013
- {
1014
- if (mxArgc > 0) {
1015
- txSlot* slot = mxArgv(0);
1016
- if (slot->kind == XS_REFERENCE_KIND) {
1017
- slot = slot->value.reference;
1018
- if (!mxBehaviorPreventExtensions(the, slot))
1019
- mxTypeError("extensible object");
1020
- }
1021
- *mxResult = *mxArgv(0);
1022
- }
1023
- }
1024
-
1025
- void fx_Object_seal(txMachine* the)
1026
- {
1027
- if (mxArgc > 0) {
1028
- txSlot* slot = mxArgv(0);
1029
- if (slot->kind == XS_REFERENCE_KIND) {
1030
- txSlot* instance = slot->value.reference;
1031
- txSlot* at;
1032
- txSlot* property;
1033
- if (!mxBehaviorPreventExtensions(the, instance))
1034
- mxTypeError("extensible object");
1035
- at = fxNewInstance(the);
1036
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG | XS_EACH_SYMBOL_FLAG, at);
1037
- mxPushUndefined();
1038
- property = the->stack;
1039
- while ((at = at->next)) {
1040
- if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, property)) {
1041
- txFlag mask = XS_DONT_DELETE_FLAG;
1042
- property->flag |= XS_DONT_DELETE_FLAG;
1043
- property->kind = XS_UNINITIALIZED_KIND;
1044
- if (!mxBehaviorDefineOwnProperty(the, instance, at->value.at.id, at->value.at.index, property, mask))
1045
- mxTypeError("cannot configure property");
1046
- }
1047
- }
1048
- mxPop();
1049
- mxPop();
1050
- }
1051
- *mxResult = *mxArgv(0);
1052
- }
1053
- }
1054
-
1055
- void fx_Object_setPrototypeOf(txMachine* the)
1056
- {
1057
- txSlot* instance;
1058
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
1059
- mxTypeError("invalid object");
1060
- if ((mxArgc < 2) || ((mxArgv(1)->kind != XS_NULL_KIND) && (mxArgv(1)->kind != XS_REFERENCE_KIND)))
1061
- mxTypeError("invalid prototype");
1062
- if (mxArgv(0)->kind == XS_REFERENCE_KIND) {
1063
- instance = mxArgv(0)->value.reference;
1064
- if (!mxBehaviorSetPrototype(the, instance, mxArgv(1)))
1065
- mxTypeError("invalid prototype");
1066
- }
1067
- *mxResult = *mxArgv(0);
1068
- }
1069
-
1070
- void fx_Object_values(txMachine* the)
1071
- {
1072
- txSlot* instance;
1073
- txSlot* result;
1074
- txSlot* array;
1075
- txSlot* property;
1076
- txSlot** address;
1077
- txSlot* item;
1078
- if ((mxArgc < 1) || (mxArgv(0)->kind == XS_UNDEFINED_KIND) || (mxArgv(0)->kind == XS_NULL_KIND))
1079
- mxTypeError("invalid object");
1080
- instance = fxToInstance(the, mxArgv(0));
1081
- mxPush(mxArrayPrototype);
1082
- result = fxNewArrayInstance(the);
1083
- mxPullSlot(mxResult);
1084
- array = result->next;
1085
- mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG, array);
1086
- mxPushUndefined();
1087
- property = the->stack;
1088
- address = &array->next;
1089
- while ((item = *address)) {
1090
- if (mxBehaviorGetOwnProperty(the, instance, item->value.at.id, item->value.at.index, property) && !(property->flag & XS_DONT_ENUM_FLAG)) {
1091
- array->value.array.length++;
1092
- mxPushReference(instance);
1093
- mxGetAll(item->value.at.id, item->value.at.index);
1094
- mxPullSlot(item);
1095
- address = &(item->next);
1096
- }
1097
- else
1098
- *address = item->next;
1099
- }
1100
- mxPop();
1101
- fxCacheArray(the, result);
1102
- }