Debian Codegraph @

terps/tads/tads2/dat.c

raw symbols SCIP
1 #ifdef RCSID
2 static char RCSid[] =
3 "$Header: d:/cvsroot/tads/TADS2/DAT.C,v 1.2 1999/05/17 02:52:11 MJRoberts Exp $";
4 #endif
5
6 /*
7 * Copyright (c) 1991, 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 dat.c - datatype manipulation routines
15 Function
16 Functions to operate on TADS run-time datatypes
17 Notes
18 Datatypes are portable, hence the hard-coded values for data
19 sizes.
20 Modified
21 08/13/91 MJRoberts - creation
22 */
23
24 #include "os.h"
25 #include "std.h"
26 #include "dat.h"
27 #include "lst.h"
28 #include "prp.h"
29 #include "obj.h"
30 #include "voc.h"
31
32 /* return size of a data value */
33 uint datsiz(dattyp typ, void *val)
34 {
35 switch(typ)
36 {
37 case DAT_NUMBER:
38 return(4); /* numbers are in 4-byte lsb-first format */
39
40 case DAT_OBJECT:
41 return(2); /* object numbers are in 2-byte lsb-first format */
42
43 case DAT_SSTRING:
44 case DAT_DSTRING:
45 case DAT_LIST:
46 return(osrp2((char *)val));
47
48 case DAT_NIL:
49 case DAT_TRUE:
50 return(0);
51
52 case DAT_PROPNUM:
53 case DAT_SYN:
54 case DAT_FNADDR:
55 case DAT_REDIR:
56 return(2);
57
58 case DAT_TPL:
59 /* template is counted array of 10-byte entries, plus length byte */
60 return(1 + ((*(uchar *)val) * VOCTPLSIZ));
61
62 case DAT_TPL2:
63 return(1 + ((*(uchar *)val) * VOCTPL2SIZ));
64
65 default:
66 return(0);
67 }
68 }