vbscript: Added set statement parser/compiler implementation.
This commit is contained in:
parent
e8797c29b5
commit
b3a6217ed3
|
@ -475,7 +475,7 @@ static HRESULT compile_if_statement(compile_ctx_t *ctx, if_statement_t *stat)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat)
|
||||
static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat, BOOL is_set)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
|
@ -493,9 +493,9 @@ static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *
|
|||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = push_instr_bstr(ctx, OP_assign_member, stat->member_expr->identifier);
|
||||
hres = push_instr_bstr(ctx, is_set ? OP_set_member : OP_assign_member, stat->member_expr->identifier);
|
||||
}else {
|
||||
hres = push_instr_bstr(ctx, OP_assign_ident, stat->member_expr->identifier);
|
||||
hres = push_instr_bstr(ctx, is_set ? OP_set_ident : OP_assign_ident, stat->member_expr->identifier);
|
||||
}
|
||||
|
||||
return hres;
|
||||
|
@ -585,7 +585,7 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat)
|
|||
while(stat) {
|
||||
switch(stat->type) {
|
||||
case STAT_ASSIGN:
|
||||
hres = compile_assign_statement(ctx, (assign_statement_t*)stat);
|
||||
hres = compile_assign_statement(ctx, (assign_statement_t*)stat, FALSE);
|
||||
break;
|
||||
case STAT_CALL:
|
||||
hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr, FALSE);
|
||||
|
@ -605,6 +605,9 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat)
|
|||
case STAT_IF:
|
||||
hres = compile_if_statement(ctx, (if_statement_t*)stat);
|
||||
break;
|
||||
case STAT_SET:
|
||||
hres = compile_assign_statement(ctx, (assign_statement_t*)stat, TRUE);
|
||||
break;
|
||||
default:
|
||||
FIXME("Unimplemented statement type %d\n", stat->type);
|
||||
hres = E_NOTIMPL;
|
||||
|
|
|
@ -385,6 +385,13 @@ static HRESULT interp_assign_ident(exec_ctx_t *ctx)
|
|||
return assign_ident(ctx, arg, v.v, v.owned);
|
||||
}
|
||||
|
||||
static HRESULT interp_set_ident(exec_ctx_t *ctx)
|
||||
{
|
||||
const BSTR arg = ctx->instr->arg1.bstr;
|
||||
FIXME("%s\n", debugstr_w(arg));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT interp_assign_member(exec_ctx_t *ctx)
|
||||
{
|
||||
BSTR identifier = ctx->instr->arg1.bstr;
|
||||
|
@ -419,6 +426,13 @@ static HRESULT interp_assign_member(exec_ctx_t *ctx)
|
|||
return hres;
|
||||
}
|
||||
|
||||
static HRESULT interp_set_member(exec_ctx_t *ctx)
|
||||
{
|
||||
BSTR identifier = ctx->instr->arg1.bstr;
|
||||
FIXME("%s\n", debugstr_w(identifier));
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT interp_jmp(exec_ctx_t *ctx)
|
||||
{
|
||||
const unsigned arg = ctx->instr->arg1.uint;
|
||||
|
|
|
@ -94,7 +94,8 @@ typedef enum {
|
|||
STAT_EXITFUNC,
|
||||
STAT_EXITSUB,
|
||||
STAT_FUNC,
|
||||
STAT_IF
|
||||
STAT_IF,
|
||||
STAT_SET
|
||||
} statement_type_t;
|
||||
|
||||
typedef struct _statement_t {
|
||||
|
|
|
@ -49,6 +49,7 @@ static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,co
|
|||
static void *new_statement(parser_ctx_t*,statement_type_t,size_t);
|
||||
static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*);
|
||||
static statement_t *new_assign_statement(parser_ctx_t*,member_expression_t*,expression_t*);
|
||||
static statement_t *new_set_statement(parser_ctx_t*,member_expression_t*,expression_t*);
|
||||
static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*);
|
||||
static statement_t *new_if_statement(parser_ctx_t*,expression_t*,statement_t*,elseif_decl_t*,statement_t*);
|
||||
static statement_t *new_function_statement(parser_ctx_t*,function_decl_t*);
|
||||
|
@ -146,6 +147,8 @@ Statement
|
|||
| FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; }
|
||||
| tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; }
|
||||
| tEXIT tSUB { $$ = new_statement(ctx, STAT_EXITSUB, 0); CHECK_ERROR; }
|
||||
| tSET MemberExpression Arguments_opt '=' Expression
|
||||
{ $2->args = $3; $$ = new_set_statement(ctx, $2, $5); CHECK_ERROR; }
|
||||
|
||||
MemberExpression
|
||||
: tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; }
|
||||
|
@ -465,6 +468,19 @@ static statement_t *new_assign_statement(parser_ctx_t *ctx, member_expression_t
|
|||
return &stat->stat;
|
||||
}
|
||||
|
||||
static statement_t *new_set_statement(parser_ctx_t *ctx, member_expression_t *left, expression_t *right)
|
||||
{
|
||||
assign_statement_t *stat;
|
||||
|
||||
stat = new_statement(ctx, STAT_SET, sizeof(*stat));
|
||||
if(!stat)
|
||||
return NULL;
|
||||
|
||||
stat->member_expr = left;
|
||||
stat->value_expr = right;
|
||||
return &stat->stat;
|
||||
}
|
||||
|
||||
static dim_decl_t *new_dim_decl(parser_ctx_t *ctx, const WCHAR *name, dim_decl_t *next)
|
||||
{
|
||||
dim_decl_t *decl;
|
||||
|
|
|
@ -150,6 +150,8 @@ typedef enum {
|
|||
X(null, 1, 0, 0) \
|
||||
X(or, 1, 0, 0) \
|
||||
X(ret, 0, 0, 0) \
|
||||
X(set_ident, 1, ARG_BSTR, 0) \
|
||||
X(set_member, 1, ARG_BSTR, 0) \
|
||||
X(short, 1, ARG_INT, 0) \
|
||||
X(string, 1, ARG_STR, 0) \
|
||||
X(sub, 1, 0, 0) \
|
||||
|
|
Loading…
Reference in New Issue