2 * ================================================================
3 * SourcePawn (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ================================================================
6 * This file is not open source and may not be copied without explicit
7 * written permission of AlliedModders LLC. This file may not be redistributed
8 * in whole or significant part.
9 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
14 #ifndef _INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
15 #define _INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
17 #include <sp_vm_types.h>
18 #include <sp_vm_api.h>
20 #if defined HAVE_STDINT_H && !defined WIN32
22 typedef int8_t jit_int8_t;
23 typedef uint8_t jit_uint8_t;
24 typedef int32_t jit_int32_t;
25 typedef uint32_t jit_uint32_t;
26 typedef int64_t jit_int64_t;
27 typedef uint64_t jit_uint64_t;
29 typedef __int8 jit_int8_t;
30 typedef unsigned __int8 jit_uint8_t;
31 typedef __int32 jit_int32_t;
32 typedef unsigned __int32 jit_uint32_t;
33 typedef __int64 jit_int64_t;
34 typedef unsigned __int64 jit_uint64_t;
37 typedef char * jitcode_t;
38 typedef unsigned int jitoffs_t;
39 typedef signed int jitrel_t;
44 inline cell_t read_cell()
46 cell_t val = *(inptr);
50 inline cell_t *read_cellptr()
52 cell_t *val = *(cell_t **)(inptr);
56 inline void write_ubyte(jit_uint8_t c)
64 inline void write_byte(jit_int8_t c)
72 inline void write_int32(jit_int32_t c)
76 *(jit_int32_t *)outptr = c;
78 outptr += sizeof(jit_int32_t);
80 inline void write_uint32(jit_uint32_t c)
84 *(jit_uint32_t *)outptr = c;
86 outptr += sizeof(jit_uint32_t);
88 inline jitoffs_t get_outputpos()
90 return (outptr - outbase);
92 inline void set_outputpos(jitoffs_t offs)
94 outptr = outbase + offs;
96 inline jitoffs_t get_inputpos()
98 return (jitoffs_t)((char *)inptr - (char *)inbase);
101 cell_t *inptr; /* input pointer */
102 cell_t *inbase; /* input base */
103 jitcode_t outbase; /* output pointer */
104 jitcode_t outptr; /* output base */
105 SourcePawn::ICompilation *data; /* compiler live info */
108 #endif //_INCLUDE_SOURCEPAWN_JIT_HELPERS_H_