vbscript: Added xor, imp and eqv expressions parser/compiler implementation.
This commit is contained in:
parent
4916c1b26c
commit
43d10693ca
|
@ -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;
|
return push_instr(ctx, OP_empty) != -1 ? S_OK : E_OUTOFMEMORY;
|
||||||
case EXPR_EQUAL:
|
case EXPR_EQUAL:
|
||||||
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_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:
|
case EXPR_EXP:
|
||||||
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_exp);
|
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_exp);
|
||||||
case EXPR_IDIV:
|
case EXPR_IDIV:
|
||||||
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_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:
|
case EXPR_MEMBER:
|
||||||
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:
|
||||||
|
@ -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);
|
return push_instr_int(ctx, OP_short, ((int_expression_t*)expr)->value);
|
||||||
case EXPR_ULONG:
|
case EXPR_ULONG:
|
||||||
return push_instr_int(ctx, OP_long, ((int_expression_t*)expr)->value);
|
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:
|
default:
|
||||||
FIXME("Unimplemented expression type %d\n", expr->type);
|
FIXME("Unimplemented expression type %d\n", expr->type);
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
|
|
@ -612,6 +612,24 @@ static HRESULT interp_or(exec_ctx_t *ctx)
|
||||||
return stack_push(ctx, &v);
|
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)
|
static HRESULT cmp_oper(exec_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
variant_val_t l, r;
|
variant_val_t l, r;
|
||||||
|
|
|
@ -25,8 +25,10 @@ typedef enum {
|
||||||
EXPR_DOUBLE,
|
EXPR_DOUBLE,
|
||||||
EXPR_EMPTY,
|
EXPR_EMPTY,
|
||||||
EXPR_EQUAL,
|
EXPR_EQUAL,
|
||||||
|
EXPR_EQV,
|
||||||
EXPR_EXP,
|
EXPR_EXP,
|
||||||
EXPR_IDIV,
|
EXPR_IDIV,
|
||||||
|
EXPR_IMP,
|
||||||
EXPR_MEMBER,
|
EXPR_MEMBER,
|
||||||
EXPR_MOD,
|
EXPR_MOD,
|
||||||
EXPR_MUL,
|
EXPR_MUL,
|
||||||
|
@ -38,7 +40,8 @@ typedef enum {
|
||||||
EXPR_STRING,
|
EXPR_STRING,
|
||||||
EXPR_SUB,
|
EXPR_SUB,
|
||||||
EXPR_ULONG,
|
EXPR_ULONG,
|
||||||
EXPR_USHORT
|
EXPR_USHORT,
|
||||||
|
EXPR_XOR
|
||||||
} expression_type_t;
|
} expression_type_t;
|
||||||
|
|
||||||
typedef struct _expression_t {
|
typedef struct _expression_t {
|
||||||
|
|
|
@ -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 OrExpression
|
%type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression
|
||||||
%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,16 @@ EmptyBrackets_opt
|
||||||
| tEMPTYBRACKETS
|
| tEMPTYBRACKETS
|
||||||
|
|
||||||
Expression
|
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; }
|
: OrExpression { $$ = $1; }
|
||||||
|
| XorExpression tXOR OrExpression { $$ = new_binary_expression(ctx, EXPR_XOR, $1, $3); CHECK_ERROR; }
|
||||||
|
|
||||||
OrExpression
|
OrExpression
|
||||||
: AndExpression { $$ = $1; }
|
: AndExpression { $$ = $1; }
|
||||||
|
|
|
@ -126,10 +126,12 @@ typedef enum {
|
||||||
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) \
|
||||||
|
X(eqv, 1, 0, 0) \
|
||||||
X(exp, 1, 0, 0) \
|
X(exp, 1, 0, 0) \
|
||||||
X(icall, 1, ARG_BSTR, ARG_UINT) \
|
X(icall, 1, ARG_BSTR, ARG_UINT) \
|
||||||
X(icallv, 1, ARG_BSTR, ARG_UINT) \
|
X(icallv, 1, ARG_BSTR, ARG_UINT) \
|
||||||
X(idiv, 1, 0, 0) \
|
X(idiv, 1, 0, 0) \
|
||||||
|
X(imp, 1, 0, 0) \
|
||||||
X(jmp, 0, ARG_ADDR, 0) \
|
X(jmp, 0, ARG_ADDR, 0) \
|
||||||
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) \
|
||||||
|
@ -143,7 +145,8 @@ typedef enum {
|
||||||
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) \
|
||||||
X(sub, 1, 0, 0)
|
X(sub, 1, 0, 0) \
|
||||||
|
X(xor, 1, 0, 0)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
#define X(x,n,a,b) OP_##x,
|
#define X(x,n,a,b) OP_##x,
|
||||||
|
|
Loading…
Reference in New Issue