cfad47cfa3/t3compiler/tads3/include/t3.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#charset "us-ascii"
2
3
/* 
4
 *   Copyright (c) 1999, 2006 Michael J. Roberts
5
 *   
6
 *   This file is part of TADS 3
7
 *   
8
 *   This header defines the t3vm intrinsic function set.  These functions
9
 *   provide access to basic features of the Virtual Machine.  
10
 */
11
12
/*
13
 *   T3 intrinsic function set definition
14
 */
15
16
#ifndef T3_H
17
#define T3_H
18
19
/* 
20
 *   include the LookupTable intrinsic class, since t3GetGlobalSymbols()
21
 *   returns an instance of this class 
22
 */
23
#include "lookup.h"
24
25
26
/* 
27
 *   define the T3 system interface 
28
 */
29
intrinsic 't3vm/010005'
30
{
31
    /* 
32
     *   Explicitly run garbage collection.
33
     */
34
    t3RunGC();
35
36
    /* 
37
     *   Set the default output function or method.  The return value is the
38
     *   old function pointer or method, depending on which one is being set
39
     *   with this call.  (If 'val' is a function pointer, the return value
40
     *   will be the old function; if 'val' is a property ID, the return
41
     *   value is the old method.)
42
     *   
43
     *   The special values T3SetSayNoFunc and T3SetSayNoMethod can be passed
44
     *   to the function to remove any existing function or method,
45
     *   respectively, and are returned when appropriate to indicate that
46
     *   there was no previous setting.  
47
     */
48
    t3SetSay(val);
49
50
    /* 
51
     *   Get the VM version number.  Returns the version number as an integer
52
     *   value, with the major version in the high-order 16 bits, the minor
53
     *   version number in the next 8 bits, and the patch number ("point
54
     *   release" number) in the low-order 8 bits.  For example, version
55
     *   3.0.10 is encoded as 0x0003000A.  
56
     */
57
    t3GetVMVsn();
58
59
    /* 
60
     *   Get the VM identifier string.  This returns the version number as a
61
     *   string, as in '3.0.10'.
62
     */
63
    t3GetVMID();
64
65
    /* 
66
     *   Get the VM banner string.  This returns a string with the name of
67
     *   the VM, the version number, and a copyright string, in a format
68
     *   suitable for displaying to the user to identify the VM executable.  
69
     */
70
    t3GetVMBanner();
71
72
    /* 
73
     *   Get the preinitialization mode flag.  This returns true if the VM is
74
     *   running as part of the compiler's pre-initialization phase, nil if
75
     *   it's running as a normal interpreter.  
76
     */
77
    t3GetVMPreinitMode();
78
79
    /* 
80
     *   Debugger trace operations.  This provides access to the interactive
81
     *   debugger subsystem, if the VM is running under a debugger.  The
82
     *   'mode' argument determines what the function does and what the
83
     *   additional arguments, if any, are for:
84
     *   
85
     *   T3DebugCheck - checks to see if an interactive debugger is present.
86
     *   No additional arguments; returns true if a debugger is present, nil
87
     *   if not.
88
     *   
89
     *   T3DebugBreak - breaks into the interactive debugger, pausing
90
     *   execution at the current code location so that the user can inspect
91
     *   the current machine state and determine how to proceed.  No
92
     *   additional arguments; after the user proceeds with execution, the
93
     *   function returns true to indicate that a debugger is present.  If no
94
     *   debugger is present, the function simply returns nil, and has no
95
     *   other effect.  
96
     */
97
    t3DebugTrace(mode, ...);
98
99
    /*
100
     *   Get the global symbol table.  If a symbol table is available, this
101
     *   returns a LookupTable object; otherwise, it returns nil.
102
     *   
103
     *   This call will return a valid object value when pre-initialization
104
     *   is running during program building, or when the program has been
105
     *   compiled for debugging.  When a program compiled for release (i.e.,
106
     *   no debug information) is run under the interpreter, this will
107
     *   return nil, because no symbol information is available.
108
     *   
109
     *   Note that programs can, if they wish, get a reference to this
110
     *   object during pre-initialization, then keep the reference (by
111
     *   storing it in an object property, for example) so that it is
112
     *   available during normal execution under the interpreter.  If the
113
     *   program is compiled for release, and it does not keep a reference
114
     *   in this manner, the garbage collector will automatically delete the
115
     *   object when pre-initialization is completed.  This allows programs
116
     *   that wish to keep the symbol information around at run-time to do
117
     *   so, while not burdening programs that don't need the information
118
     *   with the extra memory the symbols consume.  
119
     */
120
    t3GetGlobalSymbols();
121
122
    /*
123
     *   Allocate a new property.  Returns a new property not yet used
124
     *   anywhere in the program.  Note that property ID's are a somewhat
125
     *   limited resource - only approximately 65,000 total are available,
126
     *   including all of the properties that the program defines
127
     *   statically.  
128
     */
129
    t3AllocProp();
130
131
    /*
132
     *   Get a stack trace.  This returns a list of T3StackInfo objects.
133
     *   Each object represents a nesting level in the call stack.  The first
134
     *   element in the list represents the currently active level (i.e., the
135
     *   level that called this function), the second element represents the
136
     *   caller of the first element, and so on.
137
     *   
138
     *   If 'level' is specified, we'll return a single T3StackInfo object
139
     *   giving the context at the given stack level - 1 is the active level,
140
     *   2 is its caller, and so on, so 'level' would simply be the index in
141
     *   the returned list when this argument is omitted.  
142
     */
143
    t3GetStackTrace(level?);
144
}
145
146
/*
147
 *   t3DebugTrace() mode flags 
148
 */
149
150
/* check to see if the debugger is present */
151
#define T3DebugCheck     1
152
153
/* break into the debugger */
154
#define T3DebugBreak     2
155
156
/*
157
 *   t3SetSay() special values.  These can be passed in lieu of a function
158
 *   pointer or property ID when the caller wants to remove any existing
159
 *   function or method rather than install a new one.  
160
 */
161
#define T3SetSayNoFunc    1
162
#define T3SetSayNoMethod  2
163
164
165
#endif /* T3_H */