ReactOS  0.4.13-dev-257-gfabbd7c
engine.c File Reference
#include "config.h"
#include "wine/port.h"
#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 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 2640 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 1690 of file engine.c.

1691 {
1692  jsval_t r, l;
1693  HRESULT hres;
1694 
1695  hres = to_primitive(ctx, lval, &l, NO_HINT);
1696  if(FAILED(hres))
1697  return hres;
1698 
1699  hres = to_primitive(ctx, rval, &r, NO_HINT);
1700  if(FAILED(hres)) {
1701  jsval_release(l);
1702  return hres;
1703  }
1704 
1705  if(is_string(l) || is_string(r)) {
1706  jsstr_t *lstr, *rstr = NULL;
1707 
1708  hres = to_string(ctx, l, &lstr);
1709  if(SUCCEEDED(hres))
1710  hres = to_string(ctx, r, &rstr);
1711 
1712  if(SUCCEEDED(hres)) {
1713  jsstr_t *ret_str;
1714 
1715  ret_str = jsstr_concat(lstr, rstr);
1716  if(ret_str)
1717  *ret = jsval_string(ret_str);
1718  else
1719  hres = E_OUTOFMEMORY;
1720  }
1721 
1722  jsstr_release(lstr);
1723  if(rstr)
1725  }else {
1726  double nl, nr;
1727 
1728  hres = to_number(ctx, l, &nl);
1729  if(SUCCEEDED(hres)) {
1730  hres = to_number(ctx, r, &nr);
1731  if(SUCCEEDED(hres))
1732  *ret = jsval_number(nl+nr);
1733  }
1734  }
1735 
1736  jsval_release(r);
1737  jsval_release(l);
1738  return hres;
1739 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:601
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:601
#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:396

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 2839 of file engine.c.

2840 {
2842  exprval_t exprval;
2843  IDispatch *disp;
2844  jsval_t v;
2845  HRESULT hres;
2846 
2847  hres = identifier_eval(ctx, func->event_target, &exprval);
2848  if(FAILED(hres))
2849  return hres;
2850 
2851  hres = exprval_to_value(ctx, &exprval, &v);
2852  if(FAILED(hres))
2853  return hres;
2854 
2855  if(!is_object_instance(v)) {
2856  FIXME("Can't bind to %s\n", debugstr_jsval(v));
2857  jsval_release(v);
2858  }
2859 
2860  disp = get_object(v);
2861  hres = IDispatch_QueryInterface(disp, &IID_IBindEventHandler, (void**)&target);
2862  if(SUCCEEDED(hres)) {
2863  hres = IBindEventHandler_BindHandler(target, func->name, (IDispatch*)&func_obj->IDispatchEx_iface);
2864  IBindEventHandler_Release(target);
2865  if(FAILED(hres))
2866  WARN("BindEvent failed: %08x\n", hres);
2867  }else {
2868  FIXME("No IBindEventHandler, not yet supported binding\n");
2869  }
2870 
2871  IDispatch_Release(disp);
2872  return hres;
2873 }
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:189
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
#define WARN(fmt,...)
Definition: debug.h:111
IDispatchEx IDispatchEx_iface
Definition: jscript.h:227
#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:336
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:633
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:33

Referenced by exec_source().

◆ clear_acc()

static void clear_acc ( script_ctx_t ctx)
inlinestatic

Definition at line 393 of file engine.c.

394 {
395  jsval_release(ctx->acc);
396  ctx->acc = jsval_undefined();
397 }
void jsval_release(jsval_t val)
Definition: jsutils.c:189
jsval_t acc
Definition: jscript.h:429
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 428 of file engine.c.

429 {
430  memset(&ctx->ei.ei, 0, sizeof(ctx->ei.ei));
431  jsval_release(ctx->ei.val);
432  ctx->ei.val = jsval_undefined();
433 }
void jsval_release(jsval_t val)
Definition: jsutils.c:189
jsval_t val
Definition: jscript.h:396
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
EXCEPINFO ei
Definition: jscript.h:395
#define memset(x, y, z)
Definition: compat.h:39
jsexcept_t ei
Definition: jscript.h:420

Referenced by disp_call(), disp_call_value(), disp_propget(), disp_propput(), DispatchEx_InvokeEx(), exec_global_code(), index_from_val(), JScriptParse_ParseScriptText(), 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 571 of file engine.c.

572 {
573  unsigned i;
574  HRESULT hres;
575 
576  if(!frame->base_scope || !frame->base_scope->frame)
577  return S_OK;
578 
579  TRACE("detaching %p\n", frame);
580 
581  assert(frame == frame->base_scope->frame);
582  assert(frame->variable_obj == frame->base_scope->jsobj);
583 
584  if(!from_release && !frame->arguments_obj) {
585  hres = setup_arguments_object(ctx, frame);
586  if(FAILED(hres))
587  return hres;
588  }
589 
590  frame->base_scope->frame = NULL;
591 
592  for(i = 0; i < frame->function->locals_cnt; i++) {
594  ctx->stack[local_off(frame, frame->function->locals[i].ref)]);
595  if(FAILED(hres))
596  return hres;
597  }
598 
599  return S_OK;
600 }
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:178
#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:426
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:1365
HRESULT setup_arguments_object(script_ctx_t *, call_frame_t *) DECLSPEC_HIDDEN
Definition: function.c:162
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 484 of file engine.c.

485 {
486  IObjectIdentity *identity;
487  IUnknown *unk1, *unk2;
488  HRESULT hres;
489 
490  if(disp1 == disp2) {
491  *ret = TRUE;
492  return S_OK;
493  }
494 
495  if(!disp1 || !disp2) {
496  *ret = FALSE;
497  return S_OK;
498  }
499 
500  hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
501  if(FAILED(hres))
502  return hres;
503 
504  hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2);
505  if(FAILED(hres)) {
506  IUnknown_Release(unk1);
507  return hres;
508  }
509 
510  if(unk1 == unk2) {
511  *ret = TRUE;
512  }else {
513  hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
514  if(SUCCEEDED(hres)) {
515  hres = IObjectIdentity_IsEqualObject(identity, unk2);
516  IObjectIdentity_Release(identity);
517  *ret = hres == S_OK;
518  }else {
519  *ret = FALSE;
520  }
521  }
522 
523  IUnknown_Release(unk1);
524  IUnknown_Release(unk2);
525  return S_OK;
526 }
#define TRUE
Definition: types.h:120
static DWORD unk1
Definition: cursoricon.c:1521
static D3DRMMATRIX4D identity
Definition: frame.c:29
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
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 447 of file engine.c.

448 {
449  IDispatchEx *dispex;
450  jsdisp_t *jsdisp;
451  BSTR bstr;
452  HRESULT hres;
453 
454  jsdisp = iface_to_jsdisp(disp);
455  if(jsdisp) {
456  hres = jsdisp_get_id(jsdisp, name, flags, id);
457  jsdisp_release(jsdisp);
458  return hres;
459  }
460 
461  if(name_bstr) {
462  bstr = name_bstr;
463  }else {
464  bstr = SysAllocString(name);
465  if(!bstr)
466  return E_OUTOFMEMORY;
467  }
468 
469  *id = 0;
470  hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
471  if(SUCCEEDED(hres)) {
472  hres = IDispatchEx_GetDispID(dispex, bstr, make_grfdex(ctx, flags|fdexNameCaseSensitive), id);
473  IDispatchEx_Release(dispex);
474  }else {
475  TRACE("using IDispatch\n");
476  hres = IDispatch_GetIDsOfNames(disp, &IID_NULL, &bstr, 1, 0, id);
477  }
478 
479  if(name_bstr != bstr)
480  SysFreeString(bstr);
481  return hres;
482 }
disp
Definition: i386-dis.c:3181
OLECHAR * BSTR
Definition: compat.h:1934
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
static DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
Definition: jscript.h:520
#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:93
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1088
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
Definition: name.c:36
#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 2800 of file engine.c.

2801 {
2802  call_frame_t *frame;
2803  jsop_t op;
2804  HRESULT hres = S_OK;
2805 
2806  TRACE("\n");
2807 
2808  while(1) {
2809  frame = ctx->call_ctx;
2810  op = frame->bytecode->instrs[frame->ip].op;
2811  hres = op_funcs[op](ctx);
2812  if(FAILED(hres)) {
2813  hres = unwind_exception(ctx, hres);
2814  if(FAILED(hres))
2815  return hres;
2816  }else if(frame->ip == -1) {
2817  const DWORD return_to_interp = frame->flags & EXEC_RETURN_TO_INTERP;
2818 
2819  assert(ctx->stack_top == frame->stack_base);
2820  assert(frame->scope == frame->base_scope);
2821 
2822  if(return_to_interp) {
2823  jsval_release(ctx->acc);
2824  ctx->acc = steal_ret(frame);
2825  }else if(r) {
2826  *r = steal_ret(frame);
2827  }
2828  pop_call_frame(ctx);
2829  if(!return_to_interp)
2830  break;
2831  }else {
2832  frame->ip += op_move[op];
2833  }
2834  }
2835 
2836  return S_OK;
2837 }
void jsval_release(jsval_t val)
Definition: jsutils.c:189
DWORD flags
Definition: engine.h:234
static jsval_t steal_ret(call_frame_t *frame)
Definition: engine.c:386
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:2654
#define assert(x)
Definition: debug.h:53
struct _call_frame_t * call_ctx
Definition: jscript.h:410
#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:429
#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:428
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:2648
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:2723
static const op_func_t op_funcs[]
Definition: engine.c:2642
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 2128 of file engine.c.

2129 {
2130  if(jsval_type(lval) == jsval_type(rval) || (is_number(lval) && is_number(rval)))
2131  return jsval_strict_equal(lval, rval, ret);
2132 
2133  /* FIXME: NULL disps should be handled in more general way */
2134  if(is_object_instance(lval) && !get_object(lval))
2135  return equal_values(ctx, jsval_null(), rval, ret);
2137  return equal_values(ctx, lval, jsval_null(), ret);
2138 
2139  if((is_null(lval) && is_undefined(rval)) || (is_undefined(lval) && is_null(rval))) {
2140  *ret = TRUE;
2141  return S_OK;
2142  }
2143 
2144  if(is_string(lval) && is_number(rval)) {
2145  double n;
2146  HRESULT hres;
2147 
2148  hres = to_number(ctx, lval, &n);
2149  if(FAILED(hres))
2150  return hres;
2151 
2152  /* FIXME: optimize */
2153  return equal_values(ctx, jsval_number(n), rval, ret);
2154  }
2155 
2156  if(is_string(rval) && is_number(lval)) {
2157  double n;
2158  HRESULT hres;
2159 
2160  hres = to_number(ctx, rval, &n);
2161  if(FAILED(hres))
2162  return hres;
2163 
2164  /* FIXME: optimize */
2165  return equal_values(ctx, lval, jsval_number(n), ret);
2166  }
2167 
2168  if(is_bool(rval))
2169  return equal_values(ctx, lval, jsval_number(get_bool(rval) ? 1 : 0), ret);
2170 
2171  if(is_bool(lval))
2172  return equal_values(ctx, jsval_number(get_bool(lval) ? 1 : 0), rval, ret);
2173 
2174 
2175  if(is_object_instance(rval) && (is_string(lval) || is_number(lval))) {
2176  jsval_t prim;
2177  HRESULT hres;
2178 
2179  hres = to_primitive(ctx, rval, &prim, NO_HINT);
2180  if(FAILED(hres))
2181  return hres;
2182 
2183  hres = equal_values(ctx, lval, prim, ret);
2185  return hres;
2186  }
2187 
2188 
2189  if(is_object_instance(lval) && (is_string(rval) || is_number(rval))) {
2190  jsval_t prim;
2191  HRESULT hres;
2192 
2193  hres = to_primitive(ctx, lval, &prim, NO_HINT);
2194  if(FAILED(hres))
2195  return hres;
2196 
2197  hres = equal_values(ctx, prim, rval, ret);
2199  return hres;
2200  }
2201 
2202 
2203  *ret = FALSE;
2204  return S_OK;
2205 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#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:601
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:601
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:529
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:2128
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:396

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 2952 of file engine.c.

2954 {
2955  call_frame_t *frame;
2956  unsigned i;
2957  HRESULT hres;
2958 
2959  for(i = 0; i < function->func_cnt; i++) {
2960  jsdisp_t *func_obj;
2961 
2962  if(!function->funcs[i].event_target)
2963  continue;
2964 
2965  hres = create_source_function(ctx, bytecode, function->funcs+i, scope, &func_obj);
2966  if(FAILED(hres))
2967  return hres;
2968 
2969  hres = bind_event_target(ctx, function->funcs+i, func_obj);
2970  jsdisp_release(func_obj);
2971  if(FAILED(hres))
2972  return hres;
2973  }
2974 
2975  if(flags & (EXEC_GLOBAL | EXEC_EVAL)) {
2976  for(i=0; i < function->var_cnt; i++) {
2977  TRACE("[%d] %s %d\n", i, debugstr_w(function->variables[i].name), function->variables[i].func_id);
2978  if(function->variables[i].func_id != -1) {
2979  jsdisp_t *func_obj;
2980 
2981  hres = create_source_function(ctx, bytecode, function->funcs+function->variables[i].func_id, scope, &func_obj);
2982  if(FAILED(hres))
2983  return hres;
2984 
2985  hres = jsdisp_propput_name(variable_obj, function->variables[i].name, jsval_obj(func_obj));
2986  jsdisp_release(func_obj);
2987  }else if(!(flags & EXEC_GLOBAL) || !lookup_global_members(ctx, function->variables[i].name, NULL)) {
2988  DISPID id = 0;
2989 
2990  hres = jsdisp_get_id(variable_obj, function->variables[i].name, fdexNameEnsure, &id);
2991  if(FAILED(hres))
2992  return hres;
2993  }
2994  }
2995  }
2996 
2997  /* ECMA-262 3rd Edition 11.2.3.7 */
2998  if(this_obj) {
2999  jsdisp_t *jsthis;
3000 
3001  jsthis = iface_to_jsdisp(this_obj);
3002  if(jsthis) {
3003  if(jsthis->builtin_info->class == JSCLASS_GLOBAL || jsthis->builtin_info->class == JSCLASS_NONE)
3004  this_obj = NULL;
3005  jsdisp_release(jsthis);
3006  }
3007  }
3008 
3009  if(ctx->call_ctx && (flags & EXEC_EVAL)) {
3010  hres = detach_variable_object(ctx, ctx->call_ctx, FALSE);
3011  if(FAILED(hres))
3012  return hres;
3013  }
3014 
3015  frame = heap_alloc_zero(sizeof(*frame));
3016  if(!frame)
3017  return E_OUTOFMEMORY;
3018 
3019  frame->function = function;
3020  frame->ret = jsval_undefined();
3021  frame->argc = argc;
3022  frame->bytecode = bytecode_addref(bytecode);
3023 
3024  if(!(flags & (EXEC_GLOBAL|EXEC_EVAL))) {
3025  hres = setup_scope(ctx, frame, scope, variable_obj, argc, argv);
3026  if(FAILED(hres)) {
3027  release_bytecode(frame->bytecode);
3028  heap_free(frame);
3029  return hres;
3030  }
3031  }else if(scope) {
3032  frame->base_scope = frame->scope = scope_addref(scope);
3033  }
3034 
3035  frame->ip = function->instr_off;
3036  frame->stack_base = ctx->stack_top;
3037  if(this_obj)
3038  frame->this_obj = this_obj;
3039  else if(ctx->host_global)
3040  frame->this_obj = ctx->host_global;
3041  else
3042  frame->this_obj = to_disp(ctx->global);
3043  IDispatch_AddRef(frame->this_obj);
3044 
3045  if(function_instance)
3046  frame->function_instance = jsdisp_addref(function_instance);
3047 
3048  frame->flags = flags;
3049  frame->variable_obj = jsdisp_addref(variable_obj);
3050 
3051  frame->prev_frame = ctx->call_ctx;
3052  ctx->call_ctx = frame;
3053 
3055  /*
3056  * We're called directly from interpreter, so we may just setup call frame and return.
3057  * Already running interpreter will take care of execution.
3058  */
3059  if(r)
3060  *r = jsval_undefined();
3061  return S_OK;
3062  }
3063 
3064  return enter_bytecode(ctx, r);
3065 }
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:2875
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:571
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:2839
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:238
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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:424
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:2800
#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:428
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:258
GLbitfield flags
Definition: glext.h:7161
#define EXEC_GLOBAL
Definition: engine.h:248
jsclass_t class
Definition: jscript.h:215
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1088
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:241
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:602
scope_chain_t * base_scope
Definition: engine.h:226
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
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:264
jsdisp_t * global
Definition: jscript.h:436
HRESULT create_source_function(script_ctx_t *, bytecode_t *, function_code_t *, scope_chain_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: function.c:699
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
void release_bytecode(bytecode_t *code)
Definition: compile.c:2223
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1365
unsigned argc
Definition: engine.h:236
struct _function_code_t::@417 * variables
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(), invoke_source(), 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 313 of file engine.c.

314 {
315  switch(ref->type) {
316  case EXPRVAL_STACK_REF: {
317  jsval_t v = ctx->stack[ref->u.off];
318 
319  if(!is_object_instance(v)) {
320  FIXME("invoke %s\n", debugstr_jsval(v));
321  return E_FAIL;
322  }
323 
324  return disp_call_value(ctx, get_object(v), NULL, flags, argc, argv, r);
325  }
326  case EXPRVAL_IDREF:
327  return disp_call(ctx, ref->u.idref.disp, ref->u.idref.id, flags, argc, argv, r);
328  default:
329  assert(0);
330  return E_FAIL;
331  }
332 }
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:1157
#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:426
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:1249
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33

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 300 of file engine.c.

301 {
302  switch(ref->type) {
303  case EXPRVAL_STACK_REF:
304  return jsval_copy(ctx->stack[ref->u.off], r);
305  case EXPRVAL_IDREF:
306  return disp_propget(ctx, ref->u.idref.disp, ref->u.idref.id, r);
307  default:
308  assert(0);
309  return E_FAIL;
310  }
311 }
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:229
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
Definition: dispex.c:1479
jsval_t * stack
Definition: jscript.h:426

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 284 of file engine.c.

285 {
286  switch(ref->type) {
287  case EXPRVAL_STACK_REF: {
288  jsval_t *r = ctx->stack + ref->u.off;
289  jsval_release(*r);
290  return jsval_copy(v, r);
291  }
292  case EXPRVAL_IDREF:
293  return disp_propput(ctx, ref->u.idref.disp, ref->u.idref.id, v);
294  default:
295  assert(0);
296  return E_FAIL;
297  }
298 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:229
HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val)
Definition: dispex.c:1380
jsval_t * stack
Definition: jscript.h:426
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 352 of file engine.c.

353 {
354  switch(val->type) {
355  case EXPRVAL_JSVAL:
356  jsval_release(val->u.val);
357  return;
358  case EXPRVAL_IDREF:
359  if(val->u.idref.disp)
360  IDispatch_Release(val->u.idref.disp);
361  return;
362  case EXPRVAL_STACK_REF:
363  case EXPRVAL_INVALID:
364  return;
365  }
366 }
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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 374 of file engine.c.

375 {
376  ref->type = EXPRVAL_IDREF;
377 #ifdef __REACTOS__ /* FIXME: Inspect */
378  IDispatch_AddRef(obj);
379  ref->u.idref.disp = obj;
380 #else
381  IDispatch_AddRef(ref->u.idref.disp = obj);
382 #endif
383  ref->u.idref.id = id;
384 }
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 368 of file engine.c.

369 {
370  val->type = EXPRVAL_INVALID;
371  val->u.hres = hres;
372 }
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 336 of file engine.c.

337 {
338  HRESULT hres;
339 
340  if(ref->type == EXPRVAL_JSVAL) {
341  *r = ref->u.val;
342  return S_OK;
343  }
344 
345  hres = exprval_propget(ctx, ref, r);
346 
347  if(ref->type == EXPRVAL_IDREF)
348  IDispatch_Release(ref->u.idref.disp);
349  return hres;
350 }
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:300
#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 716 of file engine.c.

717 {
718  call_frame_t *frame = ctx->call_ctx;
719  return frame->bytecode->instrs[frame->ip].u.arg[i].bstr;
720 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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::@416 u

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

◆ get_op_double()

static double get_op_double ( script_ctx_t ctx)
inlinestatic

Definition at line 740 of file engine.c.

741 {
742  call_frame_t *frame = ctx->call_ctx;
743  return frame->bytecode->instrs[frame->ip].u.dbl;
744 }
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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::@416 u

Referenced by interp_double().

◆ get_op_int()

static unsigned get_op_int ( script_ctx_t ctx,
int  i 
)
inlinestatic

Definition at line 728 of file engine.c.

729 {
730  call_frame_t *frame = ctx->call_ctx;
731  return frame->bytecode->instrs[frame->ip].u.arg[i].lng;
732 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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::@416 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 734 of file engine.c.

735 {
736  call_frame_t *frame = ctx->call_ctx;
737  return frame->bytecode->instrs[frame->ip].u.arg[i].str;
738 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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::@416 u

Referenced by 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 722 of file engine.c.

723 {
724  call_frame_t *frame = ctx->call_ctx;
725  return frame->bytecode->instrs[frame->ip].u.arg[i].uint;
726 }
instr_arg_t arg[2]
Definition: engine.h:129
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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
union instr_t::@416 u
unsigned uint
Definition: engine.h:112

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 633 of file engine.c.

634 {
635  scope_chain_t *scope;
637  DISPID id = 0;
638  HRESULT hres;
639 
640  TRACE("%s\n", debugstr_w(identifier));
641 
642  if(ctx->call_ctx) {
643  for(scope = ctx->call_ctx->scope; scope; scope = scope->next) {
644  if(scope->frame) {
645  function_code_t *func = scope->frame->function;
646  local_ref_t *ref = lookup_local(func, identifier);
647  static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0};
648 
649  if(ref) {
650  ret->type = EXPRVAL_STACK_REF;
651  ret->u.off = local_off(scope->frame, ref->ref);
652  TRACE("returning ref %d for %d\n", ret->u.off, ref->ref);
653  return S_OK;
654  }
655 
656  if(!strcmpW(identifier, argumentsW)) {
657  hres = detach_variable_object(ctx, scope->frame, FALSE);
658  if(FAILED(hres))
659  return hres;
660  }
661  }
662  if(scope->jsobj)
663  hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
664  else
665  hres = disp_get_id(ctx, scope->obj, identifier, identifier, fdexNameImplicit, &id);
666  if(SUCCEEDED(hres)) {
667  exprval_set_disp_ref(ret, scope->obj, id);
668  return S_OK;
669  }
670  }
671  }
672 
673  hres = jsdisp_get_id(ctx->global, identifier, 0, &id);
674  if(SUCCEEDED(hres)) {
676  return S_OK;
677  }
678 
679  for(item = ctx->named_items; item; item = item->next) {
680  if((item->flags & SCRIPTITEM_ISVISIBLE) && !strcmpW(item->name, identifier)) {
681  if(!item->disp) {
682  IUnknown *unk;
683 
684  if(!ctx->site)
685  break;
686 
687  hres = IActiveScriptSite_GetItemInfo(ctx->site, identifier,
688  SCRIPTINFO_IUNKNOWN, &unk, NULL);
689  if(FAILED(hres)) {
690  WARN("GetItemInfo failed: %08x\n", hres);
691  break;
692  }
693 
694  hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
695  IUnknown_Release(unk);
696  if(FAILED(hres)) {
697  WARN("object does not implement IDispatch\n");
698  break;
699  }
700  }
701 
702  IDispatch_AddRef(item->disp);
703  ret->type = EXPRVAL_JSVAL;
704  ret->u.val = jsval_disp(item->disp);
705  return S_OK;
706  }
707  }
708 
709  if(lookup_global_members(ctx, identifier, ret))
710  return S_OK;
711 
713  return S_OK;
714 }
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:571
jsdisp_t * jsobj
Definition: engine.h:204
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:178
#define WARN(fmt,...)
Definition: debug.h:111
IDispatch * obj
Definition: engine.h:205
struct _call_frame_t * call_ctx
Definition: jscript.h:410
static void exprval_set_exception(exprval_t *val, HRESULT hres)
Definition: engine.c:368
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:447
#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:374
#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:1088
local_ref_t * lookup_local(const function_code_t *function, const WCHAR *identifier)
Definition: engine.c:627
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:241
static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:602
#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:73
IActiveScriptSite * site
Definition: jscript.h:412
jsdisp_t * global
Definition: jscript.h:436
#define JS_E_UNDEFINED_VARIABLE
Definition: jscript.h:558
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
named_item_t * named_items
Definition: jscript.h:411
#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 1258 of file engine.c.

1259 {
1260  exprval_t exprval;
1261  jsval_t v;
1262  HRESULT hres;
1263 
1264  hres = identifier_eval(ctx, identifier, &exprval);
1265  if(FAILED(hres))
1266  return hres;
1267 
1268  if(exprval.type == EXPRVAL_INVALID)
1269  return throw_type_error(ctx, exprval.u.hres, identifier);
1270 
1271  hres = exprval_to_value(ctx, &exprval, &v);
1272  if(FAILED(hres))
1273  return hres;
1274 
1275  return stack_push(ctx, v);
1276 }
Definition: jsval.h:54
union exprval_t::@414 u
enum exprval_t::@413 type
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:336
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:633
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
HRESULT hres
Definition: engine.c:63
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

Referenced by interp_ident(), and interp_local().

◆ interp_add()

static HRESULT interp_add ( script_ctx_t ctx)
static

Definition at line 1742 of file engine.c.

1743 {
1744  jsval_t l, r, ret;
1745  HRESULT hres;
1746 
1747  r = stack_pop(ctx);
1748  l = stack_pop(ctx);
1749 
1750  TRACE("%s + %s\n", debugstr_jsval(l), debugstr_jsval(r));
1751 
1752  hres = add_eval(ctx, l, r, &ret);
1753  jsval_release(l);
1754  jsval_release(r);
1755  if(FAILED(hres))
1756  return hres;
1757 
1758  return stack_push(ctx, ret);
1759 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:127
static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsval_t *ret)
Definition: engine.c:1690
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_and()

static HRESULT interp_and ( script_ctx_t ctx)
static

Definition at line 1574 of file engine.c.

1575 {
1576  INT l, r;
1577  HRESULT hres;
1578 
1579  TRACE("\n");
1580 
1581  hres = stack_pop_int(ctx, &r);
1582  if(FAILED(hres))
1583  return hres;
1584 
1585  hres = stack_pop_int(ctx, &l);
1586  if(FAILED(hres))
1587  return hres;
1588 
1589  return stack_push(ctx, jsval_number(l&r));
1590 }
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:168
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:67

◆ interp_array()

static HRESULT interp_array ( script_ctx_t ctx)
static

Definition at line 1023 of file engine.c.

1024 {
1025  jsstr_t *name_str;
1026  const WCHAR *name;
1027  jsval_t v, namev;
1028  IDispatch *obj;
1029  DISPID id;
1030  HRESULT hres;
1031 
1032  TRACE("\n");
1033 
1034  namev = stack_pop(ctx);
1035 
1036  hres = stack_pop_object(ctx, &obj);
1037  if(FAILED(hres)) {
1038  jsval_release(namev);
1039  return hres;
1040  }
1041 
1042  hres = to_flat_string(ctx, namev, &name_str, &name);
1043  jsval_release(namev);
1044  if(FAILED(hres)) {
1045  IDispatch_Release(obj);
1046  return hres;
1047  }
1048 
1049  hres = disp_get_id(ctx, obj, name, NULL, 0, &id);
1050  jsstr_release(name_str);
1051  if(SUCCEEDED(hres)) {
1052  hres = disp_propget(ctx, obj, id, &v);
1053  }else if(hres == DISP_E_UNKNOWNNAME) {
1054  v = jsval_undefined();
1055  hres = S_OK;
1056  }
1057  IDispatch_Release(obj);
1058  if(FAILED(hres))
1059  return hres;
1060 
1061  return stack_push(ctx, v);
1062 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
Definition: jsstr.h:39
static HRESULT stack_pop_object(script_ctx_t *ctx, IDispatch **r)
Definition: engine.c:150
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:447
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
Definition: dispex.c:1479
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:36
GLenum GLuint id
Definition: glext.h:5579
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67
GLuint const GLchar * name
Definition: glext.h:6031

◆ interp_assign()

static HRESULT interp_assign ( script_ctx_t ctx)
static

Definition at line 2501 of file engine.c.

2502 {
2503  exprval_t ref;
2504  jsval_t v;
2505  HRESULT hres;
2506 
2507  TRACE("\n");
2508 
2509  v = stack_pop(ctx);
2510 
2511  if(!stack_pop_exprval(ctx, &ref)) {
2512  jsval_release(v);
2514  }
2515 
2516  hres = exprval_propput(ctx, &ref, v);
2517  exprval_release(&ref);
2518  if(FAILED(hres)) {
2519  jsval_release(v);
2520  return hres;
2521  }
2522 
2523  return stack_push(ctx, v);
2524 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
Definition: send.c:47
static HRESULT exprval_propput(script_ctx_t *ctx, exprval_t *ref, jsval_t v)
Definition: engine.c:284
#define JS_E_ILLEGAL_ASSIGN
Definition: jscript.h:557
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:277
static void exprval_release(exprval_t *val)
Definition: engine.c:352
HRESULT throw_reference_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:423
const GLdouble * v
Definition: gl.h:2040
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_assign_call()

static HRESULT interp_assign_call ( script_ctx_t ctx)
static

Definition at line 2527 of file engine.c.

2528 {
2529  const unsigned argc = get_op_uint(ctx, 0);
2530  exprval_t ref;
2531  jsval_t v;
2532  HRESULT hres;
2533 
2534  TRACE("%u\n", argc);
2535 
2536  if(!stack_topn_exprval(ctx, argc+1, &ref))
2538 
2540  if(FAILED(hres))
2541  return hres;
2542 
2543  v = stack_pop(ctx);
2544  stack_popn(ctx, argc+2);
2545  return stack_push(ctx, v);
2546 }
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:313
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:133
Definition: send.c:47
#define JS_E_ILLEGAL_ASSIGN
Definition: jscript.h:557
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:722
#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:423
static BOOL stack_topn_exprval(script_ctx_t *ctx, unsigned n, exprval_t *r)
Definition: engine.c:221
const GLdouble * v
Definition: gl.h:2040
static jsval_t * stack_args(script_ctx_t *ctx, unsigned n)
Definition: engine.c:119
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_bneg()

static HRESULT interp_bneg ( script_ctx_t ctx)
static

Definition at line 2412 of file engine.c.

2413 {
2414  jsval_t v;
2415  INT i;
2416  HRESULT hres;
2417 
2418  TRACE("\n");
2419 
2420  v = stack_pop(ctx);
2421  hres = to_int32(ctx, v, &i);
2422  jsval_release(v);
2423  if(FAILED(hres))
2424  return hres;
2425 
2426  return stack_push(ctx, jsval_number(~i));
2427 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:657
#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:127
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:67

◆ interp_bool()

static HRESULT interp_bool ( script_ctx_t ctx)
static

Definition at line 1344 of file engine.c.

1345 {
1346  const int arg = get_op_int(ctx, 0);
1347 
1348  TRACE("%s\n", arg ? "true" : "false");
1349 
1350  return stack_push(ctx, jsval_bool(arg));
1351 }
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:728
#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:67

◆ interp_call()

static HRESULT interp_call ( script_ctx_t ctx)
static

Definition at line 1185 of file engine.c.

1186 {
1187  const unsigned argn = get_op_uint(ctx, 0);
1188  const int do_ret = get_op_int(ctx, 1);
1189  jsval_t obj;
1190 
1191  TRACE("%d %d\n", argn, do_ret);
1192 
1193  obj = stack_topn(ctx, argn);
1194  if(!is_object_instance(obj))
1196 
1197  clear_acc(ctx);
1199  argn, stack_args(ctx, argn), do_ret ? &ctx->acc : NULL);
1200 }
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:728
static void clear_acc(script_ctx_t *ctx)
Definition: engine.c:393
static jsval_t stack_topn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:114
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
jsval_t acc
Definition: jscript.h:429
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:722
#define TRACE(s)
Definition: solgame.cpp:4
#define JS_E_INVALID_PROPERTY
Definition: jscript.h:534
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:112
static jsval_t * stack_args(script_ctx_t *ctx, unsigned n)
Definition: engine.c:119
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:1249
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438

◆ interp_call_member()

static HRESULT interp_call_member ( script_ctx_t ctx)
static

Definition at line 1203 of file engine.c.

1204 {
1205  const unsigned argn = get_op_uint(ctx, 0);
1206  const int do_ret = get_op_int(ctx, 1);
1207  exprval_t ref;
1208 
1209  TRACE("%d %d\n", argn, do_ret);
1210 
1211  if(!stack_topn_exprval(ctx, argn, &ref))
1212  return throw_type_error(ctx, ref.u.hres, NULL);
1213 
1214  clear_acc(ctx);
1216  argn, stack_args(ctx, argn), do_ret ? &ctx->acc : NULL);
1217 }
static HRESULT exprval_call(script_ctx_t *ctx, exprval_t *ref, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: engine.c:313
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:728
static void clear_acc(script_ctx_t *ctx)
Definition: engine.c:393
Definition: send.c:47
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLenum GLint ref
Definition: glext.h:6028
jsval_t acc
Definition: jscript.h:429
smooth NULL
Definition: ftsmooth.c:416
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL stack_topn_exprval(script_ctx_t *ctx, unsigned n, exprval_t *r)
Definition: engine.c:221
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:112
static jsval_t * stack_args(script_ctx_t *ctx, unsigned n)
Definition: engine.c:119
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438

◆ interp_carray()

static HRESULT interp_carray ( script_ctx_t ctx)
static

Definition at line 1401 of file engine.c.

1402 {
1403  const unsigned arg = get_op_uint(ctx, 0);
1404  jsdisp_t *array;
1405  HRESULT hres;
1406 
1407  TRACE("%u\n", arg);
1408 
1409  hres = create_array(ctx, arg, &array);
1410  if(FAILED(hres))
1411  return hres;
1412 
1413  return stack_push(ctx, jsval_obj(array));
1414 }
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
#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:1310
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:67

◆ interp_carray_set()

static HRESULT interp_carray_set ( script_ctx_t ctx)
static

Definition at line 1416 of file engine.c.

1417 {
1418  const unsigned index = get_op_uint(ctx, 0);
1419  jsval_t value, array;
1420  HRESULT hres;
1421 
1422  value = stack_pop(ctx);
1423 
1424  TRACE("[%u] = %s\n", index, debugstr_jsval(value));
1425 
1426  array = stack_top(ctx);
1428 
1431  return hres;
1432 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:102
GLuint index
Definition: glext.h:6031
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
#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:1081
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
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:33

◆ interp_case()

static HRESULT interp_case ( script_ctx_t ctx)
static

Definition at line 848 of file engine.c.

849 {
850  const unsigned arg = get_op_uint(ctx, 0);
851  jsval_t v;
852  BOOL b;
853  HRESULT hres;
854 
855  TRACE("\n");
856 
857  v = stack_pop(ctx);
858  hres = jsval_strict_equal(stack_top(ctx), v, &b);
859  jsval_release(v);
860  if(FAILED(hres))
861  return hres;
862 
863  if(b) {
864  stack_popn(ctx, 1);
865  jmp_abs(ctx, arg);
866  }else {
867  jmp_next(ctx);
868  }
869  return S_OK;
870 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:133
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:751
unsigned int BOOL
Definition: ntddk_ex.h:94
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:102
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:529
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:746
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127

◆ interp_cnd_nz()

static HRESULT interp_cnd_nz ( script_ctx_t ctx)
static

Definition at line 1492 of file engine.c.

1493 {
1494  const unsigned arg = get_op_uint(ctx, 0);
1495  BOOL b;
1496  HRESULT hres;
1497 
1498  TRACE("\n");
1499 
1500  hres = to_boolean(stack_top(ctx), &b);
1501  if(FAILED(hres))
1502  return hres;
1503 
1504  if(b) {
1505  jmp_abs(ctx, arg);
1506  }else {
1507  stack_popn(ctx, 1);
1508  jmp_next(ctx);
1509  }
1510  return S_OK;
1511 }
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:133
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:751
unsigned int BOOL
Definition: ntddk_ex.h:94
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:102
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
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:464
#define S_OK
Definition: intsafe.h:59
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:746

◆ interp_cnd_z()

static HRESULT interp_cnd_z ( script_ctx_t ctx)
static

Definition at line 1514 of file engine.c.

1515 {
1516  const unsigned arg = get_op_uint(ctx, 0);
1517  BOOL b;
1518  HRESULT hres;
1519 
1520  TRACE("\n");
1521 
1522  hres = to_boolean(stack_top(ctx), &b);
1523  if(FAILED(hres))
1524  return hres;
1525 
1526  if(b) {
1527  stack_popn(ctx, 1);
1528  jmp_next(ctx);
1529  }else {
1530  jmp_abs(ctx, arg);
1531  }
1532  return S_OK;
1533 }
static void stack_popn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:133
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:751
unsigned int BOOL
Definition: ntddk_ex.h:94
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:102
#define b
Definition: ke_i.h:79
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
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:464
#define S_OK
Definition: intsafe.h:59
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:746

◆ interp_delete()

static HRESULT interp_delete ( script_ctx_t ctx)
static

Definition at line 1838 of file engine.c.

1839 {
1840  jsval_t objv, namev;
1841  IDispatch *obj;
1842  jsstr_t *name;
1843  BOOL ret;
1844  HRESULT hres;
1845 
1846  TRACE("\n");
1847 
1848  namev = stack_pop(ctx);
1849  objv = stack_pop(ctx);
1850 
1851  hres = to_object(ctx, objv, &obj);
1852  jsval_release(objv);
1853  if(FAILED(hres)) {
1854  jsval_release(namev);
1855  return hres;
1856  }
1857 
1858  hres = to_string(ctx, namev, &name);
1859  jsval_release(namev);
1860  if(FAILED(hres)) {
1861  IDispatch_Release(obj);
1862  return hres;
1863  }
1864 
1865  hres = disp_delete_name(ctx, obj, name, &ret);
1866  IDispatch_Release(obj);
1868  if(FAILED(hres))
1869  return hres;
1870 
1871  return stack_push(ctx, jsval_bool(ret));
1872 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:36
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:808
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
HRESULT disp_delete_name(script_ctx_t *ctx, IDispatch *disp, jsstr_t *name, BOOL *ret)
Definition: dispex.c:1567
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67
GLuint const GLchar * name
Definition: glext.h:6031

◆ interp_delete_ident()

static HRESULT interp_delete_ident ( script_ctx_t ctx)
static

Definition at line 1875 of file engine.c.

1876 {
1877  const BSTR arg = get_op_bstr(ctx, 0);
1878  exprval_t exprval;
1879  BOOL ret;
1880  HRESULT hres;
1881 
1882  TRACE("%s\n", debugstr_w(arg));
1883 
1884  hres = identifier_eval(ctx, arg, &exprval);
1885  if(FAILED(hres))
1886  return hres;
1887 
1888  switch(exprval.type) {
1889  case EXPRVAL_STACK_REF:
1890  ret = FALSE;
1891  break;
1892  case EXPRVAL_IDREF:
1893  hres = disp_delete(exprval.u.idref.disp, exprval.u.idref.id, &ret);
1894  IDispatch_Release(exprval.u.idref.disp);
1895  if(FAILED(hres))
1896  return hres;
1897  break;
1898  case EXPRVAL_INVALID:
1899  ret = TRUE;
1900  break;
1901  default:
1902  FIXME("Unsupported exprval\n");
1903  exprval_release(&exprval);
1904  return E_NOTIMPL;
1905  }
1906 
1907 
1908  return stack_push(ctx, jsval_bool(ret));
1909 }
#define TRUE
Definition: types.h:120
OLECHAR * BSTR
Definition: compat.h:1934
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
union exprval_t::@414 u
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:716
#define TRACE(s)
Definition: solgame.cpp:4
enum exprval_t::@413 type
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret)
Definition: dispex.c:1532
static void exprval_release(exprval_t *val)
Definition: engine.c:352
#define E_NOTIMPL
Definition: ddrawi.h:99
struct exprval_t::@414::@415 idref
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:633
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:67

◆ interp_div()

static HRESULT interp_div ( script_ctx_t ctx)
static

Definition at line 1800 of file engine.c.

1801 {
1802  double l, r;
1803  HRESULT hres;
1804 
1805  TRACE("\n");
1806 
1807  hres = stack_pop_number(ctx, &r);
1808  if(FAILED(hres))
1809  return hres;
1810 
1811  hres = stack_pop_number(ctx, &l);
1812  if(FAILED(hres))
1813  return hres;
1814 
1815  return stack_push(ctx, jsval_number(l/r));
1816 }
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:139
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:67

◆ interp_double()

static HRESULT interp_double ( script_ctx_t ctx)
static

Definition at line 1364 of file engine.c.

1365 {
1366  const double arg = get_op_double(ctx);
1367 
1368  TRACE("%lf\n", arg);
1369 
1370  return stack_push(ctx, jsval_number(arg));
1371 }
static double get_op_double(script_ctx_t *ctx)
Definition: engine.c:740
#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:67

◆ interp_end_finally()

static HRESULT interp_end_finally ( script_ctx_t ctx)
static

Definition at line 961 of file engine.c.

962 {
963  call_frame_t *frame = ctx->call_ctx;
964  jsval_t v;
965 
966  TRACE("\n");
967 
968  v = stack_pop(ctx);
969  assert(is_bool(v));
970 
971  if(!get_bool(v)) {
972  TRACE("passing exception\n");
973 
974  ctx->ei.val = stack_pop(ctx);
975  return DISP_E_EXCEPTION;
976  }
977 
978  v = stack_pop(ctx);
979  assert(is_number(v));
980  frame->ip = get_number(v);
981  return S_OK;
982 }
#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:410
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:396
#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:127
jsexcept_t ei
Definition: jscript.h:420

◆ interp_enter_catch()

static HRESULT interp_enter_catch ( script_ctx_t ctx)
static

Definition at line 984 of file engine.c.

985 {
986  const BSTR ident = get_op_bstr(ctx, 0);
987  jsdisp_t *scope_obj;
988  jsval_t v;
989  HRESULT hres;
990 
991  hres = create_dispex(ctx, NULL, NULL, &scope_obj);
992  if(FAILED(hres))
993  return hres;
994 
995  v = stack_pop(ctx);
996  hres = jsdisp_propput_name(scope_obj, ident, v);
997  jsval_release(v);
998  if(SUCCEEDED(hres))
999  hres = scope_push(ctx->call_ctx->scope, scope_obj, to_disp(scope_obj), &ctx->call_ctx->scope);
1000  jsdisp_release(scope_obj);
1001  return hres;
1002 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
struct _call_frame_t * call_ctx
Definition: jscript.h:410
static HRESULT scope_push(scope_chain_t *scope, jsdisp_t *jsobj, IDispatch *obj, scope_chain_t **ret)
Definition: engine.c:399
OLECHAR * BSTR
Definition: compat.h:1934
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:716
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:241
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:978
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1365
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ interp_eq()

static HRESULT interp_eq ( script_ctx_t ctx)
static

Definition at line 2208 of file engine.c.

2209 {
2210  jsval_t l, r;
2211  BOOL b;
2212  HRESULT hres;
2213 
2214  r = stack_pop(ctx);
2215  l = stack_pop(ctx);
2216 
2217  TRACE("%s == %s\n", debugstr_jsval(l), debugstr_jsval(r));
2218 
2219  hres = equal_values(ctx, l, r, &b);
2220  jsval_release(l);
2221  jsval_release(r);
2222  if(FAILED(hres))
2223  return hres;
2224 
2225  return stack_push(ctx, jsval_bool(b));
2226 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:2128
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_eq2()

static HRESULT interp_eq2 ( script_ctx_t ctx)
static

Definition at line 2250 of file engine.c.

2251 {
2252  jsval_t l, r;
2253  BOOL b;
2254  HRESULT hres;
2255 
2256  r = stack_pop(ctx);
2257  l = stack_pop(ctx);
2258 
2259  TRACE("%s === %s\n", debugstr_jsval(l), debugstr_jsval(r));
2260 
2261  hres = jsval_strict_equal(r, l, &b);
2262  jsval_release(l);
2263  jsval_release(r);
2264  if(FAILED(hres))
2265  return hres;
2266 
2267  return stack_push(ctx, jsval_bool(b));
2268 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:529
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:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_forin()

static HRESULT interp_forin ( script_ctx_t ctx)
static

Definition at line 757 of file engine.c.

758 {
759  const HRESULT arg = get_op_uint(ctx, 0);
760  IDispatch *obj = NULL;
761  IDispatchEx *dispex;
762  exprval_t prop_ref;
763  DISPID id;
764  BSTR name = NULL;
765  HRESULT hres;
766 
767  TRACE("\n");
768 
769  assert(is_number(stack_top(ctx)));
770  id = get_number(stack_top(ctx));
771 
772  if(!stack_topn_exprval(ctx, 1, &prop_ref)) {
773  FIXME("invalid ref: %08x\n", prop_ref.u.hres);
774  return E_FAIL;
775  }
776 
777  if(is_object_instance(stack_topn(ctx, 3)))
778  obj = get_object(stack_topn(ctx, 3));
779 
780  if(obj) {
781  hres = IDispatch_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
782  if(SUCCEEDED(hres)) {
783  hres = IDispatchEx_GetNextDispID(dispex, fdexEnumDefault, id, &id);
784  if(hres == S_OK)
785  hres = IDispatchEx_GetMemberName(dispex, id, &name);
786  IDispatchEx_Release(dispex);
787  if(FAILED(hres))
788  return hres;
789  }else {
790  TRACE("No IDispatchEx\n");
791  }
792  }
793 
794  if(name) {
795  jsstr_t *str;
796 
799  if(!str)
800  return E_OUTOFMEMORY;
801 
802  stack_pop(ctx);
803  stack_push(ctx, jsval_number(id)); /* safe, just after pop() */
804 
805  hres = exprval_propput(ctx, &prop_ref, jsval_string(str));
807  if(FAILED(hres))
808  return hres;
809 
810  jmp_next(ctx);
811  }else {
812  stack_popn(ctx, 4);
813  jmp_abs(ctx, arg);
814  }
815  return S_OK;
816 }
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:133
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:751
static jsval_t stack_topn(script_ctx_t *ctx, unsigned n)
Definition: engine.c:114
OLECHAR * BSTR
Definition: compat.h:1934
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:284
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
union exprval_t::@414 u
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static jsval_t stack_top(script_ctx_t *ctx)
Definition: engine.c:102
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:722
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
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:199
#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:221
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
static void jmp_next(script_ctx_t *ctx)
Definition: engine.c:746
Definition: name.c:36
GLenum GLuint id
Definition: glext.h:5579
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
HRESULT hres
Definition: engine.c:63
#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:67

◆ interp_func()

static HRESULT interp_func ( script_ctx_t ctx)
static

Definition at line 1005 of file engine.c.

1006 {
1007  unsigned func_idx = get_op_uint(ctx, 0);
1008  call_frame_t *frame = ctx->call_ctx;
1009  jsdisp_t *dispex;
1010  HRESULT hres;
1011 
1012  TRACE("%d\n", func_idx);
1013 
1014  hres = create_source_function(ctx, frame->bytecode, frame->function->funcs+func_idx,
1015  frame->scope, &dispex);
1016  if(FAILED(hres))
1017  return hres;
1018 
1019  return stack_push(ctx, jsval_obj(dispex));
1020 }
struct _function_code_t * funcs
Definition: engine.h:155
struct _call_frame_t * call_ctx
Definition: jscript.h:410
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:722
#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:699
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:67

◆ interp_gt()

static HRESULT interp_gt ( script_ctx_t ctx)
static

Definition at line 2370 of file engine.c.

2371 {
2372  jsval_t l, r;
2373  BOOL b;
2374  HRESULT hres;
2375 
2376  r = stack_pop(ctx);
2377  l = stack_pop(ctx);
2378 
2379  TRACE("%s > %s\n", debugstr_jsval(l), debugstr_jsval(r));
2380 
2381  hres = less_eval(ctx, r, l, FALSE, &b);
2382  jsval_release(l);
2383  jsval_release(r);
2384  if(FAILED(hres))
2385  return hres;
2386 
2387  return stack_push(ctx, jsval_bool(b));
2388 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:2292
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_gteq()

static HRESULT interp_gteq ( script_ctx_t ctx)
static

Definition at line 2391 of file engine.c.

2392 {
2393  jsval_t l, r;
2394  BOOL b;
2395  HRESULT hres;
2396 
2397  r = stack_pop(ctx);
2398  l = stack_pop(ctx);
2399 
2400  TRACE("%s >= %s\n", debugstr_jsval(l), debugstr_jsval(r));
2401 
2402  hres = less_eval(ctx, l, r, TRUE, &b);
2403  jsval_release(l);
2404  jsval_release(r);
2405  if(FAILED(hres))
2406  return hres;
2407 
2408  return stack_push(ctx, jsval_bool(b));
2409 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#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:2292
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_ident()

static HRESULT interp_ident ( script_ctx_t ctx)
static

Definition at line 1315 of file engine.c.

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

◆ interp_identid()

static HRESULT interp_identid ( script_ctx_t ctx)
static

Definition at line 1325 of file engine.c.

1326 {
1327  const BSTR arg = get_op_bstr(ctx, 0);
1328  const unsigned flags = get_op_uint(ctx, 1);
1329 
1330  TRACE("%s %x\n", debugstr_w(arg), flags);
1331 
1332  return interp_identifier_ref(ctx, arg, flags);
1333 }
OLECHAR * BSTR
Definition: compat.h:1934
#define debugstr_w
Definition: kernel32.h:32
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:716
#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:1230

◆ interp_identifier_ref()

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

Definition at line 1230 of file engine.c.

1231 {
1232  exprval_t exprval;
1233  HRESULT hres;
1234 
1235  hres = identifier_eval(ctx, identifier, &exprval);
1236  if(FAILED(hres))
1237  return hres;
1238 
1239  if(exprval.type == EXPRVAL_INVALID && (flags & fdexNameEnsure)) {
1240  DISPID id;
1241 
1242  hres = jsdisp_get_id(ctx->global, identifier, fdexNameEnsure, &id);
1243  if(FAILED(hres))
1244  return hres;
1245 
1246  exprval_set_disp_ref(&exprval, to_disp(ctx->global), id);
1247  }
1248 
1249  if(exprval.type == EXPRVAL_JSVAL || exprval.type == EXPRVAL_INVALID) {
1250  WARN("invalid ref\n");
1251  exprval_release(&exprval);
1253  }
1254 
1255  return stack_push_exprval(ctx, &exprval);
1256 }
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT stack_push_exprval(script_ctx_t *ctx, exprval_t *val)
Definition: engine.c:191
static void exprval_set_exception(exprval_t *val, HRESULT hres)
Definition: engine.c:368
static void exprval_set_disp_ref(exprval_t *ref, IDispatch *obj, DISPID id)
Definition: engine.c:374
enum exprval_t::@413 type
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:1088
static void exprval_release(exprval_t *val)
Definition: engine.c:352
static IDispatch * to_disp(jsdisp_t *jsdisp)
Definition: jscript.h:241
static VARIANTARG static DISPID
Definition: ordinal.c:49
jsdisp_t * global
Definition: jscript.h:436
static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *ret)
Definition: engine.c:633
GLenum GLuint id
Definition: glext.h:5579
#define JS_E_OBJECT_EXPECTED
Definition: jscript.h:556

Referenced by interp_identid(), and interp_local_ref().

◆ interp_in()

static HRESULT interp_in ( script_ctx_t ctx)
static

Definition at line 1651 of file engine.c.

1652 {
1653  const WCHAR *str;
1654  jsstr_t *jsstr;
1655  jsval_t obj, v;
1656  DISPID id = 0;
1657  BOOL ret;
1658  HRESULT hres;
1659 
1660  TRACE("\n");
1661 
1662  obj = stack_pop(ctx);
1663  if(!is_object_instance(obj) || !get_object(obj)) {
1664  jsval_release(obj);
1666  }
1667 
1668  v = stack_pop(ctx);
1669  hres = to_flat_string(ctx, v, &jsstr, &str);
1670  jsval_release(v);
1671  if(FAILED(hres)) {
1672  IDispatch_Release(get_object(obj));
1673  return hres;
1674  }
1675 
1676  hres = disp_get_id(ctx, get_object(obj), str, NULL, 0, &id);
1677  IDispatch_Release(get_object(obj));
1678  jsstr_release(jsstr);
1679  if(SUCCEEDED(hres))
1680  ret = TRUE;
1681  else if(hres == DISP_E_UNKNOWNNAME)
1682  ret = FALSE;
1683  else
1684  return hres;
1685 
1686  return stack_push(ctx, jsval_bool(ret));
1687 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#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:447
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:438
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
#define JS_E_OBJECT_EXPECTED
Definition: jscript.h:556
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_instanceof()

static HRESULT interp_instanceof ( script_ctx_t ctx)
static

Definition at line 1593 of file engine.c.

1594 {
1595  jsdisp_t *obj, *iter, *tmp = NULL;
1596  jsval_t prot, v;
1597  BOOL ret = FALSE;
1598  HRESULT hres;
1599 
1600  static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0};
1601 
1602  v = stack_pop(ctx);
1603  if(!is_object_instance(v) || !get_object(v)) {
1604  jsval_release(v);
1606  }
1607 
1609  IDispatch_Release(get_object(v));
1610  if(!obj) {
1611  FIXME("non-jsdisp objects not supported\n");
1612  return E_FAIL;
1613  }
1614 
1615  if(is_class(obj, JSCLASS_FUNCTION)) {
1617  }else {
1619  }
1621  if(FAILED(hres))
1622  return hres;
1623 
1624  v = stack_pop(ctx);
1625 
1626  if(is_object_instance(prot)) {
1627  if(is_object_instance(v))
1628  tmp = iface_to_jsdisp(get_object(v));
1629  for(iter = tmp; !ret && iter; iter = iter->prototype) {
1630  hres = disp_cmp(get_object(prot), to_disp(iter), &ret);
1631  if(FAILED(hres))
1632  break;
1633  }
1634 
1635  if(tmp)
1636  jsdisp_release(tmp);
1637  }else {
1638  FIXME("prototype is not an object\n");
1639  hres = E_FAIL;
1640  }
1641 
1642  jsval_release(prot);
1643  jsval_release(v);
1644  if(FAILED(hres))
1645  return hres;
1646 
1647  return stack_push(ctx, jsval_bool(ret));
1648 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#define JS_E_FUNCTION_EXPECTED
Definition: jscript.h:553
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static const WCHAR prototypeW[]
Definition: function.c:67
#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:484
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
#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:1429
__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:241
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
const GLdouble * v
Definition: gl.h:2040
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
jsdisp_t * prototype
Definition: jscript.h:236
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_int()

static HRESULT interp_int ( script_ctx_t ctx)
static

Definition at line 1354 of file engine.c.

1355 {
1356  const int arg = get_op_int(ctx, 0);
1357 
1358  TRACE("%d\n", arg);
1359 
1360  return stack_push(ctx, jsval_number(arg));
1361 }
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:728
#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:67

◆ interp_jmp()

static HRESULT interp_jmp ( script_ctx_t ctx)
static

Definition at line 2555 of file engine.c.

2556 {
2557  const unsigned arg = get_op_uint(ctx, 0);
2558 
2559  TRACE("%u\n", arg);
2560 
2561  jmp_abs(ctx, arg);
2562  return S_OK;
2563 }
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:751
static unsigned get_op_uint(script_ctx_t *ctx, int i)
Definition: engine.c:722
#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 2565 of file engine.c.

2566 {
2567  const unsigned arg = get_op_uint(ctx, 0);
2568  BOOL b;
2569  jsval_t v;
2570  HRESULT hres;
2571 
2572  TRACE("\n");
2573 
2574  v = stack_pop(ctx);
2575  hres = to_boolean(v, &b);
2576  jsval_release(v);
2577  if(FAILED(hres))
2578  return hres;
2579 
2580  if(b)
2581  jmp_next(ctx);
2582  else
2583  jmp_abs(ctx, arg);
2584  return S_OK;
2585 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static void jmp_abs(script_ctx_t *ctx, unsigned dst)
Definition: engine.c:751
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:722
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:464
#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:746
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127

◆ interp_local()

static HRESULT interp_local ( script_ctx_t ctx)
static

Definition at line 1295 of file engine.c.

1296 {
1297  const int arg = get_op_int(ctx, 0);
1298  call_frame_t *frame = ctx->call_ctx;
1299  jsval_t copy;
1300  HRESULT hres;
1301 
1302  TRACE("%d: %s\n", arg, debugstr_w(local_name(frame, arg)));
1303 
1304  if(!frame->base_scope || !frame->base_scope->frame)
1305  return identifier_value(ctx, local_name(frame, arg));
1306 
1307  hres = jsval_copy(ctx->stack[local_off(frame, arg)], &copy);
1308  if(FAILED(hres))
1309  return hres;
1310 
1311  return stack_push(ctx, copy);
1312 }
Definition: jsval.h:54
static HRESULT identifier_value(script_ctx_t *ctx, BSTR identifier)
Definition: engine.c:1258
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:178
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:728
struct _call_frame_t * call_ctx
Definition: jscript.h:410
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:229
#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:426
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:185
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_local_ref()

static HRESULT interp_local_ref ( script_ctx_t ctx)
static

Definition at line 1278 of file engine.c.

1279 {
1280  const int arg = get_op_int(ctx, 0);
1281  const unsigned flags = get_op_uint(ctx, 1);
1282  call_frame_t *frame = ctx->call_ctx;
1283  exprval_t ref;
1284 
1285  TRACE("%d\n", arg);
1286 
1287  if(!frame->base_scope || !frame->base_scope->frame)
1288  return interp_identifier_ref(ctx, local_name(frame, arg), flags);
1289 
1290  ref.type = EXPRVAL_STACK_REF;
1291  ref.u.off = local_off(frame, arg);
1292  return stack_push_exprval(ctx, &ref);
1293 }
static unsigned local_off(call_frame_t *frame, int ref)
Definition: engine.c:178
static unsigned get_op_int(script_ctx_t *ctx, int i)
Definition: engine.c:728
struct _call_frame_t * call_ctx
Definition: jscript.h:410
static HRESULT stack_push_exprval(script_ctx_t *ctx, exprval_t *val)
Definition: engine.c:191
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:722
#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:185
static HRESULT interp_identifier_ref(script_ctx_t *ctx, BSTR identifier, unsigned flags)
Definition: engine.c:1230

◆ interp_lshift()

static HRESULT interp_lshift ( script_ctx_t ctx)
static

Definition at line 2448 of file engine.c.

2449 {
2450  DWORD r;
2451  INT l;
2452  HRESULT hres;
2453 
2454  hres = stack_pop_uint(ctx, &r);
2455  if(FAILED(hres))
2456  return hres;
2457 
2458  hres = stack_pop_int(ctx, &l);
2459  if(FAILED(hres))
2460  return hres;
2461 
2462  return stack_push(ctx, jsval_number(l << (r&0x1f)));
2463 }
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:168
static HRESULT stack_pop_uint(script_ctx_t *ctx, DWORD *r)
Definition: engine.c:173
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:67

◆ interp_lt()

static HRESULT interp_lt ( script_ctx_t ctx)
static

Definition at line 2328 of file engine.c.

2329 {
2330  jsval_t l, r;
2331  BOOL b;
2332  HRESULT hres;
2333 
2334  r = stack_pop(ctx);
2335  l = stack_pop(ctx);
2336 
2337  TRACE("%s < %s\n", debugstr_jsval(l), debugstr_jsval(r));
2338 
2339  hres = less_eval(ctx, l, r, FALSE, &b);
2340  jsval_release(l);
2341  jsval_release(r);
2342  if(FAILED(hres))
2343  return hres;
2344 
2345  return stack_push(ctx, jsval_bool(b));
2346 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:2292
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_lteq()

static HRESULT interp_lteq ( script_ctx_t ctx)
static

Definition at line 2349 of file engine.c.

2350 {
2351  jsval_t l, r;
2352  BOOL b;
2353  HRESULT hres;
2354 
2355  r = stack_pop(ctx);
2356  l = stack_pop(ctx);
2357 
2358  TRACE("%s <= %s\n", debugstr_jsval(l), debugstr_jsval(r));
2359 
2360  hres = less_eval(ctx, r, l, TRUE, &b);
2361  jsval_release(l);
2362  jsval_release(r);
2363  if(FAILED(hres))
2364  return hres;
2365 
2366  return stack_push(ctx, jsval_bool(b));
2367 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#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:2292
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_member()

static HRESULT interp_member ( script_ctx_t ctx)
static

Definition at line 1065 of file engine.c.

1066 {
1067  const BSTR arg = get_op_bstr(ctx, 0);
1068  IDispatch *obj;
1069  jsval_t v;
1070  DISPID id;
1071  HRESULT hres;
1072 
1073  TRACE("\n");
1074 
1075  hres = stack_pop_object(ctx, &obj);
1076  if(FAILED(hres))
1077  return hres;
1078 
1079  hres = disp_get_id(ctx, obj, arg, arg, 0, &id);
1080  if(SUCCEEDED(hres)) {
1081  hres = disp_propget(ctx, obj, id, &v);
1082  }else if(hres == DISP_E_UNKNOWNNAME) {
1083  v = jsval_undefined();
1084  hres = S_OK;
1085  }
1086  IDispatch_Release(obj);
1087  if(FAILED(hres))
1088  return hres;
1089 
1090  return stack_push(ctx, v);
1091 }
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:150
OLECHAR * BSTR
Definition: compat.h:1934
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:447
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
Definition: dispex.c:1479
static BSTR get_op_bstr(script_ctx_t *ctx, int i)
Definition: engine.c:716
#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:67

◆ interp_memberid()

static HRESULT interp_memberid ( script_ctx_t ctx)
static

Definition at line 1094 of file engine.c.

1095 {
1096  const unsigned arg = get_op_uint(ctx, 0);
1097  jsval_t objv, namev;
1098  const WCHAR *name;
1099  jsstr_t *name_str;
1100  IDispatch *obj;
1101  exprval_t ref;
1102  DISPID id;
1103  HRESULT hres;
1104 
1105  TRACE("%x\n", arg);
1106 
1107  namev = stack_pop(ctx);
1108  objv = stack_pop(ctx);
1109 
1110  hres = to_object(ctx, objv, &obj);
1111  jsval_release(objv);
1112  if(SUCCEEDED(hres)) {
1113  hres = to_flat_string(ctx, namev, &name_str, &name);
1114  if(FAILED(hres))
1115  IDispatch_Release(obj);
1116  }
1117  jsval_release(namev);
1118  if(FAILED(hres))
1119  return hres;
1120 
1121  hres = disp_get_id(ctx, obj, name, NULL, arg, &id);
1122  jsstr_release(name_str);
1123  if(SUCCEEDED(hres)) {
1124  ref.type = EXPRVAL_IDREF;
1125  ref.u.idref.disp = obj;
1126  ref.u.idref.id = id;
1127  }else {
1128  IDispatch_Release(obj);
1129  if(hres == DISP_E_UNKNOWNNAME && !(arg & fdexNameEnsure)) {
1131  hres = S_OK;
1132  }else {
1133  ERR("failed %08x\n", hres);
1134  return hres;
1135  }
1136  }
1137 
1138  return stack_push_exprval(ctx, &ref);
1139 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
Definition: jsstr.h:39
static HRESULT stack_push_exprval(script_ctx_t *ctx, exprval_t *val)
Definition: engine.c:191
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
static void exprval_set_exception(exprval_t *val, HRESULT hres)
Definition: engine.c:368
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:447
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:722
#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:534
#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:36
HRESULT to_object(script_ctx_t *, jsval_t, IDispatch **) DECLSPEC_HIDDEN
Definition: jsutils.c:808
GLenum GLuint id
Definition: glext.h:5579
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
#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 2033 of file engine.c.

2034 {
2035  double n;
2036  HRESULT hres;
2037 
2038  TRACE("\n");
2039 
2040  hres = stack_pop_number(ctx, &n);
2041  if(FAILED(hres))
2042  return hres;
2043 
2044  return stack_push(ctx, jsval_number(-n));
2045 }
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:139
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:67

◆ interp_mod()

static HRESULT interp_mod ( script_ctx_t ctx)
static

Definition at line 1819 of file engine.c.

1820 {
1821  double l, r;
1822  HRESULT hres;
1823 
1824  TRACE("\n");
1825 
1826  hres = stack_pop_number(ctx, &r);
1827  if(FAILED(hres))
1828  return hres;
1829 
1830  hres = stack_pop_number(ctx, &l);
1831  if(FAILED(hres))
1832  return hres;
1833 
1834  return stack_push(ctx, jsval_number(fmod(l, r)));
1835 }
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:139
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:67

◆ interp_mul()

static HRESULT interp_mul ( script_ctx_t ctx)
static

Definition at line 1781 of file engine.c.

1782 {
1783  double l, r;
1784  HRESULT hres;
1785 
1786  TRACE("\n");
1787 
1788  hres = stack_pop_number(ctx, &r);
1789  if(FAILED(hres))
1790  return hres;
1791 
1792  hres = stack_pop_number(ctx, &l);
1793  if(FAILED(hres))
1794  return hres;
1795 
1796  return stack_push(ctx, jsval_number(l*r));
1797 }
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:139
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:67

◆ interp_neg()

static HRESULT interp_neg ( script_ctx_t ctx)
static

Definition at line 2430 of file engine.c.

2431 {
2432  jsval_t v;
2433  BOOL b;
2434  HRESULT hres;
2435 
2436  TRACE("\n");
2437 
2438  v = stack_pop(ctx);
2439  hres = to_boolean(v, &b);
2440  jsval_release(v);
2441  if(FAILED(hres))
2442  return hres;
2443 
2444  return stack_push(ctx, jsval_bool(!b));
2445 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:464
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:127
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: engine.c:67

◆ interp_neq()

static HRESULT interp_neq ( script_ctx_t ctx)
static

Definition at line 2229 of file engine.c.

2230 {
2231  jsval_t l, r;
2232  BOOL b;
2233  HRESULT hres;
2234 
2235  r = stack_pop(ctx);
2236  l = stack_pop(ctx);
2237 
2238  TRACE("%s != %s\n", debugstr_jsval(l), debugstr_jsval(r));
2239 
2240  hres = equal_values(ctx, l, r, &b);
2241  jsval_release(l);
2242  jsval_release(r);
2243  if(FAILED(hres))
2244  return hres;
2245 
2246  return stack_push(ctx, jsval_bool(!b));
2247 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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:2128
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
static jsval_t stack_pop(script_ctx_t *ctx)
Definition: engine.c:127
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33
static HRESULT stack_push(script_ctx_t *ctx, jsval_t v)
Definition: