b74db98c2e06575dfbba5d673893b9e3de507329
[WebKit-https.git] / Source / JavaScriptCore / Scripts / tests / builtins / expected / JavaScriptCore-Builtin.prototype-Separate.js-result
1 ### Begin File: BuiltinPrototypeBuiltins.h
2 /*
3  * Copyright (c) 2014, 2015, 2016 Apple Inc. All rights reserved.
4  * Copyright (c) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
5  * 
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 
15  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
19  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25  * THE POSSIBILITY OF SUCH DAMAGE.
26  * 
27  */
28
29 // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
30 // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
31
32 #pragma once
33
34
35
36 namespace JSC {
37 class FunctionExecutable;
38 }
39
40 namespace JSC {
41
42 /* Builtin.prototype */
43 extern const char* s_builtinPrototypeEveryCode;
44 extern const int s_builtinPrototypeEveryCodeLength;
45 extern const JSC::ConstructAbility s_builtinPrototypeEveryCodeConstructAbility;
46 extern const char* s_builtinPrototypeForEachCode;
47 extern const int s_builtinPrototypeForEachCodeLength;
48 extern const JSC::ConstructAbility s_builtinPrototypeForEachCodeConstructAbility;
49 extern const char* s_builtinPrototypeMatchCode;
50 extern const int s_builtinPrototypeMatchCodeLength;
51 extern const JSC::ConstructAbility s_builtinPrototypeMatchCodeConstructAbility;
52 extern const char* s_builtinPrototypeTestCode;
53 extern const int s_builtinPrototypeTestCodeLength;
54 extern const JSC::ConstructAbility s_builtinPrototypeTestCodeConstructAbility;
55
56 #define JSC_FOREACH_BUILTIN_PROTOTYPE_BUILTIN_DATA(macro) \
57     macro(every, builtinPrototypeEvery, 1) \
58     macro(forEach, builtinPrototypeForEach, 1) \
59     macro(match, builtinPrototypeMatch, 1) \
60     macro(test, builtinPrototypeTest, 1) \
61
62 #define JSC_BUILTIN_BUILTIN_PROTOTYPE_EVERY 1
63 #define JSC_BUILTIN_BUILTIN_PROTOTYPE_FOREACH 1
64 #define JSC_BUILTIN_BUILTIN_PROTOTYPE_MATCH 1
65 #define JSC_BUILTIN_BUILTIN_PROTOTYPE_TEST 1
66
67 #define JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_CODE(macro) \
68     macro(builtinPrototypeEveryCode, every, static_cast<const char*>(nullptr), s_builtinPrototypeEveryCodeLength) \
69     macro(builtinPrototypeForEachCode, forEach, static_cast<const char*>(nullptr), s_builtinPrototypeForEachCodeLength) \
70     macro(builtinPrototypeMatchCode, match, "[Symbol.match]", s_builtinPrototypeMatchCodeLength) \
71     macro(builtinPrototypeTestCode, test, static_cast<const char*>(nullptr), s_builtinPrototypeTestCodeLength) \
72
73 #define JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_FUNCTION_NAME(macro) \
74     macro(every) \
75     macro(forEach) \
76     macro(match) \
77     macro(test) \
78
79 #define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
80     JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
81
82 JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
83 #undef DECLARE_BUILTIN_GENERATOR
84
85 } // namespace JSC
86 ### End File: BuiltinPrototypeBuiltins.h
87
88 ### Begin File: BuiltinPrototypeBuiltins.cpp
89 /*
90  * Copyright (c) 2014, 2015, 2016 Apple Inc. All rights reserved.
91  * Copyright (c) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
92  * 
93  * Redistribution and use in source and binary forms, with or without
94  * modification, are permitted provided that the following conditions
95  * are met:
96  * 1. Redistributions of source code must retain the above copyright
97  *    notice, this list of conditions and the following disclaimer.
98  * 2. Redistributions in binary form must reproduce the above copyright
99  *    notice, this list of conditions and the following disclaimer in the
100  *    documentation and/or other materials provided with the distribution.
101  * 
102  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
103  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
104  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
105  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
106  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
107  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
108  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
109  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
110  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
111  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
112  * THE POSSIBILITY OF SUCH DAMAGE.
113  * 
114  */
115
116 // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
117 // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
118
119 #include "config.h"
120 #include "BuiltinPrototypeBuiltins.h"
121
122 #include "BuiltinExecutables.h"
123 #include "HeapInlines.h"
124 #include "IdentifierInlines.h"
125 #include "Intrinsic.h"
126 #include "JSCellInlines.h"
127 #include "VM.h"
128
129 namespace JSC {
130
131 const JSC::ConstructAbility s_builtinPrototypeEveryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
132 const int s_builtinPrototypeEveryCodeLength = 762;
133 static const JSC::Intrinsic s_builtinPrototypeEveryCodeIntrinsic = JSC::NoIntrinsic;
134 const char* s_builtinPrototypeEveryCode =
135     "(function (callback )\n" \
136     "{\n" \
137     "    \"use strict\";\n" \
138     "\n" \
139     "    if (this === null)\n" \
140     "        throw new @TypeError(\"Array.prototype.every requires that |this| not be null\");\n" \
141     "    \n" \
142     "    if (this === undefined)\n" \
143     "        throw new @TypeError(\"Array.prototype.every requires that |this| not be undefined\");\n" \
144     "    \n" \
145     "    var array = @Object(this);\n" \
146     "    var length = @toLength(array.length);\n" \
147     "\n" \
148     "    if (typeof callback !== \"function\")\n" \
149     "        throw new @TypeError(\"Array.prototype.every callback must be a function\");\n" \
150     "    \n" \
151     "    var thisArg = arguments.length > 1 ? arguments[1] : undefined;\n" \
152     "    \n" \
153     "    for (var i = 0; i < length; i++) {\n" \
154     "        if (!(i in array))\n" \
155     "            continue;\n" \
156     "        if (!callback.@call(thisArg, array[i], i, array))\n" \
157     "            return false;\n" \
158     "    }\n" \
159     "    \n" \
160     "    return true;\n" \
161     "})\n" \
162 ;
163
164 const JSC::ConstructAbility s_builtinPrototypeForEachCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
165 const int s_builtinPrototypeForEachCodeLength = 694;
166 static const JSC::Intrinsic s_builtinPrototypeForEachCodeIntrinsic = JSC::NoIntrinsic;
167 const char* s_builtinPrototypeForEachCode =
168     "(function (callback )\n" \
169     "{\n" \
170     "    \"use strict\";\n" \
171     "\n" \
172     "    if (this === null)\n" \
173     "        throw new @TypeError(\"Array.prototype.forEach requires that |this| not be null\");\n" \
174     "    \n" \
175     "    if (this === undefined)\n" \
176     "        throw new @TypeError(\"Array.prototype.forEach requires that |this| not be undefined\");\n" \
177     "    \n" \
178     "    var array = @Object(this);\n" \
179     "    var length = @toLength(array.length);\n" \
180     "\n" \
181     "    if (typeof callback !== \"function\")\n" \
182     "        throw new @TypeError(\"Array.prototype.forEach callback must be a function\");\n" \
183     "    \n" \
184     "    var thisArg = arguments.length > 1 ? arguments[1] : undefined;\n" \
185     "    \n" \
186     "    for (var i = 0; i < length; i++) {\n" \
187     "        if (i in array)\n" \
188     "            callback.@call(thisArg, array[i], i, array);\n" \
189     "    }\n" \
190     "})\n" \
191 ;
192
193 const JSC::ConstructAbility s_builtinPrototypeMatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
194 const int s_builtinPrototypeMatchCodeLength = 1238;
195 static const JSC::Intrinsic s_builtinPrototypeMatchCodeIntrinsic = JSC::NoIntrinsic;
196 const char* s_builtinPrototypeMatchCode =
197     "(function (strArg)\n" \
198     "{\n" \
199     "    \"use strict\";\n" \
200     "\n" \
201     "    if (!@isObject(this))\n" \
202     "        @throwTypeError(\"RegExp.prototype.@@match requires that |this| be an Object\");\n" \
203     "\n" \
204     "    let regexp = this;\n" \
205     "\n" \
206     "    //\n" \
207     "    if (!@hasObservableSideEffectsForRegExpMatch(regexp))\n" \
208     "        return @regExpMatchFast.@call(regexp, strArg);\n" \
209     "\n" \
210     "    let str = @toString(strArg);\n" \
211     "\n" \
212     "    if (!regexp.global)\n" \
213     "        return @regExpExec(regexp, str);\n" \
214     "    \n" \
215     "    let unicode = regexp.unicode;\n" \
216     "    regexp.lastIndex = 0;\n" \
217     "    let resultList = [];\n" \
218     "\n" \
219     "    //\n" \
220     "    //\n" \
221     "    //\n" \
222     "    const maximumReasonableMatchSize = 100000000;\n" \
223     "\n" \
224     "    while (true) {\n" \
225     "        let result = @regExpExec(regexp, str);\n" \
226     "        \n" \
227     "        if (result === null) {\n" \
228     "            if (resultList.length === 0)\n" \
229     "                return null;\n" \
230     "            return resultList;\n" \
231     "        }\n" \
232     "\n" \
233     "        if (resultList.length > maximumReasonableMatchSize)\n" \
234     "            @throwOutOfMemoryError();\n" \
235     "\n" \
236     "        if (!@isObject(result))\n" \
237     "            @throwTypeError(\"RegExp.prototype.@@match call to RegExp.exec didn't return null or an object\");\n" \
238     "\n" \
239     "        let resultString = @toString(result[0]);\n" \
240     "\n" \
241     "        if (!resultString.length)\n" \
242     "            regexp.lastIndex = @advanceStringIndex(str, regexp.lastIndex, unicode);\n" \
243     "\n" \
244     "        resultList.@push(resultString);\n" \
245     "    }\n" \
246     "})\n" \
247 ;
248
249 const JSC::ConstructAbility s_builtinPrototypeTestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
250 const int s_builtinPrototypeTestCodeLength = 504;
251 static const JSC::Intrinsic s_builtinPrototypeTestCodeIntrinsic = JSC::RegExpTestIntrinsic;
252 const char* s_builtinPrototypeTestCode =
253     "(function (strArg)\n" \
254     "{\n" \
255     "    \"use strict\";\n" \
256     "\n" \
257     "    let regexp = this;\n" \
258     "\n" \
259     "    //\n" \
260     "    if (@isRegExpObject(regexp) && @tryGetById(regexp, \"exec\") === @regExpBuiltinExec)\n" \
261     "        return @regExpTestFast.@call(regexp, strArg);\n" \
262     "\n" \
263     "    //\n" \
264     "    //\n" \
265     "    if (!@isObject(regexp))\n" \
266     "        @throwTypeError(\"RegExp.prototype.test requires that |this| be an Object\");\n" \
267     "\n" \
268     "    //\n" \
269     "    let str = @toString(strArg);\n" \
270     "\n" \
271     "    //\n" \
272     "    let match = @regExpExec(regexp, str);\n" \
273     "\n" \
274     "    //\n" \
275     "    if (match !== null)\n" \
276     "        return true;\n" \
277     "    return false;\n" \
278     "})\n" \
279 ;
280
281
282 #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
283 JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
284 {\
285     return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); }
286 JSC_FOREACH_BUILTIN.PROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
287 #undef DEFINE_BUILTIN_GENERATOR
288
289
290 } // namespace JSC
291 ### End File: BuiltinPrototypeBuiltins.cpp