1
0
mirror of https://github.com/golang/go synced 2024-10-04 09:21:21 -06:00
Commit Graph

174 Commits

Author SHA1 Message Date
Russ Cox
d30285a6f5 move some portable pieces of 6g/gsubr.c into gc/subr.c
int	brcom(int);
	int	brrev(int);
	void	setmaxarg(Type*);
	Sig*	lsort(Sig*, int(*)(Sig*, Sig*));
	int	dotoffset(Node*, int*, Node**);
	void	stringpool(Node*);
	void	tempname(Node*, Type*);

R=ken
OCL=26922
CL=26922
2009-03-30 17:52:21 -07:00
Russ Cox
5a68303a15 throw away most of the compat.h compatibility layer
in favor of the lib9 compatibility layer.  no need for two.

now that mycreate is gone, .6 files are 0644 not 0755.

TBR=r
OCL=26679
CL=26679
2009-03-24 12:12:57 -07:00
Ken Thompson
0f469a99a3 binary search on type switches.
new feature 'case nil:' in type switch
will match iff the interface is nil.

R=r
OCL=26404
CL=26404
2009-03-17 13:58:38 -07:00
Ken Thompson
5136a9e1f7 change format of Sigt and Sigi
to allow room for type hash
needed for log-time type switch.

R=r
OCL=26354
CL=26354
2009-03-16 15:27:08 -07:00
Russ Cox
8f194bf5ff make 6g constants behave as ken proposes. (i hope.)
various bug fixes and tests involving constants.

test/const1.go is the major new test case.

R=ken
OCL=26216
CL=26224
2009-03-12 19:04:38 -07:00
Ken Thompson
6eb54cb05b chan flags close/closed installed
runtime not finished.

R=r
OCL=26217
CL=26217
2009-03-12 17:55:11 -07:00
Ken Thompson
bb02e481d2 added bitclear operators &^ and &^=
R=r
OCL=26152
CL=26152
2009-03-11 19:59:35 -07:00
Russ Cox
4eb7ceba58 complain when trying to put T into an interface
if T has pointer methods.  this is just a heuristic
but it catches the problem robert ran into and
lets me put the larger interface issues aside for
now.  found one bug in pretty.

R=ken
OCL=26141
CL=26141
2009-03-11 16:06:17 -07:00
Ken Thompson
a4a10ed856 1. type switches
2. fixed fault on bug128
3. got rid of typeof
4. fixed bug in t,ok = I2T

R=r
OCL=25873
CL=25873
2009-03-06 17:50:43 -08:00
Ken Thompson
bf983477a2 new switch implementation
in preparation of type switch.
no functional change (yet).

R=r
OCL=25784
CL=25788
2009-03-05 15:49:34 -08:00
Russ Cox
98b34e5bbd reject invalid map key types at compile time
R=ken
OCL=25720
CL=25720
2009-03-04 17:38:37 -08:00
Russ Cox
49cc649e59 back to T{x}, stricter handling of T(x) vs x.(T)
R=ken
DELTA=131  (60 added, 41 deleted, 30 changed)
OCL=25617
CL=25633
2009-03-03 08:41:02 -08:00
Russ Cox
07244f7c80 add composite literal ( ) syntax.
warn about composite literal { } syntax.

R=ken
OCL=25018
CL=25023
2009-02-13 14:48:16 -08:00
Russ Cox
5f4f5647ef require type assertions when narrowing.
R=ken
OCL=24350
CL=24914
2009-02-11 17:57:29 -08:00
Russ Cox
0970c46863 closures - 6g support
R=ken
OCL=24501
CL=24566
2009-02-06 13:47:10 -08:00
Russ Cox
b0009bef20 bug064
make f(g()) work when g returns multiple
args with names different than f expects.

func swap(a, b int) (c, d int) {
	return b, a
}

swap(swap(1,2))

R=ken
OCL=24474
CL=24476
2009-02-05 15:22:49 -08:00
Russ Cox
5e2c05877d allow methods on funcs.
R=ken
OCL=24442
CL=24442
2009-02-05 13:33:07 -08:00
Russ Cox
360f0aacee fix interface not satisifed message:
x.go:13: T is not I - missing M()

NOT
x.go:13: T is not I - missing Mfunc()

R=ken
OCL=24316
CL=24316
2009-02-04 10:37:11 -08:00
Russ Cox
4a43198390 update compiler to new func rules
R=ken
OCL=23958
CL=23961
2009-01-30 14:39:42 -08:00
Russ Cox
391425ae55 if take address of local, move to heap.
heuristic to not print bogus strings.
fix one error message format.

R=ken
OCL=23849
CL=23851
2009-01-29 17:38:58 -08:00
Russ Cox
282bf8cc8c fix possible infinite recursion in eqtype.
don't use intermediate register to move
32-or-fewer-bit immediate constants
into memory.

R=ken
OCL=23726
CL=23726
2009-01-28 16:42:26 -08:00
Russ Cox
743ac07cc3 change dotdotdot interfaces to be structs,
not pointers to structs.

fix defered dotdotdot.

R=r,ken
DELTA=25  (7 added, 5 deleted, 13 changed)
OCL=23620
CL=23625
2009-01-27 15:05:25 -08:00
Ken Thompson
1e1cc4eb57 defer
R=r
OCL=23592
CL=23592
2009-01-27 12:03:53 -08:00
Russ Cox
a7f6d4066e implement new restrictions on what
can be compared/hashed.

R=r
DELTA=351  (201 added, 80 deleted, 70 changed)
OCL=23423
CL=23481
2009-01-26 09:56:42 -08:00
Russ Cox
61590c4c44 disallow P.t for lowercase t and not our package P.
implement hiding lowercase methods m in
signatures by adding in a hash of the package name
to the type hash code.

remove remaining checks for internally-generated _ names:
they are all gone.

R=ken
OCL=23236
CL=23238
2009-01-21 14:51:57 -08:00
Russ Cox
35e37bbf41 6g: better genembedtramp fatal error,
and don't put inaccessible private methods
   in signature.

R=ken
OCL=23138
CL=23140
2009-01-20 15:36:57 -08:00
Russ Cox
ae167bf08f clean up automatic indirect, delete some dead code.
R=ken
OCL=22454
CL=22457
2009-01-09 15:21:41 -08:00
Russ Cox
316d377ac2 now that TCHAN, TMAP, and TSTRING are real types,
can do methods on them without pointer worries.

R=ken
OCL=22434
CL=22436
2009-01-09 13:50:58 -08:00
Russ Cox
a91af04c06 6g cleanup suggested by ken.
remove TPTR wrapper around TMAP, TCHAN, TSTRING.

R=ken
OCL=22406
CL=22409
2009-01-09 11:13:39 -08:00
Russ Cox
e512481b17 second pass on interface fixes and tests.
R=ken
OCL=22370
CL=22372
2009-01-08 18:06:06 -08:00
Russ Cox
20595ac4b0 many interface bug fixes.
also, after
	func g() (int, int)
	func f(int, int)
allow
	f(g())
and
	func h() (int, int) { return g() }

R=ken
DELTA=356  (252 added, 26 deleted, 78 changed)
OCL=22319
CL=22325
2009-01-08 14:30:00 -08:00
Ken Thompson
88b5c5f0f8 make for slice/map/chan
new for pointers

R=r
OCL=22158
CL=22158
2009-01-06 14:52:26 -08:00
Ken Thompson
b2dfd787d7 allow slices (open arrays) to be
receivers in methods.
put back original code for hilbert/bignum

R=r
OCL=21910
CL=21920
2008-12-30 14:02:20 -08:00
Russ Cox
c3077f7606 [] and struct in interfaces.
other [] cleanup.

convert() is gone.

R=r
DELTA=352  (144 added, 68 deleted, 140 changed)
OCL=21660
CL=21662
2008-12-19 17:11:54 -08:00
Russ Cox
eee50ae1ac chan and map of [] and struct
R=r
DELTA=192  (145 added, 8 deleted, 39 changed)
OCL=21609
CL=21614
2008-12-19 12:05:22 -08:00
Russ Cox
c4416ac06b new error messages
x.go:11: illegal types for operand: AS
	*I
	*T
	(*interface vs *struct)

R=r
DELTA=10  (8 added, 0 deleted, 2 changed)
OCL=21457
CL=21602
2008-12-19 09:03:24 -08:00
Russ Cox
dc7b2e98d2 compiler changes for *chan -> chan; *map -> map; new(T) -> new(*T)
mainly a syntactic change: the compiler representations don't change
(chan and map are now hidden pointers like string).

R=ken
OCL=21578
CL=21582
2008-12-19 03:05:54 -08:00
Russ Cox
92f74ca7e2 [] fixes
R=ken
OCL=21565
CL=21565
2008-12-18 21:11:56 -08:00
Ken Thompson
4026500d18 arrays
R=r
OCL=21564
CL=21564
2008-12-18 20:06:28 -08:00
Ken Thompson
92a1190c6c robs bug converting unsafe.pointer
R=r
OCL=20834
CL=20834
2008-12-09 13:00:50 -08:00
Ken Thompson
b79272d9a2 allowed syntax for range
a range m (implies :=)
a,b range m (implies :=)
a:b range m (implies :=)

a := range m
a,b := range m
a:b := range m

a = range m
a,b = range m
a:b = range m

R=r
OCL=20676
CL=20676
2008-12-06 13:40:30 -08:00
Russ Cox
4656686cf5 use correct lineno in nod even if yacc has looked ahead.
makes lineno correct for statements without semicolons.

R=ken
OCL=19454
CL=19454
2008-11-18 09:32:05 -08:00
Russ Cox
9c7b064043 fix bugs in package locals
R=ken
OCL=19299
CL=19299
2008-11-14 17:31:29 -08:00
Russ Cox
0eda21a2fd change minimum sethi/ullman number to 1
to distinguish not computed (0) vs trivial (1).

add missing ullmancalc on function args.

R=ken
OCL=18711
CL=18711
2008-11-06 14:50:58 -08:00
Russ Cox
9906bfc7bb 6g ninit fixes - fixes the two test cases
i isolated last night.  does not fix rob's
interface-smashing bug.

R=ken
OCL=18698
CL=18698
2008-11-06 13:31:13 -08:00
Ken Thompson
79fbbe37a7 select default
R=r
OCL=18646
CL=18646
2008-11-05 21:50:28 -08:00
Russ Cox
553c98dca4 fix renamed-package bug in exported names:
always show original name

R=ken
OCL=18603
CL=18603
2008-11-05 15:59:34 -08:00
Russ Cox
1983121bbb 6g interface changes:
* allow conversion between nil interface and any type.
	* mark signatures as DUPOK so that multiple .6 can
	  contain sigt.*[]byte and only one gets used.

R=ken
OCL=18538
CL=18542
2008-11-05 11:27:50 -08:00
Russ Cox
c249a8de32 rename various magic names.
sigi and sigt:
	sys·sigi_inter -> sigi·inter
	sys·sigt_int -> sigt·int
	Package·sigt_Type -> sigt·Package.Type

	local type T in file x.go T_x -> T·x
	second one T_x_1 -> T·x·1

	method names M on T  T_M -> T·M

correctly handle local embedded types

init functions are the only place left that use underscores

R=ken
OCL=18377
CL=18377
2008-11-03 15:36:08 -08:00
Ken Thompson
2fef4c7198 DOTDOTDOT import/export
R=r
OCL=18319
CL=18319
2008-11-01 16:52:12 -07:00
Ken Thompson
74427c6346 DOTDOTDOT
R=r
OCL=18317
CL=18317
2008-11-01 16:36:46 -07:00
Russ Cox
8a1ad75644 make %Z handle embedded NULs; remove fixed-size buffer
R=r
DELTA=44  (2 added, 15 deleted, 27 changed)
OCL=18270
CL=18273
2008-10-31 14:57:57 -07:00
Russ Cox
57804f1d2d escape \ in %Z
R=ken
OCL=18202
CL=18202
2008-10-30 17:28:33 -07:00
Russ Cox
dc6bd11ce8 make %Z escape "
R=ken
OCL=18180
CL=18180
2008-10-30 15:35:56 -07:00
Russ Cox
1850b29da6 struct annotations in imports.
distribute tag across multiple names.

R=ken
OCL=18178
CL=18178
2008-10-30 15:25:26 -07:00
Russ Cox
f27aaf4819 structure field annotation strings
R=ken
OCL=18176
CL=18176
2008-10-30 15:13:09 -07:00
Ken Thompson
2f5a05a859 bug 113
R=r
OCL=18081
CL=18081
2008-10-29 16:55:52 -07:00
Ken Thompson
4a3ce5f19e sigt_int
R=r
OCL=18030
CL=18030
2008-10-29 13:40:00 -07:00
Ken Thompson
c21d9a1ec9 the end of life as we know it
int is new type

R=r
OCL=18023
CL=18023
2008-10-29 12:46:44 -07:00
Ken Thompson
a3cdd2e802 bug
R=r
OCL=17853
CL=17853
2008-10-25 14:24:51 -07:00
Ken Thompson
6d3d56d55a bug
R=r
OCL=17852
CL=17852
2008-10-25 13:50:18 -07:00
Ken Thompson
b642cf8c00 embedded methods
R=r
OCL=17851
CL=17851
2008-10-25 13:31:25 -07:00
Ken Thompson
b379d54dea another step toward interface subtypes
put explicit ./ on some runtime tests

R=r
OCL=17839
CL=17839
2008-10-24 20:14:28 -07:00
Russ Cox
689b28fd96 fix method function type compare bug (again)
R=ken
OCL=17819
CL=17819
2008-10-24 14:56:54 -07:00
Russ Cox
c14c961ae4 Automated g4 rollback of changelist 17815.
*** Reason for rollback ***

  now it's comparing function parameter names...

*** Original change description ***

fix method function type compare bug

R=ken
OCL=17816
CL=17816
2008-10-24 14:32:48 -07:00
Russ Cox
0be746d581 fix method function type compare bug
R=ken
OCL=17815
CL=17815
2008-10-24 14:29:01 -07:00
Ken Thompson
7ed8fc611d embedded types
auto & on methods

R=r
OCL=17682
CL=17682
2008-10-22 18:18:08 -07:00
Russ Cox
ad48706a24 do not use fake names on anonymous function return values
R=ken
OCL=17679
CL=17679
2008-10-22 17:45:47 -07:00
Russ Cox
21617250f4 import/export of embedded types
R=ken
OCL=17643
CL=17643
2008-10-22 13:22:56 -07:00
Russ Cox
1a149ca1be stop looking for type names beginning with _.
they're gone.

R=ken
OCL=17569
CL=17569
2008-10-21 14:44:31 -07:00
Russ Cox
aacfbb461b 6g:
* print int as int, not P.int
	* write type info for non-exported types
	   in its own new section.

ar:
	skip over rest of line after $$

R=ken
OCL=17568
CL=17568
2008-10-21 14:34:45 -07:00
Russ Cox
28912ce03f fix compiler warnings
R=r
DELTA=44  (10 added, 9 deleted, 25 changed)
OCL=17502
CL=17502
2008-10-20 15:26:38 -07:00
Russ Cox
1163b1db6f diagnose various conversion problems
R=ken
OCL=17320
CL=17320
2008-10-16 15:59:31 -07:00
Ken Thompson
1bf38484d1 interface on arbitrary types
global signatures for basic types

R=r
OCL=17238
CL=17240
2008-10-15 17:08:10 -07:00
Russ Cox
0adc1db757 until 6g implements it, warn about using int in interface.
R=ken
OCL=16935
CL=16935
2008-10-10 16:14:13 -07:00
Russ Cox
b4f8e01acb more interface checks:
- pointer to interface cannot have methods
	- record type names for better runtime error

R=r,ken
DELTA=85  (80 added, 0 deleted, 5 changed)
OCL=16658
CL=16722
2008-10-08 09:21:57 -07:00
Russ Cox
74e2e087e2 change type names to go live at the name, so that
type T struct {
		next *T
	}

and

	type T *struct {
		next T
	}

are valid without needing forward declarations.

add "type T struct" syntax for forward struct declarations.

add "type T interface" syntax, but commented out
	(need to fix semicolons first)

R=ken
DELTA=452  (259 added, 115 deleted, 78 changed)
OCL=16580
CL=16584
2008-10-06 16:44:17 -07:00
Ken Thompson
f25843e65e bug 026
R=r
OCL=16494
CL=16494
2008-10-04 15:17:49 -07:00
Russ Cox
45f4e38506 silence gcc warnings
R=ken
OCL=16449
CL=16466
2008-10-03 16:23:02 -07:00
Russ Cox
b8babed7c2 new import/export format
package flag
	export type flag.Flag struct { name flag.string; usage flag.string; \
		value flag.Value; next *flag.Flag }
	type flag.string string
	type flag.Value interface { AsBool () (? *flag.BoolValue); \
		AsInt () (? *flag.IntValue); AsString () (? *flag.StringValue); \
		IsBool () (? flag.bool); IsInt () (? flag.bool); IsString () (? flag.bool); \
		Str () (? flag.string); ValidValue (str flag.string) (? flag.bool) }
	type flag.BoolValue struct { val flag.bool; p *flag.bool }
	type flag.IntValue struct { val flag.int64; p *flag.int64 }
	type flag.StringValue struct { val flag.string; p *flag.string }
	type flag.bool bool
	func (e *flag.StringValue) AsBool () (? *flag.BoolValue)
	func (e *flag.StringValue) AsInt () (? *flag.IntValue)
	...

the \ continuations are for this message, not real.

changed delimiter for import from (( )) to $$ $$.

replaced mksys.bash with mksys.c

changed sys.go to use leading export,
	fake package name is now SYS not foop

don't always require ; on forward func decls

R=ken,r
DELTA=1827  (446 added, 1083 deleted, 298 changed)
OCL=16433
CL=16463
2008-10-03 16:15:55 -07:00
Ken Thompson
8877d27b40 interfaces of all types
R=r
OCL=16462
CL=16462
2008-10-03 16:12:21 -07:00
Ken Thompson
ed139c1e37 more on arbitrary receiver types
this CL passes the tests, but should
be considered unstable

R=r
OCL=16390
CL=16390
2008-10-02 20:51:10 -07:00
Ken Thompson
f21e731c71 added printn and panicn
prints that insert spaces and new line

R=r
OCL=16370
CL=16370
2008-10-02 14:38:07 -07:00
Russ Cox
8dc08788ef remove ( ) around mismatch type prints,
so that they don't look like functions.

R=ken
OCL=16244
CL=16244
2008-09-30 15:38:41 -07:00
Russ Cox
387c1bc31e pretty types; use 6g -t to disable
R=ken
OCL=16240
CL=16242
2008-09-30 15:35:40 -07:00
Russ Cox
4d571c9093 fix up arg list parsing to handle any names:
type t1 int;
type t2 int;
type t3 int;
func f1(t1, t2, t3);
func f2(t1, t2, t3 bool);
func f3(t1, t2, x t3);
func f4(*t2, x t3);	// error: cannot mix
func f5(t1, *t3);
func (x *t1) f6(y *[]t2) (t1, *t3);
func f7() (int, *string);
func f8(t1, *t2, x t3);	// error: cannot mix
func f9() (x int, *string);
func f10(*t2, t3);

R=ken
OCL=16202
CL=16210
2008-09-30 12:53:11 -07:00
Ken Thompson
89ac5618ac toward methods on any type
R=r
OCL=16068
CL=16068
2008-09-28 20:22:31 -07:00
Ken Thompson
4332e0a546 remove extraneous print
R=r
OCL=15666
CL=15666
2008-09-22 17:29:12 -07:00
Ken Thompson
8231e94520 now method/interface code
R=r
OCL=15627
CL=15627
2008-09-22 12:16:19 -07:00
Ken Thompson
39a4b1421f bug103 - but the fix caused other
things to break. hopefully all fixed
now.

R=r
OCL=15597
CL=15597
2008-09-20 14:59:15 -07:00
Ken Thompson
9dbaab54d1 rewriting bugs
R=r
OCL=14810
CL=14810
2008-09-04 12:21:10 -07:00
Ken Thompson
182f91ffe0 map literals
R=r
OCL=14759
CL=14759
2008-09-03 14:40:22 -07:00
Ken Thompson
4539ced714 array literals
R=r
OCL=14756
CL=14756
2008-09-03 14:09:29 -07:00
Ken Thompson
1423bf3dc4 structure literals
R=r
OCL=14735
CL=14735
2008-09-02 19:11:25 -07:00
Ken Thompson
9c5669bd0b bug in conv(string, bytearray)
R=r
OCL=14732
CL=14732
2008-09-02 16:21:30 -07:00
Ken Thompson
c6130e9f1f get rid of static/dynamic array distinction
R=r
OCL=14634
CL=14634
2008-08-28 15:17:37 -07:00
Ken Thompson
66a603c986 arrays
R=r
OCL=14603
CL=14603
2008-08-27 17:28:30 -07:00
Ken Thompson
4797523572 fixed bugs in const/case
R=r
DELTA=138  (75 added, 12 deleted, 51 changed)
OCL=14129
CL=14131
2008-08-12 14:04:03 -07:00
Ken Thompson
2b75556436 export large constants
R=r
DELTA=37  (31 added, 4 deleted, 2 changed)
OCL=14089
CL=14089
2008-08-11 13:22:04 -07:00
Ken Thompson
9c2ade358d mp constants
R=r
DELTA=381  (142 added, 26 deleted, 213 changed)
OCL=14011
CL=14016
2008-08-08 17:13:31 -07:00