angelscript.h 64 KB

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