sourcepawn/jit/jit_shared.h
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 4116 3e58428d988f
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 // vim: set ts=4 sw=4 tw=99 noet: 
     2 #ifndef _INCLUDE_SOURCEPAWN_JIT_SHARED_H_
     3 #define _INCLUDE_SOURCEPAWN_JIT_SHARED_H_
     4 
     5 #include <sp_vm_api.h>
     6 
     7 using namespace SourcePawn;
     8 
     9 #define SP_MAX_RETURN_STACK		1024
    10 
    11 /**
    12  * @brief Information about the plugin's debug tables.  These are all present if one is present.
    13  */
    14 typedef struct sp_plugin_debug_s
    15 {
    16 	const char *stringbase;		/**< base of string table */
    17 	uint32_t	files_num;		/**< number of files */
    18 	sp_fdbg_file_t *files;		/**< files table */
    19 	uint32_t	lines_num;		/**< number of lines */
    20 	sp_fdbg_line_t *lines;		/**< lines table */
    21 	uint32_t	syms_num;		/**< number of symbols */
    22 	sp_fdbg_symbol_t *symbols;	/**< symbol table */
    23 	bool unpacked;				/**< Whether debug structures are unpacked */
    24 } sp_plugin_debug_t;
    25 
    26 class BaseContext;
    27 
    28 /**
    29  * Breaks into a debugger
    30  * Params:
    31  *  [0] - plugin context
    32  *  [1] - frm
    33  *  [2] - cip
    34  */
    35 typedef int (*SPVM_DEBUGBREAK)(BaseContext *, uint32_t, uint32_t);
    36 
    37 /**
    38  * @brief The rebased memory format of a plugin.  This differs from the on-disk structure 
    39  * to ensure that the format is properly read.
    40  */
    41 namespace SourcePawn
    42 {
    43 	typedef struct sp_plugin_s
    44 	{
    45 		uint8_t		*base;			/**< Base of memory for this plugin. */
    46 		uint8_t		*pcode;			/**< P-Code of plugin */
    47 		uint32_t	pcode_size;		/**< Size of p-code */
    48 		uint8_t		*data;			/**< Data/memory layout */
    49 		uint32_t	data_size;		/**< Size of data */
    50 		uint32_t	mem_size;		/**< Required memory space */
    51 		uint16_t	flags;			/**< Code flags */
    52 		sp_plugin_debug_t   debug;	/**< Debug info table */
    53 		size_t		base_size;		/**< Size of the entire plugin base */
    54 		uint8_t		*memory;		/**< Data chunk */
    55 		const char *stringbase;		/**< base of string table */
    56 		sp_public_t	*publics;		/**< Public functions table */
    57 		uint32_t	num_publics;	/**< Number of publics. */
    58 		sp_pubvar_t	*pubvars;		/**< Public variables table */
    59 		uint32_t	num_pubvars;	/**< Number of public variables */
    60 		sp_native_t	*natives;		/**< Natives table */
    61 		uint32_t	num_natives;	/**< Number of natives */
    62 		IProfiler *profiler;		/**< Pointer to IProfiler */
    63 		uint32_t	prof_flags;		/**< Profiling flags */
    64 		uint32_t	run_flags;		/**< Runtime flags */
    65 		uint32_t	pcode_version;	/**< P-Code version number */
    66 		char		*name;			/**< Plugin/script name */
    67 	} sp_plugin_t;
    68 }
    69 
    70 struct tracker_t;
    71 class BaseContext;
    72 
    73 typedef struct sp_context_s
    74 {
    75 	cell_t			hp;				/**< Heap pointer */
    76 	cell_t			sp;				/**< Stack pointer */
    77 	cell_t			frm;			/**< Frame pointer */
    78 	cell_t			rval;			/**< Return value from InvokeFunction() */
    79 	int32_t			cip;			/**< Code pointer last error occurred in */
    80 	int32_t			err;			/**< Error last set by interpreter */
    81 	int32_t			n_err;			/**< Error code set by a native */
    82 	uint32_t		n_idx;			/**< Current native index being executed */
    83 	tracker_t 		*tracker;
    84 	sp_plugin_t 	*plugin;
    85 	BaseContext		*basecx;
    86 	void *			vm[8];			/**< VM-specific pointers */
    87 	cell_t			rp;				/**< Return stack pointer */
    88 	cell_t			rstk_cips[SP_MAX_RETURN_STACK];
    89 } sp_context_t;
    90 
    91 //#define SPFLAG_PLUGIN_DEBUG			(1<<0)
    92 #define SPFLAG_PLUGIN_PAUSED		(1<<1)
    93 
    94 #define INVALID_CIP			0xFFFFFFFF
    95 
    96 #endif //_INCLUDE_SOURCEPAWN_JIT_SHARED_H_