1 /****************************************************************************** 2 Copyright (c) 1992, 1995, 1996 Xerox Corporation. All rights reserved. 3 Portions of this code were written by Stephen White, aka ghond. 4 Use and copying of this software and preparation of derivative works based 5 upon this software are permitted. Any distribution of this software or 6 derivative works must comply with all applicable United States export 7 control laws. This software is made available AS IS, and Xerox Corporation 8 makes no warranty about the software, its performance or its conformity to 9 any specification. Any person obtaining a copy of this software is requested 10 to send their name and post office or electronic mail address to: 11 Pavel Curtis 12 Xerox PARC 13 3333 Coyote Hill Rd. 14 Palo Alto, CA 94304 15 Pavel@Xerox.Com 16 *****************************************************************************/ 17 18 #ifndef Structures_h 19 #define Structures_h 1 20 21 #include "my-stdio.h" 22 23 #include "config.h" 24 25 typedef int32 Objid; 26 27 /* 28 * Special Objid's 29 */ 30 #define SYSTEM_OBJECT 0 31 #define NOTHING -1 32 #define AMBIGUOUS -2 33 #define FAILED_MATCH -3 34 35 /* Do not reorder or otherwise modify this list, except to add new elements at 36 * the end, since the order here defines the numeric equivalents of the error 37 * values, and those equivalents are both DB-accessible knowledge and stored in 38 * raw form in the DB. 39 */ 40 enum error { 41 E_NONE, E_TYPE, E_DIV, E_PERM, E_PROPNF, E_VERBNF, E_VARNF, E_INVIND, 42 E_RECMOVE, E_MAXREC, E_RANGE, E_ARGS, E_NACC, E_INVARG, E_QUOTA, E_FLOAT 43 }; 44 45 /* Do not reorder or otherwise modify this list, except to add new elements at 46 * the end, since the order here defines the numeric equivalents of the type 47 * values, and those equivalents are both DB-accessible knowledge and stored in 48 * raw form in the DB. 49 */ 50 typedef enum { 51 TYPE_INT, TYPE_OBJ, _TYPE_STR, TYPE_ERR, _TYPE_LIST, /* user-visible */ 52 TYPE_CLEAR, /* in clear properties' value slot */ 53 TYPE_NONE, /* in uninitialized MOO variables */ 54 TYPE_CATCH, /* on-stack marker for an exception handler */ 55 TYPE_FINALLY, /* on-stack marker for a TRY-FINALLY clause */ 56 _TYPE_FLOAT /* floating-point number; user-visible */ 57 } var_type; 58 59 /* Types which have external data should be marked with the TYPE_COMPLEX_FLAG 60 * so that free_var/var_ref/var_dup can recognize them easily. This flag is 61 * only set in memory. The original _TYPE values are used in the database 62 * file and returned to verbs calling typeof(). This allows the inlines to 63 * be extremely cheap (both in space and time) for simple types like oids 64 * and ints. 65 */ 66 #define TYPE_DB_MASK 0x7f 67 #define TYPE_COMPLEX_FLAG 0x80 68 69 #define TYPE_STR (_TYPE_STR | TYPE_COMPLEX_FLAG) 70 #define TYPE_FLOAT (_TYPE_FLOAT | TYPE_COMPLEX_FLAG) 71 #define TYPE_LIST (_TYPE_LIST | TYPE_COMPLEX_FLAG) 72 73 #define TYPE_ANY ((var_type) -1) /* wildcard for use in declaring built-ins */ 74 #define TYPE_NUMERIC ((var_type) -2) /* wildcard for (integer or float) */ 75 76 typedef struct Var Var; 77 78 /* Experimental. On the Alpha, DEC cc allows us to specify certain 79 * pointers to be 32 bits, but only if we compile and link with "-taso 80 * -xtaso" in CFLAGS, which limits us to a 31-bit address space. This 81 * could be a win if your server is thrashing. Running JHM's db, SIZE 82 * went from 50M to 42M. No doubt these pragmas could be applied 83 * elsewhere as well, but I know this at least manages to load and run 84 * a non-trivial db. 85 */ 86 87 /* #define SHORT_ALPHA_VAR_POINTERS 1 */ 88 89 #ifdef SHORT_ALPHA_VAR_POINTERS 90 #pragma pointer_size save 91 #pragma pointer_size short 92 #endif 93 94 struct Var { 95 union { 96 const char *str; /* STR */ 97 int32 num; /* NUM, CATCH, FINALLY */ 98 Objid obj; /* OBJ */ 99 enum error err; /* ERR */ 100 Var *list; /* LIST */ 101 double *fnum; /* FLOAT */ 102 } v; 103 var_type type; 104 }; 105 106 #ifdef SHORT_ALPHA_VAR_POINTERS 107 #pragma pointer_size restore 108 #endif 109 110 extern Var zero; /* useful constant */ 111 112 #endif /* !Structures_h */ 113 114 /* 115 * $Log: structures.h,v $ 116 * Revision 1.4 1998/12/14 13:19:04 nop 117 * Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims 118 * 119 * Revision 1.3 1997/07/07 03:24:55 nop 120 * Merge UNSAFE_OPTS (r5) after extensive testing. 121 * 122 * Revision 1.2.2.2 1997/05/23 07:01:30 nop 123 * Added experimental support for 32-bit pointer model on Alpha with DEC cc. 124 * 125 * Revision 1.2.2.1 1997/03/20 18:07:52 bjj 126 * Add a flag to the in-memory type identifier so that inlines can cheaply 127 * identify Vars that need actual work done to ref/free/dup them. Add the 128 * appropriate inlines to utils.h and replace old functions in utils.c with 129 * complex_* functions which only handle the types with external storage. 130 * 131 * Revision 1.2 1997/03/03 04:19:29 nop 132 * GNU Indent normalization 133 * 134 * Revision 1.1.1.1 1997/03/03 03:45:04 nop 135 * LambdaMOO 1.8.0p5 136 * 137 * Revision 2.1 1996/02/08 06:12:21 pavel 138 * Added E_FLOAT, TYPE_FLOAT, and TYPE_NUMERIC. Renamed TYPE_NUM to TYPE_INT. 139 * Updated copyright notice for 1996. Release 1.8.0beta1. 140 * 141 * Revision 2.0 1995/11/30 04:55:46 pavel 142 * New baseline version, corresponding to release 1.8.0alpha1. 143 * 144 * Revision 1.12 1992/10/23 23:03:47 pavel 145 * Added copyright notice. 146 * 147 * Revision 1.11 1992/10/21 03:02:35 pavel 148 * Converted to use new automatic configuration system. 149 * 150 * Revision 1.10 1992/09/14 17:40:51 pjames 151 * Moved db_modification code to db modules. 152 * 153 * Revision 1.9 1992/09/04 01:17:29 pavel 154 * Added support for the `f' (for `fertile') bit on objects. 155 * 156 * Revision 1.8 1992/09/03 16:25:12 pjames 157 * Added TYPE_CLEAR for Var. 158 * Changed Property definition lists to be arrays instead of linked lists. 159 * 160 * Revision 1.7 1992/08/31 22:25:04 pjames 161 * Changed some `char *'s to `const char *' 162 * 163 * Revision 1.6 1992/08/14 00:00:36 pavel 164 * Converted to a typedef of `var_type' = `enum var_type'. 165 * 166 * Revision 1.5 1992/08/10 16:52:00 pjames 167 * Moved several types/procedure declarations to storage.h 168 * 169 * Revision 1.4 1992/07/30 21:24:31 pjames 170 * Added M_COND_ARM_STACK and M_STMT_STACK for vector.c 171 * 172 * Revision 1.3 1992/07/28 17:18:48 pjames 173 * Added M_COND_ARM_STACK for unparse.c 174 * 175 * Revision 1.2 1992/07/27 18:21:34 pjames 176 * Changed name of ct_env to var_names, const_env to literals and 177 * f_vectors to fork_vectors, removed M_CT_ENV, M_LOCAL_ENV, and 178 * M_LABEL_MAPS, changed M_CONST_ENV to M_LITERALS, M_IM_STACK to 179 * M_EXPR_STACK, M_F_VECTORS to M_FORK_VECTORS, M_ID_LIST to M_VL_LIST 180 * and M_ID_VALUE to M_VL_VALUE. 181 * 182 * Revision 1.1 1992/07/20 23:23:12 pavel 183 * Initial RCS-controlled version. 184 */ 185