* AT&T Research, Florham Park NJ *
**********************************************************/
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "code.h"
static int Cstringoffset;
-void Cinit(void)
-{
+void Cinit (void) {
Code_t c;
- cbufp = Marrayalloc((long) CBUFINCR * CBUFSIZE);
+ cbufp = Marrayalloc ((long) CBUFINCR * CBUFSIZE);
cbufn = CBUFINCR;
cbufi = 0;
Cstringoffset = (char *) &c.u.s[0] - (char *) &c + 1;
/* the + 1 above accounts for the null character */
}
-void Cterm(void)
-{
- Marrayfree(cbufp);
+void Cterm (void) {
+ Marrayfree (cbufp);
cbufp = NULL;
cbufn = cbufi = 0;
}
-void Creset(void)
-{
+void Creset (void) {
cbufi = 0;
}
-int Cnew(Ctype_t ctype)
-{
+int Cnew (int ctype) {
int i;
if (cbufi >= cbufn) {
- cbufp = Marraygrow(cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
- cbufn += CBUFINCR;
+ cbufp = Marraygrow (cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
+ cbufn += CBUFINCR;
}
i = cbufi++;
cbufp[i].ctype = ctype;
return i;
}
-int Cinteger(long i)
-{
+int Cinteger (long i) {
int j;
if (cbufi >= cbufn) {
- cbufp = Marraygrow(cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
- cbufn += CBUFINCR;
+ cbufp = Marraygrow (cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
+ cbufn += CBUFINCR;
}
j = cbufi++;
cbufp[j].ctype = C_INTEGER;
return j;
}
-int Creal(double d)
-{
+int Creal (double d) {
int i;
if (cbufi >= cbufn) {
- cbufp = Marraygrow(cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
- cbufn += CBUFINCR;
+ cbufp = Marraygrow (cbufp, (long) (cbufn + CBUFINCR) * CBUFSIZE);
+ cbufn += CBUFINCR;
}
i = cbufi++;
cbufp[i].ctype = C_REAL;
return i;
}
-int Cstring(char *s)
-{
+int Cstring (char *s) {
int i, size, incr;
- size = (strlen(s) + Cstringoffset + CBUFSIZE - 1) / CBUFSIZE;
+ size = (strlen (s) + Cstringoffset + CBUFSIZE - 1) / CBUFSIZE;
if (cbufi + size > cbufn) {
- incr = size > CBUFINCR ? size : CBUFINCR;
- cbufp = Marraygrow(cbufp, (long) (cbufn + incr) * CBUFSIZE);
- cbufn += incr;
+ incr = size > CBUFINCR ? size : CBUFINCR;
+ cbufp = Marraygrow (cbufp, (long) (cbufn + incr) * CBUFSIZE);
+ cbufn += incr;
}
i = cbufi, cbufi += size;
cbufp[i].ctype = C_STRING;
- strcpy((char *) &cbufp[i].u.s[0], s);
+ strcpy ((char *) &cbufp[i].u.s[0], s);
cbufp[i].next = C_NULL;
return i;
}
extern "C" {
#endif
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#ifndef _CODE_H
#define _CODE_H
#define C_ISSTMT(ct) (ct >= C_STMT && ct <= C_RETURN)
- typedef enum {
- C_CODE, C_ASSIGN, C_INTEGER, C_REAL, C_STRING, C_OR, C_AND,
- C_EQ, C_NE, C_LT, C_LE, C_GT, C_GE, C_PLUS, C_MINUS, C_MUL,
- C_DIV, C_MOD, C_UMINUS, C_NOT, C_PEXPR, C_FCALL, C_GVAR, C_LVAR,
- C_PVAR, C_FUNCTION, C_TCONS, C_DECL, C_STMT, C_IF, C_WHILE,
- C_FOR, C_FORIN, C_BREAK, C_CONTINUE, C_RETURN, C_INTERNAL,
- C_ARGS, C_NOP, C_SIZE
- } Ctype_t;
+#define C_CODE 0
+#define C_ASSIGN 1
+#define C_INTEGER 2
+#define C_REAL 3
+#define C_STRING 4
+#define C_OR 5
+#define C_AND 6
+#define C_EQ 7
+#define C_NE 8
+#define C_LT 9
+#define C_LE 10
+#define C_GT 11
+#define C_GE 12
+#define C_PLUS 13
+#define C_MINUS 14
+#define C_MUL 15
+#define C_DIV 16
+#define C_MOD 17
+#define C_UMINUS 18
+#define C_NOT 19
+#define C_PEXPR 20
+#define C_FCALL 21
+#define C_GVAR 22
+#define C_LVAR 23
+#define C_PVAR 24
+#define C_FUNCTION 25
+#define C_TCONS 26
+#define C_DECL 27
+#define C_STMT 28
+#define C_IF 29
+#define C_WHILE 30
+#define C_FOR 31
+#define C_FORIN 32
+#define C_BREAK 33
+#define C_CONTINUE 34
+#define C_RETURN 35
+#define C_INTERNAL 36
+#define C_ARGS 37
+#define C_NOP 38
+#define C_SIZE 39
- typedef struct Code_t {
- Ctype_t ctype;
- int next;
- union {
- char s[1];
- double d;
- long i;
- int fp;
- void *o;
- } u;
- } Code_t;
+typedef struct Code_t {
+ int ctype;
+ int next;
+ union {
+ char s[1];
+ double d;
+ long i;
+ int fp;
+ void *o;
+ } u;
+} Code_t;
#define C_CODESIZE sizeof (Code_t)
#define Cgetstring(i) (char *) &cbufp[i].u.s[0]
#define Csetobject(a, b) cbufp[a].u.o = b
#define Csetreal(a, b) cbufp[a].u.d = b
- extern Code_t *cbufp;
- extern int cbufn, cbufi;
+extern Code_t *cbufp;
+extern int cbufn, cbufi;
- void Cinit(void);
- void Cterm(void);
- void Creset(void);
- int Cnew(Ctype_t);
- int Cinteger(long);
- int Creal(double);
- int Cstring(char *);
-#endif /* _CODE_H */
+void Cinit (void);
+void Cterm (void);
+void Creset (void);
+int Cnew (int);
+int Cinteger (long);
+int Creal (double);
+int Cstring (char *);
+#endif /* _CODE_H */
#ifdef __cplusplus
}
#endif
+
{"yellow3",205,205,0},
{"yellow4",139,139,0},
{"yellowgreen",154,205,50},
+{"pastelblue",153,153,255},
};