sourcepawn/jit/BaseRuntime.h
author Asher Baker <asherkin@gmail.com>
Thu Aug 09 01:54:43 2012 +0100 (2012-08-09)
changeset 3601 d3a2fb7b3a1e
parent 2545 9cb1a1fefc2c
child 3977 fca2b54741ca
permissions -rw-r--r--
Added system to block malware or illegal plugins (bug 5289, r=dvander).
dvander@2193
     1
#ifndef _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
dvander@2193
     2
#define _INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_
dvander@2193
     3
dvander@2193
     4
#include <sp_vm_api.h>
dvander@2193
     5
#include "jit_shared.h"
dvander@2193
     6
#include "sp_vm_function.h"
dvander@2193
     7
dvander@2193
     8
class BaseContext;
dvander@2226
     9
class JitFunction;
dvander@2193
    10
dvander@2193
    11
class DebugInfo : public IPluginDebugInfo
dvander@2193
    12
{
dvander@2193
    13
public:
dvander@2193
    14
	DebugInfo(sp_plugin_t *plugin);
dvander@2193
    15
public:
dvander@2193
    16
	int LookupFile(ucell_t addr, const char **filename);
dvander@2193
    17
	int LookupFunction(ucell_t addr, const char **name);
dvander@2193
    18
	int LookupLine(ucell_t addr, uint32_t *line);
dvander@2193
    19
private:
dvander@2193
    20
	sp_plugin_t *m_pPlugin;
dvander@2193
    21
};
dvander@2193
    22
dvander@2193
    23
/* Jit wants fast access to this so we expose things as public */
dvander@2193
    24
class BaseRuntime : public SourcePawn::IPluginRuntime
dvander@2193
    25
{
dvander@2193
    26
public:
dvander@2226
    27
	BaseRuntime();
dvander@2193
    28
	~BaseRuntime();
dvander@2193
    29
public:
dvander@2545
    30
	virtual int CreateBlank(uint32_t heastk);
dvander@2226
    31
	virtual int CreateFromMemory(sp_file_hdr_t *hdr, uint8_t *base);
dvander@2193
    32
	virtual bool IsDebugging();
dvander@2193
    33
	virtual IPluginDebugInfo *GetDebugInfo();
dvander@2193
    34
	virtual int FindNativeByName(const char *name, uint32_t *index);
dvander@2193
    35
	virtual int GetNativeByIndex(uint32_t index, sp_native_t **native);
dvander@2193
    36
	virtual uint32_t GetNativesNum();
dvander@2193
    37
	virtual int FindPublicByName(const char *name, uint32_t *index);
dvander@2193
    38
	virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr);
dvander@2193
    39
	virtual uint32_t GetPublicsNum();
dvander@2193
    40
	virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar);
dvander@2193
    41
	virtual int FindPubvarByName(const char *name, uint32_t *index);
dvander@2193
    42
	virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr);
dvander@2193
    43
	virtual uint32_t GetPubVarsNum();
dvander@2193
    44
	virtual IPluginFunction *GetFunctionByName(const char *public_name);
dvander@2193
    45
	virtual IPluginFunction *GetFunctionById(funcid_t func_id);
dvander@2193
    46
	virtual IPluginContext *GetDefaultContext();
dvander@2193
    47
	virtual int ApplyCompilationOptions(ICompilation *co);
dvander@2193
    48
	virtual void SetPauseState(bool paused);
dvander@2193
    49
	virtual bool IsPaused();
dvander@2193
    50
	virtual size_t GetMemUsage();
asherkin@3601
    51
	virtual unsigned char *GetCodeHash();
asherkin@3601
    52
	virtual unsigned char *GetDataHash();
dvander@2226
    53
	JitFunction *GetJittedFunction(uint32_t idx);
dvander@2226
    54
	uint32_t AddJittedFunction(JitFunction *fn);
dvander@2193
    55
public:
dvander@2193
    56
	BaseContext *GetBaseContext();
dvander@2193
    57
private:
dvander@2226
    58
	sp_plugin_t m_plugin;
dvander@2226
    59
	unsigned int m_NumFuncs;
dvander@2226
    60
	unsigned int m_MaxFuncs;
dvander@2226
    61
	JitFunction **m_FuncCache;
dvander@2193
    62
public:
dvander@2193
    63
	DebugInfo m_Debug;
dvander@2193
    64
	sp_plugin_t *m_pPlugin;
dvander@2193
    65
	BaseContext *m_pCtx;
dvander@2193
    66
	CFunction **m_PubFuncs;
dvander@2226
    67
	JitFunction **m_PubJitFuncs;
dvander@2226
    68
	ICompilation *m_pCo;
dvander@2226
    69
	unsigned int m_CompSerial;
asherkin@3601
    70
	
asherkin@3601
    71
	unsigned char m_CodeHash[16];
asherkin@3601
    72
	unsigned char m_DataHash[16];
dvander@2193
    73
};
dvander@2193
    74
dvander@2193
    75
#endif //_INCLUDE_SOURCEPAWN_JIT_RUNTIME_H_