Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

430 lines
14 KiB

  1. /*****************************************************************************
  2. emoci.h
  3. Owner: DaleG
  4. Copyright (c) 1996-1997 Microsoft Corporation
  5. Op-Code Interpreter header file
  6. *****************************************************************************/
  7. #ifndef EMOCI_H
  8. #define EMOCI_H
  9. #include "emocii.h"
  10. MSOEXTERN_C_BEGIN // ***************** Begin extern "C" ********************
  11. //############################################################################
  12. //
  13. // PUBLIC Interfaces
  14. //
  15. //############################################################################
  16. // System Limits
  17. #define msoilOciStackMax 2000
  18. /* M S O O C I S */
  19. /*----------------------------------------------------------------------------
  20. %%Struct: MSOOCIS
  21. %%Contact: daleg
  22. Op-Code Interpreter State structure
  23. ----------------------------------------------------------------------------*/
  24. // The Interpreter op-code fns must always be compatible with MSOAPICALLTYPE
  25. // so that MSO-exported and app-local functions have the same type
  26. #define MSOOCVAPI MSOOCV MSOAPICALLTYPE
  27. // Define normal function: all args are evaluated and received on the stack
  28. typedef MSOOCV (MSOAPICALLTYPE *MSOPFNOCI)(MSOOCV *pocvSP);
  29. // Define function to return address of variable data
  30. typedef MSOOCV *(MSOAPICALLTYPE *MSOPFNPOCV)(MSOOCII);
  31. typedef struct _MSOOCIS
  32. {
  33. MSOPFNOCI const *rgpfn; // Function ptr array
  34. MSOOCAD const *rgocadArgDesc; // #Args/Offset arg len
  35. MSOOCV *pocvSP; // Stack pointer
  36. MSOOCV *pocvFP; // Frame pointer
  37. MSOOCV rglStack[msoilOciStackMax]; // Call/Return stack
  38. unsigned char const*rgcbImmedArg; // Immediate arg lens
  39. void *rgocvVar; // Variable array
  40. MSOPFNPOCV pfnPocvGetVar; // Get addr of var data
  41. #ifdef DEBUG
  42. unsigned char **rgszFnNames; // Function names
  43. #endif /* DEBUG */
  44. } MSOOCIS;
  45. // Define non-evaluating function: it must interpret instructions itself
  46. typedef MSOOCV (MSOAPICALLTYPE *MSOPFNOCI_NE)
  47. (MSOOCII **ppocii, MSOOCIS *pocis);
  48. /*************************************************************************
  49. Prototypes and macros
  50. *************************************************************************/
  51. MSOAPI_(MSOOCIS *) MsoPocisInit( // Init Interp Fn tbl
  52. MSOOCIS *pocis,
  53. MSOPFNOCI const *rgpfn, // Function table
  54. MSOOCAD const *rgocadArgDesc, // Arg descript table
  55. unsigned char const*rgcbImmedArg, // Immed arg desc tbl
  56. int ipfnMax, // Num builtin fns
  57. void *rgocvVar, // Variable array
  58. MSOPFNPOCV pfnPocvGetVar // Get addr of var data
  59. );
  60. MSOAPI_(MSOOCV) MsoOcvEvalPocii( // Interpret 1 instr
  61. MSOOCII **ppocii,
  62. MSOOCIS *pocis
  63. );
  64. MSOAPI_(MSOOCV *) MsoPocvPushVarArgs( // Push var args on stk
  65. int docvArgsFixed,
  66. MSOOCII **ppocii,
  67. MSOOCIS *pocis
  68. );
  69. // NOTE:
  70. // NOTE: The macros below require the parent routine to declare pocvSP!!
  71. // NOTE:
  72. // Return the value of the iocv-th argment on the stack
  73. #define MsoOcvArg(iocv) \
  74. (pocvSP[iocv])
  75. // Return the value of the pointer in the iocv-th argment on the stack
  76. #define MsoPvOcvArg(iocv) \
  77. ((void *) (pocvSP[iocv]))
  78. // Convert the pointer value to a interpreter return type
  79. #define MsoOcvFromPv(pv) \
  80. ((MSOOCV) (pv))
  81. // Return the value of the char in the iocv-th argment on the stack
  82. #define MsoChOcvArg(iocv) \
  83. ((char) (pocvSP[iocv]))
  84. // Convert the char value to a interpreter return type
  85. #define MsoOcvFromCh(ch) \
  86. ((MSOOCV) (ch))
  87. // Return the value of the unsigned char in the iocv-th argment on the stack
  88. #define MsoUchOcvArg(iocv) \
  89. ((unsigned char) (pocvSP[iocv]))
  90. // Convert the unsigned char value to a interpreter return type
  91. #define MsoOcvFromUch(uch) \
  92. ((MSOOCV) (uch))
  93. // Return the value of the int in the iocv-th argment on the stack
  94. #define MsoIntOcvArg(iocv) \
  95. ((int) (pocvSP[iocv]))
  96. // Convert the integer value to a interpreter return type
  97. #define MsoOcvFromInt(v) \
  98. ((MSOOCV) (v))
  99. // Return the value of the unsigned int in the iocv-th argment on the stack
  100. #define MsoUintOcvArg(iocv) \
  101. ((unsigned int) (pocvSP[iocv]))
  102. // Convert the unsigned int value to a interpreter return type
  103. #define MsoOcvFromUint(v) \
  104. ((MSOOCV) (v))
  105. // Return the value of the short iocv-th argment on the stack
  106. #define MsoWOcvArg(iocv) \
  107. ((short) (pocvSP[iocv]))
  108. // Convert the short value to a interpreter return type
  109. #define MsoOcvFromW(w) \
  110. ((MSOOCV) (w))
  111. // Return the value of the unsigned short iocv-th argment on the stack
  112. #define MsoUwOcvArg(iocv) \
  113. ((unsigned short) (pocvSP[iocv]))
  114. // Convert the unsigned short value to a interpreter return type
  115. #define MsoOcvFromWw(uw) \
  116. ((MSOOCV) (uw))
  117. // Return the value of the long in the iocv-th argment on the stack
  118. #define MsoLOcvArg(iocv) \
  119. ((long) (pocvSP[iocv]))
  120. // Convert the long value to a interpreter return type
  121. #define MsoOcvFromL(l) \
  122. ((MSOOCV) (l))
  123. // Return the value of the unsigned long in the iocv-th argment on the stack
  124. #define MsoUlOcvArg(iocv) \
  125. ((unsigned long) (pocvSP[iocv]))
  126. // Convert the unsigned long value to a interpreter return type
  127. #define MsoOcvFromUl(l) \
  128. ((MSOOCV) (l))
  129. // Return the address of the event (var) of index iocv: Application callback
  130. #define MsoOcvEventAddr(iocv, pocis) \
  131. ((*(pocis)->pfnPocvGetVar)(iocv))
  132. // Return the address of the stack index
  133. #define MsoOcvStackAddr(docv, pocis) \
  134. (&(pocis)->pocvFP[docv])
  135. // Return the address of a global variable or function
  136. #define MsoOciiGlobalAddr(ipv, pocis) \
  137. (&(pocis)->rgpfn[ipv])
  138. // Return the value of iocv-th argment on the stack
  139. #define MsoOcvStack(iocv) \
  140. ((long) (pocvSP[iocv]))
  141. // Supply the rest of the calling arguments to a var-args function call
  142. #define MsoOcv_varargs_0 \
  143. MsoOcvStack(0), MsoOcvStack(1), MsoOcvStack(2), MsoOcvStack(3), \
  144. MsoOcv_varargs_4
  145. #define MsoOcv_varargs_1 \
  146. MsoOcvStack(1), MsoOcvStack(2), MsoOcvStack(3), \
  147. MsoOcv_varargs_4
  148. #define MsoOcv_varargs_2 \
  149. MsoOcvStack(2), MsoOcvStack(3), \
  150. MsoOcv_varargs_4
  151. #define MsoOcv_varargs_3 \
  152. MsoOcvStack(3), \
  153. MsoOcv_varargs_4
  154. #define MsoOcv_varargs_4 \
  155. MsoOcvStack(5), MsoOcvStack(5), MsoOcvStack(6), MsoOcvStack(7), \
  156. MsoOcv_varargs_8
  157. #define MsoOcv_varargs_5 \
  158. MsoOcvStack(5), MsoOcvStack(6), MsoOcvStack(7), \
  159. MsoOcv_varargs_8
  160. #define MsoOcv_varargs_6 \
  161. MsoOcvStack(6), MsoOcvStack(7), \
  162. MsoOcv_varargs_8
  163. #define MsoOcv_varargs_7 \
  164. MsoOcvStack(7), \
  165. MsoOcv_varargs_8
  166. #define MsoOcv_varargs_8 \
  167. MsoOcvStack(8), MsoOcvStack(9), MsoOcvStack(10), MsoOcvStack(11), \
  168. MsoOcv_varargs_12
  169. #define MsoOcv_varargs_9 \
  170. MsoOcvStack(9), MsoOcvStack(10), MsoOcvStack(11), \
  171. MsoOcv_varargs_12
  172. #define MsoOcv_varargs_10 \
  173. MsoOcvStack(10), MsoOcvStack(11), \
  174. MsoOcv_varargs_12
  175. #define MsoOcv_varargs_11 \
  176. MsoOcvStack(11), \
  177. MsoOcv_varargs_12
  178. #define MsoOcv_varargs_12 \
  179. MsoOcvStack(12), MsoOcvStack(13), MsoOcvStack(14), MsoOcvStack(15), \
  180. MsoOcv_varargs_16
  181. #define MsoOcv_varargs_13 \
  182. MsoOcvStack(13), MsoOcvStack(14), MsoOcvStack(15), \
  183. MsoOcv_varargs_16
  184. #define MsoOcv_varargs_14 \
  185. MsoOcvStack(14), MsoOcvStack(15), \
  186. MsoOcv_varargs_16
  187. #define MsoOcv_varargs_15 \
  188. MsoOcvStack(15), \
  189. MsoOcv_varargs_16
  190. #define MsoOcv_varargs_16 \
  191. MsoOcvStack(16), MsoOcvStack(17), MsoOcvStack(18), MsoOcvStack(19), \
  192. MsoOcv_varargs_20
  193. #define MsoOcv_varargs_17 \
  194. MsoOcvStack(17), MsoOcvStack(18), MsoOcvStack(19), \
  195. MsoOcv_varargs_20
  196. #define MsoOcv_varargs_18 \
  197. MsoOcvStack(18), MsoOcvStack(19), \
  198. MsoOcv_varargs_20
  199. #define MsoOcv_varargs_19 \
  200. MsoOcvStack(19), \
  201. MsoOcv_varargs_20
  202. #define MsoOcv_varargs_20 \
  203. MsoOcvStack(20), MsoOcvStack(21), MsoOcvStack(22), MsoOcvStack(23), \
  204. MsoOcv_varargs_24
  205. #define MsoOcv_varargs_21 \
  206. MsoOcvStack(21), MsoOcvStack(22), MsoOcvStack(23), \
  207. MsoOcv_varargs_24
  208. #define MsoOcv_varargs_22 \
  209. MsoOcvStack(22), MsoOcvStack(23), \
  210. MsoOcv_varargs_24
  211. #define MsoOcv_varargs_23 \
  212. MsoOcvStack(23), \
  213. MsoOcv_varargs_24
  214. #define MsoOcv_varargs_24 \
  215. MsoOcvStack(24), MsoOcvStack(25), MsoOcvStack(26), MsoOcvStack(27), \
  216. MsoOcv_varargs_28
  217. #define MsoOcv_varargs_25 \
  218. MsoOcvStack(25), MsoOcvStack(26), MsoOcvStack(27), \
  219. MsoOcv_varargs_28
  220. #define MsoOcv_varargs_26 \
  221. MsoOcvStack(26), MsoOcvStack(27), \
  222. MsoOcv_varargs_28
  223. #define MsoOcv_varargs_27 \
  224. MsoOcvStack(27), \
  225. MsoOcv_varargs_28
  226. #define MsoOcv_varargs_28 \
  227. MsoOcvStack(28), MsoOcvStack(29), MsoOcvStack(30), MsoOcvStack(31)
  228. #define MsoOcv_varargs_29 \
  229. MsoOcvStack(29), MsoOcvStack(30), MsoOcvStack(31)
  230. #define MsoOcv_varargs_30 \
  231. MsoOcvStack(30), MsoOcvStack(31)
  232. #define MsoOcv_varargs_31 \
  233. MsoOcvStack(31)
  234. /*----------------------------------------------------------------------------
  235. Interpreter function list.
  236. Should be list in same order as enum for clarity.
  237. ----------------------------------------------------------------------------*/
  238. MSOAPI_(MSOOCV) MsoOcv_log_and(
  239. MSOOCII **ppocii,
  240. struct _MSOOCIS *pocis
  241. );
  242. MSOAPI_(MSOOCV) MsoOcv_log_or(
  243. MSOOCII **ppocii,
  244. struct _MSOOCIS *pocis
  245. );
  246. MSOAPI_(MSOOCV) MsoOcv_log_not(MSOOCV *pocvSP);
  247. MSOAPI_(MSOOCV) MsoOcv_less_than(MSOOCV *pocvSP);
  248. MSOAPI_(MSOOCV) MsoOcv_less_eql(MSOOCV *pocvSP);
  249. MSOAPI_(MSOOCV) MsoOcv_eql(MSOOCV *pocvSP);
  250. MSOAPI_(MSOOCV) MsoOcv_gtr_eql(MSOOCV *pocvSP);
  251. MSOAPI_(MSOOCV) MsoOcv_gtr_than(MSOOCV *pocvSP);
  252. MSOAPI_(MSOOCV) MsoOcv_not_eql(MSOOCV *pocvSP);
  253. MSOAPI_(MSOOCV) MsoOcv_assign(MSOOCV *pocvSP);
  254. MSOAPI_(MSOOCV) MsoOcv_plus(MSOOCV *pocvSP);
  255. MSOAPI_(MSOOCV) MsoOcv_minus(MSOOCV *pocvSP);
  256. MSOAPI_(MSOOCV) MsoOcv_mult(MSOOCV *pocvSP);
  257. MSOAPI_(MSOOCV) MsoOcv_divide(MSOOCV *pocvSP);
  258. MSOAPI_(MSOOCV) MsoOcv_mod(MSOOCV *pocvSP);
  259. MSOAPI_(MSOOCV) MsoOcv_increment(MSOOCV *pocvSP);
  260. MSOAPI_(MSOOCV) MsoOcv_decrement(MSOOCV *pocvSP);
  261. MSOAPI_(MSOOCV) MsoOcv_unary_plus(MSOOCV *pocvSP);
  262. MSOAPI_(MSOOCV) MsoOcv_unary_minus(MSOOCV *pocvSP);
  263. MSOAPI_(MSOOCV) MsoOcv_bitwise_not(MSOOCV *pocvSP);
  264. MSOAPI_(MSOOCV) MsoOcv_bitwise_and(MSOOCV *pocvSP);
  265. MSOAPI_(MSOOCV) MsoOcv_bitwise_or(MSOOCV *pocvSP);
  266. MSOAPI_(MSOOCV) MsoOcv_bitwise_xor(MSOOCV *pocvSP);
  267. MSOAPI_(MSOOCV) MsoOcv_shift_l(MSOOCV *pocvSP);
  268. MSOAPI_(MSOOCV) MsoOcv_shift_r(MSOOCV *pocvSP);
  269. MSOAPI_(MSOOCV) MsoOcv_dereference(MSOOCV *pocvSP);
  270. MSOAPI_(MSOOCV) MsoOcv_addr_of(MSOOCV *pocvSP);
  271. MSOAPI_(MSOOCV) MsoOcv_cast_as(MSOOCV *pocvSP);
  272. MSOAPI_(MSOOCV) MsoOcv_if(
  273. MSOOCII **ppocii,
  274. struct _MSOOCIS *pocis
  275. );
  276. MSOAPI_(MSOOCV) MsoOcv_inline_if(
  277. MSOOCII **ppocii,
  278. struct _MSOOCIS *pocis
  279. );
  280. MSOAPI_(MSOOCV) MsoOcv_let(
  281. MSOOCII **ppocii,
  282. struct _MSOOCIS *pocis
  283. );
  284. MSOAPI_(MSOOCV) MsoOcv_compound_stmt(
  285. MSOOCII **ppocii,
  286. struct _MSOOCIS *pocis
  287. );
  288. MSOAPI_(MSOOCV) MsoOcv_progn(
  289. MSOOCII **ppocii,
  290. struct _MSOOCIS *pocis
  291. );
  292. MSOAPI_(MSOOCV) MsoOcv_get_char(MSOOCV *pocvSP);
  293. MSOAPI_(MSOOCV) MsoOcv_get_uchar(MSOOCV *pocvSP);
  294. MSOAPI_(MSOOCV) MsoOcv_get_short(MSOOCV *pocvSP);
  295. MSOAPI_(MSOOCV) MsoOcv_get_ushort(MSOOCV *pocvSP);
  296. MSOAPI_(MSOOCV) MsoOcv_get_int(MSOOCV *pocvSP);
  297. MSOAPI_(MSOOCV) MsoOcv_get_uint(MSOOCV *pocvSP);
  298. MSOAPI_(MSOOCV) MsoOcv_get_long(MSOOCV *pocvSP);
  299. MSOAPI_(MSOOCV) MsoOcv_get_ulong(MSOOCV *pocvSP);
  300. MSOAPI_(MSOOCV) MsoOcv_get_float(MSOOCV *pocvSP);
  301. MSOAPI_(MSOOCV) MsoOcv_get_double(MSOOCV *pocvSP);
  302. MSOAPI_(MSOOCV) MsoOcv_get_ldouble(MSOOCV *pocvSP);
  303. MSOAPI_(MSOOCV) MsoOcv_set_char(MSOOCV *pocvSP);
  304. MSOAPI_(MSOOCV) MsoOcv_set_uchar(MSOOCV *pocvSP);
  305. MSOAPI_(MSOOCV) MsoOcv_set_short(MSOOCV *pocvSP);
  306. MSOAPI_(MSOOCV) MsoOcv_set_ushort(MSOOCV *pocvSP);
  307. MSOAPI_(MSOOCV) MsoOcv_set_int(MSOOCV *pocvSP);
  308. MSOAPI_(MSOOCV) MsoOcv_set_uint(MSOOCV *pocvSP);
  309. MSOAPI_(MSOOCV) MsoOcv_set_long(MSOOCV *pocvSP);
  310. MSOAPI_(MSOOCV) MsoOcv_set_ulong(MSOOCV *pocvSP);
  311. MSOAPI_(MSOOCV) MsoOcv_set_float(MSOOCV *pocvSP);
  312. MSOAPI_(MSOOCV) MsoOcv_set_double(MSOOCV *pocvSP);
  313. MSOAPI_(MSOOCV) MsoOcv_set_ldouble(MSOOCV *pocvSP);
  314. //############################################################################
  315. //
  316. // PRIVATE Interfaces
  317. //
  318. // To use, #define _OCI_PRIVATE
  319. //
  320. //############################################################################
  321. #ifdef _OCI_PRIVATE
  322. // Return the Argument descriptor associated with the function
  323. #define OcadArgDecripOcii(ocii, pocis) \
  324. ((pocis)->rgocadArgDesc[ocii])
  325. // Return the Argument descriptor list associated with the function
  326. #define PcbArgFromOcad(ocad, pocis) \
  327. (&(pocis)->rgcbImmedArg[ocad])
  328. #endif /* _OCI_PRIVATE */
  329. MSOEXTERN_C_END // ****************** End extern "C" *********************
  330. #endif /* !EMOCI_H */