/
go.h
1517 lines (1358 loc) · 34.1 KB
/
go.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include <bio.h>
#undef OAPPEND
// avoid <ctype.h>
#undef isblank
#define isblank goisblank
#ifndef EXTERN
#define EXTERN extern
#endif
#undef BUFSIZ
// The parser's maximum stack size.
// We have to use a #define macro here since yacc
// or bison will check for its definition and use
// a potentially smaller value if it is undefined.
#define YYMAXDEPTH 500
enum
{
NHUNK = 50000,
BUFSIZ = 8192,
NSYMB = 500,
NHASH = 1024,
STRINGSZ = 200,
MAXALIGN = 7,
UINF = 100,
HISTSZ = 10,
PRIME1 = 3,
AUNK = 100,
// These values are known by runtime.
// The MEMx and NOEQx values must run in parallel. See algtype.
AMEM = 0,
AMEM0,
AMEM8,
AMEM16,
AMEM32,
AMEM64,
AMEM128,
ANOEQ,
ANOEQ0,
ANOEQ8,
ANOEQ16,
ANOEQ32,
ANOEQ64,
ANOEQ128,
ASTRING,
AINTER,
ANILINTER,
ASLICE,
AFLOAT32,
AFLOAT64,
ACPLX64,
ACPLX128,
BADWIDTH = -1000000000,
MaxStackVarSize = 10*1024*1024,
};
extern vlong MAXWIDTH;
/*
* note this is the representation
* of the compilers string literals,
* it is not the runtime representation
*/
typedef struct Strlit Strlit;
struct Strlit
{
int32 len;
char s[3]; // variable
};
enum
{
Mpscale = 29, // safely smaller than bits in a long
Mpprec = 16, // Mpscale*Mpprec is max number of bits
Mpnorm = Mpprec - 1, // significant words in a normalized float
Mpbase = 1L << Mpscale,
Mpsign = Mpbase >> 1,
Mpmask = Mpbase - 1,
Mpdebug = 0,
};
typedef struct Mpint Mpint;
struct Mpint
{
long a[Mpprec];
uchar neg;
uchar ovf;
};
typedef struct Mpflt Mpflt;
struct Mpflt
{
Mpint val;
short exp;
};
typedef struct Mpcplx Mpcplx;
struct Mpcplx
{
Mpflt real;
Mpflt imag;
};
typedef struct Val Val;
struct Val
{
short ctype;
union
{
short reg; // OREGISTER
short bval; // bool value CTBOOL
Mpint* xval; // int CTINT, rune CTRUNE
Mpflt* fval; // float CTFLT
Mpcplx* cval; // float CTCPLX
Strlit* sval; // string CTSTR
} u;
};
typedef struct Bvec Bvec;
typedef struct Pkg Pkg;
typedef struct Sym Sym;
typedef struct Node Node;
typedef struct NodeList NodeList;
typedef struct Type Type;
typedef struct Label Label;
struct Type
{
uchar etype;
uchar nointerface;
uchar chan;
uchar trecur; // to detect loops
uchar printed;
uchar embedded; // TFIELD embedded type
uchar siggen;
uchar funarg; // on TSTRUCT and TFIELD
uchar copyany;
uchar local; // created in this file
uchar deferwidth;
uchar broke; // broken type definition.
uchar isddd; // TFIELD is ... argument
uchar align;
Node* nod; // canonical OTYPE node
Type* orig; // original type (type literal or predefined type)
int lineno;
// TFUNC
int thistuple;
int outtuple;
int intuple;
uchar outnamed;
Type* method;
Type* xmethod;
Sym* sym;
int32 vargen; // unique name for OTYPE/ONAME
Node* nname;
vlong argwid;
// most nodes
Type* type; // actual type for TFIELD, element type for TARRAY, TCHAN, TMAP, TPTRxx
vlong width; // offset in TFIELD, width in all others
// TFIELD
Type* down; // next struct field, also key type in TMAP
Type* outer; // outer struct
Strlit* note; // literal string annotation
// TARRAY
vlong bound; // negative is dynamic array
int32 maplineno; // first use of TFORW as map key
int32 embedlineno; // first use of TFORW as embedded type
// for TFORW, where to copy the eventual value to
NodeList *copyto;
// for usefield
Node *lastfn;
};
#define T ((Type*)0)
typedef struct InitEntry InitEntry;
typedef struct InitPlan InitPlan;
struct InitEntry
{
vlong xoffset; // struct, array only
Node *key; // map only
Node *expr;
};
struct InitPlan
{
vlong lit; // bytes of initialized non-zero literals
vlong zero; // bytes of zeros
vlong expr; // bytes of run-time computed expressions
InitEntry *e;
int len;
int cap;
};
enum
{
EscUnknown,
EscHeap,
EscScope,
EscNone,
EscReturn,
EscNever,
EscBits = 4,
EscMask = (1<<EscBits) - 1,
};
struct Node
{
// Tree structure.
// Generic recursive walks should follow these fields.
Node* left;
Node* right;
Node* ntest;
Node* nincr;
NodeList* ninit;
NodeList* nbody;
NodeList* nelse;
NodeList* list;
NodeList* rlist;
uchar op;
uchar nointerface;
uchar ullman; // sethi/ullman number
uchar addable; // type of addressability - 0 is not addressable
uchar trecur; // to detect loops
uchar etype; // op for OASOP, etype for OTYPE, exclam for export
uchar bounded; // bounds check unnecessary
uchar class; // PPARAM, PAUTO, PEXTERN, etc
uchar method; // OCALLMETH name
uchar embedded; // ODCLFIELD embedded type
uchar colas; // OAS resulting from :=
uchar diag; // already printed error about this
uchar noescape; // func arguments do not escape
uchar builtin; // built-in name, like len or close
uchar walkdef;
uchar typecheck;
uchar local;
uchar dodata;
uchar initorder;
uchar used;
uchar isddd;
uchar readonly;
uchar implicit;
uchar addrtaken; // address taken, even if not moved to heap
uchar dupok; // duplicate definitions ok (for func)
schar likely; // likeliness of if statement
uchar hasbreak; // has break statement
uint esc; // EscXXX
int funcdepth;
// most nodes
Type* type;
Node* orig; // original form, for printing, and tracking copies of ONAMEs
// func
Node* nname;
Node* shortname;
NodeList* enter;
NodeList* exit;
NodeList* cvars; // closure params
NodeList* dcl; // autodcl for this func/closure
NodeList* inl; // copy of the body for use in inlining
NodeList* inldcl; // copy of dcl for use in inlining
// OLITERAL/OREGISTER
Val val;
// ONAME
Node* ntype;
Node* defn; // ONAME: initializing assignment; OLABEL: labeled statement
Node* pack; // real package for import . names
Node* curfn; // function for local variables
Type* paramfld; // TFIELD for this PPARAM; also for ODOT, curfn
// ONAME func param with PHEAP
Node* heapaddr; // temp holding heap address of param
Node* stackparam; // OPARAM node referring to stack copy of param
Node* alloc; // allocation call
// ONAME closure param with PPARAMREF
Node* outer; // outer PPARAMREF in nested closure
Node* closure; // ONAME/PHEAP <-> ONAME/PPARAMREF
// ONAME substitute while inlining
Node* inlvar;
// OPACK
Pkg* pkg;
// OARRAYLIT, OMAPLIT, OSTRUCTLIT.
InitPlan* initplan;
// Escape analysis.
NodeList* escflowsrc; // flow(this, src)
NodeList* escretval; // on OCALLxxx, list of dummy return values
int escloopdepth; // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes
Sym* sym; // various
int32 vargen; // unique name for OTYPE/ONAME
int32 lineno;
int32 endlineno;
vlong xoffset;
vlong stkdelta; // offset added by stack frame compaction phase.
int32 ostk;
int32 iota;
uint32 walkgen;
int32 esclevel;
};
#define N ((Node*)0)
/*
* Every node has a walkgen field.
* If you want to do a traversal of a node graph that
* might contain duplicates and want to avoid
* visiting the same nodes twice, increment walkgen
* before starting. Then before processing a node, do
*
* if(n->walkgen == walkgen)
* return;
* n->walkgen = walkgen;
*
* Such a walk cannot call another such walk recursively,
* because of the use of the global walkgen.
*/
EXTERN uint32 walkgen;
struct NodeList
{
Node* n;
NodeList* next;
NodeList* end;
};
enum
{
SymExport = 1<<0, // to be exported
SymPackage = 1<<1,
SymExported = 1<<2, // already written out by export
SymUniq = 1<<3,
SymSiggen = 1<<4,
SymGcgen = 1<<5,
};
struct Sym
{
ushort lexical;
uchar flags;
uchar sym; // huffman encoding in object file
Sym* link;
int32 npkg; // number of imported packages with this name
uint32 uniqgen;
// saved and restored by dcopy
Pkg* pkg;
char* name; // variable name
Node* def; // definition: ONAME OTYPE OPACK or OLITERAL
Label* label; // corresponding label (ephemeral)
int32 block; // blocknumber to catch redeclaration
int32 lastlineno; // last declaration for diagnostic
Pkg* origpkg; // original package for . import
};
#define S ((Sym*)0)
EXTERN Sym* dclstack;
struct Pkg
{
char* name; // package name
Strlit* path; // string literal used in import statement
Sym* pathsym;
char* prefix; // escaped path for use in symbol table
Pkg* link;
uchar imported; // export data of this package was parsed
char exported; // import line written in export data
char direct; // imported directly
char safe; // whether the package is marked as safe
};
typedef struct Iter Iter;
struct Iter
{
int done;
Type* tfunc;
Type* t;
Node** an;
Node* n;
};
typedef struct Hist Hist;
struct Hist
{
Hist* link;
char* name;
int32 line;
int32 offset;
};
#define H ((Hist*)0)
// Node ops.
enum
{
OXXX,
// names
ONAME, // var, const or func name
ONONAME, // unnamed arg or return value: f(int, string) (int, error) { etc }
OTYPE, // type name
OPACK, // import
OLITERAL, // literal
// expressions
OADD, // x + y
OSUB, // x - y
OOR, // x | y
OXOR, // x ^ y
OADDSTR, // s + "foo"
OADDR, // &x
OANDAND, // b0 && b1
OAPPEND, // append
OARRAYBYTESTR, // string(bytes)
OARRAYRUNESTR, // string(runes)
OSTRARRAYBYTE, // []byte(s)
OSTRARRAYRUNE, // []rune(s)
OAS, // x = y or x := y
OAS2, // x, y, z = xx, yy, zz
OAS2FUNC, // x, y = f()
OAS2RECV, // x, ok = <-c
OAS2MAPR, // x, ok = m["foo"]
OAS2DOTTYPE, // x, ok = I.(int)
OASOP, // x += y
OCALL, // function call, method call or type conversion, possibly preceded by defer or go.
OCALLFUNC, // f()
OCALLMETH, // t.Method()
OCALLINTER, // err.Error()
OCALLPART, // t.Method (without ())
OCAP, // cap
OCLOSE, // close
OCLOSURE, // f = func() { etc }
OCMPIFACE, // err1 == err2
OCMPSTR, // s1 == s2
OCOMPLIT, // composite literal, typechecking may convert to a more specific OXXXLIT.
OMAPLIT, // M{"foo":3, "bar":4}
OSTRUCTLIT, // T{x:3, y:4}
OARRAYLIT, // [2]int{3, 4}
OPTRLIT, // &T{x:3, y:4}
OCONV, // var i int; var u uint; i = int(u)
OCONVIFACE, // I(t)
OCONVNOP, // type Int int; var i int; var j Int; i = int(j)
OCOPY, // copy
ODCL, // var x int
ODCLFUNC, // func f() or func (r) f()
ODCLFIELD, // struct field, interface field, or func/method argument/return value.
ODCLCONST, // const pi = 3.14
ODCLTYPE, // type Int int
ODELETE, // delete
ODOT, // t.x
ODOTPTR, // p.x that is implicitly (*p).x
ODOTMETH, // t.Method
ODOTINTER, // err.Error
OXDOT, // t.x, typechecking may convert to a more specific ODOTXXX.
ODOTTYPE, // e = err.(MyErr)
ODOTTYPE2, // e, ok = err.(MyErr)
OEQ, // x == y
ONE, // x != y
OLT, // x < y
OLE, // x <= y
OGE, // x >= y
OGT, // x > y
OIND, // *p
OINDEX, // a[i]
OINDEXMAP, // m[s]
OKEY, // The x:3 in t{x:3, y:4}, the 1:2 in a[1:2], the 2:20 in [3]int{2:20}, etc.
OPARAM, // The on-stack copy of a parameter or return value that escapes.
OLEN, // len
OMAKE, // make, typechecking may convert to a more specfic OMAKEXXX.
OMAKECHAN, // make(chan int)
OMAKEMAP, // make(map[string]int)
OMAKESLICE, // make([]int, 0)
OMUL, // x * y
ODIV, // x / y
OMOD, // x % y
OLSH, // x << u
ORSH, // x >> u
OAND, // x & y
OANDNOT, // x &^ y
ONEW, // new
ONOT, // !b
OCOM, // ^x
OPLUS, // +x
OMINUS, // -y
OOROR, // b1 || b2
OPANIC, // panic
OPRINT, // print
OPRINTN, // println
OPAREN, // (x)
OSEND, // c <- x
OSLICE, // v[1:2], typechecking may convert to a more specfic OSLICEXXX.
OSLICEARR, // a[1:2]
OSLICESTR, // s[1:2]
OSLICE3, // v[1:2:3], typechecking may convert to OSLICE3ARR.
OSLICE3ARR, // a[1:2:3]
ORECOVER, // recover
ORECV, // <-c
ORUNESTR, // string(i)
OSELRECV, // case x = <-c:
OSELRECV2, // case x, ok = <-c:
OIOTA, // iota
OREAL, // real
OIMAG, // imag
OCOMPLEX, // complex
// statements
OBLOCK, // block of code
OBREAK, // break
OCASE, // case, after being verified by swt.c's casebody.
OXCASE, // case, before verification.
OCONTINUE, // continue
ODEFER, // defer
OEMPTY, // no-op
OFALL, // fallthrough, after being verified by swt.c's casebody.
OXFALL, // fallthrough, before verification.
OFOR, // for
OGOTO, // goto
OIF, // if
OLABEL, // label:
OPROC, // go
ORANGE, // range
ORETURN, // return
OSELECT, // select
OSWITCH, // switch x
OTYPESW, // switch err.(type)
// types
OTCHAN, // chan int
OTMAP, // map[string]int
OTSTRUCT, // struct{}
OTINTER, // interface{}
OTFUNC, // func()
OTARRAY, // []int, [8]int, [N]int or [...]int
OTPAREN, // (T)
// misc
ODDD, // func f(args ...int) or f(l...) or var a = [...]int{0, 1, 2}.
ODDDARG, // func f(args ...int), introduced by escape analysis.
OINLCALL, // intermediary representation of an inlined call.
OEFACE, // itable and data words of an empty-interface value.
OITAB, // itable word of an interface value.
OCLOSUREVAR, // variable reference at beginning of closure function
OCFUNC, // reference to c function pointer (not go func value)
OCHECKNOTNIL, // emit code to ensure pointer/interface not nil
// arch-specific registers
OREGISTER, // a register, such as AX.
OINDREG, // offset plus indirect of a register, such as 8(SP).
// 386/amd64-specific opcodes
OCMP, // compare: ACMP.
ODEC, // decrement: ADEC.
OINC, // increment: AINC.
OEXTEND, // extend: ACWD/ACDQ/ACQO.
OHMUL, // high mul: AMUL/AIMUL for unsigned/signed (OMUL uses AIMUL for both).
OLROT, // left rotate: AROL.
ORROTC, // right rotate-carry: ARCR.
ORETJMP, // return to other function
OEND,
};
enum
{
Txxx, // 0
TINT8, TUINT8, // 1
TINT16, TUINT16,
TINT32, TUINT32,
TINT64, TUINT64,
TINT, TUINT, TUINTPTR,
TCOMPLEX64, // 12
TCOMPLEX128,
TFLOAT32, // 14
TFLOAT64,
TBOOL, // 16
TPTR32, TPTR64, // 17
TFUNC, // 19
TARRAY,
T_old_DARRAY,
TSTRUCT, // 22
TCHAN,
TMAP,
TINTER, // 25
TFORW,
TFIELD,
TANY,
TSTRING,
TUNSAFEPTR,
// pseudo-types for literals
TIDEAL, // 31
TNIL,
TBLANK,
// pseudo-type for frame layout
TFUNCARGS,
TCHANARGS,
TINTERMETH,
NTYPE,
};
enum
{
CTxxx,
CTINT,
CTRUNE,
CTFLT,
CTCPLX,
CTSTR,
CTBOOL,
CTNIL,
};
enum
{
/* types of channel */
/* must match ../../pkg/nreflect/type.go:/Chandir */
Cxxx,
Crecv = 1<<0,
Csend = 1<<1,
Cboth = Crecv | Csend,
};
// declaration context
enum
{
Pxxx,
PEXTERN, // global variable
PAUTO, // local variables
PPARAM, // input arguments
PPARAMOUT, // output results
PPARAMREF, // closure variable reference
PFUNC, // global function
PDISCARD, // discard during parse of duplicate import
PHEAP = 1<<7, // an extra bit to identify an escaped variable
};
enum
{
Etop = 1<<1, // evaluated at statement level
Erv = 1<<2, // evaluated in value context
Etype = 1<<3,
Ecall = 1<<4, // call-only expressions are ok
Efnstruct = 1<<5, // multivalue function returns are ok
Eiota = 1<<6, // iota is ok
Easgn = 1<<7, // assigning to expression
Eindir = 1<<8, // indirecting through expression
Eaddr = 1<<9, // taking address of expression
Eproc = 1<<10, // inside a go statement
Ecomplit = 1<<11, // type in composite literal
};
#define BITS 5
#define NVAR (BITS*sizeof(uint32)*8)
typedef struct Bits Bits;
struct Bits
{
uint32 b[BITS];
};
EXTERN Bits zbits;
struct Bvec
{
int32 n; // number of bits
uint32 b[];
};
typedef struct Var Var;
struct Var
{
vlong offset;
Node* node;
int width;
char name;
char etype;
char addr;
};
EXTERN Var var[NVAR];
typedef struct Typedef Typedef;
struct Typedef
{
char* name;
int etype;
int sameas;
};
extern Typedef typedefs[];
typedef struct Sig Sig;
struct Sig
{
char* name;
Pkg* pkg;
Sym* isym;
Sym* tsym;
Type* type;
Type* mtype;
int32 offset;
Sig* link;
};
typedef struct Io Io;
struct Io
{
char* infile;
Biobuf* bin;
int32 ilineno;
int nlsemi;
int eofnl;
int last;
int peekc;
int peekc1; // second peekc for ...
char* cp; // used for content when bin==nil
int importsafe;
};
typedef struct Dlist Dlist;
struct Dlist
{
Type* field;
};
typedef struct Idir Idir;
struct Idir
{
Idir* link;
char* dir;
};
/*
* argument passing to/from
* smagic and umagic
*/
typedef struct Magic Magic;
struct Magic
{
int w; // input for both - width
int s; // output for both - shift
int bad; // output for both - unexpected failure
// magic multiplier for signed literal divisors
int64 sd; // input - literal divisor
int64 sm; // output - multiplier
// magic multiplier for unsigned literal divisors
uint64 ud; // input - literal divisor
uint64 um; // output - multiplier
int ua; // output - adder
};
typedef struct Prog Prog;
#pragma incomplete Prog
struct Label
{
uchar used;
Sym* sym;
Node* def;
NodeList* use;
Label* link;
// for use during gen
Prog* gotopc; // pointer to unresolved gotos
Prog* labelpc; // pointer to code
Prog* breakpc; // pointer to code
Prog* continpc; // pointer to code
};
#define L ((Label*)0)
/*
* note this is the runtime representation
* of the compilers arrays.
*
* typedef struct
* { // must not move anything
* uchar array[8]; // pointer to data
* uchar nel[4]; // number of elements
* uchar cap[4]; // allocated number of elements
* } Array;
*/
EXTERN int Array_array; // runtime offsetof(Array,array) - same for String
EXTERN int Array_nel; // runtime offsetof(Array,nel) - same for String
EXTERN int Array_cap; // runtime offsetof(Array,cap)
EXTERN int sizeof_Array; // runtime sizeof(Array)
/*
* note this is the runtime representation
* of the compilers strings.
*
* typedef struct
* { // must not move anything
* uchar array[8]; // pointer to data
* uchar nel[4]; // number of elements
* } String;
*/
EXTERN int sizeof_String; // runtime sizeof(String)
EXTERN Dlist dotlist[10]; // size is max depth of embeddeds
EXTERN Io curio;
EXTERN Io pushedio;
EXTERN int32 lexlineno;
EXTERN int32 lineno;
EXTERN int32 prevlineno;
EXTERN char* pathname;
EXTERN Hist* hist;
EXTERN Hist* ehist;
EXTERN char* infile;
EXTERN char* outfile;
EXTERN Biobuf* bout;
EXTERN int nerrors;
EXTERN int nsavederrors;
EXTERN int nsyntaxerrors;
EXTERN int safemode;
EXTERN char namebuf[NSYMB];
EXTERN char lexbuf[NSYMB];
EXTERN char litbuf[NSYMB];
EXTERN int debug[256];
EXTERN Sym* hash[NHASH];
EXTERN Sym* importmyname; // my name for package
EXTERN Pkg* localpkg; // package being compiled
EXTERN Pkg* importpkg; // package being imported
EXTERN Pkg* structpkg; // package that declared struct, during import
EXTERN Pkg* builtinpkg; // fake package for builtins
EXTERN Pkg* gostringpkg; // fake pkg for Go strings
EXTERN Pkg* itabpkg; // fake pkg for itab cache
EXTERN Pkg* runtimepkg; // package runtime
EXTERN Pkg* racepkg; // package runtime/race
EXTERN Pkg* stringpkg; // fake package for C strings
EXTERN Pkg* typepkg; // fake package for runtime type info (headers)
EXTERN Pkg* typelinkpkg; // fake package for runtime type info (data)
EXTERN Pkg* weaktypepkg; // weak references to runtime type info
EXTERN Pkg* unsafepkg; // package unsafe
EXTERN Pkg* trackpkg; // fake package for field tracking
EXTERN Pkg* phash[128];
EXTERN int tptr; // either TPTR32 or TPTR64
extern char* runtimeimport;
extern char* unsafeimport;
EXTERN char* myimportpath;
EXTERN Idir* idirs;
EXTERN char* localimport;
EXTERN Type* types[NTYPE];
EXTERN Type* idealstring;
EXTERN Type* idealbool;
EXTERN Type* bytetype;
EXTERN Type* runetype;
EXTERN Type* errortype;
EXTERN uchar simtype[NTYPE];
EXTERN uchar isptr[NTYPE];
EXTERN uchar isforw[NTYPE];
EXTERN uchar isint[NTYPE];
EXTERN uchar isfloat[NTYPE];
EXTERN uchar iscomplex[NTYPE];
EXTERN uchar issigned[NTYPE];
EXTERN uchar issimple[NTYPE];
EXTERN uchar okforeq[NTYPE];
EXTERN uchar okforadd[NTYPE];
EXTERN uchar okforand[NTYPE];
EXTERN uchar okfornone[NTYPE];
EXTERN uchar okforcmp[NTYPE];
EXTERN uchar okforbool[NTYPE];
EXTERN uchar okforcap[NTYPE];
EXTERN uchar okforlen[NTYPE];
EXTERN uchar okforarith[NTYPE];
EXTERN uchar okforconst[NTYPE];
EXTERN uchar* okfor[OEND];
EXTERN uchar iscmp[OEND];
EXTERN Mpint* minintval[NTYPE];
EXTERN Mpint* maxintval[NTYPE];
EXTERN Mpflt* minfltval[NTYPE];
EXTERN Mpflt* maxfltval[NTYPE];
EXTERN NodeList* xtop;
EXTERN NodeList* externdcl;
EXTERN NodeList* closures;
EXTERN NodeList* exportlist;
EXTERN NodeList* importlist; // imported functions and methods with inlinable bodies
EXTERN NodeList* funcsyms;
EXTERN int dclcontext; // PEXTERN/PAUTO
EXTERN int incannedimport;
EXTERN int statuniqgen; // name generator for static temps
EXTERN int loophack;
EXTERN int32 iota;
EXTERN NodeList* lastconst;
EXTERN Node* lasttype;
EXTERN vlong maxarg;
EXTERN vlong stksize; // stack size for current frame
EXTERN int32 blockgen; // max block number
EXTERN int32 block; // current block number
EXTERN int hasdefer; // flag that curfn has defer statetment
EXTERN Node* curfn;
EXTERN int widthptr;
EXTERN int widthint;
EXTERN Node* typesw;
EXTERN Node* nblank;
extern int thechar;
extern char* thestring;
EXTERN int use_sse;
EXTERN char* hunk;
EXTERN int32 nhunk;
EXTERN int32 thunk;
EXTERN int funcdepth;
EXTERN int typecheckok;
EXTERN int compiling_runtime;
EXTERN int compiling_wrappers;
EXTERN int pure_go;
EXTERN int flag_race;
EXTERN int flag_largemodel;
EXTERN int noescape;
EXTERN int nointerface;
EXTERN int fieldtrack_enabled;
/*
* y.tab.c
*/
int yyparse(void);
/*
* align.c
*/
int argsize(Type *t);
void checkwidth(Type *t);
void defercheckwidth(void);
void dowidth(Type *t);
void resumecheckwidth(void);
vlong rnd(vlong o, vlong r);
void typeinit(void);
/*
* bits.c
*/
int Qconv(Fmt *fp);
Bits band(Bits a, Bits b);
int bany(Bits *a);
int beq(Bits a, Bits b);
int bitno(int32 b);
Bits blsh(uint n);
Bits bnot(Bits a);
int bnum(Bits a);
Bits bor(Bits a, Bits b);
int bset(Bits a, uint n);