23#include "parser.tab.h"
76#define X(n,a,b,c) {#n,b,c},
89 TRACE_(vbscript_disas)(
"\t%d",
arg->uint);
93 TRACE_(vbscript_disas)(
"\t%u",
arg->uint);
97 TRACE_(vbscript_disas)(
"\t%lf", *
arg->dbl);
109 for(instr =
ctx->code->instrs+1; instr < ctx->
code->instrs+
ctx->instr_cnt; instr++) {
114 TRACE_(vbscript_disas)(
"\n");
147 assert(id < ctx->instr_cnt);
148 return ctx->code->instrs +
id;
155 if(
ctx->instr_size ==
ctx->instr_cnt) {
162 ctx->code->instrs = new_instr;
163 ctx->instr_size *= 2;
166 ctx->code->instrs[
ctx->instr_cnt].op =
op;
167 ctx->code->instrs[
ctx->instr_cnt].loc =
ctx->loc;
168 return ctx->instr_cnt++;
262 if(!
ctx->code->bstr_pool_size) {
264 if(!
ctx->code->bstr_pool)
266 ctx->code->bstr_pool_size = 8;
267 }
else if(
ctx->code->bstr_pool_size ==
ctx->code->bstr_cnt) {
270 new_pool =
realloc(
ctx->code->bstr_pool,
ctx->code->bstr_pool_size*2*
sizeof(
BSTR));
274 ctx->code->bstr_pool = new_pool;
275 ctx->code->bstr_pool_size *= 2;
279 if(!
ctx->code->bstr_pool[
ctx->code->bstr_cnt])
282 return ctx->code->bstr_pool[
ctx->code->bstr_cnt++];
338#define LABEL_FLAG 0x80000000
342 if(!
ctx->labels_size) {
346 ctx->labels_size = 8;
347 }
else if(
ctx->labels_size ==
ctx->labels_cnt) {
348 unsigned *new_labels;
354 ctx->labels = new_labels;
355 ctx->labels_size *= 2;
372 for(iter =
ctx->stat_ctx; iter; iter = iter->
next)
398 if(
error == SCRIPT_E_REPORTED)
412 for(decl =
ctx->const_decls; decl; decl = decl->
next) {
420 for(decl =
ctx->global_consts; decl; decl = decl->
next) {
432 for(
i = 0;
i <
ctx->func->arg_cnt;
i++) {
444 for(dim_decl =
ctx->dim_decls; dim_decl; dim_decl = dim_decl->
next) {
540 for(stat_ctx =
ctx->stat_ctx; stat_ctx; stat_ctx = stat_ctx->
next) {
547 WARN(
"dot expression outside with statement\n");
664 unsigned cnd_jmp, endif_label = 0;
683 if(
stat->else_stat ||
stat->elseifs) {
693 for(elseif_decl =
stat->elseifs; elseif_decl; elseif_decl = elseif_decl->
next) {
696 ctx->loc = elseif_decl->
loc;
720 if(
stat->else_stat) {
738 start_addr =
ctx->instr_cnt;
756 loop_ctx = &stat_ctx;
782 start_addr =
ctx->instr_cnt;
841 loop_start =
ctx->instr_cnt;
867 unsigned step_instr, instr;
895 if(
stat->step_expr) {
970 unsigned end_label, case_cnt = 0, *case_labels =
NULL,
i;
989 for(case_iter =
stat->case_clausules; case_iter; case_iter = case_iter->
next)
993 case_labels =
malloc(case_cnt*
sizeof(*case_labels));
998 for(case_iter =
stat->case_clausules,
i=0; case_iter; case_iter = case_iter->
next,
i++) {
1000 if(!case_labels[
i]) {
1005 if(!case_iter->
expr)
1008 for(expr_iter = case_iter->
expr; expr_iter; expr_iter = expr_iter->
next) {
1041 for(case_iter =
stat->case_clausules,
i=0; case_iter; case_iter = case_iter->
next,
i++) {
1047 if(!case_iter->
next)
1067 unsigned args_cnt = 0;
1071 switch(
left->type) {
1090 op = is_set ? OP_set_member : OP_assign_member;
1092 op = is_set ? OP_set_ident : OP_assign_ident;
1145 ctx->func->var_cnt++;
1158 dim_decl = dim_decl->
next;
1161 if(
ctx->dim_decls_tail)
1162 ctx->dim_decls_tail->next =
stat->dim_decls;
1164 ctx->dim_decls =
stat->dim_decls;
1165 ctx->dim_decls_tail = dim_decl;
1223 next_decl = decl->
next;
1224 decl->
next =
ctx->const_decls;
1225 ctx->const_decls = decl;
1233 if(
ctx->func != &
ctx->code->main_code) {
1234 FIXME(
"Function is not in the global code\n");
1238 stat->func_decl->next =
ctx->func_decls;
1239 ctx->func_decls =
stat->func_decl;
1246 unsigned pop_cnt = 0;
1248 for(iter =
ctx->stat_ctx; iter; iter = iter->
next) {
1254 FIXME(
"Exit Do outside Do Loop\n");
1272 unsigned pop_cnt = 0;
1274 for(iter =
ctx->stat_ctx; iter; iter = iter->
next) {
1280 FIXME(
"Exit For outside For loop\n");
1312 if(!
ctx->sub_end_label) {
1313 FIXME(
"Exit Sub outside Sub?\n");
1322 if(!
ctx->func_end_label) {
1323 FIXME(
"Exit Function outside Function?\n");
1332 if(!
ctx->prop_end_label) {
1333 FIXME(
"Exit Property outside Property?\n");
1365 stat_ctx->
next =
ctx->stat_ctx;
1366 ctx->stat_ctx = stat_ctx;
1372 switch(
stat->type) {
1443 FIXME(
"Unimplemented statement type %d\n",
stat->type);
1454 ctx->stat_ctx = stat_ctx->
next;
1464 for(instr =
ctx->code->instrs+off; instr < ctx->
code->instrs+
ctx->instr_cnt; instr++) {
1472 ctx->labels_cnt = 0;
1477 unsigned dim_cnt = 0,
i;
1480 for(iter = dim_decl->
dims; iter; iter = iter->
next)
1487 array_desc->
dim_cnt = dim_cnt;
1489 for(iter = dim_decl->
dims,
i=0; iter; iter = iter->
next,
i++) {
1501 func->code_off =
ctx->instr_cnt;
1503 ctx->sub_end_label = 0;
1504 ctx->func_end_label = 0;
1505 ctx->prop_end_label = 0;
1507 switch(
func->type) {
1510 if(!
ctx->func_end_label)
1515 if(!
ctx->sub_end_label)
1522 if(!
ctx->prop_end_label)
1537 if(
ctx->sub_end_label)
1539 if(
ctx->func_end_label)
1541 if(
ctx->prop_end_label)
1557 for(dim_decl =
ctx->dim_decls,
i=0; dim_decl; dim_decl = dim_decl->
next,
i++) {
1559 if(!
func->vars[
i].name)
1566 if(
func->array_cnt) {
1567 unsigned array_id = 0;
1571 if(!
func->array_descs)
1574 for(dim_decl =
ctx->dim_decls; dim_decl; dim_decl = dim_decl->
next) {
1592 for(iter =
ctx->code->funcs; iter; iter = iter->
next) {
1620 func->array_cnt = 0;
1639 if(!
func->args[
i].name)
1641 func->args[
i].by_ref =
arg->by_ref;
1659 for(iter =
ctx->code->classes; iter; iter = iter->
next) {
1677 for(funcprop_decl = func_decl; funcprop_decl; funcprop_decl = funcprop_decl->
next_prop_func) {
1678 switch(funcprop_decl->
type) {
1738 if(!class_desc->
name)
1743 for(func_decl = class_decl->
funcs; func_decl; func_decl = func_decl->
next) {
1745 for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->
next_prop_func) {
1748 FIXME(
"multiple default getters or methods\n");
1751 is_default = have_default =
TRUE;
1760 if(!class_desc->
funcs)
1764 for(func_decl = class_decl->
funcs,
i=1; func_decl; func_decl = func_decl->
next,
i++) {
1765 for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->
next_prop_func) {
1774 FIXME(
"class initializer is not sub\n");
1779 }
else if(!
wcsicmp(
L"class_terminate", func_decl->
name)) {
1781 FIXME(
"class terminator is not sub\n");
1793 for(prop_decl = class_decl->
props; prop_decl; prop_decl = prop_decl->
next)
1797 if(!class_desc->
props)
1800 for(prop_decl = class_decl->
props,
i=0; prop_decl; prop_decl = prop_decl->
next,
i++) {
1822 for(prop_decl = class_decl->
props,
i=0; prop_decl; prop_decl = prop_decl->
next) {
1831 class_desc->
next =
ctx->code->classes;
1832 ctx->code->classes = class_desc;
1839 ctx->code->named_item ?
ctx->code->named_item->script_obj :
NULL,
1847 if(!contexts[
c])
continue;
1855 if(!
wcsicmp(contexts[
c]->global_funcs[
i]->
name, identifier))
1859 for(
class = contexts[
c]->classes;
class;
class =
class->
next) {
1866 unsigned var_cnt =
code->main_code.var_cnt;
1870 if(!
code->pending_exec || (
code->named_item &&
code->named_item !=
ctx->code->named_item))
1873 for(
i = 0;
i < var_cnt;
i++) {
1883 for(
class =
code->classes;
class;
class =
class->next) {
1894 unsigned i, var_cnt =
ctx->code->main_code.var_cnt;
1898 for(
i = 0;
i < var_cnt;
i++) {
1905 for(
class =
ctx->code->classes;
class;
class =
class->next) {
1922 for(
i=0;
i <
code->bstr_cnt;
i++)
1925 if(
code->named_item)
1959 ret->start_line = start_line;
1968 ctx->instr_size = 32;
1972 ret->main_code.code_ctx =
ret;
2018 if(
ctx.parser.error_loc != -1)
2019 ctx.loc =
ctx.parser.error_loc;
2032 code->option_explicit =
ctx.parser.option_explicit;
2033 ctx.global_consts =
ctx.const_decls;
2034 code->option_explicit =
ctx.parser.option_explicit;
2037 for(func_decl =
ctx.func_decls; func_decl; func_decl = func_decl->
next) {
2045 new_func->
next =
ctx.code->funcs;
2046 ctx.code->funcs = new_func;
2049 for(class_decl =
ctx.parser.class_decls; class_decl; class_decl = class_decl->
next) {
2065 code->is_persistent = (
flags & SCRIPTTEXT_ISPERSISTENT) != 0;
2086 flags & ~SCRIPTTEXT_ISPERSISTENT, &
code);
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
static void list_init(struct list_entry *head)
#define WINE_DECLARE_DEBUG_CHANNEL(x)
void release_named_item(named_item_t *item)
named_item_t * lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsigned flags)
void parser_release(parser_ctx_t *)
HRESULT report_script_error(script_ctx_t *ctx, const vbscode_t *code, unsigned loc)
#define VBS_COMPILE_ERROR
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint GLuint GLsizei GLenum type
GLuint GLuint GLuint GLuint arg1
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void clear_ei(EXCEPINFO *ei)
static HRESULT push_instr_bstr(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg)
static void dump_code(compiler_ctx_t *ctx, unsigned off)
static HRESULT compile_expression(compiler_ctx_t *, expression_t *, BOOL)
static HRESULT compile_while_statement(compiler_ctx_t *ctx, while_statement_t *stat)
static void * compiler_alloc(bytecode_t *code, size_t size)
static HRESULT compile_member_expression(compiler_ctx_t *ctx, member_expression_t *expr)
static HRESULT compile_statement(compiler_ctx_t *, statement_ctx_t *, statement_t *)
static unsigned push_instr(compiler_ctx_t *ctx, jsop_t op)
static void resolve_labels(compiler_ctx_t *ctx, unsigned off)
static unsigned alloc_label(compiler_ctx_t *ctx)
static HRESULT compile_binary_expression(compiler_ctx_t *ctx, binary_expression_t *expr, jsop_t op)
static void dump_instr_arg(instr_arg_type_t type, instr_arg_t *arg)
static HRESULT compile_if_statement(compiler_ctx_t *ctx, if_statement_t *stat)
static HRESULT push_instr_double(compiler_ctx_t *ctx, jsop_t op, double arg)
static HRESULT compile_unary_expression(compiler_ctx_t *ctx, unary_expression_t *expr, jsop_t op)
static jsstr_t * compiler_alloc_string(compiler_ctx_t *ctx, const WCHAR *str)
static void label_set_addr(compiler_ctx_t *ctx, unsigned label)
static HRESULT push_instr_uint(compiler_ctx_t *ctx, jsop_t op, unsigned arg)
HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, UINT64 source_context, unsigned start_line, const WCHAR *args, const WCHAR *delimiter, BOOL from_eval, BOOL use_decode, named_item_t *named_item, bytecode_t **ret)
static HRESULT push_instr_bstr_uint(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg1, unsigned arg2)
static instr_t * instr_ptr(compiler_ctx_t *ctx, unsigned off)
static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *expr, BOOL emit_ret)
struct _statement_ctx_t statement_ctx_t
static HRESULT push_instr_int(compiler_ctx_t *ctx, jsop_t op, LONG arg)
static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, jsstr_t *str)
static HRESULT compile_with_statement(compiler_ctx_t *ctx, with_statement_t *stat)
void heap_pool_init(heap_pool_t *)
void * heap_pool_alloc(heap_pool_t *, DWORD) __WINE_ALLOC_SIZE(2)
void heap_pool_free(heap_pool_t *)
#define memcpy(s1, s2, n)
static const WCHAR label[]
D3D11_SHADER_VARIABLE_DESC desc
#define parse_script(p, s)
#define DEFAULT_UNREACHABLE
BSTR WINAPI SysAllocString(LPCOLESTR str)
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
static unsigned __int64 next
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
struct _case_clausule_t * next
struct _class_decl_t * next
array_desc_t * array_descs
vbdisp_prop_desc_t * props
vbdisp_funcprop_desc_t * funcs
unsigned class_terminate_id
unsigned class_initialize_id
struct _class_desc_t * next
struct _const_decl_t * next
expression_t * value_expr
struct _dim_decl_t * next
struct _dim_list_t * next
struct _elseif_decl_t * next
struct _expression_t * next
struct _function_decl_t * next_prop_func
struct _function_decl_t * next
struct _redim_decl_t * next
unsigned with_stack_offset
struct _statement_ctx_t * next
function_decl_t * func_decls
const_decl_t * const_decls
const_decl_t * global_consts
dim_decl_t * dim_decls_tail
statement_ctx_t * stat_ctx
void map_vbs_exception(EXCEPINFO *ei)
static HRESULT compile_select_statement(compile_ctx_t *ctx, select_statement_t *stat)
static HRESULT compile_call_statement(compile_ctx_t *ctx, call_statement_t *stat)
static BOOL emit_catch_jmp(compile_ctx_t *ctx, unsigned stack_off, unsigned code_off)
static HRESULT compile_redim_statement(compile_ctx_t *ctx, redim_statement_t *stat)
static void release_compiler(compile_ctx_t *ctx)
static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t *stat)
static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat, BOOL is_set)
static HRESULT compile_assignment(compile_ctx_t *ctx, expression_t *left, expression_t *value_expr, BOOL is_set)
static HRESULT compile_function_statement(compile_ctx_t *ctx, function_statement_t *stat)
static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
static vbscode_t * alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source, DWORD_PTR cookie, unsigned start_line)
instr_arg_type_t arg2_type
static HRESULT compile_dot_expression(compile_ctx_t *ctx)
static BOOL lookup_dim_decls(compile_ctx_t *ctx, const WCHAR *name)
static HRESULT push_instr_uint_bstr(compile_ctx_t *ctx, vbsop_t op, unsigned arg1, const WCHAR *arg2)
static HRESULT exit_label(compile_ctx_t *ctx, unsigned jmp_label)
static HRESULT compile_error(script_ctx_t *ctx, compile_ctx_t *compiler, HRESULT error)
static HRESULT compile_exitfor_statement(compile_ctx_t *ctx)
static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str)
instr_arg_type_t arg1_type
HRESULT compile_procedure(script_ctx_t *script, const WCHAR *src, const WCHAR *item_name, const WCHAR *delimiter, DWORD_PTR cookie, unsigned start_line, DWORD flags, class_desc_t **ret)
static HRESULT fill_array_desc(compile_ctx_t *ctx, dim_decl_t *dim_decl, array_desc_t *array_desc)
static HRESULT compile_const_statement(compile_ctx_t *ctx, const_statement_t *stat)
static BOOL lookup_script_identifier(compile_ctx_t *ctx, script_ctx_t *script, const WCHAR *identifier)
static HRESULT push_instr_date(compile_ctx_t *ctx, vbsop_t op, DATE arg)
static BOOL lookup_class_funcs(class_desc_t *class_desc, const WCHAR *name)
static unsigned stack_offset(compile_ctx_t *ctx)
void release_vbscode(vbscode_t *code)
static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *func)
static BOOL emit_catch(compile_ctx_t *ctx, unsigned off)
static HRESULT push_instr_addr(compile_ctx_t *ctx, vbsop_t op, unsigned arg)
static HRESULT compile_exitfunc_statement(compile_ctx_t *ctx)
static HRESULT compile_forto_statement(compile_ctx_t *ctx, forto_statement_t *stat)
static HRESULT compile_member_call_expression(compile_ctx_t *ctx, member_expression_t *expr, unsigned arg_cnt, BOOL ret_val)
static HRESULT compile_exitdo_statement(compile_ctx_t *ctx)
static BOOL lookup_args_name(compile_ctx_t *ctx, const WCHAR *name)
static expression_t * lookup_const_decls(compile_ctx_t *ctx, const WCHAR *name, BOOL lookup_global)
static BOOL lookup_class_name(compile_ctx_t *ctx, const WCHAR *name)
static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *ret)
static void * compiler_alloc_zero(vbscode_t *vbscode, size_t size)
static HRESULT compile_onerror_statement(compile_ctx_t *ctx, onerror_statement_t *stat)
static HRESULT compile_exitprop_statement(compile_ctx_t *ctx)
static HRESULT check_script_collisions(compile_ctx_t *ctx, script_ctx_t *script)
static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t *stat)
static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat)
static HRESULT create_class_funcprop(compile_ctx_t *ctx, function_decl_t *func_decl, vbdisp_funcprop_desc_t *desc)
static HRESULT compile_retval_statement(compile_ctx_t *ctx, retval_statement_t *stat)
static BOOL lookup_funcs_name(compile_ctx_t *ctx, const WCHAR *name)
static HRESULT compile_exitsub_statement(compile_ctx_t *ctx)
static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, function_t **ret)
BSTR get_vbscript_string(int)
static unsigned arg_cnt(const DISPPARAMS *dp)
#define DISP_E_PARAMNOTFOUND