3 * ================================================================
4 * SourcePawn (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ================================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #ifndef _INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
16 #define _INCLUDE_SOURCEPAWN_JIT_HELPERS_H_
18 #include <sp_vm_types.h>
19 #include <sp_vm_api.h>
21 #if defined HAVE_STDINT_H && !defined WIN32
23 typedef int8_t jit_int8_t;
24 typedef uint8_t jit_uint8_t;
25 typedef int32_t jit_int32_t;
26 typedef uint32_t jit_uint32_t;
27 typedef int64_t jit_int64_t;
28 typedef uint64_t jit_uint64_t;
30 typedef __int8 jit_int8_t;
31 typedef unsigned __int8 jit_uint8_t;
32 typedef __int32 jit_int32_t;
33 typedef unsigned __int32 jit_uint32_t;
34 typedef __int64 jit_int64_t;
35 typedef unsigned __int64 jit_uint64_t;
38 typedef char * jitcode_t;
39 typedef unsigned int jitoffs_t;
40 typedef signed int jitrel_t;
45 inline cell_t read_cell()
47 cell_t val = *(inptr);
51 inline cell_t *read_cellptr()
53 cell_t *val = *(cell_t **)(inptr);
57 inline void write_ubyte(jit_uint8_t c)
65 inline void write_ushort(unsigned short c)
69 *(unsigned short *)outptr = c;
71 outptr += sizeof(unsigned short);
73 inline void write_byte(jit_int8_t c)
81 inline void write_int32(jit_int32_t c)
85 *(jit_int32_t *)outptr = c;
87 outptr += sizeof(jit_int32_t);
89 inline void write_uint32(jit_uint32_t c)
93 *(jit_uint32_t *)outptr = c;
95 outptr += sizeof(jit_uint32_t);
97 inline jitoffs_t get_outputpos()
99 return (outptr - outbase);
101 inline void set_outputpos(jitoffs_t offs)
103 outptr = outbase + offs;
105 inline jitoffs_t get_inputpos()
107 return (jitoffs_t)((char *)inptr - (char *)inbase);
110 cell_t *inptr; /* input pointer */
111 cell_t *inbase; /* input base */
112 jitcode_t outbase; /* output pointer */
113 jitcode_t outptr; /* output base */
114 SourcePawn::ICompilation *data; /* compiler live info */
117 #endif //_INCLUDE_SOURCEPAWN_JIT_HELPERS_H_