clipsruby 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clipsruby/agenda.c +1373 -0
  3. data/ext/clipsruby/agenda.h +169 -0
  4. data/ext/clipsruby/analysis.c +1142 -0
  5. data/ext/clipsruby/analysis.h +61 -0
  6. data/ext/clipsruby/argacces.c +526 -0
  7. data/ext/clipsruby/argacces.h +77 -0
  8. data/ext/clipsruby/bload.c +884 -0
  9. data/ext/clipsruby/bload.h +94 -0
  10. data/ext/clipsruby/bmathfun.c +557 -0
  11. data/ext/clipsruby/bmathfun.h +66 -0
  12. data/ext/clipsruby/bsave.c +634 -0
  13. data/ext/clipsruby/bsave.h +130 -0
  14. data/ext/clipsruby/classcom.c +976 -0
  15. data/ext/clipsruby/classcom.h +115 -0
  16. data/ext/clipsruby/classexm.c +1376 -0
  17. data/ext/clipsruby/classexm.h +97 -0
  18. data/ext/clipsruby/classfun.c +1392 -0
  19. data/ext/clipsruby/classfun.h +164 -0
  20. data/ext/clipsruby/classinf.c +1245 -0
  21. data/ext/clipsruby/classinf.h +94 -0
  22. data/ext/clipsruby/classini.c +843 -0
  23. data/ext/clipsruby/classini.h +75 -0
  24. data/ext/clipsruby/classpsr.c +957 -0
  25. data/ext/clipsruby/classpsr.h +73 -0
  26. data/ext/clipsruby/clips.h +133 -0
  27. data/ext/clipsruby/clipsruby.c +619 -0
  28. data/ext/clipsruby/clsltpsr.c +931 -0
  29. data/ext/clipsruby/clsltpsr.h +72 -0
  30. data/ext/clipsruby/commline.c +1217 -0
  31. data/ext/clipsruby/commline.h +131 -0
  32. data/ext/clipsruby/conscomp.c +1593 -0
  33. data/ext/clipsruby/conscomp.h +150 -0
  34. data/ext/clipsruby/constant.h +264 -0
  35. data/ext/clipsruby/constrct.c +1090 -0
  36. data/ext/clipsruby/constrct.h +216 -0
  37. data/ext/clipsruby/constrnt.c +554 -0
  38. data/ext/clipsruby/constrnt.h +132 -0
  39. data/ext/clipsruby/crstrtgy.c +1088 -0
  40. data/ext/clipsruby/crstrtgy.h +85 -0
  41. data/ext/clipsruby/cstrcbin.c +185 -0
  42. data/ext/clipsruby/cstrcbin.h +61 -0
  43. data/ext/clipsruby/cstrccmp.h +43 -0
  44. data/ext/clipsruby/cstrccom.c +1791 -0
  45. data/ext/clipsruby/cstrccom.h +115 -0
  46. data/ext/clipsruby/cstrcpsr.c +835 -0
  47. data/ext/clipsruby/cstrcpsr.h +97 -0
  48. data/ext/clipsruby/cstrnbin.c +282 -0
  49. data/ext/clipsruby/cstrnbin.h +55 -0
  50. data/ext/clipsruby/cstrnchk.c +826 -0
  51. data/ext/clipsruby/cstrnchk.h +91 -0
  52. data/ext/clipsruby/cstrncmp.c +238 -0
  53. data/ext/clipsruby/cstrncmp.h +57 -0
  54. data/ext/clipsruby/cstrnops.c +1176 -0
  55. data/ext/clipsruby/cstrnops.h +47 -0
  56. data/ext/clipsruby/cstrnpsr.c +1394 -0
  57. data/ext/clipsruby/cstrnpsr.h +88 -0
  58. data/ext/clipsruby/cstrnutl.c +564 -0
  59. data/ext/clipsruby/cstrnutl.h +54 -0
  60. data/ext/clipsruby/default.c +454 -0
  61. data/ext/clipsruby/default.h +57 -0
  62. data/ext/clipsruby/defins.c +971 -0
  63. data/ext/clipsruby/defins.h +127 -0
  64. data/ext/clipsruby/developr.c +677 -0
  65. data/ext/clipsruby/developr.h +69 -0
  66. data/ext/clipsruby/dffctbin.c +477 -0
  67. data/ext/clipsruby/dffctbin.h +76 -0
  68. data/ext/clipsruby/dffctbsc.c +308 -0
  69. data/ext/clipsruby/dffctbsc.h +72 -0
  70. data/ext/clipsruby/dffctcmp.c +297 -0
  71. data/ext/clipsruby/dffctcmp.h +44 -0
  72. data/ext/clipsruby/dffctdef.c +364 -0
  73. data/ext/clipsruby/dffctdef.h +104 -0
  74. data/ext/clipsruby/dffctpsr.c +179 -0
  75. data/ext/clipsruby/dffctpsr.h +49 -0
  76. data/ext/clipsruby/dffnxbin.c +520 -0
  77. data/ext/clipsruby/dffnxbin.h +67 -0
  78. data/ext/clipsruby/dffnxcmp.c +378 -0
  79. data/ext/clipsruby/dffnxcmp.h +54 -0
  80. data/ext/clipsruby/dffnxexe.c +241 -0
  81. data/ext/clipsruby/dffnxexe.h +58 -0
  82. data/ext/clipsruby/dffnxfun.c +1192 -0
  83. data/ext/clipsruby/dffnxfun.h +155 -0
  84. data/ext/clipsruby/dffnxpsr.c +514 -0
  85. data/ext/clipsruby/dffnxpsr.h +57 -0
  86. data/ext/clipsruby/dfinsbin.c +509 -0
  87. data/ext/clipsruby/dfinsbin.h +66 -0
  88. data/ext/clipsruby/dfinscmp.c +345 -0
  89. data/ext/clipsruby/dfinscmp.h +48 -0
  90. data/ext/clipsruby/drive.c +1191 -0
  91. data/ext/clipsruby/drive.h +65 -0
  92. data/ext/clipsruby/emathfun.c +1213 -0
  93. data/ext/clipsruby/emathfun.h +99 -0
  94. data/ext/clipsruby/engine.c +1568 -0
  95. data/ext/clipsruby/engine.h +203 -0
  96. data/ext/clipsruby/entities.h +276 -0
  97. data/ext/clipsruby/envrnbld.c +514 -0
  98. data/ext/clipsruby/envrnbld.h +40 -0
  99. data/ext/clipsruby/envrnmnt.c +257 -0
  100. data/ext/clipsruby/envrnmnt.h +112 -0
  101. data/ext/clipsruby/evaluatn.c +1736 -0
  102. data/ext/clipsruby/evaluatn.h +211 -0
  103. data/ext/clipsruby/expressn.c +494 -0
  104. data/ext/clipsruby/expressn.h +154 -0
  105. data/ext/clipsruby/exprnbin.c +538 -0
  106. data/ext/clipsruby/exprnbin.h +60 -0
  107. data/ext/clipsruby/exprnops.c +564 -0
  108. data/ext/clipsruby/exprnops.h +67 -0
  109. data/ext/clipsruby/exprnpsr.c +1112 -0
  110. data/ext/clipsruby/exprnpsr.h +98 -0
  111. data/ext/clipsruby/extconf.rb +2 -0
  112. data/ext/clipsruby/extnfunc.c +1015 -0
  113. data/ext/clipsruby/extnfunc.h +157 -0
  114. data/ext/clipsruby/factbin.c +447 -0
  115. data/ext/clipsruby/factbin.h +56 -0
  116. data/ext/clipsruby/factbld.c +1035 -0
  117. data/ext/clipsruby/factbld.h +63 -0
  118. data/ext/clipsruby/factcmp.c +386 -0
  119. data/ext/clipsruby/factcmp.h +46 -0
  120. data/ext/clipsruby/factcom.c +759 -0
  121. data/ext/clipsruby/factcom.h +80 -0
  122. data/ext/clipsruby/factfile.c +1761 -0
  123. data/ext/clipsruby/factfile.h +54 -0
  124. data/ext/clipsruby/factfun.c +682 -0
  125. data/ext/clipsruby/factfun.h +77 -0
  126. data/ext/clipsruby/factgen.c +1305 -0
  127. data/ext/clipsruby/factgen.h +229 -0
  128. data/ext/clipsruby/facthsh.c +438 -0
  129. data/ext/clipsruby/facthsh.h +81 -0
  130. data/ext/clipsruby/factlhs.c +250 -0
  131. data/ext/clipsruby/factlhs.h +54 -0
  132. data/ext/clipsruby/factmch.c +905 -0
  133. data/ext/clipsruby/factmch.h +68 -0
  134. data/ext/clipsruby/factmngr.c +3373 -0
  135. data/ext/clipsruby/factmngr.h +325 -0
  136. data/ext/clipsruby/factprt.c +498 -0
  137. data/ext/clipsruby/factprt.h +60 -0
  138. data/ext/clipsruby/factqpsr.c +796 -0
  139. data/ext/clipsruby/factqpsr.h +61 -0
  140. data/ext/clipsruby/factqury.c +1267 -0
  141. data/ext/clipsruby/factqury.h +112 -0
  142. data/ext/clipsruby/factrete.c +978 -0
  143. data/ext/clipsruby/factrete.h +70 -0
  144. data/ext/clipsruby/factrhs.c +667 -0
  145. data/ext/clipsruby/factrhs.h +55 -0
  146. data/ext/clipsruby/filecom.c +353 -0
  147. data/ext/clipsruby/filecom.h +137 -0
  148. data/ext/clipsruby/filertr.c +481 -0
  149. data/ext/clipsruby/filertr.h +94 -0
  150. data/ext/clipsruby/fileutil.c +1020 -0
  151. data/ext/clipsruby/fileutil.h +50 -0
  152. data/ext/clipsruby/generate.c +1079 -0
  153. data/ext/clipsruby/generate.h +57 -0
  154. data/ext/clipsruby/genrcbin.c +902 -0
  155. data/ext/clipsruby/genrcbin.h +69 -0
  156. data/ext/clipsruby/genrccmp.c +640 -0
  157. data/ext/clipsruby/genrccmp.h +59 -0
  158. data/ext/clipsruby/genrccom.c +2017 -0
  159. data/ext/clipsruby/genrccom.h +119 -0
  160. data/ext/clipsruby/genrcexe.c +737 -0
  161. data/ext/clipsruby/genrcexe.h +73 -0
  162. data/ext/clipsruby/genrcfun.c +890 -0
  163. data/ext/clipsruby/genrcfun.h +185 -0
  164. data/ext/clipsruby/genrcpsr.c +1618 -0
  165. data/ext/clipsruby/genrcpsr.h +80 -0
  166. data/ext/clipsruby/globlbin.c +458 -0
  167. data/ext/clipsruby/globlbin.h +71 -0
  168. data/ext/clipsruby/globlbsc.c +361 -0
  169. data/ext/clipsruby/globlbsc.h +83 -0
  170. data/ext/clipsruby/globlcmp.c +330 -0
  171. data/ext/clipsruby/globlcmp.h +52 -0
  172. data/ext/clipsruby/globlcom.c +289 -0
  173. data/ext/clipsruby/globlcom.h +63 -0
  174. data/ext/clipsruby/globldef.c +1087 -0
  175. data/ext/clipsruby/globldef.h +151 -0
  176. data/ext/clipsruby/globlpsr.c +530 -0
  177. data/ext/clipsruby/globlpsr.h +59 -0
  178. data/ext/clipsruby/immthpsr.c +431 -0
  179. data/ext/clipsruby/immthpsr.h +55 -0
  180. data/ext/clipsruby/incrrset.c +530 -0
  181. data/ext/clipsruby/incrrset.h +73 -0
  182. data/ext/clipsruby/inherpsr.c +850 -0
  183. data/ext/clipsruby/inherpsr.h +52 -0
  184. data/ext/clipsruby/inscom.c +2076 -0
  185. data/ext/clipsruby/inscom.h +182 -0
  186. data/ext/clipsruby/insfile.c +1764 -0
  187. data/ext/clipsruby/insfile.h +96 -0
  188. data/ext/clipsruby/insfun.c +1451 -0
  189. data/ext/clipsruby/insfun.h +134 -0
  190. data/ext/clipsruby/insmngr.c +2550 -0
  191. data/ext/clipsruby/insmngr.h +125 -0
  192. data/ext/clipsruby/insmoddp.c +1041 -0
  193. data/ext/clipsruby/insmoddp.h +91 -0
  194. data/ext/clipsruby/insmult.c +804 -0
  195. data/ext/clipsruby/insmult.h +62 -0
  196. data/ext/clipsruby/inspsr.c +602 -0
  197. data/ext/clipsruby/inspsr.h +60 -0
  198. data/ext/clipsruby/insquery.c +1278 -0
  199. data/ext/clipsruby/insquery.h +115 -0
  200. data/ext/clipsruby/insqypsr.c +729 -0
  201. data/ext/clipsruby/insqypsr.h +63 -0
  202. data/ext/clipsruby/iofun.c +2045 -0
  203. data/ext/clipsruby/iofun.h +116 -0
  204. data/ext/clipsruby/lgcldpnd.c +644 -0
  205. data/ext/clipsruby/lgcldpnd.h +75 -0
  206. data/ext/clipsruby/main.c +112 -0
  207. data/ext/clipsruby/match.h +142 -0
  208. data/ext/clipsruby/memalloc.c +481 -0
  209. data/ext/clipsruby/memalloc.h +197 -0
  210. data/ext/clipsruby/miscfun.c +1801 -0
  211. data/ext/clipsruby/miscfun.h +132 -0
  212. data/ext/clipsruby/modulbin.c +607 -0
  213. data/ext/clipsruby/modulbin.h +84 -0
  214. data/ext/clipsruby/modulbsc.c +347 -0
  215. data/ext/clipsruby/modulbsc.h +67 -0
  216. data/ext/clipsruby/modulcmp.c +499 -0
  217. data/ext/clipsruby/modulcmp.h +54 -0
  218. data/ext/clipsruby/moduldef.c +817 -0
  219. data/ext/clipsruby/moduldef.h +271 -0
  220. data/ext/clipsruby/modulpsr.c +1150 -0
  221. data/ext/clipsruby/modulpsr.h +69 -0
  222. data/ext/clipsruby/modulutl.c +1036 -0
  223. data/ext/clipsruby/modulutl.h +84 -0
  224. data/ext/clipsruby/msgcom.c +1221 -0
  225. data/ext/clipsruby/msgcom.h +125 -0
  226. data/ext/clipsruby/msgfun.c +1076 -0
  227. data/ext/clipsruby/msgfun.h +118 -0
  228. data/ext/clipsruby/msgpass.c +1441 -0
  229. data/ext/clipsruby/msgpass.h +103 -0
  230. data/ext/clipsruby/msgpsr.c +698 -0
  231. data/ext/clipsruby/msgpsr.h +73 -0
  232. data/ext/clipsruby/multifld.c +1404 -0
  233. data/ext/clipsruby/multifld.h +130 -0
  234. data/ext/clipsruby/multifun.c +2182 -0
  235. data/ext/clipsruby/multifun.h +102 -0
  236. data/ext/clipsruby/network.h +142 -0
  237. data/ext/clipsruby/objbin.c +1522 -0
  238. data/ext/clipsruby/objbin.h +79 -0
  239. data/ext/clipsruby/objcmp.c +1507 -0
  240. data/ext/clipsruby/objcmp.h +71 -0
  241. data/ext/clipsruby/object.h +260 -0
  242. data/ext/clipsruby/objrtbin.c +701 -0
  243. data/ext/clipsruby/objrtbin.h +79 -0
  244. data/ext/clipsruby/objrtbld.c +2393 -0
  245. data/ext/clipsruby/objrtbld.h +66 -0
  246. data/ext/clipsruby/objrtcmp.c +734 -0
  247. data/ext/clipsruby/objrtcmp.h +66 -0
  248. data/ext/clipsruby/objrtfnx.c +1330 -0
  249. data/ext/clipsruby/objrtfnx.h +222 -0
  250. data/ext/clipsruby/objrtgen.c +736 -0
  251. data/ext/clipsruby/objrtgen.h +63 -0
  252. data/ext/clipsruby/objrtmch.c +1524 -0
  253. data/ext/clipsruby/objrtmch.h +160 -0
  254. data/ext/clipsruby/parsefun.c +415 -0
  255. data/ext/clipsruby/parsefun.h +67 -0
  256. data/ext/clipsruby/pattern.c +1265 -0
  257. data/ext/clipsruby/pattern.h +163 -0
  258. data/ext/clipsruby/pprint.c +328 -0
  259. data/ext/clipsruby/pprint.h +79 -0
  260. data/ext/clipsruby/prccode.c +1478 -0
  261. data/ext/clipsruby/prccode.h +145 -0
  262. data/ext/clipsruby/prcdrfun.c +640 -0
  263. data/ext/clipsruby/prcdrfun.h +95 -0
  264. data/ext/clipsruby/prcdrpsr.c +1068 -0
  265. data/ext/clipsruby/prcdrpsr.h +79 -0
  266. data/ext/clipsruby/prdctfun.c +869 -0
  267. data/ext/clipsruby/prdctfun.h +77 -0
  268. data/ext/clipsruby/prntutil.c +878 -0
  269. data/ext/clipsruby/prntutil.h +125 -0
  270. data/ext/clipsruby/proflfun.c +827 -0
  271. data/ext/clipsruby/proflfun.h +118 -0
  272. data/ext/clipsruby/reorder.c +2082 -0
  273. data/ext/clipsruby/reorder.h +172 -0
  274. data/ext/clipsruby/reteutil.c +1732 -0
  275. data/ext/clipsruby/reteutil.h +111 -0
  276. data/ext/clipsruby/retract.c +710 -0
  277. data/ext/clipsruby/retract.h +74 -0
  278. data/ext/clipsruby/router.c +737 -0
  279. data/ext/clipsruby/router.h +147 -0
  280. data/ext/clipsruby/rulebin.c +1136 -0
  281. data/ext/clipsruby/rulebin.h +153 -0
  282. data/ext/clipsruby/rulebld.c +1328 -0
  283. data/ext/clipsruby/rulebld.h +62 -0
  284. data/ext/clipsruby/rulebsc.c +517 -0
  285. data/ext/clipsruby/rulebsc.h +91 -0
  286. data/ext/clipsruby/rulecmp.c +733 -0
  287. data/ext/clipsruby/rulecmp.h +63 -0
  288. data/ext/clipsruby/rulecom.c +1583 -0
  289. data/ext/clipsruby/rulecom.h +116 -0
  290. data/ext/clipsruby/rulecstr.c +892 -0
  291. data/ext/clipsruby/rulecstr.h +53 -0
  292. data/ext/clipsruby/ruledef.c +559 -0
  293. data/ext/clipsruby/ruledef.h +179 -0
  294. data/ext/clipsruby/ruledlt.c +599 -0
  295. data/ext/clipsruby/ruledlt.h +58 -0
  296. data/ext/clipsruby/rulelhs.c +1216 -0
  297. data/ext/clipsruby/rulelhs.h +52 -0
  298. data/ext/clipsruby/rulepsr.c +1073 -0
  299. data/ext/clipsruby/rulepsr.h +61 -0
  300. data/ext/clipsruby/scanner.c +856 -0
  301. data/ext/clipsruby/scanner.h +112 -0
  302. data/ext/clipsruby/setup.h +488 -0
  303. data/ext/clipsruby/sortfun.c +433 -0
  304. data/ext/clipsruby/sortfun.h +55 -0
  305. data/ext/clipsruby/strngfun.c +1173 -0
  306. data/ext/clipsruby/strngfun.h +96 -0
  307. data/ext/clipsruby/strngrtr.c +523 -0
  308. data/ext/clipsruby/strngrtr.h +97 -0
  309. data/ext/clipsruby/symblbin.c +648 -0
  310. data/ext/clipsruby/symblbin.h +64 -0
  311. data/ext/clipsruby/symblcmp.c +893 -0
  312. data/ext/clipsruby/symblcmp.h +61 -0
  313. data/ext/clipsruby/symbol.c +1961 -0
  314. data/ext/clipsruby/symbol.h +243 -0
  315. data/ext/clipsruby/sysdep.c +894 -0
  316. data/ext/clipsruby/sysdep.h +164 -0
  317. data/ext/clipsruby/textpro.c +1388 -0
  318. data/ext/clipsruby/textpro.h +77 -0
  319. data/ext/clipsruby/tmpltbin.c +609 -0
  320. data/ext/clipsruby/tmpltbin.h +108 -0
  321. data/ext/clipsruby/tmpltbsc.c +327 -0
  322. data/ext/clipsruby/tmpltbsc.h +87 -0
  323. data/ext/clipsruby/tmpltcmp.c +450 -0
  324. data/ext/clipsruby/tmpltcmp.h +57 -0
  325. data/ext/clipsruby/tmpltdef.c +584 -0
  326. data/ext/clipsruby/tmpltdef.h +155 -0
  327. data/ext/clipsruby/tmpltfun.c +2477 -0
  328. data/ext/clipsruby/tmpltfun.h +122 -0
  329. data/ext/clipsruby/tmpltlhs.c +379 -0
  330. data/ext/clipsruby/tmpltlhs.h +50 -0
  331. data/ext/clipsruby/tmpltpsr.c +819 -0
  332. data/ext/clipsruby/tmpltpsr.h +59 -0
  333. data/ext/clipsruby/tmpltrhs.c +595 -0
  334. data/ext/clipsruby/tmpltrhs.h +55 -0
  335. data/ext/clipsruby/tmpltutl.c +637 -0
  336. data/ext/clipsruby/tmpltutl.h +82 -0
  337. data/ext/clipsruby/userdata.c +156 -0
  338. data/ext/clipsruby/userdata.h +72 -0
  339. data/ext/clipsruby/userfunctions.c +70 -0
  340. data/ext/clipsruby/usrsetup.h +7 -0
  341. data/ext/clipsruby/utility.c +1594 -0
  342. data/ext/clipsruby/utility.h +250 -0
  343. data/ext/clipsruby/watch.c +865 -0
  344. data/ext/clipsruby/watch.h +124 -0
  345. data/lib/clipsruby.rb +1 -0
  346. metadata +388 -0
@@ -0,0 +1,890 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.41 12/04/22 */
5
+ /* */
6
+ /* */
7
+ /*******************************************************/
8
+
9
+ /*************************************************************/
10
+ /* Purpose: Generic Functions Internal Routines */
11
+ /* */
12
+ /* Principal Programmer(s): */
13
+ /* Brian L. Dantes */
14
+ /* */
15
+ /* Contributing Programmer(s): */
16
+ /* */
17
+ /* Revision History: */
18
+ /* */
19
+ /* 6.23: Changed name of variable log to logName */
20
+ /* because of Unix compiler warnings of shadowed */
21
+ /* definitions. */
22
+ /* */
23
+ /* 6.24: Removed IMPERATIVE_METHODS compilation flag. */
24
+ /* */
25
+ /* Renamed BOOLEAN macro type to intBool. */
26
+ /* */
27
+ /* 6.30: Removed conditional code for unsupported */
28
+ /* compilers/operating systems (IBM_MCW, */
29
+ /* MAC_MCW, and IBM_TBC). */
30
+ /* */
31
+ /* Changed integer type/precision. */
32
+ /* */
33
+ /* Added const qualifiers to remove C++ */
34
+ /* deprecation warnings. */
35
+ /* */
36
+ /* Converted API macros to function calls. */
37
+ /* */
38
+ /* Fixed linkage issue when DEBUGGING_FUNCTIONS */
39
+ /* is set to 0 and PROFILING_FUNCTIONS is set to */
40
+ /* 1. */
41
+ /* */
42
+ /* Fixed typing issue when OBJECT_SYSTEM */
43
+ /* compiler flag is set to 0. */
44
+ /* */
45
+ /* 6.40: Added Env prefix to GetEvaluationError and */
46
+ /* SetEvaluationError functions. */
47
+ /* */
48
+ /* Pragma once and other inclusion changes. */
49
+ /* */
50
+ /* Added support for booleans with <stdbool.h>. */
51
+ /* */
52
+ /* Removed use of void pointers for specific */
53
+ /* data structures. */
54
+ /* */
55
+ /* UDF redesign. */
56
+ /* */
57
+ /* 6.41: Used gensnprintf in place of gensprintf and. */
58
+ /* sprintf. */
59
+ /* */
60
+ /*************************************************************/
61
+
62
+ /* =========================================
63
+ *****************************************
64
+ EXTERNAL DEFINITIONS
65
+ =========================================
66
+ ***************************************** */
67
+ #include "setup.h"
68
+
69
+ #if DEFGENERIC_CONSTRUCT
70
+
71
+ #if BLOAD || BLOAD_AND_BSAVE
72
+ #include "bload.h"
73
+ #endif
74
+
75
+ #if OBJECT_SYSTEM
76
+ #include "classcom.h"
77
+ #include "classfun.h"
78
+ #endif
79
+
80
+ #include "argacces.h"
81
+ #include "constrct.h"
82
+ #include "cstrccom.h"
83
+ #include "cstrcpsr.h"
84
+ #include "envrnmnt.h"
85
+ #include "genrccom.h"
86
+ #include "genrcexe.h"
87
+ #include "genrcfun.h"
88
+ #include "memalloc.h"
89
+ #include "modulutl.h"
90
+ #include "prccode.h"
91
+ #include "prntutil.h"
92
+ #include "router.h"
93
+ #include "sysdep.h"
94
+
95
+ #include "genrcfun.h"
96
+
97
+ /* =========================================
98
+ *****************************************
99
+ INTERNALLY VISIBLE FUNCTION HEADERS
100
+ =========================================
101
+ ***************************************** */
102
+
103
+ #if DEBUGGING_FUNCTIONS
104
+ static void DisplayGenericCore(Environment *,Defgeneric *);
105
+ #endif
106
+
107
+ #if RUN_TIME
108
+ static void RuntimeDefgenericAction(Environment *,ConstructHeader *,void *);
109
+ #endif
110
+
111
+ /* =========================================
112
+ *****************************************
113
+ EXTERNALLY VISIBLE FUNCTIONS
114
+ =========================================
115
+ ***************************************** */
116
+
117
+ #if ! RUN_TIME
118
+
119
+ /***************************************************
120
+ NAME : ClearDefgenericsReady
121
+ DESCRIPTION : Determines if it is safe to
122
+ remove all defgenerics
123
+ Assumes *all* constructs will be
124
+ deleted - only checks to see if
125
+ any methods are currently
126
+ executing
127
+ INPUTS : None
128
+ RETURNS : True if no methods are
129
+ executing, false otherwise
130
+ SIDE EFFECTS : None
131
+ NOTES : Used by (clear) and (bload)
132
+ ***************************************************/
133
+ bool ClearDefgenericsReady(
134
+ Environment *theEnv,
135
+ void *context)
136
+ {
137
+ return((DefgenericData(theEnv)->CurrentGeneric != NULL) ? false : true);
138
+ }
139
+
140
+ /*****************************************************
141
+ NAME : AllocateDefgenericModule
142
+ DESCRIPTION : Creates and initializes a
143
+ list of defgenerics for a new module
144
+ INPUTS : None
145
+ RETURNS : The new deffunction module
146
+ SIDE EFFECTS : Deffunction module created
147
+ NOTES : None
148
+ *****************************************************/
149
+ void *AllocateDefgenericModule(
150
+ Environment *theEnv)
151
+ {
152
+ return (void *) get_struct(theEnv,defgenericModule);
153
+ }
154
+
155
+ /***************************************************
156
+ NAME : FreeDefgenericModule
157
+ DESCRIPTION : Removes a deffunction module and
158
+ all associated deffunctions
159
+ INPUTS : The deffunction module
160
+ RETURNS : Nothing useful
161
+ SIDE EFFECTS : Module and deffunctions deleted
162
+ NOTES : None
163
+ ***************************************************/
164
+ void FreeDefgenericModule(
165
+ Environment *theEnv,
166
+ void *theItem)
167
+ {
168
+ #if (! BLOAD_ONLY)
169
+ FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,DefgenericData(theEnv)->DefgenericConstruct);
170
+ #endif
171
+ rtn_struct(theEnv,defgenericModule,theItem);
172
+ }
173
+
174
+ #endif
175
+
176
+ #if RUN_TIME
177
+
178
+ /*************************************************/
179
+ /* RuntimeDefgenericAction: Action to be applied */
180
+ /* to each deffacts construct when a runtime */
181
+ /* initialization occurs. */
182
+ /*************************************************/
183
+ static void RuntimeDefgenericAction(
184
+ Environment *theEnv,
185
+ ConstructHeader *theConstruct,
186
+ void *buffer)
187
+ {
188
+ #if MAC_XCD
189
+ #pragma unused(buffer)
190
+ #endif
191
+ Defgeneric *theDefgeneric = (Defgeneric *) theConstruct;
192
+ long gi;
193
+
194
+ theDefgeneric->header.env = theEnv;
195
+
196
+ for (gi = 0 ; gi < theDefgeneric->mcnt ; gi++)
197
+ { theDefgeneric->methods[gi].header.env = theEnv; }
198
+ }
199
+
200
+ /********************************/
201
+ /* DefgenericRunTimeInitialize: */
202
+ /********************************/
203
+ void DefgenericRunTimeInitialize(
204
+ Environment *theEnv)
205
+ {
206
+ DoForAllConstructs(theEnv,RuntimeDefgenericAction,DefgenericData(theEnv)->DefgenericModuleIndex,true,NULL);
207
+ }
208
+
209
+ #endif
210
+
211
+ #if (! BLOAD_ONLY) && (! RUN_TIME)
212
+
213
+ /************************************************************
214
+ NAME : ClearDefmethods
215
+ DESCRIPTION : Deletes all defmethods - generic headers
216
+ are left intact
217
+ INPUTS : None
218
+ RETURNS : True if all methods deleted, false otherwise
219
+ SIDE EFFECTS : Defmethods deleted
220
+ NOTES : Clearing generic functions is done in
221
+ two stages
222
+
223
+ 1) Delete all methods (to clear any
224
+ references to other constructs)
225
+ 2) Delete all generic headers
226
+
227
+ This allows other constructs which
228
+ mutually refer to generic functions
229
+ to be cleared
230
+ ************************************************************/
231
+ bool ClearDefmethods(
232
+ Environment *theEnv)
233
+ {
234
+ Defgeneric *gfunc;
235
+ bool success = true;
236
+
237
+ #if BLOAD || BLOAD_AND_BSAVE
238
+ if (Bloaded(theEnv) == true) return false;
239
+ #endif
240
+
241
+ gfunc = GetNextDefgeneric(theEnv,NULL);
242
+ while (gfunc != NULL)
243
+ {
244
+ if (RemoveAllExplicitMethods(theEnv,gfunc) == false)
245
+ success = false;
246
+ gfunc = GetNextDefgeneric(theEnv,gfunc);
247
+ }
248
+ return success;
249
+ }
250
+
251
+ /*****************************************************************
252
+ NAME : RemoveAllExplicitMethods
253
+ DESCRIPTION : Deletes all explicit defmethods - generic headers
254
+ are left intact (as well as a method for an
255
+ overloaded system function)
256
+ INPUTS : None
257
+ RETURNS : True if all methods deleted, false otherwise
258
+ SIDE EFFECTS : Explicit defmethods deleted
259
+ NOTES : None
260
+ *****************************************************************/
261
+ bool RemoveAllExplicitMethods(
262
+ Environment *theEnv,
263
+ Defgeneric *gfunc)
264
+ {
265
+ unsigned short i, j;
266
+ unsigned short systemMethodCount = 0;
267
+ Defmethod *narr;
268
+
269
+ if (MethodsExecuting(gfunc) == false)
270
+ {
271
+ for (i = 0 ; i < gfunc->mcnt ; i++)
272
+ {
273
+ if (gfunc->methods[i].system)
274
+ systemMethodCount++;
275
+ else
276
+ DeleteMethodInfo(theEnv,gfunc,&gfunc->methods[i]);
277
+ }
278
+ if (systemMethodCount != 0)
279
+ {
280
+ narr = (Defmethod *) gm2(theEnv,(systemMethodCount * sizeof(Defmethod)));
281
+ i = 0;
282
+ j = 0;
283
+ while (i < gfunc->mcnt)
284
+ {
285
+ if (gfunc->methods[i].system)
286
+ GenCopyMemory(Defmethod,1,&narr[j++],&gfunc->methods[i]);
287
+ i++;
288
+ }
289
+ rm(theEnv,gfunc->methods,(sizeof(Defmethod) * gfunc->mcnt));
290
+ gfunc->mcnt = systemMethodCount;
291
+ gfunc->methods = narr;
292
+ }
293
+ else
294
+ {
295
+ if (gfunc->mcnt != 0)
296
+ rm(theEnv,gfunc->methods,(sizeof(Defmethod) * gfunc->mcnt));
297
+ gfunc->mcnt = 0;
298
+ gfunc->methods = NULL;
299
+ }
300
+ return true;
301
+ }
302
+ return false;
303
+ }
304
+
305
+ /**************************************************
306
+ NAME : RemoveDefgeneric
307
+ DESCRIPTION : Removes a generic function node
308
+ from the generic list along with
309
+ all its methods
310
+ INPUTS : The generic function
311
+ RETURNS : Nothing useful
312
+ SIDE EFFECTS : List adjusted
313
+ Nodes deallocated
314
+ NOTES : Assumes generic is not in use!!!
315
+ **************************************************/
316
+ void RemoveDefgeneric(
317
+ Environment *theEnv,
318
+ Defgeneric *theDefgeneric)
319
+ {
320
+ long i;
321
+
322
+ for (i = 0 ; i < theDefgeneric->mcnt ; i++)
323
+ DeleteMethodInfo(theEnv,theDefgeneric,&theDefgeneric->methods[i]);
324
+
325
+ if (theDefgeneric->mcnt != 0)
326
+ { rm(theEnv,theDefgeneric->methods,(sizeof(Defmethod) * theDefgeneric->mcnt)); }
327
+ ReleaseLexeme(theEnv,GetDefgenericNamePointer(theDefgeneric));
328
+ SetDefgenericPPForm(theEnv,theDefgeneric,NULL);
329
+ ClearUserDataList(theEnv,theDefgeneric->header.usrData);
330
+ rtn_struct(theEnv,defgeneric,theDefgeneric);
331
+ }
332
+
333
+ /****************************************************************
334
+ NAME : ClearDefgenerics
335
+ DESCRIPTION : Deletes all generic headers
336
+ INPUTS : None
337
+ RETURNS : True if all methods deleted, false otherwise
338
+ SIDE EFFECTS : Generic headers deleted (and any implicit system
339
+ function methods)
340
+ NOTES : None
341
+ ****************************************************************/
342
+ bool ClearDefgenerics(
343
+ Environment *theEnv)
344
+ {
345
+ Defgeneric *gfunc, *gtmp;
346
+ bool success = true;
347
+
348
+ #if BLOAD || BLOAD_AND_BSAVE
349
+ if (Bloaded(theEnv) == true) return false;
350
+ #endif
351
+
352
+ gfunc = GetNextDefgeneric(theEnv,NULL);
353
+ while (gfunc != NULL)
354
+ {
355
+ gtmp = gfunc;
356
+ gfunc = GetNextDefgeneric(theEnv,gfunc);
357
+ if (RemoveAllExplicitMethods(theEnv,gtmp) == false)
358
+ {
359
+ CantDeleteItemErrorMessage(theEnv,"generic function",DefgenericName(gtmp));
360
+ success = false;
361
+ }
362
+ else
363
+ {
364
+ RemoveConstructFromModule(theEnv,&gtmp->header);
365
+ RemoveDefgeneric(theEnv,gtmp);
366
+ }
367
+ }
368
+ return(success);
369
+ }
370
+
371
+ /********************************************************
372
+ NAME : MethodAlterError
373
+ DESCRIPTION : Prints out an error message reflecting
374
+ that a generic function's methods
375
+ cannot be altered while any of them
376
+ are executing
377
+ INPUTS : The generic function
378
+ RETURNS : Nothing useful
379
+ SIDE EFFECTS : None
380
+ NOTES : None
381
+ ********************************************************/
382
+ void MethodAlterError(
383
+ Environment *theEnv,
384
+ Defgeneric *gfunc)
385
+ {
386
+ PrintErrorID(theEnv,"GENRCFUN",1,false);
387
+ WriteString(theEnv,STDERR,"Defgeneric '");
388
+ WriteString(theEnv,STDERR,DefgenericName(gfunc));
389
+ WriteString(theEnv,STDERR,"' cannot be modified while one of its methods is executing.\n");
390
+ }
391
+
392
+ /***************************************************
393
+ NAME : DeleteMethodInfo
394
+ DESCRIPTION : Deallocates all the data associated
395
+ w/ a method but does not release
396
+ the method structure itself
397
+ INPUTS : 1) The generic function address
398
+ 2) The method address
399
+ RETURNS : Nothing useful
400
+ SIDE EFFECTS : Nodes deallocated
401
+ NOTES : None
402
+ ***************************************************/
403
+ void DeleteMethodInfo(
404
+ Environment *theEnv,
405
+ Defgeneric *gfunc,
406
+ Defmethod *meth)
407
+ {
408
+ short j,k;
409
+ RESTRICTION *rptr;
410
+
411
+ SaveBusyCount(gfunc);
412
+ ExpressionDeinstall(theEnv,meth->actions);
413
+ ReturnPackedExpression(theEnv,meth->actions);
414
+ ClearUserDataList(theEnv,meth->header.usrData);
415
+ if (meth->header.ppForm != NULL)
416
+ rm(theEnv,(void *) meth->header.ppForm,(sizeof(char) * (strlen(meth->header.ppForm)+1)));
417
+ for (j = 0 ; j < meth->restrictionCount ; j++)
418
+ {
419
+ rptr = &meth->restrictions[j];
420
+
421
+ for (k = 0 ; k < rptr->tcnt ; k++)
422
+ #if OBJECT_SYSTEM
423
+ DecrementDefclassBusyCount(theEnv,(Defclass *) rptr->types[k]);
424
+ #else
425
+ ReleaseInteger(theEnv,(CLIPSInteger *) rptr->types[k]);
426
+ #endif
427
+
428
+ if (rptr->types != NULL)
429
+ rm(theEnv,rptr->types,(sizeof(void *) * rptr->tcnt));
430
+ ExpressionDeinstall(theEnv,rptr->query);
431
+ ReturnPackedExpression(theEnv,rptr->query);
432
+ }
433
+ if (meth->restrictions != NULL)
434
+ rm(theEnv,meth->restrictions,
435
+ (sizeof(RESTRICTION) * meth->restrictionCount));
436
+ RestoreBusyCount(gfunc);
437
+ }
438
+
439
+ /***************************************************
440
+ NAME : DestroyMethodInfo
441
+ DESCRIPTION : Deallocates all the data associated
442
+ w/ a method but does not release
443
+ the method structure itself
444
+ INPUTS : 1) The generic function address
445
+ 2) The method address
446
+ RETURNS : Nothing useful
447
+ SIDE EFFECTS : Nodes deallocated
448
+ NOTES : None
449
+ ***************************************************/
450
+ void DestroyMethodInfo(
451
+ Environment *theEnv,
452
+ Defgeneric *gfunc,
453
+ Defmethod *meth)
454
+ {
455
+ int j;
456
+ RESTRICTION *rptr;
457
+ #if MAC_XCD
458
+ #pragma unused(gfunc)
459
+ #endif
460
+
461
+ ReturnPackedExpression(theEnv,meth->actions);
462
+
463
+ ClearUserDataList(theEnv,meth->header.usrData);
464
+ if (meth->header.ppForm != NULL)
465
+ rm(theEnv,(void *) meth->header.ppForm,(sizeof(char) * (strlen(meth->header.ppForm)+1)));
466
+ for (j = 0 ; j < meth->restrictionCount ; j++)
467
+ {
468
+ rptr = &meth->restrictions[j];
469
+
470
+ if (rptr->types != NULL)
471
+ rm(theEnv,rptr->types,(sizeof(void *) * rptr->tcnt));
472
+ ReturnPackedExpression(theEnv,rptr->query);
473
+ }
474
+
475
+ if (meth->restrictions != NULL)
476
+ rm(theEnv,meth->restrictions,
477
+ (sizeof(RESTRICTION) * meth->restrictionCount));
478
+ }
479
+
480
+ /***************************************************
481
+ NAME : MethodsExecuting
482
+ DESCRIPTION : Determines if any of the methods of
483
+ a generic function are currently
484
+ executing
485
+ INPUTS : The generic function address
486
+ RETURNS : True if any methods are executing,
487
+ false otherwise
488
+ SIDE EFFECTS : None
489
+ NOTES : None
490
+ ***************************************************/
491
+ bool MethodsExecuting(
492
+ Defgeneric *gfunc)
493
+ {
494
+ long i;
495
+
496
+ for (i = 0 ; i < gfunc->mcnt ; i++)
497
+ if (gfunc->methods[i].busy > 0)
498
+ return true;
499
+ return false;
500
+ }
501
+
502
+ #endif
503
+
504
+ #if ! OBJECT_SYSTEM
505
+
506
+ /**************************************************************
507
+ NAME : SubsumeType
508
+ DESCRIPTION : Determines if the second type subsumes
509
+ the first type
510
+ (e.g. INTEGER_TYPE is subsumed by NUMBER_TYPE_CODE)
511
+ INPUTS : Two type codes
512
+ RETURNS : True if type 2 subsumes type 1, false
513
+ otherwise
514
+ SIDE EFFECTS : None
515
+ NOTES : Used only when COOL is not present
516
+ **************************************************************/
517
+ bool SubsumeType(
518
+ long long t1,
519
+ long long t2)
520
+ {
521
+ if ((t2 == OBJECT_TYPE_CODE) || (t2 == PRIMITIVE_TYPE_CODE))
522
+ return true;
523
+ if ((t2 == NUMBER_TYPE_CODE) && ((t1 == INTEGER_TYPE) || (t1 == FLOAT_TYPE)))
524
+ return true;
525
+ if ((t2 == LEXEME_TYPE_CODE) && ((t1 == STRING_TYPE) || (t1 == SYMBOL_TYPE)))
526
+ return true;
527
+ if ((t2 == ADDRESS_TYPE_CODE) && ((t1 == EXTERNAL_ADDRESS_TYPE) ||
528
+ (t1 == FACT_ADDRESS_TYPE) || (t1 == INSTANCE_ADDRESS_TYPE)))
529
+ return true;
530
+ if ((t2 == LEXEME_TYPE_CODE) &&
531
+ ((t1 == INSTANCE_NAME_TYPE) || (t1 == INSTANCE_ADDRESS_TYPE)))
532
+ return true;
533
+ return false;
534
+ }
535
+
536
+ #endif
537
+
538
+ /*****************************************************
539
+ NAME : FindMethodByIndex
540
+ DESCRIPTION : Finds a generic function method of
541
+ specified index
542
+ INPUTS : 1) The generic function
543
+ 2) The index
544
+ RETURNS : The position of the method in the
545
+ generic function's method array,
546
+ -1 if not found
547
+ SIDE EFFECTS : None
548
+ NOTES : None
549
+ *****************************************************/
550
+ unsigned short FindMethodByIndex(
551
+ Defgeneric *gfunc,
552
+ unsigned short theIndex)
553
+ {
554
+ unsigned short i;
555
+
556
+ for (i = 0 ; i < gfunc->mcnt ; i++)
557
+ {
558
+ if (gfunc->methods[i].index == theIndex)
559
+ { return i; }
560
+ }
561
+
562
+ return METHOD_NOT_FOUND;
563
+ }
564
+
565
+ #if DEBUGGING_FUNCTIONS || PROFILING_FUNCTIONS
566
+
567
+ /******************************************************************
568
+ NAME : PrintMethod
569
+ DESCRIPTION : Lists a brief description of methods for a method
570
+ INPUTS : 1) Buffer for method info
571
+ 2) Size of buffer (not including space for '\0')
572
+ 3) The method address
573
+ RETURNS : Nothing useful
574
+ SIDE EFFECTS : None
575
+ NOTES : A terminating newline is NOT included
576
+ ******************************************************************/
577
+ void PrintMethod(
578
+ Environment *theEnv,
579
+ Defmethod *meth,
580
+ StringBuilder *theSB)
581
+ {
582
+ #if MAC_XCD
583
+ #pragma unused(theEnv)
584
+ #endif
585
+ unsigned short j,k;
586
+ RESTRICTION *rptr;
587
+ char numbuf[15];
588
+
589
+ SBReset(theSB);
590
+ if (meth->system)
591
+ SBAppend(theSB,"SYS");
592
+ gensnprintf(numbuf,sizeof(numbuf),"%-2hu ",meth->index);
593
+ SBAppend(theSB,numbuf);
594
+ for (j = 0 ; j < meth->restrictionCount ; j++)
595
+ {
596
+ rptr = &meth->restrictions[j];
597
+ if (((j + 1) == meth->restrictionCount) && (meth->maxRestrictions == RESTRICTIONS_UNBOUNDED))
598
+ {
599
+ if ((rptr->tcnt == 0) && (rptr->query == NULL))
600
+ {
601
+ SBAppend(theSB,"$?");
602
+ break;
603
+ }
604
+ SBAppend(theSB,"($? ");
605
+ }
606
+ else
607
+ SBAppend(theSB,"(");
608
+ for (k = 0 ; k < rptr->tcnt ; k++)
609
+ {
610
+ #if OBJECT_SYSTEM
611
+ SBAppend(theSB,DefclassName((Defclass *) rptr->types[k]));
612
+ #else
613
+ SBAppend(theSB,TypeName(theEnv,((CLIPSInteger *) rptr->types[k])->contents));
614
+ #endif
615
+ if ((k + 1) < rptr->tcnt)
616
+ SBAppend(theSB," ");
617
+ }
618
+ if (rptr->query != NULL)
619
+ {
620
+ if (rptr->tcnt != 0)
621
+ SBAppend(theSB," ");
622
+ SBAppend(theSB,"<qry>");
623
+ }
624
+ SBAppend(theSB,")");
625
+ if ((j + 1) != meth->restrictionCount)
626
+ SBAppend(theSB," ");
627
+ }
628
+ }
629
+
630
+ #endif /* DEBUGGING_FUNCTIONS || PROFILING_FUNCTIONS */
631
+
632
+ #if DEBUGGING_FUNCTIONS
633
+
634
+ /*************************************************************
635
+ NAME : PreviewGeneric
636
+ DESCRIPTION : Allows the user to see a printout of all the
637
+ applicable methods for a particular generic
638
+ function call
639
+ INPUTS : None
640
+ RETURNS : Nothing useful
641
+ SIDE EFFECTS : Any side-effects of evaluating the generic
642
+ function arguments
643
+ and evaluating query-functions to determine
644
+ the set of applicable methods
645
+ NOTES : H/L Syntax: (preview-generic <func> <args>)
646
+ *************************************************************/
647
+ void PreviewGeneric(
648
+ Environment *theEnv,
649
+ UDFContext *context,
650
+ UDFValue *returnValue)
651
+ {
652
+ Defgeneric *gfunc;
653
+ Defgeneric *previousGeneric;
654
+ bool oldce;
655
+ UDFValue theArg;
656
+
657
+ EvaluationData(theEnv)->EvaluationError = false;
658
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg)) return;
659
+
660
+ gfunc = LookupDefgenericByMdlOrScope(theEnv,theArg.lexemeValue->contents);
661
+ if (gfunc == NULL)
662
+ {
663
+ PrintErrorID(theEnv,"GENRCFUN",3,false);
664
+ WriteString(theEnv,STDERR,"Unable to find generic function '");
665
+ WriteString(theEnv,STDERR,theArg.lexemeValue->contents);
666
+ WriteString(theEnv,STDERR,"' in function preview-generic.\n");
667
+ return;
668
+ }
669
+ oldce = ExecutingConstruct(theEnv);
670
+ SetExecutingConstruct(theEnv,true);
671
+ previousGeneric = DefgenericData(theEnv)->CurrentGeneric;
672
+ DefgenericData(theEnv)->CurrentGeneric = gfunc;
673
+ EvaluationData(theEnv)->CurrentEvaluationDepth++;
674
+ PushProcParameters(theEnv,GetFirstArgument()->nextArg,
675
+ CountArguments(GetFirstArgument()->nextArg),
676
+ DefgenericName(gfunc),"generic function",
677
+ UnboundMethodErr);
678
+ if (EvaluationData(theEnv)->EvaluationError)
679
+ {
680
+ PopProcParameters(theEnv);
681
+ DefgenericData(theEnv)->CurrentGeneric = previousGeneric;
682
+ EvaluationData(theEnv)->CurrentEvaluationDepth--;
683
+ SetExecutingConstruct(theEnv,oldce);
684
+ return;
685
+ }
686
+ gfunc->busy++;
687
+ DisplayGenericCore(theEnv,gfunc);
688
+ gfunc->busy--;
689
+ PopProcParameters(theEnv);
690
+ DefgenericData(theEnv)->CurrentGeneric = previousGeneric;
691
+ EvaluationData(theEnv)->CurrentEvaluationDepth--;
692
+ SetExecutingConstruct(theEnv,oldce);
693
+ }
694
+
695
+ #endif /* DEBUGGING_FUNCTIONS */
696
+
697
+ /***************************************************
698
+ NAME : CheckGenericExists
699
+ DESCRIPTION : Finds the address of named
700
+ generic function and prints out
701
+ error message if not found
702
+ INPUTS : 1) Calling function
703
+ 2) Name of generic function
704
+ RETURNS : Generic function address (NULL if
705
+ not found)
706
+ SIDE EFFECTS : None
707
+ NOTES : None
708
+ ***************************************************/
709
+ Defgeneric *CheckGenericExists(
710
+ Environment *theEnv,
711
+ const char *fname,
712
+ const char *gname)
713
+ {
714
+ Defgeneric *gfunc;
715
+
716
+ gfunc = LookupDefgenericByMdlOrScope(theEnv,gname);
717
+ if (gfunc == NULL)
718
+ {
719
+ PrintErrorID(theEnv,"GENRCFUN",3,false);
720
+ WriteString(theEnv,STDERR,"Unable to find generic function '");
721
+ WriteString(theEnv,STDERR,gname);
722
+ WriteString(theEnv,STDERR,"' in function '");
723
+ WriteString(theEnv,STDERR,fname);
724
+ WriteString(theEnv,STDERR,"'.\n");
725
+ SetEvaluationError(theEnv,true);
726
+ }
727
+ return(gfunc);
728
+ }
729
+
730
+ /***************************************************
731
+ NAME : CheckMethodExists
732
+ DESCRIPTION : Finds the array index of the
733
+ specified method and prints out
734
+ error message if not found
735
+ INPUTS : 1) Calling function
736
+ 2) Generic function address
737
+ 3) Index of method
738
+ RETURNS : Method array index (METHOD_NOT_FOUND if not found)
739
+ SIDE EFFECTS : None
740
+ NOTES : None
741
+ ***************************************************/
742
+ unsigned short CheckMethodExists(
743
+ Environment *theEnv,
744
+ const char *fname,
745
+ Defgeneric *gfunc,
746
+ unsigned short mi)
747
+ {
748
+ unsigned short fi;
749
+
750
+ fi = FindMethodByIndex(gfunc,mi);
751
+ if (fi == METHOD_NOT_FOUND)
752
+ {
753
+ PrintErrorID(theEnv,"GENRCFUN",2,false);
754
+ WriteString(theEnv,STDERR,"Unable to find method '");
755
+ WriteString(theEnv,STDERR,DefgenericName(gfunc));
756
+ WriteString(theEnv,STDERR,"' #");
757
+ PrintUnsignedInteger(theEnv,STDERR,mi);
758
+ WriteString(theEnv,STDERR," in function '");
759
+ WriteString(theEnv,STDERR,fname);
760
+ WriteString(theEnv,STDERR,"'.\n");
761
+ SetEvaluationError(theEnv,true);
762
+ }
763
+ return fi;
764
+ }
765
+
766
+ #if ! OBJECT_SYSTEM
767
+
768
+ /*******************************************************
769
+ NAME : TypeName
770
+ DESCRIPTION : Given an integer type code, this
771
+ function returns the string name of
772
+ the type
773
+ INPUTS : The type code
774
+ RETURNS : The name-string of the type, or
775
+ "<???UNKNOWN-TYPE???>" for unrecognized
776
+ types
777
+ SIDE EFFECTS : EvaluationError set and error message
778
+ printed for unrecognized types
779
+ NOTES : Used only when COOL is not present
780
+ *******************************************************/
781
+ const char *TypeName(
782
+ Environment *theEnv,
783
+ long long tcode)
784
+ {
785
+ switch (tcode)
786
+ {
787
+ case INTEGER_TYPE : return(INTEGER_TYPE_NAME);
788
+ case FLOAT_TYPE : return(FLOAT_TYPE_NAME);
789
+ case SYMBOL_TYPE : return(SYMBOL_TYPE_NAME);
790
+ case STRING_TYPE : return(STRING_TYPE_NAME);
791
+ case MULTIFIELD_TYPE : return(MULTIFIELD_TYPE_NAME);
792
+ case EXTERNAL_ADDRESS_TYPE : return(EXTERNAL_ADDRESS_TYPE_NAME);
793
+ case FACT_ADDRESS_TYPE : return(FACT_ADDRESS_TYPE_NAME);
794
+ case INSTANCE_ADDRESS_TYPE : return(INSTANCE_ADDRESS_TYPE_NAME);
795
+ case INSTANCE_NAME_TYPE : return(INSTANCE_NAME_TYPE_NAME);
796
+ case OBJECT_TYPE_CODE : return(OBJECT_TYPE_NAME);
797
+ case PRIMITIVE_TYPE_CODE : return(PRIMITIVE_TYPE_NAME);
798
+ case NUMBER_TYPE_CODE : return(NUMBER_TYPE_NAME);
799
+ case LEXEME_TYPE_CODE : return(LEXEME_TYPE_NAME);
800
+ case ADDRESS_TYPE_CODE : return(ADDRESS_TYPE_NAME);
801
+ case INSTANCE_TYPE_CODE : return(INSTANCE_TYPE_NAME);
802
+ default : PrintErrorID(theEnv,"INSCOM",1,false);
803
+ WriteString(theEnv,STDERR,"Undefined type in function 'type'.\n");
804
+ SetEvaluationError(theEnv,true);
805
+ return("<UNKNOWN-TYPE>");
806
+ }
807
+ }
808
+
809
+ #endif
810
+
811
+ /******************************************************
812
+ NAME : PrintGenericName
813
+ DESCRIPTION : Prints the name of a gneric function
814
+ (including the module name if the
815
+ generic is not in the current module)
816
+ INPUTS : 1) The logical name of the output
817
+ 2) The generic functions
818
+ RETURNS : Nothing useful
819
+ SIDE EFFECTS : Generic name printed
820
+ NOTES : None
821
+ ******************************************************/
822
+ void PrintGenericName(
823
+ Environment *theEnv,
824
+ const char *logName,
825
+ Defgeneric *gfunc)
826
+ {
827
+ if (gfunc->header.whichModule->theModule != GetCurrentModule(theEnv))
828
+ {
829
+ WriteString(theEnv,logName,DefgenericModule(gfunc));
830
+ WriteString(theEnv,logName,"::");
831
+ }
832
+ WriteString(theEnv,logName,gfunc->header.name->contents);
833
+ }
834
+
835
+ /* =========================================
836
+ *****************************************
837
+ INTERNALLY VISIBLE FUNCTIONS
838
+ =========================================
839
+ ***************************************** */
840
+
841
+ #if DEBUGGING_FUNCTIONS
842
+
843
+ /*********************************************************
844
+ NAME : DisplayGenericCore
845
+ DESCRIPTION : Prints out a description of a core
846
+ frame of applicable methods for
847
+ a particular call of a generic function
848
+ INPUTS : The generic function
849
+ RETURNS : Nothing useful
850
+ SIDE EFFECTS : None
851
+ NOTES : None
852
+ *********************************************************/
853
+ static void DisplayGenericCore(
854
+ Environment *theEnv,
855
+ Defgeneric *gfunc)
856
+ {
857
+ long i;
858
+ bool rtn = false;
859
+ StringBuilder *theSB;
860
+
861
+ theSB = CreateStringBuilder(theEnv,256);
862
+
863
+ for (i = 0 ; i < gfunc->mcnt ; i++)
864
+ {
865
+ gfunc->methods[i].busy++;
866
+ if (IsMethodApplicable(theEnv,&gfunc->methods[i]))
867
+ {
868
+ rtn = true;
869
+ WriteString(theEnv,STDOUT,DefgenericName(gfunc));
870
+ WriteString(theEnv,STDOUT," #");
871
+ PrintMethod(theEnv,&gfunc->methods[i],theSB);
872
+ WriteString(theEnv,STDOUT,theSB->contents);
873
+ WriteString(theEnv,STDOUT,"\n");
874
+ }
875
+ gfunc->methods[i].busy--;
876
+ }
877
+ if (rtn == false)
878
+ {
879
+ WriteString(theEnv,STDOUT,"No applicable methods for ");
880
+ WriteString(theEnv,STDOUT,DefgenericName(gfunc));
881
+ WriteString(theEnv,STDOUT,".\n");
882
+ }
883
+
884
+ SBDispose(theSB);
885
+ }
886
+
887
+ #endif
888
+
889
+ #endif
890
+