vbscript: Added function arguments compiler implementation.
This commit is contained in:
parent
48d04b220b
commit
0c0b252c24
|
@ -658,9 +658,26 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi
|
||||||
func->code_ctx = ctx->code;
|
func->code_ctx = ctx->code;
|
||||||
func->type = decl->type;
|
func->type = decl->type;
|
||||||
|
|
||||||
|
func->arg_cnt = 0;
|
||||||
if(decl->args) {
|
if(decl->args) {
|
||||||
FIXME("arguments not implemented\n");
|
arg_decl_t *arg;
|
||||||
return E_NOTIMPL;
|
unsigned i;
|
||||||
|
|
||||||
|
for(arg = decl->args; arg; arg = arg->next)
|
||||||
|
func->arg_cnt++;
|
||||||
|
|
||||||
|
func->args = compiler_alloc(ctx->code, func->arg_cnt * sizeof(arg_desc_t));
|
||||||
|
if(!func->args)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
for(i = 0, arg = decl->args; arg; arg = arg->next, i++) {
|
||||||
|
func->args[i].name = compiler_alloc_string(ctx->code, arg->name);
|
||||||
|
if(!func->args[i].name)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
func->args[i].by_ref = arg->by_ref;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
func->args = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = compile_func(ctx, decl->body, func);
|
hres = compile_func(ctx, decl->body, func);
|
||||||
|
@ -761,6 +778,8 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source)
|
||||||
ret->global_code.type = FUNC_GLOBAL;
|
ret->global_code.type = FUNC_GLOBAL;
|
||||||
ret->global_code.name = NULL;
|
ret->global_code.name = NULL;
|
||||||
ret->global_code.code_ctx = ret;
|
ret->global_code.code_ctx = ret;
|
||||||
|
ret->global_code.arg_cnt = 0;
|
||||||
|
ret->global_code.args = NULL;
|
||||||
|
|
||||||
list_init(&ret->entry);
|
list_init(&ret->entry);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -152,6 +152,11 @@ typedef struct {
|
||||||
instr_arg_t arg2;
|
instr_arg_t arg2;
|
||||||
} instr_t;
|
} instr_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const WCHAR *name;
|
||||||
|
BOOL by_ref;
|
||||||
|
} arg_desc_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FUNC_GLOBAL,
|
FUNC_GLOBAL,
|
||||||
FUNC_SUB
|
FUNC_SUB
|
||||||
|
@ -160,6 +165,8 @@ typedef enum {
|
||||||
struct _function_t {
|
struct _function_t {
|
||||||
function_type_t type;
|
function_type_t type;
|
||||||
const WCHAR *name;
|
const WCHAR *name;
|
||||||
|
arg_desc_t *args;
|
||||||
|
unsigned arg_cnt;
|
||||||
unsigned code_off;
|
unsigned code_off;
|
||||||
vbscode_t *code_ctx;
|
vbscode_t *code_ctx;
|
||||||
function_t *next;
|
function_t *next;
|
||||||
|
|
Loading…
Reference in New Issue