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