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

579 Commits

Author SHA1 Message Date
Russ Cox
75fe1303c1 maps have == so maps are okay as map keys.
alignment issue is fixed.

R=ken
OCL=31124
CL=31144
2009-07-03 09:44:59 -07:00
Russ Cox
20cfa4a568 change alignment rules: roll receiver into
input parameters, move output parameters
into their own struct.

R=ken
OCL=30954
CL=30966
2009-06-30 20:02:07 -07:00
Russ Cox
5d5904bb4d bug163 bug164 bug166
R=ken
OCL=30889
CL=30889
2009-06-29 17:46:22 -07:00
Russ Cox
9435dc2bdf allow forward declaration of struct in another file
(in the same package).

allow forward method declaration to be satisfied
by implementation in another file (in the same package).
all methods must be declared in the same file
as the receiver type.

R=ken
OCL=30864
CL=30869
2009-06-29 15:13:37 -07:00
Russ Cox
480f51243c bug165
R=ken
OCL=30783
CL=30783
2009-06-25 21:02:39 -07:00
Russ Cox
70e232e668 separate local path lookup from standard package directories
R=ken
OCL=30760
CL=30779
2009-06-25 20:15:56 -07:00
Russ Cox
5851a1b5ad allow
package main
type t interface
type t interface{ m(map[t]bool) }
type m map[t] int

making it work without the forward declaration will require a second pass.

R=ken
OCL=30773
CL=30773
2009-06-25 18:19:05 -07:00
Russ Cox
1ea28570ec the any fix was too aggressive; allow any in any import.
R=ken
OCL=30768
CL=30768
2009-06-25 16:57:56 -07:00
Russ Cox
fa6df47986 package main
const foo = []int{1,2}

x.go:3: expression must be a constant

instead of

x.go:3: fatal error: gettype: addtop

R=ken
OCL=30767
CL=30767
2009-06-25 16:42:08 -07:00
Russ Cox
70a273476b better error; clean up lineno in a few places
wreck.mtv=; cat x.go
package main
var x = string.Split()
wreck.mtv=; 6g x.go
x.go:2: type string used as expression
x.go:2: undefined DOT Split on string
x.go:3: illegal types for operand: AS
	undefined
wreck.mtv=;

BUG=1938751
R=ken
OCL=30766
CL=30766
2009-06-25 16:32:33 -07:00
Russ Cox
4bce6d455f package main
func foo(y) { }

was:
x.go:2: NONAME-y G0 u(1) a(1) l(77) x(-1000000000) is not a type

now:
x.go:2: y is not a type

R=ken
OCL=30764
CL=30764
2009-06-25 16:25:06 -07:00
Russ Cox
30f2799f88 disable "any" except during canned imports.
new flag -A enables it during mkbuiltin.
avoids mysterious errors in programs
that refer to any accidentally.

R=ken
OCL=30763
CL=30763
2009-06-25 16:22:46 -07:00
Russ Cox
111ae83bb7 6g: update for spec change CL 30586
R=ken
OCL=30593
CL=30756
2009-06-25 14:44:45 -07:00
Ken Thompson
466dd8da4e 6g crash re mail from gri jun 18.
R=r
OCL=30719
CL=30719
2009-06-24 17:50:25 -07:00
Russ Cox
0aef57e37f fix a 6g crash after type errors.
do not bother warning about marks left
on stack after syntax errors.

leave OCONV nodes in tree to avoid type errors
arising from multiple walks.

R=ken
OCL=30639
CL=30662
2009-06-23 15:30:59 -07:00
Russ Cox
7f3eb2738f implement new spec language regarding conversions
R=ken
OCL=30519
CL=30534
2009-06-19 14:00:53 -07:00
Ken Thompson
eba82f4391 better diagnostics for eof in a string.
this assumes that embedded newlines are
legal in back-quote strings.

R=r
OCL=30502
CL=30502
2009-06-18 15:49:41 -07:00
Russ Cox
30a28aec25 b/1909731
package main
func f(a *c.b) {}
func main() {}

BUG=1909731
R=ken
OCL=30322
CL=30322
2009-06-15 20:15:59 -07:00
Russ Cox
8abcdee175 implement optional semicolons with help from the lexer,
instead of having to double the type and statement grammars.

R=ken
OCL=29987
CL=29998
2009-06-06 19:27:48 -07:00
Russ Cox
8f4af6d205 gc: grammar cleanup:
* no longer distinguishes const, var, type, package names.
  * all the predefined names are not tokens anymore.

R=ken
OCL=29326
CL=29985
2009-06-06 12:46:38 -07:00
Russ Cox
01fe6a9c58 more build refinements:
* use new Make.$GOARCH files in gobuild.
 * rename 6ar to arch-generic gopack.
 * place objects in $GOROOT/pkg/$GOOS_$GOARCH
   (makes cross-compiling easier, and no one
   ever types these paths by hand anyway).

R=r
DELTA=29  (6 added, 8 deleted, 15 changed)
OCL=29923
CL=29967
2009-06-05 22:18:32 -07:00
Russ Cox
6609d2f88d restructure makefiles, scripts to factor out O= logic.
remove a few hardcoded paths elsewhere too.

R=r,gri
DELTA=123  (44 added, 15 deleted, 64 changed)
OCL=29914
CL=29945
2009-06-05 10:59:55 -07:00
Russ Cox
2f2577a4f6 bug161, fixed
R=ken
OCL=29907
CL=29907
2009-06-04 16:18:13 -07:00
Russ Cox
9a9ffb2b0e more 8g progress.
likely to go back to registers for most temporaries.

most tests in lib pass.  these fail:

	datafmt
	fmt
	go/scanner
	log
	reflect
	strconv
	template

R=ken
OCL=29896
CL=29898
2009-06-04 15:24:01 -07:00
Russ Cox
f51ca384eb fix handling of floating point zero constant 0p+0
R=r
DELTA=25  (25 added, 0 deleted, 0 changed)
OCL=29875
CL=29875
2009-06-04 11:06:37 -07:00
Russ Cox
ea7f5505d1 zero struct in T{}
R=ken
OCL=29849
CL=29849
2009-06-03 16:10:13 -07:00
Russ Cox
f1f970ad21 minor cleanup, 64-bit /= and %= on 32-bit
R=ken
OCL=29806
CL=29808
2009-06-02 23:21:58 -07:00
Ken Thompson
c17ce9f94f prevent multiple similar errors
in complex literals. side effect is
fix of error in initializerr.go

R=r
OCL=29667
CL=29667
2009-05-31 13:02:24 -07:00
Russ Cox
d6a9817051 bug157
R=ken
OCL=29651
CL=29653
2009-05-30 21:18:15 -07:00
Ken Thompson
be63b6dc44 bug 158
R=r
OCL=29646
CL=29646
2009-05-30 17:06:51 -07:00
Ken Thompson
fbcbcdbb1d bug 156
R=r
OCL=29623
CL=29623
2009-05-29 15:34:47 -07:00
Ken Thompson
3b37b02834 bug 149
R=r
OCL=29612
CL=29612
2009-05-29 13:44:30 -07:00
Russ Cox
0a6d83567e print uint64 as uint64.
R=ken
OCL=29568
CL=29570
2009-05-28 22:24:03 -07:00
Ken Thompson
e2613711aa detect recursive initialization
R=r
OCL=29544
CL=29544
2009-05-28 16:00:55 -07:00
Russ Cox
3aa006b8cd better 64-bit handling in 8g.
fewer moves, fewer stupid LEALs.
powser1 runs (with evaln commented out).
beginnings of floating point.

R=ken
OCL=29540
CL=29543
2009-05-28 15:48:47 -07:00
Russ Cox
e81d97ea84 clean up gmove:
* conversions all in one place.
	* no separate load, store phases;
	  direct memory addressing when possible
	  (this is the x86 after all!).
	  avoids extra registers, extra MOVQs.
	* fixes int32 -> uint64 bug
	  (was zero-extending)

R=ken
OCL=29482
CL=29484
2009-05-27 23:55:14 -07:00
Ken Thompson
b3f303ec9a bug 153
R=r
OCL=29479
CL=29479
2009-05-27 18:37:02 -07:00
Ken Thompson
64c3fe05bf string([]int) conversion
R=r
OCL=29466
CL=29466
2009-05-27 15:38:02 -07:00
Russ Cox
18890eebbf fix bug154; tweak bug153 exit status
R=ken
OCL=29448
CL=29448
2009-05-27 10:16:13 -07:00
Russ Cox
a8e4ed6a3d 8g: 64-bit arithmetic and assorted bug fixes;
can run 64-bit sieve and powser.
interfaces are limping along.
next hurdle is floating point.

R=ken
OCL=29418
CL=29423
2009-05-26 21:07:26 -07:00
Ken Thompson
b46e7c4d3c bug 152
R=r
OCL=29419
CL=29419
2009-05-26 19:48:39 -07:00
Ken Thompson
51ddddc67e bug 151
R=r
OCL=29409
CL=29409
2009-05-26 16:30:35 -07:00
Ken Thompson
850cd6a2fe bug 150
R=r
OCL=29405
CL=29405
2009-05-26 15:56:37 -07:00
Russ Cox
021abfbd28 8g: hello world works again
* string format changed
	* files got renamed
	* new files that i forgot to check in last time
updates are all copy and paste from 6g

R=ken
OCL=29385
CL=29400
2009-05-26 14:46:06 -07:00
Ken Thompson
802e1a6104 static init reenabled
R=r
OCL=29358
CL=29358
2009-05-25 19:40:41 -07:00
Ken Thompson
4238b18344 1. check for dups in complex literals
structtype{a:1, a:2}
   maptypetype{"xx":1, "xx":2}
   arraytypetype{5:1, 5:2}
2. bug in registerization concerning
   alias of a struct and one of its elements
3. code optimization of struct.field
   (which exposed bug in 2)

R=r
OCL=29315
CL=29315
2009-05-23 15:34:29 -07:00
Russ Cox
4beac9985b simplifying grammar: delete LBASETYPE and LACONST.
take 2

R=ken
OCL=29304
CL=29306
2009-05-22 22:46:06 -07:00
Russ Cox
ca2fe5d8bd Automated g4 rollback of changelist 29302.
*** Reason for rollback ***

too many files included

*** Original change description ***

simplifying grammar: delete LBASETYPE and LACONST

R=ken
OCL=29303
CL=29303
2009-05-22 22:43:57 -07:00
Russ Cox
2a4dcfffc9 simplifying grammar: delete LBASETYPE and LACONST
R=ken
OCL=29300
CL=29302
2009-05-22 22:42:12 -07:00
Russ Cox
f4d3d22a94 enforce channel direction
R=ken
OCL=29209
CL=29216
2009-05-21 17:32:44 -07:00
Russ Cox
c2fa45b973 allow type name as key to accomodate anonymous fields.
update tests.

R=ken
OCL=29207
CL=29207
2009-05-21 16:31:10 -07:00
Ken Thompson
bba10b3f49 some array init bugs
renamed 6g/(gen|align|obj).c

R=r
OCL=29205
CL=29205
2009-05-21 15:44:06 -07:00
Russ Cox
8b6b380605 stricter rules for assignment.
when assigning a multifield object
(structs or arrays of structs) they
must not contain any fields that could
not be assigned individually.

R=ken
OCL=29192
CL=29194
2009-05-21 14:06:24 -07:00
Ken Thompson
a016081f43 added key:val extension to
structure and array literals

R=r
OCL=29190
CL=29190
2009-05-21 13:46:07 -07:00
Russ Cox
23e62d169f stricter interface conversion rule: i.(T)
must have non-nil i.

R=ken
OCL=29136
CL=29136
2009-05-20 18:23:19 -07:00
Russ Cox
a39bae095a ifaceop was being called with integers
that came from two different enums.
spilt into ifacecvt and ifaceop depending
on which enum the argument is.

R=ken
OCL=29122
CL=29122
2009-05-20 15:09:50 -07:00
Russ Cox
2da5022bcf change representation of interface values.
this is not a user-visible change.

before, all interface values were

	struct Itype {
		Sigt *type;
		Sigi *inter;
		void *method[n];
	}

	struct Iface {
		void *addr;
		Itype *itype;
	}

the itype is basically a vtable, but it's unnecessary
if the static type is interface{ }.
for interface values with static type empty, the
new representation is

	struct Eface {
		void *addr;
		Sigt *type;
	}

this complicates the code somewhat, but
it reduces the number of Itypes that
have to be computed and cached,
it opens up opportunities to avoid function
calls in a few common cases,
and it will make it possible to lay out
interface{} values at compile time,
which i think i'll need for the new reflection.

R=ken
OCL=28701
CL=29121
2009-05-20 14:57:55 -07:00
Russ Cox
47e5152790 fix implicit star for range on *map, *[].
do not update lineno from ONAME nodes,
	because they have declaration lineno not use.
show actual name in top-level statement error.

before
runtime.a:7: x.go:5: walkstate: NAME not a top level statement

after
x.go:14: walkstate: runtime.Goexit not a top level statement

R=ken
OCL=29113
CL=29116
2009-05-20 14:24:23 -07:00
Ken Thompson
b91a043d02 static initialization of slices
R=r
OCL=29016
CL=29016
2009-05-18 22:11:22 -07:00
Ken Thompson
62231e91d0 static initialization with DATA statements
structs and arrays are done
slices and maps are yet to do

R=r
OCL=28977
CL=28977
2009-05-17 19:16:16 -07:00
Ken Thompson
52b0f77bf9 static initialization
structure set up - no change yet

R=r
OCL=28966
CL=28966
2009-05-16 13:29:08 -07:00
Rob Pike
a8db4593ab fix spelling error in message
R=ken
OCL=28814
CL=28814
2009-05-14 09:59:16 -07:00
Russ Cox
d06a79e31b no need for compiler to hard-code definition of runtime.
use the actual go source instead.

R=r
DELTA=90  (66 added, 18 deleted, 6 changed)
OCL=28708
CL=28719
2009-05-12 16:15:52 -07:00
Russ Cox
b3533dfd72 6g:
new type equality restrictions
	better handling of renamed packages
	"sys" is no longer available to programs

R=ken
OCL=28553
CL=28578
2009-05-08 15:40:31 -07:00
Russ Cox
918afd9491 move things out of sys into os and runtime
R=r
OCL=28569
CL=28573
2009-05-08 15:21:41 -07:00
Rob Pike
c367d1b789 Move sys.Reflect and sys.Unreflect into unsafe.
R=rsc
DELTA=19  (4 added, 5 deleted, 10 changed)
OCL=28563
CL=28566
2009-05-08 14:57:56 -07:00
Russ Cox
d4fa253837 eqtype(t1, t2, 0) => eqtype(t1, t2)
R=ken
OCL=28559
CL=28562
2009-05-08 14:40:38 -07:00
Russ Cox
401a95aa83 if a struct s contains an anonymous interface value
with method m, s.m() is ok and m now shows up
in s's method set for interface runtime.

see http://cl/28419-p2 for new test interface10.go.

R=ken
OCL=28420
CL=28423
2009-05-07 13:42:47 -07:00
Russ Cox
88a1aa8e1a 6g: error messages
part 2; missing files

R=ken
OCL=28408
CL=28410
2009-05-07 10:30:22 -07:00
Russ Cox
b5e212ffdd 6g: error messages
replace "shape error across CALL" with more information.

x.go:7: not enough arguments to CALL
	a int, b int
	int
x.go:10: assignment count mismatch: 3 = 2
x.go:12: too many arguments to RETURN
	[no arguments expected]
	int, int, int

also leave type alone after conversion failure,
for later errors:

bug049.go:6: cannot convert nil constant to string
bug049.go:6: illegal types for operand: EQ
	string
	nil		# this used to be blank

R=ken
OCL=28405
CL=28407
2009-05-07 10:29:35 -07:00
Russ Cox
a6ba5ec535 6g: new interface rules (code got simpler!)
R=ken
OCL=28374
CL=28378
2009-05-06 17:05:35 -07:00
Russ Cox
83cd4ee070 6g: generate string data as individual symbols,
so that 6l can discard strings used by dead code.
also, for short strings, generate DUPOK global
symbols so that references to, say, "%s: %s" in
multiple files result in only a single symbol.

R=ken
OCL=28361
CL=28361
2009-05-06 13:47:40 -07:00
Ken Thompson
c4de24981a signs on div and mod
R=r
OCL=28319
CL=28319
2009-05-05 21:19:58 -07:00
Russ Cox
3e9b171b79 6g bug: was dropping assignment of nil to globals
R=ken
OCL=28314
CL=28314
2009-05-05 17:33:51 -07:00
Russ Cox
f821e3c7c3 6g tweaks
* byteastring is no longer used
	* do not generate ODCL, OAS for globals
	  (wasn't generating any code but might
	  save one or two init functions)
	* do not call self from Init function

R=ken
OCL=28309
CL=28309
2009-05-05 16:53:46 -07:00
Ken Thompson
567a7bf664 more code optimization
1. dont clear external and heap objects
2. propagate constant assignment

R=r
OCL=28254
CL=28254
2009-05-04 21:48:46 -07:00
Ken Thompson
49f7494894 code optmization
drip init function if it doesnt do anything

R=r
OCL=28180
CL=28180
2009-05-01 18:55:16 -07:00
Russ Cox
83e976d53e bug146: array/slice conversion before I left missed conversions
R=ken
OCL=28120
CL=28124
2009-04-30 13:49:58 -07:00
Ken Thompson
7a98315c96 allow "defer close(chan)"
bug found by anton

R=r
OCL=28001
CL=28001
2009-04-28 17:20:18 -07:00
Ken Thompson
ad36c39211 bug 145
R=r
OCL=27979
CL=27979
2009-04-28 12:28:31 -07:00
Ken Thompson
b03b541b7a recognize a defined constant
as a new name in a later declaration
(bug 144)

R=r
OCL=27850
CL=27850
2009-04-24 16:43:31 -07:00
Ken Thompson
190a540892 2 minor bugs.
lv context for some [] operations
calling implicit(*map) before walk.

R=r
OCL=27706
CL=27706
2009-04-21 19:52:13 -07:00
Ken Thompson
b5e7562191 supply default indirection to
map indexing - bug 143

R=r
OCL=27695
CL=27695
2009-04-21 17:00:08 -07:00
Ken Thompson
34b6f642de mixed old/new declaration
exact spec:
a) must be a multi-assignment w :=
b) a proper subset of the lhs
   can be declared in same block
   with the same type with no
   "redeclaration" error

R=r
OCL=27610
CL=27610
2009-04-18 13:58:04 -07:00
Russ Cox
3ea8d854a3 make string(array) take []byte only (and thus *[10]byte but not [10]byte)
R=ken
OCL=27581
CL=27585
2009-04-16 23:07:30 -07:00
Russ Cox
1cb3b7d124 panicln: emit just one newline
R=ken
OCL=27537
CL=27545
2009-04-15 22:38:09 -07:00
Russ Cox
65d397f747 compiler implementation of array slice change
R=ken
OCL=27533
CL=27533
2009-04-15 20:27:22 -07:00
Russ Cox
935953a9f8 tweak interface warning heuristic.
some day i will fix this for real.

R=ken
OCL=27468
CL=27468
2009-04-14 19:57:27 -07:00
Russ Cox
a62467af93 fix stringrange test
R=ken
OCL=27353
CL=27353
2009-04-13 05:31:44 -07:00
Ken Thompson
a91a8042b4 range over strings
R=r
OCL=27332
CL=27332
2009-04-10 19:49:31 -07:00
Ken Thompson
3657061550 change representation of strings
R=r
OCL=27293
CL=27293
2009-04-09 18:16:21 -07:00
Russ Cox
f95da9a639 yet another attempt at auto-linking
store only the original import path string (+ .a)
if 6g resolves it to an archive file.
let 6l re-resolve the .a at link time.

this lets libraries build against an archive
in the current directory but get used
against an installed archive.

R=r
OCL=27244
CL=27244
2009-04-08 22:45:33 -07:00
Russ Cox
3067781ab9 func f() (int, int);
x := f();

used to give
	fatal error: dowidth fn struct struct { int; int }

now gives
	assignment count mismatch: 1 = 2

R=ken
OCL=27198
CL=27201
2009-04-07 22:20:37 -07:00
Russ Cox
d50c70d261 set line number for errors produced during walkstate.
R=ken
OCL=27145
CL=27145
2009-04-06 22:17:46 -07:00
Russ Cox
907cb4f1e6 fix both of anton's bugs:
* make([100]int) was being compiled to
	make([]int), kind of.
* []this = [100]that was working for any this, that.

turned up a typo in pipe_test.go

R=ken
OCL=27081
CL=27081
2009-04-03 23:20:51 -07:00
Russ Cox
39436f2a74 special case check for this situation
; cat >http.go
	package main
	import "http"  // intended the library, not this file
	^D
	; 6g http.go
	; 6g http.go
	http.go:4: export/package mismatch: init
	;

new error:

	http.6:7 http.go:3: cannot import package main

R=ken
OCL=27053
CL=27053
2009-04-02 21:46:19 -07:00
Russ Cox
07687705a4 type n t;
was copying a bit too much about t into n,
like whether the signature was queued to be printed.
(bug reported by anton)

was also editing t, meaning you could do
	type T int;
	func (p int) Meth() { }

both fixed.

R=ken
OCL=27052
CL=27052
2009-04-02 21:38:11 -07:00
Russ Cox
416b27548e use _f007·filename for func literals.
this avoids problems people have run into with
multiple closures in the same package.

when preparing filename, only cut off .go, not .anything.
this fixes a bug tgs ran into with foo.pb.go and foo.go
in the same package.

also turn bad identifier chars from filename into
underscores: a-b.pb.go => a_b_pb

R=ken
OCL=27050
CL=27050
2009-04-02 18:32:57 -07:00
Ken Thompson
9efd6b8a3d compiler falut for forgetting
the assignment on a type switch

R=r
OCL=27048
CL=27048
2009-04-02 18:06:43 -07:00
Russ Cox
58f5f4f18d use separate lex buf for better errors:
package main
func main() { func(){}() + + }

x.go:2: syntax error near _f001

becomes

x.go:2: syntax error near func

R=ken
OCL=27047
CL=27047
2009-04-02 17:59:09 -07:00