cfad47cfa3/tads3/vmbifl.cpp

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
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
    vm_bif_entry_t *entry;
51
    void (*func)(VMG_ uint argc);
52
    
53
    /* get the function set */
54
    entry = table_[set_index];
55
56
    /* get the function pointer */
57
    func = entry->func[func_index];
58
59
    /* call the function */
60
    (*func)(vmg_ argc);
61
}
62
63
/*
64
 *   Handle adding a function set entry that's unresolvable at load-time 
65
 */
66
void CVmBifTable::add_entry_unresolved(const char *func_set_id)
67
{
68
    /* we can't load it - throw an error */
69
    err_throw_a(VMERR_UNKNOWN_FUNC_SET, 1, ERR_TYPE_TEXTCHAR, func_set_id);
70
}