angelscript.h 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2018 Andreas Jonsson
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any
  6. damages arising from the use of this software.
  7. Permission is granted to anyone to use this software for any
  8. purpose, including commercial applications, and to alter it and
  9. redistribute it freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you
  11. must not claim that you wrote the original software. If you use
  12. this software in a product, an acknowledgment in the product
  13. documentation would be appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and
  15. must not be misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. The original version of this library can be located at:
  19. http://www.angelcode.com/angelscript/
  20. Andreas Jonsson
  21. [email protected]
  22. */
  23. // Modified by Lasse Oorni, Nathanial Lydick, Yao Wei Tjong and Ramil Sattarov for Urho3D
  24. //
  25. // angelscript.h
  26. //
  27. // The script engine interface
  28. //
  29. #ifndef ANGELSCRIPT_H
  30. #define ANGELSCRIPT_H
  31. // Urho3D: Define AS_MAX_PORTABILITY for Web and 64-bit ARM / MCST Elbrus 2000 platforms
  32. #if defined(__EMSCRIPTEN__) || defined(__aarch64__) || defined(__e2k__)
  33. #define AS_MAX_PORTABILITY
  34. #endif
  35. #include <stddef.h>
  36. #ifndef _MSC_VER
  37. #include <stdint.h>
  38. #endif
  39. #ifdef AS_USE_NAMESPACE
  40. #define BEGIN_AS_NAMESPACE namespace AngelScript {
  41. #define END_AS_NAMESPACE }
  42. #define AS_NAMESPACE_QUALIFIER AngelScript::
  43. #else
  44. #define BEGIN_AS_NAMESPACE
  45. #define END_AS_NAMESPACE
  46. #define AS_NAMESPACE_QUALIFIER ::
  47. #endif
  48. BEGIN_AS_NAMESPACE
  49. // AngelScript version
  50. #define ANGELSCRIPT_VERSION 23300
  51. #define ANGELSCRIPT_VERSION_STRING "2.33.0"
  52. // Data types
  53. class asIScriptEngine;
  54. class asIScriptModule;
  55. class asIScriptContext;
  56. class asIScriptGeneric;
  57. class asIScriptObject;
  58. class asITypeInfo;
  59. class asIScriptFunction;
  60. class asIBinaryStream;
  61. class asIJITCompiler;
  62. class asIThreadManager;
  63. class asILockableSharedBool;
  64. class asIStringFactory;
  65. // Enumerations and constants
  66. // Return codes
  67. enum asERetCodes
  68. {
  69. asSUCCESS = 0,
  70. asERROR = -1,
  71. asCONTEXT_ACTIVE = -2,
  72. asCONTEXT_NOT_FINISHED = -3,
  73. asCONTEXT_NOT_PREPARED = -4,
  74. asINVALID_ARG = -5,
  75. asNO_FUNCTION = -6,
  76. asNOT_SUPPORTED = -7,
  77. asINVALID_NAME = -8,
  78. asNAME_TAKEN = -9,
  79. asINVALID_DECLARATION = -10,
  80. asINVALID_OBJECT = -11,
  81. asINVALID_TYPE = -12,
  82. asALREADY_REGISTERED = -13,
  83. asMULTIPLE_FUNCTIONS = -14,
  84. asNO_MODULE = -15,
  85. asNO_GLOBAL_VAR = -16,
  86. asINVALID_CONFIGURATION = -17,
  87. asINVALID_INTERFACE = -18,
  88. asCANT_BIND_ALL_FUNCTIONS = -19,
  89. asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20,
  90. asWRONG_CONFIG_GROUP = -21,
  91. asCONFIG_GROUP_IS_IN_USE = -22,
  92. asILLEGAL_BEHAVIOUR_FOR_TYPE = -23,
  93. asWRONG_CALLING_CONV = -24,
  94. asBUILD_IN_PROGRESS = -25,
  95. asINIT_GLOBAL_VARS_FAILED = -26,
  96. asOUT_OF_MEMORY = -27,
  97. asMODULE_IS_IN_USE = -28
  98. };
  99. // Engine properties
  100. enum asEEngineProp
  101. {
  102. asEP_ALLOW_UNSAFE_REFERENCES = 1,
  103. asEP_OPTIMIZE_BYTECODE = 2,
  104. asEP_COPY_SCRIPT_SECTIONS = 3,
  105. asEP_MAX_STACK_SIZE = 4,
  106. asEP_USE_CHARACTER_LITERALS = 5,
  107. asEP_ALLOW_MULTILINE_STRINGS = 6,
  108. asEP_ALLOW_IMPLICIT_HANDLE_TYPES = 7,
  109. asEP_BUILD_WITHOUT_LINE_CUES = 8,
  110. asEP_INIT_GLOBAL_VARS_AFTER_BUILD = 9,
  111. asEP_REQUIRE_ENUM_SCOPE = 10,
  112. asEP_SCRIPT_SCANNER = 11,
  113. asEP_INCLUDE_JIT_INSTRUCTIONS = 12,
  114. asEP_STRING_ENCODING = 13,
  115. asEP_PROPERTY_ACCESSOR_MODE = 14,
  116. asEP_EXPAND_DEF_ARRAY_TO_TMPL = 15,
  117. asEP_AUTO_GARBAGE_COLLECT = 16,
  118. asEP_DISALLOW_GLOBAL_VARS = 17,
  119. asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT = 18,
  120. asEP_COMPILER_WARNINGS = 19,
  121. asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE = 20,
  122. asEP_ALTER_SYNTAX_NAMED_ARGS = 21,
  123. asEP_DISABLE_INTEGER_DIVISION = 22,
  124. asEP_DISALLOW_EMPTY_LIST_ELEMENTS = 23,
  125. asEP_PRIVATE_PROP_AS_PROTECTED = 24,
  126. asEP_ALLOW_UNICODE_IDENTIFIERS = 25,
  127. asEP_HEREDOC_TRIM_MODE = 26,
  128. asEP_MAX_NESTED_CALLS = 27,
  129. asEP_GENERIC_CALL_MODE = 28,
  130. asEP_INIT_STACK_SIZE = 29,
  131. asEP_INIT_CALL_STACK_SIZE = 30,
  132. asEP_MAX_CALL_STACK_SIZE = 31,
  133. asEP_LAST_PROPERTY
  134. };
  135. // Calling conventions
  136. enum asECallConvTypes
  137. {
  138. asCALL_CDECL = 0,
  139. asCALL_STDCALL = 1,
  140. asCALL_THISCALL_ASGLOBAL = 2,
  141. asCALL_THISCALL = 3,
  142. asCALL_CDECL_OBJLAST = 4,
  143. asCALL_CDECL_OBJFIRST = 5,
  144. asCALL_GENERIC = 6,
  145. asCALL_THISCALL_OBJLAST = 7,
  146. asCALL_THISCALL_OBJFIRST = 8
  147. };
  148. // Object type flags
  149. enum asEObjTypeFlags
  150. {
  151. asOBJ_REF = (1<<0),
  152. asOBJ_VALUE = (1<<1),
  153. asOBJ_GC = (1<<2),
  154. asOBJ_POD = (1<<3),
  155. asOBJ_NOHANDLE = (1<<4),
  156. asOBJ_SCOPED = (1<<5),
  157. asOBJ_TEMPLATE = (1<<6),
  158. asOBJ_ASHANDLE = (1<<7),
  159. asOBJ_APP_CLASS = (1<<8),
  160. asOBJ_APP_CLASS_CONSTRUCTOR = (1<<9),
  161. asOBJ_APP_CLASS_DESTRUCTOR = (1<<10),
  162. asOBJ_APP_CLASS_ASSIGNMENT = (1<<11),
  163. asOBJ_APP_CLASS_COPY_CONSTRUCTOR = (1<<12),
  164. asOBJ_APP_CLASS_C = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR),
  165. asOBJ_APP_CLASS_CD = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR),
  166. asOBJ_APP_CLASS_CA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),
  167. asOBJ_APP_CLASS_CK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  168. asOBJ_APP_CLASS_CDA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),
  169. asOBJ_APP_CLASS_CDK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  170. asOBJ_APP_CLASS_CAK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  171. asOBJ_APP_CLASS_CDAK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_CONSTRUCTOR + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  172. asOBJ_APP_CLASS_D = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR),
  173. asOBJ_APP_CLASS_DA = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT),
  174. asOBJ_APP_CLASS_DK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  175. asOBJ_APP_CLASS_DAK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_DESTRUCTOR + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  176. asOBJ_APP_CLASS_A = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT),
  177. asOBJ_APP_CLASS_AK = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_ASSIGNMENT + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  178. asOBJ_APP_CLASS_K = (asOBJ_APP_CLASS + asOBJ_APP_CLASS_COPY_CONSTRUCTOR),
  179. asOBJ_APP_PRIMITIVE = (1<<13),
  180. asOBJ_APP_FLOAT = (1<<14),
  181. asOBJ_APP_ARRAY = (1<<15),
  182. asOBJ_APP_CLASS_ALLINTS = (1<<16),
  183. asOBJ_APP_CLASS_ALLFLOATS = (1<<17),
  184. asOBJ_NOCOUNT = (1<<18),
  185. asOBJ_APP_CLASS_ALIGN8 = (1<<19),
  186. asOBJ_IMPLICIT_HANDLE = (1<<20),
  187. asOBJ_MASK_VALID_FLAGS = 0x1FFFFF,
  188. // Internal flags
  189. asOBJ_SCRIPT_OBJECT = (1<<21),
  190. asOBJ_SHARED = (1<<22),
  191. asOBJ_NOINHERIT = (1<<23),
  192. asOBJ_FUNCDEF = (1<<24),
  193. asOBJ_LIST_PATTERN = (1<<25),
  194. asOBJ_ENUM = (1<<26),
  195. asOBJ_TEMPLATE_SUBTYPE = (1<<27),
  196. asOBJ_TYPEDEF = (1<<28),
  197. asOBJ_ABSTRACT = (1<<29),
  198. asOBJ_APP_ALIGN16 = (1<<30)
  199. };
  200. // Behaviours
  201. enum asEBehaviours
  202. {
  203. // Value object memory management
  204. asBEHAVE_CONSTRUCT,
  205. asBEHAVE_LIST_CONSTRUCT,
  206. asBEHAVE_DESTRUCT,
  207. // Reference object memory management
  208. asBEHAVE_FACTORY,
  209. asBEHAVE_LIST_FACTORY,
  210. asBEHAVE_ADDREF,
  211. asBEHAVE_RELEASE,
  212. asBEHAVE_GET_WEAKREF_FLAG,
  213. // Object operators
  214. asBEHAVE_TEMPLATE_CALLBACK,
  215. // Garbage collection behaviours
  216. asBEHAVE_FIRST_GC,
  217. asBEHAVE_GETREFCOUNT = asBEHAVE_FIRST_GC,
  218. asBEHAVE_SETGCFLAG,
  219. asBEHAVE_GETGCFLAG,
  220. asBEHAVE_ENUMREFS,
  221. asBEHAVE_RELEASEREFS,
  222. asBEHAVE_LAST_GC = asBEHAVE_RELEASEREFS,
  223. asBEHAVE_MAX
  224. };
  225. // Context states
  226. enum asEContextState
  227. {
  228. asEXECUTION_FINISHED = 0,
  229. asEXECUTION_SUSPENDED = 1,
  230. asEXECUTION_ABORTED = 2,
  231. asEXECUTION_EXCEPTION = 3,
  232. asEXECUTION_PREPARED = 4,
  233. asEXECUTION_UNINITIALIZED = 5,
  234. asEXECUTION_ACTIVE = 6,
  235. asEXECUTION_ERROR = 7
  236. };
  237. // Message types
  238. enum asEMsgType
  239. {
  240. asMSGTYPE_ERROR = 0,
  241. asMSGTYPE_WARNING = 1,
  242. asMSGTYPE_INFORMATION = 2
  243. };
  244. // Garbage collector flags
  245. enum asEGCFlags
  246. {
  247. asGC_FULL_CYCLE = 1,
  248. asGC_ONE_STEP = 2,
  249. asGC_DESTROY_GARBAGE = 4,
  250. asGC_DETECT_GARBAGE = 8
  251. };
  252. // Token classes
  253. enum asETokenClass
  254. {
  255. asTC_UNKNOWN = 0,
  256. asTC_KEYWORD = 1,
  257. asTC_VALUE = 2,
  258. asTC_IDENTIFIER = 3,
  259. asTC_COMMENT = 4,
  260. asTC_WHITESPACE = 5
  261. };
  262. // Type id flags
  263. enum asETypeIdFlags
  264. {
  265. asTYPEID_VOID = 0,
  266. asTYPEID_BOOL = 1,
  267. asTYPEID_INT8 = 2,
  268. asTYPEID_INT16 = 3,
  269. asTYPEID_INT32 = 4,
  270. asTYPEID_INT64 = 5,
  271. asTYPEID_UINT8 = 6,
  272. asTYPEID_UINT16 = 7,
  273. asTYPEID_UINT32 = 8,
  274. asTYPEID_UINT64 = 9,
  275. asTYPEID_FLOAT = 10,
  276. asTYPEID_DOUBLE = 11,
  277. asTYPEID_OBJHANDLE = 0x40000000,
  278. asTYPEID_HANDLETOCONST = 0x20000000,
  279. asTYPEID_MASK_OBJECT = 0x1C000000,
  280. asTYPEID_APPOBJECT = 0x04000000,
  281. asTYPEID_SCRIPTOBJECT = 0x08000000,
  282. asTYPEID_TEMPLATE = 0x10000000,
  283. asTYPEID_MASK_SEQNBR = 0x03FFFFFF
  284. };
  285. // Type modifiers
  286. enum asETypeModifiers
  287. {
  288. asTM_NONE = 0,
  289. asTM_INREF = 1,
  290. asTM_OUTREF = 2,
  291. asTM_INOUTREF = 3,
  292. asTM_CONST = 4
  293. };
  294. // GetModule flags
  295. enum asEGMFlags
  296. {
  297. asGM_ONLY_IF_EXISTS = 0,
  298. asGM_CREATE_IF_NOT_EXISTS = 1,
  299. asGM_ALWAYS_CREATE = 2
  300. };
  301. // Compile flags
  302. enum asECompileFlags
  303. {
  304. asCOMP_ADD_TO_MODULE = 1
  305. };
  306. // Function types
  307. enum asEFuncType
  308. {
  309. asFUNC_DUMMY =-1,
  310. asFUNC_SYSTEM = 0,
  311. asFUNC_SCRIPT = 1,
  312. asFUNC_INTERFACE = 2,
  313. asFUNC_VIRTUAL = 3,
  314. asFUNC_FUNCDEF = 4,
  315. asFUNC_IMPORTED = 5,
  316. asFUNC_DELEGATE = 6
  317. };
  318. //
  319. // asBYTE = 8 bits
  320. // asWORD = 16 bits
  321. // asDWORD = 32 bits
  322. // asQWORD = 64 bits
  323. // asPWORD = size of pointer
  324. //
  325. typedef signed char asINT8;
  326. typedef signed short asINT16;
  327. typedef unsigned char asBYTE;
  328. typedef unsigned short asWORD;
  329. typedef unsigned int asUINT;
  330. #if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__S3E__) || (defined(_MSC_VER) && defined(__clang__))
  331. // size_t is not really correct, since it only guaranteed to be large enough to hold the segment size.
  332. // For example, on 16bit systems the size_t may be 16bits only even if pointers are 32bit. But nobody
  333. // is likely to use MSVC6 to compile for 16bit systems anymore, so this should be ok.
  334. typedef size_t asPWORD;
  335. #else
  336. typedef uintptr_t asPWORD;
  337. #endif
  338. #ifdef __LP64__
  339. typedef unsigned int asDWORD;
  340. typedef unsigned long asQWORD;
  341. typedef long asINT64;
  342. #else
  343. typedef unsigned long asDWORD;
  344. #if !defined(_MSC_VER) && (defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_CC) || defined(__psp2__))
  345. typedef uint64_t asQWORD;
  346. typedef int64_t asINT64;
  347. #else
  348. typedef unsigned __int64 asQWORD;
  349. typedef __int64 asINT64;
  350. #endif
  351. #endif
  352. // Is the target a 64bit system?
  353. #if defined(__LP64__) || defined(__amd64__) || defined(__x86_64__) || defined(_M_X64)
  354. #ifndef AS_64BIT_PTR
  355. #define AS_64BIT_PTR
  356. #endif
  357. #endif
  358. typedef void (*asFUNCTION_t)();
  359. typedef void (*asGENFUNC_t)(asIScriptGeneric *);
  360. typedef void *(*asALLOCFUNC_t)(size_t);
  361. typedef void (*asFREEFUNC_t)(void *);
  362. typedef void (*asCLEANENGINEFUNC_t)(asIScriptEngine *);
  363. typedef void (*asCLEANMODULEFUNC_t)(asIScriptModule *);
  364. typedef void (*asCLEANCONTEXTFUNC_t)(asIScriptContext *);
  365. typedef void (*asCLEANFUNCTIONFUNC_t)(asIScriptFunction *);
  366. typedef void (*asCLEANTYPEINFOFUNC_t)(asITypeInfo *);
  367. typedef void (*asCLEANSCRIPTOBJECTFUNC_t)(asIScriptObject *);
  368. typedef asIScriptContext *(*asREQUESTCONTEXTFUNC_t)(asIScriptEngine *, void *);
  369. typedef void (*asRETURNCONTEXTFUNC_t)(asIScriptEngine *, asIScriptContext *, void *);
  370. typedef void (*asCIRCULARREFFUNC_t)(asITypeInfo *, const void *, void *);
  371. // Check if the compiler can use C++11 features
  372. #if !defined(_MSC_VER) || _MSC_VER >= 1700 // MSVC 2012
  373. #if !defined(__GNUC__) || defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) // gnuc 4.7 or clang
  374. #if !(defined(__GNUC__) && defined(__cplusplus) && __cplusplus < 201103L) // gnuc and clang require compiler flag -std=c++11
  375. #if !defined(__SUNPRO_CC) // Oracle Solaris Studio
  376. #define AS_CAN_USE_CPP11 1
  377. #endif
  378. #endif
  379. #endif
  380. #endif
  381. // This macro does basically the same thing as offsetof defined in stddef.h, but
  382. // GNUC should not complain about the usage as I'm not using 0 as the base pointer.
  383. #define asOFFSET(s,m) ((int)(size_t)(&reinterpret_cast<s*>(100000)->m)-100000)
  384. #define asFUNCTION(f) asFunctionPtr(f)
  385. #if (defined(_MSC_VER) && _MSC_VER <= 1200) || (defined(__BORLANDC__) && __BORLANDC__ < 0x590)
  386. // MSVC 6 has a bug that prevents it from properly compiling using the correct asFUNCTIONPR with operator >
  387. // so we need to use ordinary C style cast instead of static_cast. The drawback is that the compiler can't
  388. // check that the cast is really valid.
  389. // BCC v5.8 (C++Builder 2006) and earlier have a similar bug which forces us to fall back to a C-style cast.
  390. #define asFUNCTIONPR(f,p,r) asFunctionPtr((void (*)())((r (*)p)(f)))
  391. #else
  392. #define asFUNCTIONPR(f,p,r) asFunctionPtr(reinterpret_cast<void (*)()>(static_cast<r (*)p>(f)))
  393. #endif
  394. #ifndef AS_NO_CLASS_METHODS
  395. class asCUnknownClass;
  396. typedef void (asCUnknownClass::*asMETHOD_t)();
  397. struct asSFuncPtr
  398. {
  399. asSFuncPtr(asBYTE f = 0)
  400. {
  401. for( size_t n = 0; n < sizeof(ptr.dummy); n++ )
  402. ptr.dummy[n] = 0;
  403. flag = f;
  404. }
  405. void CopyMethodPtr(const void *mthdPtr, size_t size)
  406. {
  407. for( size_t n = 0; n < size; n++ )
  408. ptr.dummy[n] = reinterpret_cast<const char *>(mthdPtr)[n];
  409. }
  410. union
  411. {
  412. // The largest known method point is 20 bytes (MSVC 64bit),
  413. // but with 8byte alignment this becomes 24 bytes. So we need
  414. // to be able to store at least that much.
  415. char dummy[25];
  416. struct {asMETHOD_t mthd; char dummy[25-sizeof(asMETHOD_t)];} m;
  417. struct {asFUNCTION_t func; char dummy[25-sizeof(asFUNCTION_t)];} f;
  418. } ptr;
  419. asBYTE flag; // 1 = generic, 2 = global func, 3 = method
  420. };
  421. #if defined(__BORLANDC__)
  422. // A bug in BCC (QC #85374) makes it impossible to distinguish const/non-const method overloads
  423. // with static_cast<>. The workaround is to use an _implicit_cast instead.
  424. #if __BORLANDC__ < 0x590
  425. // BCC v5.8 (C++Builder 2006) and earlier have an even more annoying bug which causes
  426. // the "pretty" workaround below (with _implicit_cast<>) to fail. For these compilers
  427. // we need to use a traditional C-style cast.
  428. #define AS_METHOD_AMBIGUITY_CAST(t) (t)
  429. #else
  430. template <typename T>
  431. T _implicit_cast (T val)
  432. { return val; }
  433. #define AS_METHOD_AMBIGUITY_CAST(t) AS_NAMESPACE_QUALIFIER _implicit_cast<t >
  434. #endif
  435. #else
  436. #define AS_METHOD_AMBIGUITY_CAST(t) static_cast<t >
  437. #endif
  438. #define asMETHOD(c,m) asSMethodPtr<sizeof(void (c::*)())>::Convert((void (c::*)())(&c::m))
  439. #define asMETHODPR(c,m,p,r) asSMethodPtr<sizeof(void (c::*)())>::Convert(AS_METHOD_AMBIGUITY_CAST(r (c::*)p)(&c::m))
  440. #else // Class methods are disabled
  441. struct asSFuncPtr
  442. {
  443. asSFuncPtr(asBYTE f)
  444. {
  445. for( int n = 0; n < sizeof(ptr.dummy); n++ )
  446. ptr.dummy[n] = 0;
  447. flag = f;
  448. }
  449. union
  450. {
  451. char dummy[25]; // largest known class method pointer
  452. struct {asFUNCTION_t func; char dummy[25-sizeof(asFUNCTION_t)];} f;
  453. } ptr;
  454. asBYTE flag; // 1 = generic, 2 = global func
  455. };
  456. #endif
  457. struct asSMessageInfo
  458. {
  459. const char *section;
  460. int row;
  461. int col;
  462. asEMsgType type;
  463. const char *message;
  464. };
  465. // API functions
  466. // ANGELSCRIPT_EXPORT is defined when compiling the dll or lib
  467. // ANGELSCRIPT_DLL_LIBRARY_IMPORT is defined when dynamically linking to the
  468. // dll through the link lib automatically generated by MSVC++
  469. // ANGELSCRIPT_DLL_MANUAL_IMPORT is defined when manually loading the dll
  470. // Don't define anything when linking statically to the lib
  471. #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
  472. #if defined(ANGELSCRIPT_EXPORT)
  473. #define AS_API __declspec(dllexport)
  474. #elif defined(ANGELSCRIPT_DLL_LIBRARY_IMPORT)
  475. #define AS_API __declspec(dllimport)
  476. #else // statically linked library
  477. #define AS_API
  478. #endif
  479. #elif defined(__GNUC__)
  480. #if defined(ANGELSCRIPT_EXPORT)
  481. #define AS_API __attribute__((visibility ("default")))
  482. #else
  483. #define AS_API
  484. #endif
  485. #else
  486. #define AS_API
  487. #endif
  488. #ifndef ANGELSCRIPT_DLL_MANUAL_IMPORT
  489. extern "C"
  490. {
  491. // Engine
  492. AS_API asIScriptEngine *asCreateScriptEngine(asDWORD version = ANGELSCRIPT_VERSION);
  493. AS_API const char *asGetLibraryVersion();
  494. AS_API const char *asGetLibraryOptions();
  495. // Context
  496. AS_API asIScriptContext *asGetActiveContext();
  497. // Thread support
  498. AS_API int asPrepareMultithread(asIThreadManager *externalMgr = 0);
  499. AS_API void asUnprepareMultithread();
  500. AS_API asIThreadManager *asGetThreadManager();
  501. AS_API void asAcquireExclusiveLock();
  502. AS_API void asReleaseExclusiveLock();
  503. AS_API void asAcquireSharedLock();
  504. AS_API void asReleaseSharedLock();
  505. AS_API int asAtomicInc(int &value);
  506. AS_API int asAtomicDec(int &value);
  507. AS_API int asThreadCleanup();
  508. // Memory management
  509. AS_API int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc);
  510. AS_API int asResetGlobalMemoryFunctions();
  511. AS_API void *asAllocMem(size_t size);
  512. AS_API void asFreeMem(void *mem);
  513. // Auxiliary
  514. AS_API asILockableSharedBool *asCreateLockableSharedBool();
  515. }
  516. #endif // ANGELSCRIPT_DLL_MANUAL_IMPORT
  517. // Determine traits of a type for registration of value types
  518. // Relies on C++11 features so it can not be used with non-compliant compilers
  519. #ifdef AS_CAN_USE_CPP11
  520. END_AS_NAMESPACE
  521. #include <type_traits>
  522. BEGIN_AS_NAMESPACE
  523. template<typename T>
  524. asUINT asGetTypeTraits()
  525. {
  526. // Urho3D - Clang compiler built with old GCC's libstdc++ suffers the same pre-standard templates problem as old GCC compiler
  527. #if defined(_MSC_VER) || defined(_LIBCPP_TYPE_TRAITS) || (__GNUC__ >= 5) || (defined(__clang__) && !defined(CLANG_PRE_STANDARD))
  528. // MSVC, XCode/Clang, and gnuc 5+
  529. // C++11 compliant code
  530. bool hasConstructor = std::is_default_constructible<T>::value && !std::is_trivially_default_constructible<T>::value;
  531. bool hasDestructor = std::is_destructible<T>::value && !std::is_trivially_destructible<T>::value;
  532. bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::is_trivially_copy_assignable<T>::value;
  533. bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::is_trivially_copy_constructible<T>::value;
  534. #elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || defined(__clang__)
  535. // gnuc 4.8 is using a mix of C++11 standard and pre-standard templates
  536. bool hasConstructor = std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value;
  537. bool hasDestructor = std::is_destructible<T>::value && !std::is_trivially_destructible<T>::value;
  538. bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::has_trivial_copy_assign<T>::value;
  539. bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::has_trivial_copy_constructor<T>::value;
  540. #else
  541. // All other compilers and versions are assumed to use non C++11 compliant code until proven otherwise
  542. // Not fully C++11 compliant. The has_trivial checks were used while the standard was still
  543. // being elaborated, but were then removed in favor of the above is_trivially checks
  544. // http://stackoverflow.com/questions/12702103/writing-code-that-works-when-has-trivial-destructor-is-defined-instead-of-is
  545. // https://github.com/mozart/mozart2/issues/51
  546. bool hasConstructor = std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value;
  547. bool hasDestructor = std::is_destructible<T>::value && !std::has_trivial_destructor<T>::value;
  548. bool hasAssignmentOperator = std::is_copy_assignable<T>::value && !std::has_trivial_copy_assign<T>::value;
  549. bool hasCopyConstructor = std::is_copy_constructible<T>::value && !std::has_trivial_copy_constructor<T>::value;
  550. #endif
  551. bool isFloat = std::is_floating_point<T>::value;
  552. bool isPrimitive = std::is_integral<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value;
  553. bool isClass = std::is_class<T>::value;
  554. bool isArray = std::is_array<T>::value;
  555. if( isFloat )
  556. return asOBJ_APP_FLOAT;
  557. if( isPrimitive )
  558. return asOBJ_APP_PRIMITIVE;
  559. if( isClass )
  560. {
  561. asDWORD flags = asOBJ_APP_CLASS;
  562. if( hasConstructor )
  563. flags |= asOBJ_APP_CLASS_CONSTRUCTOR;
  564. if( hasDestructor )
  565. flags |= asOBJ_APP_CLASS_DESTRUCTOR;
  566. if( hasAssignmentOperator )
  567. flags |= asOBJ_APP_CLASS_ASSIGNMENT;
  568. if( hasCopyConstructor )
  569. flags |= asOBJ_APP_CLASS_COPY_CONSTRUCTOR;
  570. return flags;
  571. }
  572. if( isArray )
  573. return asOBJ_APP_ARRAY;
  574. // Unknown type traits
  575. return 0;
  576. }
  577. #endif // c++11
  578. // Interface declarations
  579. class asIScriptEngine
  580. {
  581. public:
  582. // Memory management
  583. virtual int AddRef() const = 0;
  584. virtual int Release() const = 0;
  585. virtual int ShutDownAndRelease() = 0;
  586. // Engine properties
  587. virtual int SetEngineProperty(asEEngineProp property, asPWORD value) = 0;
  588. virtual asPWORD GetEngineProperty(asEEngineProp property) const = 0;
  589. // Compiler messages
  590. virtual int SetMessageCallback(const asSFuncPtr &callback, void *obj, asDWORD callConv) = 0;
  591. virtual int ClearMessageCallback() = 0;
  592. virtual int WriteMessage(const char *section, int row, int col, asEMsgType type, const char *message) = 0;
  593. // JIT Compiler
  594. virtual int SetJITCompiler(asIJITCompiler *compiler) = 0;
  595. virtual asIJITCompiler *GetJITCompiler() const = 0;
  596. // Global functions
  597. virtual int RegisterGlobalFunction(const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0) = 0;
  598. virtual asUINT GetGlobalFunctionCount() const = 0;
  599. virtual asIScriptFunction *GetGlobalFunctionByIndex(asUINT index) const = 0;
  600. virtual asIScriptFunction *GetGlobalFunctionByDecl(const char *declaration) const = 0;
  601. // Global properties
  602. virtual int RegisterGlobalProperty(const char *declaration, void *pointer) = 0;
  603. virtual asUINT GetGlobalPropertyCount() const = 0;
  604. virtual int GetGlobalPropertyByIndex(asUINT index, const char **name, const char **nameSpace = 0, int *typeId = 0, bool *isConst = 0, const char **configGroup = 0, void **pointer = 0, asDWORD *accessMask = 0) const = 0;
  605. virtual int GetGlobalPropertyIndexByName(const char *name) const = 0;
  606. virtual int GetGlobalPropertyIndexByDecl(const char *decl) const = 0;
  607. // Object types
  608. virtual int RegisterObjectType(const char *obj, int byteSize, asDWORD flags) = 0;
  609. virtual int RegisterObjectProperty(const char *obj, const char *declaration, int byteOffset, int compositeOffset = 0, bool isCompositeIndirect = false) = 0;
  610. virtual int RegisterObjectMethod(const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false) = 0;
  611. virtual int RegisterObjectBehaviour(const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary = 0, int compositeOffset = 0, bool isCompositeIndirect = false) = 0;
  612. virtual int RegisterInterface(const char *name) = 0;
  613. virtual int RegisterInterfaceMethod(const char *intf, const char *declaration) = 0;
  614. virtual asUINT GetObjectTypeCount() const = 0;
  615. virtual asITypeInfo *GetObjectTypeByIndex(asUINT index) const = 0;
  616. // String factory
  617. virtual int RegisterStringFactory(const char *datatype, asIStringFactory *factory) = 0;
  618. virtual int GetStringFactoryReturnTypeId(asDWORD *flags = 0) const = 0;
  619. // Default array type
  620. virtual int RegisterDefaultArrayType(const char *type) = 0;
  621. virtual int GetDefaultArrayTypeId() const = 0;
  622. // Enums
  623. virtual int RegisterEnum(const char *type) = 0;
  624. virtual int RegisterEnumValue(const char *type, const char *name, int value) = 0;
  625. virtual asUINT GetEnumCount() const = 0;
  626. virtual asITypeInfo *GetEnumByIndex(asUINT index) const = 0;
  627. // Funcdefs
  628. virtual int RegisterFuncdef(const char *decl) = 0;
  629. virtual asUINT GetFuncdefCount() const = 0;
  630. virtual asITypeInfo *GetFuncdefByIndex(asUINT index) const = 0;
  631. // Typedefs
  632. virtual int RegisterTypedef(const char *type, const char *decl) = 0;
  633. virtual asUINT GetTypedefCount() const = 0;
  634. virtual asITypeInfo *GetTypedefByIndex(asUINT index) const = 0;
  635. // Configuration groups
  636. virtual int BeginConfigGroup(const char *groupName) = 0;
  637. virtual int EndConfigGroup() = 0;
  638. virtual int RemoveConfigGroup(const char *groupName) = 0;
  639. virtual asDWORD SetDefaultAccessMask(asDWORD defaultMask) = 0;
  640. virtual int SetDefaultNamespace(const char *nameSpace) = 0;
  641. virtual const char *GetDefaultNamespace() const = 0;
  642. // Script modules
  643. virtual asIScriptModule *GetModule(const char *module, asEGMFlags flag = asGM_ONLY_IF_EXISTS) = 0;
  644. virtual int DiscardModule(const char *module) = 0;
  645. virtual asUINT GetModuleCount() const = 0;
  646. virtual asIScriptModule *GetModuleByIndex(asUINT index) const = 0;
  647. // Script functions
  648. virtual asIScriptFunction *GetFunctionById(int funcId) const = 0;
  649. // Type identification
  650. virtual int GetTypeIdByDecl(const char *decl) const = 0;
  651. virtual const char *GetTypeDeclaration(int typeId, bool includeNamespace = false) const = 0;
  652. virtual int GetSizeOfPrimitiveType(int typeId) const = 0;
  653. virtual asITypeInfo *GetTypeInfoById(int typeId) const = 0;
  654. virtual asITypeInfo *GetTypeInfoByName(const char *name) const = 0;
  655. virtual asITypeInfo *GetTypeInfoByDecl(const char *decl) const = 0;
  656. // Script execution
  657. virtual asIScriptContext *CreateContext() = 0;
  658. virtual void *CreateScriptObject(const asITypeInfo *type) = 0;
  659. virtual void *CreateScriptObjectCopy(void *obj, const asITypeInfo *type) = 0;
  660. virtual void *CreateUninitializedScriptObject(const asITypeInfo *type) = 0;
  661. virtual asIScriptFunction *CreateDelegate(asIScriptFunction *func, void *obj) = 0;
  662. virtual int AssignScriptObject(void *dstObj, void *srcObj, const asITypeInfo *type) = 0;
  663. virtual void ReleaseScriptObject(void *obj, const asITypeInfo *type) = 0;
  664. virtual void AddRefScriptObject(void *obj, const asITypeInfo *type) = 0;
  665. virtual int RefCastObject(void *obj, asITypeInfo *fromType, asITypeInfo *toType, void **newPtr, bool useOnlyImplicitCast = false) = 0;
  666. virtual asILockableSharedBool *GetWeakRefFlagOfScriptObject(void *obj, const asITypeInfo *type) const = 0;
  667. // Context pooling
  668. virtual asIScriptContext *RequestContext() = 0;
  669. virtual void ReturnContext(asIScriptContext *ctx) = 0;
  670. virtual int SetContextCallbacks(asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param = 0) = 0;
  671. // String interpretation
  672. virtual asETokenClass ParseToken(const char *string, size_t stringLength = 0, asUINT *tokenLength = 0) const = 0;
  673. // Garbage collection
  674. virtual int GarbageCollect(asDWORD flags = asGC_FULL_CYCLE, asUINT numIterations = 1) = 0;
  675. virtual void GetGCStatistics(asUINT *currentSize, asUINT *totalDestroyed = 0, asUINT *totalDetected = 0, asUINT *newObjects = 0, asUINT *totalNewDestroyed = 0) const = 0;
  676. virtual int NotifyGarbageCollectorOfNewObject(void *obj, asITypeInfo *type) = 0;
  677. virtual int GetObjectInGC(asUINT idx, asUINT *seqNbr = 0, void **obj = 0, asITypeInfo **type = 0) = 0;
  678. virtual void GCEnumCallback(void *reference) = 0;
  679. virtual void ForwardGCEnumReferences(void *ref, asITypeInfo *type) = 0;
  680. virtual void ForwardGCReleaseReferences(void *ref, asITypeInfo *type) = 0;
  681. virtual void SetCircularRefDetectedCallback(asCIRCULARREFFUNC_t callback, void *param = 0) = 0;
  682. // User data
  683. virtual void *SetUserData(void *data, asPWORD type = 0) = 0;
  684. virtual void *GetUserData(asPWORD type = 0) const = 0;
  685. virtual void SetEngineUserDataCleanupCallback(asCLEANENGINEFUNC_t callback, asPWORD type = 0) = 0;
  686. virtual void SetModuleUserDataCleanupCallback(asCLEANMODULEFUNC_t callback, asPWORD type = 0) = 0;
  687. virtual void SetContextUserDataCleanupCallback(asCLEANCONTEXTFUNC_t callback, asPWORD type = 0) = 0;
  688. virtual void SetFunctionUserDataCleanupCallback(asCLEANFUNCTIONFUNC_t callback, asPWORD type = 0) = 0;
  689. virtual void SetTypeInfoUserDataCleanupCallback(asCLEANTYPEINFOFUNC_t callback, asPWORD type = 0) = 0;
  690. virtual void SetScriptObjectUserDataCleanupCallback(asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type = 0) = 0;
  691. // Exception handling
  692. virtual int SetTranslateAppExceptionCallback(asSFuncPtr callback, void *param, int callConv) = 0;
  693. protected:
  694. virtual ~asIScriptEngine() {}
  695. };
  696. class asIStringFactory
  697. {
  698. public:
  699. virtual const void *GetStringConstant(const char *data, asUINT length) = 0;
  700. virtual int ReleaseStringConstant(const void *str) = 0;
  701. virtual int GetRawStringData(const void *str, char *data, asUINT *length) const = 0;
  702. protected:
  703. virtual ~asIStringFactory() {}
  704. };
  705. class asIThreadManager
  706. {
  707. protected:
  708. virtual ~asIThreadManager() {}
  709. };
  710. class asIScriptModule
  711. {
  712. public:
  713. virtual asIScriptEngine *GetEngine() const = 0;
  714. virtual void SetName(const char *name) = 0;
  715. virtual const char *GetName() const = 0;
  716. virtual void Discard() = 0;
  717. // Compilation
  718. virtual int AddScriptSection(const char *name, const char *code, size_t codeLength = 0, int lineOffset = 0) = 0;
  719. virtual int Build() = 0;
  720. virtual int CompileFunction(const char *sectionName, const char *code, int lineOffset, asDWORD compileFlags, asIScriptFunction **outFunc) = 0;
  721. virtual int CompileGlobalVar(const char *sectionName, const char *code, int lineOffset) = 0;
  722. virtual asDWORD SetAccessMask(asDWORD accessMask) = 0;
  723. virtual int SetDefaultNamespace(const char *nameSpace) = 0;
  724. virtual const char *GetDefaultNamespace() const = 0;
  725. // Functions
  726. virtual asUINT GetFunctionCount() const = 0;
  727. virtual asIScriptFunction *GetFunctionByIndex(asUINT index) const = 0;
  728. virtual asIScriptFunction *GetFunctionByDecl(const char *decl) const = 0;
  729. virtual asIScriptFunction *GetFunctionByName(const char *name) const = 0;
  730. virtual int RemoveFunction(asIScriptFunction *func) = 0;
  731. // Global variables
  732. virtual int ResetGlobalVars(asIScriptContext *ctx = 0) = 0;
  733. virtual asUINT GetGlobalVarCount() const = 0;
  734. virtual int GetGlobalVarIndexByName(const char *name) const = 0;
  735. virtual int GetGlobalVarIndexByDecl(const char *decl) const = 0;
  736. virtual const char *GetGlobalVarDeclaration(asUINT index, bool includeNamespace = false) const = 0;
  737. virtual int GetGlobalVar(asUINT index, const char **name, const char **nameSpace = 0, int *typeId = 0, bool *isConst = 0) const = 0;
  738. virtual void *GetAddressOfGlobalVar(asUINT index) = 0;
  739. virtual int RemoveGlobalVar(asUINT index) = 0;
  740. // Type identification
  741. virtual asUINT GetObjectTypeCount() const = 0;
  742. virtual asITypeInfo *GetObjectTypeByIndex(asUINT index) const = 0;
  743. virtual int GetTypeIdByDecl(const char *decl) const = 0;
  744. virtual asITypeInfo *GetTypeInfoByName(const char *name) const = 0;
  745. virtual asITypeInfo *GetTypeInfoByDecl(const char *decl) const = 0;
  746. // Enums
  747. virtual asUINT GetEnumCount() const = 0;
  748. virtual asITypeInfo *GetEnumByIndex(asUINT index) const = 0;
  749. // Typedefs
  750. virtual asUINT GetTypedefCount() const = 0;
  751. virtual asITypeInfo *GetTypedefByIndex(asUINT index) const = 0;
  752. // Dynamic binding between modules
  753. virtual asUINT GetImportedFunctionCount() const = 0;
  754. virtual int GetImportedFunctionIndexByDecl(const char *decl) const = 0;
  755. virtual const char *GetImportedFunctionDeclaration(asUINT importIndex) const = 0;
  756. virtual const char *GetImportedFunctionSourceModule(asUINT importIndex) const = 0;
  757. virtual int BindImportedFunction(asUINT importIndex, asIScriptFunction *func) = 0;
  758. virtual int UnbindImportedFunction(asUINT importIndex) = 0;
  759. virtual int BindAllImportedFunctions() = 0;
  760. virtual int UnbindAllImportedFunctions() = 0;
  761. // Byte code saving and loading
  762. virtual int SaveByteCode(asIBinaryStream *out, bool stripDebugInfo = false) const = 0;
  763. virtual int LoadByteCode(asIBinaryStream *in, bool *wasDebugInfoStripped = 0) = 0;
  764. // User data
  765. virtual void *SetUserData(void *data, asPWORD type = 0) = 0;
  766. virtual void *GetUserData(asPWORD type = 0) const = 0;
  767. protected:
  768. virtual ~asIScriptModule() {}
  769. };
  770. class asIScriptContext
  771. {
  772. public:
  773. // Memory management
  774. virtual int AddRef() const = 0;
  775. virtual int Release() const = 0;
  776. // Miscellaneous
  777. virtual asIScriptEngine *GetEngine() const = 0;
  778. // Execution
  779. virtual int Prepare(asIScriptFunction *func) = 0;
  780. virtual int Unprepare() = 0;
  781. virtual int Execute() = 0;
  782. virtual int Abort() = 0;
  783. virtual int Suspend() = 0;
  784. virtual asEContextState GetState() const = 0;
  785. virtual int PushState() = 0;
  786. virtual int PopState() = 0;
  787. virtual bool IsNested(asUINT *nestCount = 0) const = 0;
  788. // Object pointer for calling class methods
  789. virtual int SetObject(void *obj) = 0;
  790. // Arguments
  791. virtual int SetArgByte(asUINT arg, asBYTE value) = 0;
  792. virtual int SetArgWord(asUINT arg, asWORD value) = 0;
  793. virtual int SetArgDWord(asUINT arg, asDWORD value) = 0;
  794. virtual int SetArgQWord(asUINT arg, asQWORD value) = 0;
  795. virtual int SetArgFloat(asUINT arg, float value) = 0;
  796. virtual int SetArgDouble(asUINT arg, double value) = 0;
  797. virtual int SetArgAddress(asUINT arg, void *addr) = 0;
  798. virtual int SetArgObject(asUINT arg, void *obj) = 0;
  799. virtual int SetArgVarType(asUINT arg, void *ptr, int typeId) = 0;
  800. virtual void *GetAddressOfArg(asUINT arg) = 0;
  801. // Return value
  802. virtual asBYTE GetReturnByte() = 0;
  803. virtual asWORD GetReturnWord() = 0;
  804. virtual asDWORD GetReturnDWord() = 0;
  805. virtual asQWORD GetReturnQWord() = 0;
  806. virtual float GetReturnFloat() = 0;
  807. virtual double GetReturnDouble() = 0;
  808. virtual void *GetReturnAddress() = 0;
  809. virtual void *GetReturnObject() = 0;
  810. virtual void *GetAddressOfReturnValue() = 0;
  811. // Exception handling
  812. virtual int SetException(const char *info, bool allowCatch = true) = 0;
  813. virtual int GetExceptionLineNumber(int *column = 0, const char **sectionName = 0) = 0;
  814. virtual asIScriptFunction *GetExceptionFunction() = 0;
  815. virtual const char * GetExceptionString() = 0;
  816. virtual bool WillExceptionBeCaught() = 0;
  817. virtual int SetExceptionCallback(asSFuncPtr callback, void *obj, int callConv) = 0;
  818. virtual void ClearExceptionCallback() = 0;
  819. // Debugging
  820. virtual int SetLineCallback(asSFuncPtr callback, void *obj, int callConv) = 0;
  821. virtual void ClearLineCallback() = 0;
  822. virtual asUINT GetCallstackSize() const = 0;
  823. virtual asIScriptFunction *GetFunction(asUINT stackLevel = 0) = 0;
  824. virtual int GetLineNumber(asUINT stackLevel = 0, int *column = 0, const char **sectionName = 0) = 0;
  825. virtual int GetVarCount(asUINT stackLevel = 0) = 0;
  826. virtual const char *GetVarName(asUINT varIndex, asUINT stackLevel = 0) = 0;
  827. virtual const char *GetVarDeclaration(asUINT varIndex, asUINT stackLevel = 0, bool includeNamespace = false) = 0;
  828. virtual int GetVarTypeId(asUINT varIndex, asUINT stackLevel = 0) = 0;
  829. virtual void *GetAddressOfVar(asUINT varIndex, asUINT stackLevel = 0) = 0;
  830. virtual bool IsVarInScope(asUINT varIndex, asUINT stackLevel = 0) = 0;
  831. virtual int GetThisTypeId(asUINT stackLevel = 0) = 0;
  832. virtual void *GetThisPointer(asUINT stackLevel = 0) = 0;
  833. virtual asIScriptFunction *GetSystemFunction() = 0;
  834. // User data
  835. virtual void *SetUserData(void *data, asPWORD type = 0) = 0;
  836. virtual void *GetUserData(asPWORD type = 0) const = 0;
  837. protected:
  838. virtual ~asIScriptContext() {}
  839. };
  840. class asIScriptGeneric
  841. {
  842. public:
  843. // Miscellaneous
  844. virtual asIScriptEngine *GetEngine() const = 0;
  845. virtual asIScriptFunction *GetFunction() const = 0;
  846. virtual void *GetAuxiliary() const = 0;
  847. // Object
  848. virtual void *GetObject() = 0;
  849. virtual int GetObjectTypeId() const = 0;
  850. // Arguments
  851. virtual int GetArgCount() const = 0;
  852. virtual int GetArgTypeId(asUINT arg, asDWORD *flags = 0) const = 0;
  853. virtual asBYTE GetArgByte(asUINT arg) = 0;
  854. virtual asWORD GetArgWord(asUINT arg) = 0;
  855. virtual asDWORD GetArgDWord(asUINT arg) = 0;
  856. virtual asQWORD GetArgQWord(asUINT arg) = 0;
  857. virtual float GetArgFloat(asUINT arg) = 0;
  858. virtual double GetArgDouble(asUINT arg) = 0;
  859. virtual void *GetArgAddress(asUINT arg) = 0;
  860. virtual void *GetArgObject(asUINT arg) = 0;
  861. virtual void *GetAddressOfArg(asUINT arg) = 0;
  862. // Return value
  863. virtual int GetReturnTypeId(asDWORD *flags = 0) const = 0;
  864. virtual int SetReturnByte(asBYTE val) = 0;
  865. virtual int SetReturnWord(asWORD val) = 0;
  866. virtual int SetReturnDWord(asDWORD val) = 0;
  867. virtual int SetReturnQWord(asQWORD val) = 0;
  868. virtual int SetReturnFloat(float val) = 0;
  869. virtual int SetReturnDouble(double val) = 0;
  870. virtual int SetReturnAddress(void *addr) = 0;
  871. virtual int SetReturnObject(void *obj) = 0;
  872. virtual void *GetAddressOfReturnLocation() = 0;
  873. protected:
  874. virtual ~asIScriptGeneric() {}
  875. };
  876. class asIScriptObject
  877. {
  878. public:
  879. // Memory management
  880. virtual int AddRef() const = 0;
  881. virtual int Release() const = 0;
  882. virtual asILockableSharedBool *GetWeakRefFlag() const = 0;
  883. // Type info
  884. virtual int GetTypeId() const = 0;
  885. virtual asITypeInfo *GetObjectType() const = 0;
  886. // Class properties
  887. virtual asUINT GetPropertyCount() const = 0;
  888. virtual int GetPropertyTypeId(asUINT prop) const = 0;
  889. virtual const char *GetPropertyName(asUINT prop) const = 0;
  890. virtual void *GetAddressOfProperty(asUINT prop) = 0;
  891. // Miscellaneous
  892. virtual asIScriptEngine *GetEngine() const = 0;
  893. virtual int CopyFrom(asIScriptObject *other) = 0;
  894. // User data
  895. virtual void *SetUserData(void *data, asPWORD type = 0) = 0;
  896. virtual void *GetUserData(asPWORD type = 0) const = 0;
  897. protected:
  898. virtual ~asIScriptObject() {}
  899. };
  900. class asITypeInfo
  901. {
  902. public:
  903. // Miscellaneous
  904. virtual asIScriptEngine *GetEngine() const = 0;
  905. virtual const char *GetConfigGroup() const = 0;
  906. virtual asDWORD GetAccessMask() const = 0;
  907. virtual asIScriptModule *GetModule() const = 0;
  908. // Memory management
  909. virtual int AddRef() const = 0;
  910. virtual int Release() const = 0;
  911. // Type info
  912. virtual const char *GetName() const = 0;
  913. virtual const char *GetNamespace() const = 0;
  914. virtual asITypeInfo *GetBaseType() const = 0;
  915. virtual bool DerivesFrom(const asITypeInfo *objType) const = 0;
  916. virtual asDWORD GetFlags() const = 0;
  917. virtual asUINT GetSize() const = 0;
  918. virtual int GetTypeId() const = 0;
  919. virtual int GetSubTypeId(asUINT subTypeIndex = 0) const = 0;
  920. virtual asITypeInfo *GetSubType(asUINT subTypeIndex = 0) const = 0;
  921. virtual asUINT GetSubTypeCount() const = 0;
  922. // Interfaces
  923. virtual asUINT GetInterfaceCount() const = 0;
  924. virtual asITypeInfo *GetInterface(asUINT index) const = 0;
  925. virtual bool Implements(const asITypeInfo *objType) const = 0;
  926. // Factories
  927. virtual asUINT GetFactoryCount() const = 0;
  928. virtual asIScriptFunction *GetFactoryByIndex(asUINT index) const = 0;
  929. virtual asIScriptFunction *GetFactoryByDecl(const char *decl) const = 0;
  930. // Methods
  931. virtual asUINT GetMethodCount() const = 0;
  932. virtual asIScriptFunction *GetMethodByIndex(asUINT index, bool getVirtual = true) const = 0;
  933. virtual asIScriptFunction *GetMethodByName(const char *name, bool getVirtual = true) const = 0;
  934. virtual asIScriptFunction *GetMethodByDecl(const char *decl, bool getVirtual = true) const = 0;
  935. // Properties
  936. virtual asUINT GetPropertyCount() const = 0;
  937. virtual int GetProperty(asUINT index, const char **name, int *typeId = 0, bool *isPrivate = 0, bool *isProtected = 0, int *offset = 0, bool *isReference = 0, asDWORD *accessMask = 0, int *compositeOffset = 0, bool *isCompositeIndirect = 0) const = 0;
  938. virtual const char *GetPropertyDeclaration(asUINT index, bool includeNamespace = false) const = 0;
  939. // Behaviours
  940. virtual asUINT GetBehaviourCount() const = 0;
  941. virtual asIScriptFunction *GetBehaviourByIndex(asUINT index, asEBehaviours *outBehaviour) const = 0;
  942. // Child types
  943. virtual asUINT GetChildFuncdefCount() const = 0;
  944. virtual asITypeInfo *GetChildFuncdef(asUINT index) const = 0;
  945. virtual asITypeInfo *GetParentType() const = 0;
  946. // Enums
  947. virtual asUINT GetEnumValueCount() const = 0;
  948. virtual const char *GetEnumValueByIndex(asUINT index, int *outValue) const = 0;
  949. // Typedef
  950. virtual int GetTypedefTypeId() const = 0;
  951. // Funcdef
  952. virtual asIScriptFunction *GetFuncdefSignature() const = 0;
  953. // User data
  954. virtual void *SetUserData(void *data, asPWORD type = 0) = 0;
  955. virtual void *GetUserData(asPWORD type = 0) const = 0;
  956. protected:
  957. virtual ~asITypeInfo() {}
  958. };
  959. class asIScriptFunction
  960. {
  961. public:
  962. virtual asIScriptEngine *GetEngine() const = 0;
  963. // Memory management
  964. virtual int AddRef() const = 0;
  965. virtual int Release() const = 0;
  966. // Miscellaneous
  967. virtual int GetId() const = 0;
  968. virtual asEFuncType GetFuncType() const = 0;
  969. virtual const char *GetModuleName() const = 0;
  970. virtual asIScriptModule *GetModule() const = 0;
  971. virtual const char *GetScriptSectionName() const = 0;
  972. virtual const char *GetConfigGroup() const = 0;
  973. virtual asDWORD GetAccessMask() const = 0;
  974. virtual void *GetAuxiliary() const = 0;
  975. // Function signature
  976. virtual asITypeInfo *GetObjectType() const = 0;
  977. virtual const char *GetObjectName() const = 0;
  978. virtual const char *GetName() const = 0;
  979. virtual const char *GetNamespace() const = 0;
  980. virtual const char *GetDeclaration(bool includeObjectName = true, bool includeNamespace = false, bool includeParamNames = false) const = 0;
  981. virtual bool IsReadOnly() const = 0;
  982. virtual bool IsPrivate() const = 0;
  983. virtual bool IsProtected() const = 0;
  984. virtual bool IsFinal() const = 0;
  985. virtual bool IsOverride() const = 0;
  986. virtual bool IsShared() const = 0;
  987. virtual bool IsExplicit() const = 0;
  988. virtual asUINT GetParamCount() const = 0;
  989. virtual int GetParam(asUINT index, int *typeId, asDWORD *flags = 0, const char **name = 0, const char **defaultArg = 0) const = 0;
  990. virtual int GetReturnTypeId(asDWORD *flags = 0) const = 0;
  991. // Type id for function pointers
  992. virtual int GetTypeId() const = 0;
  993. virtual bool IsCompatibleWithTypeId(int typeId) const = 0;
  994. // Delegates
  995. virtual void *GetDelegateObject() const = 0;
  996. virtual asITypeInfo *GetDelegateObjectType() const = 0;
  997. virtual asIScriptFunction *GetDelegateFunction() const = 0;
  998. // Debug information
  999. virtual asUINT GetVarCount() const = 0;
  1000. virtual int GetVar(asUINT index, const char **name, int *typeId = 0) const = 0;
  1001. virtual const char *GetVarDecl(asUINT index, bool includeNamespace = false) const = 0;
  1002. virtual int FindNextLineWithCode(int line) const = 0;
  1003. // For JIT compilation
  1004. virtual asDWORD *GetByteCode(asUINT *length = 0) = 0;
  1005. // User data
  1006. virtual void *SetUserData(void *userData, asPWORD type = 0) = 0;
  1007. virtual void *GetUserData(asPWORD type = 0) const = 0;
  1008. protected:
  1009. virtual ~asIScriptFunction() {};
  1010. };
  1011. class asIBinaryStream
  1012. {
  1013. public:
  1014. virtual int Read(void *ptr, asUINT size) = 0;
  1015. virtual int Write(const void *ptr, asUINT size) = 0;
  1016. public:
  1017. virtual ~asIBinaryStream() {}
  1018. };
  1019. class asILockableSharedBool
  1020. {
  1021. public:
  1022. // Memory management
  1023. virtual int AddRef() const = 0;
  1024. virtual int Release() const = 0;
  1025. // Value
  1026. virtual bool Get() const = 0;
  1027. virtual void Set(bool val) = 0;
  1028. // Thread management
  1029. virtual void Lock() const = 0;
  1030. virtual void Unlock() const = 0;
  1031. protected:
  1032. virtual ~asILockableSharedBool() {}
  1033. };
  1034. //-----------------------------------------------------------------
  1035. // Function pointers
  1036. // Template function to capture all global functions,
  1037. // except the ones using the generic calling convention
  1038. template <class T>
  1039. inline asSFuncPtr asFunctionPtr(T func)
  1040. {
  1041. // Mark this as a global function
  1042. asSFuncPtr p(2);
  1043. #ifdef AS_64BIT_PTR
  1044. // The size_t cast is to avoid a compiler warning with asFUNCTION(0)
  1045. // on 64bit, as 0 is interpreted as a 32bit int value
  1046. p.ptr.f.func = reinterpret_cast<asFUNCTION_t>(size_t(func));
  1047. #else
  1048. // MSVC6 doesn't like the size_t cast above so I
  1049. // solved this with a separate code for 32bit.
  1050. p.ptr.f.func = reinterpret_cast<asFUNCTION_t>(func);
  1051. #endif
  1052. return p;
  1053. }
  1054. // Specialization for functions using the generic calling convention
  1055. template<>
  1056. inline asSFuncPtr asFunctionPtr<asGENFUNC_t>(asGENFUNC_t func)
  1057. {
  1058. // Mark this as a generic function
  1059. asSFuncPtr p(1);
  1060. p.ptr.f.func = reinterpret_cast<asFUNCTION_t>(func);
  1061. return p;
  1062. }
  1063. #ifndef AS_NO_CLASS_METHODS
  1064. // Method pointers
  1065. // Declare a dummy class so that we can determine the size of a simple method pointer
  1066. class asCSimpleDummy {};
  1067. typedef void (asCSimpleDummy::*asSIMPLEMETHOD_t)();
  1068. const int SINGLE_PTR_SIZE = sizeof(asSIMPLEMETHOD_t);
  1069. // Define template
  1070. template <int N>
  1071. struct asSMethodPtr
  1072. {
  1073. template<class M>
  1074. static asSFuncPtr Convert(M Mthd)
  1075. {
  1076. // This version of the function should never be executed, nor compiled,
  1077. // as it would mean that the size of the method pointer cannot be determined.
  1078. int ERROR_UnsupportedMethodPtr[N-100];
  1079. asSFuncPtr p(0);
  1080. return p;
  1081. }
  1082. };
  1083. // Template specialization
  1084. template <>
  1085. struct asSMethodPtr<SINGLE_PTR_SIZE>
  1086. {
  1087. template<class M>
  1088. static asSFuncPtr Convert(M Mthd)
  1089. {
  1090. // Mark this as a class method
  1091. asSFuncPtr p(3);
  1092. p.CopyMethodPtr(&Mthd, SINGLE_PTR_SIZE);
  1093. return p;
  1094. }
  1095. };
  1096. #if defined(_MSC_VER) && !defined(__MWERKS__)
  1097. // MSVC and Intel uses different sizes for different class method pointers
  1098. template <>
  1099. struct asSMethodPtr<SINGLE_PTR_SIZE+1*sizeof(int)>
  1100. {
  1101. template <class M>
  1102. static asSFuncPtr Convert(M Mthd)
  1103. {
  1104. // Mark this as a class method
  1105. asSFuncPtr p(3);
  1106. p.CopyMethodPtr(&Mthd, SINGLE_PTR_SIZE+sizeof(int));
  1107. return p;
  1108. }
  1109. };
  1110. template <>
  1111. struct asSMethodPtr<SINGLE_PTR_SIZE+2*sizeof(int)>
  1112. {
  1113. template <class M>
  1114. static asSFuncPtr Convert(M Mthd)
  1115. {
  1116. // On 32bit platforms with is where a class with virtual inheritance falls.
  1117. // On 64bit platforms we can also fall here if 8byte data alignments is used.
  1118. // Mark this as a class method
  1119. asSFuncPtr p(3);
  1120. p.CopyMethodPtr(&Mthd, SINGLE_PTR_SIZE+2*sizeof(int));
  1121. // Microsoft has a terrible optimization on class methods with virtual inheritance.
  1122. // They are hardcoding an important offset, which is not coming in the method pointer.
  1123. #if defined(_MSC_VER) && !defined(AS_64BIT_PTR)
  1124. // Method pointers for virtual inheritance is not supported,
  1125. // as it requires the location of the vbase table, which is
  1126. // only available to the C++ compiler, but not in the method
  1127. // pointer.
  1128. // You can get around this by forward declaring the class and
  1129. // storing the sizeof its method pointer in a constant. Example:
  1130. // class ClassWithVirtualInheritance;
  1131. // const int ClassWithVirtualInheritance_workaround = sizeof(void ClassWithVirtualInheritance::*());
  1132. // This will force the compiler to use the unknown type
  1133. // for the class, which falls under the next case
  1134. // Copy the virtual table index to the 4th dword so that AngelScript
  1135. // can properly detect and deny the use of methods with virtual inheritance.
  1136. *(reinterpret_cast<asDWORD*>(&p)+3) = *(reinterpret_cast<asDWORD*>(&p)+2);
  1137. #endif
  1138. return p;
  1139. }
  1140. };
  1141. template <>
  1142. struct asSMethodPtr<SINGLE_PTR_SIZE+3*sizeof(int)>
  1143. {
  1144. template <class M>
  1145. static asSFuncPtr Convert(M Mthd)
  1146. {
  1147. // Mark this as a class method
  1148. asSFuncPtr p(3);
  1149. p.CopyMethodPtr(&Mthd, SINGLE_PTR_SIZE+3*sizeof(int));
  1150. return p;
  1151. }
  1152. };
  1153. template <>
  1154. struct asSMethodPtr<SINGLE_PTR_SIZE+4*sizeof(int)>
  1155. {
  1156. template <class M>
  1157. static asSFuncPtr Convert(M Mthd)
  1158. {
  1159. // On 64bit platforms with 8byte data alignment
  1160. // the unknown class method pointers will come here.
  1161. // Mark this as a class method
  1162. asSFuncPtr p(3);
  1163. p.CopyMethodPtr(&Mthd, SINGLE_PTR_SIZE+4*sizeof(int));
  1164. return p;
  1165. }
  1166. };
  1167. #endif
  1168. #endif // AS_NO_CLASS_METHODS
  1169. //----------------------------------------------------------------
  1170. // JIT compiler
  1171. struct asSVMRegisters
  1172. {
  1173. asDWORD *programPointer; // points to current bytecode instruction
  1174. asDWORD *stackFramePointer; // function stack frame
  1175. asDWORD *stackPointer; // top of stack (grows downward)
  1176. asQWORD valueRegister; // temp register for primitives
  1177. void *objectRegister; // temp register for objects and handles
  1178. asITypeInfo *objectType; // type of object held in object register
  1179. bool doProcessSuspend; // whether or not the JIT should break out when it encounters a suspend instruction
  1180. asIScriptContext *ctx; // the active context
  1181. };
  1182. typedef void (*asJITFunction)(asSVMRegisters *registers, asPWORD jitArg);
  1183. class asIJITCompiler
  1184. {
  1185. public:
  1186. virtual int CompileFunction(asIScriptFunction *function, asJITFunction *output) = 0;
  1187. virtual void ReleaseJITFunction(asJITFunction func) = 0;
  1188. public:
  1189. virtual ~asIJITCompiler() {}
  1190. };
  1191. // Byte code instructions
  1192. enum asEBCInstr
  1193. {
  1194. asBC_PopPtr = 0,
  1195. asBC_PshGPtr = 1,
  1196. asBC_PshC4 = 2,
  1197. asBC_PshV4 = 3,
  1198. asBC_PSF = 4,
  1199. asBC_SwapPtr = 5,
  1200. asBC_NOT = 6,
  1201. asBC_PshG4 = 7,
  1202. asBC_LdGRdR4 = 8,
  1203. asBC_CALL = 9,
  1204. asBC_RET = 10,
  1205. asBC_JMP = 11,
  1206. asBC_JZ = 12,
  1207. asBC_JNZ = 13,
  1208. asBC_JS = 14,
  1209. asBC_JNS = 15,
  1210. asBC_JP = 16,
  1211. asBC_JNP = 17,
  1212. asBC_TZ = 18,
  1213. asBC_TNZ = 19,
  1214. asBC_TS = 20,
  1215. asBC_TNS = 21,
  1216. asBC_TP = 22,
  1217. asBC_TNP = 23,
  1218. asBC_NEGi = 24,
  1219. asBC_NEGf = 25,
  1220. asBC_NEGd = 26,
  1221. asBC_INCi16 = 27,
  1222. asBC_INCi8 = 28,
  1223. asBC_DECi16 = 29,
  1224. asBC_DECi8 = 30,
  1225. asBC_INCi = 31,
  1226. asBC_DECi = 32,
  1227. asBC_INCf = 33,
  1228. asBC_DECf = 34,
  1229. asBC_INCd = 35,
  1230. asBC_DECd = 36,
  1231. asBC_IncVi = 37,
  1232. asBC_DecVi = 38,
  1233. asBC_BNOT = 39,
  1234. asBC_BAND = 40,
  1235. asBC_BOR = 41,
  1236. asBC_BXOR = 42,
  1237. asBC_BSLL = 43,
  1238. asBC_BSRL = 44,
  1239. asBC_BSRA = 45,
  1240. asBC_COPY = 46,
  1241. asBC_PshC8 = 47,
  1242. asBC_PshVPtr = 48,
  1243. asBC_RDSPtr = 49,
  1244. asBC_CMPd = 50,
  1245. asBC_CMPu = 51,
  1246. asBC_CMPf = 52,
  1247. asBC_CMPi = 53,
  1248. asBC_CMPIi = 54,
  1249. asBC_CMPIf = 55,
  1250. asBC_CMPIu = 56,
  1251. asBC_JMPP = 57,
  1252. asBC_PopRPtr = 58,
  1253. asBC_PshRPtr = 59,
  1254. asBC_STR = 60,
  1255. asBC_CALLSYS = 61,
  1256. asBC_CALLBND = 62,
  1257. asBC_SUSPEND = 63,
  1258. asBC_ALLOC = 64,
  1259. asBC_FREE = 65,
  1260. asBC_LOADOBJ = 66,
  1261. asBC_STOREOBJ = 67,
  1262. asBC_GETOBJ = 68,
  1263. asBC_REFCPY = 69,
  1264. asBC_CHKREF = 70,
  1265. asBC_GETOBJREF = 71,
  1266. asBC_GETREF = 72,
  1267. asBC_PshNull = 73,
  1268. asBC_ClrVPtr = 74,
  1269. asBC_OBJTYPE = 75,
  1270. asBC_TYPEID = 76,
  1271. asBC_SetV4 = 77,
  1272. asBC_SetV8 = 78,
  1273. asBC_ADDSi = 79,
  1274. asBC_CpyVtoV4 = 80,
  1275. asBC_CpyVtoV8 = 81,
  1276. asBC_CpyVtoR4 = 82,
  1277. asBC_CpyVtoR8 = 83,
  1278. asBC_CpyVtoG4 = 84,
  1279. asBC_CpyRtoV4 = 85,
  1280. asBC_CpyRtoV8 = 86,
  1281. asBC_CpyGtoV4 = 87,
  1282. asBC_WRTV1 = 88,
  1283. asBC_WRTV2 = 89,
  1284. asBC_WRTV4 = 90,
  1285. asBC_WRTV8 = 91,
  1286. asBC_RDR1 = 92,
  1287. asBC_RDR2 = 93,
  1288. asBC_RDR4 = 94,
  1289. asBC_RDR8 = 95,
  1290. asBC_LDG = 96,
  1291. asBC_LDV = 97,
  1292. asBC_PGA = 98,
  1293. asBC_CmpPtr = 99,
  1294. asBC_VAR = 100,
  1295. asBC_iTOf = 101,
  1296. asBC_fTOi = 102,
  1297. asBC_uTOf = 103,
  1298. asBC_fTOu = 104,
  1299. asBC_sbTOi = 105,
  1300. asBC_swTOi = 106,
  1301. asBC_ubTOi = 107,
  1302. asBC_uwTOi = 108,
  1303. asBC_dTOi = 109,
  1304. asBC_dTOu = 110,
  1305. asBC_dTOf = 111,
  1306. asBC_iTOd = 112,
  1307. asBC_uTOd = 113,
  1308. asBC_fTOd = 114,
  1309. asBC_ADDi = 115,
  1310. asBC_SUBi = 116,
  1311. asBC_MULi = 117,
  1312. asBC_DIVi = 118,
  1313. asBC_MODi = 119,
  1314. asBC_ADDf = 120,
  1315. asBC_SUBf = 121,
  1316. asBC_MULf = 122,
  1317. asBC_DIVf = 123,
  1318. asBC_MODf = 124,
  1319. asBC_ADDd = 125,
  1320. asBC_SUBd = 126,
  1321. asBC_MULd = 127,
  1322. asBC_DIVd = 128,
  1323. asBC_MODd = 129,
  1324. asBC_ADDIi = 130,
  1325. asBC_SUBIi = 131,
  1326. asBC_MULIi = 132,
  1327. asBC_ADDIf = 133,
  1328. asBC_SUBIf = 134,
  1329. asBC_MULIf = 135,
  1330. asBC_SetG4 = 136,
  1331. asBC_ChkRefS = 137,
  1332. asBC_ChkNullV = 138,
  1333. asBC_CALLINTF = 139,
  1334. asBC_iTOb = 140,
  1335. asBC_iTOw = 141,
  1336. asBC_SetV1 = 142,
  1337. asBC_SetV2 = 143,
  1338. asBC_Cast = 144,
  1339. asBC_i64TOi = 145,
  1340. asBC_uTOi64 = 146,
  1341. asBC_iTOi64 = 147,
  1342. asBC_fTOi64 = 148,
  1343. asBC_dTOi64 = 149,
  1344. asBC_fTOu64 = 150,
  1345. asBC_dTOu64 = 151,
  1346. asBC_i64TOf = 152,
  1347. asBC_u64TOf = 153,
  1348. asBC_i64TOd = 154,
  1349. asBC_u64TOd = 155,
  1350. asBC_NEGi64 = 156,
  1351. asBC_INCi64 = 157,
  1352. asBC_DECi64 = 158,
  1353. asBC_BNOT64 = 159,
  1354. asBC_ADDi64 = 160,
  1355. asBC_SUBi64 = 161,
  1356. asBC_MULi64 = 162,
  1357. asBC_DIVi64 = 163,
  1358. asBC_MODi64 = 164,
  1359. asBC_BAND64 = 165,
  1360. asBC_BOR64 = 166,
  1361. asBC_BXOR64 = 167,
  1362. asBC_BSLL64 = 168,
  1363. asBC_BSRL64 = 169,
  1364. asBC_BSRA64 = 170,
  1365. asBC_CMPi64 = 171,
  1366. asBC_CMPu64 = 172,
  1367. asBC_ChkNullS = 173,
  1368. asBC_ClrHi = 174,
  1369. asBC_JitEntry = 175,
  1370. asBC_CallPtr = 176,
  1371. asBC_FuncPtr = 177,
  1372. asBC_LoadThisR = 178,
  1373. asBC_PshV8 = 179,
  1374. asBC_DIVu = 180,
  1375. asBC_MODu = 181,
  1376. asBC_DIVu64 = 182,
  1377. asBC_MODu64 = 183,
  1378. asBC_LoadRObjR = 184,
  1379. asBC_LoadVObjR = 185,
  1380. asBC_RefCpyV = 186,
  1381. asBC_JLowZ = 187,
  1382. asBC_JLowNZ = 188,
  1383. asBC_AllocMem = 189,
  1384. asBC_SetListSize = 190,
  1385. asBC_PshListElmnt = 191,
  1386. asBC_SetListType = 192,
  1387. asBC_POWi = 193,
  1388. asBC_POWu = 194,
  1389. asBC_POWf = 195,
  1390. asBC_POWd = 196,
  1391. asBC_POWdi = 197,
  1392. asBC_POWi64 = 198,
  1393. asBC_POWu64 = 199,
  1394. asBC_Thiscall1 = 200,
  1395. asBC_MAXBYTECODE = 201,
  1396. // Temporary tokens. Can't be output to the final program
  1397. asBC_TryBlock = 250,
  1398. asBC_VarDecl = 251,
  1399. asBC_Block = 252,
  1400. asBC_ObjInfo = 253,
  1401. asBC_LINE = 254,
  1402. asBC_LABEL = 255
  1403. };
  1404. // Instruction types
  1405. enum asEBCType
  1406. {
  1407. asBCTYPE_INFO = 0,
  1408. asBCTYPE_NO_ARG = 1,
  1409. asBCTYPE_W_ARG = 2,
  1410. asBCTYPE_wW_ARG = 3,
  1411. asBCTYPE_DW_ARG = 4,
  1412. asBCTYPE_rW_DW_ARG = 5,
  1413. asBCTYPE_QW_ARG = 6,
  1414. asBCTYPE_DW_DW_ARG = 7,
  1415. asBCTYPE_wW_rW_rW_ARG = 8,
  1416. asBCTYPE_wW_QW_ARG = 9,
  1417. asBCTYPE_wW_rW_ARG = 10,
  1418. asBCTYPE_rW_ARG = 11,
  1419. asBCTYPE_wW_DW_ARG = 12,
  1420. asBCTYPE_wW_rW_DW_ARG = 13,
  1421. asBCTYPE_rW_rW_ARG = 14,
  1422. asBCTYPE_wW_W_ARG = 15,
  1423. asBCTYPE_QW_DW_ARG = 16,
  1424. asBCTYPE_rW_QW_ARG = 17,
  1425. asBCTYPE_W_DW_ARG = 18,
  1426. asBCTYPE_rW_W_DW_ARG = 19,
  1427. asBCTYPE_rW_DW_DW_ARG = 20
  1428. };
  1429. // Instruction type sizes
  1430. const int asBCTypeSize[21] =
  1431. {
  1432. 0, // asBCTYPE_INFO
  1433. 1, // asBCTYPE_NO_ARG
  1434. 1, // asBCTYPE_W_ARG
  1435. 1, // asBCTYPE_wW_ARG
  1436. 2, // asBCTYPE_DW_ARG
  1437. 2, // asBCTYPE_rW_DW_ARG
  1438. 3, // asBCTYPE_QW_ARG
  1439. 3, // asBCTYPE_DW_DW_ARG
  1440. 2, // asBCTYPE_wW_rW_rW_ARG
  1441. 3, // asBCTYPE_wW_QW_ARG
  1442. 2, // asBCTYPE_wW_rW_ARG
  1443. 1, // asBCTYPE_rW_ARG
  1444. 2, // asBCTYPE_wW_DW_ARG
  1445. 3, // asBCTYPE_wW_rW_DW_ARG
  1446. 2, // asBCTYPE_rW_rW_ARG
  1447. 2, // asBCTYPE_wW_W_ARG
  1448. 4, // asBCTYPE_QW_DW_ARG
  1449. 3, // asBCTYPE_rW_QW_ARG
  1450. 2, // asBCTYPE_W_DW_ARG
  1451. 3, // asBCTYPE_rW_W_DW_ARG
  1452. 3 // asBCTYPE_rW_DW_DW_ARG
  1453. };
  1454. // Instruction info
  1455. struct asSBCInfo
  1456. {
  1457. asEBCInstr bc;
  1458. asEBCType type;
  1459. int stackInc;
  1460. const char *name;
  1461. };
  1462. #ifndef AS_64BIT_PTR
  1463. #define asBCTYPE_PTR_ARG asBCTYPE_DW_ARG
  1464. #define asBCTYPE_PTR_DW_ARG asBCTYPE_DW_DW_ARG
  1465. #define asBCTYPE_wW_PTR_ARG asBCTYPE_wW_DW_ARG
  1466. #define asBCTYPE_rW_PTR_ARG asBCTYPE_rW_DW_ARG
  1467. #ifndef AS_PTR_SIZE
  1468. #define AS_PTR_SIZE 1
  1469. #endif
  1470. #else
  1471. #define asBCTYPE_PTR_ARG asBCTYPE_QW_ARG
  1472. #define asBCTYPE_PTR_DW_ARG asBCTYPE_QW_DW_ARG
  1473. #define asBCTYPE_wW_PTR_ARG asBCTYPE_wW_QW_ARG
  1474. #define asBCTYPE_rW_PTR_ARG asBCTYPE_rW_QW_ARG
  1475. #ifndef AS_PTR_SIZE
  1476. #define AS_PTR_SIZE 2
  1477. #endif
  1478. #endif
  1479. #define asBCINFO(b,t,s) {asBC_##b, asBCTYPE_##t, s, #b}
  1480. #define asBCINFO_DUMMY(b) {asBC_MAXBYTECODE, asBCTYPE_INFO, 0, "BC_" #b}
  1481. const asSBCInfo asBCInfo[256] =
  1482. {
  1483. asBCINFO(PopPtr, NO_ARG, -AS_PTR_SIZE),
  1484. asBCINFO(PshGPtr, PTR_ARG, AS_PTR_SIZE),
  1485. asBCINFO(PshC4, DW_ARG, 1),
  1486. asBCINFO(PshV4, rW_ARG, 1),
  1487. asBCINFO(PSF, rW_ARG, AS_PTR_SIZE),
  1488. asBCINFO(SwapPtr, NO_ARG, 0),
  1489. asBCINFO(NOT, rW_ARG, 0),
  1490. asBCINFO(PshG4, PTR_ARG, 1),
  1491. asBCINFO(LdGRdR4, wW_PTR_ARG, 0),
  1492. asBCINFO(CALL, DW_ARG, 0xFFFF),
  1493. asBCINFO(RET, W_ARG, 0xFFFF),
  1494. asBCINFO(JMP, DW_ARG, 0),
  1495. asBCINFO(JZ, DW_ARG, 0),
  1496. asBCINFO(JNZ, DW_ARG, 0),
  1497. asBCINFO(JS, DW_ARG, 0),
  1498. asBCINFO(JNS, DW_ARG, 0),
  1499. asBCINFO(JP, DW_ARG, 0),
  1500. asBCINFO(JNP, DW_ARG, 0),
  1501. asBCINFO(TZ, NO_ARG, 0),
  1502. asBCINFO(TNZ, NO_ARG, 0),
  1503. asBCINFO(TS, NO_ARG, 0),
  1504. asBCINFO(TNS, NO_ARG, 0),
  1505. asBCINFO(TP, NO_ARG, 0),
  1506. asBCINFO(TNP, NO_ARG, 0),
  1507. asBCINFO(NEGi, rW_ARG, 0),
  1508. asBCINFO(NEGf, rW_ARG, 0),
  1509. asBCINFO(NEGd, rW_ARG, 0),
  1510. asBCINFO(INCi16, NO_ARG, 0),
  1511. asBCINFO(INCi8, NO_ARG, 0),
  1512. asBCINFO(DECi16, NO_ARG, 0),
  1513. asBCINFO(DECi8, NO_ARG, 0),
  1514. asBCINFO(INCi, NO_ARG, 0),
  1515. asBCINFO(DECi, NO_ARG, 0),
  1516. asBCINFO(INCf, NO_ARG, 0),
  1517. asBCINFO(DECf, NO_ARG, 0),
  1518. asBCINFO(INCd, NO_ARG, 0),
  1519. asBCINFO(DECd, NO_ARG, 0),
  1520. asBCINFO(IncVi, rW_ARG, 0),
  1521. asBCINFO(DecVi, rW_ARG, 0),
  1522. asBCINFO(BNOT, rW_ARG, 0),
  1523. asBCINFO(BAND, wW_rW_rW_ARG, 0),
  1524. asBCINFO(BOR, wW_rW_rW_ARG, 0),
  1525. asBCINFO(BXOR, wW_rW_rW_ARG, 0),
  1526. asBCINFO(BSLL, wW_rW_rW_ARG, 0),
  1527. asBCINFO(BSRL, wW_rW_rW_ARG, 0),
  1528. asBCINFO(BSRA, wW_rW_rW_ARG, 0),
  1529. asBCINFO(COPY, W_DW_ARG, -AS_PTR_SIZE),
  1530. asBCINFO(PshC8, QW_ARG, 2),
  1531. asBCINFO(PshVPtr, rW_ARG, AS_PTR_SIZE),
  1532. asBCINFO(RDSPtr, NO_ARG, 0),
  1533. asBCINFO(CMPd, rW_rW_ARG, 0),
  1534. asBCINFO(CMPu, rW_rW_ARG, 0),
  1535. asBCINFO(CMPf, rW_rW_ARG, 0),
  1536. asBCINFO(CMPi, rW_rW_ARG, 0),
  1537. asBCINFO(CMPIi, rW_DW_ARG, 0),
  1538. asBCINFO(CMPIf, rW_DW_ARG, 0),
  1539. asBCINFO(CMPIu, rW_DW_ARG, 0),
  1540. asBCINFO(JMPP, rW_ARG, 0),
  1541. asBCINFO(PopRPtr, NO_ARG, -AS_PTR_SIZE),
  1542. asBCINFO(PshRPtr, NO_ARG, AS_PTR_SIZE),
  1543. asBCINFO(STR, W_ARG, 1+AS_PTR_SIZE),
  1544. asBCINFO(CALLSYS, DW_ARG, 0xFFFF),
  1545. asBCINFO(CALLBND, DW_ARG, 0xFFFF),
  1546. asBCINFO(SUSPEND, NO_ARG, 0),
  1547. asBCINFO(ALLOC, PTR_DW_ARG, 0xFFFF),
  1548. asBCINFO(FREE, wW_PTR_ARG, 0),
  1549. asBCINFO(LOADOBJ, rW_ARG, 0),
  1550. asBCINFO(STOREOBJ, wW_ARG, 0),
  1551. asBCINFO(GETOBJ, W_ARG, 0),
  1552. asBCINFO(REFCPY, PTR_ARG, -AS_PTR_SIZE),
  1553. asBCINFO(CHKREF, NO_ARG, 0),
  1554. asBCINFO(GETOBJREF, W_ARG, 0),
  1555. asBCINFO(GETREF, W_ARG, 0),
  1556. asBCINFO(PshNull, NO_ARG, AS_PTR_SIZE),
  1557. asBCINFO(ClrVPtr, wW_ARG, 0),
  1558. asBCINFO(OBJTYPE, PTR_ARG, AS_PTR_SIZE),
  1559. asBCINFO(TYPEID, DW_ARG, 1),
  1560. asBCINFO(SetV4, wW_DW_ARG, 0),
  1561. asBCINFO(SetV8, wW_QW_ARG, 0),
  1562. asBCINFO(ADDSi, W_DW_ARG, 0),
  1563. asBCINFO(CpyVtoV4, wW_rW_ARG, 0),
  1564. asBCINFO(CpyVtoV8, wW_rW_ARG, 0),
  1565. asBCINFO(CpyVtoR4, rW_ARG, 0),
  1566. asBCINFO(CpyVtoR8, rW_ARG, 0),
  1567. asBCINFO(CpyVtoG4, rW_PTR_ARG, 0),
  1568. asBCINFO(CpyRtoV4, wW_ARG, 0),
  1569. asBCINFO(CpyRtoV8, wW_ARG, 0),
  1570. asBCINFO(CpyGtoV4, wW_PTR_ARG, 0),
  1571. asBCINFO(WRTV1, rW_ARG, 0),
  1572. asBCINFO(WRTV2, rW_ARG, 0),
  1573. asBCINFO(WRTV4, rW_ARG, 0),
  1574. asBCINFO(WRTV8, rW_ARG, 0),
  1575. asBCINFO(RDR1, wW_ARG, 0),
  1576. asBCINFO(RDR2, wW_ARG, 0),
  1577. asBCINFO(RDR4, wW_ARG, 0),
  1578. asBCINFO(RDR8, wW_ARG, 0),
  1579. asBCINFO(LDG, PTR_ARG, 0),
  1580. asBCINFO(LDV, rW_ARG, 0),
  1581. asBCINFO(PGA, PTR_ARG, AS_PTR_SIZE),
  1582. asBCINFO(CmpPtr, rW_rW_ARG, 0),
  1583. asBCINFO(VAR, rW_ARG, AS_PTR_SIZE),
  1584. asBCINFO(iTOf, rW_ARG, 0),
  1585. asBCINFO(fTOi, rW_ARG, 0),
  1586. asBCINFO(uTOf, rW_ARG, 0),
  1587. asBCINFO(fTOu, rW_ARG, 0),
  1588. asBCINFO(sbTOi, rW_ARG, 0),
  1589. asBCINFO(swTOi, rW_ARG, 0),
  1590. asBCINFO(ubTOi, rW_ARG, 0),
  1591. asBCINFO(uwTOi, rW_ARG, 0),
  1592. asBCINFO(dTOi, wW_rW_ARG, 0),
  1593. asBCINFO(dTOu, wW_rW_ARG, 0),
  1594. asBCINFO(dTOf, wW_rW_ARG, 0),
  1595. asBCINFO(iTOd, wW_rW_ARG, 0),
  1596. asBCINFO(uTOd, wW_rW_ARG, 0),
  1597. asBCINFO(fTOd, wW_rW_ARG, 0),
  1598. asBCINFO(ADDi, wW_rW_rW_ARG, 0),
  1599. asBCINFO(SUBi, wW_rW_rW_ARG, 0),
  1600. asBCINFO(MULi, wW_rW_rW_ARG, 0),
  1601. asBCINFO(DIVi, wW_rW_rW_ARG, 0),
  1602. asBCINFO(MODi, wW_rW_rW_ARG, 0),
  1603. asBCINFO(ADDf, wW_rW_rW_ARG, 0),
  1604. asBCINFO(SUBf, wW_rW_rW_ARG, 0),
  1605. asBCINFO(MULf, wW_rW_rW_ARG, 0),
  1606. asBCINFO(DIVf, wW_rW_rW_ARG, 0),
  1607. asBCINFO(MODf, wW_rW_rW_ARG, 0),
  1608. asBCINFO(ADDd, wW_rW_rW_ARG, 0),
  1609. asBCINFO(SUBd, wW_rW_rW_ARG, 0),
  1610. asBCINFO(MULd, wW_rW_rW_ARG, 0),
  1611. asBCINFO(DIVd, wW_rW_rW_ARG, 0),
  1612. asBCINFO(MODd, wW_rW_rW_ARG, 0),
  1613. asBCINFO(ADDIi, wW_rW_DW_ARG, 0),
  1614. asBCINFO(SUBIi, wW_rW_DW_ARG, 0),
  1615. asBCINFO(MULIi, wW_rW_DW_ARG, 0),
  1616. asBCINFO(ADDIf, wW_rW_DW_ARG, 0),
  1617. asBCINFO(SUBIf, wW_rW_DW_ARG, 0),
  1618. asBCINFO(MULIf, wW_rW_DW_ARG, 0),
  1619. asBCINFO(SetG4, PTR_DW_ARG, 0),
  1620. asBCINFO(ChkRefS, NO_ARG, 0),
  1621. asBCINFO(ChkNullV, rW_ARG, 0),
  1622. asBCINFO(CALLINTF, DW_ARG, 0xFFFF),
  1623. asBCINFO(iTOb, rW_ARG, 0),
  1624. asBCINFO(iTOw, rW_ARG, 0),
  1625. asBCINFO(SetV1, wW_DW_ARG, 0),
  1626. asBCINFO(SetV2, wW_DW_ARG, 0),
  1627. asBCINFO(Cast, DW_ARG, -AS_PTR_SIZE),
  1628. asBCINFO(i64TOi, wW_rW_ARG, 0),
  1629. asBCINFO(uTOi64, wW_rW_ARG, 0),
  1630. asBCINFO(iTOi64, wW_rW_ARG, 0),
  1631. asBCINFO(fTOi64, wW_rW_ARG, 0),
  1632. asBCINFO(dTOi64, rW_ARG, 0),
  1633. asBCINFO(fTOu64, wW_rW_ARG, 0),
  1634. asBCINFO(dTOu64, rW_ARG, 0),
  1635. asBCINFO(i64TOf, wW_rW_ARG, 0),
  1636. asBCINFO(u64TOf, wW_rW_ARG, 0),
  1637. asBCINFO(i64TOd, rW_ARG, 0),
  1638. asBCINFO(u64TOd, rW_ARG, 0),
  1639. asBCINFO(NEGi64, rW_ARG, 0),
  1640. asBCINFO(INCi64, NO_ARG, 0),
  1641. asBCINFO(DECi64, NO_ARG, 0),
  1642. asBCINFO(BNOT64, rW_ARG, 0),
  1643. asBCINFO(ADDi64, wW_rW_rW_ARG, 0),
  1644. asBCINFO(SUBi64, wW_rW_rW_ARG, 0),
  1645. asBCINFO(MULi64, wW_rW_rW_ARG, 0),
  1646. asBCINFO(DIVi64, wW_rW_rW_ARG, 0),
  1647. asBCINFO(MODi64, wW_rW_rW_ARG, 0),
  1648. asBCINFO(BAND64, wW_rW_rW_ARG, 0),
  1649. asBCINFO(BOR64, wW_rW_rW_ARG, 0),
  1650. asBCINFO(BXOR64, wW_rW_rW_ARG, 0),
  1651. asBCINFO(BSLL64, wW_rW_rW_ARG, 0),
  1652. asBCINFO(BSRL64, wW_rW_rW_ARG, 0),
  1653. asBCINFO(BSRA64, wW_rW_rW_ARG, 0),
  1654. asBCINFO(CMPi64, rW_rW_ARG, 0),
  1655. asBCINFO(CMPu64, rW_rW_ARG, 0),
  1656. asBCINFO(ChkNullS, W_ARG, 0),
  1657. asBCINFO(ClrHi, NO_ARG, 0),
  1658. asBCINFO(JitEntry, PTR_ARG, 0),
  1659. asBCINFO(CallPtr, rW_ARG, 0xFFFF),
  1660. asBCINFO(FuncPtr, PTR_ARG, AS_PTR_SIZE),
  1661. asBCINFO(LoadThisR, W_DW_ARG, 0),
  1662. asBCINFO(PshV8, rW_ARG, 2),
  1663. asBCINFO(DIVu, wW_rW_rW_ARG, 0),
  1664. asBCINFO(MODu, wW_rW_rW_ARG, 0),
  1665. asBCINFO(DIVu64, wW_rW_rW_ARG, 0),
  1666. asBCINFO(MODu64, wW_rW_rW_ARG, 0),
  1667. asBCINFO(LoadRObjR, rW_W_DW_ARG, 0),
  1668. asBCINFO(LoadVObjR, rW_W_DW_ARG, 0),
  1669. asBCINFO(RefCpyV, wW_PTR_ARG, 0),
  1670. asBCINFO(JLowZ, DW_ARG, 0),
  1671. asBCINFO(JLowNZ, DW_ARG, 0),
  1672. asBCINFO(AllocMem, wW_DW_ARG, 0),
  1673. asBCINFO(SetListSize, rW_DW_DW_ARG, 0),
  1674. asBCINFO(PshListElmnt, rW_DW_ARG, AS_PTR_SIZE),
  1675. asBCINFO(SetListType, rW_DW_DW_ARG, 0),
  1676. asBCINFO(POWi, wW_rW_rW_ARG, 0),
  1677. asBCINFO(POWu, wW_rW_rW_ARG, 0),
  1678. asBCINFO(POWf, wW_rW_rW_ARG, 0),
  1679. asBCINFO(POWd, wW_rW_rW_ARG, 0),
  1680. asBCINFO(POWdi, wW_rW_rW_ARG, 0),
  1681. asBCINFO(POWi64, wW_rW_rW_ARG, 0),
  1682. asBCINFO(POWu64, wW_rW_rW_ARG, 0),
  1683. asBCINFO(Thiscall1, DW_ARG, -AS_PTR_SIZE-1),
  1684. asBCINFO_DUMMY(201),
  1685. asBCINFO_DUMMY(202),
  1686. asBCINFO_DUMMY(203),
  1687. asBCINFO_DUMMY(204),
  1688. asBCINFO_DUMMY(205),
  1689. asBCINFO_DUMMY(206),
  1690. asBCINFO_DUMMY(207),
  1691. asBCINFO_DUMMY(208),
  1692. asBCINFO_DUMMY(209),
  1693. asBCINFO_DUMMY(210),
  1694. asBCINFO_DUMMY(211),
  1695. asBCINFO_DUMMY(212),
  1696. asBCINFO_DUMMY(213),
  1697. asBCINFO_DUMMY(214),
  1698. asBCINFO_DUMMY(215),
  1699. asBCINFO_DUMMY(216),
  1700. asBCINFO_DUMMY(217),
  1701. asBCINFO_DUMMY(218),
  1702. asBCINFO_DUMMY(219),
  1703. asBCINFO_DUMMY(220),
  1704. asBCINFO_DUMMY(221),
  1705. asBCINFO_DUMMY(222),
  1706. asBCINFO_DUMMY(223),
  1707. asBCINFO_DUMMY(224),
  1708. asBCINFO_DUMMY(225),
  1709. asBCINFO_DUMMY(226),
  1710. asBCINFO_DUMMY(227),
  1711. asBCINFO_DUMMY(228),
  1712. asBCINFO_DUMMY(229),
  1713. asBCINFO_DUMMY(230),
  1714. asBCINFO_DUMMY(231),
  1715. asBCINFO_DUMMY(232),
  1716. asBCINFO_DUMMY(233),
  1717. asBCINFO_DUMMY(234),
  1718. asBCINFO_DUMMY(235),
  1719. asBCINFO_DUMMY(236),
  1720. asBCINFO_DUMMY(237),
  1721. asBCINFO_DUMMY(238),
  1722. asBCINFO_DUMMY(239),
  1723. asBCINFO_DUMMY(240),
  1724. asBCINFO_DUMMY(241),
  1725. asBCINFO_DUMMY(242),
  1726. asBCINFO_DUMMY(243),
  1727. asBCINFO_DUMMY(244),
  1728. asBCINFO_DUMMY(245),
  1729. asBCINFO_DUMMY(246),
  1730. asBCINFO_DUMMY(247),
  1731. asBCINFO_DUMMY(248),
  1732. asBCINFO_DUMMY(249),
  1733. asBCINFO(TryBlock, DW_ARG, 0),
  1734. asBCINFO(VarDecl, W_ARG, 0),
  1735. asBCINFO(Block, INFO, 0),
  1736. asBCINFO(ObjInfo, rW_DW_ARG, 0),
  1737. asBCINFO(LINE, INFO, 0),
  1738. asBCINFO(LABEL, INFO, 0)
  1739. };
  1740. // Macros to access bytecode instruction arguments
  1741. #define asBC_DWORDARG(x) (*(((asDWORD*)x)+1))
  1742. #define asBC_INTARG(x) (*(int*)(((asDWORD*)x)+1))
  1743. #define asBC_QWORDARG(x) (*(asQWORD*)(((asDWORD*)x)+1))
  1744. #define asBC_FLOATARG(x) (*(float*)(((asDWORD*)x)+1))
  1745. #define asBC_PTRARG(x) (*(asPWORD*)(((asDWORD*)x)+1))
  1746. #define asBC_WORDARG0(x) (*(((asWORD*)x)+1))
  1747. #define asBC_WORDARG1(x) (*(((asWORD*)x)+2))
  1748. #define asBC_SWORDARG0(x) (*(((short*)x)+1))
  1749. #define asBC_SWORDARG1(x) (*(((short*)x)+2))
  1750. #define asBC_SWORDARG2(x) (*(((short*)x)+3))
  1751. // Urho3D: Include the wrapper macros file but only after they have been defined above
  1752. // This causes a large number of warnings, which could possibly be prevented with further
  1753. // changes to the library or the Urho Angelscript code
  1754. // Only include this file if we are NOT building the angelscript library itself,
  1755. // as Angelscript already provides generic wrappers for their classes
  1756. // (AS_IS_BUILDING is defined in the CMakeLists.txt file for the AngelScript (sub)library)
  1757. #ifndef AS_IS_BUILDING
  1758. #include "wrapmacros.h"
  1759. #endif
  1760. END_AS_NAMESPACE
  1761. #endif