jscript: Store function name in function_code_t.
This commit is contained in:
parent
d76b675ea8
commit
8c533d10d6
|
@ -1771,7 +1771,8 @@ static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, BOOL from_eval, function_code_t *func)
|
static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, function_expression_t *func_expr,
|
||||||
|
BOOL from_eval, function_code_t *func)
|
||||||
{
|
{
|
||||||
function_declaration_t *iter;
|
function_declaration_t *iter;
|
||||||
unsigned off, i;
|
unsigned off, i;
|
||||||
|
@ -1796,17 +1797,24 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
|
||||||
dump_code(ctx, off);
|
dump_code(ctx, off);
|
||||||
|
|
||||||
func->instr_off = off;
|
func->instr_off = off;
|
||||||
|
|
||||||
|
if(func_expr && func_expr->identifier) {
|
||||||
|
func->name = compiler_alloc_bstr(ctx, func_expr->identifier);
|
||||||
|
if(!func->name)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
func->source_elements = source;
|
func->source_elements = source;
|
||||||
|
func->expr = func_expr;
|
||||||
|
|
||||||
func->funcs = heap_alloc_zero(func->func_cnt * sizeof(*func->funcs));
|
func->funcs = heap_alloc_zero(func->func_cnt * sizeof(*func->funcs));
|
||||||
if(!func->funcs)
|
if(!func->funcs)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
for(iter = source->functions, i=0; iter; iter = iter->next, i++) {
|
for(iter = source->functions, i=0; iter; iter = iter->next, i++) {
|
||||||
hres = compile_function(ctx, iter->expr->source_elements, FALSE, func->funcs+i);
|
hres = compile_function(ctx, iter->expr->source_elements, iter->expr, FALSE, func->funcs+i);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
func->funcs[i].expr = iter->expr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(i == func->func_cnt);
|
assert(i == func->func_cnt);
|
||||||
|
@ -1839,7 +1847,7 @@ HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimi
|
||||||
|
|
||||||
compiler.code->parser = compiler.parser;
|
compiler.code->parser = compiler.parser;
|
||||||
|
|
||||||
hres = compile_function(&compiler, compiler.parser->source, from_eval, &compiler.code->global_code);
|
hres = compile_function(&compiler, compiler.parser->source, NULL, from_eval, &compiler.code->global_code);
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
release_bytecode(compiler.code);
|
release_bytecode(compiler.code);
|
||||||
return hres;
|
return hres;
|
||||||
|
|
|
@ -2624,7 +2624,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
|
||||||
jsdisp_t *func_obj;
|
jsdisp_t *func_obj;
|
||||||
VARIANT var;
|
VARIANT var;
|
||||||
|
|
||||||
if(!func->funcs[i].expr->identifier)
|
if(!func->funcs[i].name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
expr = func->funcs[i].expr;
|
expr = func->funcs[i].expr;
|
||||||
|
@ -2634,7 +2634,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
var_set_jsdisp(&var, func_obj);
|
var_set_jsdisp(&var, func_obj);
|
||||||
hres = jsdisp_propput_name(ctx->var_disp, expr->identifier, &var, ei);
|
hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, &var, ei);
|
||||||
jsdisp_release(func_obj);
|
jsdisp_release(func_obj);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
|
@ -167,6 +167,7 @@ typedef struct {
|
||||||
} instr_t;
|
} instr_t;
|
||||||
|
|
||||||
typedef struct _function_code_t {
|
typedef struct _function_code_t {
|
||||||
|
BSTR name;
|
||||||
unsigned instr_off;
|
unsigned instr_off;
|
||||||
|
|
||||||
function_expression_t *expr; /* FIXME */
|
function_expression_t *expr; /* FIXME */
|
||||||
|
|
Loading…
Reference in New Issue