ReactOS  0.4.14-dev-593-g1793dcc
engine.c File Reference
#include <math.h>
#include <assert.h>
#include "jscript.h"
#include "engine.h"
#include "wine/debug.h"
Include dependency graph for engine.c:

Go to the source code of this file.

Classes

struct  _except_frame_t
 
struct  exprval_t
 

Macros

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

Typedefs

typedef HRESULT(* op_func_t) (script_ctx_t *)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static HRESULT stack_push (script_ctx_t *ctx, jsval_t v)
 
static HRESULT stack_push_string (script_ctx_t *ctx, const WCHAR *str)
 
static jsval_t stack_top (script_ctx_t *ctx)
 
static jsval_tstack_top_ref (script_ctx_t *ctx, unsigned n)
 
static jsval_t stack_topn (script_ctx_t *ctx, unsigned n)
 
static jsval_tstack_args (script_ctx_t *ctx, unsigned n)
 
static jsval_t stack_pop (script_ctx_t *ctx)
 
static void stack_popn (script_ctx_t *ctx, unsigned n)
 
static HRESULT stack_pop_number (script_ctx_t *ctx, double *r)
 
static HRESULT stack_pop_object (script_ctx_t *ctx, IDispatch **r)
 
static HRESULT stack_pop_int (script_ctx_t *ctx, INT *r)
 
static HRESULT stack_pop_uint (script_ctx_t *ctx, DWORD *r)
 
static unsigned local_off (call_frame_t *frame, int ref)
 
static BSTR local_name (call_frame_t *frame, int ref)
 
static HRESULT stack_push_exprval (script_ctx_t *ctx, exprval_t *val)
 
static BOOL stack_topn_exprval (script_ctx_t *ctx, unsigned n, exprval_t *r)
 
static BOOL stack_pop_exprval (script_ctx_t *ctx, exprval_t *r)
 
static HRESULT exprval_propput (script_ctx_t *ctx, exprval_t *ref, jsval_t v)
 
static HRESULT exprval_propget (script_ctx_t *ctx, exprval_t *ref, jsval_t *r)
 
static HRESULT exprval_call (script_ctx_t *ctx, exprval_t *ref, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT exprval_to_value (script_ctx_t *ctx, exprval_t *ref, jsval_t *r)
 
static void exprval_release (exprval_t *val)
 
static void exprval_set_exception (exprval_t *val, HRESULT hres)
 
static void exprval_set_disp_ref (exprval_t *ref, IDispatch *obj, DISPID id)
 
static jsval_t steal_ret (call_frame_t *frame)
 
static void clear_acc (script_ctx_t *ctx)
 
static HRESULT scope_push (scope_chain_t *scope, jsdisp_t *jsobj, IDispatch *obj, scope_chain_t **ret)
 
static void scope_pop (scope_chain_t **scope)
 
void clear_ei (script_ctx_t *ctx)
 
void scope_release (scope_chain_t *scope)
 
static HRESULT disp_get_id (script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
 
static HRESULT disp_cmp (IDispatch *disp1, IDispatch *disp2, BOOL *ret)
 
HRESULT jsval_strict_equal (jsval_t lval, jsval_t rval, BOOL *ret)
 
static HRESULT detach_variable_object (script_ctx_t *ctx, call_frame_t *frame, BOOL from_release)
 
static BOOL lookup_global_members (script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
 
static int __cdecl local_ref_cmp (const void *key, const void *ref)
 
local_ref_tlookup_local (const function_code_t *function, const WCHAR *identifier)
 
static HRESULT identifier_eval (script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
 
static BSTR get_op_bstr (script_ctx_t *ctx, int i)
 
static unsigned get_op_uint (script_ctx_t *ctx, int i)
 
static unsigned get_op_int (script_ctx_t *ctx, int i)
 
static jsstr_tget_op_str (script_ctx_t *ctx, int i)
 
static double get_op_double (script_ctx_t *ctx)
 
static void jmp_next (script_ctx_t *ctx)
 
static void jmp_abs (script_ctx_t *ctx, unsigned dst)
 
static HRESULT interp_forin (script_ctx_t *ctx)
 
static HRESULT interp_push_scope (script_ctx_t *ctx)
 
static HRESULT interp_pop_scope (script_ctx_t *ctx)
 
static HRESULT interp_case (script_ctx_t *ctx)
 
static HRESULT interp_throw (script_ctx_t *ctx)
 
static HRESULT interp_throw_ref (script_ctx_t *ctx)
 
static HRESULT interp_throw_type (script_ctx_t *ctx)
 
static HRESULT interp_push_except (script_ctx_t *ctx)
 
static HRESULT interp_pop_except (script_ctx_t *ctx)
 
static HRESULT interp_end_finally (script_ctx_t *ctx)
 
static HRESULT interp_enter_catch (script_ctx_t *ctx)
 
static HRESULT interp_func (script_ctx_t *ctx)
 
static HRESULT interp_array (script_ctx_t *ctx)
 
static HRESULT interp_member (script_ctx_t *ctx)
 
static HRESULT interp_memberid (script_ctx_t *ctx)
 
static HRESULT interp_refval (script_ctx_t *ctx)
 
static HRESULT interp_new (script_ctx_t *ctx)
 
static HRESULT interp_call (script_ctx_t *ctx)
 
static HRESULT interp_call_member (script_ctx_t *ctx)
 
static HRESULT interp_this (script_ctx_t *ctx)
 
static HRESULT interp_identifier_ref (script_ctx_t *ctx, BSTR identifier, unsigned flags)
 
static HRESULT identifier_value (script_ctx_t *ctx, BSTR identifier)
 
static HRESULT interp_local_ref (script_ctx_t *ctx)
 
static HRESULT interp_local (script_ctx_t *ctx)
 
static HRESULT interp_ident (script_ctx_t *ctx)
 
static HRESULT interp_identid (script_ctx_t *ctx)
 
static HRESULT interp_null (script_ctx_t *ctx)
 
static HRESULT interp_bool (script_ctx_t *ctx)
 
static HRESULT interp_int (script_ctx_t *ctx)
 
static HRESULT interp_double (script_ctx_t *ctx)
 
static HRESULT interp_str (script_ctx_t *ctx)
 
static HRESULT interp_regexp (script_ctx_t *ctx)
 
static HRESULT interp_carray (script_ctx_t *ctx)
 
static HRESULT interp_carray_set (script_ctx_t *ctx)
 
static HRESULT interp_new_obj (script_ctx_t *ctx)
 
static HRESULT interp_obj_prop (script_ctx_t *ctx)
 
static HRESULT interp_cnd_nz (script_ctx_t *ctx)
 
static HRESULT interp_cnd_z (script_ctx_t *ctx)
 
static HRESULT interp_or (script_ctx_t *ctx)
 
static HRESULT interp_xor (script_ctx_t *ctx)
 
static HRESULT interp_and (script_ctx_t *ctx)
 
static HRESULT interp_instanceof (script_ctx_t *ctx)
 
static HRESULT interp_in (script_ctx_t *ctx)
 
static HRESULT add_eval (script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsval_t *ret)
 
static HRESULT interp_add (script_ctx_t *ctx)
 
static HRESULT interp_sub (script_ctx_t *ctx)
 
static HRESULT interp_mul (script_ctx_t *ctx)
 
static HRESULT interp_div (script_ctx_t *ctx)
 
static HRESULT interp_mod (script_ctx_t *ctx)
 
static HRESULT interp_delete (script_ctx_t *ctx)
 
static HRESULT interp_delete_ident (script_ctx_t *ctx)
 
static HRESULT interp_void (script_ctx_t *ctx)
 
static HRESULT typeof_string (jsval_t v, const WCHAR **ret)
 
static HRESULT interp_typeofid (script_ctx_t *ctx)
 
static HRESULT interp_typeofident (script_ctx_t *ctx)
 
static HRESULT interp_typeof (script_ctx_t *ctx)
 
static HRESULT interp_minus (script_ctx_t *ctx)
 
static HRESULT interp_tonum (script_ctx_t *ctx)
 
static HRESULT interp_postinc (script_ctx_t *ctx)
 
static HRESULT interp_preinc (script_ctx_t *ctx)
 
static HRESULT equal_values (script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL *ret)
 
static HRESULT interp_eq (script_ctx_t *ctx)
 
static HRESULT interp_neq (script_ctx_t *ctx)
 
static HRESULT interp_eq2 (script_ctx_t *ctx)
 
static HRESULT interp_neq2 (script_ctx_t *ctx)
 
static HRESULT less_eval (script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, BOOL *ret)
 
static HRESULT interp_lt (script_ctx_t *ctx)
 
static HRESULT interp_lteq (script_ctx_t *ctx)
 
static HRESULT interp_gt (script_ctx_t *ctx)
 
static HRESULT interp_gteq (script_ctx_t *ctx)
 
static HRESULT interp_bneg (script_ctx_t *ctx)
 
static HRESULT interp_neg (script_ctx_t *ctx)
 
static HRESULT interp_lshift (script_ctx_t *ctx)
 
static HRESULT interp_rshift (script_ctx_t *ctx)
 
static HRESULT interp_rshift2 (script_ctx_t *ctx)
 
static HRESULT interp_assign (script_ctx_t *ctx)
 
static HRESULT interp_assign_call (script_ctx_t *ctx)
 
static HRESULT interp_undefined (script_ctx_t *ctx)
 
static HRESULT interp_jmp (script_ctx_t *ctx)
 
static HRESULT interp_jmp_z (script_ctx_t *ctx)
 
static HRESULT interp_pop (script_ctx_t *ctx)
 
static HRESULT interp_ret (script_ctx_t *ctx)
 
static HRESULT interp_setret (script_ctx_t *ctx)
 
static HRESULT interp_push_acc (script_ctx_t *ctx)
 
static void pop_call_frame (script_ctx_t *ctx)
 
static void print_backtrace (script_ctx_t *ctx)
 
static HRESULT unwind_exception (script_ctx_t *ctx, HRESULT exception_hres)
 
static HRESULT enter_bytecode (script_ctx_t *ctx, jsval_t *r)
 
static HRESULT bind_event_target (script_ctx_t *ctx, function_code_t *func, jsdisp_t *func_obj)
 
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)
 
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)
 

Variables

static const WCHAR booleanW [] = {'b','o','o','l','e','a','n',0}
 
static const WCHAR functionW [] = {'f','u','n','c','t','i','o','n',0}
 
static const WCHAR numberW [] = {'n','u','m','b','e','r',0}
 
static const WCHAR objectW [] = {'o','b','j','e','c','t',0}
 
static const WCHAR stringW [] = {'s','t','r','i','n','g',0}
 
static const WCHAR undefinedW [] = {'u','n','d','e','f','i','n','e','d',0}
 
static const WCHAR unknownW [] = {'u','n','k','n','o','w','n',0}
 
static const op_func_t op_funcs []
 
static const unsigned op_move []
 

Macro Definition Documentation

◆ X [1/2]

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

◆ X [2/2]

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

Typedef Documentation

◆ op_func_t

typedef HRESULT(* op_func_t) (script_ctx_t *)

Definition at line 2646 of file engine.c.

Function Documentation

◆ add_eval()

static HRESULT add_eval ( script_ctx_t ctx,
jsval_t  lval,
jsval_t  rval,
jsval_t ret 
)
static

Definition at line 1696 of file engine.c.

1697 {
1698  jsval_t r, l;
1699  HRESULT hres;
1700 
1701  hres = to_primitive(ctx, lval, &l, NO_HINT);
1702  if(FAILED(hres))
1703  return hres;
1704 
1705  hres = to_primitive(ctx, rval, &r, NO_HINT);
1706  if(FAILED(hres)) {
1707  jsval_release(l);
1708  return hres;
1709  }
1710 
1711  if(is_string(l) || is_string(r)) {
1712  jsstr_t *lstr, *rstr = NULL;
1713 
1714  hres = to_string(ctx, l, &lstr);
1715  if(SUCCEEDED(hres))
1716  hres = to_string(ctx, r, &rstr);
1717 
1718  if(SUCCEEDED(hres)) {
1719  jsstr_t *ret_str;
1720 
1721  ret_str = jsstr_concat(lstr, rstr);
1722  if(ret_str)
1723  *ret = jsval_string(ret_str);
1724  else
1725  hres = E_OUTOFMEMORY;
1726  }
1727 
1728  jsstr_release(lstr);
1729  if(rstr)
1731  }else {
1732  double nl, nr;
1733 
1734  hres = to_number(ctx, l, &nl);
1735  if(SUCCEEDED(hres)) {
1736  hres = to_number(ctx, r, &nr);
1737  if(SUCCEEDED(hres))
1738  *ret = jsval_number(nl+nr);
1739  }
1740  }
1741 
1742  jsval_release(r);
1743  jsval_release(l);
1744  return hres;
1745 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
jsstr_t * jsstr_concat(jsstr_t *str1, jsstr_t *str2)
Definition: jsstr.c:211
ULONG nr
Definition: thread.c:7
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:600
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
r l[0]
Definition: byte_order.h:167
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
float rval
Definition: cylfrac.c:48
LOCAL char * rstr(char *s1, char *s2)
Definition: tree.c:165
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144
HRESULT to_primitive(script_ctx_t *, jsval_t, jsval_t *, hint_t) DECLSPEC_HIDDEN
Definition: jsutils.c:404

Referenced by interp_add().

◆ bind_event_target()

static HRESULT bind_event_target ( script_ctx_t ctx,
function_code_t func,
jsdisp_t func_obj 
)
static

Definition at line 2845 of file engine.c.

2846 {
2848  exprval_t exprval;
2849  IDispatch *disp;
2850  jsval_t v;
2851  HRESULT hres;
2852 
2853  hres = identifier_eval(ctx, func->event_target, &exprval);
2854  if(FAILED(hres))
2855  return hres;
2856 
2857  hres = exprval_to_value(ctx, &exprval, &v);
2858  if(FAILED(hres))
2859  return hres;
2860 
2861  if(!is_object_instance(v)) {
2862  FIXME("Can't bind to %s\n", debugstr_jsval(v));
2863  jsval_release(v);
2864  }
2865 
2866  disp = get_object(v);
2867  hres = IDispatch_QueryInterface(disp, &IID_IBindEventHandler, (void**)&target);
2868  if(SUCCEEDED(hres)) {
2869  hres = IBindEventHandler_BindHandler(target, func->name, (IDispatch*)&func_obj->IDispatchEx_iface);
2870  IBindEventHandler_Release(target);
2871  if(FAILED(hres))
2872  WARN("BindEvent failed: %08x\n", hres);
2873  }else {
2874  FIXME("No IBindEventHandler, not yet supported binding\n");
2875  }
2876 
2877  IDispatch_Release(disp);
2878  return hres;
2879 }
Definition: jsval.h:54
GLenum func
Definition: glext.h:6028
disp
Definition: i386-dis.c:3181
void jsval_release(jsval_t val)
Definition: jsutils.c:191
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
#define WARN(fmt,...)
Definition: debug.h:111
IDispatchEx IDispatchEx_iface
Definition: jscript.h:231
#define FIXME(fmt,...)
Definition: debug.h:110
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GLdouble * v
Definition: gl.h:2040
static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *ref, jsval_t *r)
Definition: engine.c:338
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:635
GLenum target
Definition: glext.h:7315
#define SUCCEEDED(hr)
Definition: intsafe.h:57
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35

Referenced by exec_source().

◆ clear_acc()

static void clear_acc ( script_ctx_t ctx)
inlinestatic

Definition at line 395 of file engine.c.

396 {
397  jsval_release(ctx->acc);
398  ctx->acc = jsval_undefined();
399 }
void jsval_release(jsval_t val)
Definition: jsutils.c:191
jsval_t acc
Definition: jscript.h:434
static jsval_t jsval_undefined(void)
Definition: jsval.h:137

Referenced by interp_call(), interp_call_member(), and interp_new().

◆ clear_ei()

void clear_ei ( script_ctx_t ctx)

Definition at line 430 of file engine.c.

431 {
432  memset(&ctx->ei.ei, 0, sizeof(ctx->ei.ei));
433  jsval_release(ctx->ei.val);
434  ctx->ei.val = jsval_undefined();
435 }
void jsval_release(jsval_t val)
Definition: jsutils.c:191
jsval_t val
Definition: jscript.h:401
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
EXCEPINFO ei
Definition: jscript.h:400
#define memset(x, y, z)
Definition: compat.h:39
jsexcept_t ei
Definition: jscript.h:425

Referenced by compile_error(), disp_call(), disp_call_value(), disp_propget(), disp_propput(), DispatchEx_InvokeEx(), Err_Clear(), exec_global_code(), index_from_val(), JScriptParse_ParseScriptText(), release_script(), script_release(), unwind_exception(), and variant_change_type().

◆ detach_variable_object()

static HRESULT detach_variable_object ( script_ctx_t ctx,
call_frame_t frame,
BOOL  from_release 
)
static

Definition at line 573 of file engine.c.

574 {
575  unsigned i;
576  HRESULT hres;
577 
578  if(!frame->base_scope || !frame->base_scope->frame)
579  return S_OK;
580 
581  TRACE("detaching %p\n", frame);
582 
583  assert(frame == frame->base_scope->frame);
584  assert(frame->variable_obj == frame->base_scope->jsobj);
585 
586  if(!from_release && !frame->arguments_obj) {
587  hres = setup_arguments_object(ctx, frame);
588  if(FAILED(hres))
589  return hres;
590  }
591 
592  frame->base_scope->frame = NULL;
593 
594  for(i = 0; i < frame->function->locals_cnt; i++) {
596  ctx->stack[local_off(frame, frame->function->locals[i].ref)]);
597  if(FAILED(hres))
598  return hres;
599  }
600 
601  return S_OK;
602 }
jsdisp_t * arguments_obj
Definition: engine.h:233
jsdisp_t * jsobj
Definition: engine.h:204
jsdisp_t * variable_obj
Definition: engine.h:232
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:180
#define assert(x)
Definition: debug.h:53
function_code_t * function
Definition: engine.h:243
local_ref_t * locals
Definition: engine.h:167
BSTR name
Definition: engine.h:141
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
struct _call_frame_t * frame
Definition: engine.h:206
jsval_t * stack
Definition: jscript.h:431
scope_chain_t * base_scope
Definition: engine.h:226
#define S_OK
Definition: intsafe.h:59
unsigned locals_cnt
Definition: engine.h:166
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
HRESULT setup_arguments_object(script_ctx_t *, call_frame_t *) DECLSPEC_HIDDEN
Definition: function.c:192
int ref
Definition: engine.h:142

Referenced by exec_source(), identifier_eval(), and pop_call_frame().

◆ disp_cmp()

static HRESULT disp_cmp ( IDispatch disp1,
IDispatch disp2,
BOOL ret 
)
static

Definition at line 486 of file engine.c.

487 {
488  IObjectIdentity *identity;
489  IUnknown *unk1, *unk2;
490  HRESULT hres;
491 
492  if(disp1 == disp2) {
493  *ret = TRUE;
494  return S_OK;
495  }
496 
497  if(!disp1 || !disp2) {
498  *ret = FALSE;
499  return S_OK;
500  }
501 
502  hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
503  if(FAILED(hres))
504  return hres;
505 
506  hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2);
507  if(FAILED(hres)) {
508  IUnknown_Release(unk1);
509  return hres;
510  }
511 
512  if(unk1 == unk2) {
513  *ret = TRUE;
514  }else {
515  hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
516  if(SUCCEEDED(hres)) {
517  hres = IObjectIdentity_IsEqualObject(identity, unk2);
518  IObjectIdentity_Release(identity);
519  *ret = hres == S_OK;
520  }else {
521  *ret = FALSE;
522  }
523  }
524 
525  IUnknown_Release(unk1);
526  IUnknown_Release(unk2);
527  return S_OK;
528 }
#define TRUE
Definition: types.h:120
static DWORD unk1
Definition: cursoricon.c:1638
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static const struct d3drm_matrix identity
Definition: frame.c:26
int ret
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by interp_instanceof(), and jsval_strict_equal().

◆ disp_get_id()

static HRESULT disp_get_id ( script_ctx_t ctx,
IDispatch disp,
const WCHAR name,
BSTR  name_bstr,
DWORD  flags,
DISPID id 
)
static

Definition at line 449 of file engine.c.

450 {
451  IDispatchEx *dispex;
452  jsdisp_t *jsdisp;
453  BSTR bstr;
454  HRESULT hres;
455 
456  jsdisp = iface_to_jsdisp(disp);
457  if(jsdisp) {
458  hres = jsdisp_get_id(jsdisp, name, flags, id);
459  jsdisp_release(jsdisp);
460  return hres;
461  }
462 
463  if(name_bstr) {
464  bstr = name_bstr;
465  }else {
466  bstr = SysAllocString(name);
467  if(!bstr)
468  return E_OUTOFMEMORY;
469  }
470 
471  *id = 0;
472  hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
473  if(SUCCEEDED(hres)) {
474  hres = IDispatchEx_GetDispID(dispex, bstr, make_grfdex(ctx, flags|fdexNameCaseSensitive), id);
475  IDispatchEx_Release(dispex);
476  }else {
477  TRACE("using IDispatch\n");
478  hres = IDispatch_GetIDsOfNames(disp, &IID_NULL, &bstr, 1, 0, id);
479  }
480 
481  if(name_bstr != bstr)
482  SysFreeString(bstr);
483  return hres;
484 }
disp
Definition: i386-dis.c:3181
OLECHAR * BSTR
Definition: compat.h:1942
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
static DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
Definition: jscript.h:519
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
#define IID_NULL
Definition: guiddef.h:98
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
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
Definition: name.c:38
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by do_mcall(), identifier_eval(), interp_array(), interp_assign_member(), interp_in(), interp_member(), interp_memberid(), interp_set_member(), lookup_global_members(), and lookup_identifier().

◆ enter_bytecode()

static HRESULT enter_bytecode ( script_ctx_t ctx,
jsval_t r 
)
static

Definition at line 2806 of file engine.c.

2807 {
2808  call_frame_t *frame;
2809  jsop_t op;
2810  HRESULT hres = S_OK;
2811 
2812  TRACE("\n");
2813 
2814  while(1) {
2815  frame = ctx->call_ctx;
2816  op = frame->bytecode->instrs[frame->ip].op;
2817  hres = op_funcs[op](ctx);
2818  if(FAILED(hres)) {
2819  hres = unwind_exception(ctx, hres);
2820  if(FAILED(hres))
2821  return hres;
2822  }else if(frame->ip == -1) {
2823  const DWORD return_to_interp = frame->flags & EXEC_RETURN_TO_INTERP;
2824 
2825  assert(ctx->stack_top == frame->stack_base);
2826  assert(frame->scope == frame->base_scope);
2827 
2828  if(return_to_interp) {
2829  jsval_release(ctx->acc);
2830  ctx->acc = steal_ret(frame);
2831  }else if(r) {
2832  *r = steal_ret(frame);
2833  }
2834  pop_call_frame(ctx);
2835  if(!return_to_interp)
2836  break;
2837  }else {
2838  frame->ip += op_move[op];
2839  }
2840  }
2841 
2842  return S_OK;
2843 }
void jsval_release(jsval_t val)
Definition: jsutils.c:191
DWORD flags
Definition: engine.h:234
static jsval_t steal_ret(call_frame_t *frame)
Definition: engine.c:388
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned stack_base
Definition: engine.h:224
static void pop_call_frame(script_ctx_t *ctx)
Definition: engine.c:2660
#define assert(x)
Definition: debug.h:53
struct _call_frame_t * call_ctx
Definition: jscript.h:415
#define EXEC_RETURN_TO_INTERP
Definition: engine.h:250
scope_chain_t * scope
Definition: engine.h:225
unsigned ip
Definition: engine.h:222
bytecode_t * bytecode
Definition: engine.h:242
jsval_t acc
Definition: jscript.h:434
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned stack_top
Definition: jscript.h:433
unsigned long DWORD
Definition: ntddk_ex.h:95
instr_t * instrs
Definition: engine.h:175
jsop_t op
Definition: engine.h:127
static const unsigned op_move[]
Definition: engine.c:2654
jsop_t
Definition: engine.h:101
scope_chain_t * base_scope
Definition: engine.h:226
#define S_OK
Definition: intsafe.h:59
static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres)
Definition: engine.c:2729
static const op_func_t op_funcs[]
Definition: engine.c:2648
UINT op
Definition: effect.c:223

Referenced by exec_source().

◆ equal_values()

static HRESULT equal_values ( script_ctx_t ctx,
jsval_t  lval,
jsval_t  rval,
BOOL ret 
)
static

Definition at line 2134 of file engine.c.

2135 {
2136  if(jsval_type(lval) == jsval_type(rval) || (is_number(lval) && is_number(rval)))
2137  return jsval_strict_equal(lval, rval, ret);
2138 
2139  /* FIXME: NULL disps should be handled in more general way */
2140  if(is_object_instance(lval) && !get_object(lval))
2141  return equal_values(ctx, jsval_null(), rval, ret);
2143  return equal_values(ctx, lval, jsval_null(), ret);
2144 
2145  if((is_null(lval) && is_undefined(rval)) || (is_undefined(lval) && is_null(rval))) {
2146  *ret = TRUE;
2147  return S_OK;
2148  }
2149 
2150  if(is_string(lval) && is_number(rval)) {
2151  double n;
2152  HRESULT hres;
2153 
2154  hres = to_number(ctx, lval, &n);
2155  if(FAILED(hres))
2156  return hres;
2157 
2158  /* FIXME: optimize */
2159  return equal_values(ctx, jsval_number(n), rval, ret);
2160  }
2161 
2162  if(is_string(rval) && is_number(lval)) {
2163  double n;
2164  HRESULT hres;
2165 
2166  hres = to_number(ctx, rval, &n);
2167  if(FAILED(hres))
2168  return hres;
2169 
2170  /* FIXME: optimize */
2171  return equal_values(ctx, lval, jsval_number(n), ret);
2172  }
2173 
2174  if(is_bool(rval))
2175  return equal_values(ctx, lval, jsval_number(get_bool(rval) ? 1 : 0), ret);
2176 
2177  if(is_bool(lval))
2178  return equal_values(ctx, jsval_number(get_bool(lval) ? 1 : 0), rval, ret);
2179 
2180 
2181  if(is_object_instance(rval) && (is_string(lval) || is_number(lval))) {
2182  jsval_t prim;
2183  HRESULT hres;
2184 
2185  hres = to_primitive(ctx, rval, &prim, NO_HINT);
2186  if(FAILED(hres))
2187  return hres;
2188 
2189  hres = equal_values(ctx, lval, prim, ret);
2191  return hres;
2192  }
2193 
2194 
2195  if(is_object_instance(lval) && (is_string(rval) || is_number(rval))) {
2196  jsval_t prim;
2197  HRESULT hres;
2198 
2199  hres = to_primitive(ctx, lval, &prim, NO_HINT);
2200  if(FAILED(hres))
2201  return hres;
2202 
2203  hres = equal_values(ctx, prim, rval, ret);
2205  return hres;
2206  }
2207 
2208 
2209  *ret = FALSE;
2210  return S_OK;
2211 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
#define TRUE
Definition: types.h:120
static jsval_t jsval_null(void)
Definition: jsval.h:130
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble n
Definition: glext.h:7729
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:600
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:531
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
int ret
float rval
Definition: cylfrac.c:48
static jsval_type_t jsval_type(jsval_t v)
Definition: jsval.h:210
#define S_OK
Definition: intsafe.h:59
static BOOL is_bool(jsval_t v)
Definition: jsval.h:205
static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:2134
LOCAL int prim(arg_t *ap)
Definition: match.c:440
static jsval_t jsval_number(double n)
Definition: jsval.h:144
HRESULT to_primitive(script_ctx_t *, jsval_t, jsval_t *, hint_t) DECLSPEC_HIDDEN
Definition: jsutils.c:404

Referenced by interp_eq(), and interp_neq().

◆ 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 }
jsval_t ret
Definition: engine.h:228
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 int argc
Definition: ServiceArgs.c:12
struct _function_code_t * funcs
Definition: engine.h:155
static HRESULT detach_variable_object(script_ctx_t *ctx, call_frame_t *frame, BOOL from_release)
Definition: engine.c:573
DWORD flags
Definition: engine.h:234
static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdisp_t *func_obj)
Definition: engine.c:2845
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
jsdisp_t * variable_obj
Definition: engine.h:232
unsigned stack_base
Definition: engine.h:224
const builtin_info_t * builtin_info
Definition: jscript.h:242
struct _call_frame_t * call_ctx
Definition: jscript.h:415
jsdisp_t * function_instance
Definition: engine.h:231
function_code_t * function
Definition: engine.h:243
#define argv
Definition: mplay32.c:18
#define EXEC_RETURN_TO_INTERP
Definition: engine.h:250
#define EXEC_EVAL
Definition: engine.h:251
scope_chain_t * scope
Definition: engine.h:225
IDispatch * host_global
Definition: jscript.h:429
unsigned ip
Definition: engine.h:222
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
static scope_chain_t * scope_addref(scope_chain_t *scope)
Definition: engine.h:212
bytecode_t * bytecode
Definition: engine.h:242
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT enter_bytecode(script_ctx_t *ctx, jsval_t *r)
Definition: engine.c:2806
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned stack_top
Definition: jscript.h:433
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:262
GLbitfield flags
Definition: glext.h:7161
#define EXEC_GLOBAL
Definition: engine.h:248
jsclass_t class
Definition: jscript.h:219
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1067
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
struct _call_frame_t * prev_frame
Definition: engine.h:245
static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:604
scope_chain_t * base_scope
Definition: engine.h:226
struct _function_code_t::@424 * variables
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1060
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
IDispatch * this_obj
Definition: engine.h:230
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
jsdisp_t * global
Definition: jscript.h:441
HRESULT create_source_function(script_ctx_t *, bytecode_t *, function_code_t *, scope_chain_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: function.c:767
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
void release_bytecode(bytecode_t *code)
Definition: compile.c:2226
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
unsigned argc
Definition: engine.h:236
static bytecode_t * bytecode_addref(bytecode_t *code)
Definition: engine.h:196
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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

◆ exprval_call()

static HRESULT exprval_call ( script_ctx_t ctx,
exprval_t ref,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 315 of file engine.c.

316 {
317  switch(ref->type) {
318  case EXPRVAL_STACK_REF: {
319  jsval_t v = ctx->stack[ref->u.off];
320 
321  if(!is_object_instance(v)) {
322  FIXME("invoke %s\n", debugstr_jsval(v));
323  return E_FAIL;
324  }
325 
326  return disp_call_value(ctx, get_object(v), NULL, flags, argc, argv, r);
327  }
328  case EXPRVAL_IDREF:
329  return disp_call(ctx, ref->u.idref.disp, ref->u.idref.id, flags, argc, argv, r);
330  default:
331  assert(0);
332  return E_FAIL;
333  }
334 }
Definition: jsval.h:54
static int argc
Definition: ServiceArgs.c:12
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define assert(x)
Definition: debug.h:53
#define argv
Definition: mplay32.c:18
#define E_FAIL
Definition: ddrawi.h:102
Definition: send.c:47
HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, jsval_t *ret)
Definition: dispex.c:1136
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
GLbitfield flags
Definition: glext.h:7161
jsval_t * stack
Definition: jscript.h:431
const GLdouble * v
Definition: gl.h:2040
HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1228
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35

Referenced by interp_assign_call(), and interp_call_member().

◆ exprval_propget()

static HRESULT exprval_propget ( script_ctx_t ctx,
exprval_t ref,
jsval_t r 
)
static

Definition at line 302 of file engine.c.

303 {
304  switch(ref->type) {
305  case EXPRVAL_STACK_REF:
306  return jsval_copy(ctx->stack[ref->u.off], r);
307  case EXPRVAL_IDREF:
308  return disp_propget(ctx, ref->u.idref.disp, ref->u.idref.id, r);
309  default:
310  assert(0);
311  return E_FAIL;
312  }
313 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define assert(x)
Definition: debug.h:53
#define E_FAIL
Definition: ddrawi.h:102
Definition: send.c:47
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
Definition: dispex.c:1458
jsval_t * stack
Definition: jscript.h:431

Referenced by exprval_to_value(), interp_postinc(), interp_preinc(), interp_refval(), and interp_typeofid().

◆ exprval_propput()

static HRESULT exprval_propput ( script_ctx_t ctx,
exprval_t ref,
jsval_t  v 
)
static

Definition at line 286 of file engine.c.

287 {
288  switch(ref->type) {
289  case EXPRVAL_STACK_REF: {
290  jsval_t *r = ctx->stack + ref->u.off;
291  jsval_release(*r);
292  return jsval_copy(v, r);
293  }
294  case EXPRVAL_IDREF:
295  return disp_propput(ctx, ref->u.idref.disp, ref->u.idref.id, v);
296  default:
297  assert(0);
298  return E_FAIL;
299  }
300 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define assert(x)
Definition: debug.h:53
#define E_FAIL
Definition: ddrawi.h:102
Definition: send.c:47
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val)
Definition: dispex.c:1359
jsval_t * stack
Definition: jscript.h:431
const GLdouble * v
Definition: gl.h:2040

Referenced by interp_assign(), interp_forin(), interp_postinc(), and interp_preinc().

◆ exprval_release()

static void exprval_release ( exprval_t val)
static

Definition at line 354 of file engine.c.

355 {
356  switch(val->type) {
357  case EXPRVAL_JSVAL:
358  jsval_release(val->u.val);
359  return;
360  case EXPRVAL_IDREF:
361  if(val->u.idref.disp)
362  IDispatch_Release(val->u.idref.disp);
363  return;
364  case EXPRVAL_STACK_REF:
365  case EXPRVAL_INVALID:
366  return;
367  }
368 }
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by interp_assign(), interp_delete_ident(), interp_identifier_ref(), interp_postinc(), interp_preinc(), and interp_typeofid().

◆ exprval_set_disp_ref()

static void exprval_set_disp_ref ( exprval_t ref,
IDispatch obj,
DISPID  id 
)
inlinestatic

Definition at line 376 of file engine.c.

377 {
378  ref->type = EXPRVAL_IDREF;
379 #ifdef __REACTOS__ /* FIXME: Inspect */
380  IDispatch_AddRef(obj);
381  ref->u.idref.disp = obj;
382 #else
383  IDispatch_AddRef(ref->u.idref.disp = obj);
384 #endif
385  ref->u.idref.id = id;
386 }
Definition: send.c:47
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
GLenum GLuint id
Definition: glext.h:5579

Referenced by identifier_eval(), interp_identifier_ref(), and lookup_global_members().

◆ exprval_set_exception()

static void exprval_set_exception ( exprval_t val,
HRESULT  hres 
)
inlinestatic

Definition at line 370 of file engine.c.

371 {
372  val->type = EXPRVAL_INVALID;
373  val->u.hres = hres;
374 }
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT hres
Definition: protocol.c:465

Referenced by identifier_eval(), interp_identifier_ref(), and interp_memberid().

◆ exprval_to_value()

static HRESULT exprval_to_value ( script_ctx_t ctx,
exprval_t ref,
jsval_t r 
)
static

Definition at line 338 of file engine.c.

339 {
340  HRESULT hres;
341 
342  if(ref->type == EXPRVAL_JSVAL) {
343  *r = ref->u.val;
344  return S_OK;
345  }
346 
347  hres = exprval_propget(ctx, ref, r);
348 
349  if(ref->type == EXPRVAL_IDREF)
350  IDispatch_Release(ref->u.idref.disp);
351  return hres;
352 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
Definition: send.c:47
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT exprval_propget(script_ctx_t *ctx, exprval_t *ref, jsval_t *r)
Definition: engine.c:302
#define S_OK
Definition: intsafe.h:59

Referenced by bind_event_target(), identifier_value(), and interp_typeofident().

◆ get_op_bstr()

static BSTR get_op_bstr ( script_ctx_t ctx,
int  i 
)
inlinestatic

Definition at line 718 of file engine.c.

719 {
720  call_frame_t *frame = ctx->call_ctx;
721  return frame->bytecode->instrs[frame->ip].u.arg[i].bstr;
722 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:415
unsigned ip
Definition: engine.h:222
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
bytecode_t * bytecode
Definition: engine.h:242
instr_t * instrs
Definition: engine.h:175
BSTR bstr
Definition: engine.h:109
union instr_t::@423 u

Referenced by interp_delete_ident(), interp_enter_catch(), interp_ident(), interp_identid(), interp_member(), and interp_typeofident().

◆ get_op_double()

static double get_op_double ( script_ctx_t ctx)
inlinestatic

Definition at line 742 of file engine.c.

743 {
744  call_frame_t *frame = ctx->call_ctx;
745  return frame->bytecode->instrs[frame->ip].u.dbl;
746 }
struct _call_frame_t * call_ctx
Definition: jscript.h:415
unsigned ip
Definition: engine.h:222
double dbl
Definition: engine.h:130
bytecode_t * bytecode
Definition: engine.h:242
instr_t * instrs
Definition: engine.h:175
union instr_t::@423 u

Referenced by interp_double().

◆ get_op_int()

static unsigned get_op_int ( script_ctx_t ctx,
int  i 
)
inlinestatic

Definition at line 730 of file engine.c.

731 {
732  call_frame_t *frame = ctx->call_ctx;
733  return frame->bytecode->instrs[frame->ip].u.arg[i].lng;
734 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:415
unsigned ip
Definition: engine.h:222
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
bytecode_t * bytecode
Definition: engine.h:242
LONG lng
Definition: engine.h:110
instr_t * instrs
Definition: engine.h:175
union instr_t::@423 u

Referenced by interp_bool(), interp_call(), interp_call_member(), interp_int(), interp_local(), interp_local_ref(), interp_postinc(), and interp_preinc().

◆ get_op_str()

static jsstr_t* get_op_str ( script_ctx_t ctx,
int  i 
)
inlinestatic

Definition at line 736 of file engine.c.

737 {
738  call_frame_t *frame = ctx->call_ctx;
739  return frame->bytecode->instrs[frame->ip].u.arg[i].str;
740 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:415
unsigned ip
Definition: engine.h:222
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
bytecode_t * bytecode
Definition: engine.h:242
jsstr_t * str
Definition: engine.h:111
instr_t * instrs
Definition: engine.h:175
union instr_t::@423 u

Referenced by interp_obj_prop(), interp_regexp(), interp_str(), and interp_throw_type().

◆ get_op_uint()

static unsigned get_op_uint ( script_ctx_t ctx,
int  i 
)
inlinestatic

Definition at line 724 of file engine.c.

725 {
726  call_frame_t *frame = ctx->call_ctx;
727  return frame->bytecode->instrs[frame->ip].u.arg[i].uint;
728 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:415
unsigned ip
Definition: engine.h:222
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
bytecode_t * bytecode
Definition: engine.h:242
instr_t * instrs
Definition: engine.h:175
unsigned uint
Definition: engine.h:112
union instr_t::@423 u

Referenced by interp_assign_call(), interp_call(), interp_call_member(), interp_carray(), interp_carray_set(), interp_case(), interp_cnd_nz(), interp_cnd_z(), interp_forin(), interp_func(), interp_identid(), interp_jmp(), interp_jmp_z(), interp_local_ref(), interp_memberid(), interp_new(), interp_obj_prop(), interp_pop(), interp_pop_except(), interp_push_except(), interp_regexp(), interp_ret(), interp_throw_ref(), and interp_throw_type().

◆ identifier_eval()

static HRESULT identifier_eval ( script_ctx_t ctx,
BSTR  identifier,
exprval_t ret 
)
static

Definition at line 635 of file engine.c.

636 {
637  scope_chain_t *scope;
639  DISPID id = 0;
640  HRESULT hres;
641 
642  TRACE("%s\n", debugstr_w(identifier));
643 
644  if(ctx->call_ctx) {
645  for(scope = ctx->call_ctx->scope; scope; scope = scope->next) {
646  if(scope->frame) {
647  function_code_t *func = scope->frame->function;
648  local_ref_t *ref = lookup_local(func, identifier);
649  static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0};
650 
651  if(ref) {
652  ret->type = EXPRVAL_STACK_REF;
653  ret->u.off = local_off(scope->frame, ref->ref);
654  TRACE("returning ref %d for %d\n", ret->u.off, ref->ref);
655  return S_OK;
656  }
657 
658  if(!wcscmp(identifier, argumentsW)) {
659  hres = detach_variable_object(ctx, scope->frame, FALSE);
660  if(FAILED(hres))
661  return hres;
662  }
663  }
664  if(scope->jsobj)
665  hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
666  else
667  hres = disp_get_id(ctx, scope->obj, identifier, identifier, fdexNameImplicit, &id);
668  if(SUCCEEDED(hres)) {
669  exprval_set_disp_ref(ret, scope->obj, id);
670  return S_OK;
671  }
672  }
673  }
674 
675  hres = jsdisp_get_id(ctx->global, identifier, 0, &id);
676  if(SUCCEEDED(hres)) {
678  return S_OK;
679  }
680 
681  for(item = ctx->named_items; item; item = item->next) {
682  if((item->flags & SCRIPTITEM_ISVISIBLE) && !wcscmp(item->name, identifier)) {
683  if(!item->disp) {
684  IUnknown *unk;
685 
686  if(!ctx->site)
687  break;
688 
689  hres = IActiveScriptSite_GetItemInfo(ctx->site, identifier,
690  SCRIPTINFO_IUNKNOWN, &unk, NULL);
691  if(FAILED(hres)) {
692  WARN("GetItemInfo failed: %08x\n", hres);
693  break;
694  }
695 
696  hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
697  IUnknown_Release(unk);
698  if(FAILED(hres)) {
699  WARN("object does not implement IDispatch\n");
700  break;
701  }
702  }
703 
704  IDispatch_AddRef(item->disp);
705  ret->type = EXPRVAL_JSVAL;
706  ret->u.val = jsval_disp(item->disp);
707  return S_OK;
708  }
709  }
710 
711  if(lookup_global_members(ctx, identifier, ret))
712  return S_OK;
713 
715  return S_OK;
716 }
GLenum func
Definition: glext.h:6028
static HRESULT detach_variable_object(script_ctx_t *ctx, call_frame_t *frame, BOOL from_release)
Definition: engine.c:573
jsdisp_t * jsobj
Definition: engine.h:204
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:180
#define WARN(fmt,...)
Definition: debug.h:111
IDispatch * obj
Definition: engine.h:205
struct _call_frame_t * call_ctx
Definition: jscript.h:415
static void exprval_set_exception(exprval_t *val, HRESULT hres)
Definition: engine.c:370
Definition: send.c:47
struct _scope_chain_t * next
Definition: engine.h:207
static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
Definition: engine.c:449
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static void exprval_set_disp_ref(exprval_t *ref, IDispatch *obj, DISPID id)
Definition: engine.c:376
#define TRACE(s)
Definition: solgame.cpp:4
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
struct _call_frame_t * frame
Definition: engine.h:206
const GUID IID_IDispatch
int ret
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1067
local_ref_t * lookup_local(const function_code_t *function, const WCHAR *identifier)
Definition: engine.c:629
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:604
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
static ATOM item
Definition: dde.c:856
static const WCHAR argumentsW[]
Definition: function.c:101
IActiveScriptSite * site
Definition: jscript.h:417
jsdisp_t * global
Definition: jscript.h:441
#define JS_E_UNDEFINED_VARIABLE
Definition: jscript.h:557
named_item_t * named_items
Definition: jscript.h:416
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by bind_event_target(), identifier_value(), interp_delete_ident(), interp_identifier_ref(), and interp_typeofident().

◆ identifier_value()

static HRESULT identifier_value ( script_ctx_t ctx,
BSTR  identifier 
)
static

Definition at line 1260 of file engine.c.

1261 {
1262  exprval_t exprval;
1263  jsval_t v;
1264  HRESULT hres;
1265 
1266  hres = identifier_eval(ctx, identifier, &exprval);
1267  if(FAILED(hres))
1268  return hres;
1269 
1270  if(exprval.type == EXPRVAL_INVALID)
1271  return throw_type_error(ctx, exprval.u.hres, identifier);
1272 
1273  hres = exprval_to_value(ctx, &exprval, &v);
1274  if(FAILED(hres))
1275  return hres;
1276 
1277  return stack_push(ctx, v);
1278 }
Definition: jsval.h:54
enum exprval_t::@420 type
HRESULT hres
Definition: protocol.c:465
union exprval_t::@421 u
LONG HRESULT
Definition: typedefs.h:77
const GLdouble * v
Definition: gl.h:2040
static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *ref, jsval_t *r)
Definition: engine.c:338
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:635
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
HRESULT hres
Definition: engine.c:65
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

Referenced by interp_ident(), and interp_local().

◆ interp_add()

static HRESULT interp_add ( script_ctx_t ctx)
static

Definition at line 1748 of file engine.c.

1749 {
1750  jsval_t l, r, ret;
1751  HRESULT hres;
1752 
1753  r = stack_pop(ctx);
1754  l = stack_pop(ctx);
1755 
1756  TRACE("%s + %s\n", debugstr_jsval(l), debugstr_jsval(r));
1757 
1758  hres = add_eval(ctx, l, r, &ret);
1759  jsval_release(l);
1760  jsval_release(r);
1761  if(FAILED(hres))
1762  return hres;
1763 
1764  return stack_push(ctx, ret);
1765 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsval_t *ret)
Definition: engine.c:1696
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_and()

static HRESULT interp_and ( script_ctx_t ctx)
static

Definition at line 1580 of file engine.c.

1581 {
1582  INT l, r;
1583  HRESULT hres;
1584 
1585  TRACE("\n");
1586 
1587  hres = stack_pop_int(ctx, &r);
1588  if(FAILED(hres))
1589  return hres;
1590 
1591  hres = stack_pop_int(ctx, &l);
1592  if(FAILED(hres))
1593  return hres;
1594 
1595  return stack_push(ctx, jsval_number(l&r));
1596 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int32_t INT
Definition: typedefs.h:56
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT stack_pop_int(script_ctx_t *ctx, INT *r)
Definition: engine.c:170
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_array()

static HRESULT interp_array ( script_ctx_t ctx)
static

Definition at line 1025 of file engine.c.

1026 {
1027  jsstr_t *name_str;
1028  const WCHAR *name;
1029  jsval_t v, namev;
1030  IDispatch *obj;
1031  DISPID id;
1032  HRESULT hres;
1033 
1034  TRACE("\n");
1035 
1036  namev = stack_pop(ctx);
1037 
1038  hres = stack_pop_object(ctx, &obj);
1039  if(FAILED(hres)) {
1040  jsval_release(namev);
1041  return hres;
1042  }
1043 
1044  hres = to_flat_string(ctx, namev, &name_str, &name);
1045  jsval_release(namev);
1046  if(FAILED(hres)) {
1047  IDispatch_Release(obj);
1048  return hres;
1049  }
1050 
1051  hres = disp_get_id(ctx, obj, name, NULL, 0, &id);
1052  jsstr_release(name_str);
1053  if(SUCCEEDED(hres)) {
1054  hres = disp_propget(ctx, obj, id, &v);
1055  }else if(hres == DISP_E_UNKNOWNNAME) {
1056  v = jsval_undefined();
1057  hres = S_OK;
1058  }
1059  IDispatch_Release(obj);
1060  if(FAILED(hres))
1061  return hres;
1062 
1063  return stack_push(ctx, v);
1064 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:191
Definition: jsstr.h:39
static HRESULT stack_pop_object(script_ctx_t *ctx, IDispatch **r)
Definition: engine.c:152
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
Definition: engine.c:449
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
Definition: dispex.c:1458
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
const GLdouble * v
Definition: gl.h:2040
Definition: name.c:38
GLenum GLuint id
Definition: glext.h:5579
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69
GLuint const GLchar * name
Definition: glext.h:6031

◆ interp_assign()

static HRESULT interp_assign ( script_ctx_t ctx)
static

Definition at line 2507 of file engine.c.

2508 {
2509  exprval_t ref;
2510  jsval_t v;
2511  HRESULT hres;
2512 
2513  TRACE("\n");
2514 
2515  v = stack_pop(ctx);
2516 
2517  if(!stack_pop_exprval(ctx, &ref)) {
2518  jsval_release(v);
2520  }
2521 
2522  hres = exprval_propput(ctx, &ref, v);
2523  exprval_release(&ref);
2524  if(FAILED(hres)) {
2525  jsval_release(v);
2526  return hres;
2527  }
2528 
2529  return stack_push(ctx, v);
2530 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
Definition: send.c:47
static HRESULT exprval_propput(script_ctx_t *ctx, exprval_t *ref, jsval_t v)
Definition: engine.c:286
#define JS_E_ILLEGAL_ASSIGN
Definition: jscript.h:556
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static BOOL stack_pop_exprval(script_ctx_t *ctx, exprval_t *r)
Definition: engine.c:279
static void exprval_release(exprval_t *val)
Definition: engine.c:354
HRESULT throw_reference_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:425
const GLdouble * v
Definition: gl.h:2040
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_assign_call()

static HRESULT interp_assign_call ( script_ctx_t ctx)
static

Definition at line 2533 of file engine.c.

2534 {
2535  const unsigned argc = get_op_uint(ctx, 0);
2536  exprval_t ref;
2537  jsval_t v;
2538  HRESULT hres;
2539 
2540  TRACE("%u\n", argc);
2541 
2542  if(!stack_topn_exprval(ctx, argc+1, &ref))
2544 
2546  if(FAILED(hres))
2547  return hres;
2548 
2549  v = stack_pop(ctx);
2550  stack_popn(ctx, argc+2);
2551  return stack_push(ctx, v);
2552 }
Definition: jsval.h:54
static int argc
Definition: ServiceArgs.c:12
static HRESULT exprval_call(script_ctx_t *ctx, exprval_t *ref, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: engine.c:315
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:135
Definition: send.c:47
#define JS_E_ILLEGAL_ASSIGN
Definition: jscript.h:556
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT throw_reference_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:425
static BOOL stack_topn_exprval(script_ctx_t *ctx, unsigned n, exprval_t *r)
Definition: engine.c:223
const GLdouble * v
Definition: gl.h:2040
static jsval_t * stack_args(script_ctx_t *ctx, unsigned n)
Definition: engine.c:121
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_bneg()

static HRESULT interp_bneg ( script_ctx_t ctx)
static

Definition at line 2418 of file engine.c.

2419 {
2420  jsval_t v;
2421  INT i;
2422  HRESULT hres;
2423 
2424  TRACE("\n");
2425 
2426  v = stack_pop(ctx);
2427  hres = to_int32(ctx, v, &i);
2428  jsval_release(v);
2429  if(FAILED(hres))
2430  return hres;
2431 
2432  return stack_push(ctx, jsval_number(~i));
2433 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
int32_t INT
Definition: typedefs.h:56
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 to_int32(script_ctx_t *, jsval_t, INT *) DECLSPEC_HIDDEN
Definition: jsutils.c:665
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GLdouble * v
Definition: gl.h:2040
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_bool()

static HRESULT interp_bool ( script_ctx_t ctx)
static

Definition at line 1346 of file engine.c.

1347 {
1348  const int arg = get_op_int(ctx, 0);
1349 
1350  TRACE("%s\n", arg ? "true" : "false");
1351 
1352  return stack_push(ctx, jsval_bool(arg));
1353 }
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:730
#define TRACE(s)
Definition: solgame.cpp:4
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_call()

static HRESULT interp_call ( script_ctx_t ctx)
static

Definition at line 1187 of file engine.c.

1188 {
1189  const unsigned argn = get_op_uint(ctx, 0);
1190  const int do_ret = get_op_int(ctx, 1);
1191  jsval_t obj;
1192 
1193  TRACE("%d %d\n", argn, do_ret);
1194 
1195  obj = stack_topn(ctx, argn);
1196  if(!is_object_instance(obj))
1198 
1199  clear_acc(ctx);
1201  argn, stack_args(ctx, argn), do_ret ? &ctx->acc : NULL);
1202 }
Definition: jsval.h:54
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:730
static void clear_acc(script_ctx_t *ctx)
Definition: engine.c:395
static jsval_t stack_topn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:116
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
jsval_t acc
Definition: jscript.h:434
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
#define JS_E_INVALID_PROPERTY
Definition: jscript.h:533
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:115
static jsval_t * stack_args(script_ctx_t *ctx, unsigned n)
Definition: engine.c:121
HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1228
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440

◆ interp_call_member()

static HRESULT interp_call_member ( script_ctx_t ctx)
static

Definition at line 1205 of file engine.c.

1206 {
1207  const unsigned argn = get_op_uint(ctx, 0);
1208  const int do_ret = get_op_int(ctx, 1);
1209  exprval_t ref;
1210 
1211  TRACE("%d %d\n", argn, do_ret);
1212 
1213  if(!stack_topn_exprval(ctx, argn, &ref))
1214  return throw_type_error(ctx, ref.u.hres, NULL);
1215 
1216  clear_acc(ctx);
1218  argn, stack_args(ctx, argn), do_ret ? &ctx->acc : NULL);
1219 }
static HRESULT exprval_call(script_ctx_t *ctx, exprval_t *ref, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: engine.c:315
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:730
static void clear_acc(script_ctx_t *ctx)
Definition: engine.c:395
Definition: send.c:47
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLenum GLint ref
Definition: glext.h:6028
jsval_t acc
Definition: jscript.h:434
smooth NULL
Definition: ftsmooth.c:416
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL stack_topn_exprval(script_ctx_t *ctx, unsigned n, exprval_t *r)
Definition: engine.c:223
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:115
static jsval_t * stack_args(script_ctx_t *ctx, unsigned n)
Definition: engine.c:121
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440

◆ interp_carray()

static HRESULT interp_carray ( script_ctx_t ctx)
static

Definition at line 1403 of file engine.c.

1404 {
1405  const unsigned arg = get_op_uint(ctx, 0);
1406  jsdisp_t *array;
1407  HRESULT hres;
1408 
1409  TRACE("%u\n", arg);
1410 
1411  hres = create_array(ctx, arg, &array);
1412  if(FAILED(hres))
1413  return hres;
1414 
1415  return stack_push(ctx, jsval_obj(array));
1416 }
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1381
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_carray_set()

static HRESULT interp_carray_set ( script_ctx_t ctx)
static

Definition at line 1418 of file engine.c.

1419 {
1420  const unsigned index = get_op_uint(ctx, 0);
1421  jsval_t value, array;
1422  HRESULT hres;
1423 
1424  value = stack_pop(ctx);
1425 
1426  TRACE("[%u] = %s\n", index, debugstr_jsval(value));
1427 
1428  array = stack_top(ctx);
1430 
1433  return hres;
1434 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
#define assert(x)
Definition: debug.h:53
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:104
GLuint index
Definition: glext.h:6031
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLsizei const GLfloat * value
Definition: glext.h:6069
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1060
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1349
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35

◆ interp_case()

static HRESULT interp_case ( script_ctx_t ctx)
static

Definition at line 850 of file engine.c.

851 {
852  const unsigned arg = get_op_uint(ctx, 0);
853  jsval_t v;
854  BOOL b;
855  HRESULT hres;
856 
857  TRACE("\n");
858 
859  v = stack_pop(ctx);
860  hres = jsval_strict_equal(stack_top(ctx), v, &b);
861  jsval_release(v);
862  if(FAILED(hres))
863  return hres;
864 
865  if(b) {
866  stack_popn(ctx, 1);
867  jmp_abs(ctx, arg);
868  }else {
869  jmp_next(ctx);
870  }
871  return S_OK;
872 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:135
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:753
unsigned int BOOL
Definition: ntddk_ex.h:94
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:104
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:531
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:748
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129

◆ interp_cnd_nz()

static HRESULT interp_cnd_nz ( script_ctx_t ctx)
static

Definition at line 1498 of file engine.c.

1499 {
1500  const unsigned arg = get_op_uint(ctx, 0);
1501  BOOL b;
1502  HRESULT hres;
1503 
1504  TRACE("\n");
1505 
1506  hres = to_boolean(stack_top(ctx), &b);
1507  if(FAILED(hres))
1508  return hres;
1509 
1510  if(b) {
1511  jmp_abs(ctx, arg);
1512  }else {
1513  stack_popn(ctx, 1);
1514  jmp_next(ctx);
1515  }
1516  return S_OK;
1517 }
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:135
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:753
unsigned int BOOL
Definition: ntddk_ex.h:94
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:104
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT to_boolean(jsval_t, BOOL *) DECLSPEC_HIDDEN
Definition: jsutils.c:472
#define S_OK
Definition: intsafe.h:59
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:748

◆ interp_cnd_z()

static HRESULT interp_cnd_z ( script_ctx_t ctx)
static

Definition at line 1520 of file engine.c.

1521 {
1522  const unsigned arg = get_op_uint(ctx, 0);
1523  BOOL b;
1524  HRESULT hres;
1525 
1526  TRACE("\n");
1527 
1528  hres = to_boolean(stack_top(ctx), &b);
1529  if(FAILED(hres))
1530  return hres;
1531 
1532  if(b) {
1533  stack_popn(ctx, 1);
1534  jmp_next(ctx);
1535  }else {
1536  jmp_abs(ctx, arg);
1537  }
1538  return S_OK;
1539 }
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:135
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:753
unsigned int BOOL
Definition: ntddk_ex.h:94
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:104
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT to_boolean(jsval_t, BOOL *) DECLSPEC_HIDDEN
Definition: jsutils.c:472
#define S_OK
Definition: intsafe.h:59
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:748

◆ interp_delete()

static HRESULT interp_delete ( script_ctx_t ctx)
static

Definition at line 1844 of file engine.c.

1845 {
1846  jsval_t objv, namev;
1847  IDispatch *obj;
1848  jsstr_t *name;
1849  BOOL ret;
1850  HRESULT hres;
1851 
1852  TRACE("\n");
1853 
1854  namev = stack_pop(ctx);
1855  objv = stack_pop(ctx);
1856 
1857  hres = to_object(ctx, objv, &obj);
1858  jsval_release(objv);
1859  if(FAILED(hres)) {
1860  jsval_release(namev);
1861  return hres;
1862  }
1863 
1864  hres = to_string(ctx, namev, &name);
1865  jsval_release(namev);
1866  if(FAILED(hres)) {
1867  IDispatch_Release(obj);
1868  return hres;
1869  }
1870 
1871  hres = disp_delete_name(ctx, obj, name, &ret);
1872  IDispatch_Release(obj);
1874  if(FAILED(hres))
1875  return hres;
1876 
1877  return stack_push(ctx, jsval_bool(ret));
1878 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
Definition: jsstr.h:39
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
unsigned int BOOL
Definition: ntddk_ex.h:94
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
Definition: name.c:38
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:816
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
HRESULT disp_delete_name(script_ctx_t *ctx, IDispatch *disp, jsstr_t *name, BOOL *ret)
Definition: dispex.c:1574
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69
GLuint const GLchar * name
Definition: glext.h:6031

◆ interp_delete_ident()

static HRESULT interp_delete_ident ( script_ctx_t ctx)
static

Definition at line 1881 of file engine.c.

1882 {
1883  const BSTR arg = get_op_bstr(ctx, 0);
1884  exprval_t exprval;
1885  BOOL ret;
1886  HRESULT hres;
1887 
1888  TRACE("%s\n", debugstr_w(arg));
1889 
1890  hres = identifier_eval(ctx, arg, &exprval);
1891  if(FAILED(hres))
1892  return hres;
1893 
1894  switch(exprval.type) {
1895  case EXPRVAL_STACK_REF:
1896  ret = FALSE;
1897  break;
1898  case EXPRVAL_IDREF:
1899  hres = disp_delete(exprval.u.idref.disp, exprval.u.idref.id, &ret);
1900  IDispatch_Release(exprval.u.idref.disp);
1901  if(FAILED(hres))
1902  return hres;
1903  break;
1904  case EXPRVAL_INVALID:
1905  ret = TRUE;
1906  break;
1907  default:
1908  FIXME("Unsupported exprval\n");
1909  exprval_release(&exprval);
1910  return E_NOTIMPL;
1911  }
1912 
1913 
1914  return stack_push(ctx, jsval_bool(ret));
1915 }
#define TRUE
Definition: types.h:120
enum exprval_t::@420 type
OLECHAR * BSTR
Definition: compat.h:1942
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:718
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
union exprval_t::@421 u
LONG HRESULT
Definition: typedefs.h:77
int ret
HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret)
Definition: dispex.c:1511
static void exprval_release(exprval_t *val)
Definition: engine.c:354
struct exprval_t::@421::@422 idref
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:635
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_div()

static HRESULT interp_div ( script_ctx_t ctx)
static

Definition at line 1806 of file engine.c.

1807 {
1808  double l, r;
1809  HRESULT hres;
1810 
1811  TRACE("\n");
1812 
1813  hres = stack_pop_number(ctx, &r);
1814  if(FAILED(hres))
1815  return hres;
1816 
1817  hres = stack_pop_number(ctx, &l);
1818  if(FAILED(hres))
1819  return hres;
1820 
1821  return stack_push(ctx, jsval_number(l/r));
1822 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT stack_pop_number(script_ctx_t *ctx, double *r)
Definition: engine.c:141
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_double()

static HRESULT interp_double ( script_ctx_t ctx)
static

Definition at line 1366 of file engine.c.

1367 {
1368  const double arg = get_op_double(ctx);
1369 
1370  TRACE("%lf\n", arg);
1371 
1372  return stack_push(ctx, jsval_number(arg));
1373 }
static double get_op_double(script_ctx_t *ctx)
Definition: engine.c:742
#define TRACE(s)
Definition: solgame.cpp:4
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_end_finally()

static HRESULT interp_end_finally ( script_ctx_t ctx)
static

Definition at line 963 of file engine.c.

964 {
965  call_frame_t *frame = ctx->call_ctx;
966  jsval_t v;
967 
968  TRACE("\n");
969 
970  v = stack_pop(ctx);
971  assert(is_bool(v));
972 
973  if(!get_bool(v)) {
974  TRACE("passing exception\n");
975 
976  ctx->ei.val = stack_pop(ctx);
977  return DISP_E_EXCEPTION;
978  }
979 
980  v = stack_pop(ctx);
981  assert(is_number(v));
982  frame->ip = get_number(v);
983  return S_OK;
984 }
#define DISP_E_EXCEPTION
Definition: winerror.h:2518
Definition: jsval.h:54
#define assert(x)
Definition: debug.h:53
struct _call_frame_t * call_ctx
Definition: jscript.h:415
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
unsigned ip
Definition: engine.h:222
static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
jsval_t val
Definition: jscript.h:401
#define TRACE(s)
Definition: solgame.cpp:4
static double get_number(jsval_t v)
Definition: jsval.h:224
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
static BOOL is_bool(jsval_t v)
Definition: jsval.h:205
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
jsexcept_t ei
Definition: jscript.h:425

◆ interp_enter_catch()

static HRESULT interp_enter_catch ( script_ctx_t ctx)
static

Definition at line 986 of file engine.c.

987 {
988  const BSTR ident = get_op_bstr(ctx, 0);
989  jsdisp_t *scope_obj;
990  jsval_t v;
991  HRESULT hres;
992 
993  hres = create_dispex(ctx, NULL, NULL, &scope_obj);
994  if(FAILED(hres))
995  return hres;
996 
997  v = stack_pop(ctx);
998  hres = jsdisp_propput_name(scope_obj, ident, v);
999  jsval_release(v);
1000  if(SUCCEEDED(hres))
1001  hres = scope_push(ctx->call_ctx->scope, scope_obj, to_disp(scope_obj), &ctx->call_ctx->scope);
1002  jsdisp_release(scope_obj);
1003  return hres;
1004 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
struct _call_frame_t * call_ctx
Definition: jscript.h:415
static HRESULT scope_push(scope_chain_t *scope, jsdisp_t *jsobj, IDispatch *obj, scope_chain_t **ret)
Definition: engine.c:401
OLECHAR * BSTR
Definition: compat.h:1942
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3993
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:718
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
const GLdouble * v
Definition: gl.h:2040
HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype, jsdisp_t **dispex)
Definition: dispex.c:957
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1344
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ interp_eq()

static HRESULT interp_eq ( script_ctx_t ctx)
static

Definition at line 2214 of file engine.c.

2215 {
2216  jsval_t l, r;
2217  BOOL b;
2218  HRESULT hres;
2219 
2220  r = stack_pop(ctx);
2221  l = stack_pop(ctx);
2222 
2223  TRACE("%s == %s\n", debugstr_jsval(l), debugstr_jsval(r));
2224 
2225  hres = equal_values(ctx, l, r, &b);
2226  jsval_release(l);
2227  jsval_release(r);
2228  if(FAILED(hres))
2229  return hres;
2230 
2231  return stack_push(ctx, jsval_bool(b));
2232 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:2134
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_eq2()

static HRESULT interp_eq2 ( script_ctx_t ctx)
static

Definition at line 2256 of file engine.c.

2257 {
2258  jsval_t l, r;
2259  BOOL b;
2260  HRESULT hres;
2261 
2262  r = stack_pop(ctx);
2263  l = stack_pop(ctx);
2264 
2265  TRACE("%s === %s\n", debugstr_jsval(l), debugstr_jsval(r));
2266 
2267  hres = jsval_strict_equal(r, l, &b);
2268  jsval_release(l);
2269  jsval_release(r);
2270  if(FAILED(hres))
2271  return hres;
2272 
2273  return stack_push(ctx, jsval_bool(b));
2274 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:531
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_forin()

static HRESULT interp_forin ( script_ctx_t ctx)
static

Definition at line 759 of file engine.c.

760 {
761  const HRESULT arg = get_op_uint(ctx, 0);
762  IDispatch *obj = NULL;
763  IDispatchEx *dispex;
764  exprval_t prop_ref;
765  DISPID id;
766  BSTR name = NULL;
767  HRESULT hres;
768 
769  TRACE("\n");
770 
771  assert(is_number(stack_top(ctx)));
772  id = get_number(stack_top(ctx));
773 
774  if(!stack_topn_exprval(ctx, 1, &prop_ref)) {
775  FIXME("invalid ref: %08x\n", prop_ref.u.hres);
776  return E_FAIL;
777  }
778 
779  if(is_object_instance(stack_topn(ctx, 3)))
780  obj = get_object(stack_topn(ctx, 3));
781 
782  if(obj) {
783  hres = IDispatch_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
784  if(SUCCEEDED(hres)) {
785  hres = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, id, &id);
786  if(hres == S_OK)
787  hres = IDispatchEx_GetMemberName(dispex, id, &name);
788  IDispatchEx_Release(dispex);
789  if(FAILED(hres))
790  return hres;
791  }else {
792  TRACE("No IDispatchEx\n");
793  }
794  }
795 
796  if(name) {
797  jsstr_t *str;
798 
801  if(!str)
802  return E_OUTOFMEMORY;
803 
804  stack_pop(ctx);
805  stack_push(ctx, jsval_number(id)); /* safe, just after pop() */
806 
807  hres = exprval_propput(ctx, &prop_ref, jsval_string(str));
809  if(FAILED(hres))
810  return hres;
811 
812  jmp_next(ctx);
813  }else {
814  stack_popn(ctx, 4);
815  jmp_abs(ctx, arg);
816  }
817  return S_OK;
818 }
jsstr_t * jsstr_alloc_len(const WCHAR *buf, unsigned len)
Definition: jsstr.c:86
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:135
Definition: jsstr.h:39
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
#define assert(x)
Definition: debug.h:53
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:753
static jsval_t stack_topn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:116
OLECHAR * BSTR
Definition: compat.h:1942
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT exprval_propput(script_ctx_t *ctx, exprval_t *ref, jsval_t v)
Definition: engine.c:286
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:104
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
union exprval_t::@421 u
LONG HRESULT
Definition: typedefs.h:77
static double get_number(jsval_t v)
Definition: jsval.h:224
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
static BOOL stack_topn_exprval(script_ctx_t *ctx, unsigned n, exprval_t *r)
Definition: engine.c:223
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:748
Definition: name.c:38
GLenum GLuint id
Definition: glext.h:5579
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
HRESULT hres
Definition: engine.c:65
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_func()

static HRESULT interp_func ( script_ctx_t ctx)
static

Definition at line 1007 of file engine.c.

1008 {
1009  unsigned func_idx = get_op_uint(ctx, 0);
1010  call_frame_t *frame = ctx->call_ctx;
1011  jsdisp_t *dispex;
1012  HRESULT hres;
1013 
1014  TRACE("%d\n", func_idx);
1015 
1016  hres = create_source_function(ctx, frame->bytecode, frame->function->funcs+func_idx,
1017  frame->scope, &dispex);
1018  if(FAILED(hres))
1019  return hres;
1020 
1021  return stack_push(ctx, jsval_obj(dispex));
1022 }
struct _function_code_t * funcs
Definition: engine.h:155
struct _call_frame_t * call_ctx
Definition: jscript.h:415
function_code_t * function
Definition: engine.h:243
scope_chain_t * scope
Definition: engine.h:225
bytecode_t * bytecode
Definition: engine.h:242
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT create_source_function(script_ctx_t *, bytecode_t *, function_code_t *, scope_chain_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: function.c:767
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_gt()

static HRESULT interp_gt ( script_ctx_t ctx)
static

Definition at line 2376 of file engine.c.

2377 {
2378  jsval_t l, r;
2379  BOOL b;
2380  HRESULT hres;
2381 
2382  r = stack_pop(ctx);
2383  l = stack_pop(ctx);
2384 
2385  TRACE("%s > %s\n", debugstr_jsval(l), debugstr_jsval(r));
2386 
2387  hres = less_eval(ctx, r, l, FALSE, &b);
2388  jsval_release(l);
2389  jsval_release(r);
2390  if(FAILED(hres))
2391  return hres;
2392 
2393  return stack_push(ctx, jsval_bool(b));
2394 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, BOOL *ret)
Definition: engine.c:2298
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_gteq()

static HRESULT interp_gteq ( script_ctx_t ctx)
static

Definition at line 2397 of file engine.c.

2398 {
2399  jsval_t l, r;
2400  BOOL b;
2401  HRESULT hres;
2402 
2403  r = stack_pop(ctx);
2404  l = stack_pop(ctx);
2405 
2406  TRACE("%s >= %s\n", debugstr_jsval(l), debugstr_jsval(r));
2407 
2408  hres = less_eval(ctx, l, r, TRUE, &b);
2409  jsval_release(l);
2410  jsval_release(r);
2411  if(FAILED(hres))
2412  return hres;
2413 
2414  return stack_push(ctx, jsval_bool(b));
2415 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, BOOL *ret)
Definition: engine.c:2298
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_ident()

static HRESULT interp_ident ( script_ctx_t ctx)
static

Definition at line 1317 of file engine.c.

1318 {
1319  const BSTR arg = get_op_bstr(ctx, 0);
1320 
1321  TRACE("%s\n", debugstr_w(arg));
1322 
1323  return identifier_value(ctx, arg);
1324 }
static HRESULT identifier_value(script_ctx_t *ctx, BSTR identifier)
Definition: engine.c:1260
OLECHAR * BSTR
Definition: compat.h:1942
#define debugstr_w
Definition: kernel32.h:32
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:718
#define TRACE(s)
Definition: solgame.cpp:4

◆ interp_identid()

static HRESULT interp_identid ( script_ctx_t ctx)
static

Definition at line 1327 of file engine.c.

1328 {
1329  const BSTR arg = get_op_bstr(ctx, 0);
1330  const unsigned flags = get_op_uint(ctx, 1);
1331 
1332  TRACE("%s %x\n", debugstr_w(arg), flags);
1333 
1334  return interp_identifier_ref(ctx, arg, flags);
1335 }
OLECHAR * BSTR
Definition: compat.h:1942
#define debugstr_w
Definition: kernel32.h:32
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:718
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static HRESULT interp_identifier_ref(script_ctx_t *ctx, BSTR identifier, unsigned flags)
Definition: engine.c:1232

◆ interp_identifier_ref()

static HRESULT interp_identifier_ref ( script_ctx_t ctx,
BSTR  identifier,
unsigned  flags 
)
static

Definition at line 1232 of file engine.c.

1233 {
1234  exprval_t exprval;
1235  HRESULT hres;
1236 
1237  hres = identifier_eval(ctx, identifier, &exprval);
1238  if(FAILED(hres))
1239  return hres;
1240 
1241  if(exprval.type == EXPRVAL_INVALID && (flags & fdexNameEnsure)) {
1242  DISPID id;
1243 
1244  hres = jsdisp_get_id(ctx->global, identifier, fdexNameEnsure, &id);
1245  if(FAILED(hres))
1246  return hres;
1247 
1248  exprval_set_disp_ref(&exprval, to_disp(ctx->global), id);
1249  }
1250 
1251  if(exprval.type == EXPRVAL_JSVAL || exprval.type == EXPRVAL_INVALID) {
1252  WARN("invalid ref\n");
1253  exprval_release(&exprval);
1255  }
1256 
1257  return stack_push_exprval(ctx, &exprval);
1258 }
enum exprval_t::@420 type
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT stack_push_exprval(script_ctx_t *ctx, exprval_t *val)
Definition: engine.c:193
static void exprval_set_exception(exprval_t *val, HRESULT hres)
Definition: engine.c:370
static void exprval_set_disp_ref(exprval_t *ref, IDispatch *obj, DISPID id)
Definition: engine.c:376
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLbitfield flags
Definition: glext.h:7161
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1067
static void exprval_release(exprval_t *val)
Definition: engine.c:354
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
static VARIANTARG static DISPID
Definition: ordinal.c:49
jsdisp_t * global
Definition: jscript.h:441
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:635
GLenum GLuint id
Definition: glext.h:5579
#define JS_E_OBJECT_EXPECTED
Definition: jscript.h:555

Referenced by interp_identid(), and interp_local_ref().

◆ interp_in()

static HRESULT interp_in ( script_ctx_t ctx)
static

Definition at line 1657 of file engine.c.

1658 {
1659  const WCHAR *str;
1660  jsstr_t *jsstr;
1661  jsval_t obj, v;
1662  DISPID id = 0;
1663  BOOL ret;
1664  HRESULT hres;
1665 
1666  TRACE("\n");
1667 
1668  obj = stack_pop(ctx);
1669  if(!is_object_instance(obj) || !get_object(obj)) {
1670  jsval_release(obj);
1672  }
1673 
1674  v = stack_pop(ctx);
1675  hres = to_flat_string(ctx, v, &jsstr, &str);
1676  jsval_release(v);
1677  if(FAILED(hres)) {
1678  IDispatch_Release(get_object(obj));
1679  return hres;
1680  }
1681 
1682  hres = disp_get_id(ctx, get_object(obj), str, NULL, 0, &id);
1683  IDispatch_Release(get_object(obj));
1684  jsstr_release(jsstr);
1685  if(SUCCEEDED(hres))
1686  ret = TRUE;
1687  else if(hres == DISP_E_UNKNOWNNAME)
1688  ret = FALSE;
1689  else
1690  return hres;
1691 
1692  return stack_push(ctx, jsval_bool(ret));
1693 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:191
#define TRUE
Definition: types.h:120
Definition: jsstr.h:39
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
Definition: engine.c:449
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
static VARIANTARG static DISPID
Definition: ordinal.c:49
const GLdouble * v
Definition: gl.h:2040
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
#define JS_E_OBJECT_EXPECTED
Definition: jscript.h:555
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_instanceof()

static HRESULT interp_instanceof ( script_ctx_t ctx)
static

Definition at line 1599 of file engine.c.

1600 {
1601  jsdisp_t *obj, *iter, *tmp = NULL;
1602  jsval_t prot, v;
1603  BOOL ret = FALSE;
1604  HRESULT hres;
1605 
1606  static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0};
1607 
1608  v = stack_pop(ctx);
1609  if(!is_object_instance(v) || !get_object(v)) {
1610  jsval_release(v);
1612  }
1613 
1615  IDispatch_Release(get_object(v));
1616  if(!obj) {
1617  FIXME("non-jsdisp objects not supported\n");
1618  return E_FAIL;
1619  }
1620 
1621  if(is_class(obj, JSCLASS_FUNCTION)) {
1623  }else {
1625  }
1627  if(FAILED(hres))
1628  return hres;
1629 
1630  v = stack_pop(ctx);
1631 
1632  if(is_object_instance(prot)) {
1633  if(is_object_instance(v))
1634  tmp = iface_to_jsdisp(get_object(v));
1635  for(iter = tmp; !ret && iter; iter = iter->prototype) {
1636  hres = disp_cmp(get_object(prot), to_disp(iter), &ret);
1637  if(FAILED(hres))
1638  break;
1639  }
1640 
1641  if(tmp)
1642  jsdisp_release(tmp);
1643  }else {
1644  FIXME("prototype is not an object\n");
1645  hres = E_FAIL;
1646  }
1647 
1648  jsval_release(prot);
1649  jsval_release(v);
1650  if(FAILED(hres))
1651  return hres;
1652 
1653  return stack_push(ctx, jsval_bool(ret));
1654 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:552
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static const WCHAR prototypeW[]
Definition: function.c:94
#define E_FAIL
Definition: ddrawi.h:102
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
Definition: engine.c:486
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:504
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
HRESULT hres
Definition: protocol.c:465
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1408
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
int ret
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:245
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1060
const GLdouble * v
Definition: gl.h:2040
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:440
jsdisp_t * prototype
Definition: jscript.h:240
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_int()

static HRESULT interp_int ( script_ctx_t ctx)
static

Definition at line 1356 of file engine.c.

1357 {
1358  const int arg = get_op_int(ctx, 0);
1359 
1360  TRACE("%d\n", arg);
1361 
1362  return stack_push(ctx, jsval_number(arg));
1363 }
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:730
#define TRACE(s)
Definition: solgame.cpp:4
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_jmp()

static HRESULT interp_jmp ( script_ctx_t ctx)
static

Definition at line 2561 of file engine.c.

2562 {
2563  const unsigned arg = get_op_uint(ctx, 0);
2564 
2565  TRACE("%u\n", arg);
2566 
2567  jmp_abs(ctx, arg);
2568  return S_OK;
2569 }
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:753
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ interp_jmp_z()

static HRESULT interp_jmp_z ( script_ctx_t ctx)
static

Definition at line 2571 of file engine.c.

2572 {
2573  const unsigned arg = get_op_uint(ctx, 0);
2574  BOOL b;
2575  jsval_t v;
2576  HRESULT hres;
2577 
2578  TRACE("\n");
2579 
2580  v = stack_pop(ctx);
2581  hres = to_boolean(v, &b);
2582  jsval_release(v);
2583  if(FAILED(hres))
2584  return hres;
2585 
2586  if(b)
2587  jmp_next(ctx);
2588  else
2589  jmp_abs(ctx, arg);
2590  return S_OK;
2591 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:753
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT to_boolean(jsval_t, BOOL *) DECLSPEC_HIDDEN
Definition: jsutils.c:472
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:748
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129

◆ interp_local()

static HRESULT interp_local ( script_ctx_t ctx)
static

Definition at line 1297 of file engine.c.

1298 {
1299  const int arg = get_op_int(ctx, 0);
1300  call_frame_t *frame = ctx->call_ctx;
1301  jsval_t copy;
1302  HRESULT hres;
1303 
1304  TRACE("%d: %s\n", arg, debugstr_w(local_name(frame, arg)));
1305 
1306  if(!frame->base_scope || !frame->base_scope->frame)
1307  return identifier_value(ctx, local_name(frame, arg));
1308 
1309  hres = jsval_copy(ctx->stack[local_off(frame, arg)], &copy);
1310  if(FAILED(hres))
1311  return hres;
1312 
1313  return stack_push(ctx, copy);
1314 }
Definition: jsval.h:54
static HRESULT identifier_value(script_ctx_t *ctx, BSTR identifier)
Definition: engine.c:1260
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:180
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:730
struct _call_frame_t * call_ctx
Definition: jscript.h:415
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
struct _call_frame_t * frame
Definition: engine.h:206
jsval_t * stack
Definition: jscript.h:431
scope_chain_t * base_scope
Definition: engine.h:226
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
static BSTR local_name(call_frame_t *frame, int ref)
Definition: engine.c:187
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_local_ref()

static HRESULT interp_local_ref ( script_ctx_t ctx)
static

Definition at line 1280 of file engine.c.

1281 {
1282  const int arg = get_op_int(ctx, 0);
1283  const unsigned flags = get_op_uint(ctx, 1);
1284  call_frame_t *frame = ctx->call_ctx;
1285  exprval_t ref;
1286 
1287  TRACE("%d\n", arg);
1288 
1289  if(!frame->base_scope || !frame->base_scope->frame)
1290  return interp_identifier_ref(ctx, local_name(frame, arg), flags);
1291 
1292  ref.type = EXPRVAL_STACK_REF;
1293  ref.u.off = local_off(frame, arg);
1294  return stack_push_exprval(ctx, &ref);
1295 }
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:180
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:730
struct _call_frame_t * call_ctx
Definition: jscript.h:415
static HRESULT stack_push_exprval(script_ctx_t *ctx, exprval_t *val)
Definition: engine.c:193
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
struct _call_frame_t * frame
Definition: engine.h:206
GLbitfield flags
Definition: glext.h:7161
scope_chain_t * base_scope
Definition: engine.h:226
static BSTR local_name(call_frame_t *frame, int ref)
Definition: engine.c:187
static HRESULT interp_identifier_ref(script_ctx_t *ctx, BSTR identifier, unsigned flags)
Definition: engine.c:1232

◆ interp_lshift()

static HRESULT interp_lshift ( script_ctx_t ctx)
static

Definition at line 2454 of file engine.c.

2455 {
2456  DWORD r;
2457  INT l;
2458  HRESULT hres;
2459 
2460  hres = stack_pop_uint(ctx, &r);
2461  if(FAILED(hres))
2462  return hres;
2463 
2464  hres = stack_pop_int(ctx, &l);
2465  if(FAILED(hres))
2466  return hres;
2467 
2468  return stack_push(ctx, jsval_number(l << (r&0x1f)));
2469 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int32_t INT
Definition: typedefs.h:56
r l[0]
Definition: byte_order.h:167
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT stack_pop_int(script_ctx_t *ctx, INT *r)
Definition: engine.c:170
static HRESULT stack_pop_uint(script_ctx_t *ctx, DWORD *r)
Definition: engine.c:175
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_lt()

static HRESULT interp_lt ( script_ctx_t ctx)
static

Definition at line 2334 of file engine.c.

2335 {
2336  jsval_t l, r;
2337  BOOL b;
2338  HRESULT hres;
2339 
2340  r = stack_pop(ctx);
2341  l = stack_pop(ctx);
2342 
2343  TRACE("%s < %s\n", debugstr_jsval(l), debugstr_jsval(r));
2344 
2345  hres = less_eval(ctx, l, r, FALSE, &b);
2346  jsval_release(l);
2347  jsval_release(r);
2348  if(FAILED(hres))
2349  return hres;
2350 
2351  return stack_push(ctx, jsval_bool(b));
2352 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, BOOL *ret)
Definition: engine.c:2298
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_lteq()

static HRESULT interp_lteq ( script_ctx_t ctx)
static

Definition at line 2355 of file engine.c.

2356 {
2357  jsval_t l, r;
2358  BOOL b;
2359  HRESULT hres;
2360 
2361  r = stack_pop(ctx);
2362  l = stack_pop(ctx);
2363 
2364  TRACE("%s <= %s\n", debugstr_jsval(l), debugstr_jsval(r));
2365 
2366  hres = less_eval(ctx, r, l, TRUE, &b);
2367  jsval_release(l);
2368  jsval_release(r);
2369  if(FAILED(hres))
2370  return hres;
2371 
2372  return stack_push(ctx, jsval_bool(b));
2373 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, BOOL *ret)
Definition: engine.c:2298
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_member()

static HRESULT interp_member ( script_ctx_t ctx)
static

Definition at line 1067 of file engine.c.

1068 {
1069  const BSTR arg = get_op_bstr(ctx, 0);
1070  IDispatch *obj;
1071  jsval_t v;
1072  DISPID id;
1073  HRESULT hres;
1074 
1075  TRACE("\n");
1076 
1077  hres = stack_pop_object(ctx, &obj);
1078  if(FAILED(hres))
1079  return hres;
1080 
1081  hres = disp_get_id(ctx, obj, arg, arg, 0, &id);
1082  if(SUCCEEDED(hres)) {
1083  hres = disp_propget(ctx, obj, id, &v);
1084  }else if(hres == DISP_E_UNKNOWNNAME) {
1085  v = jsval_undefined();
1086  hres = S_OK;
1087  }
1088  IDispatch_Release(obj);
1089  if(FAILED(hres))
1090  return hres;
1091 
1092  return stack_push(ctx, v);
1093 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static HRESULT stack_pop_object(script_ctx_t *ctx, IDispatch **r)
Definition: engine.c:152
OLECHAR * BSTR
Definition: compat.h:1942
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
Definition: engine.c:449
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
Definition: dispex.c:1458
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:718
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
const GLdouble * v
Definition: gl.h:2040
GLenum GLuint id
Definition: glext.h:5579
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_memberid()

static HRESULT interp_memberid ( script_ctx_t ctx)
static

Definition at line 1096 of file engine.c.

1097 {
1098  const unsigned arg = get_op_uint(ctx, 0);
1099  jsval_t objv, namev;
1100  const WCHAR *name;
1101  jsstr_t *name_str;
1102  IDispatch *obj;
1103  exprval_t ref;
1104  DISPID id;
1105  HRESULT hres;
1106 
1107  TRACE("%x\n", arg);
1108 
1109  namev = stack_pop(ctx);
1110  objv = stack_pop(ctx);
1111 
1112  hres = to_object(ctx, objv, &obj);
1113  jsval_release(objv);
1114  if(SUCCEEDED(hres)) {
1115  hres = to_flat_string(ctx, namev, &name_str, &name);
1116  if(FAILED(hres))
1117  IDispatch_Release(obj);
1118  }
1119  jsval_release(namev);
1120  if(FAILED(hres))
1121  return hres;
1122 
1123  hres = disp_get_id(ctx, obj, name, NULL, arg, &id);
1124  jsstr_release(name_str);
1125  if(SUCCEEDED(hres)) {
1126  ref.type = EXPRVAL_IDREF;
1127  ref.u.idref.disp = obj;
1128  ref.u.idref.id = id;
1129  }else {
1130  IDispatch_Release(obj);
1131  if(hres == DISP_E_UNKNOWNNAME && !(arg & fdexNameEnsure)) {
1133  hres = S_OK;
1134  }else {
1135  ERR("failed %08x\n", hres);
1136  return hres;
1137  }
1138  }
1139 
1140  return stack_push_exprval(ctx, &ref);
1141 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:191
Definition: jsstr.h:39
static HRESULT stack_push_exprval(script_ctx_t *ctx, exprval_t *val)
Definition: engine.c:193
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
static void exprval_set_exception(exprval_t *val, HRESULT hres)
Definition: engine.c:370
Definition: send.c:47
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, BSTR name_bstr, DWORD flags, DISPID *id)
Definition: engine.c:449
GLenum GLint ref
Definition: glext.h:6028
smooth NULL
Definition: ftsmooth.c:416
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:724
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define JS_E_INVALID_PROPERTY
Definition: jscript.h:533
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
Definition: name.c:38
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:816
GLenum GLuint id
Definition: glext.h:5579
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
#define SUCCEEDED(hr)
Definition: intsafe.h:57
GLuint const GLchar * name
Definition: glext.h:6031

◆ interp_minus()

static HRESULT interp_minus ( script_ctx_t ctx)
static

Definition at line 2039 of file engine.c.

2040 {
2041  double n;
2042  HRESULT hres;
2043 
2044  TRACE("\n");
2045 
2046  hres = stack_pop_number(ctx, &n);
2047  if(FAILED(hres))
2048  return hres;
2049 
2050  return stack_push(ctx, jsval_number(-n));
2051 }
GLdouble n
Definition: glext.h:7729
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT stack_pop_number(script_ctx_t *ctx, double *r)
Definition: engine.c:141
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_mod()

static HRESULT interp_mod ( script_ctx_t ctx)
static

Definition at line 1825 of file engine.c.

1826 {
1827  double l, r;
1828  HRESULT hres;
1829 
1830  TRACE("\n");
1831 
1832  hres = stack_pop_number(ctx, &r);
1833  if(FAILED(hres))
1834  return hres;
1835 
1836  hres = stack_pop_number(ctx, &l);
1837  if(FAILED(hres))
1838  return hres;
1839 
1840  return stack_push(ctx, jsval_number(fmod(l, r)));
1841 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
r l[0]
Definition: byte_order.h:167
_Check_return_ double __cdecl fmod(_In_ double x, _In_ double y)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT stack_pop_number(script_ctx_t *ctx, double *r)
Definition: engine.c:141
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_mul()

static HRESULT interp_mul ( script_ctx_t ctx)
static

Definition at line 1787 of file engine.c.

1788 {
1789  double l, r;
1790  HRESULT hres;
1791 
1792  TRACE("\n");
1793 
1794  hres = stack_pop_number(ctx, &r);
1795  if(FAILED(hres))
1796  return hres;
1797 
1798  hres = stack_pop_number(ctx, &l);
1799  if(FAILED(hres))
1800  return hres;
1801 
1802  return stack_push(ctx, jsval_number(l*r));
1803 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static HRESULT stack_pop_number(script_ctx_t *ctx, double *r)
Definition: engine.c:141
static jsval_t jsval_number(double n)
Definition: jsval.h:144
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_neg()

static HRESULT interp_neg ( script_ctx_t ctx)
static

Definition at line 2436 of file engine.c.

2437 {
2438  jsval_t v;
2439  BOOL b;
2440  HRESULT hres;
2441 
2442  TRACE("\n");
2443 
2444  v = stack_pop(ctx);
2445  hres = to_boolean(v, &b);
2446  jsval_release(v);
2447  if(FAILED(hres))
2448  return hres;
2449 
2450  return stack_push(ctx, jsval_bool(!b));
2451 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT to_boolean(jsval_t, BOOL *) DECLSPEC_HIDDEN
Definition: jsutils.c:472
const GLdouble * v
Definition: gl.h:2040
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:129
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:69

◆ interp_neq()

static HRESULT interp_neq ( script_ctx_t ctx)
static

Definition at line 2235 of file engine.c.

2236 {
2237  jsval_t l, r;
2238  BOOL b;
2239  HRESULT hres;
2240 
2241  r = stack_pop(ctx);
2242  l = stack_pop(ctx);
2243 
2244  TRACE("%s != %s\n", debugstr_jsval(l), debugstr_jsval(r));
2245 
2246  hres = equal_values(ctx, l, r, &b);
2247  jsval_release(l);
2248  jsval_release(r);
2249  if(FAILED(hres))
2250  return hres;
2251 
2252  return stack_push(ctx, jsval_bool(!b));
2253 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:191
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int BOOL
Definition: ntddk_ex.h:94
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT