Annotation of OpenXM/src/k097/d.h, Revision 1.5
1.5 ! takayama 1: /* $OpenXM: OpenXM/src/k097/d.h,v 1.4 2005/06/09 04:47:16 takayama Exp $ */
1.1 maekawa 2: /* d.h;*/
3: /* from stackm.h */
4:
5: /**** data types (class identifiers) ************/
6: #define Snull 0
7: #define Sinteger 1 /* integer */
8: #define Sstring 2 /* pointer to a string */
9: #define SexecutableArray 3 /* executable array */
10: #define Soperator 4 /* operators defined in the system dic */
11: #define Sdollar 5 /* pointer to a string obtained from $...$ */
12: #define Sarray 6 /* lc.ival is the size of array,
13: (rc.op)[0], ..., (rc.op)[k] is the array
14: of object */
15: #define SleftBraceTag 7 /* [ */
16: #define SrightBraceTag 8 /* ] */
17: #define Spoly 9
18: #define SarrayOfPOLY 10
19: #define SmatrixOfPOLY 11
20: #define Slist 12 /* list of object */
21: #define Sfile 13
22: #define Sring 14
23: #define SuniversalNumber 15
24: #define SrationalFunction 16
25: #define Sclass 17 /* class, for extension */
26: #define Sdouble 18
27:
28: #define TYPES 19 /* number of data types. */
29: /* NOTE! If you change the above, you need to change mklookup.c too. */
30: /* Change also dr.sm1 : datatype constants. */
31:
32: /* The following tags are not in stackm.h, but we use them. */
33: #define CLASSNAME_CONTEXT 258
34:
35:
36: /*********** fundamental data types ****************/
37: union cell {
38: int ival;
39: char *str;
40: struct Object *op;
41: FILE *file;
42: struct stringBuf *sbuf;
43: void *voidp;
44: };
45:
46: struct Object{
47: int tag; /* class identifier */
48: union cell lc; /* left cell */
49: union cell rc; /* right cell */
1.4 takayama 50: struct object *attr;
1.1 maekawa 51: };
52:
53: struct object{ /* must be compatible with stackm.h */
54: int tag; /* class identifier */
55: union cell lc; /* left cell */
56: union cell rc; /* right cell */
1.4 takayama 57: struct object *attr;
1.1 maekawa 58: };
1.5 ! takayama 59:
! 60: #define OINIT { .attr = NULL }
1.1 maekawa 61:
62: typedef struct Object * objectp; /* cf. 65p of Schreiner. */
63: #define YYSTYPE objectp
64:
65:
66: struct stringBuf {
67: char *str;
68: int limit;
69: int ptr;
70: };
71:
72: struct object Sm1obj;
73:
74: /* for dic.c */
75: struct dictionary {
76: char *key;
77: int h0; /* Value of hash functions */
78: int h1;
79: objectp obj;
80: int attr;
81: };
82: struct operandStack {
83: objectp *ostack;
84: int sp;
85: int size;
86: };
87: struct context {
88: struct dictionary *userDictionary;
89: struct context *super;
90: char *contextName;
91: struct operandStack *mystack; /* It is not used for now. */
92: };
93: #define USER_DICTIONARY_SIZE 1223
94: /* The value of USER_DICTIONARY_SIZE must be prime number, because of hashing
95: method */
96: #define EMPTY (char *)NULL
97: #define SET_ATTR_FOR_ALL_WORDS 0x10
98: #define PROTECT 0x1
99: #define ABSOLUTE_PROTECT 0x2
100: typedef enum {CCPUSH,CCPOP,CCRESTORE} actionOfContextControl;
101: #define CSTACK_SIZE 1000
102: typedef enum {IRESET,IPUT,IEXIT} actionOfPutIncetanceVariable;
103:
104: /* ki.c or dm.c */
105: void pkkan(char *s);
106: void pkkanInteger(int k);
107: void pkdebug(char *s0,char *s1,char *s2,char *s3);
108: void pkdebug2(void);
109: char *readstring();
110: char *newString(int size);
111:
112: /* object handling */
113: objectp newObject_d();
114: void printObject_d(FILE *fp,objectp op);
115: void printObjectSymbol(objectp op);
116: char *objectSymbolToString(objectp op);
117: int K00objectToInteger(objectp op);
118: objectp K00integerToObject(int k);
119: objectp K00contextToObject(struct context *cp);
120: struct context *K00objectToContext(objectp op);
121: objectp ooAdd(objectp a,objectp b);
122: objectp ooMult(objectp a,objectp b);
123:
124: /* memory */
125: void *mymalloc(int size);
126:
127: /* protection of symbols */
128: int isProtectedSymbol(char *s);
129: int ips(objectp op);
130: /* read from file */
131: void parseAFile(FILE *fp);
132: void parseAstring(char *s);
133: int fsgetc(objectp op);
134: int fsungetc(int c,objectp op);
135: void readLineFromFile(FILE *fp,struct stringBuf *obuf);
136: struct stringBuf *newStringBuf(char *initstr);
137: void doublingStringBuf(struct stringBuf *sbuf);
1.3 takayama 138: objectp checkIfTheFileExists(objectp name);
1.1 maekawa 139: void loadFile(objectp op);
140: void loadFileWithCpp(objectp op);
141: void showStringBuff(objectp op);
142: char *getLOAD_K_PATH();
143: void clearInop();
144:
145: struct object KSpop();
146: void testNewFunction(objectp op);
147:
148: /* Dictionary and context handling. dic.c */
149: int K00putUserDictionary(char *str,int h0,int h1,objectp ob,
150: struct context *cp);
151: int K00putUserDictionary2(char *str,int h0,int h1, int attr,
152: struct context *cp);
153: objectp K00findUserDictionary(char *str,int h0,int h1,struct context *cp);
154: objectp K00findUserDictionary0(char *str,int h0,int h1,struct context *cp);
155: int K00hash0(char *str);
156: int K00hash1(char *str);
157: void K00hashInitialize(struct dictionary *dic);
158: void K00fprintContext(FILE *fp,struct context *cp);
159: void K00fprintContextAndDictionary(FILE *fp,struct context *cp);
160: struct context *K00newContext0(struct context *super,char *name);
161: void K00contextControl(actionOfContextControl ctl);
162: char *K00getCurrentContextName();
163: void K00InitDic();
164: void K00errorDic(char *s);
165:
166: /* name space control */
167: int K00putIncetanceVariable(actionOfPutIncetanceVariable action,char *s);
168: int K00getIncetanceVariable(char *s);
169: void K00recoverFromError();
170: int K00declareClass(char *name,char *supername);
171: void K00toPrimitiveClass();
172:
173:
174:
175:
176:
177:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>