ReactOS 0.4.15-dev-7788-g1ad9096
engine.h
Go to the documentation of this file.
1/*
2 * Copyright 2008,2011 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19#pragma once
20
21#define OP_LIST \
22 X(add, 1, 0,0) \
23 X(and, 1, 0,0) \
24 X(array, 1, 0,0) \
25 X(assign, 1, 0,0) \
26 X(assign_call,1, ARG_UINT, 0) \
27 X(bool, 1, ARG_INT, 0) \
28 X(bneg, 1, 0,0) \
29 X(call, 1, ARG_UINT, ARG_UINT) \
30 X(call_member,1, ARG_UINT, ARG_UINT) \
31 X(carray, 1, ARG_UINT, 0) \
32 X(carray_set, 1, ARG_UINT, 0) \
33 X(case, 0, ARG_ADDR, 0) \
34 X(cnd_nz, 0, ARG_ADDR, 0) \
35 X(cnd_z, 0, ARG_ADDR, 0) \
36 X(delete, 1, 0,0) \
37 X(delete_ident,1,ARG_BSTR, 0) \
38 X(div, 1, 0,0) \
39 X(double, 1, ARG_DBL, 0) \
40 X(end_finally,0, 0,0) \
41 X(enter_catch,1, ARG_BSTR, 0) \
42 X(eq, 1, 0,0) \
43 X(eq2, 1, 0,0) \
44 X(forin, 0, ARG_ADDR, 0) \
45 X(func, 1, ARG_UINT, 0) \
46 X(gt, 1, 0,0) \
47 X(gteq, 1, 0,0) \
48 X(ident, 1, ARG_BSTR, 0) \
49 X(identid, 1, ARG_BSTR, ARG_INT) \
50 X(in, 1, 0,0) \
51 X(instanceof, 1, 0,0) \
52 X(int, 1, ARG_INT, 0) \
53 X(jmp, 0, ARG_ADDR, 0) \
54 X(jmp_z, 0, ARG_ADDR, 0) \
55 X(local, 1, ARG_INT, 0) \
56 X(local_ref, 1, ARG_INT, ARG_UINT) \
57 X(lshift, 1, 0,0) \
58 X(lt, 1, 0,0) \
59 X(lteq, 1, 0,0) \
60 X(member, 1, ARG_BSTR, 0) \
61 X(memberid, 1, ARG_UINT, 0) \
62 X(minus, 1, 0,0) \
63 X(mod, 1, 0,0) \
64 X(mul, 1, 0,0) \
65 X(neg, 1, 0,0) \
66 X(neq, 1, 0,0) \
67 X(neq2, 1, 0,0) \
68 X(new, 1, ARG_UINT, 0) \
69 X(new_obj, 1, 0,0) \
70 X(null, 1, 0,0) \
71 X(obj_prop, 1, ARG_STR, ARG_UINT) \
72 X(or, 1, 0,0) \
73 X(pop, 1, ARG_UINT, 0) \
74 X(pop_except, 0, ARG_ADDR, 0) \
75 X(pop_scope, 1, 0,0) \
76 X(postinc, 1, ARG_INT, 0) \
77 X(preinc, 1, ARG_INT, 0) \
78 X(push_acc, 1, 0,0) \
79 X(push_except,1, ARG_ADDR, ARG_UINT) \
80 X(push_scope, 1, 0,0) \
81 X(regexp, 1, ARG_STR, ARG_UINT) \
82 X(rshift, 1, 0,0) \
83 X(rshift2, 1, 0,0) \
84 X(str, 1, ARG_STR, 0) \
85 X(this, 1, 0,0) \
86 X(throw, 0, 0,0) \
87 X(throw_ref, 0, ARG_UINT, 0) \
88 X(throw_type, 0, ARG_UINT, ARG_STR) \
89 X(tonum, 1, 0,0) \
90 X(typeof, 1, 0,0) \
91 X(typeofid, 1, 0,0) \
92 X(typeofident,1, 0,0) \
93 X(refval, 1, 0,0) \
94 X(ret, 0, ARG_UINT, 0) \
95 X(setret, 1, 0,0) \
96 X(sub, 1, 0,0) \
97 X(undefined, 1, 0,0) \
98 X(void, 1, 0,0) \
99 X(xor, 1, 0,0)
100
101typedef enum {
102#define X(x,a,b,c) OP_##x,
104#undef X
105 OP_LAST
107
108typedef union {
112 unsigned uint;
114
115typedef enum {
125
126typedef struct {
128 union {
130 double dbl;
131 } u;
132} instr_t;
133
134typedef enum {
139
140typedef struct {
142 int ref;
144
145typedef struct _function_code_t {
149 unsigned instr_off;
150
151 const WCHAR *source;
152 unsigned source_len;
153
154 unsigned func_cnt;
156
157 unsigned var_cnt;
158 struct {
159 BSTR name;
160 int func_id; /* -1 if not a function */
162
163 unsigned param_cnt;
165
166 unsigned locals_cnt;
169
171
172typedef struct _bytecode_t {
174
177
179
181
184 unsigned bstr_cnt;
185
188 unsigned str_cnt;
189
192
195
197{
198 code->ref++;
199 return code;
200}
201
202typedef struct _scope_chain_t {
209
211
213{
214 scope->ref++;
215 return scope;
216}
217
219struct _parser_ctx_t;
220
221typedef struct _call_frame_t {
222 unsigned ip;
224 unsigned stack_base;
227
229
235
236 unsigned argc;
237 unsigned pop_locals;
241
244
247
248#define EXEC_GLOBAL 0x0001
249#define EXEC_CONSTRUCTOR 0x0002
250#define EXEC_RETURN_TO_INTERP 0x0004
251#define EXEC_EVAL 0x0008
252
255
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
OLECHAR * BSTR
Definition: compat.h:2293
local_ref_t * lookup_local(const function_code_t *, const WCHAR *) DECLSPEC_HIDDEN
Definition: engine.c:629
struct _scope_chain_t scope_chain_t
#define OP_LIST
Definition: engine.h:21
static scope_chain_t * scope_addref(scope_chain_t *scope)
Definition: engine.h:212
property_definition_type_t
Definition: engine.h:134
@ PROPERTY_DEFINITION_GETTER
Definition: engine.h:136
@ PROPERTY_DEFINITION_VALUE
Definition: engine.h:135
@ PROPERTY_DEFINITION_SETTER
Definition: engine.h:137
HRESULT setup_arguments_object(script_ctx_t *, call_frame_t *) DECLSPEC_HIDDEN
Definition: function.c:192
struct _call_frame_t call_frame_t
void scope_release(scope_chain_t *) DECLSPEC_HIDDEN
Definition: engine.c:437
struct _bytecode_t bytecode_t
instr_arg_type_t
Definition: engine.h:115
@ ARG_DBL
Definition: engine.h:119
@ ARG_INT
Definition: engine.h:121
@ ARG_ADDR
Definition: engine.h:117
@ ARG_BSTR
Definition: engine.h:118
@ ARG_NONE
Definition: engine.h:116
@ ARG_FUNC
Definition: engine.h:120
@ ARG_STR
Definition: engine.h:122
@ ARG_UINT
Definition: engine.h:123
HRESULT compile_script(script_ctx_t *, const WCHAR *, const WCHAR *, const WCHAR *, BOOL, BOOL, bytecode_t **) DECLSPEC_HIDDEN
Definition: compile.c:2461
struct _function_code_t function_code_t
void detach_arguments_object(jsdisp_t *) DECLSPEC_HIDDEN
Definition: function.c:229
void release_bytecode(bytecode_t *) DECLSPEC_HIDDEN
Definition: compile.c:2226
jsop_t
Definition: engine.h:101
@ OP_LAST
Definition: engine.h:105
HRESULT exec_source(script_ctx_t *, DWORD, bytecode_t *, function_code_t *, scope_chain_t *, IDispatch *, jsdisp_t *, jsdisp_t *, unsigned, jsval_t *, jsval_t *) DECLSPEC_HIDDEN
Definition: engine.c:2958
HRESULT create_source_function(script_ctx_t *, bytecode_t *, function_code_t *, scope_chain_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: function.c:767
static bytecode_t * bytecode_addref(bytecode_t *code)
Definition: engine.h:196
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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 * u
Definition: glfuncs.h:240
long LONG
Definition: pedump.c:60
unsigned str_pool_size
Definition: engine.h:187
instr_t * instrs
Definition: engine.h:175
LONG ref
Definition: engine.h:173
WCHAR * source
Definition: engine.h:180
heap_pool_t heap
Definition: engine.h:176
BSTR * bstr_pool
Definition: engine.h:182
unsigned bstr_pool_size
Definition: engine.h:183
struct _bytecode_t * next
Definition: engine.h:190
unsigned str_cnt
Definition: engine.h:188
jsstr_t ** str_pool
Definition: engine.h:186
unsigned bstr_cnt
Definition: engine.h:184
function_code_t global_code
Definition: engine.h:178
IDispatch * this_obj
Definition: engine.h:230
except_frame_t * except_frame
Definition: engine.h:223
struct _call_frame_t * prev_frame
Definition: engine.h:245
unsigned variables_off
Definition: engine.h:239
unsigned ip
Definition: engine.h:222
unsigned argc
Definition: engine.h:236
unsigned pop_locals
Definition: engine.h:237
jsdisp_t * arguments_obj
Definition: engine.h:233
scope_chain_t * base_scope
Definition: engine.h:226
jsdisp_t * variable_obj
Definition: engine.h:232
function_code_t * function
Definition: engine.h:243
bytecode_t * bytecode
Definition: engine.h:242
unsigned arguments_off
Definition: engine.h:238
DWORD flags
Definition: engine.h:234
scope_chain_t * scope
Definition: engine.h:225
jsval_t ret
Definition: engine.h:228
unsigned pop_variables
Definition: engine.h:240
jsdisp_t * function_instance
Definition: engine.h:231
unsigned stack_base
Definition: engine.h:224
unsigned var_cnt
Definition: engine.h:157
struct _function_code_t * funcs
Definition: engine.h:155
BSTR event_target
Definition: engine.h:148
unsigned func_cnt
Definition: engine.h:154
local_ref_t * locals
Definition: engine.h:167
BSTR * params
Definition: engine.h:164
unsigned locals_cnt
Definition: engine.h:166
struct _function_code_t::@442 * variables
unsigned source_len
Definition: engine.h:152
unsigned param_cnt
Definition: engine.h:163
const WCHAR * source
Definition: engine.h:151
unsigned instr_off
Definition: engine.h:149
Definition: jsstr.h:39
Definition: jsval.h:54
IDispatch * obj
Definition: engine.h:205
struct _call_frame_t * frame
Definition: engine.h:206
struct _scope_chain_t * next
Definition: engine.h:207
jsdisp_t * jsobj
Definition: engine.h:204
Definition: inflate.c:139
jsop_t op
Definition: engine.h:127
double dbl
Definition: engine.h:130
int ref
Definition: engine.h:142
BSTR name
Definition: engine.h:141
unsigned uint
Definition: engine.h:112
LONG lng
Definition: engine.h:110
jsstr_t * str
Definition: engine.h:111
BSTR bstr
Definition: engine.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180