diff --git a/public/sourcepawn/sp_vm_api.h b/public/sourcepawn/sp_vm_api.h index e2a51e38..ad56dfb5 100644 --- a/public/sourcepawn/sp_vm_api.h +++ b/public/sourcepawn/sp_vm_api.h @@ -829,6 +829,26 @@ namespace SourcePawn const cell_t *params, unsigned int num_params, cell_t *result) =0; + + /** + * @brief Returns whether a context is in an error state. + * + * This should only be used inside natives to determine whether + * a prior call failed. + */ + virtual int GetLastNativeError() =0; + + /** + * @brief Returns the local parameter stack, starting from the + * cell that contains the number of parameters passed. + * + * Local parameters are the parameters passed to the function + * from which a native was called (and thus this can only be + * called inside a native). + * + * @return Parameter stack. + */ + virtual cell_t *GetLocalParams() =0; }; diff --git a/sourcepawn/jit/sp_vm_basecontext.cpp b/sourcepawn/jit/sp_vm_basecontext.cpp index 36315f12..7bd0b003 100644 --- a/sourcepawn/jit/sp_vm_basecontext.cpp +++ b/sourcepawn/jit/sp_vm_basecontext.cpp @@ -759,3 +759,13 @@ int DebugInfo::LookupLine(ucell_t addr, uint32_t *line) } #undef USHR + +int BaseContext::GetLastNativeError() +{ + return m_ctx.n_err; +} + +cell_t *BaseContext::GetLocalParams() +{ + return (cell_t *)(m_pPlugin->memory + m_ctx.frm + (2 * sizeof(cell_t))); +} diff --git a/sourcepawn/jit/sp_vm_basecontext.h b/sourcepawn/jit/sp_vm_basecontext.h index d56f3ed4..d8e50e22 100644 --- a/sourcepawn/jit/sp_vm_basecontext.h +++ b/sourcepawn/jit/sp_vm_basecontext.h @@ -88,6 +88,8 @@ public: //IPluginContext int BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC native); int Execute(IPluginFunction *function, const cell_t *params, unsigned int num_params, cell_t *result); IPluginRuntime *GetRuntime(); + int GetLastNativeError(); + cell_t *GetLocalParams(); public: bool IsInExec(); private: