#ifndef QCOMMON_VM_H #define QCOMMON_VM_H 1 #include "q_shared.h" /* ============================================================== VIRTUAL MACHINE ============================================================== */ typedef struct vm_s vm_t; typedef enum { VMI_NATIVE, VMI_BYTECODE, VMI_COMPILED } vmInterpret_t; typedef enum { TRAP_MEMSET = 100, TRAP_MEMCPY, TRAP_STRNCPY, TRAP_SIN, TRAP_COS, TRAP_ATAN2, TRAP_SQRT, TRAP_MATRIXMULTIPLY, TRAP_ANGLEVECTORS, TRAP_PERPENDICULARVECTOR, TRAP_FLOOR, TRAP_CEIL, TRAP_TESTPRINTINT, TRAP_TESTPRINTFLOAT } sharedTraps_t; void VM_Init( void ); vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), vmInterpret_t interpret ); // module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm" void VM_Free( vm_t *vm ); void VM_Clear(void); void VM_Forced_Unload_Start(void); void VM_Forced_Unload_Done(void); void VM_ClearCallLevel(vm_t *vm); vm_t *VM_Restart(vm_t *vm, bool unpure); intptr_t QDECL VM_Call( vm_t *vm, int callNum, ... ); void VM_Debug( int level ); void *VM_ArgPtr( intptr_t intValue ); void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue ); #define VMA(x) VM_ArgPtr(args[x]) static ID_INLINE float _vmf(intptr_t x) { floatint_t fi; fi.i = (int) x; return fi.f; } #define VMF(x) _vmf(args[x]) #endif