diff options
Diffstat (limited to 'test')
53 files changed, 150 insertions, 156 deletions
diff --git a/test/235.go b/test/235.go index 47d6b58ac..4ff7c30c8 100644 --- a/test/235.go +++ b/test/235.go @@ -8,10 +8,10 @@ package main type T chan uint64; -func M(f uint64) (in, out *T) { +func M(f uint64) (in, out T) { in = new(T, 100); out = new(T, 100); - go func(in, out *T, f uint64) { + go func(in, out T, f uint64) { for { out <- f * <-in; } @@ -44,8 +44,8 @@ func main() { 1250, 1280, 1296, 1350, 1440, 1458, 1500, 1536, 1600 }; x := uint64(1); - ins := new([]*T, n); - outs := new([]*T, n); + ins := new([]T, n); + outs := new([]T, n); xs := new([]uint64, n); for i := 0; i < n; i++ { ins[i], outs[i] = M(F[i]); @@ -61,7 +61,7 @@ func main() { for i := 0; i < n; i++ { if xs[i] == x { xs[i] = <- outs[i]; } } - + x = min(xs); if x != OUT[i] { panic("bad: ", x, " should be ", OUT[i]); } } diff --git a/test/bugs/bug121.go b/test/bugs/bug121.go index cc960e318..cea6f1b70 100644 --- a/test/bugs/bug121.go +++ b/test/bugs/bug121.go @@ -21,5 +21,5 @@ func (s *S) g() {} func (s *S) h() {} // here we can't write (s *S) T either func main() { - var i I = new(S); + var i I = new(*S); } diff --git a/test/chan/fifo.go b/test/chan/fifo.go index 1152a6d66..eef494dd6 100644 --- a/test/chan/fifo.go +++ b/test/chan/fifo.go @@ -23,7 +23,7 @@ func AsynchFifo() { } } -func Chain(ch *<-chan int, val int, in *<-chan int, out *chan<- int) { +func Chain(ch <-chan int, val int, in <-chan int, out chan<- int) { <-in; if <-ch != val { panic(val) diff --git a/test/chan/goroutines.go b/test/chan/goroutines.go index 3fd80f29b..afc5ead30 100644 --- a/test/chan/goroutines.go +++ b/test/chan/goroutines.go @@ -14,7 +14,7 @@ import ( "strconv"; ) -func f(left, right *chan int) { +func f(left, right chan int) { left <- <-right; } @@ -36,6 +36,6 @@ func main() { go f(left, right); left = right; } - go func(c *chan int) { c <- 1 }(right); + go func(c chan int) { c <- 1 }(right); <-leftmost; } diff --git a/test/chan/nonblock.go b/test/chan/nonblock.go index 5622e8382..4d36bdbbf 100644 --- a/test/chan/nonblock.go +++ b/test/chan/nonblock.go @@ -13,35 +13,35 @@ func pause() { for i:=0; i<100; i++ { sys.gosched() } } -func i32receiver(c *chan int32) { +func i32receiver(c chan int32) { if <-c != 123 { panic("i32 value") } } -func i32sender(c *chan int32) { +func i32sender(c chan int32) { c <- 234 } -func i64receiver(c *chan int64) { +func i64receiver(c chan int64) { if <-c != 123456 { panic("i64 value") } } -func i64sender(c *chan int64) { +func i64sender(c chan int64) { c <- 234567 } -func breceiver(c *chan bool) { +func breceiver(c chan bool) { if ! <-c { panic("b value") } } -func bsender(c *chan bool) { +func bsender(c chan bool) { c <- true } -func sreceiver(c *chan string) { +func sreceiver(c chan string) { if <-c != "hello" { panic("s value") } } -func ssender(c *chan string) { +func ssender(c chan string) { c <- "hello again" } @@ -57,19 +57,19 @@ func main() { c64 := new(chan int64, buffer); cb := new(chan bool, buffer); cs := new(chan string, buffer); - + i32, ok = <-c32; if ok { panic("blocked i32sender") } - + i64, ok = <-c64; if ok { panic("blocked i64sender") } - + b, ok = <-cb; if ok { panic("blocked bsender") } - + s, ok = <-cs; if ok { panic("blocked ssender") } - + go i32receiver(c32); pause(); ok = c32 <- 123; @@ -79,7 +79,7 @@ func main() { i32, ok = <-c32; if !ok { panic("i32sender") } if i32 != 234 { panic("i32sender value") } - + go i64receiver(c64); pause(); ok = c64 <- 123456; @@ -89,7 +89,7 @@ func main() { i64, ok = <-c64; if !ok { panic("i64sender") } if i64 != 234567 { panic("i64sender value") } - + go breceiver(cb); pause(); ok = cb <- true; @@ -99,7 +99,7 @@ func main() { b, ok = <-cb; if !ok { panic("bsender") } if !b{ panic("bsender value") } - + go sreceiver(cs); pause(); ok = cs <- "hello"; diff --git a/test/chan/powser1.go b/test/chan/powser1.go index 8222de039..a010f6995 100644 --- a/test/chan/powser1.go +++ b/test/chan/powser1.go @@ -30,8 +30,8 @@ func (u *rat) eq(c item) bool { } type dch struct { - req *chan int; - dat *chan item; + req chan int; + dat chan item; nam int; } @@ -46,7 +46,7 @@ func Init(); func mkdch() *dch { c := chnameserial % len(chnames); chnameserial++; - d := new(dch); + d := new(*dch); d.req = new(chan int); d.dat = new(chan item); d.nam = c; @@ -54,7 +54,7 @@ func mkdch() *dch { } func mkdch2() *dch2 { - d2 := new(dch2); + d2 := new(*dch2); d2[0] = mkdch(); d2[1] = mkdch(); return d2; @@ -74,7 +74,7 @@ func mkdch2() *dch2 { // a signal on the release-wait channel tells the next newer // generation to begin servicing out[1]. -func dosplit(in *dch, out *dch2, wait *chan int ){ +func dosplit(in *dch, out *dch2, wait chan int ){ var t *dch; both := false; // do not service both channels @@ -127,9 +127,9 @@ func get(in *dch) *rat { func getn(in []*dch, n int) []item { // BUG n:=len(in); if n != 2 { panic("bad n in getn") }; - req := new([2] *chan int); - dat := new([2] *chan item); - out := new([2] item); + req := new(*[2] chan int); + dat := new(*[2] chan item); + out := new([]item, 2); var i int; var it item; for i=0; i<n; i++ { @@ -159,11 +159,8 @@ func getn(in []*dch, n int) []item { // Get one item from each of 2 demand channels -func get2(in0 *dch, in1 *dch) []item { - x := new([2] *dch); - x[0] = in0; - x[1] = in1; - return getn(x, 2); +func get2(in0 *dch, in1 *dch) []item { + return getn([]*dch{in0, in1}, 2); } func copy(in *dch, out *dch){ @@ -211,7 +208,7 @@ func gcd (u, v int64) int64{ func i2tor(u, v int64) *rat{ g := gcd(u,v); - r := new(rat); + r := new(*rat); if v > 0 { r.num = u/g; r.den = v/g; @@ -249,7 +246,7 @@ func add(u, v *rat) *rat { func mul(u, v *rat) *rat{ g1 := gcd(u.num,v.den); g2 := gcd(u.den,v.num); - r := new(rat); + r := new(*rat); r.num =(u.num/g1)*(v.num/g2); r.den = (u.den/g2)*(v.den/g1); return r; @@ -649,7 +646,7 @@ func main() { check(Ones, one, 5, "Ones"); check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones"); // 1 1 1 1 1 check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos"); // 3 3 3 3 3 - a := new([N] *rat); + a := new([] *rat, N); d := Diff(Ones); // BUG: want array initializer for i:=0; i < N; i++ { diff --git a/test/chan/powser2.go b/test/chan/powser2.go index c72c2fad5..5f2d1dc8c 100644 --- a/test/chan/powser2.go +++ b/test/chan/powser2.go @@ -35,8 +35,8 @@ func (u *rat) eq(c item) bool { } type dch struct { - req *chan int; - dat *chan item; + req chan int; + dat chan item; nam int; } @@ -51,7 +51,7 @@ func Init(); func mkdch() *dch { c := chnameserial % len(chnames); chnameserial++; - d := new(dch); + d := new(*dch); d.req = new(chan int); d.dat = new(chan item); d.nam = c; @@ -59,7 +59,7 @@ func mkdch() *dch { } func mkdch2() *dch2 { - d2 := new(dch2); + d2 := new(*dch2); d2[0] = mkdch(); d2[1] = mkdch(); return d2; @@ -79,7 +79,7 @@ func mkdch2() *dch2 { // a signal on the release-wait channel tells the next newer // generation to begin servicing out[1]. -func dosplit(in *dch, out *dch2, wait *chan int ){ +func dosplit(in *dch, out *dch2, wait chan int ){ var t *dch; both := false; // do not service both channels @@ -132,9 +132,9 @@ func get(in *dch) *rat { func getn(in []*dch, n int) []item { // BUG n:=len(in); if n != 2 { panic("bad n in getn") }; - req := new([2] *chan int); - dat := new([2] *chan item); - out := new([2] item); + req := new([] chan int, 2); + dat := new([] chan item, 2); + out := new([]item, 2); var i int; var it item; for i=0; i<n; i++ { @@ -165,10 +165,7 @@ func getn(in []*dch, n int) []item { // Get one item from each of 2 demand channels func get2(in0 *dch, in1 *dch) []item { - x := new([2] *dch); - x[0] = in0; - x[1] = in1; - return getn(x, 2); + return getn([]*dch{in0, in1}, 2); } func copy(in *dch, out *dch){ @@ -216,7 +213,7 @@ func gcd (u, v int64) int64{ func i2tor(u, v int64) *rat{ g := gcd(u,v); - r := new(rat); + r := new(*rat); if v > 0 { r.num = u/g; r.den = v/g; @@ -254,7 +251,7 @@ func add(u, v *rat) *rat { func mul(u, v *rat) *rat{ g1 := gcd(u.num,v.den); g2 := gcd(u.den,v.num); - r := new(rat); + r := new(*rat); r.num =(u.num/g1)*(v.num/g2); r.den = (u.den/g2)*(v.den/g1); return r; @@ -654,7 +651,7 @@ func main() { check(Ones, one, 5, "Ones"); check(Add(Ones, Ones), itor(2), 0, "Add Ones Ones"); // 1 1 1 1 1 check(Add(Ones, Twos), itor(3), 0, "Add Ones Twos"); // 3 3 3 3 3 - a := new([N] *rat); + a := new([]*rat, N); d := Diff(Ones); // BUG: want array initializer for i:=0; i < N; i++ { diff --git a/test/chan/select.go b/test/chan/select.go index 470e15181..3158ee6c2 100644 --- a/test/chan/select.go +++ b/test/chan/select.go @@ -14,7 +14,7 @@ func GetValue() uint { return 1 << shift } -func Send(a, b *chan uint) int { +func Send(a, b chan uint) int { var i int; LOOP: for { diff --git a/test/chan/sieve.go b/test/chan/sieve.go index f45373b48..b6bcdb33d 100644 --- a/test/chan/sieve.go +++ b/test/chan/sieve.go @@ -10,7 +10,7 @@ package main // Send the sequence 2, 3, 4, ... to channel 'ch'. -func Generate(ch *chan<- int) { +func Generate(ch chan<- int) { for i := 2; ; i++ { ch <- i // Send 'i' to channel 'ch'. } @@ -18,7 +18,7 @@ func Generate(ch *chan<- int) { // Copy the values from channel 'in' to channel 'out', // removing those divisible by 'prime'. -func Filter(in *<-chan int, out *chan<- int, prime int) { +func Filter(in <-chan int, out chan<- int, prime int) { for { i := <-in; // Receive value of new variable 'i' from 'in'. if i % prime != 0 { @@ -28,7 +28,7 @@ func Filter(in *<-chan int, out *chan<- int, prime int) { } // The prime sieve: Daisy-chain Filter processes together. -func Sieve(primes *chan<- int) { +func Sieve(primes chan<- int) { ch := new(chan int); // Create a new channel. go Generate(ch); // Start Generate() as a subprocess. for { diff --git a/test/complit.go b/test/complit.go index 43f090412..ca3c8e048 100644 --- a/test/complit.go +++ b/test/complit.go @@ -11,7 +11,7 @@ type T struct { i int; f float; s string; next *T } type R struct { num int } func itor(a int) *R { - r := new(R); + r := new(*R); r.num = a; return r; } @@ -49,12 +49,12 @@ func main() { if len(at) != 3 { panic("at") } c := new(chan int); - ac := []*chan int{c, c, c}; + ac := []chan int{c, c, c}; if len(ac) != 3 { panic("ac") } aat := [][len(at)]*T{at, at}; if len(aat) != 2 || len(aat[1]) != 3 { panic("at") } - + s := string([]byte{'h', 'e', 'l', 'l', 'o'}); if s != "hello" { panic("s") } @@ -62,7 +62,7 @@ func main() { if len(m) != 3 { panic("m") } eq(&[]*R{itor(0), itor(1), itor(2), itor(3), itor(4), itor(5)}); - + p1 := NewP(1, 2); p2 := NewP(1, 2); if p1 == p2 { panic("NewP") } diff --git a/test/fixedbugs/bug011.go b/test/fixedbugs/bug011.go index 63673c086..c2d9cde6c 100644 --- a/test/fixedbugs/bug011.go +++ b/test/fixedbugs/bug011.go @@ -16,7 +16,7 @@ func (t *T) m(a int, b float) int { } func main() { - var t *T = new(T); + var t *T = new(*T); t.x = 1; t.y = 2; r10 := t.m(1, 3.0); diff --git a/test/fixedbugs/bug026.go b/test/fixedbugs/bug026.go index 1d97c18ae..d8a1d7785 100644 --- a/test/fixedbugs/bug026.go +++ b/test/fixedbugs/bug026.go @@ -18,8 +18,8 @@ func (v *Vector) Insert(i int, e Element) { func main() { type I struct { val int; }; // BUG: can't be local; works if global - v := new(Vector); - v.Insert(0, new(I)); + v := new(*Vector); + v.Insert(0, new(*I)); } /* check: main_sigs_I: not defined diff --git a/test/fixedbugs/bug027.go b/test/fixedbugs/bug027.go index 2c595cb83..95bc06412 100644 --- a/test/fixedbugs/bug027.go +++ b/test/fixedbugs/bug027.go @@ -15,9 +15,9 @@ type Vector struct { } func New() *Vector { - v := new(Vector); + v := new(*Vector); v.nelem = 0; - v.elem = new([10]Element); + v.elem = new(*[10]Element); return v; } @@ -33,11 +33,11 @@ func (v *Vector) Insert(e Element) { type I struct { val int; }; // BUG: can't be local; func main() { - i0 := new(I); i0.val = 0; - i1 := new(I); i1.val = 11; - i2 := new(I); i2.val = 222; - i3 := new(I); i3.val = 3333; - i4 := new(I); i4.val = 44444; + i0 := new(*I); i0.val = 0; + i1 := new(*I); i1.val = 11; + i2 := new(*I); i2.val = 222; + i3 := new(*I); i3.val = 3333; + i4 := new(*I); i4.val = 44444; v := New(); print("hi\n"); v.Insert(i4); diff --git a/test/fixedbugs/bug038.go b/test/fixedbugs/bug038.go index 7585376a3..444a04252 100644 --- a/test/fixedbugs/bug038.go +++ b/test/fixedbugs/bug038.go @@ -9,5 +9,5 @@ package main func main() { var z [3]byte; - z := new([3]byte); // BUG redeclaration + z := new(*[3]byte); // BUG redeclaration } diff --git a/test/fixedbugs/bug045.go b/test/fixedbugs/bug045.go index d8a712c6d..9e94f4473 100644 --- a/test/fixedbugs/bug045.go +++ b/test/fixedbugs/bug045.go @@ -13,7 +13,7 @@ type T struct { func main() { var ta []*T; - ta = new([1]*T); + ta = new(*[1]*T); ta[0] = nil; } /* diff --git a/test/fixedbugs/bug054.go b/test/fixedbugs/bug054.go index decf5841d..f4d7c27fa 100644 --- a/test/fixedbugs/bug054.go +++ b/test/fixedbugs/bug054.go @@ -30,12 +30,12 @@ func (s *TStruct) field(i int) *TStruct { } func main() { - v := new(Vector); - v.elem = new([10]Element); - t := new(TStruct); + v := new(*Vector); + v.elem = new(*[10]Element); + t := new(*TStruct); t.name = "hi"; v.elem[0] = t; - s := new(TStruct); + s := new(*TStruct); s.name = "foo"; s.fields = v; if s.field(0).name != "hi" { diff --git a/test/fixedbugs/bug058.go b/test/fixedbugs/bug058.go index f44181546..2cfe19de4 100644 --- a/test/fixedbugs/bug058.go +++ b/test/fixedbugs/bug058.go @@ -7,8 +7,8 @@ package main type Box struct {}; -var m *map[string] *Box; - +var m map[string] *Box; + func main() { m := new(map[string] *Box); s := "foo"; diff --git a/test/fixedbugs/bug059.go b/test/fixedbugs/bug059.go index 5a29ed1f0..55c05f680 100644 --- a/test/fixedbugs/bug059.go +++ b/test/fixedbugs/bug059.go @@ -20,7 +20,7 @@ func P(a []string) string { func main() { m := new(map[string] []string); - as := new([2]string); + as := new(*[2]string); as[0] = "0"; as[1] = "1"; m["0"] = as; diff --git a/test/fixedbugs/bug066.go b/test/fixedbugs/bug066.go index ab6925792..4f64152ae 100644 --- a/test/fixedbugs/bug066.go +++ b/test/fixedbugs/bug066.go @@ -12,7 +12,7 @@ type ( ) type Scope struct { - entries *map[string] *Object; + entries map[string] *Object; } diff --git a/test/fixedbugs/bug067.go b/test/fixedbugs/bug067.go index fd22cd6f8..1e747ebba 100644 --- a/test/fixedbugs/bug067.go +++ b/test/fixedbugs/bug067.go @@ -6,7 +6,7 @@ package main -var c *chan int +var c chan int func main() { c = new(chan int); diff --git a/test/fixedbugs/bug069.go b/test/fixedbugs/bug069.go index 51e034d65..2e538469b 100644 --- a/test/fixedbugs/bug069.go +++ b/test/fixedbugs/bug069.go @@ -13,6 +13,6 @@ func main(){ i, ok = <-c; // works - ca := new([2]*chan int); + ca := new(*[2]chan int); i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2 } diff --git a/test/fixedbugs/bug071.go b/test/fixedbugs/bug071.go index 8af54626e..665a441bd 100644 --- a/test/fixedbugs/bug071.go +++ b/test/fixedbugs/bug071.go @@ -14,7 +14,7 @@ func (u *rat) pr() { } type dch struct { - dat *chan *rat; + dat chan *rat; } func dosplit(in *dch){ diff --git a/test/fixedbugs/bug075.go b/test/fixedbugs/bug075.go index 01b0fe0e7..c1b864745 100644 --- a/test/fixedbugs/bug075.go +++ b/test/fixedbugs/bug075.go @@ -6,9 +6,9 @@ package main -type T struct { m *map[int]int } +type T struct { m map[int]int } func main() { - t := new(T); + t := new(*T); t.m = new(map[int]int); var x int; var ok bool; diff --git a/test/fixedbugs/bug078.go b/test/fixedbugs/bug078.go index 3ffadb7d0..ddd3faeba 100644 --- a/test/fixedbugs/bug078.go +++ b/test/fixedbugs/bug078.go @@ -6,7 +6,7 @@ package main -func dosplit(wait *chan int ){ +func dosplit(wait chan int ){ select { case <-wait: } diff --git a/test/fixedbugs/bug084.go b/test/fixedbugs/bug084.go index a5ccdb37c..138b6da4b 100644 --- a/test/fixedbugs/bug084.go +++ b/test/fixedbugs/bug084.go @@ -18,6 +18,6 @@ var arith Service func main() { c := new(chan string); - a := new(Service); + a := new(*Service); go a.Serve(1234); } diff --git a/test/fixedbugs/bug099.go b/test/fixedbugs/bug099.go index f76f0e873..2b1776c1f 100644 --- a/test/fixedbugs/bug099.go +++ b/test/fixedbugs/bug099.go @@ -18,7 +18,7 @@ func (s *S) F() int { return 1 } // if you take it out (and the 0s below) // then the bug goes away. func NewI(i int) I { - return new(S) + return new(*S) } // Uses interface method. diff --git a/test/fixedbugs/bug111.go b/test/fixedbugs/bug111.go index 39da9b4dd..ee61cd830 100644 --- a/test/fixedbugs/bug111.go +++ b/test/fixedbugs/bug111.go @@ -22,7 +22,7 @@ func (s *Stucky) Me() Iffy { } func main() { - s := new(Stucky); + s := new(*Stucky); i := s.Me(); j := i.Me(); j.Me(); diff --git a/test/fixedbugs/bug118.go b/test/fixedbugs/bug118.go index 778b533c7..d508d8353 100644 --- a/test/fixedbugs/bug118.go +++ b/test/fixedbugs/bug118.go @@ -6,7 +6,7 @@ package main -export func Send(c *chan int) int { +export func Send(c chan int) int { select { default: return 1; diff --git a/test/func.go b/test/func.go index ee9414ddc..7b15f7477 100644 --- a/test/func.go +++ b/test/func.go @@ -81,7 +81,7 @@ func main() { r9, s9 := f9(1); assertequal(r9, 9, "r9"); assertequal(int(s9), 9, "s9"); - var t *T = new(T); + var t *T = new(*T); t.x = 1; t.y = 2; r10 := t.m10(1, 3.0); diff --git a/test/hashmap.go b/test/hashmap.go index 86a342272..d458b8c97 100755 --- a/test/hashmap.go +++ b/test/hashmap.go @@ -64,7 +64,7 @@ func (m *HashMap) Clear() { func (m *HashMap) Initialize (initial_log2_capacity uint32) { m.log2_capacity_ = initial_log2_capacity; - m.map_ = new([1024] Entry); + m.map_ = new(*[1024] Entry); m.Clear(); } @@ -74,7 +74,7 @@ func (m *HashMap) Probe (key *KeyType) *Entry { var i uint32 = key.Hash() % m.capacity(); ASSERT(0 <= i && i < m.capacity()); - + ASSERT(m.occupancy_ < m.capacity()); // guarantees loop termination for m.map_[i].key != nil && !m.map_[i].key.Match(key) { i++; @@ -82,7 +82,7 @@ func (m *HashMap) Probe (key *KeyType) *Entry { i = 0; } } - + return &m.map_[i]; } @@ -102,13 +102,13 @@ func (m *HashMap) Lookup (key *KeyType, insert bool) *Entry { p.key = key; p.value = nil; m.occupancy_++; - + // Grow the map if we reached >= 80% occupancy. if m.occupancy_ + m.occupancy_/4 >= m.capacity() { m.Resize(); p = m.Probe(key); } - + return p; } @@ -120,10 +120,10 @@ func (m *HashMap) Lookup (key *KeyType, insert bool) *Entry { func (m *HashMap) Resize() { var hmap *[1024] Entry = m.map_; var n uint32 = m.occupancy_; - + // Allocate a new map of twice the current size. m.Initialize(m.log2_capacity_ << 1); - + // Rehash all current entries. var i uint32 = 0; for n > 0 { @@ -157,7 +157,7 @@ func (n *Number) Match(other *KeyType) bool { func MakeNumber (x uint32) *Number { - var n *Number = new(Number); + var n *Number = new(*Number); n.x = x; return n; } @@ -167,18 +167,18 @@ func main() { //f unc (n int) int { return n + 1; }(1); //print "HashMap - gri 2/8/2008\n"; - - var hmap *HashMap = new(HashMap); + + var hmap *HashMap = new(*HashMap); hmap.Initialize(0); - + var x1 *Number = MakeNumber(1001); var x2 *Number = MakeNumber(2002); var x3 *Number = MakeNumber(3003); - + // this doesn't work I think... //hmap.Lookup(x1, true); //hmap.Lookup(x2, true); //hmap.Lookup(x3, true); - + //print "done\n"; } diff --git a/test/hilbert.go b/test/hilbert.go index b2b916b13..415e957f8 100644 --- a/test/hilbert.go +++ b/test/hilbert.go @@ -47,7 +47,7 @@ func (a *Matrix) set(i, j int, x *Big.Rational) { func NewMatrix(n, m int) *Matrix { assert(0 <= n && 0 <= m); - a := new(Matrix); + a := new(*Matrix); a.n = n; a.m = m; a.a = new([]*Big.Rational, n*m); diff --git a/test/initcomma.go b/test/initcomma.go index d4bff2a88..d86ddbac4 100644 --- a/test/initcomma.go +++ b/test/initcomma.go @@ -7,7 +7,7 @@ package main var a = []int { 1, 2, } -var b = [5]int { } +var b = []int { } var c = []int { 1 } func main() { diff --git a/test/interface1.go b/test/interface1.go index 649a955f6..a053ed3e9 100644 --- a/test/interface1.go +++ b/test/interface1.go @@ -28,8 +28,8 @@ func AddInst(Inst) *Inst { } func main() { - re := new(Regexp); + re := new(*Regexp); print("call addinst\n"); - var x Inst = AddInst(new(Start)); // ERROR "illegal|incompatible" + var x Inst = AddInst(new(*Start)); // ERROR "illegal|incompatible" print("return from addinst\n"); } diff --git a/test/ken/array.go b/test/ken/array.go index 167830e57..2027a31ff 100644 --- a/test/ken/array.go +++ b/test/ken/array.go @@ -95,7 +95,7 @@ testpfpf() func testpdpf1() { - a := new([40]int); + a := new(*[40]int); setpd(a); res(sumpd(a), 0, 40); diff --git a/test/ken/chan.go b/test/ken/chan.go index 64758537e..da08477e6 100644 --- a/test/ken/chan.go +++ b/test/ken/chan.go @@ -22,7 +22,7 @@ nrand(n int) int type Chan struct { - sc,rc *chan int; // send and recv chan + sc,rc chan int; // send and recv chan sv,rv int; // send and recv seq } @@ -38,7 +38,7 @@ var func init() { - nc = new(Chan); + nc = new(*Chan); } func @@ -47,7 +47,7 @@ mkchan(c,n int) []*Chan ca := new([]*Chan, n); for i:=0; i<n; i++ { cval = cval+100; - ch := new(Chan); + ch := new(*Chan); ch.sc = new(chan int, c); ch.rc = ch.sc; ch.sv = cval; diff --git a/test/ken/embed.go b/test/ken/embed.go index f0c9f4ec2..42e83e44f 100644 --- a/test/ken/embed.go +++ b/test/ken/embed.go @@ -166,10 +166,10 @@ main() var s *S; // allocate - s = new(S); - s.Subp = new(Subp); - s.Sub.SubSubp = new(SubSubp); - s.Subp.SubpSubp = new(SubpSubp); + s = new(*S); + s.Subp = new(*Subp); + s.Sub.SubSubp = new(*SubSubp); + s.Subp.SubpSubp = new(*SubpSubp); // explicit assignment s.a = 1; diff --git a/test/ken/interfun.go b/test/ken/interfun.go index 97db89316..4ab2b8b9f 100644 --- a/test/ken/interfun.go +++ b/test/ken/interfun.go @@ -40,7 +40,7 @@ main() var i2 I2; var g *S; - s := new(S); + s := new(*S); s.a = 5; s.b = 6; diff --git a/test/ken/intervar.go b/test/ken/intervar.go index 1c3d65000..711568b4c 100644 --- a/test/ken/intervar.go +++ b/test/ken/intervar.go @@ -58,9 +58,9 @@ puts(s string) func main() { - p := new(Print); - b := new(Bio); - f := new(File); + p := new(*Print); + b := new(*Bio); + f := new(*File); p.whoami = 1; p.put = b; diff --git a/test/ken/ptrfun.go b/test/ken/ptrfun.go index e7db3a94d..949cb823e 100644 --- a/test/ken/ptrfun.go +++ b/test/ken/ptrfun.go @@ -27,7 +27,7 @@ main() var v int; var c *C; - c = new(C); + c = new(*C); c.a = 6; c.x = &g; diff --git a/test/ken/range.go b/test/ken/range.go index 2831806bf..5bb6d55dc 100644 --- a/test/ken/range.go +++ b/test/ken/range.go @@ -10,7 +10,7 @@ const size = 16; var a [size]byte; var p []byte; -var m *map[int]byte; +var m map[int]byte; func f(k int) byte diff --git a/test/ken/rob1.go b/test/ken/rob1.go index a75878b1f..35397b36f 100644 --- a/test/ken/rob1.go +++ b/test/ken/rob1.go @@ -31,7 +31,7 @@ Init() func (list *List) Insert(i Item) { - item := new(ListItem); + item := new(*ListItem); item.item = i; item.next = list.head; list.head = item; @@ -69,10 +69,10 @@ Print() func main() { - list := new(List); + list := new(*List); list.Init(); for i := 0; i < 10; i = i + 1 { - integer := new(Integer); + integer := new(*Integer); integer.Init(i); list.Insert(integer); } diff --git a/test/ken/rob2.go b/test/ken/rob2.go index 7d2eecbf7..9cb2ff3dd 100644 --- a/test/ken/rob2.go +++ b/test/ken/rob2.go @@ -213,7 +213,7 @@ func ParseList() *Slist { var slist, retval *Slist; - slist = new(Slist); + slist = new(*Slist); slist.list.car = nil; slist.list.cdr = nil; slist.isatom = false; @@ -225,7 +225,7 @@ func ParseList() *Slist if token == ')' || token == EOF { // empty cdr break; } - slist.list.cdr = new(Slist); + slist.list.cdr = new(*Slist); slist = slist.list.cdr; } return retval; @@ -236,7 +236,7 @@ func atom(i int) *Slist // BUG: uses tokenbuf; should take argument var h, length int; var slist, tail *Slist; - slist = new(Slist); + slist = new(*Slist); if token == '0' { slist.atom.integer = i; slist.isstring = false; diff --git a/test/ken/robfunc.go b/test/ken/robfunc.go index 12b4b6d7b..947016fac 100644 --- a/test/ken/robfunc.go +++ b/test/ken/robfunc.go @@ -86,7 +86,7 @@ func main() { r9, s9 = f9(1); assertequal(r9, 9, "r9"); assertequal(int(s9), 9, "s9"); - var t *T = new(T); + var t *T = new(*T); t.x = 1; t.y = 2; r10 := t.m10(1, 3.0); diff --git a/test/ken/simparray.go b/test/ken/simparray.go index 90331e5e3..f68ff145b 100644 --- a/test/ken/simparray.go +++ b/test/ken/simparray.go @@ -35,7 +35,7 @@ main() if s2 != 35 { panic(s2); } - b := new([100]int); + b := new(*[100]int); for i:=0; i<100; i=i+1 { b[i] = i; } diff --git a/test/ken/simpbool.go b/test/ken/simpbool.go index aad111dd5..28ddafe15 100644 --- a/test/ken/simpbool.go +++ b/test/ken/simpbool.go @@ -30,7 +30,7 @@ main() if !!!a { panic(6); } var x *s; - x = new(s); + x = new(*s); x.a = true; x.b = false; diff --git a/test/ken/string.go b/test/ken/string.go index 3a15beeff..7e3aa902b 100644 --- a/test/ken/string.go +++ b/test/ken/string.go @@ -92,7 +92,7 @@ main() } /* create string with byte array pointer */ - z2 := new([3]byte); + z2 := new(*[3]byte); z2[0] = 'a'; z2[1] = 'b'; z2[2] = 'c'; diff --git a/test/map.go b/test/map.go index a0175feac..7182aa08f 100644 --- a/test/map.go +++ b/test/map.go @@ -46,8 +46,8 @@ func main() { //mit := new(map[int] T); // should be able to do a value but: fatal error: algtype: cant find type <T>{} //mti := new(map[T] int); // should be able to do a value but: fatal error: algtype: cant find type <T>{} - type M map[int] int; - mipM := new(map[int] *M); + type M map[int] int; + mipM := new(map[int] M); const count = 100; // BUG: should be bigger but maps do linear lookup var apT [2*count]*T; @@ -55,14 +55,14 @@ func main() { for i := 0; i < count; i++ { s := F.d(i).str(); f := float(i); - apT[i] = new(T); + apT[i] = new(*T); apT[i].s = s; apT[i].f = f; - apT[2*i] = new(T); // need twice as many entries as we use, for the nonexistence check + apT[2*i] = new(*T); // need twice as many entries as we use, for the nonexistence check apT[2*i].s = s; apT[2*i].f = f; // BUG t := T(s, f); - t := new(T); t.s = s; t.f = f; + t := new(*T); t.s = s; t.f = f; // BUG m := M(i, i+1); m := new(M); m[i] = i+1; mib[i] = (i != 0); @@ -73,7 +73,7 @@ func main() { msi[F.d(i).str()] = i; mss[F.d(i).str()] = F.d(10*i).str(); mss[F.d(i).str()] = F.d(10*i).str(); - as := new([arraylen]string); + as := new([]string, arraylen); as[0] = F.d(10*i).str(); as[1] = F.d(10*i).str(); mspa[F.d(i).str()] = as; @@ -120,7 +120,7 @@ func main() { if len(mipM) != count { F.s("len(mipM) = ").d(len(mipM)).putnl(); } - + // test construction directly for i := 0; i < count; i++ { s := F.d(i).str(); @@ -411,7 +411,7 @@ func main() { } } } - + // tests for structured map element updates for i := 0; i < count; i++ { diff --git a/test/nil.go b/test/nil.go index f26ba3221..8cd8e57aa 100644 --- a/test/nil.go +++ b/test/nil.go @@ -17,8 +17,8 @@ func main() { var i *int; var f *float; var s *string; - var m *map[float] *int; - var c *chan int; + var m map[float] *int; + var c chan int; var t *T; var in IN; var ta []IN; @@ -30,6 +30,6 @@ func main() { c = nil; t = nil; i = nil; - ta = new([1]IN); + ta = new([]IN, 1); ta[0] = nil; } diff --git a/test/peano.go b/test/peano.go index 4c1b837b2..e29090574 100644 --- a/test/peano.go +++ b/test/peano.go @@ -25,7 +25,7 @@ func is_zero(x *Number) bool { func add1(x *Number) *Number { - e := new(Number); + e := new(*Number); e.next = x; return e; } @@ -122,7 +122,7 @@ func verify() { func main() { - + verify(); for i := 0; i <= 10; i++ { print(i, "! = ", count(fact(gen(i))), "\n"); diff --git a/test/sieve.go b/test/sieve.go index 366d5b94c..91fa6e5f0 100644 --- a/test/sieve.go +++ b/test/sieve.go @@ -7,7 +7,7 @@ package main // Send the sequence 2, 3, 4, ... to channel 'ch'. -func Generate(ch *chan<- int) { +func Generate(ch chan<- int) { for i := 2; ; i++ { ch <- i // Send 'i' to channel 'ch'. } @@ -15,7 +15,7 @@ func Generate(ch *chan<- int) { // Copy the values from channel 'in' to channel 'out', // removing those divisible by 'prime'. -func Filter(in *<-chan int, out *chan<- int, prime int) { +func Filter(in <-chan int, out chan<- int, prime int) { for { i := <-in; // Receive value of new variable 'i' from 'in'. if i % prime != 0 { diff --git a/test/test0.go b/test/test0.go index a3691fb46..0a11e1d28 100644 --- a/test/test0.go +++ b/test/test0.go @@ -8,7 +8,7 @@ package main const a_const = 0 - + const ( pi = /* the usual */ 3.14159265358979323; e = 2.718281828; @@ -55,7 +55,7 @@ func swap(x, y int) (u, v int) { } func control_structs() { - var p *Point = new(Point).Initialize(2, 3); + var p *Point = new(*Point).Initialize(2, 3); i := p.Distance(); var f float = 0.3; for {} diff --git a/test/utf.go b/test/utf.go index 5905152b6..7880b5ab9 100644 --- a/test/utf.go +++ b/test/utf.go @@ -29,7 +29,7 @@ func main() { // encoded as bytes: 'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e const L = 12; if L != l { panic("wrong length constructing array") } - a := new([L]byte); + a := new(*[L]byte); a[0] = 'a'; a[1] = 'b'; a[2] = 'c'; diff --git a/test/vectors.go b/test/vectors.go index eefec9197..abc59732e 100644 --- a/test/vectors.go +++ b/test/vectors.go @@ -31,7 +31,7 @@ func test0() { func test1() { var a [1000] *S; for i := 0; i < len(a); i++ { - a[i] = new(S).Init(i); + a[i] = new(*S).Init(i); } v := array.New(0); @@ -48,7 +48,7 @@ func test1() { panic("expected ", i, ", found ", x.val, "\n"); } } - + for v.Len() > 10 { v.Remove(10); } |
