vbscript: Added xor, imp and eqv expressions parser/compiler implementation.

This commit is contained in:
Jacek Caban 2011-09-14 12:59:49 +02:00 committed by Alexandre Julliard
parent 4916c1b26c
commit 43d10693ca
5 changed files with 42 additions and 3 deletions

View File

@ -370,10 +370,14 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return push_instr(ctx, OP_empty) != -1 ? S_OK : E_OUTOFMEMORY;
case EXPR_EQUAL:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_equal);
case EXPR_EQV:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eqv);
case EXPR_EXP:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_exp);
case EXPR_IDIV:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_idiv);
case EXPR_IMP:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_imp);
case EXPR_MEMBER:
return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
case EXPR_MOD:
@ -398,6 +402,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return push_instr_int(ctx, OP_short, ((int_expression_t*)expr)->value);
case EXPR_ULONG:
return push_instr_int(ctx, OP_long, ((int_expression_t*)expr)->value);
case EXPR_XOR:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_xor);
default:
FIXME("Unimplemented expression type %d\n", expr->type);
return E_NOTIMPL;

View File

@ -612,6 +612,24 @@ static HRESULT interp_or(exec_ctx_t *ctx)
return stack_push(ctx, &v);
}
static HRESULT interp_xor(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_eqv(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_imp(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT cmp_oper(exec_ctx_t *ctx)
{
variant_val_t l, r;

View File

@ -25,8 +25,10 @@ typedef enum {
EXPR_DOUBLE,
EXPR_EMPTY,
EXPR_EQUAL,
EXPR_EQV,
EXPR_EXP,
EXPR_IDIV,
EXPR_IMP,
EXPR_MEMBER,
EXPR_MOD,
EXPR_MUL,
@ -38,7 +40,8 @@ typedef enum {
EXPR_STRING,
EXPR_SUB,
EXPR_ULONG,
EXPR_USHORT
EXPR_USHORT,
EXPR_XOR
} expression_type_t;
typedef struct _expression_t {

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 <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression
%type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression
%type <expression> NotExpression UnaryExpression AndExpression OrExpression
%type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression
%type <member> MemberExpression
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
%type <bool> OptionExplicit_opt
@ -188,7 +188,16 @@ EmptyBrackets_opt
| tEMPTYBRACKETS
Expression
: EqvExpression { $$ = $1; }
| Expression tIMP EqvExpression { $$ = new_binary_expression(ctx, EXPR_IMP, $1, $3); CHECK_ERROR; }
EqvExpression
: XorExpression { $$ = $1; }
| EqvExpression tEQV XorExpression { $$ = new_binary_expression(ctx, EXPR_EQV, $1, $3); CHECK_ERROR; }
XorExpression
: OrExpression { $$ = $1; }
| XorExpression tXOR OrExpression { $$ = new_binary_expression(ctx, EXPR_XOR, $1, $3); CHECK_ERROR; }
OrExpression
: AndExpression { $$ = $1; }

View File

@ -126,10 +126,12 @@ typedef enum {
X(double, 1, ARG_DOUBLE, 0) \
X(empty, 1, 0, 0) \
X(equal, 1, 0, 0) \
X(eqv, 1, 0, 0) \
X(exp, 1, 0, 0) \
X(icall, 1, ARG_BSTR, ARG_UINT) \
X(icallv, 1, ARG_BSTR, ARG_UINT) \
X(idiv, 1, 0, 0) \
X(imp, 1, 0, 0) \
X(jmp, 0, ARG_ADDR, 0) \
X(jmp_false, 0, ARG_ADDR, 0) \
X(long, 1, ARG_INT, 0) \
@ -143,7 +145,8 @@ typedef enum {
X(ret, 0, 0, 0) \
X(short, 1, ARG_INT, 0) \
X(string, 1, ARG_STR, 0) \
X(sub, 1, 0, 0)
X(sub, 1, 0, 0) \
X(xor, 1, 0, 0)
typedef enum {
#define X(x,n,a,b) OP_##x,