jscript: Don't return function value it's unless explicitly returned.
This commit is contained in:
parent
0839ae88ca
commit
56b04194fc
|
@ -414,7 +414,8 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
|
||||
HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, exec_type_t exec_type,
|
||||
jsexcept_t *ei, VARIANT *retv)
|
||||
{
|
||||
script_ctx_t *script = parser->script;
|
||||
function_declaration_t *func;
|
||||
|
@ -493,7 +494,7 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so
|
|||
return hres;
|
||||
}
|
||||
|
||||
if(retv)
|
||||
if(retv && (exec_type == EXECT_EVAL || rt.type == RT_RETURN))
|
||||
*retv = val;
|
||||
else
|
||||
VariantClear(&val);
|
||||
|
|
|
@ -109,9 +109,15 @@ static inline void exec_addref(exec_ctx_t *ctx)
|
|||
ctx->ref++;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
EXECT_PROGRAM,
|
||||
EXECT_FUNCTION,
|
||||
EXECT_EVAL
|
||||
} exec_type_t;
|
||||
|
||||
void exec_release(exec_ctx_t*);
|
||||
HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**);
|
||||
HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*);
|
||||
HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,exec_type_t,jsexcept_t*,VARIANT*);
|
||||
|
||||
typedef struct _statement_t statement_t;
|
||||
typedef struct _expression_t expression_t;
|
||||
|
|
|
@ -216,7 +216,7 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
|
|||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = exec_source(exec_ctx, function->parser, function->source, ei, retv);
|
||||
hres = exec_source(exec_ctx, function->parser, function->source, EXECT_FUNCTION, ei, retv);
|
||||
exec_release(exec_ctx);
|
||||
|
||||
return hres;
|
||||
|
|
|
@ -408,7 +408,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
|
|||
return throw_syntax_error(ctx, ei, hres, NULL);
|
||||
}
|
||||
|
||||
hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv);
|
||||
hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, EXECT_EVAL, ei, retv);
|
||||
parser_release(parser_ctx);
|
||||
|
||||
return hres;
|
||||
|
|
|
@ -104,7 +104,7 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx)
|
|||
IActiveScriptSite_OnEnterScript(This->site);
|
||||
|
||||
memset(&jsexcept, 0, sizeof(jsexcept));
|
||||
hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, &jsexcept, &var);
|
||||
hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, EXECT_PROGRAM, &jsexcept, &var);
|
||||
VariantClear(&jsexcept.var);
|
||||
exec_release(exec_ctx);
|
||||
if(SUCCEEDED(hres))
|
||||
|
|
|
@ -109,6 +109,11 @@ ok(typeof(this) === "object", "typeof(this) is not object");
|
|||
|
||||
ok(testFunc1(true, "test") === true, "testFunc1 not returned true");
|
||||
|
||||
tmp = (function() {1;})();
|
||||
ok(tmp === undefined, "tmp = " + tmp);
|
||||
tmp = eval("1;");
|
||||
ok(tmp === 1, "tmp = " + tmp);
|
||||
|
||||
var obj1 = new Object();
|
||||
ok(typeof(obj1) === "object", "typeof(obj1) is not object");
|
||||
obj1.test = true;
|
||||
|
|
Loading…
Reference in New Issue