vbscript: Added class properties compiler implementation.
This commit is contained in:
parent
117fd7c0e1
commit
ae57aa14b3
|
@ -821,9 +821,22 @@ static HRESULT create_class_funcprop(compile_ctx_t *ctx, function_decl_t *func_d
|
||||||
return create_function(ctx, func_decl, desc->entries);
|
return create_function(ctx, func_decl, desc->entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL lookup_class_funcs(class_desc_t *class_desc, const WCHAR *name)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for(i=0; i < class_desc->func_cnt; i++) {
|
||||||
|
if(class_desc->funcs[i].name && !strcmpiW(class_desc->funcs[i].name, name))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
||||||
{
|
{
|
||||||
function_decl_t *func_decl;
|
function_decl_t *func_decl;
|
||||||
|
class_prop_decl_t *prop_decl;
|
||||||
class_desc_t *class_desc;
|
class_desc_t *class_desc;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -843,6 +856,7 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
class_desc->func_cnt = 1; /* always allocate slot for default getter */
|
class_desc->func_cnt = 1; /* always allocate slot for default getter */
|
||||||
|
class_desc->prop_cnt = 0;
|
||||||
|
|
||||||
for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next)
|
for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next)
|
||||||
class_desc->func_cnt++;
|
class_desc->func_cnt++;
|
||||||
|
@ -858,6 +872,26 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(prop_decl = class_decl->props; prop_decl; prop_decl = prop_decl->next)
|
||||||
|
class_desc->prop_cnt++;
|
||||||
|
|
||||||
|
class_desc->props = compiler_alloc(ctx->code, class_desc->prop_cnt*sizeof(*class_desc->props));
|
||||||
|
if(!class_desc->props)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
for(prop_decl = class_decl->props, i=0; prop_decl; prop_decl = prop_decl->next, i++) {
|
||||||
|
if(lookup_class_funcs(class_desc, prop_decl->name)) {
|
||||||
|
FIXME("Property %s redefined\n", debugstr_w(prop_decl->name));
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
class_desc->props[i].name = compiler_alloc_string(ctx->code, prop_decl->name);
|
||||||
|
if(!class_desc->props[i].name)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
class_desc->props[i].is_public = prop_decl->is_public;
|
||||||
|
}
|
||||||
|
|
||||||
class_desc->next = ctx->classes;
|
class_desc->next = ctx->classes;
|
||||||
ctx->classes = class_desc;
|
ctx->classes = class_desc;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
|
@ -62,6 +62,11 @@ typedef enum {
|
||||||
VBDISP_ANY
|
VBDISP_ANY
|
||||||
} vbdisp_invoke_type_t;
|
} vbdisp_invoke_type_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BOOL is_public;
|
||||||
|
const WCHAR *name;
|
||||||
|
} vbdisp_prop_desc_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const WCHAR *name;
|
const WCHAR *name;
|
||||||
BOOL is_public;
|
BOOL is_public;
|
||||||
|
@ -73,6 +78,8 @@ typedef struct _class_desc_t {
|
||||||
script_ctx_t *ctx;
|
script_ctx_t *ctx;
|
||||||
unsigned func_cnt;
|
unsigned func_cnt;
|
||||||
vbdisp_funcprop_desc_t *funcs;
|
vbdisp_funcprop_desc_t *funcs;
|
||||||
|
unsigned prop_cnt;
|
||||||
|
vbdisp_prop_desc_t *props;
|
||||||
struct _class_desc_t *next;
|
struct _class_desc_t *next;
|
||||||
} class_desc_t;
|
} class_desc_t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue