diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 14d259878ba..015e775e9a3 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -666,6 +666,10 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f if(ctx->sub_end_label == -1) return E_OUTOFMEMORY; break; + case FUNC_PROPGET: + case FUNC_PROPLET: + case FUNC_PROPSET: + /* FIXME */ case FUNC_GLOBAL: break; } diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 63b2ded21a5..6227e0c465d 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -140,6 +140,7 @@ typedef struct _function_decl_t { arg_decl_t *args; statement_t *body; struct _function_decl_t *next; + struct _function_decl_t *next_prop_func; } function_decl_t; typedef struct { diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 5224c71c6c8..f67abd5ceab 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -115,7 +115,7 @@ static class_decl_t *add_variant_prop(parser_ctx_t*,class_decl_t*,const WCHAR*,u %type Arguments_opt ArgumentList_opt ArgumentList %type OptionExplicit_opt %type ArgumentsDecl_opt ArgumentDeclList ArgumentDecl -%type FunctionDecl +%type FunctionDecl PropertyDecl %type ElseIfs_opt ElseIfs ElseIf %type ClassDeclaration ClassBody %type Storage Storage_opt @@ -295,6 +295,15 @@ ClassBody : /* empty */ { $$ = new_class_decl(ctx); } | FunctionDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; } | Storage tIdentifier tNL ClassBody { $$ = add_variant_prop(ctx, $4, $2, $1); CHECK_ERROR; } + | PropertyDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; } + +PropertyDecl + : Storage_opt tPROPERTY tGET tIdentifier EmptyBrackets_opt tNL StatementsNl_opt tEND tPROPERTY + { $$ = new_function_decl(ctx, $4, FUNC_PROPGET, $1, NULL, $7); CHECK_ERROR; } + | Storage_opt tPROPERTY tLET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY + { $$ = new_function_decl(ctx, $4, FUNC_PROPLET, $1, $6, $9); CHECK_ERROR; } + | Storage_opt tPROPERTY tSET tIdentifier '(' ArgumentDecl ')' tNL StatementsNl_opt tEND tPROPERTY + { $$ = new_function_decl(ctx, $4, FUNC_PROPSET, $1, $6, $9); CHECK_ERROR; } FunctionDecl : Storage_opt tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB @@ -591,9 +600,14 @@ static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, function_decl_t *decl; if(storage_flags & STORAGE_IS_DEFAULT) { - FIXME("Function declared as default property\n"); - ctx->hres = E_FAIL; - return NULL; + if(type == FUNC_PROPGET) { + FIXME("default value not implemented\n"); + ctx->hres = E_NOTIMPL; + }else { + FIXME("Invalid default property\n"); + ctx->hres = E_FAIL; + return NULL; + } } decl = parser_alloc(ctx, sizeof(*decl)); @@ -606,6 +620,7 @@ static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name, decl->args = arg_decl; decl->body = body; decl->next = NULL; + decl->next_prop_func = NULL; return decl; } @@ -646,6 +661,20 @@ static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_d ctx->hres = E_FAIL; return NULL; } + + while(1) { + if(iter->type == decl->type) { + FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name)); + ctx->hres = E_FAIL; + return NULL; + } + if(!iter->next_prop_func) + break; + iter = iter->next_prop_func; + } + + iter->next_prop_func = decl; + return class_decl; } } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index e29a20ff984..ac70b5ff84b 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -399,11 +399,25 @@ Class TestClass publicFunction = 4 End Function + Public Property Get gsProp() + gsProp = privateProp + funcCalled = "gsProp get" + End Property + Public publicProp2 Public Sub publicSub End Sub + Public Property Let gsProp(val) + privateProp = val + funcCalled = "gsProp let" + End Property + + Public Property Set gsProp(val) + funcCalled = "gsProp set" + End Property + Public Sub setPrivateProp(x) privateProp = x End Sub diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index ce1fa01f585..74332939de3 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -211,7 +211,10 @@ typedef struct { typedef enum { FUNC_GLOBAL, FUNC_FUNCTION, - FUNC_SUB + FUNC_SUB, + FUNC_PROPGET, + FUNC_PROPLET, + FUNC_PROPSET } function_type_t; typedef struct {