github.com/ccccaoqing/test@v0.0.0-20220510085219-3985d23445c0/src/cmd/8a/a.h (about) 1 // Inferno utils/8a/a.h 2 // http://code.google.com/p/inferno-os/source/browse/utils/8a/a.h 3 // 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 6 // Portions Copyright © 1997-1999 Vita Nuova Limited 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 8 // Portions Copyright © 2004,2006 Bruce Ellis 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others 11 // Portions Copyright © 2009 The Go Authors. All rights reserved. 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a copy 14 // of this software and associated documentation files (the "Software"), to deal 15 // in the Software without restriction, including without limitation the rights 16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 // copies of the Software, and to permit persons to whom the Software is 18 // furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included in 21 // all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 // THE SOFTWARE. 30 31 #include <bio.h> 32 #include <link.h> 33 #include "../8l/8.out.h" 34 35 #ifndef EXTERN 36 #define EXTERN extern 37 #endif 38 39 #undef getc 40 #undef ungetc 41 #undef BUFSIZ 42 43 #define getc ccgetc 44 #define ungetc ccungetc 45 46 typedef struct Sym Sym; 47 typedef struct Ref Ref; 48 typedef struct Io Io; 49 typedef struct Addr2 Addr2; 50 51 #define MAXALIGN 7 52 #define FPCHIP 1 53 #define NSYMB 500 54 #define BUFSIZ 8192 55 #define HISTSZ 20 56 #ifndef EOF 57 #define EOF (-1) 58 #endif 59 #define IGN (-2) 60 #define GETC() ((--fi.c < 0)? filbuf(): *fi.p++ & 0xff) 61 #define NHASH 503 62 #define STRINGSZ 200 63 #define NMACRO 10 64 65 struct Sym 66 { 67 Sym* link; 68 Ref* ref; 69 char* macro; 70 int32 value; 71 ushort type; 72 char *name; 73 char sym; 74 }; 75 #define S ((Sym*)0) 76 77 struct Ref 78 { 79 int class; 80 }; 81 82 EXTERN struct 83 { 84 char* p; 85 int c; 86 } fi; 87 88 struct Io 89 { 90 Io* link; 91 char b[BUFSIZ]; 92 char* p; 93 short c; 94 short f; 95 }; 96 #define I ((Io*)0) 97 98 struct Addr2 99 { 100 Addr from; 101 Addr to; 102 }; 103 104 enum 105 { 106 CLAST, 107 CMACARG, 108 CMACRO, 109 CPREPROC, 110 }; 111 112 EXTERN int debug[256]; 113 EXTERN Sym* hash[NHASH]; 114 EXTERN char** Dlist; 115 EXTERN int nDlist; 116 EXTERN int newflag; 117 EXTERN char* hunk; 118 EXTERN char** include; 119 EXTERN Io* iofree; 120 EXTERN Io* ionext; 121 EXTERN Io* iostack; 122 EXTERN int32 lineno; 123 EXTERN int nerrors; 124 EXTERN int32 nhunk; 125 EXTERN int ninclude; 126 EXTERN int32 nsymb; 127 EXTERN Addr nullgen; 128 EXTERN char* outfile; 129 EXTERN int pass; 130 EXTERN int32 pc; 131 EXTERN int peekc; 132 EXTERN int32 stmtline; 133 EXTERN int sym; 134 EXTERN char* symb; 135 EXTERN int thechar; 136 EXTERN char* thestring; 137 EXTERN int32 thunk; 138 EXTERN Biobuf obuf; 139 EXTERN Link* ctxt; 140 EXTERN Biobuf bstdout; 141 142 void* alloc(int32); 143 void* allocn(void*, int32, int32); 144 void ensuresymb(int32); 145 void errorexit(void); 146 void pushio(void); 147 void newio(void); 148 void newfile(char*, int); 149 Sym* slookup(char*); 150 Sym* lookup(void); 151 void syminit(Sym*); 152 int32 yylex(void); 153 int getc(void); 154 int getnsc(void); 155 void unget(int); 156 int escchar(int); 157 void cinit(void); 158 void checkscale(int); 159 void pinit(char*); 160 void cclean(void); 161 int isreg(Addr*); 162 void outcode(int, Addr2*); 163 void outhist(void); 164 int filbuf(void); 165 Sym* getsym(void); 166 void domacro(void); 167 void macund(void); 168 void macdef(void); 169 void macexpand(Sym*, char*); 170 void macinc(void); 171 void macprag(void); 172 void maclin(void); 173 void macif(int); 174 void macend(void); 175 void dodefine(char*); 176 void prfile(int32); 177 void linehist(char*, int); 178 void gethunk(void); 179 void yyerror(char*, ...); 180 int yyparse(void); 181 void setinclude(char*); 182 int assemble(char*);