vbscript: Added assign statement compiler implementation.

This commit is contained in:
Jacek Caban 2011-09-12 12:32:50 +02:00 committed by Alexandre Julliard
parent e63c447228
commit 3c85122e05
3 changed files with 50 additions and 0 deletions

View File

@ -150,6 +150,23 @@ static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str)
return ctx->code->bstr_pool[ctx->code->bstr_cnt++]; return ctx->code->bstr_pool[ctx->code->bstr_cnt++];
} }
static HRESULT push_instr_bstr(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg)
{
unsigned instr;
BSTR bstr;
bstr = alloc_bstr_arg(ctx, arg);
if(!bstr)
return E_OUTOFMEMORY;
instr = push_instr(ctx, op);
if(instr == -1)
return E_OUTOFMEMORY;
instr_ptr(ctx, instr)->arg1.bstr = bstr;
return S_OK;
}
static HRESULT push_instr_bstr_uint(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg1, unsigned arg2) static HRESULT push_instr_bstr_uint(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg1, unsigned arg2)
{ {
unsigned instr; unsigned instr;
@ -272,12 +289,38 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
return S_OK; return S_OK;
} }
static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat)
{
HRESULT hres;
hres = compile_expression(ctx, stat->value_expr);
if(FAILED(hres))
return hres;
if(stat->member_expr->args) {
FIXME("arguments support not implemented\n");
return E_NOTIMPL;
}
if(stat->member_expr->obj_expr) {
FIXME("obj_expr not implemented\n");
hres = E_NOTIMPL;
}else {
hres = push_instr_bstr(ctx, OP_assign_ident, stat->member_expr->identifier);
}
return hres;
}
static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat)
{ {
HRESULT hres; HRESULT hres;
while(stat) { while(stat) {
switch(stat->type) { switch(stat->type) {
case STAT_ASSIGN:
hres = compile_assign_statement(ctx, (assign_statement_t*)stat);
break;
case STAT_CALL: case STAT_CALL:
hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr, FALSE); hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr, FALSE);
break; break;

View File

@ -217,6 +217,12 @@ static HRESULT interp_icallv(exec_ctx_t *ctx)
return do_icall(ctx, NULL); return do_icall(ctx, NULL);
} }
static HRESULT interp_assign_ident(exec_ctx_t *ctx)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT interp_ret(exec_ctx_t *ctx) static HRESULT interp_ret(exec_ctx_t *ctx)
{ {
TRACE("\n"); TRACE("\n");

View File

@ -89,6 +89,7 @@ typedef enum {
#define OP_LIST \ #define OP_LIST \
X(add, 1, 0, 0) \ X(add, 1, 0, 0) \
X(assign_ident, 1, ARG_BSTR, 0) \
X(bool, 1, ARG_INT, 0) \ X(bool, 1, ARG_INT, 0) \
X(concat, 1, 0, 0) \ X(concat, 1, 0, 0) \
X(double, 1, ARG_DOUBLE, 0) \ X(double, 1, ARG_DOUBLE, 0) \