sourcepawn/include/sp_vm_api.h
author David Anderson <dvander@alliedmods.net>
Sat Nov 11 05:47:00 2006 +0000 (2006-11-11)
changeset 175 d8fc20f56ca0
parent 172 d8a8186eccbf
child 179 628bdadc9b32
permissions -rw-r--r--
added new API for function address lookups. this gives us O(1) code_addr -> sequential index
dvander@67
     1
#ifndef _INCLUDE_SOURCEPAWN_VM_API_H_
dvander@67
     2
#define _INCLUDE_SOURCEPAWN_VM_API_H_
dvander@67
     3
dvander@67
     4
#include <stdio.h>
dvander@67
     5
#include "sp_vm_types.h"
dvander@67
     6
dvander@175
     7
#define SOURCEPAWN_VM_API_VERSION		1
dvander@175
     8
dvander@67
     9
namespace SourcePawn
dvander@67
    10
{
dvander@157
    11
	class IVirtualMachine;
dvander@157
    12
dvander@164
    13
	/**
dvander@164
    14
	 * @brief Interface to managing a debug context at runtime.
dvander@164
    15
	 */
dvander@157
    16
	class IPluginDebugInfo
dvander@157
    17
	{
dvander@157
    18
	public:
dvander@157
    19
		/**
dvander@157
    20
		 * Given a code pointer, finds the file it is associated with.
dvander@157
    21
		 * 
dvander@157
    22
		 * @param addr		Code address offset.
dvander@157
    23
		 * @param filename	Pointer to store filename pointer in.
dvander@157
    24
		 */
dvander@157
    25
		virtual int LookupFile(ucell_t addr, const char **filename) =0;
dvander@157
    26
dvander@157
    27
		/**
dvander@157
    28
		 * Given a code pointer, finds the function it is associated with.
dvander@157
    29
		 *
dvander@157
    30
		 * @param addr		Code address offset.
dvander@157
    31
		 * @param name		Pointer to store function name pointer in.
dvander@157
    32
		 */
dvander@157
    33
		virtual int LookupFunction(ucell_t addr, const char **name) =0;
dvander@157
    34
dvander@157
    35
		/**
dvander@157
    36
		 * Given a code pointer, finds the line it is associated with.
dvander@157
    37
		 *
dvander@157
    38
		 * @param addr		Code address offset.
dvander@157
    39
		 * @param line		Pointer to store line number in.
dvander@157
    40
		 */
dvander@157
    41
		virtual int LookupLine(ucell_t addr, uint32_t *line) =0;
dvander@157
    42
	};
dvander@157
    43
dvander@164
    44
	/**
dvander@164
    45
	 * @brief Interface to managing a context at runtime.
dvander@164
    46
	 */
dvander@157
    47
	class IPluginContext
dvander@157
    48
	{
dvander@157
    49
	public:
dvander@157
    50
		virtual ~IPluginContext() { };
dvander@157
    51
	public:
dvander@157
    52
		/** 
dvander@157
    53
		 * Returns the parent IVirtualMachine.
dvander@157
    54
		 *
dvander@157
    55
		 * @return				Parent virtual machine pointer.
dvander@157
    56
		 */
dvander@157
    57
		virtual IVirtualMachine *GetVirtualMachine() =0;
dvander@157
    58
dvander@157
    59
		/**
dvander@157
    60
		 * Returns the child sp_context_t structure.
dvander@157
    61
		 *
dvander@157
    62
		 * @return				Child sp_context_t structure.
dvander@157
    63
		 */
dvander@157
    64
		virtual sp_context_t *GetContext() =0;
dvander@157
    65
dvander@157
    66
		/**
dvander@157
    67
		 * Returns true if the plugin is in debug mode.
dvander@157
    68
		 *
dvander@157
    69
		 * @return				True if in debug mode, false otherwise.
dvander@157
    70
		 */
dvander@157
    71
		virtual bool IsDebugging() =0;
dvander@157
    72
dvander@157
    73
		/**
dvander@157
    74
		 * Installs a debug break and returns the old one, if any.
dvander@157
    75
		 * This will fail if the plugin is not debugging.
dvander@157
    76
		 *
dvander@157
    77
		 * @param newpfn		New function pointer.
dvander@157
    78
		 * @param oldpfn		Pointer to retrieve old function pointer.
dvander@157
    79
		 */
dvander@157
    80
		virtual int SetDebugBreak(SPVM_DEBUGBREAK newpfn, SPVM_DEBUGBREAK *oldpfn) =0;
dvander@157
    81
dvander@157
    82
		/**
dvander@157
    83
		 * Returns debug info.
dvander@157
    84
		 *
dvander@157
    85
		 * @return				IPluginDebugInfo, or NULL if no debug info found.
dvander@157
    86
		 */
dvander@157
    87
		virtual IPluginDebugInfo *GetDebugInfo() =0;
dvander@157
    88
dvander@157
    89
		/**
dvander@157
    90
		 * Allocs memory on the secondary stack of a plugin.
dvander@157
    91
		 * Note that although called a heap, it is in fact a stack.
dvander@157
    92
		 * 
dvander@157
    93
		 * @param cells			Number of cells to allocate.
dvander@157
    94
		 * @param local_adddr	Will be filled with data offset to heap.
dvander@157
    95
		 * @param phys_addr		Physical address to heap memory.
dvander@157
    96
		 */
dvander@157
    97
		virtual int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr) =0;
dvander@157
    98
dvander@157
    99
		/**
dvander@157
   100
		 * Pops a heap address off the heap stack.  Use this to free memory allocated with
dvander@157
   101
		 *  SP_HeapAlloc().  
dvander@157
   102
		 * Note that in SourcePawn, the heap is in fact a bottom-up stack.  Deallocations
dvander@157
   103
		 *  with this native should be performed in precisely the REVERSE order.
dvander@157
   104
		 *
dvander@157
   105
		 * @param local_addr	Local address to free.
dvander@157
   106
 		 */
dvander@157
   107
		virtual int HeapPop(cell_t local_addr) =0;
dvander@157
   108
dvander@157
   109
		/**
dvander@157
   110
		 * Releases a heap address using a different method than SP_HeapPop().
dvander@157
   111
		 * This allows you to release in any order.  However, if you allocate N 
dvander@157
   112
		 *  objects, release only some of them, then begin allocating again, 
dvander@157
   113
		 *  you cannot go back and starting freeing the originals.  
dvander@157
   114
		 * In other words, for each chain of allocations, if you start deallocating,
dvander@157
   115
		 *  then allocating more in a chain, you must only deallocate from the current 
dvander@157
   116
		 *  allocation chain.  This is basically HeapPop() except on a larger scale.
dvander@157
   117
		 *
dvander@157
   118
		 * @param local_addr	Local address to free.
dvander@157
   119
 		 */
dvander@157
   120
		virtual int HeapRelease(cell_t local_addr) =0;
dvander@157
   121
dvander@157
   122
		/**
dvander@157
   123
		 * Finds a native by name.
dvander@157
   124
		 *
dvander@157
   125
		 * @param name			Name of native.
dvander@157
   126
		 * @param index			Optionally filled with native index number.
dvander@157
   127
		 */
dvander@157
   128
		virtual int FindNativeByName(const char *name, uint32_t *index) =0;
dvander@157
   129
dvander@157
   130
		/**
dvander@157
   131
		 * Gets native info by index.
dvander@157
   132
		 *
dvander@157
   133
		 * @param index			Index number of native.
dvander@157
   134
		 * @param native		Optionally filled with pointer to native structure.
dvander@157
   135
		 */
dvander@157
   136
		virtual int GetNativeByIndex(uint32_t index, sp_native_t **native) =0;
dvander@157
   137
dvander@157
   138
		/**
dvander@157
   139
		 * Gets the number of natives.
dvander@157
   140
		 * 
dvander@157
   141
		 * @return				Filled with the number of natives.
dvander@157
   142
		 */
dvander@157
   143
		virtual uint32_t GetNativesNum() =0;
dvander@157
   144
dvander@157
   145
		/**
dvander@157
   146
		 * Finds a public function by name.
dvander@157
   147
		 *
dvander@157
   148
		 * @param name			Name of public
dvander@157
   149
		 * @param index			Optionally filled with public index number.
dvander@157
   150
		 */
dvander@157
   151
		virtual int FindPublicByName(const char *name, uint32_t *index) =0;
dvander@157
   152
dvander@157
   153
		/**
dvander@157
   154
		 * Gets public function info by index.
dvander@157
   155
		 * 
dvander@157
   156
		 * @param index			Public function index number.
dvander@157
   157
		 * @param public		Optionally filled with pointer to public structure.
dvander@157
   158
		 */
dvander@157
   159
		virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr) =0;
dvander@157
   160
dvander@157
   161
		/**
dvander@157
   162
		 * Gets the number of public functions.
dvander@157
   163
		 *
dvander@157
   164
		 * @return				Filled with the number of public functions.
dvander@157
   165
		 */
dvander@157
   166
		virtual uint32_t GetPublicsNum() =0;
dvander@157
   167
dvander@157
   168
		/**
dvander@157
   169
		 * Gets public variable info by index.
dvander@157
   170
		 * @param index			Public variable index number.
dvander@157
   171
		 * @param pubvar		Optionally filled with pointer to pubvar structure.
dvander@157
   172
		 */
dvander@157
   173
		virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) =0;
dvander@157
   174
dvander@157
   175
		/**
dvander@157
   176
		 * Finds a public variable by name.
dvander@157
   177
		 *
dvander@157
   178
		 * @param name			Name of pubvar
dvander@157
   179
		 * @param index			Optionally filled with pubvar index number.
dvander@157
   180
		 */
dvander@157
   181
		virtual int FindPubvarByName(const char *name, uint32_t *index) =0;
dvander@157
   182
dvander@157
   183
		/**
dvander@157
   184
		* Gets the addresses of a public variable.
dvander@157
   185
		* 
dvander@157
   186
		* @param index			Index of public variable.
dvander@157
   187
		* @param local_addr		Address to store local address in.
dvander@157
   188
		* @param phys_addr		Address to store physically relocated in.
dvander@157
   189
		*/
dvander@157
   190
		virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) =0;
dvander@157
   191
dvander@157
   192
		/**
dvander@157
   193
		 * Returns the number of public variables.
dvander@157
   194
		 *
dvander@157
   195
		 * @return				Number of public variables.
dvander@157
   196
		 */
dvander@157
   197
		virtual uint32_t GetPubVarsNum() =0;
dvander@157
   198
dvander@157
   199
		/**
dvander@157
   200
		 * Round-about method of converting a plugin reference to a physical address
dvander@157
   201
		 *
dvander@157
   202
		 * @param local_addr	Local address in plugin.
dvander@157
   203
		 * @param phys_addr		Optionally filled with relocated physical address.
dvander@157
   204
		 */
dvander@157
   205
		virtual int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr) =0;
dvander@157
   206
dvander@157
   207
		/**:TODO: FIX ALL PACKED STUFF COMMENTS!
dvander@157
   208
		 * Converts a local address to a physical string.
dvander@157
   209
		 * Note that SourcePawn does not support packed strings, as such this function is
dvander@157
   210
		 *  'cell to char' only.
dvander@157
   211
		 *
dvander@157
   212
		 * @param local_addr	Local address in plugin.
dvander@157
   213
		 * @param addr			Destination output pointer.
dvander@157
   214
		 */
dvander@157
   215
		virtual int LocalToString(cell_t local_addr, char **addr) =0;
dvander@157
   216
dvander@157
   217
		/**
dvander@157
   218
		 * Converts a physical string to a local address.
dvander@157
   219
		 * Note that SourcePawn does not support packed strings.
dvander@157
   220
		 *
dvander@157
   221
		 * @param local_addr	Local address in plugin.
dvander@157
   222
		 * @param chars			Number of chars to write, including NULL terminator.
dvander@157
   223
		 * @param source		Source string to copy.
dvander@157
   224
		 */
dvander@157
   225
		virtual int StringToLocal(cell_t local_addr, size_t chars, const char *source) =0;
dvander@157
   226
dvander@157
   227
		/**
dvander@157
   228
		 * Pushes a cell onto the stack.  Increases the parameter count by one.
dvander@157
   229
		 *
dvander@157
   230
		 * @param value			Cell value.
dvander@157
   231
		 */
dvander@157
   232
		virtual int PushCell(cell_t value) =0;
dvander@157
   233
dvander@157
   234
		/** 
dvander@157
   235
		 * Pushes an array of cells onto the stack.  Increases the parameter count by one.
dvander@157
   236
		 * If the function returns an error it will fail entirely, releasing anything allocated in the process.
dvander@157
   237
		 * Note that this does not release the heap, so you should release it after
dvander@157
   238
		 *  calling Execute().
dvander@157
   239
		 *
dvander@157
   240
		 * @param local_addr	Filled with local address to release.
dvander@157
   241
		 * @param phys_addr		Optionally filled with physical address of new array.
dvander@157
   242
		 * @param array			Cell array to copy.
dvander@157
   243
		 * @param numcells		Number of cells in the array to copy.
dvander@157
   244
		 */
dvander@157
   245
		virtual int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells) =0;
dvander@157
   246
dvander@157
   247
		/**
dvander@157
   248
		 * Pushes a string onto the stack (by reference) and increases the parameter count by one.
dvander@157
   249
		 * Note that this does not release the heap, so you should release it after
dvander@157
   250
		 *  calling Execute().
dvander@157
   251
		 *
dvander@157
   252
		 * @param local_addr	Filled with local address to release.
dvander@157
   253
		 * @param phys_addr		Optionally filled with physical address of new array.
dvander@157
   254
		 * @param string		Source string to push.
dvander@157
   255
		 */
dvander@157
   256
		virtual int PushString(cell_t *local_addr, cell_t **phys_addr, const char *string) =0;
dvander@157
   257
dvander@157
   258
		/**
dvander@157
   259
		 * Individually pushes each cell of an array of cells onto the stack.  Increases the 
dvander@157
   260
		 *  parameter count by the number of cells pushed.
dvander@157
   261
		 * If the function returns an error it will fail entirely, releasing anything allocated in the process.
dvander@157
   262
		 *
dvander@157
   263
		 * @param array			Array of cells to read from.
dvander@157
   264
		 * @param numcells		Number of cells to read.
dvander@157
   265
		 */
dvander@157
   266
		virtual int PushCellsFromArray(cell_t array[], unsigned int numcells) =0;
dvander@157
   267
dvander@157
   268
		/** 
dvander@157
   269
		 * Binds a list of native names and their function pointers to a context.
dvander@157
   270
		 * If num is 0, the list is read until an entry with a NULL name is reached.
dvander@157
   271
		 * If overwrite is non-zero, already registered natives will be overwritten.
dvander@157
   272
		 * 
dvander@157
   273
		 * @param natives		Array of natives.
dvander@157
   274
		 * @param num			Number of natives in array.
dvander@157
   275
		 * @param overwrite		Toggles overwrite.
dvander@157
   276
		 */
dvander@157
   277
		virtual int BindNatives(sp_nativeinfo_t *natives, unsigned int num, int overwrite) =0;
dvander@157
   278
dvander@157
   279
		/**
dvander@157
   280
		 * Binds a single native.  Overwrites any existing bind.
dvander@157
   281
		 * If the context does not contain the native that will be binded the function will return
dvander@164
   282
		 *  with a SP_ERROR_NOT_FOUND error.
dvander@157
   283
		 *
dvander@157
   284
		 * @param native		Pointer to native.
dvander@157
   285
		 */
dvander@164
   286
		virtual int BindNative(sp_nativeinfo_t *native) =0;
dvander@157
   287
dvander@157
   288
		/**
dvander@164
   289
		 * Binds a single native to any non-registered native.
dvander@157
   290
		 *
dvander@157
   291
		 * @param native		Native to bind.
dvander@157
   292
		 */
dvander@157
   293
		virtual int BindNativeToAny(SPVM_NATIVE_FUNC native) =0;
dvander@157
   294
dvander@157
   295
		/**
dvander@164
   296
		 * Executes a function ID located in this context.
dvander@164
   297
		 *
dvander@164
   298
		 * @param funcid		Function id to execute.
dvander@164
   299
		 * @param result		Pointer to store the return value (required).
dvander@164
   300
		 * @return				Error code (if any) from the VM.
dvander@157
   301
		 */
dvander@164
   302
		virtual int Execute(uint32_t funcid, cell_t *result) =0;
dvander@157
   303
	};
dvander@67
   304
dvander@67
   305
	/**
dvander@164
   306
	 * @brief Contains helper functions used by VMs and the host app
dvander@67
   307
	 */
dvander@67
   308
	class ISourcePawnEngine
dvander@67
   309
	{
dvander@67
   310
	public:
dvander@67
   311
		/**
dvander@67
   312
		* Loads a named file from a file pointer.  
dvander@67
   313
		* Using this means base memory will be allocated by the VM.
dvander@67
   314
		* 
faluco@149
   315
		* @param fp			File pointer.  May be at any offset.  Not closed on return.
dvander@67
   316
		* @param err		Optional error code pointer.
dvander@67
   317
		* @return			A new plugin structure.
dvander@67
   318
		*/	
dvander@67
   319
		virtual sp_plugin_t *LoadFromFilePointer(FILE *fp, int *err) =0;
dvander@67
   320
	
dvander@67
   321
		/**
dvander@67
   322
		 * Loads a file from a base memory address.
dvander@67
   323
		 *	
dvander@67
   324
		 * @param base		Base address of the plugin's memory region.
dvander@67
   325
		 * @param plugin	If NULL, a new plugin pointer is returned.
dvander@67
   326
		 *                  Otherwise, the passed pointer is used.
dvander@67
   327
		 * @param err		Optional error code pointer.
dvander@67
   328
		 * @return			The resulting plugin pointer.
dvander@67
   329
		 */
dvander@67
   330
		virtual sp_plugin_t *LoadFromMemory(void *base, sp_plugin_t *plugin, int *err) =0;
dvander@67
   331
dvander@67
   332
		/**
dvander@67
   333
		 * Frees all of the memory associated with a plugin file.
dvander@67
   334
		 * If allocated using SP_LoadFromMemory, the base and plugin pointer 
dvander@67
   335
		 *  itself are not freed (so this may end up doing nothing).
dvander@67
   336
		 */
dvander@67
   337
		virtual int FreeFromMemory(sp_plugin_t *plugin) =0;
dvander@67
   338
dvander@67
   339
		/**
dvander@67
   340
		 * Creates a new IContext from a context handle.
dvander@67
   341
		 *
dvander@67
   342
		 * @param ctx		Context to use as a basis for the IPluginContext.
dvander@67
   343
		 * @return			New IPluginContext handle.
dvander@67
   344
		 */
dvander@67
   345
		virtual IPluginContext *CreateBaseContext(sp_context_t *ctx) =0;
dvander@67
   346
dvander@67
   347
		/** 
dvander@172
   348
		 * Frees a base context.  Does not free the sp_context_t it holds.
dvander@67
   349
		 *
dvander@67
   350
		 * @param ctx		Context pointer to free.
dvander@67
   351
		 */
dvander@67
   352
		virtual void FreeBaseContext(IPluginContext *ctx) =0;
dvander@67
   353
dvander@67
   354
		/**
dvander@93
   355
		 * Allocates large blocks of temporary memory.
dvander@67
   356
		 * 
dvander@67
   357
		 * @param size		Size of memory to allocate.
dvander@67
   358
		 * @return			Pointer to memory, NULL if allocation failed.
dvander@67
   359
		 */
dvander@67
   360
		virtual void *BaseAlloc(size_t size) =0;
dvander@67
   361
dvander@67
   362
		/**
dvander@67
   363
		 * Frees memory allocated with BaseAlloc.
dvander@67
   364
		 *
faluco@149
   365
		 * @param memory	Memory address to free.
dvander@67
   366
		 */
dvander@67
   367
		virtual void BaseFree(void *memory) =0;
dvander@93
   368
dvander@93
   369
		/**
dvander@93
   370
		 * Allocates executable memory.
dvander@93
   371
		 *
dvander@93
   372
		 * @param size		Size of memory to allocate.
dvander@93
   373
		 * @return			Pointer to memory, NULL if allocation failed.
dvander@93
   374
		 */
dvander@93
   375
		virtual void *ExecAlloc(size_t size) =0;
dvander@93
   376
dvander@93
   377
		/**
dvander@93
   378
		 * Frees executable memory.
dvander@93
   379
		 *
faluco@149
   380
		 * @param address	Address to free.
dvander@93
   381
		 */
dvander@93
   382
		virtual void ExecFree(void *address) =0;
dvander@67
   383
	};
dvander@67
   384
dvander@69
   385
	class ICompilation
dvander@69
   386
	{
dvander@69
   387
	public:
dvander@69
   388
		virtual ~ICompilation() { };
dvander@69
   389
	};
dvander@67
   390
dvander@164
   391
	/** 
dvander@164
   392
	 * @brief Outlines the interface a Virtual Machine (JIT) must expose
dvander@164
   393
	 */
dvander@67
   394
	class IVirtualMachine
dvander@67
   395
	{
dvander@67
   396
	public:
dvander@67
   397
		/**
dvander@175
   398
		 * @brief Returns the current API version.
dvander@175
   399
		 */
dvander@175
   400
		virtual unsigned int GetAPIVersion() =0;
dvander@175
   401
dvander@175
   402
		/**
dvander@175
   403
		 * @brief Returns the string name of a VM implementation.
dvander@67
   404
		 */
dvander@67
   405
		virtual const char *GetVMName() =0;
dvander@67
   406
dvander@67
   407
		/**
dvander@175
   408
		 * @brief Begins a new compilation
dvander@67
   409
		 * 
dvander@67
   410
		 * @param plugin	Pointer to a plugin structure.
dvander@67
   411
		 * @return			New compilation pointer.
dvander@67
   412
		 */
dvander@67
   413
		virtual ICompilation *StartCompilation(sp_plugin_t *plugin) =0;
dvander@67
   414
dvander@67
   415
		/**
dvander@175
   416
		 * @brief Sets a compilation option.
dvander@67
   417
		 *
dvander@67
   418
		 * @param co		Pointer to a compilation.
dvander@67
   419
		 * @param key		Option key name.
dvander@67
   420
		 * @param val		Option value string.
dvander@67
   421
		 * @return			True if option could be set, false otherwise.
dvander@67
   422
		 */
dvander@67
   423
		virtual bool SetCompilationOption(ICompilation *co, const char *key, const char *val) =0;
dvander@67
   424
dvander@67
   425
		/**
dvander@175
   426
		 * @brief Finalizes a compilation into a new sp_context_t.
dvander@67
   427
		 * Note: This will free the ICompilation pointer.
dvander@67
   428
		 *
dvander@67
   429
		 * @param co		Compilation pointer.
dvander@69
   430
		 * @param err		Filled with error code on exit.
dvander@67
   431
		 * @return			New plugin context.
dvander@67
   432
		 */
dvander@93
   433
		virtual sp_context_t *CompileToContext(ICompilation *co, int *err) =0;
dvander@69
   434
dvander@69
   435
		/**
dvander@175
   436
		 * @brief Aborts a compilation and frees the ICompilation pointer.
dvander@69
   437
		 *
dvander@69
   438
		 * @param co		Compilation pointer.
dvander@69
   439
		 */
dvander@69
   440
		virtual void AbortCompilation(ICompilation *co) =0;
dvander@67
   441
dvander@67
   442
		/**
dvander@175
   443
		 * @brief Frees any internal variable usage on a context.
dvander@67
   444
		 *
dvander@67
   445
		 * @param ctx		Context structure pointer.
dvander@67
   446
		 */
dvander@93
   447
		virtual void FreeContext(sp_context_t *ctx) =0;
dvander@67
   448
dvander@67
   449
		/**
dvander@175
   450
		 * @brief Calls the "execute" function on a context.
dvander@67
   451
		 *
dvander@67
   452
		 * @param ctx		Executes a function in a context.
dvander@175
   453
		 * @param code_addr	Index into the code section.
dvander@175
   454
		 * @param result	Pointer to store result into.
dvander@67
   455
		 * @return			Error code (if any).
dvander@67
   456
		 */
dvander@175
   457
		virtual int ContextExecute(sp_context_t *ctx, uint32_t code_addr, cell_t *result) =0;
dvander@175
   458
dvander@175
   459
		/**
dvander@175
   460
		 * @brief Given a context and a code address, returns the index of the function.
dvander@175
   461
		 * 
dvander@175
   462
		 * @param ctx		Context to search.
dvander@175
   463
		 * @param code_addr	Index into the code section.
dvander@175
   464
		 * @param result	Pointer to store result into.
dvander@175
   465
		 * @return			True if code index is valid, false otherwise.
dvander@175
   466
		 */
dvander@175
   467
		virtual bool FunctionLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result) =0;
dvander@175
   468
dvander@175
   469
		/**
dvander@175
   470
		 * @brief Returns the number of functions defined in the context.
dvander@175
   471
		 *
dvander@175
   472
		 * @param ctx		Context to search.
dvander@175
   473
		 * @return			Number of functions.
dvander@175
   474
		 */
dvander@175
   475
		virtual unsigned int FunctionCount(const sp_context_t *ctx) =0;
dvander@67
   476
	};
dvander@67
   477
};
dvander@67
   478
dvander@67
   479
#endif //_INCLUDE_SOURCEPAWN_VM_API_H_