Jacek Caban : vbscript: Added set statement parser/compiler implementation.

Alexandre Julliard julliard at winehq.org
Thu Sep 15 12:34:54 CDT 2011


Module: wine
Branch: master
Commit: b3a6217ed3105ab69eec4a571b9012052f2c3e13
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b3a6217ed3105ab69eec4a571b9012052f2c3e13

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Sep 15 14:17:38 2011 +0200

vbscript: Added set statement parser/compiler implementation.

---

 dlls/vbscript/compile.c  |   11 +++++++----
 dlls/vbscript/interp.c   |   14 ++++++++++++++
 dlls/vbscript/parse.h    |    3 ++-
 dlls/vbscript/parser.y   |   16 ++++++++++++++++
 dlls/vbscript/vbscript.h |    2 ++
 5 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 21c8588..d1720cf 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -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;
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 2a50667..e61ed7a 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -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;
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index 67fa221..76f8775 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -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 {
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 6d8a674..2e0140e 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -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;
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 9ad3bb6..9655978 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -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)          \




More information about the wine-cvs mailing list