vbscript: Added 'or' expression parser/compiler implementation.

This commit is contained in:
Jacek Caban 2011-09-14 12:59:26 +02:00 committed by Alexandre Julliard
parent 091f243051
commit fae7352f93
5 changed files with 15 additions and 1 deletions

View File

@ -388,6 +388,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not); return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not);
case EXPR_NULL: case EXPR_NULL:
return push_instr(ctx, OP_null) != -1 ? S_OK : E_OUTOFMEMORY; return push_instr(ctx, OP_null) != -1 ? S_OK : E_OUTOFMEMORY;
case EXPR_OR:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_or);
case EXPR_STRING: case EXPR_STRING:
return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value); return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value);
case EXPR_SUB: case EXPR_SUB:

View File

@ -588,6 +588,12 @@ static HRESULT interp_and(exec_ctx_t *ctx)
return stack_push(ctx, &v); return stack_push(ctx, &v);
} }
static HRESULT interp_or(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT cmp_oper(exec_ctx_t *ctx) static HRESULT cmp_oper(exec_ctx_t *ctx)
{ {
variant_val_t l, r; variant_val_t l, r;

View File

@ -34,6 +34,7 @@ typedef enum {
EXPR_NEQUAL, EXPR_NEQUAL,
EXPR_NOT, EXPR_NOT,
EXPR_NULL, EXPR_NULL,
EXPR_OR,
EXPR_STRING, EXPR_STRING,
EXPR_SUB, EXPR_SUB,
EXPR_ULONG, EXPR_ULONG,

View File

@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL);
%type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt
%type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
%type <expression> NotExpression UnaryExpression AndExpression %type <expression> NotExpression UnaryExpression AndExpression OrExpression
%type <member> MemberExpression %type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <expression> Arguments_opt ArgumentList_opt ArgumentList
%type <bool> OptionExplicit_opt %type <bool> OptionExplicit_opt
@ -188,7 +188,11 @@ EmptyBrackets_opt
| tEMPTYBRACKETS | tEMPTYBRACKETS
Expression Expression
: OrExpression { $$ = $1; }
OrExpression
: AndExpression { $$ = $1; } : AndExpression { $$ = $1; }
| OrExpression tOR AndExpression { $$ = new_binary_expression(ctx, EXPR_OR, $1, $3); CHECK_ERROR; }
AndExpression AndExpression
: NotExpression { $$ = $1; } : NotExpression { $$ = $1; }

View File

@ -139,6 +139,7 @@ typedef enum {
X(nequal, 1, 0, 0) \ X(nequal, 1, 0, 0) \
X(not, 1, 0, 0) \ X(not, 1, 0, 0) \
X(null, 1, 0, 0) \ X(null, 1, 0, 0) \
X(or, 1, 0, 0) \
X(ret, 0, 0, 0) \ X(ret, 0, 0, 0) \
X(short, 1, ARG_INT, 0) \ X(short, 1, ARG_INT, 0) \
X(string, 1, ARG_STR, 0) \ X(string, 1, ARG_STR, 0) \