File: JavaScriptCore-Operations.Promise-Combined.js-result

package info (click to toggle)
qtwebkit-opensource-src 5.212.0~alpha2-21
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 126,448 kB
  • sloc: cpp: 1,398,101; ansic: 32,876; perl: 19,440; python: 12,790; ruby: 10,299; xml: 8,371; asm: 5,078; yacc: 2,166; lex: 906; sh: 414; makefile: 43
file content (415 lines) | stat: -rw-r--r-- 18,308 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
### Begin File: JSCBuiltins.h
/*
 * Copyright (c) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */

// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py

#ifndef JSCBuiltins_h
#define JSCBuiltins_h

namespace JSC {
class FunctionExecutable;
class VM;

enum class ConstructAbility : unsigned;
}

namespace JSC {

/* Operations.Promise */
extern const char* s_operationsPromiseIsPromiseCode;
extern const int s_operationsPromiseIsPromiseCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseIsPromiseCodeConstructAbility;
extern const char* s_operationsPromiseNewPromiseReactionCode;
extern const int s_operationsPromiseNewPromiseReactionCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseNewPromiseReactionCodeConstructAbility;
extern const char* s_operationsPromiseNewPromiseCapabilityCode;
extern const int s_operationsPromiseNewPromiseCapabilityCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseNewPromiseCapabilityCodeConstructAbility;
extern const char* s_operationsPromiseTriggerPromiseReactionsCode;
extern const int s_operationsPromiseTriggerPromiseReactionsCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseTriggerPromiseReactionsCodeConstructAbility;
extern const char* s_operationsPromiseRejectPromiseCode;
extern const int s_operationsPromiseRejectPromiseCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseRejectPromiseCodeConstructAbility;
extern const char* s_operationsPromiseFulfillPromiseCode;
extern const int s_operationsPromiseFulfillPromiseCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseFulfillPromiseCodeConstructAbility;
extern const char* s_operationsPromiseCreateResolvingFunctionsCode;
extern const int s_operationsPromiseCreateResolvingFunctionsCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseCreateResolvingFunctionsCodeConstructAbility;
extern const char* s_operationsPromisePromiseReactionJobCode;
extern const int s_operationsPromisePromiseReactionJobCodeLength;
extern const JSC::ConstructAbility s_operationsPromisePromiseReactionJobCodeConstructAbility;
extern const char* s_operationsPromisePromiseResolveThenableJobCode;
extern const int s_operationsPromisePromiseResolveThenableJobCodeLength;
extern const JSC::ConstructAbility s_operationsPromisePromiseResolveThenableJobCodeConstructAbility;
extern const char* s_operationsPromiseInitializePromiseCode;
extern const int s_operationsPromiseInitializePromiseCodeLength;
extern const JSC::ConstructAbility s_operationsPromiseInitializePromiseCodeConstructAbility;

#define JSC_FOREACH_OPERATIONSPROMISE_BUILTIN_DATA(macro) \
    macro(isPromise, operationsPromiseIsPromise, 1) \
    macro(newPromiseReaction, operationsPromiseNewPromiseReaction, 2) \
    macro(newPromiseCapability, operationsPromiseNewPromiseCapability, 1) \
    macro(triggerPromiseReactions, operationsPromiseTriggerPromiseReactions, 2) \
    macro(rejectPromise, operationsPromiseRejectPromise, 2) \
    macro(fulfillPromise, operationsPromiseFulfillPromise, 2) \
    macro(createResolvingFunctions, operationsPromiseCreateResolvingFunctions, 1) \
    macro(promiseReactionJob, operationsPromisePromiseReactionJob, 2) \
    macro(promiseResolveThenableJob, operationsPromisePromiseResolveThenableJob, 3) \
    macro(initializePromise, operationsPromiseInitializePromise, 1) \

#define JSC_BUILTIN_OPERATIONSPROMISE_ISPROMISE 1
#define JSC_BUILTIN_OPERATIONSPROMISE_NEWPROMISEREACTION 1
#define JSC_BUILTIN_OPERATIONSPROMISE_NEWPROMISECAPABILITY 1
#define JSC_BUILTIN_OPERATIONSPROMISE_TRIGGERPROMISEREACTIONS 1
#define JSC_BUILTIN_OPERATIONSPROMISE_REJECTPROMISE 1
#define JSC_BUILTIN_OPERATIONSPROMISE_FULFILLPROMISE 1
#define JSC_BUILTIN_OPERATIONSPROMISE_CREATERESOLVINGFUNCTIONS 1
#define JSC_BUILTIN_OPERATIONSPROMISE_PROMISEREACTIONJOB 1
#define JSC_BUILTIN_OPERATIONSPROMISE_PROMISERESOLVETHENABLEJOB 1
#define JSC_BUILTIN_OPERATIONSPROMISE_INITIALIZEPROMISE 1

#define JSC_FOREACH_BUILTIN_CODE(macro) \
    macro(operationsPromiseIsPromiseCode, isPromise, s_operationsPromiseIsPromiseCodeLength) \
    macro(operationsPromiseNewPromiseReactionCode, newPromiseReaction, s_operationsPromiseNewPromiseReactionCodeLength) \
    macro(operationsPromiseNewPromiseCapabilityCode, newPromiseCapability, s_operationsPromiseNewPromiseCapabilityCodeLength) \
    macro(operationsPromiseTriggerPromiseReactionsCode, triggerPromiseReactions, s_operationsPromiseTriggerPromiseReactionsCodeLength) \
    macro(operationsPromiseRejectPromiseCode, rejectPromise, s_operationsPromiseRejectPromiseCodeLength) \
    macro(operationsPromiseFulfillPromiseCode, fulfillPromise, s_operationsPromiseFulfillPromiseCodeLength) \
    macro(operationsPromiseCreateResolvingFunctionsCode, createResolvingFunctions, s_operationsPromiseCreateResolvingFunctionsCodeLength) \
    macro(operationsPromisePromiseReactionJobCode, promiseReactionJob, s_operationsPromisePromiseReactionJobCodeLength) \
    macro(operationsPromisePromiseResolveThenableJobCode, promiseResolveThenableJob, s_operationsPromisePromiseResolveThenableJobCodeLength) \
    macro(operationsPromiseInitializePromiseCode, initializePromise, s_operationsPromiseInitializePromiseCodeLength) \

#define JSC_FOREACH_BUILTIN_FUNCTION_NAME(macro) \
    macro(createResolvingFunctions) \
    macro(fulfillPromise) \
    macro(initializePromise) \
    macro(isPromise) \
    macro(newPromiseCapability) \
    macro(newPromiseReaction) \
    macro(promiseReactionJob) \
    macro(promiseResolveThenableJob) \
    macro(rejectPromise) \
    macro(triggerPromiseReactions) \

#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
    JSC::FunctionExecutable* codeName##Generator(JSC::VM&);

JSC_FOREACH_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
#undef DECLARE_BUILTIN_GENERATOR

#define JSC_BUILTIN_EXISTS(object, func) defined JSC_BUILTIN_ ## object ## _ ## func

} // namespace JSC

#endif // JSCBuiltins_h

### End File: JSCBuiltins.h

### Begin File: JSCBuiltins.cpp
/*
 * Copyright (c) 2015 Yusuke Suzuki <utatane.tea@gmail.com>.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */

// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py

#include "config.h"
#include "JSCBuiltins.h"

#include "BuiltinExecutables.h"
#include "Executable.h"
#include "JSCellInlines.h"
#include "VM.h"

namespace JSC {

const JSC::ConstructAbility s_operationsPromiseIsPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseIsPromiseCodeLength = 158;
const char* s_operationsPromiseIsPromiseCode =
   "(function (promise)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    return @isObject(promise) && !!promise.@promiseState;\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseNewPromiseReactionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseNewPromiseReactionCodeLength = 220;
const char* s_operationsPromiseNewPromiseReactionCode =
   "(function (capability, handler)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    return {\n" \
   "        @capabilities: capability,\n" \
   "        @handler: handler\n" \
   "    };\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseNewPromiseCapabilityCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseNewPromiseCapabilityCodeLength = 1427;
const char* s_operationsPromiseNewPromiseCapabilityCode =
   "(function (constructor)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    //\n" \
   "    if (typeof constructor !== \"function\")\n" \
   "        throw new @TypeError(\"promise capability requires a constructor function\");\n" \
   "\n" \
   "    var promiseCapability = {\n" \
   "        @promise: undefined,\n" \
   "        @resolve: undefined,\n" \
   "        @reject: undefined\n" \
   "    };\n" \
   "\n" \
   "    function executor(resolve, reject)\n" \
   "    {\n" \
   "        if (promiseCapability.@resolve !== undefined)\n" \
   "            throw new @TypeError(\"resolve function is already set\");\n" \
   "        if (promiseCapability.@reject !== undefined)\n" \
   "            throw new @TypeError(\"reject function is already set\");\n" \
   "\n" \
   "        promiseCapability.@resolve = resolve;\n" \
   "        promiseCapability.@reject = reject;\n" \
   "    }\n" \
   "\n" \
   "    var promise = new constructor(executor);\n" \
   "\n" \
   "    if (typeof promiseCapability.@resolve !== \"function\")\n" \
   "        throw new @TypeError(\"executor did not take a resolve function\");\n" \
   "\n" \
   "    if (typeof promiseCapability.@reject !== \"function\")\n" \
   "        throw new @TypeError(\"executor did not take a reject function\");\n" \
   "\n" \
   "    promiseCapability.@promise = promise;\n" \
   "\n" \
   "    return promiseCapability;\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseTriggerPromiseReactionsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseTriggerPromiseReactionsCodeLength = 269;
const char* s_operationsPromiseTriggerPromiseReactionsCode =
   "(function (reactions, argument)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    for (var index = 0, length = reactions.length; index < length; ++index)\n" \
   "        @enqueueJob(@promiseReactionJob, [reactions[index], argument]);\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseRejectPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseRejectPromiseCodeLength = 541;
const char* s_operationsPromiseRejectPromiseCode =
   "(function (promise, reason)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    var reactions = promise.@promiseRejectReactions;\n" \
   "    promise.@promiseResult = reason;\n" \
   "    promise.@promiseFulfillReactions = undefined;\n" \
   "    promise.@promiseRejectReactions = undefined;\n" \
   "    promise.@promiseState = @promiseRejected;\n" \
   "\n" \
   "    @InspectorInstrumentation.promiseRejected(promise, reason, reactions);\n" \
   "\n" \
   "    @triggerPromiseReactions(reactions, reason);\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseFulfillPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseFulfillPromiseCodeLength = 540;
const char* s_operationsPromiseFulfillPromiseCode =
   "(function (promise, value)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    var reactions = promise.@promiseFulfillReactions;\n" \
   "    promise.@promiseResult = value;\n" \
   "    promise.@promiseFulfillReactions = undefined;\n" \
   "    promise.@promiseRejectReactions = undefined;\n" \
   "    promise.@promiseState = @promiseFulfilled;\n" \
   "\n" \
   "    @InspectorInstrumentation.promiseFulfilled(promise, value, reactions);\n" \
   "\n" \
   "    @triggerPromiseReactions(reactions, value);\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseCreateResolvingFunctionsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseCreateResolvingFunctionsCodeLength = 1468;
const char* s_operationsPromiseCreateResolvingFunctionsCode =
   "(function (promise)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    var alreadyResolved = false;\n" \
   "\n" \
   "    var resolve = function (resolution) {\n" \
   "        if (alreadyResolved)\n" \
   "            return undefined;\n" \
   "        alreadyResolved = true;\n" \
   "\n" \
   "        if (resolution === promise)\n" \
   "            return @rejectPromise(promise, new @TypeError(\"Resolve a promise with itself\"));\n" \
   "\n" \
   "        if (!@isObject(resolution))\n" \
   "            return @fulfillPromise(promise, resolution);\n" \
   "\n" \
   "        var then;\n" \
   "        try {\n" \
   "            then = resolution.then;\n" \
   "        } catch (error) {\n" \
   "            return @rejectPromise(promise, error);\n" \
   "        }\n" \
   "\n" \
   "        if (typeof then !== 'function')\n" \
   "            return @fulfillPromise(promise, resolution);\n" \
   "\n" \
   "        @enqueueJob(@promiseResolveThenableJob, [promise, resolution, then]);\n" \
   "\n" \
   "        return undefined;\n" \
   "    };\n" \
   "\n" \
   "    var reject = function (reason) {\n" \
   "        if (alreadyResolved)\n" \
   "            return undefined;\n" \
   "        alreadyResolved = true;\n" \
   "\n" \
   "        return @rejectPromise(promise, reason);\n" \
   "    };\n" \
   "\n" \
   "    return {\n" \
   "        @resolve: resolve,\n" \
   "        @reject: reject\n" \
   "    };\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromisePromiseReactionJobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromisePromiseReactionJobCodeLength = 493;
const char* s_operationsPromisePromiseReactionJobCode =
   "(function (reaction, argument)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    var promiseCapability = reaction.@capabilities;\n" \
   "\n" \
   "    var result;\n" \
   "    try {\n" \
   "        result = reaction.@handler.@call(undefined, argument);\n" \
   "    } catch (error) {\n" \
   "        return promiseCapability.@reject.@call(undefined, error);\n" \
   "    }\n" \
   "\n" \
   "    return promiseCapability.@resolve.@call(undefined, result);\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromisePromiseResolveThenableJobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromisePromiseResolveThenableJobCodeLength = 453;
const char* s_operationsPromisePromiseResolveThenableJobCode =
   "(function (promiseToResolve, thenable, then)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    var resolvingFunctions = @createResolvingFunctions(promiseToResolve);\n" \
   "\n" \
   "    try {\n" \
   "        return then.@call(thenable, resolvingFunctions.@resolve, resolvingFunctions.@reject);\n" \
   "    } catch (error) {\n" \
   "        return resolvingFunctions.@reject.@call(undefined, error);\n" \
   "    }\n" \
   "})\n" \
;

const JSC::ConstructAbility s_operationsPromiseInitializePromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
const int s_operationsPromiseInitializePromiseCodeLength = 731;
const char* s_operationsPromiseInitializePromiseCode =
   "(function (executor)\n" \
   "{\n" \
   "    \"use strict\";\n" \
   "\n" \
   "    if (typeof executor !== 'function')\n" \
   "        throw new @TypeError(\"Promise constructor takes a function argument\");\n" \
   "\n" \
   "    this.@promiseState = @promisePending;\n" \
   "    this.@promiseFulfillReactions = [];\n" \
   "    this.@promiseRejectReactions = [];\n" \
   "\n" \
   "    var resolvingFunctions = @createResolvingFunctions(this);\n" \
   "    try {\n" \
   "        executor(resolvingFunctions.@resolve, resolvingFunctions.@reject);\n" \
   "    } catch (error) {\n" \
   "        return resolvingFunctions.@reject.@call(undefined, error);\n" \
   "    }\n" \
   "\n" \
   "    return this;\n" \
   "})\n" \
;


#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, argumentCount) \
JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
{\
    return vm.builtinExecutables()->codeName##Executable()->link(vm, vm.builtinExecutables()->codeName##Source()); }
JSC_FOREACH_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
#undef DEFINE_BUILTIN_GENERATOR


} // namespace JSC
### End File: JSCBuiltins.cpp