Browse Source

Merge branch 'defprop-wec-macro'

pull/20/head
Sami Vaarala 11 years ago
parent
commit
19ccf8aa71
  1. 11
      src/duk_api_internal.h
  2. 14
      src/duk_bi_array.c
  3. 6
      src/duk_bi_duktape.c
  4. 10
      src/duk_error_augment.c
  5. 6
      src/duk_js_call.c
  6. 6
      src/duk_js_executor.c
  7. 6
      src/duk_js_var.c
  8. 4
      src/duk_regexp_executor.c

11
src/duk_api_internal.h

@ -105,8 +105,17 @@ void duk_def_prop(duk_context *ctx, int obj_index, int desc_flags); /* [key val
void duk_def_prop_index(duk_context *ctx, int obj_index, unsigned int arr_index, int desc_flags); /* [val] -> [] */
void duk_def_prop_stridx(duk_context *ctx, int obj_index, unsigned int stridx, int desc_flags); /* [val] -> [] */
void duk_def_prop_stridx_builtin(duk_context *ctx, int obj_index, unsigned int stridx, unsigned int builtin_idx, int desc_flags); /* [] -> [] */
void duk_def_prop_stridx_thrower(duk_context *ctx, int obj_index, unsigned int stridx, int desc_flags); /* [] -> [] */
/* These are macros for now, but could be separate functions to reduce code
* footprint (check call site count before refactoring).
*/
#define duk_def_prop_wec(ctx,obj_index) \
duk_def_prop((ctx), (obj_index), DUK_PROPDESC_FLAGS_WEC)
#define duk_def_prop_index_wec(ctx,obj_index,arr_index) \
duk_def_prop_index((ctx), (obj_index), (arr_index), DUK_PROPDESC_FLAGS_WEC)
#define duk_def_prop_stridx_wec(ctx,obj_index,stridx) \
duk_def_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC)
#endif /* DUK_API_INTERNAL_H_INCLUDED */

14
src/duk_bi_array.c

@ -91,7 +91,7 @@ int duk_bi_array_constructor(duk_context *ctx) {
*/
for (i = 0; i < nargs; i++) {
duk_dup(ctx, i);
duk_def_prop_index(ctx, -2, i, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -2, i);
}
duk_push_u32(ctx, (duk_uint32_t) nargs);
@ -185,7 +185,7 @@ int duk_bi_array_prototype_concat(duk_context *ctx) {
duk_dup(ctx, i);
h = duk_get_hobject_with_class(ctx, -1, DUK_HOBJECT_CLASS_ARRAY);
if (!h) {
duk_def_prop_index(ctx, -2, idx++, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -2, idx++);
idx_last = idx;
continue;
}
@ -199,7 +199,7 @@ int duk_bi_array_prototype_concat(duk_context *ctx) {
for (j = 0; j < len; j++) {
if (duk_get_prop_index(ctx, -1, j)) {
/* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */
duk_def_prop_index(ctx, -3, idx++, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -3, idx++);
idx_last = idx;
} else {
/* XXX: according to E5.1 Section 15.4.4.4 nonexistent trailing
@ -734,7 +734,7 @@ int duk_bi_array_prototype_splice(duk_context *ctx) {
for (i = 0; i < del_count; i++) {
if (duk_get_prop_index(ctx, -3, act_start + i)) {
duk_def_prop_index(ctx, -2, i, DUK_PROPDESC_FLAGS_WEC); /* throw flag irrelevant (false in std alg) */
duk_def_prop_index_wec(ctx, -2, i); /* throw flag irrelevant (false in std alg) */
} else {
duk_pop(ctx);
}
@ -909,7 +909,7 @@ int duk_bi_array_prototype_slice(duk_context *ctx) {
for (i = start; i < end; i++) {
DUK_ASSERT_TOP(ctx, 5);
if (duk_get_prop_index(ctx, 2, i)) {
duk_def_prop_index(ctx, 4, idx, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, 4, idx);
res_length = idx + 1;
} else {
duk_pop(ctx);
@ -1204,14 +1204,14 @@ int duk_bi_array_prototype_iter_shared(duk_context *ctx) {
break;
case DUK__ITER_MAP:
duk_dup(ctx, -1);
duk_def_prop_index(ctx, 4, i, DUK_PROPDESC_FLAGS_WEC); /* retval to result[i] */
duk_def_prop_index_wec(ctx, 4, i); /* retval to result[i] */
res_length = i + 1;
break;
case DUK__ITER_FILTER:
bval = duk_to_boolean(ctx, -1);
if (bval) {
duk_dup(ctx, -2); /* orig value */
duk_def_prop_index(ctx, 4, k, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, 4, k);
k++;
res_length = k;
}

6
src/duk_bi_duktape.c

@ -151,9 +151,9 @@ duk_ret_t duk_bi_duktape_object_act(duk_context *ctx) {
/* [ level obj func pc line ] */
/* FIXME: version specific array format instead? */
duk_def_prop_stridx(ctx, -4, DUK_STRIDX_LINE_NUMBER, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx(ctx, -3, DUK_STRIDX_PC, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_LC_FUNCTION, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx_wec(ctx, -4, DUK_STRIDX_LINE_NUMBER);
duk_def_prop_stridx_wec(ctx, -3, DUK_STRIDX_PC);
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_LC_FUNCTION);
return 1;
}

10
src/duk_error_augment.c

@ -198,13 +198,13 @@ static void duk__add_traceback(duk_hthread *thr, duk_hthread *thr_callstack, con
if (filename) {
duk_push_string(ctx, filename);
duk_def_prop_index(ctx, -2, arr_idx, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -2, arr_idx);
arr_idx++;
d = (noblame_fileline ? ((double) DUK_TB_FLAG_NOBLAME_FILELINE) * DUK_DOUBLE_2TO32 : 0.0) +
(double) line;
duk_push_number(ctx, d);
duk_def_prop_index(ctx, -2, arr_idx, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -2, arr_idx);
arr_idx++;
}
@ -235,7 +235,7 @@ static void duk__add_traceback(duk_hthread *thr, duk_hthread *thr_callstack, con
/* add function */
duk_push_hobject(ctx, thr_callstack->callstack[i].func); /* -> [... arr func] */
duk_def_prop_index(ctx, -2, arr_idx, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -2, arr_idx);
arr_idx++;
/* add a number containing: pc, activation flags */
@ -252,7 +252,7 @@ static void duk__add_traceback(duk_hthread *thr, duk_hthread *thr_callstack, con
DUK_ASSERT(pc >= 0 && (double) pc < DUK_DOUBLE_2TO32); /* assume PC is at most 32 bits and non-negative */
d = ((double) thr_callstack->callstack[i].flags) * DUK_DOUBLE_2TO32 + (double) pc;
duk_push_number(ctx, d); /* -> [... arr num] */
duk_def_prop_index(ctx, -2, arr_idx, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_index_wec(ctx, -2, arr_idx);
arr_idx++;
}
@ -262,7 +262,7 @@ static void duk__add_traceback(duk_hthread *thr, duk_hthread *thr_callstack, con
/* [ ... error arr ] */
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_TRACEDATA, DUK_PROPDESC_FLAGS_WEC); /* -> [ ... error ] */
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_TRACEDATA); /* -> [ ... error ] */
}
#endif /* DUK_USE_TRACEBACKS */

6
src/duk_js_call.c

@ -127,7 +127,7 @@ static void duk__create_arguments_object(duk_hthread *thr,
DUK_DDD(DUK_DDDPRINT("define arguments[%d]=arg", idx));
duk_push_int(ctx, idx);
duk_dup(ctx, i_argbase + idx);
duk_def_prop(ctx, i_arg, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_wec(ctx, i_arg);
DUK_DDD(DUK_DDDPRINT("defined arguments[%d]=arg", idx));
/* step 11.c is relevant only if non-strict (checked in 11.c.ii) */
@ -154,13 +154,13 @@ static void duk__create_arguments_object(duk_hthread *thr,
duk_dup(ctx, -1); /* name */
duk_push_int(ctx, idx); /* index */
duk_to_string(ctx, -1);
duk_def_prop(ctx, i_mappednames, DUK_PROPDESC_FLAGS_WEC); /* out of spec, must be configurable */
duk_def_prop_wec(ctx, i_mappednames); /* out of spec, must be configurable */
DUK_DDD(DUK_DDDPRINT("set map[%d]=%s", idx, duk_get_string(ctx, -1)));
duk_push_int(ctx, idx); /* index */
duk_to_string(ctx, -1);
duk_dup(ctx, -2); /* name */
duk_def_prop(ctx, i_map, DUK_PROPDESC_FLAGS_WEC); /* out of spec, must be configurable */
duk_def_prop_wec(ctx, i_map); /* out of spec, must be configurable */
} else {
/* duk_has_prop() popped the second 'name' */
}

6
src/duk_js_executor.c

@ -1775,7 +1775,7 @@ void duk_js_execute_bytecode(duk_hthread *entry_thread) {
DUK__INTERNAL_ERROR("MPUTOBJ key not a string");
}
duk_push_tval(ctx, DUK__REGP(idx + 1)); /* -> [... obj key value] */
duk_def_prop(ctx, -3, DUK_PROPDESC_FLAGS_WEC); /* -> [... obj] */
duk_def_prop_wec(ctx, -3); /* -> [... obj] */
count--;
idx += 2;
@ -1845,8 +1845,8 @@ void duk_js_execute_bytecode(duk_hthread *entry_thread) {
* and finally set 'length' manually in the end (as already happens now).
*/
duk_push_tval(ctx, DUK__REGP(idx)); /* -> [... obj value] */
duk_def_prop_index(ctx, -2, arr_idx, DUK_PROPDESC_FLAGS_WEC); /* -> [... obj] */
duk_push_tval(ctx, DUK__REGP(idx)); /* -> [... obj value] */
duk_def_prop_index_wec(ctx, -2, arr_idx); /* -> [... obj] */
count--;
idx++;

6
src/duk_js_var.c

@ -494,11 +494,11 @@ duk_hobject *duk_create_activation_environment_record(duk_hthread *thr,
if (DUK_HOBJECT_IS_COMPILEDFUNCTION(func)) {
duk_push_hthread(ctx, thr);
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_INT_THREAD, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_INT_THREAD);
duk_push_hobject(ctx, func);
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_INT_CALLEE, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_INT_CALLEE);
duk_push_int(ctx, idx_bottom); /* FIXME: type */
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_INT_REGBASE, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_INT_REGBASE);
}
return env;

4
src/duk_regexp_executor.c

@ -900,10 +900,10 @@ static void duk__regexp_match_helper(duk_hthread *thr, duk_small_int_t force_glo
/* [ ... re_obj input bc saved_buf res_obj ] */
duk_push_number(ctx, (double) char_offset);
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_INDEX, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_INDEX);
duk_dup(ctx, -4);
duk_def_prop_stridx(ctx, -2, DUK_STRIDX_INPUT, DUK_PROPDESC_FLAGS_WEC);
duk_def_prop_stridx_wec(ctx, -2, DUK_STRIDX_INPUT);
for (i = 0; i < re_ctx.nsaved; i += 2) {
/* Captures which are undefined have NULL pointers and are returned

Loading…
Cancel
Save