2 * Copyright 2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "parser.tab.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
28 WINE_DECLARE_DEBUG_CHANNEL(vbscript_disas);
41 unsigned sub_end_label;
42 unsigned func_end_label;
44 dim_decl_t *dim_decls;
45 dynamic_var_t *global_vars;
49 function_decl_t *func_decls;
51 class_desc_t *classes;
54 static HRESULT compile_expression(compile_ctx_t*,expression_t*);
55 static HRESULT compile_statement(compile_ctx_t*,statement_t*);
59 instr_arg_type_t arg1_type;
60 instr_arg_type_t arg2_type;
62 #define X(n,a,b,c) {#n,b,c},
67 static void dump_instr_arg(instr_arg_type_t type, instr_arg_t *arg)
72 TRACE_(vbscript_disas)("\t%s", debugstr_w(arg->str));
75 TRACE_(vbscript_disas)("\t%d", arg->uint);
79 TRACE_(vbscript_disas)("\t%u", arg->uint);
82 TRACE_(vbscript_disas)("\t%lf", *arg->dbl);
91 static void dump_code(compile_ctx_t *ctx)
95 for(instr = ctx->code->instrs; instr < ctx->code->instrs+ctx->instr_cnt; instr++) {
96 TRACE_(vbscript_disas)("%d:\t%s", instr-ctx->code->instrs, instr_info[instr->op].op_str);
97 dump_instr_arg(instr_info[instr->op].arg1_type, &instr->arg1);
98 dump_instr_arg(instr_info[instr->op].arg2_type, &instr->arg2);
99 TRACE_(vbscript_disas)("\n");
103 static inline void *compiler_alloc(vbscode_t *vbscode, size_t size)
105 return vbsheap_alloc(&vbscode->heap, size);
108 static WCHAR *compiler_alloc_string(vbscode_t *vbscode, const WCHAR *str)
113 size = (strlenW(str)+1)*sizeof(WCHAR);
114 ret = compiler_alloc(vbscode, size);
116 memcpy(ret, str, size);
120 static inline instr_t *instr_ptr(compile_ctx_t *ctx, unsigned id)
122 assert(id < ctx->instr_cnt);
123 return ctx->code->instrs + id;
126 static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op)
128 assert(ctx->instr_size && ctx->instr_size >= ctx->instr_cnt);
130 if(ctx->instr_size == ctx->instr_cnt) {
133 new_instr = heap_realloc(ctx->code->instrs, ctx->instr_size*2*sizeof(instr_t));
137 ctx->code->instrs = new_instr;
138 ctx->instr_size *= 2;
141 ctx->code->instrs[ctx->instr_cnt].op = op;
142 return ctx->instr_cnt++;
145 static HRESULT push_instr_int(compile_ctx_t *ctx, vbsop_t op, LONG arg)
149 ret = push_instr(ctx, op);
151 return E_OUTOFMEMORY;
153 instr_ptr(ctx, ret)->arg1.lng = arg;
157 static HRESULT push_instr_addr(compile_ctx_t *ctx, vbsop_t op, unsigned arg)
161 ret = push_instr(ctx, op);
163 return E_OUTOFMEMORY;
165 instr_ptr(ctx, ret)->arg1.uint = arg;
169 static HRESULT push_instr_str(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg)
174 str = compiler_alloc_string(ctx->code, arg);
176 return E_OUTOFMEMORY;
178 instr = push_instr(ctx, op);
180 return E_OUTOFMEMORY;
182 instr_ptr(ctx, instr)->arg1.str = str;
186 static HRESULT push_instr_double(compile_ctx_t *ctx, vbsop_t op, double arg)
191 d = compiler_alloc(ctx->code, sizeof(double));
193 return E_OUTOFMEMORY;
195 instr = push_instr(ctx, op);
197 return E_OUTOFMEMORY;
200 instr_ptr(ctx, instr)->arg1.dbl = d;
204 static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str)
206 if(!ctx->code->bstr_pool_size) {
207 ctx->code->bstr_pool = heap_alloc(8 * sizeof(BSTR));
208 if(!ctx->code->bstr_pool)
210 ctx->code->bstr_pool_size = 8;
211 }else if(ctx->code->bstr_pool_size == ctx->code->bstr_cnt) {
214 new_pool = heap_realloc(ctx->code->bstr_pool, ctx->code->bstr_pool_size*2*sizeof(BSTR));
218 ctx->code->bstr_pool = new_pool;
219 ctx->code->bstr_pool_size *= 2;
222 ctx->code->bstr_pool[ctx->code->bstr_cnt] = SysAllocString(str);
223 if(!ctx->code->bstr_pool[ctx->code->bstr_cnt])
226 return ctx->code->bstr_pool[ctx->code->bstr_cnt++];
229 static HRESULT push_instr_bstr(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg)
234 bstr = alloc_bstr_arg(ctx, arg);
236 return E_OUTOFMEMORY;
238 instr = push_instr(ctx, op);
240 return E_OUTOFMEMORY;
242 instr_ptr(ctx, instr)->arg1.bstr = bstr;
246 static HRESULT push_instr_bstr_uint(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg1, unsigned arg2)
251 bstr = alloc_bstr_arg(ctx, arg1);
253 return E_OUTOFMEMORY;
255 instr = push_instr(ctx, op);
257 return E_OUTOFMEMORY;
259 instr_ptr(ctx, instr)->arg1.bstr = bstr;
260 instr_ptr(ctx, instr)->arg2.uint = arg2;
264 #define LABEL_FLAG 0x80000000
266 static unsigned alloc_label(compile_ctx_t *ctx)
268 if(!ctx->labels_size) {
269 ctx->labels = heap_alloc(8 * sizeof(*ctx->labels));
272 ctx->labels_size = 8;
273 }else if(ctx->labels_size == ctx->labels_cnt) {
274 unsigned *new_labels;
276 new_labels = heap_realloc(ctx->labels, 2*ctx->labels_size*sizeof(*ctx->labels));
280 ctx->labels = new_labels;
281 ctx->labels_size *= 2;
284 return ctx->labels_cnt++ | LABEL_FLAG;
287 static inline void label_set_addr(compile_ctx_t *ctx, unsigned label)
289 assert(label & LABEL_FLAG);
290 ctx->labels[label & ~LABEL_FLAG] = ctx->instr_cnt;
293 static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *ret)
295 unsigned arg_cnt = 0;
299 hres = compile_expression(ctx, args);
311 static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t *expr, BOOL ret_val)
313 unsigned arg_cnt = 0;
316 hres = compile_args(ctx, expr->args, &arg_cnt);
321 hres = compile_expression(ctx, expr->obj_expr);
325 hres = push_instr_bstr_uint(ctx, ret_val ? OP_mcall : OP_mcallv, expr->identifier, arg_cnt);
327 hres = push_instr_bstr_uint(ctx, ret_val ? OP_icall : OP_icallv, expr->identifier, arg_cnt);
333 static HRESULT compile_unary_expression(compile_ctx_t *ctx, unary_expression_t *expr, vbsop_t op)
337 hres = compile_expression(ctx, expr->subexpr);
341 return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
344 static HRESULT compile_binary_expression(compile_ctx_t *ctx, binary_expression_t *expr, vbsop_t op)
348 hres = compile_expression(ctx, expr->left);
352 hres = compile_expression(ctx, expr->right);
356 return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
359 static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr)
363 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add);
365 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_and);
367 return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value);
369 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_concat);
371 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_div);
373 return push_instr_double(ctx, OP_double, ((double_expression_t*)expr)->value);
375 return push_instr(ctx, OP_empty) != -1 ? S_OK : E_OUTOFMEMORY;
377 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_equal);
379 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_eqv);
381 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_exp);
383 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_idiv);
385 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_imp);
387 return compile_member_expression(ctx, (member_expression_t*)expr, TRUE);
389 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mod);
391 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_mul);
393 return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_neg);
395 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_nequal);
397 return push_instr_str(ctx, OP_new, ((string_expression_t*)expr)->value);
399 return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not);
401 return push_instr(ctx, OP_nothing) != -1 ? S_OK : E_OUTOFMEMORY;
403 return push_instr(ctx, OP_null) != -1 ? S_OK : E_OUTOFMEMORY;
405 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_or);
407 return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value);
409 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_sub);
411 return push_instr_int(ctx, OP_short, ((int_expression_t*)expr)->value);
413 return push_instr_int(ctx, OP_long, ((int_expression_t*)expr)->value);
415 return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_xor);
417 FIXME("Unimplemented expression type %d\n", expr->type);
424 static HRESULT compile_if_statement(compile_ctx_t *ctx, if_statement_t *stat)
426 unsigned cnd_jmp, endif_label = -1;
427 elseif_decl_t *elseif_decl;
430 hres = compile_expression(ctx, stat->expr);
434 cnd_jmp = push_instr(ctx, OP_jmp_false);
436 return E_OUTOFMEMORY;
438 hres = compile_statement(ctx, stat->if_stat);
442 if(stat->else_stat || stat->elseifs) {
443 endif_label = alloc_label(ctx);
444 if(endif_label == -1)
445 return E_OUTOFMEMORY;
447 hres = push_instr_addr(ctx, OP_jmp, endif_label);
452 for(elseif_decl = stat->elseifs; elseif_decl; elseif_decl = elseif_decl->next) {
453 instr_ptr(ctx, cnd_jmp)->arg1.uint = ctx->instr_cnt;
455 hres = compile_expression(ctx, elseif_decl->expr);
459 cnd_jmp = push_instr(ctx, OP_jmp_false);
461 return E_OUTOFMEMORY;
463 hres = compile_statement(ctx, elseif_decl->stat);
467 hres = push_instr_addr(ctx, OP_jmp, endif_label);
472 instr_ptr(ctx, cnd_jmp)->arg1.uint = ctx->instr_cnt;
474 if(stat->else_stat) {
475 hres = compile_statement(ctx, stat->else_stat);
480 if(endif_label != -1)
481 label_set_addr(ctx, endif_label);
485 static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat, BOOL is_set)
489 hres = compile_expression(ctx, stat->value_expr);
493 if(stat->member_expr->args) {
494 FIXME("arguments support not implemented\n");
498 if(stat->member_expr->obj_expr) {
499 hres = compile_expression(ctx, stat->member_expr->obj_expr);
503 hres = push_instr_bstr(ctx, is_set ? OP_set_member : OP_assign_member, stat->member_expr->identifier);
505 hres = push_instr_bstr(ctx, is_set ? OP_set_ident : OP_assign_ident, stat->member_expr->identifier);
511 static BOOL lookup_dim_decls(compile_ctx_t *ctx, const WCHAR *name)
513 dim_decl_t *dim_decl;
515 for(dim_decl = ctx->dim_decls; dim_decl; dim_decl = dim_decl->next) {
516 if(!strcmpiW(dim_decl->name, name))
523 static BOOL lookup_args_name(compile_ctx_t *ctx, const WCHAR *name)
527 for(i = 0; i < ctx->func->arg_cnt; i++) {
528 if(!strcmpiW(ctx->func->args[i].name, name))
535 static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat)
537 dim_decl_t *dim_decl = stat->dim_decls;
540 if(lookup_dim_decls(ctx, dim_decl->name) || lookup_args_name(ctx, dim_decl->name)) {
541 FIXME("dim %s name redefined\n", debugstr_w(dim_decl->name));
547 dim_decl = dim_decl->next;
550 dim_decl->next = ctx->dim_decls;
551 ctx->dim_decls = stat->dim_decls;
552 ctx->func->var_cnt++;
556 static HRESULT compile_function_statement(compile_ctx_t *ctx, function_statement_t *stat)
558 if(ctx->func != &ctx->code->global_code) {
559 FIXME("Function is not in the global code\n");
563 stat->func_decl->next = ctx->func_decls;
564 ctx->func_decls = stat->func_decl;
568 static HRESULT compile_exitsub_statement(compile_ctx_t *ctx)
570 if(ctx->sub_end_label == -1) {
571 FIXME("Exit Sub outside Sub?\n");
575 return push_instr_addr(ctx, OP_jmp, ctx->sub_end_label);
578 static HRESULT compile_exitfunc_statement(compile_ctx_t *ctx)
580 if(ctx->func_end_label == -1) {
581 FIXME("Exit Function outside Function?\n");
585 return push_instr_addr(ctx, OP_jmp, ctx->func_end_label);
588 static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat)
595 hres = compile_assign_statement(ctx, (assign_statement_t*)stat, FALSE);
598 hres = compile_member_expression(ctx, ((call_statement_t*)stat)->expr, FALSE);
601 hres = compile_dim_statement(ctx, (dim_statement_t*)stat);
604 hres = compile_exitfunc_statement(ctx);
607 hres = compile_exitsub_statement(ctx);
610 hres = compile_function_statement(ctx, (function_statement_t*)stat);
613 hres = compile_if_statement(ctx, (if_statement_t*)stat);
616 hres = compile_assign_statement(ctx, (assign_statement_t*)stat, TRUE);
619 FIXME("Unimplemented statement type %d\n", stat->type);
631 static void resolve_labels(compile_ctx_t *ctx, unsigned off)
635 for(instr = ctx->code->instrs+off; instr < ctx->code->instrs+ctx->instr_cnt; instr++) {
636 if(instr_info[instr->op].arg1_type == ARG_ADDR && (instr->arg1.uint & LABEL_FLAG)) {
637 assert((instr->arg1.uint & ~LABEL_FLAG) < ctx->labels_cnt);
638 instr->arg1.uint = ctx->labels[instr->arg1.uint & ~LABEL_FLAG];
640 assert(instr_info[instr->op].arg2_type != ARG_ADDR);
646 static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func)
650 func->code_off = ctx->instr_cnt;
652 ctx->sub_end_label = -1;
653 ctx->func_end_label = -1;
657 ctx->func_end_label = alloc_label(ctx);
658 if(ctx->func_end_label == -1)
659 return E_OUTOFMEMORY; /* FIXME ! */
662 ctx->sub_end_label = alloc_label(ctx);
663 if(ctx->sub_end_label == -1)
664 return E_OUTOFMEMORY;
671 ctx->dim_decls = NULL;
672 hres = compile_statement(ctx, stat);
677 if(ctx->sub_end_label != -1)
678 label_set_addr(ctx, ctx->sub_end_label);
679 if(ctx->func_end_label != -1)
680 label_set_addr(ctx, ctx->func_end_label);
682 if(push_instr(ctx, OP_ret) == -1)
683 return E_OUTOFMEMORY;
685 resolve_labels(ctx, func->code_off);
688 dim_decl_t *dim_decl;
690 if(func->type == FUNC_GLOBAL) {
691 dynamic_var_t *new_var;
695 for(dim_decl = ctx->dim_decls; dim_decl; dim_decl = dim_decl->next) {
696 new_var = compiler_alloc(ctx->code, sizeof(*new_var));
698 return E_OUTOFMEMORY;
700 new_var->name = compiler_alloc_string(ctx->code, dim_decl->name);
702 return E_OUTOFMEMORY;
704 V_VT(&new_var->v) = VT_EMPTY;
706 new_var->next = ctx->global_vars;
707 ctx->global_vars = new_var;
712 func->vars = compiler_alloc(ctx->code, func->var_cnt * sizeof(var_desc_t));
714 return E_OUTOFMEMORY;
716 for(dim_decl = ctx->dim_decls, i=0; dim_decl; dim_decl = dim_decl->next, i++) {
717 func->vars[i].name = compiler_alloc_string(ctx->code, dim_decl->name);
718 if(!func->vars[i].name)
719 return E_OUTOFMEMORY;
722 assert(i == func->var_cnt);
729 static BOOL lookup_funcs_name(compile_ctx_t *ctx, const WCHAR *name)
733 for(iter = ctx->funcs; iter; iter = iter->next) {
734 if(!strcmpiW(iter->name, name))
741 static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, function_t **ret)
746 if(lookup_dim_decls(ctx, decl->name) || lookup_funcs_name(ctx, decl->name)) {
747 FIXME("%s: redefinition\n", debugstr_w(decl->name));
751 func = compiler_alloc(ctx->code, sizeof(*func));
753 return E_OUTOFMEMORY;
755 func->name = compiler_alloc_string(ctx->code, decl->name);
757 return E_OUTOFMEMORY;
761 func->code_ctx = ctx->code;
762 func->type = decl->type;
769 for(arg = decl->args; arg; arg = arg->next)
772 func->args = compiler_alloc(ctx->code, func->arg_cnt * sizeof(arg_desc_t));
774 return E_OUTOFMEMORY;
776 for(i = 0, arg = decl->args; arg; arg = arg->next, i++) {
777 func->args[i].name = compiler_alloc_string(ctx->code, arg->name);
778 if(!func->args[i].name)
779 return E_OUTOFMEMORY;
780 func->args[i].by_ref = arg->by_ref;
786 hres = compile_func(ctx, decl->body, func);
794 static BOOL lookup_class_name(compile_ctx_t *ctx, const WCHAR *name)
798 for(iter = ctx->classes; iter; iter = iter->next) {
799 if(!strcmpiW(iter->name, name))
806 static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
808 class_desc_t *class_desc;
810 if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name)
811 || lookup_class_name(ctx, class_decl->name)) {
812 FIXME("%s: redefinition\n", debugstr_w(class_decl->name));
816 class_desc = compiler_alloc(ctx->code, sizeof(*class_desc));
818 return E_OUTOFMEMORY;
820 class_desc->name = compiler_alloc_string(ctx->code, class_decl->name);
821 if(!class_desc->name)
822 return E_OUTOFMEMORY;
824 class_desc->next = ctx->classes;
825 ctx->classes = class_desc;
829 static BOOL lookup_script_identifier(script_ctx_t *script, const WCHAR *identifier)
835 for(var = script->global_vars; var; var = var->next) {
836 if(!strcmpiW(var->name, identifier))
840 for(func = script->global_funcs; func; func = func->next) {
841 if(!strcmpiW(func->name, identifier))
845 for(class = script->classes; class; class = class->next) {
846 if(!strcmpiW(class->name, identifier))
853 static HRESULT check_script_collisions(compile_ctx_t *ctx, script_ctx_t *script)
859 for(var = ctx->global_vars; var; var = var->next) {
860 if(lookup_script_identifier(script, var->name)) {
861 FIXME("%s: redefined\n", debugstr_w(var->name));
866 for(func = ctx->funcs; func; func = func->next) {
867 if(lookup_script_identifier(script, func->name)) {
868 FIXME("%s: redefined\n", debugstr_w(func->name));
873 for(class = ctx->classes; class; class = class->next) {
874 if(lookup_script_identifier(script, class->name)) {
875 FIXME("%s: redefined\n", debugstr_w(class->name));
883 void release_vbscode(vbscode_t *code)
887 list_remove(&code->entry);
889 for(i=0; i < code->bstr_cnt; i++)
890 SysFreeString(code->bstr_pool[i]);
892 vbsheap_free(&code->heap);
894 heap_free(code->bstr_pool);
895 heap_free(code->source);
896 heap_free(code->instrs);
900 static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source)
904 ret = heap_alloc(sizeof(*ret));
908 ret->source = heap_strdupW(source);
914 ret->instrs = heap_alloc(32*sizeof(instr_t));
916 release_vbscode(ret);
921 ctx->instr_size = 32;
922 vbsheap_init(&ret->heap);
924 ret->option_explicit = ctx->parser.option_explicit;
926 ret->bstr_pool = NULL;
927 ret->bstr_pool_size = 0;
929 ret->global_executed = FALSE;
931 ret->global_code.type = FUNC_GLOBAL;
932 ret->global_code.name = NULL;
933 ret->global_code.code_ctx = ret;
934 ret->global_code.vars = NULL;
935 ret->global_code.var_cnt = 0;
936 ret->global_code.arg_cnt = 0;
937 ret->global_code.args = NULL;
939 list_init(&ret->entry);
943 static void release_compiler(compile_ctx_t *ctx)
945 parser_release(&ctx->parser);
946 heap_free(ctx->labels);
948 release_vbscode(ctx->code);
951 HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
953 function_t *new_func;
954 function_decl_t *func_decl;
955 class_decl_t *class_decl;
960 hres = parse_script(&ctx.parser, src);
964 code = ctx.code = alloc_vbscode(&ctx, src);
966 return E_OUTOFMEMORY;
969 ctx.func_decls = NULL;
970 ctx.global_vars = NULL;
971 ctx.dim_decls = NULL;
974 ctx.labels_cnt = ctx.labels_size = 0;
976 hres = compile_func(&ctx, ctx.parser.stats, &ctx.code->global_code);
978 release_compiler(&ctx);
982 for(func_decl = ctx.func_decls; func_decl; func_decl = func_decl->next) {
983 hres = create_function(&ctx, func_decl, &new_func);
985 release_compiler(&ctx);
989 new_func->next = ctx.funcs;
990 ctx.funcs = new_func;
993 for(class_decl = ctx.parser.class_decls; class_decl; class_decl = class_decl->next) {
994 hres = compile_class(&ctx, class_decl);
996 release_compiler(&ctx);
1001 hres = check_script_collisions(&ctx, script);
1003 release_compiler(&ctx);
1007 if(ctx.global_vars) {
1010 for(var = ctx.global_vars; var->next; var = var->next);
1012 var->next = script->global_vars;
1013 script->global_vars = ctx.global_vars;
1017 for(new_func = ctx.funcs; new_func->next; new_func = new_func->next);
1019 new_func->next = script->global_funcs;
1020 script->global_funcs = ctx.funcs;
1024 class_desc_t *class = ctx.classes;
1027 class->ctx = script;
1030 class = class->next;
1033 class->next = script->classes;
1034 script->classes = ctx.classes;
1037 if(TRACE_ON(vbscript_disas))
1041 release_compiler(&ctx);
1043 list_add_tail(&script->code_list, &code->entry);