Debian Codegraph @

terps/tads/tads3/vmbt3_nd.cpp

raw symbols SCIP
1 #ifdef RCSID
2 static char RCSid[] =
3 "$Header$";
4 #endif
5
6 /*
7 * Copyright (c) 2000, 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 vmbt3_nd.cpp - T3 VM system interface function set - non-debugger version
15 Function
16
17 Notes
18
19 Modified
20 03/11/00 MJRoberts - Creation
21 */
22
23 #include <time.h>
24
25 #include "t3std.h"
26 #include "vmtype.h"
27 #include "vmbif.h"
28 #include "vmbift3.h"
29 #include "vmstack.h"
30 #include "vmrun.h"
31 #include "charmap.h"
32 #include "vmdatasrc.h"
33 #include "vmlog.h"
34
35
36 /*
37 * Debug Trace
38 */
39 void CVmBifT3::debug_trace(VMG_ uint argc)
40 {
41 /* make sure we have at least one argument */
42 if (argc < 1)
43 err_throw(VMERR_WRONG_NUM_OF_ARGS);
44
45 /* pop the flags and see what we're being asked to do */
46 switch(pop_int_val(vmg0_))
47 {
48 case T3DBG_CHECK:
49 /* check arguments */
50 check_argc(vmg_ argc, 1);
51
52 /* we're just being asked if the debugger is present - it's not */
53 retval_nil(vmg0_);
54 break;
55
56 case T3DBG_BREAK:
57 /* check arguments */
58 check_argc(vmg_ argc, 1);
59
60 /* tell the caller there's no debugger */
61 retval_nil(vmg0_);
62 break;
63
64 case T3DBG_LOG:
65 {
66 /* check arguments and retrieve the string */
67 check_argc(vmg_ argc, 2);
68 const char *str = G_stk->get(0)->get_as_string(vmg0_);
69 if (str == 0)
70 err_throw(VMERR_BAD_TYPE_BIF);
71
72 /* decode and skip the length prefix */
73 int len = vmb_get_len(str);
74 str += VMB_LEN;
75
76 /* convert the string to the local file character set */
77 char *lstr;
78 size_t llen = G_cmap_to_file->map_utf8_alo(&lstr, str, len);
79
80 /* log the message */
81 vm_log(vmg_ lstr, llen);
82
83 /* done with the mapped string */
84 t3free(lstr);
85
86 /* discard the string */
87 G_stk->discard();
88 }
89
90 /* no return value */
91 retval_nil(vmg0_);
92 break;
93
94 default:
95 /* anything else just returns nil, to allow for future expansion */
96 G_stk->discard(argc - 1);
97 retval_nil(vmg0_);
98 break;
99 }
100 }
101