Refactor the JIT to use a newer, simpler macro assembler. (
bug 5827, r=ann)
3 * =============================================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEPAWN_BASECONTEXT_H_
33 #define _INCLUDE_SOURCEPAWN_BASECONTEXT_H_
35 #include "sp_vm_api.h"
36 #include "sp_vm_function.h"
37 #include "BaseRuntime.h"
38 #include "jit_shared.h"
41 * :TODO: Make functions allocate as a lump instead of individual allocations!
44 class BaseContext : public IPluginContext
47 BaseContext(BaseRuntime *pRuntime);
49 public: //IPluginContext
50 IVirtualMachine *GetVirtualMachine();
51 sp_context_t *GetContext();
52 sp_context_t *GetCtx();
54 int SetDebugBreak(void *newpfn, void *oldpfn);
55 IPluginDebugInfo *GetDebugInfo();
56 int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr);
57 int HeapPop(cell_t local_addr);
58 int HeapRelease(cell_t local_addr);
59 int FindNativeByName(const char *name, uint32_t *index);
60 int GetNativeByIndex(uint32_t index, sp_native_t **native);
61 uint32_t GetNativesNum();
62 int FindPublicByName(const char *name, uint32_t *index);
63 int GetPublicByIndex(uint32_t index, sp_public_t **publicptr);
64 uint32_t GetPublicsNum();
65 int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar);
66 int FindPubvarByName(const char *name, uint32_t *index);
67 int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr);
68 uint32_t GetPubVarsNum();
69 int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr);
70 int LocalToString(cell_t local_addr, char **addr);
71 int StringToLocal(cell_t local_addr, size_t chars, const char *source);
72 int StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes);
73 int PushCell(cell_t value);
74 int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells);
75 int PushString(cell_t *local_addr, char **phys_addr, const char *string);
76 int PushCellsFromArray(cell_t array[], unsigned int numcells);
77 int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite);
78 int BindNative(const sp_nativeinfo_t *native);
79 int BindNativeToAny(SPVM_NATIVE_FUNC native);
80 int Execute(uint32_t code_addr, cell_t *result);
81 cell_t ThrowNativeErrorEx(int error, const char *msg, ...);
82 cell_t ThrowNativeError(const char *msg, ...);
83 IPluginFunction *GetFunctionByName(const char *public_name);
84 IPluginFunction *GetFunctionById(funcid_t func_id);
85 SourceMod::IdentityToken_t *GetIdentity();
86 cell_t *GetNullRef(SP_NULL_TYPE type);
87 int LocalToStringNULL(cell_t local_addr, char **addr);
88 int BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC native);
89 int Execute2(IPluginFunction *function, const cell_t *params, unsigned int num_params, cell_t *result);
90 IPluginRuntime *GetRuntime();
91 int GetLastNativeError();
92 cell_t *GetLocalParams();
93 void SetKey(int k, void *value);
94 bool GetKey(int k, void **value);
96 void ClearLastNativeError();
100 void SetErrorMessage(const char *msg, va_list ap);
101 void _SetErrorMessage(const char *msg, ...);
104 cell_t *m_pNullString;
105 char m_MsgCache[1024];
108 BaseRuntime *m_pRuntime;
114 #endif //_INCLUDE_SOURCEPAWN_BASECONTEXT_H_