vbscript: Added class property parser implementation.
This commit is contained in:
parent
005808cb0e
commit
117fd7c0e1
|
@ -142,14 +142,21 @@ typedef struct _function_decl_t {
|
||||||
struct _function_decl_t *next;
|
struct _function_decl_t *next;
|
||||||
} function_decl_t;
|
} function_decl_t;
|
||||||
|
|
||||||
typedef struct _function_statement_t {
|
typedef struct {
|
||||||
statement_t stat;
|
statement_t stat;
|
||||||
function_decl_t *func_decl;
|
function_decl_t *func_decl;
|
||||||
} function_statement_t;
|
} function_statement_t;
|
||||||
|
|
||||||
|
typedef struct _class_prop_decl_t {
|
||||||
|
BOOL is_public;
|
||||||
|
const WCHAR *name;
|
||||||
|
struct _class_prop_decl_t *next;
|
||||||
|
} class_prop_decl_t;
|
||||||
|
|
||||||
typedef struct _class_decl_t {
|
typedef struct _class_decl_t {
|
||||||
const WCHAR *name;
|
const WCHAR *name;
|
||||||
function_decl_t *funcs;
|
function_decl_t *funcs;
|
||||||
|
class_prop_decl_t *props;
|
||||||
struct _class_decl_t *next;
|
struct _class_decl_t *next;
|
||||||
} class_decl_t;
|
} class_decl_t;
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ 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*);
|
static class_decl_t *add_class_function(parser_ctx_t*,class_decl_t*,function_decl_t*);
|
||||||
|
static class_decl_t *add_variant_prop(parser_ctx_t*,class_decl_t*,const WCHAR*,unsigned);
|
||||||
|
|
||||||
#define STORAGE_IS_PRIVATE 1
|
#define STORAGE_IS_PRIVATE 1
|
||||||
#define STORAGE_IS_DEFAULT 2
|
#define STORAGE_IS_DEFAULT 2
|
||||||
|
@ -293,6 +294,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 tNL ClassBody { $$ = add_class_function(ctx, $3, $1); CHECK_ERROR; }
|
||||||
|
| Storage tIdentifier tNL ClassBody { $$ = add_variant_prop(ctx, $4, $2, $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
|
||||||
|
@ -628,6 +630,7 @@ static class_decl_t *new_class_decl(parser_ctx_t *ctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
class_decl->funcs = NULL;
|
class_decl->funcs = NULL;
|
||||||
|
class_decl->props = NULL;
|
||||||
class_decl->next = NULL;
|
class_decl->next = NULL;
|
||||||
return class_decl;
|
return class_decl;
|
||||||
}
|
}
|
||||||
|
@ -651,6 +654,27 @@ static class_decl_t *add_class_function(parser_ctx_t *ctx, class_decl_t *class_d
|
||||||
return class_decl;
|
return class_decl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class_decl_t *add_variant_prop(parser_ctx_t *ctx, class_decl_t *class_decl, const WCHAR *identifier, unsigned storage_flags)
|
||||||
|
{
|
||||||
|
class_prop_decl_t *prop;
|
||||||
|
|
||||||
|
if(storage_flags & STORAGE_IS_DEFAULT) {
|
||||||
|
FIXME("variant prop van't be default value\n");
|
||||||
|
ctx->hres = E_FAIL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop = parser_alloc(ctx, sizeof(*prop));
|
||||||
|
if(!prop)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
prop->name = identifier;
|
||||||
|
prop->is_public = !(storage_flags & STORAGE_IS_PRIVATE);
|
||||||
|
prop->next = class_decl->props;
|
||||||
|
class_decl->props = prop;
|
||||||
|
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;
|
||||||
|
|
|
@ -390,6 +390,10 @@ Class EmptyClass
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
Class TestClass
|
Class TestClass
|
||||||
|
Public publicProp
|
||||||
|
|
||||||
|
Private privateProp
|
||||||
|
|
||||||
Public Function publicFunction()
|
Public Function publicFunction()
|
||||||
privateSub()
|
privateSub()
|
||||||
publicFunction = 4
|
publicFunction = 4
|
||||||
|
|
Loading…
Reference in New Issue