| 1 | #ifdef RCSID |
| 2 | static char RCSid[] = |
| 3 | "$Header$"; |
| 4 | #endif |
| 5 | |
| 6 | /* |
| 7 | * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved. |
| 8 | * |
| 9 | * Please see the accompanying license file, LICENSE.TXT, for information |
| 10 | * on using and copying this software. |
| 11 | */ |
| 12 | /* |
| 13 | Name |
| 14 | vmbifl.cpp - built-in function - Load-time resolution |
| 15 | Function |
| 16 | This is a version of the built-in function interface for resolving |
| 17 | built-ins on loading the image file. This version makes no checks |
| 18 | on the availability of a function when it's invoked. |
| 19 | |
| 20 | This version can be used in a normal stand-alone interpreter. A |
| 21 | version of the interpreter that's used to complete compilation by |
| 22 | running 'preinit' should use the call-time resolution version instead. |
| 23 | Notes |
| 24 | |
| 25 | Modified |
| 26 | 07/21/99 MJRoberts - Creation |
| 27 | */ |
| 28 | |
| 29 | #include <stdlib.h> |
| 30 | #include <string.h> |
| 31 | |
| 32 | #include "t3std.h" |
| 33 | #include "vmtype.h" |
| 34 | #include "vmerr.h" |
| 35 | #include "vmerrnum.h" |
| 36 | #include "vmglob.h" |
| 37 | #include "vmbif.h" |
| 38 | #include "vmbifreg.h" |
| 39 | #include "vmstr.h" |
| 40 | #include "vmobj.h" |
| 41 | #include "vmrun.h" |
| 42 | |
| 43 | |
| 44 | /* ------------------------------------------------------------------------ */ |
| 45 | /* |
| 46 | * Call the given function from the given function set. |
| 47 | */ |
| 48 | void CVmBifTable::call_func(VMG_ uint set_index, uint func_index, uint argc) |
| 49 | { |
| 50 | /* |
| 51 | * find the function set in the registration table, get the function |
| 52 | * descriptor from the set's function table, and invoke the function |
| 53 | * pointer from the function descriptor |
| 54 | */ |
| 55 | (*table_[set_index]->func[func_index].func)(vmg_ argc); |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * Get a function's descriptor |
| 60 | */ |
| 61 | const vm_bif_desc *CVmBifTable::get_desc(uint set_index, uint func_index) |
| 62 | { |
| 63 | /* |
| 64 | * find the function in the registration table, and return the function |
| 65 | * descriptor from the set's function table |
| 66 | */ |
| 67 | return &table_[set_index]->func[func_index]; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | /* |
| 72 | * Handle adding a function set entry that's unresolvable at load-time |
| 73 | */ |
| 74 | void CVmBifTable::add_entry_unresolved(VMG_ const char *func_set_id) |
| 75 | { |
| 76 | /* this is the static-link version, so an unresolved entry is an error */ |
| 77 | err_throw_a(VMERR_UNKNOWN_FUNC_SET, 3, |
| 78 | ERR_TYPE_TEXTCHAR, func_set_id, |
| 79 | ERR_TYPE_FUNCSET, func_set_id, |
| 80 | ERR_TYPE_VERSION_FLAG); |
| 81 | } |