github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/cmd/gc/go.h (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  #include	<bio.h>
     6  
     7  #undef OAPPEND
     8  
     9  // avoid <ctype.h>
    10  #undef isblank
    11  #define isblank goisblank
    12  
    13  #ifndef	EXTERN
    14  #define	EXTERN	extern
    15  #endif
    16  
    17  #undef	BUFSIZ
    18  
    19  // The parser's maximum stack size.
    20  // We have to use a #define macro here since yacc
    21  // or bison will check for its definition and use
    22  // a potentially smaller value if it is undefined.
    23  #define YYMAXDEPTH 500
    24  
    25  enum
    26  {
    27  	NHUNK		= 50000,
    28  	BUFSIZ		= 8192,
    29  	NSYMB		= 500,
    30  	NHASH		= 1024,
    31  	STRINGSZ	= 200,
    32  	MAXALIGN	= 7,
    33  	UINF		= 100,
    34  	HISTSZ		= 10,
    35  
    36  	PRIME1		= 3,
    37  
    38  	AUNK		= 100,
    39  
    40  	// These values are known by runtime.
    41  	// The MEMx and NOEQx values must run in parallel.  See algtype.
    42  	AMEM		= 0,
    43  	AMEM0,
    44  	AMEM8,
    45  	AMEM16,
    46  	AMEM32,
    47  	AMEM64,
    48  	AMEM128,
    49  	ANOEQ,
    50  	ANOEQ0,
    51  	ANOEQ8,
    52  	ANOEQ16,
    53  	ANOEQ32,
    54  	ANOEQ64,
    55  	ANOEQ128,
    56  	ASTRING,
    57  	AINTER,
    58  	ANILINTER,
    59  	ASLICE,
    60  	AFLOAT32,
    61  	AFLOAT64,
    62  	ACPLX64,
    63  	ACPLX128,
    64  
    65  	BADWIDTH	= -1000000000,
    66  	
    67  	MaxStackVarSize = 10*1024*1024,
    68  };
    69  
    70  extern vlong	MAXWIDTH;
    71  
    72  /*
    73   * note this is the representation
    74   * of the compilers string literals,
    75   * it is not the runtime representation
    76   */
    77  typedef	struct	Strlit	Strlit;
    78  struct	Strlit
    79  {
    80  	int32	len;
    81  	char	s[1]; // variable
    82  };
    83  
    84  enum
    85  {
    86  	Mpscale	= 29,		// safely smaller than bits in a long
    87  	Mpprec	= 16,		// Mpscale*Mpprec is max number of bits
    88  	Mpnorm	= Mpprec - 1,	// significant words in a normalized float
    89  	Mpbase	= 1L << Mpscale,
    90  	Mpsign	= Mpbase >> 1,
    91  	Mpmask	= Mpbase - 1,
    92  	Mpdebug	= 0,
    93  };
    94  
    95  typedef	struct	Mpint	Mpint;
    96  struct	Mpint
    97  {
    98  	long	a[Mpprec];
    99  	uchar	neg;
   100  	uchar	ovf;
   101  };
   102  
   103  typedef	struct	Mpflt	Mpflt;
   104  struct	Mpflt
   105  {
   106  	Mpint	val;
   107  	short	exp;
   108  };
   109  
   110  typedef	struct	Mpcplx	Mpcplx;
   111  struct	Mpcplx
   112  {
   113  	Mpflt	real;
   114  	Mpflt	imag;
   115  };
   116  
   117  typedef	struct	Val	Val;
   118  struct	Val
   119  {
   120  	short	ctype;
   121  	union
   122  	{
   123  		short	reg;		// OREGISTER
   124  		short	bval;		// bool value CTBOOL
   125  		Mpint*	xval;		// int CTINT, rune CTRUNE
   126  		Mpflt*	fval;		// float CTFLT
   127  		Mpcplx*	cval;		// float CTCPLX
   128  		Strlit*	sval;		// string CTSTR
   129  	} u;
   130  };
   131  
   132  typedef	struct	Bvec	Bvec;
   133  typedef	struct	Pkg Pkg;
   134  typedef	struct	Sym	Sym;
   135  typedef	struct	Node	Node;
   136  typedef	struct	NodeList	NodeList;
   137  typedef	struct	Type	Type;
   138  typedef	struct	Label	Label;
   139  
   140  struct	Type
   141  {
   142  	uchar	etype;
   143  	uchar	nointerface;
   144  	uchar	noalg;
   145  	uchar	chan;
   146  	uchar	trecur;		// to detect loops
   147  	uchar	printed;
   148  	uchar	embedded;	// TFIELD embedded type
   149  	uchar	siggen;
   150  	uchar	funarg;		// on TSTRUCT and TFIELD
   151  	uchar	copyany;
   152  	uchar	local;		// created in this file
   153  	uchar	deferwidth;
   154  	uchar	broke;  	// broken type definition.
   155  	uchar	isddd;		// TFIELD is ... argument
   156  	uchar	align;
   157  	uchar	haspointers;	// 0 unknown, 1 no, 2 yes
   158  
   159  	Node*	nod;		// canonical OTYPE node
   160  	Type*	orig;		// original type (type literal or predefined type)
   161  	int		lineno;
   162  
   163  	// TFUNC
   164  	int	thistuple;
   165  	int	outtuple;
   166  	int	intuple;
   167  	uchar	outnamed;
   168  
   169  	Type*	method;
   170  	Type*	xmethod;
   171  
   172  	Sym*	sym;
   173  	int32	vargen;		// unique name for OTYPE/ONAME
   174  
   175  	Node*	nname;
   176  	vlong	argwid;
   177  
   178  	// most nodes
   179  	Type*	type;   	// actual type for TFIELD, element type for TARRAY, TCHAN, TMAP, TPTRxx
   180  	vlong	width;  	// offset in TFIELD, width in all others
   181  
   182  	// TFIELD
   183  	Type*	down;		// next struct field, also key type in TMAP
   184  	Type*	outer;		// outer struct
   185  	Strlit*	note;		// literal string annotation
   186  
   187  	// TARRAY
   188  	vlong	bound;		// negative is dynamic array
   189  
   190  	// TMAP
   191  	Type*	bucket;		// internal type representing a hash bucket
   192  	Type*	hmap;		// internal type representing a Hmap (map header object)
   193  
   194  	int32	maplineno;	// first use of TFORW as map key
   195  	int32	embedlineno;	// first use of TFORW as embedded type
   196  	
   197  	// for TFORW, where to copy the eventual value to
   198  	NodeList	*copyto;
   199  	
   200  	Node	*lastfn;	// for usefield
   201  };
   202  #define	T	((Type*)0)
   203  
   204  typedef struct InitEntry InitEntry;
   205  typedef struct InitPlan InitPlan;
   206  
   207  struct InitEntry
   208  {
   209  	vlong xoffset;  // struct, array only
   210  	Node *key;  // map only
   211  	Node *expr;
   212  };
   213  
   214  struct InitPlan
   215  {
   216  	vlong lit;  // bytes of initialized non-zero literals
   217  	vlong zero;  // bytes of zeros
   218  	vlong expr;  // bytes of run-time computed expressions
   219  
   220  	InitEntry *e;
   221  	int len;
   222  	int cap;
   223  };
   224  
   225  enum
   226  {
   227  	EscUnknown,
   228  	EscHeap,
   229  	EscScope,
   230  	EscNone,
   231  	EscReturn,
   232  	EscNever,
   233  	EscBits = 4,
   234  	EscMask = (1<<EscBits) - 1,
   235  };
   236  
   237  struct	Node
   238  {
   239  	// Tree structure.
   240  	// Generic recursive walks should follow these fields.
   241  	Node*	left;
   242  	Node*	right;
   243  	Node*	ntest;
   244  	Node*	nincr;
   245  	NodeList*	ninit;
   246  	NodeList*	nbody;
   247  	NodeList*	nelse;
   248  	NodeList*	list;
   249  	NodeList*	rlist;
   250  
   251  	uchar	op;
   252  	uchar	nointerface;
   253  	uchar	ullman;		// sethi/ullman number
   254  	uchar	addable;	// type of addressability - 0 is not addressable
   255  	uchar	trecur;		// to detect loops
   256  	uchar	etype;		// op for OASOP, etype for OTYPE, exclam for export
   257  	uchar	bounded;	// bounds check unnecessary
   258  	uchar	class;		// PPARAM, PAUTO, PEXTERN, etc
   259  	uchar	method;		// OCALLMETH name
   260  	uchar	embedded;	// ODCLFIELD embedded type
   261  	uchar	colas;		// OAS resulting from :=
   262  	uchar	diag;		// already printed error about this
   263  	uchar	noescape;	// func arguments do not escape
   264  	uchar	builtin;	// built-in name, like len or close
   265  	uchar	walkdef;
   266  	uchar	typecheck;
   267  	uchar	local;
   268  	uchar	dodata;
   269  	uchar	initorder;
   270  	uchar	used;
   271  	uchar	isddd;
   272  	uchar	readonly;
   273  	uchar	implicit;
   274  	uchar	addrtaken;	// address taken, even if not moved to heap
   275  	uchar	dupok;	// duplicate definitions ok (for func)
   276  	uchar	wrapper;	// is method wrapper (for func)
   277  	schar	likely; // likeliness of if statement
   278  	uchar	hasbreak;	// has break statement
   279  	uchar	needzero; // if it contains pointers, needs to be zeroed on function entry
   280  	uint	esc;		// EscXXX
   281  	int	funcdepth;
   282  
   283  	// most nodes
   284  	Type*	type;
   285  	Node*	orig;		// original form, for printing, and tracking copies of ONAMEs
   286  
   287  	// func
   288  	Node*	nname;
   289  	Node*	shortname;
   290  	NodeList*	enter;
   291  	NodeList*	exit;
   292  	NodeList*	cvars;	// closure params
   293  	NodeList*	dcl;	// autodcl for this func/closure
   294  	NodeList*	inl;	// copy of the body for use in inlining
   295  	NodeList*	inldcl;	// copy of dcl for use in inlining
   296  
   297  	// OLITERAL/OREGISTER
   298  	Val	val;
   299  
   300  	// ONAME
   301  	Node*	ntype;
   302  	Node*	defn;	// ONAME: initializing assignment; OLABEL: labeled statement
   303  	Node*	pack;	// real package for import . names
   304  	Node*	curfn;	// function for local variables
   305  	Type*	paramfld; // TFIELD for this PPARAM; also for ODOT, curfn
   306  
   307  	// ONAME func param with PHEAP
   308  	Node*	heapaddr;	// temp holding heap address of param
   309  	Node*	stackparam;	// OPARAM node referring to stack copy of param
   310  	Node*	alloc;	// allocation call
   311  
   312  	// ONAME closure param with PPARAMREF
   313  	Node*	outer;	// outer PPARAMREF in nested closure
   314  	Node*	closure;	// ONAME/PHEAP <-> ONAME/PPARAMREF
   315  
   316  	// ONAME substitute while inlining
   317  	Node* inlvar;
   318  
   319  	// OPACK
   320  	Pkg*	pkg;
   321  	
   322  	// OARRAYLIT, OMAPLIT, OSTRUCTLIT.
   323  	InitPlan*	initplan;
   324  
   325  	// Escape analysis.
   326  	NodeList* escflowsrc;	// flow(this, src)
   327  	NodeList* escretval;	// on OCALLxxx, list of dummy return values
   328  	int	escloopdepth;	// -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes
   329  
   330  	Sym*	sym;		// various
   331  	int32	vargen;		// unique name for OTYPE/ONAME
   332  	int32	lineno;
   333  	int32	endlineno;
   334  	vlong	xoffset;
   335  	vlong	stkdelta;	// offset added by stack frame compaction phase.
   336  	int32	ostk;
   337  	int32	iota;
   338  	uint32	walkgen;
   339  	int32	esclevel;
   340  	void*	opt;	// for optimization passes
   341  };
   342  #define	N	((Node*)0)
   343  
   344  /*
   345   * Every node has a walkgen field.
   346   * If you want to do a traversal of a node graph that
   347   * might contain duplicates and want to avoid
   348   * visiting the same nodes twice, increment walkgen
   349   * before starting.  Then before processing a node, do
   350   *
   351   *	if(n->walkgen == walkgen)
   352   *		return;
   353   *	n->walkgen = walkgen;
   354   *
   355   * Such a walk cannot call another such walk recursively,
   356   * because of the use of the global walkgen.
   357   */
   358  EXTERN	uint32	walkgen;
   359  
   360  struct	NodeList
   361  {
   362  	Node*	n;
   363  	NodeList*	next;
   364  	NodeList*	end;
   365  };
   366  
   367  enum
   368  {
   369  	SymExport	= 1<<0,	// to be exported
   370  	SymPackage	= 1<<1,
   371  	SymExported	= 1<<2,	// already written out by export
   372  	SymUniq		= 1<<3,
   373  	SymSiggen	= 1<<4,
   374  	SymGcgen	= 1<<5,
   375  };
   376  
   377  struct	Sym
   378  {
   379  	ushort	lexical;
   380  	uchar	flags;
   381  	uchar	sym;		// huffman encoding in object file
   382  	Sym*	link;
   383  	int32	npkg;	// number of imported packages with this name
   384  	uint32	uniqgen;
   385  	Pkg*	importdef;	// where imported definition was found
   386  
   387  	// saved and restored by dcopy
   388  	Pkg*	pkg;
   389  	char*	name;		// variable name
   390  	Node*	def;		// definition: ONAME OTYPE OPACK or OLITERAL
   391  	Label*	label;	// corresponding label (ephemeral)
   392  	int32	block;		// blocknumber to catch redeclaration
   393  	int32	lastlineno;	// last declaration for diagnostic
   394  	Pkg*	origpkg;	// original package for . import
   395  };
   396  #define	S	((Sym*)0)
   397  
   398  EXTERN	Sym*	dclstack;
   399  
   400  struct	Pkg
   401  {
   402  	char*	name;		// package name
   403  	Strlit*	path;		// string literal used in import statement
   404  	Sym*	pathsym;
   405  	char*	prefix;		// escaped path for use in symbol table
   406  	Pkg*	link;
   407  	uchar	imported;	// export data of this package was parsed
   408  	char	exported;	// import line written in export data
   409  	char	direct;	// imported directly
   410  	char	safe;	// whether the package is marked as safe
   411  };
   412  
   413  typedef	struct	Iter	Iter;
   414  struct	Iter
   415  {
   416  	int	done;
   417  	Type*	tfunc;
   418  	Type*	t;
   419  	Node**	an;
   420  	Node*	n;
   421  };
   422  
   423  typedef	struct	Hist	Hist;
   424  struct	Hist
   425  {
   426  	Hist*	link;
   427  	char*	name;
   428  	int32	line;
   429  	int32	offset;
   430  };
   431  #define	H	((Hist*)0)
   432  
   433  // Node ops.
   434  enum
   435  {
   436  	OXXX,
   437  
   438  	// names
   439  	ONAME,	// var, const or func name
   440  	ONONAME,	// unnamed arg or return value: f(int, string) (int, error) { etc }
   441  	OTYPE,	// type name
   442  	OPACK,	// import
   443  	OLITERAL, // literal
   444  
   445  	// expressions
   446  	OADD,	// x + y
   447  	OSUB,	// x - y
   448  	OOR,	// x | y
   449  	OXOR,	// x ^ y
   450  	OADDSTR,	// s + "foo"
   451  	OADDR,	// &x
   452  	OANDAND,	// b0 && b1
   453  	OAPPEND,	// append
   454  	OARRAYBYTESTR,	// string(bytes)
   455  	OARRAYRUNESTR,	// string(runes)
   456  	OSTRARRAYBYTE,	// []byte(s)
   457  	OSTRARRAYRUNE,	// []rune(s)
   458  	OAS,	// x = y or x := y
   459  	OAS2,	// x, y, z = xx, yy, zz
   460  	OAS2FUNC,	// x, y = f()
   461  	OAS2RECV,	// x, ok = <-c
   462  	OAS2MAPR,	// x, ok = m["foo"]
   463  	OAS2DOTTYPE,	// x, ok = I.(int)
   464  	OASOP,	// x += y
   465  	OCALL,	// function call, method call or type conversion, possibly preceded by defer or go.
   466  	OCALLFUNC,	// f()
   467  	OCALLMETH,	// t.Method()
   468  	OCALLINTER,	// err.Error()
   469  	OCALLPART,	// t.Method (without ())
   470  	OCAP,	// cap
   471  	OCLOSE,	// close
   472  	OCLOSURE,	// f = func() { etc }
   473  	OCMPIFACE,	// err1 == err2
   474  	OCMPSTR,	// s1 == s2
   475  	OCOMPLIT,	// composite literal, typechecking may convert to a more specific OXXXLIT.
   476  	OMAPLIT,	// M{"foo":3, "bar":4}
   477  	OSTRUCTLIT,	// T{x:3, y:4}
   478  	OARRAYLIT,	// [2]int{3, 4}
   479  	OPTRLIT,	// &T{x:3, y:4}
   480  	OCONV,	// var i int; var u uint; i = int(u)
   481  	OCONVIFACE,	// I(t)
   482  	OCONVNOP,	// type Int int; var i int; var j Int; i = int(j)
   483  	OCOPY,	// copy
   484  	ODCL,	// var x int
   485  	ODCLFUNC,	// func f() or func (r) f()
   486  	ODCLFIELD,	// struct field, interface field, or func/method argument/return value.
   487  	ODCLCONST,	// const pi = 3.14
   488  	ODCLTYPE,	// type Int int
   489  	ODELETE,	// delete
   490  	ODOT,	// t.x
   491  	ODOTPTR,	// p.x that is implicitly (*p).x
   492  	ODOTMETH,	// t.Method
   493  	ODOTINTER,	// err.Error
   494  	OXDOT,	// t.x, typechecking may convert to a more specific ODOTXXX.
   495  	ODOTTYPE,	// e = err.(MyErr)
   496  	ODOTTYPE2,	// e, ok = err.(MyErr)
   497  	OEQ,	// x == y
   498  	ONE,	// x != y
   499  	OLT,	// x < y
   500  	OLE,	// x <= y
   501  	OGE,	// x >= y
   502  	OGT,	// x > y
   503  	OIND,	// *p
   504  	OINDEX,	// a[i]
   505  	OINDEXMAP,	// m[s]
   506  	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.
   507  	OPARAM,	// The on-stack copy of a parameter or return value that escapes.
   508  	OLEN,	// len
   509  	OMAKE,	// make, typechecking may convert to a more specfic OMAKEXXX.
   510  	OMAKECHAN,	// make(chan int)
   511  	OMAKEMAP,	// make(map[string]int)
   512  	OMAKESLICE,	// make([]int, 0)
   513  	OMUL,	// x * y
   514  	ODIV,	// x / y
   515  	OMOD,	// x % y
   516  	OLSH,	// x << u
   517  	ORSH,	// x >> u
   518  	OAND,	// x & y
   519  	OANDNOT,	// x &^ y
   520  	ONEW,	// new
   521  	ONOT,	// !b
   522  	OCOM,	// ^x
   523  	OPLUS,	// +x
   524  	OMINUS,	// -y
   525  	OOROR,	// b1 || b2
   526  	OPANIC,	// panic
   527  	OPRINT,	// print
   528  	OPRINTN,	// println
   529  	OPAREN,	// (x)
   530  	OSEND,	// c <- x
   531  	OSLICE,	// v[1:2], typechecking may convert to a more specfic OSLICEXXX.
   532  	OSLICEARR,	// a[1:2]
   533  	OSLICESTR,	// s[1:2]
   534  	OSLICE3,	// v[1:2:3], typechecking may convert to OSLICE3ARR.
   535  	OSLICE3ARR,	// a[1:2:3]
   536  	ORECOVER,	// recover
   537  	ORECV,	// <-c
   538  	ORUNESTR,	// string(i)
   539  	OSELRECV,	// case x = <-c:
   540  	OSELRECV2,	// case x, ok = <-c:
   541  	OIOTA,	// iota
   542  	OREAL,	// real
   543  	OIMAG,	// imag
   544  	OCOMPLEX,	// complex
   545  
   546  	// statements
   547  	OBLOCK,	// block of code
   548  	OBREAK,	// break
   549  	OCASE,	// case, after being verified by swt.c's casebody.
   550  	OXCASE,	// case, before verification.
   551  	OCONTINUE,	// continue
   552  	ODEFER,	// defer
   553  	OEMPTY,	// no-op
   554  	OFALL,	// fallthrough, after being verified by swt.c's casebody.
   555  	OXFALL,	// fallthrough, before verification.
   556  	OFOR,	// for
   557  	OGOTO,	// goto
   558  	OIF,	// if
   559  	OLABEL,	// label:
   560  	OPROC,	// go
   561  	ORANGE,	// range
   562  	ORETURN,	// return
   563  	OSELECT,	// select
   564  	OSWITCH,	// switch x
   565  	OTYPESW,	// switch err.(type)
   566  
   567  	// types
   568  	OTCHAN,	// chan int
   569  	OTMAP,	// map[string]int
   570  	OTSTRUCT,	// struct{}
   571  	OTINTER,	// interface{}
   572  	OTFUNC,	// func()
   573  	OTARRAY,	// []int, [8]int, [N]int or [...]int
   574  	OTPAREN,	// (T)
   575  
   576  	// misc
   577  	ODDD,	// func f(args ...int) or f(l...) or var a = [...]int{0, 1, 2}.
   578  	ODDDARG,	// func f(args ...int), introduced by escape analysis.
   579  	OINLCALL,	// intermediary representation of an inlined call.
   580  	OEFACE,	// itable and data words of an empty-interface value.
   581  	OITAB,	// itable word of an interface value.
   582  	OSPTR,  // base pointer of a slice or string.
   583  	OCLOSUREVAR, // variable reference at beginning of closure function
   584  	OCFUNC,	// reference to c function pointer (not go func value)
   585  	OCHECKNIL, // emit code to ensure pointer/interface not nil
   586  
   587  	// arch-specific registers
   588  	OREGISTER,	// a register, such as AX.
   589  	OINDREG,	// offset plus indirect of a register, such as 8(SP).
   590  
   591  	// 386/amd64-specific opcodes
   592  	OCMP,	// compare: ACMP.
   593  	ODEC,	// decrement: ADEC.
   594  	OINC,	// increment: AINC.
   595  	OEXTEND,	// extend: ACWD/ACDQ/ACQO.
   596  	OHMUL, // high mul: AMUL/AIMUL for unsigned/signed (OMUL uses AIMUL for both).
   597  	OLROT,	// left rotate: AROL.
   598  	ORROTC, // right rotate-carry: ARCR.
   599  	ORETJMP,	// return to other function
   600  
   601  	OEND,
   602  };
   603  
   604  enum
   605  {
   606  	Txxx,			// 0
   607  
   608  	TINT8,	TUINT8,		// 1
   609  	TINT16,	TUINT16,
   610  	TINT32,	TUINT32,
   611  	TINT64,	TUINT64,
   612  	TINT, TUINT, TUINTPTR,
   613  
   614  	TCOMPLEX64,		// 12
   615  	TCOMPLEX128,
   616  
   617  	TFLOAT32,		// 14
   618  	TFLOAT64,
   619  
   620  	TBOOL,			// 16
   621  
   622  	TPTR32, TPTR64,		// 17
   623  
   624  	TFUNC,			// 19
   625  	TARRAY,
   626  	T_old_DARRAY,
   627  	TSTRUCT,		// 22
   628  	TCHAN,
   629  	TMAP,
   630  	TINTER,			// 25
   631  	TFORW,
   632  	TFIELD,
   633  	TANY,
   634  	TSTRING,
   635  	TUNSAFEPTR,
   636  
   637  	// pseudo-types for literals
   638  	TIDEAL,			// 31
   639  	TNIL,
   640  	TBLANK,
   641  
   642  	// pseudo-type for frame layout
   643  	TFUNCARGS,
   644  	TCHANARGS,
   645  	TINTERMETH,
   646  
   647  	NTYPE,
   648  };
   649  
   650  enum
   651  {
   652  	CTxxx,
   653  
   654  	CTINT,
   655  	CTRUNE,
   656  	CTFLT,
   657  	CTCPLX,
   658  	CTSTR,
   659  	CTBOOL,
   660  	CTNIL,
   661  };
   662  
   663  enum
   664  {
   665  	/* types of channel */
   666  	/* must match ../../pkg/nreflect/type.go:/Chandir */
   667  	Cxxx,
   668  	Crecv = 1<<0,
   669  	Csend = 1<<1,
   670  	Cboth = Crecv | Csend,
   671  };
   672  
   673  // declaration context
   674  enum
   675  {
   676  	Pxxx,
   677  
   678  	PEXTERN,	// global variable
   679  	PAUTO,		// local variables
   680  	PPARAM,		// input arguments
   681  	PPARAMOUT,	// output results
   682  	PPARAMREF,	// closure variable reference
   683  	PFUNC,		// global function
   684  
   685  	PDISCARD,	// discard during parse of duplicate import
   686  
   687  	PHEAP = 1<<7,	// an extra bit to identify an escaped variable
   688  };
   689  
   690  enum
   691  {
   692  	Etop = 1<<1,		// evaluated at statement level
   693  	Erv = 1<<2,		// evaluated in value context
   694  	Etype = 1<<3,
   695  	Ecall = 1<<4,		// call-only expressions are ok
   696  	Efnstruct = 1<<5,	// multivalue function returns are ok
   697  	Eiota = 1<<6,		// iota is ok
   698  	Easgn = 1<<7,		// assigning to expression
   699  	Eindir = 1<<8,		// indirecting through expression
   700  	Eaddr = 1<<9,		// taking address of expression
   701  	Eproc = 1<<10,		// inside a go statement
   702  	Ecomplit = 1<<11,	// type in composite literal
   703  };
   704  
   705  #define	BITS	5
   706  #define	NVAR	(BITS*sizeof(uint32)*8)
   707  
   708  typedef	struct	Bits	Bits;
   709  struct	Bits
   710  {
   711  	uint32	b[BITS];
   712  };
   713  
   714  EXTERN	Bits	zbits;
   715  
   716  struct Bvec
   717  {
   718  	int32	n;	// number of bits
   719  	uint32	b[];
   720  };
   721  
   722  typedef	struct	Var	Var;
   723  struct	Var
   724  {
   725  	vlong	offset;
   726  	Node*	node;
   727  	int	width;
   728  	char	name;
   729  	char	etype;
   730  	char	addr;
   731  };
   732  
   733  EXTERN	Var	var[NVAR];
   734  
   735  typedef	struct	Typedef	Typedef;
   736  struct	Typedef
   737  {
   738  	char*	name;
   739  	int	etype;
   740  	int	sameas;
   741  };
   742  
   743  extern	Typedef	typedefs[];
   744  
   745  typedef	struct	Sig	Sig;
   746  struct	Sig
   747  {
   748  	char*	name;
   749  	Pkg*	pkg;
   750  	Sym*	isym;
   751  	Sym*	tsym;
   752  	Type*	type;
   753  	Type*	mtype;
   754  	int32	offset;
   755  	Sig*	link;
   756  };
   757  
   758  typedef	struct	Io	Io;
   759  struct	Io
   760  {
   761  	char*	infile;
   762  	Biobuf*	bin;
   763  	int32	ilineno;
   764  	int	nlsemi;
   765  	int	eofnl;
   766  	int	last;
   767  	int	peekc;
   768  	int	peekc1;	// second peekc for ...
   769  	char*	cp;	// used for content when bin==nil
   770  	int	importsafe;
   771  };
   772  
   773  typedef	struct	Dlist	Dlist;
   774  struct	Dlist
   775  {
   776  	Type*	field;
   777  };
   778  
   779  typedef	struct	Idir	Idir;
   780  struct Idir
   781  {
   782  	Idir*	link;
   783  	char*	dir;
   784  };
   785  
   786  /*
   787   * argument passing to/from
   788   * smagic and umagic
   789   */
   790  typedef	struct	Magic Magic;
   791  struct	Magic
   792  {
   793  	int	w;	// input for both - width
   794  	int	s;	// output for both - shift
   795  	int	bad;	// output for both - unexpected failure
   796  
   797  	// magic multiplier for signed literal divisors
   798  	int64	sd;	// input - literal divisor
   799  	int64	sm;	// output - multiplier
   800  
   801  	// magic multiplier for unsigned literal divisors
   802  	uint64	ud;	// input - literal divisor
   803  	uint64	um;	// output - multiplier
   804  	int	ua;	// output - adder
   805  };
   806  
   807  typedef struct	Prog Prog;
   808  #pragma incomplete Prog
   809  
   810  struct	Label
   811  {
   812  	uchar	used;
   813  	Sym*	sym;
   814  	Node*	def;
   815  	NodeList*	use;
   816  	Label*	link;
   817  	
   818  	// for use during gen
   819  	Prog*	gotopc;	// pointer to unresolved gotos
   820  	Prog*	labelpc;	// pointer to code
   821  	Prog*	breakpc;	// pointer to code
   822  	Prog*	continpc;	// pointer to code
   823  };
   824  #define	L	((Label*)0)
   825  
   826  /*
   827   * note this is the runtime representation
   828   * of the compilers arrays.
   829   *
   830   * typedef	struct
   831   * {				// must not move anything
   832   *	uchar	array[8];	// pointer to data
   833   *	uchar	nel[4];		// number of elements
   834   *	uchar	cap[4];		// allocated number of elements
   835   * } Array;
   836   */
   837  EXTERN	int	Array_array;	// runtime offsetof(Array,array) - same for String
   838  EXTERN	int	Array_nel;	// runtime offsetof(Array,nel) - same for String
   839  EXTERN	int	Array_cap;	// runtime offsetof(Array,cap)
   840  EXTERN	int	sizeof_Array;	// runtime sizeof(Array)
   841  
   842  
   843  /*
   844   * note this is the runtime representation
   845   * of the compilers strings.
   846   *
   847   * typedef	struct
   848   * {				// must not move anything
   849   *	uchar	array[8];	// pointer to data
   850   *	uchar	nel[4];		// number of elements
   851   * } String;
   852   */
   853  EXTERN	int	sizeof_String;	// runtime sizeof(String)
   854  
   855  EXTERN	Dlist	dotlist[10];	// size is max depth of embeddeds
   856  
   857  EXTERN	Io	curio;
   858  EXTERN	Io	pushedio;
   859  EXTERN	int32	lexlineno;
   860  EXTERN	int32	lineno;
   861  EXTERN	int32	prevlineno;
   862  EXTERN	char*	pathname;
   863  EXTERN	Hist*	hist;
   864  EXTERN	Hist*	ehist;
   865  
   866  EXTERN	char*	infile;
   867  EXTERN	char*	outfile;
   868  EXTERN	Biobuf*	bout;
   869  EXTERN	int	nerrors;
   870  EXTERN	int	nsavederrors;
   871  EXTERN	int	nsyntaxerrors;
   872  EXTERN	int	safemode;
   873  EXTERN	char	namebuf[NSYMB];
   874  EXTERN	char	lexbuf[NSYMB];
   875  EXTERN	char	litbuf[NSYMB];
   876  EXTERN	int	debug[256];
   877  EXTERN	char*	debugstr;
   878  EXTERN	int	debug_checknil;
   879  EXTERN	Sym*	hash[NHASH];
   880  EXTERN	Sym*	importmyname;	// my name for package
   881  EXTERN	Pkg*	localpkg;	// package being compiled
   882  EXTERN	Pkg*	importpkg;	// package being imported
   883  EXTERN	Pkg*	structpkg;	// package that declared struct, during import
   884  EXTERN	Pkg*	builtinpkg;	// fake package for builtins
   885  EXTERN	Pkg*	gostringpkg;	// fake pkg for Go strings
   886  EXTERN	Pkg*	itabpkg;	// fake pkg for itab cache
   887  EXTERN	Pkg*	runtimepkg;	// package runtime
   888  EXTERN	Pkg*	racepkg;	// package runtime/race
   889  EXTERN	Pkg*	stringpkg;	// fake package for C strings
   890  EXTERN	Pkg*	typepkg;	// fake package for runtime type info (headers)
   891  EXTERN	Pkg*	typelinkpkg;	// fake package for runtime type info (data)
   892  EXTERN	Pkg*	weaktypepkg;	// weak references to runtime type info
   893  EXTERN	Pkg*	unsafepkg;	// package unsafe
   894  EXTERN	Pkg*	trackpkg;	// fake package for field tracking
   895  EXTERN	Pkg*	phash[128];
   896  EXTERN	int	tptr;		// either TPTR32 or TPTR64
   897  extern	char*	runtimeimport;
   898  extern	char*	unsafeimport;
   899  EXTERN	char*	myimportpath;
   900  EXTERN	Idir*	idirs;
   901  EXTERN	char*	localimport;
   902  
   903  EXTERN	Type*	types[NTYPE];
   904  EXTERN	Type*	idealstring;
   905  EXTERN	Type*	idealbool;
   906  EXTERN	Type*	bytetype;
   907  EXTERN	Type*	runetype;
   908  EXTERN	Type*	errortype;
   909  EXTERN	uchar	simtype[NTYPE];
   910  EXTERN	uchar	isptr[NTYPE];
   911  EXTERN	uchar	isforw[NTYPE];
   912  EXTERN	uchar	isint[NTYPE];
   913  EXTERN	uchar	isfloat[NTYPE];
   914  EXTERN	uchar	iscomplex[NTYPE];
   915  EXTERN	uchar	issigned[NTYPE];
   916  EXTERN	uchar	issimple[NTYPE];
   917  
   918  EXTERN	uchar	okforeq[NTYPE];
   919  EXTERN	uchar	okforadd[NTYPE];
   920  EXTERN	uchar	okforand[NTYPE];
   921  EXTERN	uchar	okfornone[NTYPE];
   922  EXTERN	uchar	okforcmp[NTYPE];
   923  EXTERN	uchar	okforbool[NTYPE];
   924  EXTERN	uchar	okforcap[NTYPE];
   925  EXTERN	uchar	okforlen[NTYPE];
   926  EXTERN	uchar	okforarith[NTYPE];
   927  EXTERN	uchar	okforconst[NTYPE];
   928  EXTERN	uchar*	okfor[OEND];
   929  EXTERN	uchar	iscmp[OEND];
   930  
   931  EXTERN	Mpint*	minintval[NTYPE];
   932  EXTERN	Mpint*	maxintval[NTYPE];
   933  EXTERN	Mpflt*	minfltval[NTYPE];
   934  EXTERN	Mpflt*	maxfltval[NTYPE];
   935  
   936  EXTERN	NodeList*	xtop;
   937  EXTERN	NodeList*	externdcl;
   938  EXTERN	NodeList*	closures;
   939  EXTERN	NodeList*	exportlist;
   940  EXTERN	NodeList*	importlist;	// imported functions and methods with inlinable bodies
   941  EXTERN	NodeList*	funcsyms;
   942  EXTERN	int	dclcontext;		// PEXTERN/PAUTO
   943  EXTERN	int	incannedimport;
   944  EXTERN	int	statuniqgen;		// name generator for static temps
   945  EXTERN	int	loophack;
   946  
   947  EXTERN	int32	iota;
   948  EXTERN	NodeList*	lastconst;
   949  EXTERN	Node*	lasttype;
   950  EXTERN	vlong	maxarg;
   951  EXTERN	vlong	stksize;		// stack size for current frame
   952  EXTERN	vlong	stkptrsize;		// prefix of stack containing pointers
   953  EXTERN	vlong	stkzerosize;		// prefix of stack that must be zeroed on entry
   954  EXTERN	int32	blockgen;		// max block number
   955  EXTERN	int32	block;			// current block number
   956  EXTERN	int	hasdefer;		// flag that curfn has defer statetment
   957  
   958  EXTERN	Node*	curfn;
   959  
   960  EXTERN	int	widthptr;
   961  EXTERN	int	widthint;
   962  
   963  EXTERN	Node*	typesw;
   964  EXTERN	Node*	nblank;
   965  
   966  extern	int	thechar;
   967  extern	char*	thestring;
   968  EXTERN	int  	use_sse;
   969  
   970  EXTERN	char*	hunk;
   971  EXTERN	int32	nhunk;
   972  EXTERN	int32	thunk;
   973  
   974  EXTERN	int	funcdepth;
   975  EXTERN	int	typecheckok;
   976  EXTERN	int	compiling_runtime;
   977  EXTERN	int	compiling_wrappers;
   978  EXTERN	int	pure_go;
   979  EXTERN	char*	flag_installsuffix;
   980  EXTERN	int	flag_race;
   981  EXTERN	int	flag_largemodel;
   982  EXTERN	int	noescape;
   983  
   984  EXTERN	int	nointerface;
   985  EXTERN	int	fieldtrack_enabled;
   986  EXTERN	int	precisestack_enabled;
   987  
   988  /*
   989   *	y.tab.c
   990   */
   991  int	yyparse(void);
   992  
   993  /*
   994   *	align.c
   995   */
   996  int	argsize(Type *t);
   997  void	checkwidth(Type *t);
   998  void	defercheckwidth(void);
   999  void	dowidth(Type *t);
  1000  void	resumecheckwidth(void);
  1001  vlong	rnd(vlong o, vlong r);
  1002  void	typeinit(void);
  1003  
  1004  /*
  1005   *	bits.c
  1006   */
  1007  int	Qconv(Fmt *fp);
  1008  Bits	band(Bits a, Bits b);
  1009  int	bany(Bits *a);
  1010  int	beq(Bits a, Bits b);
  1011  int	bitno(int32 b);
  1012  Bits	blsh(uint n);
  1013  Bits	bnot(Bits a);
  1014  int	bnum(Bits a);
  1015  Bits	bor(Bits a, Bits b);
  1016  int	bset(Bits a, uint n);
  1017  
  1018  /*
  1019   *	bv.c
  1020   */
  1021  Bvec*	bvalloc(int32 n);
  1022  void	bvset(Bvec *bv, int32 i);
  1023  void	bvres(Bvec *bv, int32 i);
  1024  int	bvget(Bvec *bv, int32 i);
  1025  int	bvisempty(Bvec *bv);
  1026  int	bvcmp(Bvec *bv1, Bvec *bv2);
  1027  
  1028  /*
  1029   *	closure.c
  1030   */
  1031  Node*	closurebody(NodeList *body);
  1032  void	closurehdr(Node *ntype);
  1033  void	typecheckclosure(Node *func, int top);
  1034  Node*	walkclosure(Node *func, NodeList **init);
  1035  void	typecheckpartialcall(Node*, Node*);
  1036  Node*	walkpartialcall(Node*, NodeList**);
  1037  
  1038  /*
  1039   *	const.c
  1040   */
  1041  int	cmpslit(Node *l, Node *r);
  1042  int	consttype(Node *n);
  1043  void	convconst(Node *con, Type *t, Val *val);
  1044  void	convlit(Node **np, Type *t);
  1045  void	convlit1(Node **np, Type *t, int explicit);
  1046  void	defaultlit(Node **np, Type *t);
  1047  void	defaultlit2(Node **lp, Node **rp, int force);
  1048  void	evconst(Node *n);
  1049  int	isconst(Node *n, int ct);
  1050  int	isgoconst(Node *n);
  1051  Node*	nodcplxlit(Val r, Val i);
  1052  Node*	nodlit(Val v);
  1053  long	nonnegconst(Node *n);
  1054  int	doesoverflow(Val v, Type *t);
  1055  void	overflow(Val v, Type *t);
  1056  int	smallintconst(Node *n);
  1057  Val	toint(Val v);
  1058  Mpflt*	truncfltlit(Mpflt *oldv, Type *t);
  1059  
  1060  /*
  1061   *	cplx.c
  1062   */
  1063  void	complexadd(int op, Node *nl, Node *nr, Node *res);
  1064  void	complexbool(int op, Node *nl, Node *nr, int true, int likely, Prog *to);
  1065  void	complexgen(Node *n, Node *res);
  1066  void	complexminus(Node *nl, Node *res);
  1067  void	complexmove(Node *f, Node *t);
  1068  void	complexmul(Node *nl, Node *nr, Node *res);
  1069  int	complexop(Node *n, Node *res);
  1070  void	nodfconst(Node *n, Type *t, Mpflt* fval);
  1071  
  1072  /*
  1073   *	dcl.c
  1074   */
  1075  void	addmethod(Sym *sf, Type *t, int local, int nointerface);
  1076  void	addvar(Node *n, Type *t, int ctxt);
  1077  NodeList*	checkarglist(NodeList *all, int input);
  1078  Node*	colas(NodeList *left, NodeList *right, int32 lno);
  1079  void	colasdefn(NodeList *left, Node *defn);
  1080  NodeList*	constiter(NodeList *vl, Node *t, NodeList *cl);
  1081  Node*	dclname(Sym *s);
  1082  void	declare(Node *n, int ctxt);
  1083  void	dumpdcl(char *st);
  1084  Node*	embedded(Sym *s, Pkg *pkg);
  1085  Node*	fakethis(void);
  1086  void	funcbody(Node *n);
  1087  void	funccompile(Node *n, int isclosure);
  1088  void	funchdr(Node *n);
  1089  Type*	functype(Node *this, NodeList *in, NodeList *out);
  1090  void	ifacedcl(Node *n);
  1091  int	isifacemethod(Type *f);
  1092  void	markdcl(void);
  1093  Node*	methodname(Node *n, Type *t);
  1094  Node*	methodname1(Node *n, Node *t);
  1095  Sym*	methodsym(Sym *nsym, Type *t0, int iface);
  1096  Node*	newname(Sym *s);
  1097  Node*	oldname(Sym *s);
  1098  void	popdcl(void);
  1099  void	poptodcl(void);
  1100  void	redeclare(Sym *s, char *where);
  1101  void	testdclstack(void);
  1102  Type*	tointerface(NodeList *l);
  1103  Type*	tostruct(NodeList *l);
  1104  Node*	typedcl0(Sym *s);
  1105  Node*	typedcl1(Node *n, Node *t, int local);
  1106  Node*	typenod(Type *t);
  1107  NodeList*	variter(NodeList *vl, Node *t, NodeList *el);
  1108  Sym*	funcsym(Sym*);
  1109  
  1110  /*
  1111   *	esc.c
  1112   */
  1113  void	escapes(NodeList*);
  1114  
  1115  /*
  1116   *	export.c
  1117   */
  1118  void	autoexport(Node *n, int ctxt);
  1119  void	dumpexport(void);
  1120  int	exportname(char *s);
  1121  void	exportsym(Node *n);
  1122  void    importconst(Sym *s, Type *t, Node *n);
  1123  void	importimport(Sym *s, Strlit *z);
  1124  Sym*    importsym(Sym *s, int op);
  1125  void    importtype(Type *pt, Type *t);
  1126  void    importvar(Sym *s, Type *t);
  1127  Type*	pkgtype(Sym *s);
  1128  
  1129  /*
  1130   *	fmt.c
  1131   */
  1132  void	fmtinstallgo(void);
  1133  void	dump(char *s, Node *n);
  1134  void	dumplist(char *s, NodeList *l);
  1135  
  1136  /*
  1137   *	gen.c
  1138   */
  1139  void	addrescapes(Node *n);
  1140  void	cgen_as(Node *nl, Node *nr);
  1141  void	cgen_callmeth(Node *n, int proc);
  1142  void	cgen_eface(Node* n, Node* res);
  1143  void	cgen_slice(Node* n, Node* res);
  1144  void	clearlabels(void);
  1145  void	checklabels(void);
  1146  int	dotoffset(Node *n, int64 *oary, Node **nn);
  1147  void	gen(Node *n);
  1148  void	genlist(NodeList *l);
  1149  Node*	sysfunc(char *name);
  1150  void	tempname(Node *n, Type *t);
  1151  Node*	temp(Type*);
  1152  
  1153  /*
  1154   *	init.c
  1155   */
  1156  void	fninit(NodeList *n);
  1157  Sym*	renameinit(void);
  1158  
  1159  /*
  1160   *	inl.c
  1161   */
  1162  void	caninl(Node *fn);
  1163  void	inlcalls(Node *fn);
  1164  void	typecheckinl(Node *fn);
  1165  
  1166  /*
  1167   *	lex.c
  1168   */
  1169  void	cannedimports(char *file, char *cp);
  1170  void	importfile(Val *f, int line);
  1171  char*	lexname(int lex);
  1172  char*	expstring(void);
  1173  void	mkpackage(char* pkgname);
  1174  void	unimportfile(void);
  1175  int32	yylex(void);
  1176  extern	int	windows;
  1177  extern	int	yylast;
  1178  extern	int	yyprev;
  1179  
  1180  /*
  1181   *	mparith1.c
  1182   */
  1183  int	Bconv(Fmt *fp);
  1184  int	Fconv(Fmt *fp);
  1185  void	mpaddcfix(Mpint *a, vlong c);
  1186  void	mpaddcflt(Mpflt *a, double c);
  1187  void	mpatofix(Mpint *a, char *as);
  1188  void	mpatoflt(Mpflt *a, char *as);
  1189  int	mpcmpfixc(Mpint *b, vlong c);
  1190  int	mpcmpfixfix(Mpint *a, Mpint *b);
  1191  int	mpcmpfixflt(Mpint *a, Mpflt *b);
  1192  int	mpcmpfltc(Mpflt *b, double c);
  1193  int	mpcmpfltfix(Mpflt *a, Mpint *b);
  1194  int	mpcmpfltflt(Mpflt *a, Mpflt *b);
  1195  void	mpcomfix(Mpint *a);
  1196  void	mpdivfixfix(Mpint *a, Mpint *b);
  1197  void	mpmodfixfix(Mpint *a, Mpint *b);
  1198  void	mpmovefixfix(Mpint *a, Mpint *b);
  1199  void	mpmovefixflt(Mpflt *a, Mpint *b);
  1200  int	mpmovefltfix(Mpint *a, Mpflt *b);
  1201  void	mpmovefltflt(Mpflt *a, Mpflt *b);
  1202  void	mpmulcfix(Mpint *a, vlong c);
  1203  void	mpmulcflt(Mpflt *a, double c);
  1204  void	mpsubfixfix(Mpint *a, Mpint *b);
  1205  void	mpsubfltflt(Mpflt *a, Mpflt *b);
  1206  
  1207  /*
  1208   *	mparith2.c
  1209   */
  1210  void	mpaddfixfix(Mpint *a, Mpint *b, int);
  1211  void	mpandfixfix(Mpint *a, Mpint *b);
  1212  void	mpandnotfixfix(Mpint *a, Mpint *b);
  1213  void	mpdivfract(Mpint *a, Mpint *b);
  1214  void	mpdivmodfixfix(Mpint *q, Mpint *r, Mpint *n, Mpint *d);
  1215  vlong	mpgetfix(Mpint *a);
  1216  void	mplshfixfix(Mpint *a, Mpint *b);
  1217  void	mpmovecfix(Mpint *a, vlong c);
  1218  void	mpmulfixfix(Mpint *a, Mpint *b);
  1219  void	mpmulfract(Mpint *a, Mpint *b);
  1220  void	mpnegfix(Mpint *a);
  1221  void	mporfixfix(Mpint *a, Mpint *b);
  1222  void	mprshfixfix(Mpint *a, Mpint *b);
  1223  void	mpshiftfix(Mpint *a, int s);
  1224  int	mptestfix(Mpint *a);
  1225  void	mpxorfixfix(Mpint *a, Mpint *b);
  1226  
  1227  /*
  1228   *	mparith3.c
  1229   */
  1230  void	mpaddfltflt(Mpflt *a, Mpflt *b);
  1231  void	mpdivfltflt(Mpflt *a, Mpflt *b);
  1232  double	mpgetflt(Mpflt *a);
  1233  void	mpmovecflt(Mpflt *a, double c);
  1234  void	mpmulfltflt(Mpflt *a, Mpflt *b);
  1235  void	mpnegflt(Mpflt *a);
  1236  void	mpnorm(Mpflt *a);
  1237  int	mptestflt(Mpflt *a);
  1238  int	sigfig(Mpflt *a);
  1239  
  1240  /*
  1241   *	obj.c
  1242   */
  1243  void	Bputname(Biobuf *b, Sym *s);
  1244  int	duint16(Sym *s, int off, uint16 v);
  1245  int	duint32(Sym *s, int off, uint32 v);
  1246  int	duint64(Sym *s, int off, uint64 v);
  1247  int	duint8(Sym *s, int off, uint8 v);
  1248  int	duintptr(Sym *s, int off, uint64 v);
  1249  int	dsname(Sym *s, int off, char *dat, int ndat);
  1250  void	dumpobj(void);
  1251  void	ieeedtod(uint64 *ieee, double native);
  1252  Sym*	stringsym(char*, int);
  1253  
  1254  /*
  1255   *	order.c
  1256   */
  1257  void	order(Node *fn);
  1258  
  1259  /*
  1260   *	range.c
  1261   */
  1262  void	typecheckrange(Node *n);
  1263  void	walkrange(Node *n);
  1264  
  1265  /*
  1266   *	reflect.c
  1267   */
  1268  void	dumptypestructs(void);
  1269  Type*	methodfunc(Type *f, Type*);
  1270  Node*	typename(Type *t);
  1271  Sym*	typesym(Type *t);
  1272  Sym*	typenamesym(Type *t);
  1273  Sym*	tracksym(Type *t);
  1274  Sym*	typesymprefix(char *prefix, Type *t);
  1275  int	haspointers(Type *t);
  1276  void	usefield(Node*);
  1277  
  1278  /*
  1279   *	select.c
  1280   */
  1281  void	typecheckselect(Node *sel);
  1282  void	walkselect(Node *sel);
  1283  
  1284  /*
  1285   *	sinit.c
  1286   */
  1287  void	anylit(int, Node *n, Node *var, NodeList **init);
  1288  int	gen_as_init(Node *n);
  1289  NodeList*	initfix(NodeList *l);
  1290  int	oaslit(Node *n, NodeList **init);
  1291  int	stataddr(Node *nam, Node *n);
  1292  
  1293  /*
  1294   *	subr.c
  1295   */
  1296  Node*	adddot(Node *n);
  1297  int	adddot1(Sym *s, Type *t, int d, Type **save, int ignorecase);
  1298  void	addinit(Node**, NodeList*);
  1299  Type*	aindex(Node *b, Type *t);
  1300  int	algtype(Type *t);
  1301  int	algtype1(Type *t, Type **bad);
  1302  void	argtype(Node *on, Type *t);
  1303  Node*	assignconv(Node *n, Type *t, char *context);
  1304  int	assignop(Type *src, Type *dst, char **why);
  1305  void	badtype(int o, Type *tl, Type *tr);
  1306  int	brcom(int a);
  1307  int	brrev(int a);
  1308  NodeList*	concat(NodeList *a, NodeList *b);
  1309  int	convertop(Type *src, Type *dst, char **why);
  1310  Node*	copyexpr(Node*, Type*, NodeList**);
  1311  int	count(NodeList *l);
  1312  int	cplxsubtype(int et);
  1313  int	eqtype(Type *t1, Type *t2);
  1314  int	eqtypenoname(Type *t1, Type *t2);
  1315  void	errorexit(void);
  1316  void	expandmeth(Type *t);
  1317  void	fatal(char *fmt, ...);
  1318  void	flusherrors(void);
  1319  void	frame(int context);
  1320  Type*	funcfirst(Iter *s, Type *t);
  1321  Type*	funcnext(Iter *s);
  1322  void	genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface);
  1323  void	genhash(Sym *sym, Type *t);
  1324  void	geneq(Sym *sym, Type *t);
  1325  Type**	getinarg(Type *t);
  1326  Type*	getinargx(Type *t);
  1327  Type**	getoutarg(Type *t);
  1328  Type*	getoutargx(Type *t);
  1329  Type**	getthis(Type *t);
  1330  Type*	getthisx(Type *t);
  1331  int	implements(Type *t, Type *iface, Type **missing, Type **have, int *ptr);
  1332  void	importdot(Pkg *opkg, Node *pack);
  1333  int	is64(Type *t);
  1334  int	isbadimport(Strlit *s);
  1335  int	isblank(Node *n);
  1336  int	isblanksym(Sym *s);
  1337  int	isfixedarray(Type *t);
  1338  int	isideal(Type *t);
  1339  int	isinter(Type *t);
  1340  int	isnil(Node *n);
  1341  int	isnilinter(Type *t);
  1342  int	isptrto(Type *t, int et);
  1343  int	isslice(Type *t);
  1344  int	istype(Type *t, int et);
  1345  void	linehist(char *file, int32 off, int relative);
  1346  NodeList*	list(NodeList *l, Node *n);
  1347  NodeList*	list1(Node *n);
  1348  void	listsort(NodeList**, int(*f)(Node*, Node*));
  1349  Node*	liststmt(NodeList *l);
  1350  NodeList*	listtreecopy(NodeList *l);
  1351  Sym*	lookup(char *name);
  1352  void*	mal(int32 n);
  1353  Type*	maptype(Type *key, Type *val);
  1354  Type*	methtype(Type *t, int mustname);
  1355  Pkg*	mkpkg(Strlit *path);
  1356  Sym*	ngotype(Node *n);
  1357  int	noconv(Type *t1, Type *t2);
  1358  Node*	nod(int op, Node *nleft, Node *nright);
  1359  Node*	nodbool(int b);
  1360  void	nodconst(Node *n, Type *t, int64 v);
  1361  Node*	nodintconst(int64 v);
  1362  Node*	nodfltconst(Mpflt *v);
  1363  Node*	nodnil(void);
  1364  int	parserline(void);
  1365  Sym*	pkglookup(char *name, Pkg *pkg);
  1366  int	powtwo(Node *n);
  1367  Type*	ptrto(Type *t);
  1368  void*	remal(void *p, int32 on, int32 n);
  1369  Sym*	restrictlookup(char *name, Pkg *pkg);
  1370  Node*	safeexpr(Node *n, NodeList **init);
  1371  void	saveerrors(void);
  1372  Node*	cheapexpr(Node *n, NodeList **init);
  1373  Node*	localexpr(Node *n, Type *t, NodeList **init);
  1374  void	saveorignode(Node *n);
  1375  int32	setlineno(Node *n);
  1376  void	setmaxarg(Type *t);
  1377  Type*	shallow(Type *t);
  1378  int	simsimtype(Type *t);
  1379  void	smagic(Magic *m);
  1380  Type*	sortinter(Type *t);
  1381  uint32	stringhash(char *p);
  1382  Strlit*	strlit(char *s);
  1383  int	structcount(Type *t);
  1384  Type*	structfirst(Iter *s, Type **nn);
  1385  Type*	structnext(Iter *s);
  1386  Node*	syslook(char *name, int copy);
  1387  Type*	tounsigned(Type *t);
  1388  Node*	treecopy(Node *n);
  1389  Type*	typ(int et);
  1390  uint32	typehash(Type *t);
  1391  void	ullmancalc(Node *n);
  1392  void	umagic(Magic *m);
  1393  void	warn(char *fmt, ...);
  1394  void	warnl(int line, char *fmt, ...);
  1395  void	yyerror(char *fmt, ...);
  1396  void	yyerrorl(int line, char *fmt, ...);
  1397  
  1398  /*
  1399   *	swt.c
  1400   */
  1401  void	typecheckswitch(Node *n);
  1402  void	walkswitch(Node *sw);
  1403  
  1404  /*
  1405   *	typecheck.c
  1406   */
  1407  int	islvalue(Node *n);
  1408  Node*	typecheck(Node **np, int top);
  1409  void	typechecklist(NodeList *l, int top);
  1410  Node*	typecheckdef(Node *n);
  1411  void	copytype(Node *n, Type *t);
  1412  void	checkreturn(Node*);
  1413  void	queuemethod(Node *n);
  1414  
  1415  /*
  1416   *	unsafe.c
  1417   */
  1418  int	isunsafebuiltin(Node *n);
  1419  Node*	unsafenmagic(Node *n);
  1420  
  1421  /*
  1422   *	walk.c
  1423   */
  1424  Node*	callnew(Type *t);
  1425  Node*	chanfn(char *name, int n, Type *t);
  1426  Node*	mkcall(char *name, Type *t, NodeList **init, ...);
  1427  Node*	mkcall1(Node *fn, Type *t, NodeList **init, ...);
  1428  int	vmatch1(Node *l, Node *r);
  1429  void	walk(Node *fn);
  1430  void	walkexpr(Node **np, NodeList **init);
  1431  void	walkexprlist(NodeList *l, NodeList **init);
  1432  void	walkexprlistsafe(NodeList *l, NodeList **init);
  1433  void	walkstmt(Node **np);
  1434  void	walkstmtlist(NodeList *l);
  1435  Node*	conv(Node*, Type*);
  1436  int	candiscard(Node*);
  1437  
  1438  /*
  1439   *	arch-specific ggen.c/gsubr.c/gobj.c/pgen.c
  1440   */
  1441  #define	P	((Prog*)0)
  1442  
  1443  typedef	struct	Plist	Plist;
  1444  struct	Plist
  1445  {
  1446  	Node*	name;
  1447  	Prog*	firstpc;
  1448  	int	recur;
  1449  	Plist*	link;
  1450  };
  1451  
  1452  EXTERN	Plist*	plist;
  1453  EXTERN	Plist*	plast;
  1454  
  1455  EXTERN	Prog*	continpc;
  1456  EXTERN	Prog*	breakpc;
  1457  EXTERN	Prog*	pc;
  1458  EXTERN	Prog*	firstpc;
  1459  EXTERN	Prog*	retpc;
  1460  
  1461  EXTERN	Node*	nodfp;
  1462  EXTERN	int	disable_checknil;
  1463  
  1464  int	anyregalloc(void);
  1465  void	betypeinit(void);
  1466  void	bgen(Node *n, int true, int likely, Prog *to);
  1467  void	checknil(Node*, NodeList**);
  1468  void	expandchecks(Prog*);
  1469  void	cgen(Node*, Node*);
  1470  void	cgen_asop(Node *n);
  1471  void	cgen_call(Node *n, int proc);
  1472  void	cgen_callinter(Node *n, Node *res, int proc);
  1473  void	cgen_checknil(Node*);
  1474  void	cgen_ret(Node *n);
  1475  void	clearfat(Node *n);
  1476  void	compile(Node*);
  1477  void	defframe(Prog*, Bvec*);
  1478  int	dgostringptr(Sym*, int off, char *str);
  1479  int	dgostrlitptr(Sym*, int off, Strlit*);
  1480  int	dstringptr(Sym *s, int off, char *str);
  1481  int	dsymptr(Sym *s, int off, Sym *x, int xoff);
  1482  int	duintxx(Sym *s, int off, uint64 v, int wid);
  1483  void	dumpdata(void);
  1484  void	dumpfuncs(void);
  1485  void	fixautoused(Prog*);
  1486  void	gdata(Node*, Node*, int);
  1487  void	gdatacomplex(Node*, Mpcplx*);
  1488  void	gdatastring(Node*, Strlit*);
  1489  void	ggloblnod(Node *nam);
  1490  void	ggloblsym(Sym *s, int32 width, int dupok, int rodata);
  1491  Prog*	gjmp(Prog*);
  1492  void	gused(Node*);
  1493  void	movelarge(NodeList*);
  1494  int	isfat(Type*);
  1495  void	markautoused(Prog*);
  1496  Plist*	newplist(void);
  1497  Node*	nodarg(Type*, int);
  1498  void	nopout(Prog*);
  1499  void	patch(Prog*, Prog*);
  1500  Prog*	unpatch(Prog*);
  1501  void	zfile(Biobuf *b, char *p, int n);
  1502  void	zhist(Biobuf *b, int line, vlong offset);
  1503  void	zname(Biobuf *b, Sym *s, int t);
  1504  
  1505  #pragma	varargck	type	"A"	int
  1506  #pragma	varargck	type	"B"	Mpint*
  1507  #pragma	varargck	type	"D"	Addr*
  1508  #pragma	varargck	type	"lD"	Addr*
  1509  #pragma	varargck	type	"E"	int
  1510  #pragma	varargck	type	"E"	uint
  1511  #pragma	varargck	type	"F"	Mpflt*
  1512  #pragma	varargck	type	"H"	NodeList*
  1513  #pragma	varargck	type	"J"	Node*
  1514  #pragma	varargck	type	"lL"	int
  1515  #pragma	varargck	type	"lL"	uint
  1516  #pragma	varargck	type	"L"	int
  1517  #pragma	varargck	type	"L"	uint
  1518  #pragma	varargck	type	"N"	Node*
  1519  #pragma	varargck	type	"lN"	Node*
  1520  #pragma	varargck	type	"O"	uint
  1521  #pragma	varargck	type	"P"	Prog*
  1522  #pragma	varargck	type	"Q"	Bits
  1523  #pragma	varargck	type	"R"	int
  1524  #pragma	varargck	type	"S"	Sym*
  1525  #pragma	varargck	type	"lS"	Sym*
  1526  #pragma	varargck	type	"T"	Type*
  1527  #pragma	varargck	type	"lT"	Type*
  1528  #pragma	varargck	type	"V"	Val*
  1529  #pragma	varargck	type	"Y"	char*
  1530  #pragma	varargck	type	"Z"	Strlit*
  1531  
  1532  /*
  1533   *	racewalk.c
  1534   */
  1535  void	racewalk(Node *fn);