~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/cmd/8a/a.h

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-04-20 17:36:48 UTC
  • Revision ID: james.westby@ubuntu.com-20110420173648-ifergoxyrm832trd
Tags: upstream-2011.03.07.1
Import upstream version 2011.03.07.1

Show diffs side-by-side

added added

removed removed

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