@agoric/xsnap 0.14.3-u14.0 → 0.14.3-u16.1

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 (137) hide show
  1. package/README.md +3 -3
  2. package/api.js +4 -2
  3. package/build.env +1 -1
  4. package/moddable/modules/data/base64/base64.js +28 -0
  5. package/moddable/modules/data/base64/manifest.json +11 -0
  6. package/moddable/modules/data/base64/modBase64.c +188 -0
  7. package/moddable/modules/data/binaryMessage/BinaryMessage.js +106 -0
  8. package/moddable/modules/data/crc/crc.c +205 -0
  9. package/moddable/modules/data/crc/crc.js +36 -0
  10. package/moddable/modules/data/crc/manifest.json +8 -0
  11. package/moddable/modules/data/hex/hex.js +28 -0
  12. package/moddable/modules/data/hex/manifest.json +11 -0
  13. package/moddable/modules/data/hex/modHex.c +139 -0
  14. package/moddable/modules/data/logical/logical.js +32 -0
  15. package/moddable/modules/data/logical/modLogical.c +98 -0
  16. package/moddable/modules/data/qrcode/manifest.json +9 -0
  17. package/moddable/modules/data/qrcode/qrcode.c +93 -0
  18. package/moddable/modules/data/qrcode/qrcode.js +23 -0
  19. package/moddable/modules/data/qrcode/qrcodegen.c +1025 -0
  20. package/moddable/modules/data/qrcode/qrcodegen.h +267 -0
  21. package/moddable/modules/data/text/decoder/manifest.json +8 -0
  22. package/moddable/modules/data/text/decoder/textdecoder.c +480 -0
  23. package/moddable/modules/data/text/decoder/textdecoder.js +27 -0
  24. package/moddable/modules/data/text/encoder/manifest.json +8 -0
  25. package/moddable/modules/data/text/encoder/textencoder.c +232 -0
  26. package/moddable/modules/data/text/encoder/textencoder.js +24 -0
  27. package/moddable/modules/data/tinyint/tinyint.c +150 -0
  28. package/moddable/modules/data/tinyint/tinyint.js +53 -0
  29. package/moddable/modules/data/url/manifest.json +17 -0
  30. package/moddable/modules/data/url/url.c +1959 -0
  31. package/moddable/modules/data/url/url.js +210 -0
  32. package/moddable/modules/data/wavreader/manifest.json +8 -0
  33. package/moddable/modules/data/wavreader/wavreader.js +128 -0
  34. package/moddable/modules/data/zlib/deflate.c +161 -0
  35. package/moddable/modules/data/zlib/deflate.js +63 -0
  36. package/moddable/modules/data/zlib/inflate.c +145 -0
  37. package/moddable/modules/data/zlib/inflate.js +66 -0
  38. package/moddable/modules/data/zlib/manifest_deflate.json +9 -0
  39. package/moddable/modules/data/zlib/manifest_inflate.json +9 -0
  40. package/moddable/modules/data/zlib/miniz.c +4924 -0
  41. package/moddable/xs/includes/xs.d.ts +73 -0
  42. package/moddable/xs/includes/xs.h +1533 -0
  43. package/moddable/xs/includes/xsmc.h +206 -0
  44. package/moddable/xs/makefiles/lin/makefile +33 -0
  45. package/moddable/xs/makefiles/lin/xsc.mk +118 -0
  46. package/moddable/xs/makefiles/lin/xsid.mk +90 -0
  47. package/moddable/xs/makefiles/lin/xsl.mk +168 -0
  48. package/moddable/xs/makefiles/lin/xst.mk +201 -0
  49. package/moddable/xs/makefiles/mac/makefile +33 -0
  50. package/moddable/xs/makefiles/mac/xsc.mk +130 -0
  51. package/moddable/xs/makefiles/mac/xsid.mk +102 -0
  52. package/moddable/xs/makefiles/mac/xsl.mk +177 -0
  53. package/moddable/xs/makefiles/mac/xst.mk +203 -0
  54. package/moddable/xs/makefiles/mac/xst_no_asan.txt +52 -0
  55. package/moddable/xs/makefiles/win/build.bat +26 -0
  56. package/moddable/xs/makefiles/win/xsc.mak +142 -0
  57. package/moddable/xs/makefiles/win/xsid.mak +113 -0
  58. package/moddable/xs/makefiles/win/xsl.mak +186 -0
  59. package/moddable/xs/makefiles/win/xst.mak +195 -0
  60. package/moddable/xs/platforms/lin_xs.h +99 -0
  61. package/moddable/xs/platforms/mac_xs.h +97 -0
  62. package/moddable/xs/platforms/wasm_xs.h +79 -0
  63. package/moddable/xs/platforms/win_xs.h +104 -0
  64. package/moddable/xs/platforms/xsHost.h +63 -0
  65. package/moddable/xs/platforms/xsPlatform.h +618 -0
  66. package/moddable/xs/sources/xsAPI.c +2555 -0
  67. package/moddable/xs/sources/xsAll.c +294 -0
  68. package/moddable/xs/sources/xsAll.h +2741 -0
  69. package/moddable/xs/sources/xsArguments.c +222 -0
  70. package/moddable/xs/sources/xsArray.c +2657 -0
  71. package/moddable/xs/sources/xsAtomics.c +844 -0
  72. package/moddable/xs/sources/xsBigInt.c +1859 -0
  73. package/moddable/xs/sources/xsBoolean.c +109 -0
  74. package/moddable/xs/sources/xsCode.c +4493 -0
  75. package/moddable/xs/sources/xsCommon.c +1710 -0
  76. package/moddable/xs/sources/xsCommon.h +1142 -0
  77. package/moddable/xs/sources/xsDataView.c +2890 -0
  78. package/moddable/xs/sources/xsDate.c +1541 -0
  79. package/moddable/xs/sources/xsDebug.c +2710 -0
  80. package/moddable/xs/sources/xsDefaults.c +134 -0
  81. package/moddable/xs/sources/xsError.c +353 -0
  82. package/moddable/xs/sources/xsFunction.c +776 -0
  83. package/moddable/xs/sources/xsGenerator.c +865 -0
  84. package/moddable/xs/sources/xsGlobal.c +839 -0
  85. package/moddable/xs/sources/xsJSON.c +1091 -0
  86. package/moddable/xs/sources/xsLexical.c +1969 -0
  87. package/moddable/xs/sources/xsLockdown.c +933 -0
  88. package/moddable/xs/sources/xsMapSet.c +1649 -0
  89. package/moddable/xs/sources/xsMarshall.c +1020 -0
  90. package/moddable/xs/sources/xsMath.c +624 -0
  91. package/moddable/xs/sources/xsMemory.c +1941 -0
  92. package/moddable/xs/sources/xsModule.c +3101 -0
  93. package/moddable/xs/sources/xsNumber.c +560 -0
  94. package/moddable/xs/sources/xsObject.c +1102 -0
  95. package/moddable/xs/sources/xsPlatforms.c +480 -0
  96. package/moddable/xs/sources/xsProfile.c +577 -0
  97. package/moddable/xs/sources/xsPromise.c +1199 -0
  98. package/moddable/xs/sources/xsProperty.c +636 -0
  99. package/moddable/xs/sources/xsProxy.c +1014 -0
  100. package/moddable/xs/sources/xsRegExp.c +1168 -0
  101. package/moddable/xs/sources/xsRun.c +4889 -0
  102. package/moddable/xs/sources/xsScope.c +1293 -0
  103. package/moddable/xs/sources/xsScript.c +288 -0
  104. package/moddable/xs/sources/xsScript.h +1186 -0
  105. package/moddable/xs/sources/xsSnapshot.c +2161 -0
  106. package/moddable/xs/sources/xsSnapshot.h +51 -0
  107. package/moddable/xs/sources/xsSourceMap.c +218 -0
  108. package/moddable/xs/sources/xsString.c +3332 -0
  109. package/moddable/xs/sources/xsSymbol.c +503 -0
  110. package/moddable/xs/sources/xsSyntaxical.c +4193 -0
  111. package/moddable/xs/sources/xsTree.c +1893 -0
  112. package/moddable/xs/sources/xsType.c +1488 -0
  113. package/moddable/xs/sources/xsdtoa.c +6672 -0
  114. package/moddable/xs/sources/xsmc.c +340 -0
  115. package/moddable/xs/sources/xsre.c +7578 -0
  116. package/package.json +37 -20
  117. package/scripts/get_xsnap_version.sh +14 -0
  118. package/scripts/test-package.sh +21 -0
  119. package/src/avaAssertXS.js +6 -2
  120. package/src/avaHandler.cjs +2 -5
  121. package/src/avaXS.js +7 -8
  122. package/src/build.js +161 -28
  123. package/src/replay.js +0 -3
  124. package/src/xsnap.js +105 -91
  125. package/src/xsrepl.js +2 -3
  126. package/xsnap-native/xsnap/makefiles/lin/makefile +10 -0
  127. package/xsnap-native/xsnap/makefiles/lin/xsnap-worker.mk +156 -0
  128. package/xsnap-native/xsnap/makefiles/lin/xsnap.mk +144 -0
  129. package/xsnap-native/xsnap/makefiles/mac/makefile +10 -0
  130. package/xsnap-native/xsnap/makefiles/mac/xsnap-worker.mk +165 -0
  131. package/xsnap-native/xsnap/makefiles/mac/xsnap.mk +153 -0
  132. package/xsnap-native/xsnap/sources/xsnap-worker.c +1008 -0
  133. package/xsnap-native/xsnap/sources/xsnap.c +717 -0
  134. package/xsnap-native/xsnap/sources/xsnap.h +142 -0
  135. package/xsnap-native/xsnap/sources/xsnapPlatform.c +1501 -0
  136. package/xsnap-native/xsnap/sources/xsnapPlatform.h +105 -0
  137. package/CHANGELOG.md +0 -654
@@ -0,0 +1,839 @@
1
+ /*
2
+ * Copyright (c) 2016-2017 Moddable Tech, Inc.
3
+ *
4
+ * This file is part of the Moddable SDK Runtime.
5
+ *
6
+ * The Moddable SDK Runtime is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * The Moddable SDK Runtime is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ * This file incorporates work covered by the following copyright and
20
+ * permission notice:
21
+ *
22
+ * Copyright (C) 2010-2016 Marvell International Ltd.
23
+ * Copyright (C) 2002-2010 Kinoma, Inc.
24
+ *
25
+ * Licensed under the Apache License, Version 2.0 (the "License");
26
+ * you may not use this file except in compliance with the License.
27
+ * You may obtain a copy of the License at
28
+ *
29
+ * http://www.apache.org/licenses/LICENSE-2.0
30
+ *
31
+ * Unless required by applicable law or agreed to in writing, software
32
+ * distributed under the License is distributed on an "AS IS" BASIS,
33
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
+ * See the License for the specific language governing permissions and
35
+ * limitations under the License.
36
+ */
37
+
38
+ #include "xsAll.h"
39
+
40
+ static void fx_trace_aux(txMachine* the, txInteger flags);
41
+
42
+ static const char ICACHE_RODATA_ATTR gxURIEmptySet[128] = {
43
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
44
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */
45
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */
46
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2x !"#$%&'()*+,-./ */
47
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3x 0123456789:;<=>? */
48
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4x @ABCDEFGHIJKLMNO */
49
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5X PQRSTUVWXYZ[\]^_ */
50
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6x `abcdefghijklmno */
51
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 7X pqrstuvwxyz{|}~ */
52
+ };
53
+
54
+ static const char ICACHE_RODATA_ATTR gxURIReservedSet[128] = {
55
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
56
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */
57
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */
58
+ 0,0,0,1,1,0,1,0,0,0,0,1,1,0,0,1, /* 2x !"#$%&'()*+,-./ */
59
+ 0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,1, /* 3x 0123456789:;<=>? */
60
+ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4x @ABCDEFGHIJKLMNO */
61
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5X PQRSTUVWXYZ[\]^_ */
62
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6x `abcdefghijklmno */
63
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 7X pqrstuvwxyz{|}~ */
64
+ };
65
+
66
+ static const char ICACHE_RODATA_ATTR gxURIUnescapedSet[128] = {
67
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
68
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */
69
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */
70
+ 0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0, /* 2x !"#$%&'()*+,-./ */
71
+ 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, /* 3x 0123456789:;<=>? */
72
+ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4x @ABCDEFGHIJKLMNO */
73
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, /* 5X PQRSTUVWXYZ[\]^_ */
74
+ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6x `abcdefghijklmno */
75
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0 /* 7X pqrstuvwxyz{|}~ */
76
+ };
77
+
78
+ static const char ICACHE_RODATA_ATTR gxURIReservedAndUnescapedSet[128] = {
79
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
80
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */
81
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */
82
+ 0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1, /* 2x !"#$%&'()*+,-./ */
83
+ 1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1, /* 3x 0123456789:;<=>? */
84
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4x @ABCDEFGHIJKLMNO */
85
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, /* 5X PQRSTUVWXYZ[\]^_ */
86
+ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6x `abcdefghijklmno */
87
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0 /* 7X pqrstuvwxyz{|}~ */
88
+ };
89
+
90
+ const txBehavior ICACHE_FLASH_ATTR gxGlobalBehavior = {
91
+ fxGlobalGetProperty,
92
+ fxGlobalSetProperty,
93
+ fxOrdinaryCall,
94
+ fxOrdinaryConstruct,
95
+ fxOrdinaryDefineOwnProperty,
96
+ fxGlobalDeleteProperty,
97
+ fxOrdinaryGetOwnProperty,
98
+ fxOrdinaryGetPropertyValue,
99
+ fxOrdinaryGetPrototype,
100
+ fxOrdinaryHasProperty,
101
+ fxOrdinaryIsExtensible,
102
+ fxOrdinaryOwnKeys,
103
+ fxOrdinaryPreventExtensions,
104
+ fxOrdinarySetPropertyValue,
105
+ fxOrdinarySetPrototype,
106
+ };
107
+
108
+ void fxBuildGlobal(txMachine* the)
109
+ {
110
+ txSlot* slot;
111
+
112
+ fxNewInstance(the);
113
+ mxPull(mxObjectPrototype);
114
+
115
+ mxPush(mxObjectPrototype);
116
+ fxNewFunctionInstance(the, XS_NO_ID);
117
+ mxPull(mxFunctionPrototype);
118
+
119
+ fxBuildHostFunction(the, mxCallback(fx_isFinite), 1, mxID(_isFinite));
120
+ mxPull(mxIsFiniteFunction);
121
+ fxBuildHostFunction(the, mxCallback(fx_isNaN), 1, mxID(_isNaN));
122
+ mxPull(mxIsNaNFunction);
123
+ fxBuildHostFunction(the, mxCallback(fx_parseFloat), 1, mxID(_parseFloat));
124
+ mxPull(mxParseFloatFunction);
125
+ fxBuildHostFunction(the, mxCallback(fx_parseInt), 2, mxID(_parseInt));
126
+ mxPull(mxParseIntFunction);
127
+ fxBuildHostFunction(the, mxCallback(fx_decodeURI), 1, mxID(_decodeURI));
128
+ mxPull(mxDecodeURIFunction);
129
+ fxBuildHostFunction(the, mxCallback(fx_decodeURIComponent), 1, mxID(_decodeURIComponent));
130
+ mxPull(mxDecodeURIComponentFunction);
131
+ fxBuildHostFunction(the, mxCallback(fx_encodeURI), 1, mxID(_encodeURI));
132
+ mxPull(mxEncodeURIFunction);
133
+ fxBuildHostFunction(the, mxCallback(fx_encodeURIComponent), 1, mxID(_encodeURIComponent));
134
+ mxPull(mxEncodeURIComponentFunction);
135
+ fxBuildHostFunction(the, mxCallback(fx_escape), 1, mxID(_escape));
136
+ mxPull(mxEscapeFunction);
137
+ fxBuildHostFunction(the, mxCallback(fx_eval), 1, mxID(_eval));
138
+ mxPull(mxEvalFunction);
139
+ fxBuildHostFunction(the, mxCallback(fx_unescape), 1, mxID(_unescape));
140
+ mxPull(mxUnescapeFunction);
141
+
142
+ slot = fxBuildHostFunction(the, mxCallback(fx_trace), 1, mxID(_trace));
143
+ slot = fxLastProperty(the, slot);
144
+ slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_trace_center), 1, mxID(_center), XS_DONT_ENUM_FLAG);
145
+ slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_trace_left), 1, mxID(_left), XS_DONT_ENUM_FLAG);
146
+ slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_trace_right), 1, mxID(_right), XS_DONT_ENUM_FLAG);
147
+ mxPull(mxTraceFunction);
148
+
149
+ mxPush(mxObjectPrototype);
150
+ slot = fxNewObjectInstance(the);
151
+ slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Iterator_iterator), 0, mxID(_Symbol_iterator), XS_DONT_ENUM_FLAG);
152
+ mxPull(mxIteratorPrototype);
153
+
154
+ mxPush(mxIteratorPrototype);
155
+ slot = fxLastProperty(the, fxNewObjectInstance(the));
156
+ slot = fxNextHostFunctionProperty(the, slot, mxCallback(fx_Enumerator_next), 0, mxID(_next), XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG);
157
+ fxNewHostConstructor(the, mxCallback(fx_Enumerator), 0, XS_NO_ID);
158
+ mxPull(mxEnumeratorFunction);
159
+
160
+ fxNewHostFunction(the, mxCallback(fxThrowTypeError), 0, XS_NO_ID, XS_NO_ID);
161
+ mxThrowTypeErrorFunction = *the->stack;
162
+ slot = the->stack->value.reference;
163
+ slot->flag |= XS_DONT_PATCH_FLAG;
164
+ slot = slot->next;
165
+ while (slot) {
166
+ slot->flag |= XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG;
167
+ slot = slot->next;
168
+ }
169
+ mxPop();
170
+ }
171
+
172
+ txSlot* fxNewGlobalInstance(txMachine* the)
173
+ {
174
+ txSlot* instance;
175
+ txSlot* property;
176
+ txSize size = fxMultiplyChunkSizes(the, XS_INTRINSICS_COUNT, sizeof(txSlot*));
177
+ instance = fxNewSlot(the);
178
+ instance->flag = XS_EXOTIC_FLAG;
179
+ instance->kind = XS_INSTANCE_KIND;
180
+ instance->value.instance.garbage = C_NULL;
181
+ instance->value.instance.prototype = the->stack->value.reference;
182
+ the->stack->value.reference = instance;
183
+ the->stack->kind = XS_REFERENCE_KIND;
184
+ property = instance->next = fxNewSlot(the);
185
+ property->value.table.address = (txSlot**)fxNewChunk(the, size);
186
+ c_memset(property->value.table.address, 0, size);
187
+ property->value.table.length = XS_INTRINSICS_COUNT;
188
+ property->flag = XS_INTERNAL_FLAG;
189
+ property->ID = XS_GLOBAL_BEHAVIOR;
190
+ property->kind = XS_GLOBAL_KIND;
191
+ return instance;
192
+ }
193
+
194
+ txSlot* fxCheckIteratorInstance(txMachine* the, txSlot* slot, txID id)
195
+ {
196
+ txSlot* instance;
197
+ if (slot->kind == XS_REFERENCE_KIND) {
198
+ instance = slot->value.reference;
199
+ slot = instance->next;
200
+ if (slot && (slot->flag & XS_INTERNAL_FLAG) && (slot->ID == id) && (slot->kind == XS_REFERENCE_KIND)) {
201
+ return instance;
202
+ }
203
+ }
204
+ mxTypeError("this is no iterator");
205
+ return C_NULL;
206
+ }
207
+
208
+ txSlot* fxCheckIteratorResult(txMachine* the, txSlot* result)
209
+ {
210
+ txSlot* value = result->value.reference->next;
211
+ while (value && (value->flag & XS_INTERNAL_FLAG))
212
+ value = value->next;
213
+ mxCheck(the, (value != C_NULL) && (value->ID == mxID(_value)));
214
+ mxCheck(the, (value->next != C_NULL) && (value->next->ID == mxID(_done)));
215
+ return value;
216
+ }
217
+
218
+ txBoolean fxIteratorNext(txMachine* the, txSlot* iterator, txSlot* next, txSlot* value)
219
+ {
220
+ mxPushSlot(iterator);
221
+ mxPushSlot(next);
222
+ mxCall();
223
+ mxRunCount(0);
224
+ if (!mxIsReference(the->stack))
225
+ mxTypeError("iterator result is no object");
226
+ mxDub();
227
+ mxGetID(mxID(_done));
228
+ if (fxToBoolean(the, the->stack)) {
229
+ mxPop();
230
+ mxPop();
231
+ return 0;
232
+ }
233
+ mxPop();
234
+ mxGetID(mxID(_value));
235
+ mxPullSlot(value);
236
+ return 1;
237
+ }
238
+
239
+ void fxIteratorReturn(txMachine* the, txSlot* iterator)
240
+ {
241
+ mxPush(mxException);
242
+ mxTry(the) {
243
+ mxPushSlot(iterator);
244
+ mxDub();
245
+ mxGetID(mxID(_return));
246
+ if (mxIsUndefined(the->stack))
247
+ mxPop();
248
+ else {
249
+ mxCall();
250
+ mxRunCount(0);
251
+ }
252
+ mxPop();
253
+ }
254
+ mxCatch(the) {
255
+ }
256
+ mxPull(mxException);
257
+ }
258
+
259
+ txBoolean fxGetIterator(txMachine* the, txSlot* iterable, txSlot* iterator, txSlot* next, txBoolean optional)
260
+ {
261
+ mxPushSlot(iterable);
262
+ mxDub();
263
+ mxGetID(mxID(_Symbol_iterator));
264
+ if (optional && (mxIsUndefined(the->stack) || mxIsNull(the->stack))) {
265
+ mxPop();
266
+ mxPop();
267
+ return 0;
268
+ }
269
+ mxCall();
270
+ mxRunCount(0);
271
+ if (!mxIsReference(the->stack))
272
+ mxTypeError("iterator is no object");
273
+ if (next) {
274
+ mxDub();
275
+ mxGetID(mxID(_next));
276
+ mxPullSlot(next);
277
+ }
278
+ mxPullSlot(iterator);
279
+ return 1;
280
+ }
281
+
282
+ txSlot* fxNewIteratorInstance(txMachine* the, txSlot* iterable, txID id)
283
+ {
284
+ txSlot* instance;
285
+ txSlot* result;
286
+ txSlot* property;
287
+ instance = fxNewObjectInstance(the);
288
+ mxPush(mxObjectPrototype);
289
+ result = fxNewObjectInstance(the);
290
+ property = fxNextUndefinedProperty(the, result, mxID(_value), XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG);
291
+ property = fxNextBooleanProperty(the, property, 0, mxID(_done), XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG);
292
+ property = fxNextSlotProperty(the, instance, the->stack, id, XS_INTERNAL_FLAG);
293
+ property = fxNextSlotProperty(the, property, iterable, XS_NO_ID, XS_INTERNAL_FLAG);
294
+ property = fxNextIntegerProperty(the, property, 0, XS_NO_ID, XS_INTERNAL_FLAG);
295
+ mxPop();
296
+ return instance;
297
+ }
298
+
299
+ void fx_Iterator_iterator(txMachine* the)
300
+ {
301
+ *mxResult = *mxThis;
302
+ }
303
+
304
+ void fx_Enumerator(txMachine* the)
305
+ {
306
+ txSlot* iterator;
307
+ txSlot* result;
308
+ txSlot* slot;
309
+ txSlot* keys;
310
+ txSlot* visited;
311
+
312
+ mxPush(mxEnumeratorFunction);
313
+ mxGetID(mxID(_prototype));
314
+ iterator = fxNewObjectInstance(the);
315
+ mxPullSlot(mxResult);
316
+ mxPush(mxObjectPrototype);
317
+ result = fxNewObjectInstance(the);
318
+ slot = fxNextUndefinedProperty(the, result, mxID(_value), XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG);
319
+ slot = fxNextBooleanProperty(the, slot, 0, mxID(_done), XS_DONT_DELETE_FLAG | XS_DONT_SET_FLAG);
320
+ slot = fxNextSlotProperty(the, iterator, the->stack, mxID(_result), XS_GET_ONLY);
321
+ mxPop();
322
+
323
+ slot = slot->next = fxNewSlot(the);
324
+ slot->flag = XS_GET_ONLY;
325
+ slot->ID = mxID(_iterable);
326
+ slot->kind = mxThis->kind;
327
+ slot->value = mxThis->value;
328
+ if (mxIsUndefined(slot) || mxIsNull(slot))
329
+ return;
330
+ fxToInstance(the, slot);
331
+
332
+ keys = fxNewInstance(the);
333
+ mxBehaviorOwnKeys(the, slot->value.reference, XS_EACH_NAME_FLAG, keys);
334
+ slot = slot->next = fxNewSlot(the);
335
+ slot->flag = XS_GET_ONLY;
336
+ slot->kind = XS_REFERENCE_KIND;
337
+ slot->value.reference = keys;
338
+ mxPop();
339
+
340
+ visited = fxNewInstance(the);
341
+ slot = slot->next = fxNewSlot(the);
342
+ slot->flag = XS_GET_ONLY;
343
+ slot->kind = XS_REFERENCE_KIND;
344
+ slot->value.reference = visited;
345
+ mxPop();
346
+ }
347
+
348
+ void fx_Enumerator_next(txMachine* the)
349
+ {
350
+ txSlot* iterator = fxGetInstance(the, mxThis);
351
+ txSlot* result = iterator->next;
352
+ txSlot* iterable = result->next;
353
+ txSlot* at = C_NULL;
354
+ if (mxIsReference(iterable)) {
355
+ txSlot* instance = iterable->value.reference;
356
+ txSlot* keys = iterable->next;
357
+ txSlot* visited = keys->next;
358
+ txSlot* slot;
359
+ txSlot* former;
360
+
361
+ keys = keys->value.reference;
362
+ visited = visited->value.reference;
363
+
364
+ mxPushUndefined();
365
+ slot = the->stack;
366
+ again:
367
+ while ((at = keys->next)) {
368
+ if (mxBehaviorGetOwnProperty(the, instance, at->value.at.id, at->value.at.index, slot)) {
369
+ txSlot** address = &(visited->next);
370
+ while ((former = *address)) {
371
+ if ((at->value.at.id == former->value.at.id) && (at->value.at.index == former->value.at.index))
372
+ break;
373
+ address = &(former->next);
374
+ }
375
+ if (!former) {
376
+ *address = at;
377
+ keys->next = at->next;
378
+ at->next = NULL;
379
+ if (!(slot->flag & XS_DONT_ENUM_FLAG)) {
380
+ fxKeyAt(the, at->value.at.id, at->value.at.index, result->value.reference->next);
381
+ break;
382
+ }
383
+ }
384
+ else
385
+ keys->next = at->next;
386
+ }
387
+ else
388
+ keys->next = at->next;
389
+ }
390
+ if (!at) {
391
+ if (mxBehaviorGetPrototype(the, instance, slot)) {
392
+ iterable->value.reference = instance = slot->value.reference;
393
+ mxBehaviorOwnKeys(the, instance, XS_EACH_NAME_FLAG, keys);
394
+ goto again;
395
+ }
396
+ }
397
+ mxPop();
398
+ }
399
+ if (!at) {
400
+ result->value.reference->next->kind = XS_UNDEFINED_KIND;
401
+ result->value.reference->next->next->value.boolean = 1;
402
+ }
403
+ mxResult->kind = result->kind;
404
+ mxResult->value = result->value;
405
+ }
406
+
407
+ txBoolean fxGlobalDeleteProperty(txMachine* the, txSlot* instance, txID id, txIndex index)
408
+ {
409
+ txBoolean result = fxOrdinaryDeleteProperty(the, instance, id, index);
410
+ if ((XS_SYMBOL_ID_COUNT <= id) && (id < XS_INTRINSICS_COUNT) && result) {
411
+ txSlot* globals = instance->next;
412
+ globals->value.table.address[id] = C_NULL;
413
+ }
414
+ return result;
415
+ }
416
+
417
+ txSlot* fxGlobalGetProperty(txMachine* the, txSlot* instance, txID id, txIndex index, txFlag flag)
418
+ {
419
+ txSlot* result = C_NULL;
420
+ if ((XS_SYMBOL_ID_COUNT <= id) && (id < XS_INTRINSICS_COUNT)) {
421
+ txSlot* globals = instance->next;
422
+ result = globals->value.table.address[id];
423
+ if (!result) {
424
+ result = fxOrdinaryGetProperty(the, instance, id, index, flag);
425
+ globals->value.table.address[id] = result;
426
+ }
427
+ }
428
+ if (!result)
429
+ result = fxOrdinaryGetProperty(the, instance, id, index, flag);
430
+ return result;
431
+ }
432
+
433
+ txSlot* fxGlobalSetProperty(txMachine* the, txSlot* instance, txID id, txIndex index, txFlag flag)
434
+ {
435
+ txSlot* result = C_NULL;
436
+ if ((XS_SYMBOL_ID_COUNT <= id) && (id < XS_INTRINSICS_COUNT)) {
437
+ txSlot* globals = instance->next;
438
+ result = globals->value.table.address[id];
439
+ if (!result) {
440
+ result = fxOrdinarySetProperty(the, instance, id, index, flag);
441
+ globals->value.table.address[id] = result;
442
+ }
443
+ }
444
+ if (!result)
445
+ result = fxOrdinarySetProperty(the, instance, id, index, flag);
446
+ return result;
447
+ }
448
+
449
+ void fx_decodeURI(txMachine* the)
450
+ {
451
+ if (mxArgc < 1)
452
+ mxSyntaxError("no URI parameter");
453
+ fxDecodeURI(the, (txString)gxURIReservedSet);
454
+ }
455
+
456
+ void fx_decodeURIComponent(txMachine* the)
457
+ {
458
+ if (mxArgc < 1)
459
+ mxSyntaxError("no URI Component parameter");
460
+ fxDecodeURI(the, (txString)gxURIEmptySet);
461
+ }
462
+
463
+ void fx_encodeURI(txMachine* the)
464
+ {
465
+ if (mxArgc < 1)
466
+ mxSyntaxError("no URI parameter");
467
+ fxEncodeURI(the, (txString)gxURIReservedAndUnescapedSet);
468
+ }
469
+
470
+ void fx_encodeURIComponent(txMachine* the)
471
+ {
472
+ if (mxArgc < 1)
473
+ mxSyntaxError("no URI Component parameter");
474
+ fxEncodeURI(the, (txString)gxURIUnescapedSet);
475
+ }
476
+
477
+ void fx_escape(txMachine* the)
478
+ {
479
+ static const char ICACHE_RODATA_ATTR gxSet[128] = {
480
+ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
481
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */
482
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */
483
+ 0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1, /* 2x !"#$%&'()*+,-./ */
484
+ 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0, /* 3x 0123456789:;<=>? */
485
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4x @ABCDEFGHIJKLMNO */
486
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1, /* 5X PQRSTUVWXYZ[\]^_ */
487
+ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6x `abcdefghijklmno */
488
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0 /* 7X pqrstuvwxyz{|}~ */
489
+ };
490
+ txString src;
491
+ txInteger length;
492
+ txInteger c;
493
+ txString dst;
494
+
495
+ if (mxArgc < 1) {
496
+ mxResult->value.string = mxUndefinedString.value.string;
497
+ mxResult->kind = mxUndefinedString.kind;
498
+ return;
499
+ }
500
+ src = fxToString(the, mxArgv(0));
501
+ length = 0;
502
+ while (((src = mxStringByteDecode(src, &c))) && (c != C_EOF)) {
503
+ if ((c < 128) && c_read8(gxSet + (int)c))
504
+ length = fxAddChunkSizes(the, length, 1);
505
+ else if (c < 256)
506
+ length = fxAddChunkSizes(the, length, 3);
507
+ else if (c < 0x10000)
508
+ length = fxAddChunkSizes(the, length, 6);
509
+ else
510
+ length = fxAddChunkSizes(the, length, 12);
511
+ }
512
+ if (length == (src - mxArgv(0)->value.string)) {
513
+ mxResult->value.string = mxArgv(0)->value.string;
514
+ mxResult->kind = mxArgv(0)->kind;
515
+ return;
516
+ }
517
+ mxResult->value.string = fxNewChunk(the, fxAddChunkSizes(the, length, 1));
518
+ mxResult->kind = XS_STRING_KIND;
519
+ src = mxArgv(0)->value.string;
520
+ dst = mxResult->value.string;
521
+ while (((src = mxStringByteDecode(src, &c))) && (c != C_EOF)) {
522
+ if ((c < 128) && c_read8(gxSet + (int)c))
523
+ *dst++ = (char)c;
524
+ else if (c < 256) {
525
+ *dst++ = '%';
526
+ dst = fxStringifyHexEscape(dst, c);
527
+ }
528
+ else {
529
+ *dst++ = '%';
530
+ *dst++ = 'u';
531
+ dst = fxStringifyUnicodeEscape(dst, c, '%');
532
+ }
533
+ }
534
+ *dst = 0;
535
+ }
536
+
537
+ void fx_eval(txMachine* the)
538
+ {
539
+ txStringStream aStream;
540
+ txSlot* realm;
541
+ txSlot* module = mxFunctionInstanceHome(mxFunction->value.reference)->value.home.module;
542
+ if (!module) module = mxProgram.value.reference;
543
+
544
+ realm = mxModuleInstanceInternal(module)->value.module.realm;
545
+ if (mxArgc < 1)
546
+ return;
547
+ if (!mxIsStringPrimitive(mxArgv(0))) {
548
+ *mxResult = *mxArgv(0);
549
+ return;
550
+ }
551
+ aStream.slot = mxArgv(0);
552
+ aStream.offset = 0;
553
+ aStream.size = mxStringLength(fxToString(the, mxArgv(0)));
554
+ fxRunScript(the, fxParseScript(the, &aStream, fxStringGetter, mxProgramFlag | mxEvalFlag), mxRealmGlobal(realm), C_NULL, mxRealmClosures(realm)->value.reference, C_NULL, module);
555
+ mxPullSlot(mxResult);
556
+ }
557
+
558
+ void fx_trace(txMachine* the)
559
+ {
560
+ //@@#ifdef mxDebug
561
+ int i;
562
+ for (i = 0; i < mxArgc; i++) {
563
+ fxToString(the, mxArgv(i));
564
+ fxReport(the, "%s", mxArgv(i)->value.string);
565
+ }
566
+ //#endif
567
+ }
568
+
569
+ void fx_trace_aux(txMachine* the, txInteger flags)
570
+ {
571
+ txSlot* conversation = C_NULL;
572
+ void* message = C_NULL;
573
+ txInteger length = 0;
574
+ if (mxArgc > 1) {
575
+ conversation = mxArgv(1);
576
+ fxToString(the, conversation);
577
+ }
578
+ if ((mxArgc > 0) && (mxArgv(0)->kind == XS_REFERENCE_KIND)) {
579
+ txSlot* slot = mxArgv(0)->value.reference->next;
580
+ if (slot && (slot->kind == XS_ARRAY_BUFFER_KIND)) {
581
+ txSlot* bufferInfo = slot->next;
582
+ length = bufferInfo->value.bufferInfo.length;
583
+ message = slot->value.arrayBuffer.address;
584
+ flags |= XS_BUBBLE_BINARY;
585
+ }
586
+ else if (slot && (slot->kind == XS_HOST_KIND)) {
587
+ txSlot* bufferInfo = slot->next;
588
+ if (bufferInfo && (bufferInfo->kind == XS_BUFFER_INFO_KIND)) {
589
+ length = bufferInfo->value.bufferInfo.length;
590
+ message = slot->value.host.data;
591
+ flags |= XS_BUBBLE_BINARY;
592
+ }
593
+ }
594
+ }
595
+ if (!message)
596
+ message = fxToString(the, mxArgv(0));
597
+ fxBubble(the, flags, message, length, (conversation) ? conversation->value.string : C_NULL);
598
+ }
599
+
600
+ void fx_trace_center(txMachine* the)
601
+ {
602
+ fx_trace_aux(the, XS_NO_FLAG);
603
+ }
604
+
605
+ void fx_trace_left(txMachine* the)
606
+ {
607
+ fx_trace_aux(the, XS_BUBBLE_LEFT);
608
+ }
609
+
610
+ void fx_trace_right(txMachine* the)
611
+ {
612
+ fx_trace_aux(the, XS_BUBBLE_RIGHT);
613
+ }
614
+
615
+ void fx_unescape(txMachine* the)
616
+ {
617
+ txString src;
618
+ txInteger length;
619
+ char c;
620
+ txInteger d;
621
+ txString dst;
622
+
623
+ if (mxArgc < 1) {
624
+ mxResult->value.string = mxUndefinedString.value.string;
625
+ mxResult->kind = mxUndefinedString.kind;
626
+ return;
627
+ }
628
+ src = fxToString(the, mxArgv(0));
629
+ length = 0;
630
+ while ((c = c_read8(src++))) {
631
+ if (c == '%') {
632
+ c = c_read8(src++);
633
+ if (c == 'u') {
634
+ if (fxParseUnicodeEscape(&src, &d, 0, '%'))
635
+ length += mxStringByteLength(d);
636
+ else
637
+ length += 2;
638
+ }
639
+ else {
640
+ src--;
641
+ if (fxParseHexEscape(&src, &d))
642
+ length += mxStringByteLength(d);
643
+ else
644
+ length += 1;
645
+ }
646
+ }
647
+ else
648
+ length += 1;
649
+ }
650
+ length += 1;
651
+ if (length == (src - mxArgv(0)->value.string)) {
652
+ mxResult->value.string = mxArgv(0)->value.string;
653
+ mxResult->kind = mxArgv(0)->kind;
654
+ return;
655
+ }
656
+ mxResult->value.string = fxNewChunk(the, length);
657
+ mxResult->kind = XS_STRING_KIND;
658
+ src = mxArgv(0)->value.string;
659
+ dst = mxResult->value.string;
660
+ while ((c = c_read8(src++))) {
661
+ if (c == '%') {
662
+ c = c_read8(src++);
663
+ d = 0;
664
+ if (c == 'u') {
665
+ if (fxParseUnicodeEscape(&src, &d, 0, '%'))
666
+ dst = mxStringByteEncode(dst, d);
667
+ else {
668
+ *dst++ = '%';
669
+ *dst++ = 'u';
670
+ }
671
+ }
672
+ else {
673
+ src--;
674
+ if (fxParseHexEscape(&src, &d))
675
+ dst = mxStringByteEncode(dst, d);
676
+ else
677
+ *dst++ = '%';
678
+ }
679
+ }
680
+ else
681
+ *dst++ = (txU1)c;
682
+ }
683
+ *dst = 0;
684
+ }
685
+
686
+ void fxDecodeURI(txMachine* the, txString theSet)
687
+ {
688
+ txString src;
689
+ txInteger length;
690
+ txInteger c, d;
691
+ const txUTF8Sequence *sequence;
692
+ txInteger size;
693
+ txString dst;
694
+
695
+ src = fxToString(the, mxArgv(0));
696
+ length = 0;
697
+ while ((c = c_read8(src++))) {
698
+ if (c == '%') {
699
+ if (!fxParseHexEscape(&src, &d))
700
+ mxURIError("invalid URI");
701
+ if ((d < 128) && c_read8(theSet + d))
702
+ length += 3;
703
+ else {
704
+ for (sequence = gxUTF8Sequences; sequence->size; sequence++) {
705
+ if ((d & sequence->cmask) == sequence->cval)
706
+ break;
707
+ }
708
+ if (!sequence->size)
709
+ mxURIError("invalid URI");
710
+ size = sequence->size - 1;
711
+ while (size > 0) {
712
+ c = c_read8(src++);
713
+ if (c != '%')
714
+ mxURIError("invalid URI");
715
+ if (!fxParseHexEscape(&src, &c))
716
+ mxURIError("invalid URI");
717
+ if ((c & 0xC0) != 0x80)
718
+ mxURIError("invalid URI");
719
+ d = (d << 6) | (c & 0x3F);
720
+ size--;
721
+ }
722
+ d &= sequence->lmask;
723
+ length += mxStringByteLength(d);
724
+ }
725
+ }
726
+ else
727
+ length += 1;
728
+ }
729
+ length += 1;
730
+ if (length == (src - mxArgv(0)->value.string)) {
731
+ mxResult->value.string = mxArgv(0)->value.string;
732
+ mxResult->kind = mxArgv(0)->kind;
733
+ return;
734
+ }
735
+ mxResult->value.string = fxNewChunk(the, length);
736
+ mxResult->kind = XS_STRING_KIND;
737
+ src = mxArgv(0)->value.string;
738
+ dst = mxResult->value.string;
739
+ while ((c = c_read8(src++))) {
740
+ if (c == '%') {
741
+ fxParseHexEscape(&src, &d);
742
+ if ((d < 128) && c_read8(theSet + d)) {
743
+ *dst++ = c_read8(src - 3);
744
+ *dst++ = c_read8(src - 2);
745
+ *dst++ = c_read8(src - 1);
746
+ }
747
+ else {
748
+ for (sequence = gxUTF8Sequences; sequence->size; sequence++) {
749
+ if ((d & sequence->cmask) == sequence->cval)
750
+ break;
751
+ }
752
+ size = sequence->size - 1;
753
+ while (size > 0) {
754
+ src++;
755
+ fxParseHexEscape(&src, &c);
756
+ d = (d << 6) | (c & 0x3F);
757
+ size--;
758
+ }
759
+ d &= sequence->lmask;
760
+ dst = mxStringByteEncode(dst, d);
761
+ }
762
+ }
763
+ else
764
+ *dst++ = c;
765
+ }
766
+ *dst = 0;
767
+ }
768
+
769
+ void fxEncodeURI(txMachine* the, txString theSet)
770
+ {
771
+ txString src;
772
+ txInteger length;
773
+ txInteger c;
774
+ txString dst;
775
+
776
+ src = fxToString(the, mxArgv(0));
777
+ length = 0;
778
+ while (((src = mxStringByteDecode(src, &c))) && (c != C_EOF)) {
779
+ if (c < 0x80) {
780
+ if (c_read8(theSet + c))
781
+ length += 1;
782
+ else
783
+ length += 3;
784
+ }
785
+ else if (c < 0x800)
786
+ length += 6;
787
+ else if ((0xD800 <= c) && (c <= 0xDFFF))
788
+ mxURIError("invalid string");
789
+ else if (c < 0x10000)
790
+ length += 9;
791
+ else
792
+ length += 12;
793
+ }
794
+ length += 1;
795
+ if (length == (src - mxArgv(0)->value.string)) {
796
+ mxResult->value.string = mxArgv(0)->value.string;
797
+ mxResult->kind = mxArgv(0)->kind;
798
+ return;
799
+ }
800
+ mxResult->value.string = fxNewChunk(the, length);
801
+ mxResult->kind = XS_STRING_KIND;
802
+ src = mxArgv(0)->value.string;
803
+ dst = mxResult->value.string;
804
+ while (((src = mxStringByteDecode(src, &c))) && (c != C_EOF)) {
805
+ if (c < 0x80) {
806
+ if (c_read8(theSet + c))
807
+ *dst++ = (char)c;
808
+ else {
809
+ *dst++ = '%';
810
+ dst = fxStringifyHexEscape(dst, c);
811
+ }
812
+ }
813
+ else if (c < 0x800) {
814
+ *dst++ = '%';
815
+ dst = fxStringifyHexEscape(dst, 0xC0 | (c >> 6));
816
+ *dst++ = '%';
817
+ dst = fxStringifyHexEscape(dst, 0x80 | (c & 0x3F));
818
+ }
819
+ else if (c < 0x10000) {
820
+ *dst++ = '%';
821
+ dst = fxStringifyHexEscape(dst, 0xE0 | (c >> 12));
822
+ *dst++ = '%';
823
+ dst = fxStringifyHexEscape(dst, 0x80 | ((c >> 6) & 0x3F));
824
+ *dst++ = '%';
825
+ dst = fxStringifyHexEscape(dst, 0x80 | (c & 0x3F));
826
+ }
827
+ else {
828
+ *dst++ = '%';
829
+ dst = fxStringifyHexEscape(dst, 0xF0 | (c >> 18));
830
+ *dst++ = '%';
831
+ dst = fxStringifyHexEscape(dst, 0x80 | ((c >> 12) & 0x3F));
832
+ *dst++ = '%';
833
+ dst = fxStringifyHexEscape(dst, 0x80 | ((c >> 6) & 0x3F));
834
+ *dst++ = '%';
835
+ dst = fxStringifyHexEscape(dst, 0x80 | (c & 0x3F));
836
+ }
837
+ }
838
+ *dst = 0;
839
+ }