Jacek Caban : vbscript: Added function storage specifiers support.
Alexandre Julliard
julliard at winehq.org
Thu Sep 15 12:34:55 CDT 2011
Module: wine
Branch: master
Commit: 3862cdab4ffb12aab79309df331fbe40a962ba37
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3862cdab4ffb12aab79309df331fbe40a962ba37
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Sep 15 14:20:05 2011 +0200
vbscript: Added function storage specifiers support.
---
dlls/vbscript/compile.c | 1 +
dlls/vbscript/parse.h | 1 +
dlls/vbscript/parser.y | 35 ++++++++++++++++++++++++++++-------
dlls/vbscript/tests/lang.vbs | 16 ++++++++++++++++
dlls/vbscript/vbscript.h | 1 +
5 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 698ea8d..5c7f7e3 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -760,6 +760,7 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi
func->var_cnt = 0;
func->code_ctx = ctx->code;
func->type = decl->type;
+ func->is_public = decl->is_public;
func->arg_cnt = 0;
if(decl->args) {
diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h
index ac0f310..3a4d03b 100644
--- a/dlls/vbscript/parse.h
+++ b/dlls/vbscript/parse.h
@@ -135,6 +135,7 @@ typedef struct _arg_decl_t {
typedef struct _function_decl_t {
const WCHAR *name;
function_type_t type;
+ BOOL is_public;
arg_decl_t *args;
statement_t *body;
struct _function_decl_t *next;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y
index 50a4bf1..e310a70 100644
--- a/dlls/vbscript/parser.y
+++ b/dlls/vbscript/parser.y
@@ -31,7 +31,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
static int parser_error(const char*);
- static void parse_complete(parser_ctx_t*,BOOL);
+static void parse_complete(parser_ctx_t*,BOOL);
static void source_add_statement(parser_ctx_t*,statement_t*);
static void source_add_class(parser_ctx_t*,class_decl_t*);
@@ -57,10 +57,13 @@ static statement_t *new_function_statement(parser_ctx_t*,function_decl_t*);
static dim_decl_t *new_dim_decl(parser_ctx_t*,const WCHAR*,dim_decl_t*);
static elseif_decl_t *new_elseif_decl(parser_ctx_t*,expression_t*,statement_t*);
-static function_decl_t *new_function_decl(parser_ctx_t*,const WCHAR*,function_type_t,arg_decl_t*,statement_t*);
+static function_decl_t *new_function_decl(parser_ctx_t*,const WCHAR*,function_type_t,unsigned,arg_decl_t*,statement_t*);
static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL);
static class_decl_t *new_class_decl(parser_ctx_t*);
+#define STORAGE_IS_PRIVATE 1
+#define STORAGE_IS_DEFAULT 2
+
#define CHECK_ERROR if(((parser_ctx_t*)ctx)->hres != S_OK) YYABORT
%}
@@ -78,6 +81,7 @@ static class_decl_t *new_class_decl(parser_ctx_t*);
function_decl_t *func_decl;
arg_decl_t *arg_decl;
class_decl_t *class_decl;
+ unsigned uint;
LONG lng;
BOOL bool;
double dbl;
@@ -111,6 +115,7 @@ static class_decl_t *new_class_decl(parser_ctx_t*);
%type <func_decl> FunctionDecl
%type <elseif> ElseIfs_opt ElseIfs ElseIf
%type <class_decl> ClassDeclaration ClassBody
+%type <uint> Storage Storage_opt
%type <dim_decl> DimDeclList
%%
@@ -286,10 +291,19 @@ ClassBody
: /* empty */ { $$ = new_class_decl(ctx); }
FunctionDecl
- : /* Storage_opt */ tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB
- { $$ = new_function_decl(ctx, $2, FUNC_SUB, $3, $5); CHECK_ERROR; }
- | /* Storage_opt */ tFUNCTION tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tFUNCTION
- { $$ = new_function_decl(ctx, $2, FUNC_FUNCTION, $3, $5); CHECK_ERROR; }
+ : Storage_opt tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB
+ { $$ = new_function_decl(ctx, $3, FUNC_SUB, $1, $4, $6); CHECK_ERROR; }
+ | Storage_opt tFUNCTION tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tFUNCTION
+ { $$ = new_function_decl(ctx, $3, FUNC_FUNCTION, $1, $4, $6); CHECK_ERROR; }
+
+Storage_opt
+ : /* empty*/ { $$ = 0; }
+ | Storage { $$ = $1; }
+
+Storage
+ : tPUBLIC tDEFAULT { $$ = STORAGE_IS_DEFAULT; }
+ | tPUBLIC { $$ = 0; }
+ | tPRIVATE { $$ = STORAGE_IS_PRIVATE; }
ArgumentsDecl_opt
: EmptyBrackets_opt { $$ = NULL; }
@@ -566,16 +580,23 @@ static arg_decl_t *new_argument_decl(parser_ctx_t *ctx, const WCHAR *name, BOOL
}
static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, function_type_t type,
- arg_decl_t *arg_decl, statement_t *body)
+ unsigned storage_flags, arg_decl_t *arg_decl, statement_t *body)
{
function_decl_t *decl;
+ if(storage_flags & STORAGE_IS_DEFAULT) {
+ FIXME("Function declared as default property\n");
+ ctx->hres = E_FAIL;
+ return NULL;
+ }
+
decl = parser_alloc(ctx, sizeof(*decl));
if(!decl)
return NULL;
decl->name = name;
decl->type = type;
+ decl->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
decl->args = arg_decl;
decl->body = body;
return decl;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index a94b2cd..bc64f85 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -271,6 +271,14 @@ y = true
Call TestSubLocalVal
Call ok(x, "global x is not true?")
+Public Sub TestPublicSub
+End Sub
+Call TestPublicSub
+
+Private Sub TestPrivateSub
+End Sub
+Call TestPrivateSub
+
if false then
Function testfunc
x = true
@@ -360,6 +368,14 @@ x = false
ok SetVal(x, true), "SetVal returned false?"
Call ok(x, "x is not set to true by SetVal?")
+Public Function TestPublicFunc
+End Function
+Call TestPublicFunc
+
+Private Function TestPrivateFunc
+End Function
+Call TestPrivateFunc
+
set x = testObj
Call ok(getVT(x) = "VT_DISPATCH*", "getVT(x=testObj) = " & getVT(x))
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 8defcd6..014e480 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -204,6 +204,7 @@ typedef struct {
struct _function_t {
function_type_t type;
const WCHAR *name;
+ BOOL is_public;
arg_desc_t *args;
unsigned arg_cnt;
var_desc_t *vars;
More information about the wine-cvs
mailing list