ReactOS 0.4.15-dev-8348-gc1b9bb5
engine.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  instr_arg_t
 
struct  instr_t
 
struct  local_ref_t
 
struct  _function_code_t
 
struct  _bytecode_t
 
struct  _scope_chain_t
 
struct  _call_frame_t
 

Macros

#define OP_LIST
 
#define X(x, a, b, c)   OP_##x,
 
#define EXEC_GLOBAL   0x0001
 
#define EXEC_CONSTRUCTOR   0x0002
 
#define EXEC_RETURN_TO_INTERP   0x0004
 
#define EXEC_EVAL   0x0008
 

Typedefs

typedef struct _function_code_t function_code_t
 
typedef struct _bytecode_t bytecode_t
 
typedef struct _scope_chain_t scope_chain_t
 
typedef struct _except_frame_t except_frame_t
 
typedef struct _call_frame_t call_frame_t
 

Enumerations

enum  jsop_t { OP_LAST }
 
enum  instr_arg_type_t {
  ARG_NONE = 0 , ARG_ADDR , ARG_BSTR , ARG_DBL ,
  ARG_FUNC , ARG_INT , ARG_STR , ARG_UINT ,
  ARG_NONE = 0 , ARG_STR , ARG_BSTR , ARG_INT ,
  ARG_UINT , ARG_ADDR , ARG_DOUBLE
}
 
enum  property_definition_type_t { PROPERTY_DEFINITION_VALUE , PROPERTY_DEFINITION_GETTER , PROPERTY_DEFINITION_SETTER }
 

Functions

local_ref_tlookup_local (const function_code_t *, const WCHAR *) DECLSPEC_HIDDEN
 
HRESULT compile_script (script_ctx_t *, const WCHAR *, const WCHAR *, const WCHAR *, BOOL, BOOL, bytecode_t **) DECLSPEC_HIDDEN
 
void release_bytecode (bytecode_t *) DECLSPEC_HIDDEN
 
static bytecode_tbytecode_addref (bytecode_t *code)
 
void scope_release (scope_chain_t *) DECLSPEC_HIDDEN
 
static scope_chain_tscope_addref (scope_chain_t *scope)
 
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
 
HRESULT create_source_function (script_ctx_t *, bytecode_t *, function_code_t *, scope_chain_t *, jsdisp_t **) DECLSPEC_HIDDEN
 
HRESULT setup_arguments_object (script_ctx_t *, call_frame_t *) DECLSPEC_HIDDEN
 
void detach_arguments_object (jsdisp_t *) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ EXEC_CONSTRUCTOR

#define EXEC_CONSTRUCTOR   0x0002

Definition at line 249 of file engine.h.

◆ EXEC_EVAL

#define EXEC_EVAL   0x0008

Definition at line 251 of file engine.h.

◆ EXEC_GLOBAL

#define EXEC_GLOBAL   0x0001

Definition at line 248 of file engine.h.

◆ EXEC_RETURN_TO_INTERP

#define EXEC_RETURN_TO_INTERP   0x0004

Definition at line 250 of file engine.h.

◆ OP_LIST

#define OP_LIST

Definition at line 21 of file engine.h.

◆ X

#define X (   x,
  a,
  b,
  c 
)    OP_##x,

Definition at line 102 of file engine.h.

Typedef Documentation

◆ bytecode_t

◆ call_frame_t

◆ except_frame_t

Definition at line 218 of file engine.h.

◆ function_code_t

◆ scope_chain_t

Enumeration Type Documentation

◆ instr_arg_type_t

Enumerator
ARG_NONE 
ARG_ADDR 
ARG_BSTR 
ARG_DBL 
ARG_FUNC 
ARG_INT 
ARG_STR 
ARG_UINT 
ARG_NONE 
ARG_STR 
ARG_BSTR 
ARG_INT 
ARG_UINT 
ARG_ADDR 
ARG_DOUBLE 

Definition at line 115 of file engine.h.

115 {
116 ARG_NONE = 0,
117 ARG_ADDR,
118 ARG_BSTR,
119 ARG_DBL,
120 ARG_FUNC,
121 ARG_INT,
122 ARG_STR,
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

◆ jsop_t

Enumerator
OP_LAST 

Definition at line 101 of file engine.h.

101 {
102#define X(x,a,b,c) OP_##x,
104#undef X
105 OP_LAST
106} jsop_t;
#define OP_LIST
Definition: engine.h:21
jsop_t
Definition: engine.h:101
@ OP_LAST
Definition: engine.h:105

◆ property_definition_type_t

Enumerator
PROPERTY_DEFINITION_VALUE 
PROPERTY_DEFINITION_GETTER 
PROPERTY_DEFINITION_SETTER 

Definition at line 134 of file engine.h.

134 {
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

Function Documentation

◆ bytecode_addref()

static bytecode_t * bytecode_addref ( bytecode_t code)
inlinestatic

Definition at line 196 of file engine.h.

197{
198 code->ref++;
199 return code;
200}
Definition: inflate.c:139

Referenced by create_source_function(), and exec_source().

◆ compile_script()

HRESULT compile_script ( script_ctx_t ctx,
const WCHAR code,
const WCHAR args,
const WCHAR delimiter,
BOOL  from_eval,
BOOL  use_decode,
bytecode_t **  ret 
)

Definition at line 2461 of file compile.c.

2463{
2464 compiler_ctx_t compiler = {0};
2465 HRESULT hres;
2466
2467 hres = init_code(&compiler, code);
2468 if(FAILED(hres))
2469 return hres;
2470
2471 if(args) {
2472 hres = compile_arguments(&compiler, args);
2473 if(FAILED(hres))
2474 return hres;
2475 }
2476
2477 if(use_decode) {
2478 hres = decode_source(compiler.code->source);
2479 if(FAILED(hres)) {
2480 WARN("Decoding failed\n");
2481 return hres;
2482 }
2483 }
2484
2485 hres = script_parse(ctx, &compiler, compiler.code->source, delimiter, from_eval, &compiler.parser);
2486 if(FAILED(hres)) {
2487 release_bytecode(compiler.code);
2488 return hres;
2489 }
2490
2491 heap_pool_init(&compiler.heap);
2492 hres = compile_function(&compiler, compiler.parser->source, NULL, from_eval, &compiler.code->global_code);
2493 heap_pool_free(&compiler.heap);
2494 parser_release(compiler.parser);
2495 if(FAILED(hres)) {
2496 release_bytecode(compiler.code);
2497 return hres;
2498 }
2499
2500 *ret = compiler.code;
2501 return S_OK;
2502}
#define WARN(fmt,...)
Definition: precomp.h:61
#define NULL
Definition: types.h:112
void parser_release(parser_ctx_t *) DECLSPEC_HIDDEN
HRESULT script_parse(script_ctx_t *, struct _compiler_ctx_t *, const WCHAR *, const WCHAR *, BOOL, parser_ctx_t **) DECLSPEC_HIDDEN
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
void release_bytecode(bytecode_t *code)
Definition: compile.c:2226
static HRESULT compile_arguments(compiler_ctx_t *ctx, const WCHAR *args)
Definition: compile.c:2445
static HRESULT init_code(compiler_ctx_t *compiler, const WCHAR *source)
Definition: compile.c:2246
static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source, function_expression_t *func_expr, BOOL from_eval, function_code_t *func)
Definition: compile.c:2272
HRESULT decode_source(WCHAR *code)
Definition: decode.c:111
void heap_pool_free(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:169
void heap_pool_init(heap_pool_t *) DECLSPEC_HIDDEN
Definition: jsutils.c:71
HRESULT hres
Definition: protocol.c:465
const char * delimiter
Definition: string.c:1566
WCHAR * source
Definition: engine.h:180
function_code_t global_code
Definition: engine.h:178
bytecode_t * code
Definition: compile.c:53
heap_pool_t heap
Definition: compile.c:73
parser_ctx_t * parser
Definition: compile.c:52
Definition: match.c:390
int ret

Referenced by compile_procedure(), construct_function(), JScriptParse_ParseScriptText(), JScriptParseProcedure_ParseProcedureText(), JSGlobal_eval(), and VBScriptParse_ParseScriptText().

◆ create_source_function()

HRESULT create_source_function ( script_ctx_t ctx,
bytecode_t code,
function_code_t func_code,
scope_chain_t scope_chain,
jsdisp_t **  ret 
)

Definition at line 767 of file function.c.

769{
770 InterpretedFunction *function;
771 jsdisp_t *prototype;
773
774 hres = create_object(ctx, NULL, &prototype);
775 if(FAILED(hres))
776 return hres;
777
779 FALSE, NULL, (void**)&function);
780 if(SUCCEEDED(hres)) {
782 jsval_obj(prototype));
783 if(SUCCEEDED(hres))
784 hres = set_constructor_prop(ctx, &function->function.dispex, prototype);
785 if(FAILED(hres))
786 jsdisp_release(&function->function.dispex);
787 }
788 jsdisp_release(prototype);
789 if(FAILED(hres))
790 return hres;
791
792 if(scope_chain) {
793 scope_addref(scope_chain);
794 function->scope_chain = scope_chain;
795 }
796
798 function->code = code;
799 function->func_code = func_code;
800 function->function.length = function->func_code->param_cnt;
801
802 *ret = &function->function.dispex;
803 return S_OK;
804}
#define FALSE
Definition: types.h:117
static const WCHAR prototypeW[]
Definition: function.c:94
static HRESULT set_constructor_prop(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot)
Definition: function.c:678
static const function_vtbl_t InterpretedFunctionVtbl
Definition: function.c:761
static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret)
Definition: function.c:566
static scope_chain_t * scope_addref(scope_chain_t *scope)
Definition: engine.h:212
static bytecode_t * bytecode_addref(bytecode_t *code)
Definition: engine.h:196
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
#define PROPF_CONSTR
Definition: jscript.h:98
HRESULT create_object(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:731
#define PROPF_WRITABLE
Definition: jscript.h:101
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
jsdisp_t dispex
Definition: function.c:31
FunctionInstance function
Definition: function.c:44
bytecode_t * code
Definition: function.c:46
function_code_t * func_code
Definition: function.c:47
scope_chain_t * scope_chain
Definition: function.c:45
unsigned param_cnt
Definition: engine.h:163

Referenced by construct_function(), exec_source(), interp_func(), JScriptParseProcedure_ParseProcedureText(), and setup_scope().

◆ detach_arguments_object()

void detach_arguments_object ( jsdisp_t args_disp)

Definition at line 229 of file function.c.

230{
231 ArgumentsInstance *arguments = arguments_from_jsdisp(args_disp);
232 call_frame_t *frame = arguments->frame;
233 const BOOL on_stack = frame->base_scope->frame == frame;
235
236 /* Reset arguments value to cut the reference cycle. Note that since all activation contexts have
237 * their own arguments property, it's impossible to use prototype's one during name lookup */
239 arguments->frame = NULL;
240
241 /* Don't bother coppying arguments if call frame holds the last reference. */
242 if(arguments->jsdisp.ref > 1) {
243 arguments->buf = heap_alloc(arguments->argc * sizeof(*arguments->buf));
244 if(arguments->buf) {
245 int i;
246
247 for(i = 0; i < arguments->argc ; i++) {
248 if(on_stack || i >= frame->function->param_cnt)
249 hres = jsval_copy(arguments->jsdisp.ctx->stack[frame->arguments_off + i], arguments->buf+i);
250 else
251 hres = jsdisp_propget_name(frame->base_scope->jsobj, frame->function->params[i], arguments->buf+i);
252 if(FAILED(hres))
253 arguments->buf[i] = jsval_undefined();
254 }
255 }else {
256 ERR("out of memory\n");
257 arguments->argc = 0;
258 }
259 }
260
262}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define ERR(fmt,...)
Definition: precomp.h:57
static ArgumentsInstance * arguments_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:89
static const WCHAR argumentsW[]
Definition: function.c:101
unsigned int BOOL
Definition: ntddk_ex.h:94
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
Definition: glfuncs.h:248
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1408
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
call_frame_t * frame
Definition: function.c:68
jsdisp_t jsdisp
Definition: function.c:65
jsval_t * buf
Definition: function.c:67
unsigned argc
Definition: function.c:69
jsdisp_t * arguments_obj
Definition: engine.h:233
scope_chain_t * base_scope
Definition: engine.h:226
function_code_t * function
Definition: engine.h:243
unsigned arguments_off
Definition: engine.h:238
BSTR * params
Definition: engine.h:164
struct _call_frame_t * frame
Definition: engine.h:206
jsdisp_t * jsobj
Definition: engine.h:204
jsval_t * stack
Definition: jscript.h:431
LONG ref
Definition: jscript.h:233
script_ctx_t * ctx
Definition: jscript.h:238

Referenced by pop_call_frame().

◆ exec_source()

HRESULT exec_source ( script_ctx_t ctx,
DWORD  flags,
bytecode_t bytecode,
function_code_t function,
scope_chain_t scope,
IDispatch this_obj,
jsdisp_t function_instance,
jsdisp_t variable_obj,
unsigned  argc,
jsval_t argv,
jsval_t r 
)

Definition at line 2958 of file engine.c.

2960{
2961 call_frame_t *frame;
2962 unsigned i;
2963 HRESULT hres;
2964
2965 for(i = 0; i < function->func_cnt; i++) {
2966 jsdisp_t *func_obj;
2967
2968 if(!function->funcs[i].event_target)
2969 continue;
2970
2971 hres = create_source_function(ctx, bytecode, function->funcs+i, scope, &func_obj);
2972 if(FAILED(hres))
2973 return hres;
2974
2975 hres = bind_event_target(ctx, function->funcs+i, func_obj);
2976 jsdisp_release(func_obj);
2977 if(FAILED(hres))
2978 return hres;
2979 }
2980
2981 if(flags & (EXEC_GLOBAL | EXEC_EVAL)) {
2982 for(i=0; i < function->var_cnt; i++) {
2983 TRACE("[%d] %s %d\n", i, debugstr_w(function->variables[i].name), function->variables[i].func_id);
2984 if(function->variables[i].func_id != -1) {
2985 jsdisp_t *func_obj;
2986
2987 hres = create_source_function(ctx, bytecode, function->funcs+function->variables[i].func_id, scope, &func_obj);
2988 if(FAILED(hres))
2989 return hres;
2990
2991 hres = jsdisp_propput_name(variable_obj, function->variables[i].name, jsval_obj(func_obj));
2992 jsdisp_release(func_obj);
2993 }else if(!(flags & EXEC_GLOBAL) || !lookup_global_members(ctx, function->variables[i].name, NULL)) {
2994 DISPID id = 0;
2995
2996 hres = jsdisp_get_id(variable_obj, function->variables[i].name, fdexNameEnsure, &id);
2997 if(FAILED(hres))
2998 return hres;
2999 }
3000 }
3001 }
3002
3003 /* ECMA-262 3rd Edition 11.2.3.7 */
3004 if(this_obj) {
3005 jsdisp_t *jsthis;
3006
3007 jsthis = iface_to_jsdisp(this_obj);
3008 if(jsthis) {
3009 if(jsthis->builtin_info->class == JSCLASS_GLOBAL || jsthis->builtin_info->class == JSCLASS_NONE)
3010 this_obj = NULL;
3011 jsdisp_release(jsthis);
3012 }
3013 }
3014
3015 if(ctx->call_ctx && (flags & EXEC_EVAL)) {
3016 hres = detach_variable_object(ctx, ctx->call_ctx, FALSE);
3017 if(FAILED(hres))
3018 return hres;
3019 }
3020
3021 frame = heap_alloc_zero(sizeof(*frame));
3022 if(!frame)
3023 return E_OUTOFMEMORY;
3024
3025 frame->function = function;
3026 frame->ret = jsval_undefined();
3027 frame->argc = argc;
3028 frame->bytecode = bytecode_addref(bytecode);
3029
3030 if(!(flags & (EXEC_GLOBAL|EXEC_EVAL))) {
3031 hres = setup_scope(ctx, frame, scope, variable_obj, argc, argv);
3032 if(FAILED(hres)) {
3033 release_bytecode(frame->bytecode);
3034 heap_free(frame);
3035 return hres;
3036 }
3037 }else if(scope) {
3038 frame->base_scope = frame->scope = scope_addref(scope);
3039 }
3040
3041 frame->ip = function->instr_off;
3042 frame->stack_base = ctx->stack_top;
3043 if(this_obj)
3044 frame->this_obj = this_obj;
3045 else if(ctx->host_global)
3046 frame->this_obj = ctx->host_global;
3047 else
3048 frame->this_obj = to_disp(ctx->global);
3049 IDispatch_AddRef(frame->this_obj);
3050
3051 if(function_instance)
3052 frame->function_instance = jsdisp_addref(function_instance);
3053
3054 frame->flags = flags;
3055 frame->variable_obj = jsdisp_addref(variable_obj);
3056
3057 frame->prev_frame = ctx->call_ctx;
3058 ctx->call_ctx = frame;
3059
3061 /*
3062 * We're called directly from interpreter, so we may just setup call frame and return.
3063 * Already running interpreter will take care of execution.
3064 */
3065 if(r)
3066 *r = jsval_undefined();
3067 return S_OK;
3068 }
3069
3070 return enter_bytecode(ctx, r);
3071}
static int argc
Definition: ServiceArgs.c:12
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT detach_variable_object(script_ctx_t *ctx, call_frame_t *frame, BOOL from_release)
Definition: engine.c:573
static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdisp_t *func_obj)
Definition: engine.c:2845
static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:604
static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, scope_chain_t *scope_chain, jsdisp_t *variable_object, unsigned argc, jsval_t *argv)
Definition: engine.c:2881
static HRESULT enter_bytecode(script_ctx_t *ctx, jsval_t *r)
Definition: engine.c:2806
#define EXEC_GLOBAL
Definition: engine.h:248
#define EXEC_RETURN_TO_INTERP
Definition: engine.h:250
#define EXEC_EVAL
Definition: engine.h:251
HRESULT create_source_function(script_ctx_t *, bytecode_t *, function_code_t *, scope_chain_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: function.c:767
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLbitfield flags
Definition: glext.h:7161
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1067
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1060
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
@ JSCLASS_NONE
Definition: jscript.h:120
@ JSCLASS_GLOBAL
Definition: jscript.h:127
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:262
#define debugstr_w
Definition: kernel32.h:32
static VARIANTARG static DISPID
Definition: ordinal.c:52
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
IDispatch * this_obj
Definition: engine.h:230
struct _call_frame_t * prev_frame
Definition: engine.h:245
unsigned ip
Definition: engine.h:222
unsigned argc
Definition: engine.h:236
jsdisp_t * variable_obj
Definition: engine.h:232
bytecode_t * bytecode
Definition: engine.h:242
DWORD flags
Definition: engine.h:234
scope_chain_t * scope
Definition: engine.h:225
jsval_t ret
Definition: engine.h:228
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
struct _function_code_t::@438 * variables
unsigned func_cnt
Definition: engine.h:154
unsigned instr_off
Definition: engine.h:149
jsclass_t class
Definition: jscript.h:219
const builtin_info_t * builtin_info
Definition: jscript.h:242

Referenced by exec_global_code(), InterpretedFunction_call(), JScriptParse_ParseScriptText(), and JSGlobal_eval().

◆ lookup_local()

local_ref_t * lookup_local ( const function_code_t function,
const WCHAR identifier 
)

Definition at line 629 of file engine.c.

630{
631 return bsearch(identifier, function->locals, function->locals_cnt, sizeof(*function->locals), local_ref_cmp);
632}
static int __cdecl local_ref_cmp(const void *key, const void *ref)
Definition: engine.c:624
local_ref_t * locals
Definition: engine.h:167
unsigned locals_cnt
Definition: engine.h:166
#define bsearch

Referenced by bind_local(), compile_function(), and identifier_eval().

◆ release_bytecode()

void release_bytecode ( bytecode_t code)

Definition at line 2226 of file compile.c.

2227{
2228 unsigned i;
2229
2230 if(--code->ref)
2231 return;
2232
2233 for(i=0; i < code->bstr_cnt; i++)
2234 SysFreeString(code->bstr_pool[i]);
2235 for(i=0; i < code->str_cnt; i++)
2236 jsstr_release(code->str_pool[i]);
2237
2238 heap_free(code->source);
2239 heap_pool_free(&code->heap);
2240 heap_free(code->bstr_pool);
2241 heap_free(code->str_pool);
2242 heap_free(code->instrs);
2243 heap_free(code);
2244}
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271

Referenced by clear_script_queue(), compile_script(), construct_function(), exec_source(), init_code(), InterpretedFunction_destructor(), JScriptParse_ParseScriptText(), JScriptParseProcedure_ParseProcedureText(), JSGlobal_eval(), and pop_call_frame().

◆ scope_addref()

static scope_chain_t * scope_addref ( scope_chain_t scope)
inlinestatic

Definition at line 212 of file engine.h.

213{
214 scope->ref++;
215 return scope;
216}

Referenced by create_source_function(), exec_source(), and scope_push().

◆ scope_release()

void scope_release ( scope_chain_t scope)

Definition at line 437 of file engine.c.

438{
439 if(--scope->ref)
440 return;
441
442 if(scope->next)
443 scope_release(scope->next);
444
445 IDispatch_Release(scope->obj);
446 heap_free(scope);
447}
void scope_release(scope_chain_t *scope)
Definition: engine.c:437
IDispatch * obj
Definition: engine.h:205
struct _scope_chain_t * next
Definition: engine.h:207

Referenced by InterpretedFunction_destructor(), pop_call_frame(), scope_pop(), scope_release(), and setup_scope().

◆ setup_arguments_object()

HRESULT setup_arguments_object ( script_ctx_t ctx,
call_frame_t frame 
)

Definition at line 192 of file function.c.

193{
196
197 static const WCHAR caleeW[] = {'c','a','l','l','e','e',0};
198
199 args = heap_alloc_zero(sizeof(*args));
200 if(!args)
201 return E_OUTOFMEMORY;
202
203 hres = init_dispex_from_constr(&args->jsdisp, ctx, &Arguments_info, ctx->object_constr);
204 if(FAILED(hres)) {
206 return hres;
207 }
208
210 args->argc = frame->argc;
211 args->frame = frame;
212
214 jsval_number(args->argc));
215 if(SUCCEEDED(hres))
217 jsval_obj(&args->function->function.dispex));
218 if(SUCCEEDED(hres))
220 if(FAILED(hres)) {
221 jsdisp_release(&args->jsdisp);
222 return hres;
223 }
224
225 frame->arguments_obj = &args->jsdisp;
226 return S_OK;
227}
static FunctionInstance * function_from_jsdisp(jsdisp_t *jsdisp)
Definition: function.c:74
static const WCHAR lengthW[]
Definition: function.c:96
static const builtin_info_t Arguments_info
Definition: function.c:181
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1030
HRESULT jsdisp_propput(jsdisp_t *obj, const WCHAR *name, DWORD flags, jsval_t val)
Definition: dispex.c:1332
#define PROPF_CONFIGURABLE
Definition: jscript.h:102
static jsval_t jsval_number(double n)
Definition: jsval.h:144
#define args
Definition: format.c:66
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by detach_variable_object(), and Function_get_arguments().