Commit c0f3c789 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added 'new' expression implementation.

parent 47fcf8d0
......@@ -41,7 +41,8 @@ static void exprval_release(exprval_t *val)
{
switch(val->type) {
case EXPRVAL_VARIANT:
VariantClear(&val->u.var);
if(V_VT(&val->u.var) != VT_EMPTY)
VariantClear(&val->u.var);
return;
case EXPRVAL_IDREF:
if(val->u.idref.disp)
......@@ -1054,7 +1055,7 @@ HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags
return S_OK;
}
hres = disp_get_id(obj, str, flags & EXPR_NEW ? fdexNameEnsure : 0, &id);
hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
SysFreeString(str);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, obj, id);
......@@ -1085,11 +1086,11 @@ static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei,
HRESULT hres = S_OK;
memset(dp, 0, sizeof(*dp));
if(!args)
return S_OK;
for(iter = args; iter; iter = iter->next)
cnt++;
if(!cnt)
return S_OK;
vargs = heap_alloc_zero(cnt * sizeof(*vargs));
if(!vargs)
......@@ -1117,7 +1118,7 @@ static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei,
}
/* ECMA-262 3rd Edition 11.2.2 */
HRESULT member_new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
call_expression_t *expr = (call_expression_t*)_expr;
exprval_t exprval;
......@@ -1847,12 +1848,6 @@ HRESULT pre_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWOR
return S_OK;
}
HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
}
/* ECMA-262 3rd Edition 11.9.3 */
static HRESULT equal_values(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, BOOL *ret)
{
......
......@@ -395,7 +395,6 @@ typedef enum {
EXPR_POSTDEC,
EXPR_PREINC,
EXPR_PREDEC,
EXPR_NEW,
EXPR_EQ,
EXPR_EQEQ,
EXPR_NOTEQ,
......@@ -427,7 +426,7 @@ HRESULT function_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exp
HRESULT conditional_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT array_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT member_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT member_new_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT new_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT call_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT this_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT identifier_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
......@@ -457,7 +456,6 @@ HRESULT post_increment_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_
HRESULT post_decrement_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT pre_increment_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT pre_decrement_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT new_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT equal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT equal2_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
HRESULT not_equal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
......
......@@ -126,7 +126,7 @@ static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expres
static expression_t *new_conditional_expression(parser_ctx_t*,expression_t*,expression_t*,expression_t*);
static expression_t *new_array_expression(parser_ctx_t*,expression_t*,expression_t*);
static expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
static expression_t *new_member_new_expression(parser_ctx_t*,expression_t*,argument_list_t*);
static expression_t *new_new_expression(parser_ctx_t*,expression_t*,argument_list_t*);
static expression_t *new_call_expression(parser_ctx_t*,expression_t*,argument_list_t*);
static expression_t *new_this_expression(parser_ctx_t*);
static expression_t *new_identifier_expression(parser_ctx_t*,const WCHAR*);
......@@ -676,7 +676,7 @@ LeftHandSideExpression
/* ECMA-262 3rd Edition 11.2 */
NewExpression
: MemberExpression { $$ = $1; }
| kNEW NewExpression { $$ = new_unary_expression(ctx, EXPR_NEW, $2); }
| kNEW NewExpression { $$ = new_new_expression(ctx, $2, NULL); }
/* ECMA-262 3rd Edition 11.2 */
MemberExpression
......@@ -687,7 +687,7 @@ MemberExpression
| MemberExpression '.' tIdentifier
{ $$ = new_member_expression(ctx, $1, $3); }
| kNEW MemberExpression Arguments
{ $$ = new_member_new_expression(ctx, $2, $3); }
{ $$ = new_new_expression(ctx, $2, $3); }
/* ECMA-262 3rd Edition 11.2 */
CallExpression
......@@ -1281,7 +1281,6 @@ static const expression_eval_t expression_eval_table[] = {
post_decrement_expression_eval,
pre_increment_expression_eval,
pre_decrement_expression_eval,
new_expression_eval,
equal_expression_eval,
equal2_expression_eval,
not_equal_expression_eval,
......@@ -1366,11 +1365,11 @@ static expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *expr
return &ret->expr;
}
static expression_t *new_member_new_expression(parser_ctx_t *ctx, expression_t *expression, argument_list_t *argument_list)
static expression_t *new_new_expression(parser_ctx_t *ctx, expression_t *expression, argument_list_t *argument_list)
{
call_expression_t *ret = parser_alloc(ctx, sizeof(call_expression_t));
ret->expr.eval = member_new_expression_eval;
ret->expr.eval = new_expression_eval;
ret->expression = expression;
ret->argument_list = argument_list ? argument_list->head : NULL;
......
......@@ -133,6 +133,9 @@ obj2.pvar = 3;
testConstr1.prototype.pvar = 1;
ok(obj2.pvar === 3, "obj2.pvar is not 3");
var obj3 = new Object;
ok(typeof(obj3) === "object", "typeof(obj3) is not object");
tmp = 0;
if(true)
tmp = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment