|
| 1 | +// Inferno utils/6a/a.h |
| 2 | +// http://code.google.com/p/inferno-os/source/browse/utils/6a/a.h |
| 3 | +// |
| 4 | +// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
| 5 | +// Portions Copyright © 1995-1997 C H Forsyth ([email protected]) |
| 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 ([email protected]) |
| 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 <u.h> |
| 32 | +#include <libc.h> |
| 33 | +#include <bio.h> |
| 34 | +#include "../6l/6.out.h" |
| 35 | +#include "compat.h" |
| 36 | + |
| 37 | + |
| 38 | +#ifndef EXTERN |
| 39 | +#define EXTERN extern |
| 40 | +#endif |
| 41 | + |
| 42 | +typedef struct Sym Sym; |
| 43 | +typedef struct Ref Ref; |
| 44 | +typedef struct Gen Gen; |
| 45 | +typedef struct Io Io; |
| 46 | +typedef struct Hist Hist; |
| 47 | +typedef struct Gen2 Gen2; |
| 48 | + |
| 49 | +#define MAXALIGN 7 |
| 50 | +#define FPCHIP 1 |
| 51 | +#define NSYMB 500 |
| 52 | +#define BUFSIZ 8192 |
| 53 | +#define HISTSZ 20 |
| 54 | +#define NINCLUDE 10 |
| 55 | +#define NHUNK 10000 |
| 56 | +#define EOF (-1) |
| 57 | +#define IGN (-2) |
| 58 | +#define GETC() ((--fi.c < 0)? filbuf(): *fi.p++ & 0xff) |
| 59 | +#define NHASH 503 |
| 60 | +#define STRINGSZ 200 |
| 61 | +#define NMACRO 10 |
| 62 | + |
| 63 | +struct Sym |
| 64 | +{ |
| 65 | + Sym* link; |
| 66 | + Ref* ref; |
| 67 | + char* macro; |
| 68 | + vlong value; |
| 69 | + ushort type; |
| 70 | + char *name; |
| 71 | + char sym; |
| 72 | +}; |
| 73 | +#define S ((Sym*)0) |
| 74 | + |
| 75 | +struct Ref |
| 76 | +{ |
| 77 | + int class; |
| 78 | +}; |
| 79 | + |
| 80 | +EXTERN struct |
| 81 | +{ |
| 82 | + char* p; |
| 83 | + int c; |
| 84 | +} fi; |
| 85 | + |
| 86 | +struct Io |
| 87 | +{ |
| 88 | + Io* link; |
| 89 | + char b[BUFSIZ]; |
| 90 | + char* p; |
| 91 | + short c; |
| 92 | + short f; |
| 93 | +}; |
| 94 | +#define I ((Io*)0) |
| 95 | + |
| 96 | +EXTERN struct |
| 97 | +{ |
| 98 | + Sym* sym; |
| 99 | + short type; |
| 100 | +} h[NSYM]; |
| 101 | + |
| 102 | +struct Gen |
| 103 | +{ |
| 104 | + double dval; |
| 105 | + char sval[8]; |
| 106 | + vlong offset; |
| 107 | + Sym* sym; |
| 108 | + short type; |
| 109 | + short index; |
| 110 | + short scale; |
| 111 | +}; |
| 112 | +struct Gen2 |
| 113 | +{ |
| 114 | + Gen from; |
| 115 | + Gen to; |
| 116 | +}; |
| 117 | + |
| 118 | +struct Hist |
| 119 | +{ |
| 120 | + Hist* link; |
| 121 | + char* name; |
| 122 | + long line; |
| 123 | + vlong offset; |
| 124 | +}; |
| 125 | +#define H ((Hist*)0) |
| 126 | + |
| 127 | +enum |
| 128 | +{ |
| 129 | + CLAST, |
| 130 | + CMACARG, |
| 131 | + CMACRO, |
| 132 | + CPREPROC, |
| 133 | +}; |
| 134 | + |
| 135 | + |
| 136 | +EXTERN char debug[256]; |
| 137 | +EXTERN Sym* hash[NHASH]; |
| 138 | +EXTERN char* Dlist[30]; |
| 139 | +EXTERN int nDlist; |
| 140 | +EXTERN Hist* ehist; |
| 141 | +EXTERN int newflag; |
| 142 | +EXTERN Hist* hist; |
| 143 | +EXTERN char* hunk; |
| 144 | +EXTERN char* include[NINCLUDE]; |
| 145 | +EXTERN Io* iofree; |
| 146 | +EXTERN Io* ionext; |
| 147 | +EXTERN Io* iostack; |
| 148 | +EXTERN long lineno; |
| 149 | +EXTERN int nerrors; |
| 150 | +EXTERN long nhunk; |
| 151 | +EXTERN int ninclude; |
| 152 | +EXTERN Gen nullgen; |
| 153 | +EXTERN char* outfile; |
| 154 | +EXTERN int pass; |
| 155 | +EXTERN char* pathname; |
| 156 | +EXTERN long pc; |
| 157 | +EXTERN int peekc; |
| 158 | +EXTERN int sym; |
| 159 | +EXTERN char symb[NSYMB]; |
| 160 | +EXTERN int thechar; |
| 161 | +EXTERN char* thestring; |
| 162 | +EXTERN long thunk; |
| 163 | +EXTERN Biobuf obuf; |
| 164 | + |
| 165 | +void* allocn(void*, long, long); |
| 166 | +void errorexit(void); |
| 167 | +void pushio(void); |
| 168 | +void newio(void); |
| 169 | +void newfile(char*, int); |
| 170 | +Sym* slookup(char*); |
| 171 | +Sym* lookup(void); |
| 172 | +void syminit(Sym*); |
| 173 | +long yylex(void); |
| 174 | +int getc(void); |
| 175 | +int getnsc(void); |
| 176 | +void unget(int); |
| 177 | +int escchar(int); |
| 178 | +void cinit(void); |
| 179 | +void checkscale(int); |
| 180 | +void pinit(char*); |
| 181 | +void cclean(void); |
| 182 | +int isreg(Gen*); |
| 183 | +void outcode(int, Gen2*); |
| 184 | +void outhist(void); |
| 185 | +void zaddr(Gen*, int); |
| 186 | +void zname(char*, int, int); |
| 187 | +void ieeedtod(Ieee*, double); |
| 188 | +int filbuf(void); |
| 189 | +Sym* getsym(void); |
| 190 | +void domacro(void); |
| 191 | +void macund(void); |
| 192 | +void macdef(void); |
| 193 | +void macexpand(Sym*, char*); |
| 194 | +void macinc(void); |
| 195 | +void macprag(void); |
| 196 | +void maclin(void); |
| 197 | +void macif(int); |
| 198 | +void macend(void); |
| 199 | +void dodefine(char*); |
| 200 | +void prfile(long); |
| 201 | +void linehist(char*, int); |
| 202 | +void gethunk(void); |
| 203 | +void yyerror(char*, ...); |
| 204 | +int yyparse(void); |
| 205 | +void setinclude(char*); |
| 206 | +int assemble(char*); |
0 commit comments