vbscript: Added getters/setters parser implementation.
This commit is contained in:
parent
e843608748
commit
32f336bd9d
|
@ -666,6 +666,10 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f
|
||||||
if(ctx->sub_end_label == -1)
|
if(ctx->sub_end_label == -1)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
break;
|
break;
|
||||||
|
case FUNC_PROPGET:
|
||||||
|
case FUNC_PROPLET:
|
||||||
|
case FUNC_PROPSET:
|
||||||
|
/* FIXME */
|
||||||
case FUNC_GLOBAL:
|
case FUNC_GLOBAL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ typedef struct _function_decl_t {
|
||||||
arg_decl_t *args;
|
arg_decl_t *args;
|
||||||
statement_t *body;
|
statement_t *body;
|
||||||
struct _function_decl_t *next;
|
struct _function_decl_t *next;
|
||||||
|
struct _function_decl_t *next_prop_func;
|
||||||
} function_decl_t;
|
} function_decl_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -115,7 +115,7 @@ static class_decl_t *add_variant_prop(parser_ctx_t*,class_decl_t*,const WCHAR*,u
|
||||||
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
|
%type <expression> Arguments_opt ArgumentList_opt ArgumentList
|
||||||
%type <bool> OptionExplicit_opt
|
%type <bool> OptionExplicit_opt
|
||||||
%type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl
|
%type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl
|
||||||
%type <func_decl> FunctionDecl
|
%type <func_decl> FunctionDecl PropertyDecl
|
||||||
%type <elseif> ElseIfs_opt ElseIfs ElseIf
|
%type <elseif> ElseIfs_opt ElseIfs ElseIf
|
||||||
%type <class_decl> ClassDeclaration ClassBody
|
%type <class_decl> ClassDeclaration ClassBody
|
||||||
%type <uint> Storage Storage_opt
|
%type <uint> Storage Storage_opt
|
||||||
|
@ -295,6 +295,15 @@ ClassBody
|
||||||
: /* empty */ { $$ = new_class_decl(ctx); }
|
: /* empty */ { $$ = new_class_decl(ctx); }
|
||||||
| FunctionDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
|
| FunctionDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
|
||||||
| Storage tIdentifier tNL ClassBody { $$ = add_variant_prop(ctx, $4, $2, $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
|
FunctionDecl
|
||||||
: Storage_opt tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB
|
: 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;
|
function_decl_t *decl;
|
||||||
|
|
||||||
if(storage_flags & STORAGE_IS_DEFAULT) {
|
if(storage_flags & STORAGE_IS_DEFAULT) {
|
||||||
FIXME("Function declared as default property\n");
|
if(type == FUNC_PROPGET) {
|
||||||
ctx->hres = E_FAIL;
|
FIXME("default value not implemented\n");
|
||||||
return NULL;
|
ctx->hres = E_NOTIMPL;
|
||||||
|
}else {
|
||||||
|
FIXME("Invalid default property\n");
|
||||||
|
ctx->hres = E_FAIL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decl = parser_alloc(ctx, sizeof(*decl));
|
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->args = arg_decl;
|
||||||
decl->body = body;
|
decl->body = body;
|
||||||
decl->next = NULL;
|
decl->next = NULL;
|
||||||
|
decl->next_prop_func = NULL;
|
||||||
return decl;
|
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;
|
ctx->hres = E_FAIL;
|
||||||
return NULL;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,11 +399,25 @@ Class TestClass
|
||||||
publicFunction = 4
|
publicFunction = 4
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Property Get gsProp()
|
||||||
|
gsProp = privateProp
|
||||||
|
funcCalled = "gsProp get"
|
||||||
|
End Property
|
||||||
|
|
||||||
Public publicProp2
|
Public publicProp2
|
||||||
|
|
||||||
Public Sub publicSub
|
Public Sub publicSub
|
||||||
End Sub
|
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)
|
Public Sub setPrivateProp(x)
|
||||||
privateProp = x
|
privateProp = x
|
||||||
End Sub
|
End Sub
|
||||||
|
|
|
@ -211,7 +211,10 @@ typedef struct {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FUNC_GLOBAL,
|
FUNC_GLOBAL,
|
||||||
FUNC_FUNCTION,
|
FUNC_FUNCTION,
|
||||||
FUNC_SUB
|
FUNC_SUB,
|
||||||
|
FUNC_PROPGET,
|
||||||
|
FUNC_PROPLET,
|
||||||
|
FUNC_PROPSET
|
||||||
} function_type_t;
|
} function_type_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue