From 0abc326d7b4dcd7b22a0eeeaf8f64934046ee88e Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Mon, 5 Dec 2016 19:12:52 +0200 Subject: [PATCH] FIXME: placeholder for function source --- src-input/duk_bi_function.c | 7 +++++++ src-input/duk_js_compiler.c | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src-input/duk_bi_function.c b/src-input/duk_bi_function.c index abb32d49..28bbc45c 100644 --- a/src-input/duk_bi_function.c +++ b/src-input/duk_bi_function.c @@ -135,6 +135,13 @@ DUK_INTERNAL duk_ret_t duk_bi_function_prototype_to_string(duk_context *ctx) { func_name = duk_to_string(ctx, -1); DUK_ASSERT(func_name != NULL); } + /* Leave func_name on value stack for reachability. */ + + if (duk_get_prop_stridx(ctx, -2, DUK_STRIDX_INT_SOURCE)) { + /* If function has _Source, use it as is. */ + return 1; + } + /* No need to duk_pop() here; save footprint. */ if (DUK_HOBJECT_IS_COMPFUNC(obj)) { duk_push_sprintf(ctx, "function %s() { [ecmascript code] }", (const char *) func_name); diff --git a/src-input/duk_js_compiler.c b/src-input/duk_js_compiler.c index bc233167..53a58ebb 100644 --- a/src-input/duk_js_compiler.c +++ b/src-input/duk_js_compiler.c @@ -888,8 +888,9 @@ DUK_LOCAL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx, duk_boo } /* _Source */ -#if defined(DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY) - if (0) { + /* FIXME: implement */ +#if 1 /* FIXME: defined(DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY) */ + if (1) { /* XXX: Currently function source code is not stored, as it is not * required by the standard. Source code should not be stored by * default (user should enable it explicitly), and the source should @@ -928,10 +929,8 @@ DUK_LOCAL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx, duk_boo * 'function a(foo,bar) { print(foo); }' */ -#if 0 duk_push_string(ctx, "XXX"); duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE); -#endif } #endif /* DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY */