Git init
[external/mawk.git] / types.h
1
2 /********************************************
3 types.h
4 copyright 1991, Michael D. Brennan
5
6 This is a source file for mawk, an implementation of
7 the AWK programming language.
8
9 Mawk is distributed without warranty under the terms of
10 the GNU General Public License, version 2, 1991.
11 ********************************************/
12
13
14 /* $Log: types.h,v $
15  * Revision 1.3  1993/07/15  23:56:18  mike
16  * general cleanup
17  *
18  * Revision 1.2  1993/07/04  12:52:15  mike
19  * start on autoconfig changes
20  *
21  * Revision 5.1  1991/12/05  07:59:39  brennan
22  * 1.1 pre-release
23  *
24 */
25
26
27 /*  types.h  */
28
29 #ifndef  MAWK_TYPES_H
30 #define  MAWK_TYPES_H
31
32 #include  "sizes.h"
33
34
35 /*  CELL  types  */
36
37 #define  C_NOINIT                0
38 #define  C_DOUBLE                1
39 #define  C_STRING                2
40 #define  C_STRNUM                3
41 #define  C_MBSTRN                4 
42         /*could be STRNUM, has not been checked */
43 #define  C_RE                    5
44 #define  C_SPACE                 6
45         /* split on space */
46 #define  C_SNULL                 7
47         /* split on the empty string  */
48 #define  C_REPL                  8
49         /* a replacement string   '\&' changed to &  */
50 #define  C_REPLV                 9
51         /* a vector replacement -- broken on &  */
52 #define  NUM_CELL_TYPES         10
53
54 /* these defines are used to check types for two
55    CELLs which are adjacent in memory */
56
57 #define  TWO_NOINITS  (2*(1<<C_NOINIT))
58 #define  TWO_DOUBLES  (2*(1<<C_DOUBLE))
59 #define  TWO_STRINGS  (2*(1<<C_STRING))
60 #define  TWO_STRNUMS  (2*(1<<C_STRNUM))
61 #define  TWO_MBSTRNS  (2*(1<<C_MBSTRN))
62 #define  NOINIT_AND_DOUBLE  ((1<<C_NOINIT)+(1<<C_DOUBLE))
63 #define  NOINIT_AND_STRING  ((1<<C_NOINIT)+(1<<C_STRING))
64 #define  NOINIT_AND_STRNUM  ((1<<C_NOINIT)+(1<<C_STRNUM))
65 #define  DOUBLE_AND_STRING  ((1<<C_DOUBLE)+(1<<C_STRING))
66 #define  DOUBLE_AND_STRNUM  ((1<<C_STRNUM)+(1<<C_DOUBLE))
67 #define  STRING_AND_STRNUM  ((1<<C_STRING)+(1<<C_STRNUM))
68 #define  NOINIT_AND_MBSTRN  ((1<<C_NOINIT)+(1<<C_MBSTRN))
69 #define  DOUBLE_AND_MBSTRN  ((1<<C_DOUBLE)+(1<<C_MBSTRN))
70 #define  STRING_AND_MBSTRN  ((1<<C_STRING)+(1<<C_MBSTRN))
71 #define  STRNUM_AND_MBSTRN  ((1<<C_STRNUM)+(1<<C_MBSTRN))
72
73 typedef  struct {
74 unsigned len ;
75 unsigned short ref_cnt ;
76 char str[2] ;
77 } STRING ;
78
79 /* number of bytes more than the characters to store a
80    string */
81 #define  STRING_OH   (sizeof(STRING)-1)
82
83
84 typedef  struct cell {
85 short type ;
86 short vcnt ; /* only used if type == C_REPLV   */
87 PTR   ptr ;
88 double  dval ;
89 }  CELL ;
90
91
92 /* all builtins are passed the evaluation stack pointer and
93    return its new value, here is the type */
94
95 #ifndef  NO_PROTOS
96 typedef CELL *(*PF_CP)(CELL *) ;
97 #else
98 typedef CELL *(*PF_CP)() ;
99 #endif
100
101 /* an element of code (instruction) */
102 typedef  union {
103 int  op ;
104 PTR  ptr ;
105 }  INST ;
106
107 #endif  /* MAWK_TYPES_H */