GetContext() now returns 'this' as a hack (shouldn't+can't be accessed anyway)

--HG--
branch : refac-jit
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/refac-jit%402397
This commit is contained in:
David Anderson 2008-07-11 05:14:32 +00:00
parent f9b294d89e
commit 79cf4e07eb
7 changed files with 32 additions and 17 deletions

View File

@ -494,7 +494,9 @@ namespace SourcePawn
/**
* @brief Deprecated, do not use.
*
* @return Opaque pointer.
* Returns the pointer of this object, casted to an opaque structure.
*
* @return Returns this.
*/
virtual sp_context_t *GetContext() =0;

View File

@ -52,7 +52,7 @@ BaseRuntime::~BaseRuntime()
void BaseRuntime::ClearCompile()
{
g_Jit1.FreeContextVars(m_pCtx->GetContext());
g_Jit1.FreeContextVars(m_pCtx->GetCtx());
g_Jit1.FreePluginVars(m_pPlugin);
}
@ -349,3 +349,9 @@ size_t BaseRuntime::GetMemUsage()
return mem;
}
BaseContext *BaseRuntime::GetBaseContext()
{
return m_pCtx;
}

View File

@ -45,6 +45,8 @@ public:
virtual void SetPauseState(bool paused);
virtual bool IsPaused();
virtual size_t GetMemUsage();
public:
BaseContext *GetBaseContext();
private:
void ClearCompile();
void RefreshFunctionCache();

View File

@ -65,6 +65,11 @@ IVirtualMachine *BaseContext::GetVirtualMachine()
}
sp_context_t *BaseContext::GetContext()
{
return reinterpret_cast<sp_context_t *>((IPluginContext * )this);
}
sp_context_t *BaseContext::GetCtx()
{
return &m_ctx;
}
@ -481,12 +486,14 @@ int BaseContext::LocalToStringNULL(cell_t local_addr, char **addr)
SourceMod::IdentityToken_t *BaseContext::GetIdentity()
{
return m_pToken;
}
SourceMod::IdentityToken_t *tok;
void BaseContext::SetIdentity(SourceMod::IdentityToken_t *token)
{
m_pToken = token;
if (GetKey(1, (void **)&tok))
{
return tok;
}
return NULL;
}
cell_t *BaseContext::GetNullRef(SP_NULL_TYPE type)
@ -536,7 +543,7 @@ int BaseContext::Execute(IPluginFunction *function, const cell_t *params, unsign
return SP_ERROR_NOT_RUNNABLE;
}
if (m_ctx.hp + 16*sizeof(cell_t) > (cell_t)(m_ctx.sp - (sizeof(cell_t) * (num_params + 1))))
if ((cell_t)(m_ctx.hp + 16*sizeof(cell_t)) > (cell_t)(m_ctx.sp - (sizeof(cell_t) * (num_params + 1))))
{
return SP_ERROR_STACKLOW;
}

View File

@ -49,6 +49,7 @@ public:
public: //IPluginContext
IVirtualMachine *GetVirtualMachine();
sp_context_t *GetContext();
sp_context_t *GetCtx();
bool IsDebugging();
int SetDebugBreak(void *newpfn, void *oldpfn);
IPluginDebugInfo *GetDebugInfo();
@ -82,7 +83,6 @@ public: //IPluginContext
IPluginFunction *GetFunctionByName(const char *public_name);
IPluginFunction *GetFunctionById(funcid_t func_id);
SourceMod::IdentityToken_t *GetIdentity();
void SetIdentity(SourceMod::IdentityToken_t *token);
cell_t *GetNullRef(SP_NULL_TYPE type);
int LocalToStringNULL(cell_t local_addr, char **addr);
int BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC native);
@ -100,7 +100,6 @@ private:
void _SetErrorMessage(const char *msg, ...);
private:
sp_plugin_t *m_pPlugin;
SourceMod::IdentityToken_t *m_pToken;
cell_t *m_pNullVec;
cell_t *m_pNullString;
char m_MsgCache[1024];

View File

@ -329,9 +329,9 @@ void SourcePawnEngine::PopTracer(int error, const char *msg)
{
uint32_t native = INVALID_CIP;
if (m_CallStack->ctx->GetContext()->n_err)
if (m_CallStack->ctx->GetCtx()->n_err)
{
native = m_CallStack->ctx->GetContext()->n_idx;
native = m_CallStack->ctx->GetCtx()->n_idx;
}
CContextTrace trace(m_CallStack, error, msg, native);

View File

@ -38,6 +38,8 @@
#include "../jit_version.h"
#include "../sp_vm_engine.h"
#include "../engine2.h"
#include "BaseRuntime.h"
#include "../sp_vm_basecontext.h"
#if defined USE_UNGEN_OPCODES
#include "ungen_opcodes.h"
@ -2416,10 +2418,7 @@ cell_t NativeCallback_Debug_Profile(sp_context_t *ctx, ucell_t native_idx, cell_
static cell_t InvalidNative(IPluginContext *pCtx, const cell_t *params)
{
sp_context_t *ctx = pCtx->GetContext();
ctx->n_err = SP_ERROR_INVALID_NATIVE;
return 0;
return pCtx->ThrowNativeErrorEx(SP_ERROR_INVALID_NATIVE, "Invalid native");
}
jitoffs_t RelocLookup(JitWriter *jit, cell_t pcode_offs, bool relative)
@ -2664,7 +2663,7 @@ jit_rewind:
*************/
/* setup basics */
sp_context_t *ctx = data->runtime->GetDefaultContext()->GetContext();
sp_context_t *ctx = data->runtime->GetBaseContext()->GetCtx();
/* Clear out any old cruft */
if (plugin->codebase != NULL)