Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_bi_object.c File Reference
#include "duk_internal.h"

Go to the source code of this file.

Functions

DUK_INTERNAL duk_ret_t duk_bi_object_constructor (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_getprototype_shared (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_setprototype_shared (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_create (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_property (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_properties (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_seal_freeze_shared (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_prevent_extensions (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_extensible (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_keys_shared (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_locale_string (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_prototype_value_of (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_prototype_is_prototype_of (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_prototype_has_own_property (duk_context *ctx)
 
DUK_INTERNAL duk_ret_t duk_bi_object_prototype_property_is_enumerable (duk_context *ctx)
 

Function Documentation

◆ duk_bi_object_constructor()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor ( duk_context * ctx)

Definition at line 7 of file duktape-1.5.2/src-separate/duk_bi_object.c.

7 {
8 if (!duk_is_constructor_call(ctx) &&
10 duk_to_object(ctx, 0);
11 return 1;
12 }
13
14 if (duk_is_object(ctx, 0)) {
15 return 1;
16 }
17
18 /* Pointer and buffer primitive values are treated like other
19 * primitives values which have a fully fledged object counterpart:
20 * promote to an object value. Lightfuncs are coerced with
21 * ToObject() even they could also be returned as is.
22 */
29 duk_to_object(ctx, 0);
30 return 1;
31 }
32
37 return 1;
38}
#define DUK_HOBJECT_CLASS_OBJECT
#define DUK_BIDX_OBJECT_PROTOTYPE
DUK_EXTERNAL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask)
#define DUK_HOBJECT_CLASS_AS_FLAGS(v)
DUK_EXTERNAL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_bool_t duk_is_constructor_call(duk_context *ctx)
#define DUK_HOBJECT_FLAG_EXTENSIBLE
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
DUK_EXTERNAL duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_to_object(duk_context *ctx, duk_idx_t index)
#define DUK_TYPE_MASK_STRING
#define DUK_TYPE_MASK_BUFFER
#define DUK_TYPE_MASK_LIGHTFUNC
#define DUK_TYPE_MASK_NUMBER
#define DUK_TYPE_MASK_BOOLEAN
#define DUK_TYPE_MASK_POINTER

References DUK_BIDX_OBJECT_PROTOTYPE, duk_check_type_mask(), DUK_HOBJECT_CLASS_AS_FLAGS, DUK_HOBJECT_CLASS_OBJECT, DUK_HOBJECT_FLAG_EXTENSIBLE, duk_is_constructor_call(), duk_is_null_or_undefined(), duk_is_object(), duk_push_object_helper(), duk_to_object(), DUK_TYPE_MASK_BOOLEAN, DUK_TYPE_MASK_BUFFER, DUK_TYPE_MASK_LIGHTFUNC, DUK_TYPE_MASK_NUMBER, DUK_TYPE_MASK_POINTER, and DUK_TYPE_MASK_STRING.

◆ duk_bi_object_constructor_create()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_create ( duk_context * ctx)

Definition at line 158 of file duktape-1.5.2/src-separate/duk_bi_object.c.

158 {
159 duk_tval *tv;
161
162 DUK_ASSERT_TOP(ctx, 2);
163
164 tv = duk_get_tval(ctx, 0);
165 DUK_ASSERT(tv != NULL);
166 if (DUK_TVAL_IS_NULL(tv)) {
167 ;
168 } else if (DUK_TVAL_IS_OBJECT(tv)) {
171 } else {
172 return DUK_RET_TYPE_ERROR;
173 }
174
178 proto);
179
180 if (!duk_is_undefined(ctx, 1)) {
181 /* [ O Properties obj ] */
182
183 duk_replace(ctx, 0);
184
185 /* [ obj Properties ] */
186
187 /* Just call the "original" Object.defineProperties() to
188 * finish up.
189 */
190
192 }
193
194 /* [ O Properties obj ] */
195
196 return 1;
197}
const char * proto
Definition civetweb.c:18378
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto)
DUK_EXTERNAL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index)
#define DUK_TVAL_GET_OBJECT(tv)
#define DUK_TVAL_IS_NULL(tv)
#define DUK_TVAL_IS_OBJECT(tv)
DUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_index)
#define DUK_ASSERT_TOP(ctx, n)
DUK_INTERNAL_DECL duk_tval * duk_get_tval(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_properties(duk_context *ctx)
#define NULL
Definition gmacros.h:924

References DUK_ASSERT, DUK_ASSERT_TOP, duk_bi_object_constructor_define_properties(), duk_get_tval(), DUK_HOBJECT_CLASS_AS_FLAGS, DUK_HOBJECT_CLASS_OBJECT, DUK_HOBJECT_FLAG_EXTENSIBLE, duk_is_undefined(), duk_push_object_helper_proto(), duk_replace(), DUK_RET_TYPE_ERROR, DUK_TVAL_GET_OBJECT, DUK_TVAL_IS_NULL, DUK_TVAL_IS_OBJECT, NULL, and proto.

◆ duk_bi_object_constructor_define_properties()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_properties ( duk_context * ctx)

Definition at line 269 of file duktape-1.5.2/src-separate/duk_bi_object.c.

269 {
270 duk_small_uint_t pass;
271 duk_uint_t defprop_flags;
272 duk_hobject *obj;
273 duk_idx_t idx_value;
274 duk_hobject *get;
275 duk_hobject *set;
276
277 /* Lightfunc handling by ToObject() coercion. */
278 obj = duk_require_hobject_or_lfunc_coerce(ctx, 0); /* target */
279 DUK_ASSERT(obj != NULL);
280
281 duk_to_object(ctx, 1); /* properties object */
282
283 DUK_DDD(DUK_DDDPRINT("target=%!iT, properties=%!iT",
284 (duk_tval *) duk_get_tval(ctx, 0),
285 (duk_tval *) duk_get_tval(ctx, 1)));
286
287 /*
288 * Two pass approach to processing the property descriptors.
289 * On first pass validate and normalize all descriptors before
290 * any changes are made to the target object. On second pass
291 * make the actual modifications to the target object.
292 *
293 * Right now we'll just use the same normalize/validate helper
294 * on both passes, ignoring its outputs on the first pass.
295 */
296
297 for (pass = 0; pass < 2; pass++) {
298 duk_set_top(ctx, 2); /* -> [ hobject props ] */
299 duk_enum(ctx, 1, DUK_ENUM_OWN_PROPERTIES_ONLY /*enum_flags*/);
300
301 for (;;) {
302 duk_hstring *key;
303
304 /* [ hobject props enum(props) ] */
305
306 duk_set_top(ctx, 3);
307
308 if (!duk_next(ctx, 2, 1 /*get_value*/)) {
309 break;
310 }
311
312 DUK_DDD(DUK_DDDPRINT("-> key=%!iT, desc=%!iT",
313 (duk_tval *) duk_get_tval(ctx, -2),
314 (duk_tval *) duk_get_tval(ctx, -1)));
315
316 /* [ hobject props enum(props) key desc ] */
317
319 4 /*idx_desc*/,
320 &defprop_flags,
321 &idx_value,
322 &get,
323 &set);
324
325 /* [ hobject props enum(props) key desc value? getter? setter? ] */
326
327 if (pass == 0) {
328 continue;
329 }
330
331 key = duk_get_hstring(ctx, 3);
332 DUK_ASSERT(key != NULL);
333
335 defprop_flags,
336 obj,
337 key,
338 idx_value,
339 get,
340 set);
341 }
342 }
343
344 /*
345 * Return target object
346 */
347
348 duk_dup(ctx, 0);
349 return 1;
350}
unsigned int duk_small_uint_t
duk_uint_fast32_t duk_uint_t
DUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags)
DUK_EXTERNAL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value)
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_set_top(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_dup(duk_context *ctx, duk_idx_t from_index)
DUK_INTERNAL_DECL void duk_hobject_prepare_property_descriptor(duk_context *ctx, duk_idx_t idx_in, duk_uint_t *out_defprop_flags, duk_idx_t *out_idx_value, duk_hobject **out_getter, duk_hobject **out_setter)
DUK_INTERNAL_DECL void duk_hobject_define_property_helper(duk_context *ctx, duk_uint_t defprop_flags, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_value, duk_hobject *get, duk_hobject *set)
DUK_INTERNAL_DECL duk_hstring * duk_get_hstring(duk_context *ctx, duk_idx_t index)
#define DUK_ENUM_OWN_PROPERTIES_ONLY

References DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, duk_dup(), duk_enum(), DUK_ENUM_OWN_PROPERTIES_ONLY, duk_get_hstring(), duk_get_tval(), duk_hobject_define_property_helper(), duk_hobject_prepare_property_descriptor(), duk_next(), duk_require_hobject_or_lfunc_coerce(), duk_set_top(), duk_to_object(), and NULL.

Referenced by duk_bi_object_constructor_create().

◆ duk_bi_object_constructor_define_property()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_property ( duk_context * ctx)

Definition at line 199 of file duktape-1.5.2/src-separate/duk_bi_object.c.

199 {
200 duk_hobject *obj;
201 duk_hstring *key;
202 duk_hobject *get;
203 duk_hobject *set;
204 duk_idx_t idx_value;
205 duk_uint_t defprop_flags;
206
207 DUK_ASSERT(ctx != NULL);
208
209 DUK_DDD(DUK_DDDPRINT("Object.defineProperty(): ctx=%p obj=%!T key=%!T desc=%!T",
210 (void *) ctx,
211 (duk_tval *) duk_get_tval(ctx, 0),
212 (duk_tval *) duk_get_tval(ctx, 1),
213 (duk_tval *) duk_get_tval(ctx, 2)));
214
215 /* [ obj key desc ] */
216
217 /* Lightfuncs are currently supported by coercing to a temporary
218 * Function object; changes will be allowed (the coerced value is
219 * extensible) but will be lost.
220 */
222 (void) duk_to_string(ctx, 1);
223 key = duk_require_hstring(ctx, 1);
224 (void) duk_require_hobject(ctx, 2);
225
226 DUK_ASSERT(obj != NULL);
227 DUK_ASSERT(key != NULL);
228 DUK_ASSERT(duk_get_hobject(ctx, 2) != NULL);
229
230 /*
231 * Validate and convert argument property descriptor (an Ecmascript
232 * object) into a set of defprop_flags and possibly property value,
233 * getter, and/or setter values on the value stack.
234 *
235 * Lightfunc set/get values are coerced to full Functions.
236 */
237
239 2 /*idx_desc*/,
240 &defprop_flags,
241 &idx_value,
242 &get,
243 &set);
244
245 /*
246 * Use Object.defineProperty() helper for the actual operation.
247 */
248
250 defprop_flags,
251 obj,
252 key,
253 idx_value,
254 get,
255 set);
256
257 /* Ignore the normalize/validate helper outputs on the value stack,
258 * they're popped automatically.
259 */
260
261 /*
262 * Return target object.
263 */
264
265 duk_push_hobject(ctx, obj);
266 return 1;
267}
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL const char * duk_to_string(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_push_hobject(duk_context *ctx, duk_hobject *h)
DUK_INTERNAL_DECL duk_hstring * duk_require_hstring(duk_context *ctx, duk_idx_t index)

References DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, duk_get_hobject(), duk_get_tval(), duk_hobject_define_property_helper(), duk_hobject_prepare_property_descriptor(), duk_push_hobject(), duk_require_hobject(), duk_require_hobject_or_lfunc_coerce(), duk_require_hstring(), duk_to_string(), and NULL.

◆ duk_bi_object_constructor_get_own_property_descriptor()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor ( duk_context * ctx)

Definition at line 153 of file duktape-1.5.2/src-separate/duk_bi_object.c.

153 {
154 /* XXX: no need for indirect call */
156}
DUK_INTERNAL_DECL duk_ret_t duk_hobject_object_get_own_property_descriptor(duk_context *ctx)

References duk_hobject_object_get_own_property_descriptor().

◆ duk_bi_object_constructor_is_extensible()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_extensible ( duk_context * ctx)

Definition at line 411 of file duktape-1.5.2/src-separate/duk_bi_object.c.

411 {
412 duk_hobject *h;
413
415 if (!h) {
416 duk_push_false(ctx);
417 } else {
419 }
420 return 1;
421}
DUK_EXTERNAL void duk_push_boolean(duk_context *ctx, duk_bool_t val)
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_push_false(duk_context *ctx)
#define DUK_HOBJECT_HAS_EXTENSIBLE(h)

References DUK_HOBJECT_HAS_EXTENSIBLE, duk_push_boolean(), duk_push_false(), and duk_require_hobject_or_lfunc().

◆ duk_bi_object_constructor_is_sealed_frozen_shared()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared ( duk_context * ctx)

Definition at line 395 of file duktape-1.5.2/src-separate/duk_bi_object.c.

395 {
396 duk_hobject *h;
397 duk_bool_t is_frozen;
398 duk_bool_t rc;
399
401 if (!h) {
402 duk_push_true(ctx); /* frozen and sealed */
403 } else {
404 is_frozen = duk_get_current_magic(ctx);
405 rc = duk_hobject_object_is_sealed_frozen_helper((duk_hthread *) ctx, h, is_frozen /*is_frozen*/);
406 duk_push_boolean(ctx, rc);
407 }
408 return 1;
409}
duk_small_int_t duk_bool_t
DUK_EXTERNAL void duk_push_true(duk_context *ctx)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_is_sealed_frozen_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_frozen)
DUK_EXTERNAL duk_int_t duk_get_current_magic(duk_context *ctx)

References duk_get_current_magic(), duk_hobject_object_is_sealed_frozen_helper(), duk_push_boolean(), duk_push_true(), and duk_require_hobject_or_lfunc().

◆ duk_bi_object_constructor_keys_shared()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_keys_shared ( duk_context * ctx)

Definition at line 426 of file duktape-1.5.2/src-separate/duk_bi_object.c.

426 {
427 duk_hthread *thr = (duk_hthread *) ctx;
428 duk_hobject *obj;
429#if defined(DUK_USE_ES6_PROXY)
430 duk_hobject *h_proxy_target;
431 duk_hobject *h_proxy_handler;
432 duk_hobject *h_trap_result;
433 duk_uarridx_t i, len, idx;
434#endif
435 duk_small_uint_t enum_flags;
436
437 DUK_ASSERT_TOP(ctx, 1);
438 DUK_UNREF(thr);
439
441 DUK_ASSERT(obj != NULL);
442 DUK_UNREF(obj);
443
444#if defined(DUK_USE_ES6_PROXY)
446 obj,
447 &h_proxy_target,
448 &h_proxy_handler))) {
449 goto skip_proxy;
450 }
451
452 duk_push_hobject(ctx, h_proxy_handler);
454 /* Careful with reachability here: don't pop 'obj' before pushing
455 * proxy target.
456 */
457 DUK_DDD(DUK_DDDPRINT("no ownKeys trap, get keys of target instead"));
458 duk_pop_2(ctx);
459 duk_push_hobject(ctx, h_proxy_target);
460 duk_replace(ctx, 0);
461 DUK_ASSERT_TOP(ctx, 1);
462 goto skip_proxy;
463 }
464
465 /* [ obj handler trap ] */
466 duk_insert(ctx, -2);
467 duk_push_hobject(ctx, h_proxy_target); /* -> [ obj trap handler target ] */
468 duk_call_method(ctx, 1 /*nargs*/); /* -> [ obj trap_result ] */
469 h_trap_result = duk_require_hobject(ctx, -1);
470 DUK_UNREF(h_trap_result);
471
472 len = (duk_uarridx_t) duk_get_length(ctx, -1);
473 idx = 0;
474 duk_push_array(ctx);
475 for (i = 0; i < len; i++) {
476 /* [ obj trap_result res_arr ] */
477 if (duk_get_prop_index(ctx, -2, i) && duk_is_string(ctx, -1)) {
478 /* XXX: for Object.keys() we should check enumerability of key */
479 /* [ obj trap_result res_arr propname ] */
480 duk_put_prop_index(ctx, -2, idx);
481 idx++;
482 } else {
483 duk_pop(ctx);
484 }
485 }
486
487 /* XXX: missing trap result validation for non-configurable target keys
488 * (must be present), for non-extensible target all target keys must be
489 * present and no extra keys can be present.
490 * http://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
491 */
492
493 /* XXX: for Object.keys() the [[OwnPropertyKeys]] result (trap result)
494 * should be filtered so that only enumerable keys remain. Enumerability
495 * should be checked with [[GetOwnProperty]] on the original object
496 * (i.e., the proxy in this case). If the proxy has a getOwnPropertyDescriptor
497 * trap, it should be triggered for every property. If the proxy doesn't have
498 * the trap, enumerability should be checked against the target object instead.
499 * We don't do any of this now, so Object.keys() and Object.getOwnPropertyNames()
500 * return the same result now for proxy traps. We still do clean up the trap
501 * result, so that Object.keys() and Object.getOwnPropertyNames() will return a
502 * clean array of strings without gaps.
503 */
504 return 1;
505
506 skip_proxy:
507#endif /* DUK_USE_ES6_PROXY */
508
509 DUK_ASSERT_TOP(ctx, 1);
510
511 if (duk_get_current_magic(ctx)) {
512 /* Object.keys */
513 enum_flags = DUK_ENUM_OWN_PROPERTIES_ONLY |
515 } else {
516 /* Object.getOwnPropertyNames */
517 enum_flags = DUK_ENUM_INCLUDE_NONENUMERABLE |
520 }
521
522 return duk_hobject_get_enumerated_keys(ctx, enum_flags);
523}
DUK_EXTERNAL void duk_pop_2(duk_context *ctx)
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx)
DUK_EXTERNAL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_insert(duk_context *ctx, duk_idx_t to_index)
DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
DUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs)
DUK_INTERNAL_DECL duk_ret_t duk_hobject_get_enumerated_keys(duk_context *ctx, duk_small_uint_t enum_flags)
DUK_EXTERNAL void duk_pop(duk_context *ctx)
DUK_EXTERNAL duk_idx_t duk_push_array(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_proxy_check(duk_hthread *thr, duk_hobject *obj, duk_hobject **out_target, duk_hobject **out_handler)
#define DUK_ENUM_NO_PROXY_BEHAVIOR
#define DUK_ENUM_INCLUDE_NONENUMERABLE

References DUK_ASSERT, DUK_ASSERT_TOP, duk_call_method(), DUK_DDD, DUK_DDDPRINT, DUK_ENUM_INCLUDE_NONENUMERABLE, DUK_ENUM_NO_PROXY_BEHAVIOR, DUK_ENUM_OWN_PROPERTIES_ONLY, duk_get_current_magic(), duk_get_length(), duk_get_prop_index(), duk_get_prop_stridx(), duk_hobject_get_enumerated_keys(), duk_hobject_proxy_check(), duk_insert(), duk_is_string(), DUK_LIKELY, duk_pop(), duk_pop_2(), duk_push_array(), duk_push_hobject(), duk_put_prop_index(), duk_replace(), duk_require_hobject(), duk_require_hobject_or_lfunc_coerce(), DUK_STRIDX_OWN_KEYS, DUK_UNREF, and NULL.

◆ duk_bi_object_constructor_prevent_extensions()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_prevent_extensions ( duk_context * ctx)

Definition at line 374 of file duktape-1.5.2/src-separate/duk_bi_object.c.

374 {
375 duk_hthread *thr = (duk_hthread *) ctx;
376 duk_hobject *h;
377
379 if (!h) {
380 /* Lightfunc, always success. */
381 return 1;
382 }
383 DUK_ASSERT(h != NULL);
384
386
387 /* A non-extensible object cannot gain any more properties,
388 * so this is a good time to compact.
389 */
391
392 return 1;
393}
DUK_INTERNAL_DECL void duk_hobject_compact_props(duk_hthread *thr, duk_hobject *obj)
#define DUK_HOBJECT_CLEAR_EXTENSIBLE(h)

References DUK_ASSERT, DUK_HOBJECT_CLEAR_EXTENSIBLE, duk_hobject_compact_props(), duk_require_hobject_or_lfunc(), and NULL.

◆ duk_bi_object_constructor_seal_freeze_shared()

DUK_INTERNAL duk_ret_t duk_bi_object_constructor_seal_freeze_shared ( duk_context * ctx)

Definition at line 352 of file duktape-1.5.2/src-separate/duk_bi_object.c.

352 {
353 duk_hthread *thr = (duk_hthread *) ctx;
354 duk_hobject *h;
355 duk_bool_t is_freeze;
356
358 if (!h) {
359 /* Lightfunc, always success. */
360 return 1;
361 }
362
363 is_freeze = (duk_bool_t) duk_get_current_magic(ctx);
364 duk_hobject_object_seal_freeze_helper(thr, h, is_freeze);
365
366 /* Sealed and frozen objects cannot gain any more properties,
367 * so this is a good time to compact them.
368 */
370
371 return 1;
372}
DUK_INTERNAL_DECL void duk_hobject_object_seal_freeze_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_freeze)

References duk_get_current_magic(), duk_hobject_compact_props(), duk_hobject_object_seal_freeze_helper(), and duk_require_hobject_or_lfunc().

◆ duk_bi_object_getprototype_shared()

DUK_INTERNAL duk_ret_t duk_bi_object_getprototype_shared ( duk_context * ctx)

Definition at line 45 of file duktape-1.5.2/src-separate/duk_bi_object.c.

45 {
46 duk_hthread *thr = (duk_hthread *) ctx;
47 duk_hobject *h;
49
50 DUK_UNREF(thr);
51
52 /* magic: 0=getter call, 1=Object.getPrototypeOf */
53 if (duk_get_current_magic(ctx) == 0) {
55 duk_insert(ctx, 0);
56 }
57
59 /* h is NULL for lightfunc */
60
61 /* XXX: should the API call handle this directly, i.e. attempt
62 * to duk_push_hobject(ctx, null) would push a null instead?
63 * (On the other hand 'undefined' would be just as logical, but
64 * not wanted here.)
65 */
66
67 if (h == NULL) {
69 } else {
71 if (proto) {
73 } else {
74 duk_push_null(ctx);
75 }
76 }
77 return 1;
78}
#define DUK_HOBJECT_GET_PROTOTYPE(heap, h)
#define DUK_BIDX_FUNCTION_PROTOTYPE
DUK_EXTERNAL void duk_push_null(duk_context *ctx)
DUK_INTERNAL_DECL void duk_push_hobject_bidx(duk_context *ctx, duk_small_int_t builtin_idx)
DUK_INTERNAL_DECL duk_hobject * duk_push_this_coercible_to_object(duk_context *ctx)

References DUK_BIDX_FUNCTION_PROTOTYPE, duk_get_current_magic(), DUK_HOBJECT_GET_PROTOTYPE, duk_insert(), duk_push_hobject(), duk_push_hobject_bidx(), duk_push_null(), duk_push_this_coercible_to_object(), duk_require_hobject_or_lfunc(), DUK_UNREF, duk_hthread::heap, NULL, and proto.

◆ duk_bi_object_prototype_has_own_property()

DUK_INTERNAL duk_ret_t duk_bi_object_prototype_has_own_property ( duk_context * ctx)

Definition at line 571 of file duktape-1.5.2/src-separate/duk_bi_object.c.

571 {
572 return duk_hobject_object_ownprop_helper(ctx, 0 /*required_desc_flags*/);
573}
DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_ownprop_helper(duk_context *ctx, duk_small_uint_t required_desc_flags)

References duk_hobject_object_ownprop_helper().

◆ duk_bi_object_prototype_is_prototype_of()

DUK_INTERNAL duk_ret_t duk_bi_object_prototype_is_prototype_of ( duk_context * ctx)

Definition at line 548 of file duktape-1.5.2/src-separate/duk_bi_object.c.

548 {
549 duk_hthread *thr = (duk_hthread *) ctx;
550 duk_hobject *h_v;
551 duk_hobject *h_obj;
552
553 DUK_ASSERT_TOP(ctx, 1);
554
555 h_v = duk_get_hobject(ctx, 0);
556 if (!h_v) {
557 duk_push_false(ctx); /* XXX: tail call: return duk_push_false(ctx) */
558 return 1;
559 }
560
562 DUK_ASSERT(h_obj != NULL);
563
564 /* E5.1 Section 15.2.4.6, step 3.a, lookup proto once before compare.
565 * Prototype loops should cause an error to be thrown.
566 */
567 duk_push_boolean(ctx, duk_hobject_prototype_chain_contains(thr, DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_v), h_obj, 0 /*ignore_loop*/));
568 return 1;
569}
DUK_INTERNAL_DECL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop)

References DUK_ASSERT, DUK_ASSERT_TOP, duk_get_hobject(), DUK_HOBJECT_GET_PROTOTYPE, duk_hobject_prototype_chain_contains(), duk_push_boolean(), duk_push_false(), duk_push_this_coercible_to_object(), duk_hthread::heap, and NULL.

◆ duk_bi_object_prototype_property_is_enumerable()

DUK_INTERNAL duk_ret_t duk_bi_object_prototype_property_is_enumerable ( duk_context * ctx)

◆ duk_bi_object_prototype_to_locale_string()

DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_locale_string ( duk_context * ctx)

Definition at line 531 of file duktape-1.5.2/src-separate/duk_bi_object.c.

531 {
532 DUK_ASSERT_TOP(ctx, 0);
535 if (!duk_is_callable(ctx, 1)) {
536 return DUK_RET_TYPE_ERROR;
537 }
538 duk_dup(ctx, 0); /* -> [ O toString O ] */
539 duk_call_method(ctx, 0); /* XXX: call method tail call? */
540 return 1;
541}
#define duk_is_callable(ctx, index)

References DUK_ASSERT_TOP, duk_call_method(), duk_dup(), duk_get_prop_stridx(), duk_is_callable, duk_push_this_coercible_to_object(), DUK_RET_TYPE_ERROR, and DUK_STRIDX_TO_STRING.

◆ duk_bi_object_prototype_to_string()

DUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string ( duk_context * ctx)

Definition at line 525 of file duktape-1.5.2/src-separate/duk_bi_object.c.

525 {
526 duk_push_this(ctx);
528 return 1;
529}
DUK_EXTERNAL void duk_push_this(duk_context *ctx)
DUK_INTERNAL_DECL void duk_to_object_class_string_top(duk_context *ctx)

References duk_push_this(), and duk_to_object_class_string_top().

◆ duk_bi_object_prototype_value_of()

DUK_INTERNAL duk_ret_t duk_bi_object_prototype_value_of ( duk_context * ctx)

Definition at line 543 of file duktape-1.5.2/src-separate/duk_bi_object.c.

543 {
545 return 1;
546}

References duk_push_this_coercible_to_object().

◆ duk_bi_object_setprototype_shared()

DUK_INTERNAL duk_ret_t duk_bi_object_setprototype_shared ( duk_context * ctx)

Definition at line 86 of file duktape-1.5.2/src-separate/duk_bi_object.c.

86 {
87 duk_hthread *thr = (duk_hthread *) ctx;
88 duk_hobject *h_obj;
89 duk_hobject *h_new_proto;
90 duk_hobject *h_curr;
91 duk_ret_t ret_success = 1; /* retval for success path */
92
93 /* Preliminaries for __proto__ and setPrototypeOf (E6 19.1.2.18 steps 1-4);
94 * magic: 0=setter call, 1=Object.setPrototypeOf
95 */
96 if (duk_get_current_magic(ctx) == 0) {
98 duk_insert(ctx, 0);
100 return 0;
101 }
102
103 /* __proto__ setter returns 'undefined' on success unlike the
104 * setPrototypeOf() call which returns the target object.
105 */
106 ret_success = 0;
107 } else {
110 }
111
112 h_new_proto = duk_get_hobject(ctx, 1);
113 /* h_new_proto may be NULL */
114 if (duk_is_lightfunc(ctx, 0)) {
115 if (h_new_proto == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]) {
116 goto skip;
117 }
118 goto fail_nonextensible;
119 }
120 h_obj = duk_get_hobject(ctx, 0);
121 if (!h_obj) {
122 goto skip;
123 }
124 DUK_ASSERT(h_obj != NULL);
125
126 /* [[SetPrototypeOf]] standard behavior, E6 9.1.2 */
127 /* TODO: implement Proxy object support here */
128
129 if (h_new_proto == DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_obj)) {
130 goto skip;
131 }
132 if (!DUK_HOBJECT_HAS_EXTENSIBLE(h_obj)) {
133 goto fail_nonextensible;
134 }
135 for (h_curr = h_new_proto; h_curr != NULL; h_curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_curr)) {
136 /* Loop prevention */
137 if (h_curr == h_obj) {
138 goto fail_loop;
139 }
140 }
141 DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h_obj, h_new_proto);
142 /* fall thru */
143
144 skip:
145 duk_set_top(ctx, 1);
146 return ret_success;
147
148 fail_nonextensible:
149 fail_loop:
150 return DUK_RET_TYPE_ERROR;
151}
duk_small_int_t duk_ret_t
#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, p)
DUK_EXTERNAL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_push_this_check_object_coercible(duk_context *ctx)
#define DUK_TYPE_MASK_OBJECT
#define duk_require_object_coercible(ctx, index)
#define duk_require_type_mask(ctx, index, mask)
duk_hobject * builtins[DUK_NUM_BUILTINS]

References duk_hthread::builtins, DUK_ASSERT, DUK_BIDX_FUNCTION_PROTOTYPE, duk_check_type_mask(), duk_get_current_magic(), duk_get_hobject(), DUK_HOBJECT_GET_PROTOTYPE, DUK_HOBJECT_HAS_EXTENSIBLE, DUK_HOBJECT_SET_PROTOTYPE_UPDREF, duk_insert(), duk_is_lightfunc(), duk_push_this_check_object_coercible(), duk_require_object_coercible, duk_require_type_mask, DUK_RET_TYPE_ERROR, duk_set_top(), DUK_TYPE_MASK_NULL, DUK_TYPE_MASK_OBJECT, duk_hthread::heap, and NULL.