vbscript: Added new expression parser/compiler implemetation.

This commit is contained in:
Jacek Caban 2011-09-15 14:18:12 +02:00 committed by Alexandre Julliard
parent f683832ac1
commit 408a1bf682
5 changed files with 25 additions and 0 deletions

View File

@ -390,6 +390,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
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:
return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_nequal); return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_nequal);
case EXPR_NEW:
return push_instr_str(ctx, OP_new, ((string_expression_t*)expr)->value);
case EXPR_NOT: case EXPR_NOT:
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:

View File

@ -444,6 +444,13 @@ static HRESULT interp_set_member(exec_ctx_t *ctx)
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT interp_new(exec_ctx_t *ctx)
{
const WCHAR *arg = ctx->instr->arg1.bstr;
FIXME("%s\n", debugstr_w(arg));
return E_NOTIMPL;
}
static HRESULT interp_jmp(exec_ctx_t *ctx) static HRESULT interp_jmp(exec_ctx_t *ctx)
{ {
const unsigned arg = ctx->instr->arg1.uint; const unsigned arg = ctx->instr->arg1.uint;

View File

@ -34,6 +34,7 @@ typedef enum {
EXPR_MUL, EXPR_MUL,
EXPR_NEG, EXPR_NEG,
EXPR_NEQUAL, EXPR_NEQUAL,
EXPR_NEW,
EXPR_NOT, EXPR_NOT,
EXPR_NULL, EXPR_NULL,
EXPR_OR, EXPR_OR,

View File

@ -43,6 +43,7 @@ static expression_t *new_long_expression(parser_ctx_t*,expression_type_t,LONG);
static expression_t *new_double_expression(parser_ctx_t*,double); static expression_t *new_double_expression(parser_ctx_t*,double);
static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*); static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*);
static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*); static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*);
static expression_t *new_new_expression(parser_ctx_t*,const WCHAR*);
static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*); static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*);
@ -256,6 +257,7 @@ ExpExpression
UnaryExpression UnaryExpression
: LiteralExpression { $$ = $1; } : LiteralExpression { $$ = $1; }
| CallExpression { $$ = $1; } | CallExpression { $$ = $1; }
| tNEW tIdentifier { $$ = new_new_expression(ctx, $2); CHECK_ERROR; }
| '-' UnaryExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; } | '-' UnaryExpression { $$ = new_unary_expression(ctx, EXPR_NEG, $2); CHECK_ERROR; }
CallExpression CallExpression
@ -430,6 +432,18 @@ static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_
return expr; return expr;
} }
static expression_t *new_new_expression(parser_ctx_t *ctx, const WCHAR *identifier)
{
string_expression_t *expr;
expr = new_expression(ctx, EXPR_NEW, sizeof(*expr));
if(!expr)
return NULL;
expr->value = identifier;
return &expr->expr;
}
static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size) static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size)
{ {
statement_t *stat; statement_t *stat;

View File

@ -146,6 +146,7 @@ typedef enum {
X(mul, 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(new, 1, ARG_STR, 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(or, 1, 0, 0) \