vbscript: Added class functions parser implementation.
This commit is contained in:
parent
3862cdab4f
commit
ee67bc7a37
|
@ -148,6 +148,7 @@ typedef struct _function_statement_t {
|
||||||
|
|
||||||
typedef struct _class_decl_t {
|
typedef struct _class_decl_t {
|
||||||
const WCHAR *name;
|
const WCHAR *name;
|
||||||
|
function_decl_t *funcs;
|
||||||
struct _class_decl_t *next;
|
struct _class_decl_t *next;
|
||||||
} class_decl_t;
|
} class_decl_t;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,9 @@ 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 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,unsigned,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 arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL);
|
||||||
|
|
||||||
static class_decl_t *new_class_decl(parser_ctx_t*);
|
static class_decl_t *new_class_decl(parser_ctx_t*);
|
||||||
|
static class_decl_t *add_class_function(parser_ctx_t*,class_decl_t*,function_decl_t*);
|
||||||
|
|
||||||
#define STORAGE_IS_PRIVATE 1
|
#define STORAGE_IS_PRIVATE 1
|
||||||
#define STORAGE_IS_DEFAULT 2
|
#define STORAGE_IS_DEFAULT 2
|
||||||
|
@ -289,6 +291,7 @@ ClassDeclaration
|
||||||
|
|
||||||
ClassBody
|
ClassBody
|
||||||
: /* empty */ { $$ = new_class_decl(ctx); }
|
: /* empty */ { $$ = new_class_decl(ctx); }
|
||||||
|
| FunctionDecl tNL ClassBody { $$ = add_class_function(ctx, $3, $1); 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
|
||||||
|
@ -599,6 +602,7 @@ static function_decl_t *new_function_decl(parser_ctx_t *ctx, const WCHAR *name,
|
||||||
decl->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
|
decl->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
|
||||||
decl->args = arg_decl;
|
decl->args = arg_decl;
|
||||||
decl->body = body;
|
decl->body = body;
|
||||||
|
decl->next = NULL;
|
||||||
return decl;
|
return decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,10 +626,30 @@ static class_decl_t *new_class_decl(parser_ctx_t *ctx)
|
||||||
if(!class_decl)
|
if(!class_decl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
class_decl->funcs = NULL;
|
||||||
class_decl->next = NULL;
|
class_decl->next = NULL;
|
||||||
return class_decl;
|
return class_decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_decl, function_decl_t *decl)
|
||||||
|
{
|
||||||
|
function_decl_t *iter;
|
||||||
|
|
||||||
|
for(iter = class_decl->funcs; iter; iter = iter->next) {
|
||||||
|
if(!strcmpiW(iter->name, decl->name)) {
|
||||||
|
if(decl->type == FUNC_SUB || decl->type == FUNC_FUNCTION) {
|
||||||
|
FIXME("Redefinition of %s::%s\n", debugstr_w(class_decl->name), debugstr_w(decl->name));
|
||||||
|
ctx->hres = E_FAIL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
decl->next = class_decl->funcs;
|
||||||
|
class_decl->funcs = decl;
|
||||||
|
return class_decl;
|
||||||
|
}
|
||||||
|
|
||||||
void *parser_alloc(parser_ctx_t *ctx, size_t size)
|
void *parser_alloc(parser_ctx_t *ctx, size_t size)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|
|
@ -386,4 +386,16 @@ Call ok(getVT(obj) = "VT_DISPATCH*", "getVT(obj) = " & getVT(obj))
|
||||||
Class EmptyClass
|
Class EmptyClass
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
Class TestClass
|
||||||
|
Public Function publicFunction()
|
||||||
|
publicFunction = 4
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Sub publicSub
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub privateSub
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
|
|
||||||
reportSuccess()
|
reportSuccess()
|
||||||
|
|
Loading…
Reference in New Issue