Commit 2f3c235a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added multiplicative expression parser/compiler implementation.

parent 80eff040
...@@ -353,6 +353,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) ...@@ -353,6 +353,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value); return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value);
case EXPR_CONCAT: case EXPR_CONCAT:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_concat); return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_concat);
case EXPR_DIV:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_div);
case EXPR_DOUBLE: case EXPR_DOUBLE:
return push_instr_double(ctx, OP_double, ((double_expression_t*)expr)->value); return push_instr_double(ctx, OP_double, ((double_expression_t*)expr)->value);
case EXPR_EMPTY: case EXPR_EMPTY:
...@@ -365,6 +367,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) ...@@ -365,6 +367,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return compile_member_expression(ctx, (member_expression_t*)expr, TRUE); return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
case EXPR_MOD: case EXPR_MOD:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mod); return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mod);
case EXPR_MUL:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mul);
case EXPR_NEG: case EXPR_NEG:
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg); return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
case EXPR_NEQUAL: case EXPR_NEQUAL:
......
...@@ -690,6 +690,18 @@ static HRESULT interp_idiv(exec_ctx_t *ctx) ...@@ -690,6 +690,18 @@ static HRESULT interp_idiv(exec_ctx_t *ctx)
return stack_push(ctx, &v); return stack_push(ctx, &v);
} }
static HRESULT interp_div(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_mul(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_neg(exec_ctx_t *ctx) static HRESULT interp_neg(exec_ctx_t *ctx)
{ {
variant_val_t val; variant_val_t val;
......
...@@ -20,12 +20,14 @@ typedef enum { ...@@ -20,12 +20,14 @@ typedef enum {
EXPR_ADD, EXPR_ADD,
EXPR_BOOL, EXPR_BOOL,
EXPR_CONCAT, EXPR_CONCAT,
EXPR_DIV,
EXPR_DOUBLE, EXPR_DOUBLE,
EXPR_EMPTY, EXPR_EMPTY,
EXPR_EQUAL, EXPR_EQUAL,
EXPR_IDIV, EXPR_IDIV,
EXPR_MEMBER, EXPR_MEMBER,
EXPR_MOD, EXPR_MOD,
EXPR_MUL,
EXPR_NEG, EXPR_NEG,
EXPR_NEQUAL, EXPR_NEQUAL,
EXPR_NOT, EXPR_NOT,
......
...@@ -91,7 +91,7 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*); ...@@ -91,7 +91,7 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*);
%type <statement> Statement StatementNl StatementsNl IfStatement Else_opt %type <statement> Statement StatementNl StatementsNl IfStatement Else_opt
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
%type <expression> NotExpression UnaryExpression %type <expression> NotExpression UnaryExpression
%type <member> MemberExpression %type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <expression> Arguments_opt ArgumentList_opt ArgumentList
...@@ -203,6 +203,13 @@ IntdivExpression ...@@ -203,6 +203,13 @@ IntdivExpression
{ $$ = new_binary_expression(ctx, EXPR_IDIV, $1, $3); CHECK_ERROR; } { $$ = new_binary_expression(ctx, EXPR_IDIV, $1, $3); CHECK_ERROR; }
MultiplicativeExpression MultiplicativeExpression
: ExpExpression { $$ = $1; }
| MultiplicativeExpression '*' ExpExpression
{ $$ = new_binary_expression(ctx, EXPR_MUL, $1, $3); CHECK_ERROR; }
| MultiplicativeExpression '/' ExpExpression
{ $$ = new_binary_expression(ctx, EXPR_DIV, $1, $3); CHECK_ERROR; }
ExpExpression
: UnaryExpression /* FIXME */ { $$ = $1; } : UnaryExpression /* FIXME */ { $$ = $1; }
UnaryExpression UnaryExpression
......
...@@ -103,6 +103,7 @@ typedef enum { ...@@ -103,6 +103,7 @@ typedef enum {
X(assign_member, 1, ARG_BSTR, 0) \ X(assign_member, 1, ARG_BSTR, 0) \
X(bool, 1, ARG_INT, 0) \ X(bool, 1, ARG_INT, 0) \
X(concat, 1, 0, 0) \ X(concat, 1, 0, 0) \
X(div, 1, 0, 0) \
X(double, 1, ARG_DOUBLE, 0) \ X(double, 1, ARG_DOUBLE, 0) \
X(empty, 1, 0, 0) \ X(empty, 1, 0, 0) \
X(equal, 1, 0, 0) \ X(equal, 1, 0, 0) \
...@@ -113,6 +114,7 @@ typedef enum { ...@@ -113,6 +114,7 @@ typedef enum {
X(jmp_false, 0, ARG_ADDR, 0) \ X(jmp_false, 0, ARG_ADDR, 0) \
X(long, 1, ARG_INT, 0) \ X(long, 1, ARG_INT, 0) \
X(mod, 1, 0, 0) \ X(mod, 1, 0, 0) \
X(mul, 1, 0, 0) \
X(neg, 1, 0, 0) \ X(neg, 1, 0, 0) \
X(nequal, 1, 0, 0) \ X(nequal, 1, 0, 0) \
X(not, 1, 0, 0) \ X(not, 1, 0, 0) \
......
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