package malloc
export type Stats struct {
- alloc uint64;
- sys uint64;
+ Alloc uint64;
+ Sys uint64;
};
export func Alloc(uint64) *byte;
package main
-type T chan uint64;
+export type T chan uint64;
-func M(f uint64) (in, out T) {
+export func M(f uint64) (in, out T) {
in = make(T, 100);
out = make(T, 100);
go func(in, out T, f uint64) {
"fmt";
)
-type T struct {
+export type T struct {
a float64;
b int64;
c string;
}
var a = []int{ 1, 2, 3 }
-var NIL []int;
+export var NIL []int;
func arraycmptest() {
a1 := a;
}
}
-func SameArray(a, b []int) bool {
+export func SameArray(a, b []int) bool {
if len(a) != len(b) || cap(a) != cap(b) {
return false;
}
}
}
-type E struct { }
+export type E struct { }
var e E
func interfacetest() {
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// $G $D/$F.go && echo BUG: compilation succeeds incorrectly
+// ! $G $D/$F.go || echo BUG: compilation succeeds incorrectly
package main
-type T struct
-type S struct {
- p *T // BUG T never declared
+type t struct
+type s struct {
+ p *t // BUG t never declared
}
func main() {
- var s S;
+ var s1 s;
}
// license that can be found in the LICENSE file.
package main
-type S struct { a int }
-type PS *S
+export type S struct { a int }
+export type PS *S
func (p *S) get() int {
return p.a
}
package main
-type T ()
+export type T ()
-type I interface {
+export type I interface {
f, g ();
h T; // should only allow FunctionType here
}
-type S struct {
+export type S struct {
}
func (s *S) f() {}
// license that can be found in the LICENSE file.
package main
-const ( F = 1 )
+export const ( F = 1 )
func fn(i int) int {
if i == F() { // ERROR "function"
return 0
package main
-type I interface { send(chan <- int) }
+export type I interface { send(chan <- int) }
-type S struct { v int }
+export type S struct { v int }
func (p *S) send(c chan <- int) { c <- p.v }
func main() {
package main
-const N = 10
+export const N = 10
-func AsynchFifo() {
+export func AsynchFifo() {
ch := make(chan int, N);
for i := 0; i < N; i++ {
ch <- i
}
}
-func Chain(ch <-chan int, val int, in <-chan int, out chan<- int) {
+export func Chain(ch <-chan int, val int, in <-chan int, out chan<- int) {
<-in;
if <-ch != val {
panic(val)
}
// thread together a daisy chain to read the elements in sequence
-func SynchFifo() {
+export func SynchFifo() {
ch := make(chan int);
in := make(chan int);
start := in;
var chnameserial int
var seqno int
-func Init();
+export func Init();
func mkdch() *dch {
c := chnameserial % len(chnames);
}
}
-type PS *dch; // power series
-type PS2 *[2] PS; // pair of power series
+export type PS *dch; // power series
+export type PS2 *[2] PS; // pair of power series
-var Ones PS
-var Twos PS
+export var Ones PS
+export var Twos PS
func mkPS() *dch {
return mkdch()
}
// print eval in floating point of PS at x=c to n terms
-func
-Evaln(c *rat, U PS, n int)
+export func Evaln(c *rat, U PS, n int)
{
xn := float64(1);
x := float64(c.num)/float64(c.den);
}
// Print n terms of a power series
-func Printn(U PS, n int){
+export func Printn(U PS, n int){
done := false;
for ; !done && n>0; n-- {
u := get(U);
print(("\n"));
}
-func Print(U PS){
+export func Print(U PS){
Printn(U,1000000000);
}
// Make a pair of power series identical to a given power series
-func Split(U PS) *dch2{
+export func Split(U PS) *dch2{
UU := mkdch2();
go split(U,UU);
return UU;
}
// Add two power series
-func Add(U, V PS) PS{
+export func Add(U, V PS) PS{
Z := mkPS();
go func(U, V, Z PS){
var uv [] *rat;
}
// Multiply a power series by a constant
-func Cmul(c *rat,U PS) PS{
+export func Cmul(c *rat,U PS) PS{
Z := mkPS();
go func(c *rat, U, Z PS){
done := false;
// Subtract
-func Sub(U, V PS) PS{
+export func Sub(U, V PS) PS{
return Add(U, Cmul(neg(one), V));
}
// Multiply a power series by the monomial x^n
-func Monmul(U PS, n int) PS{
+export func Monmul(U PS, n int) PS{
Z := mkPS();
go func(n int, U PS, Z PS){
for ; n>0; n-- { put(zero,Z) }
// Multiply by x
-func Xmul(U PS) PS{
+export func Xmul(U PS) PS{
return Monmul(U,1);
}
-func Rep(c *rat) PS{
+export func Rep(c *rat) PS{
Z := mkPS();
go repeat(c,Z);
return Z;
// Monomial c*x^n
-func Mon(c *rat, n int) PS{
+export func Mon(c *rat, n int) PS{
Z:=mkPS();
go func(c *rat, n int, Z PS){
if(c.num!=0) {
return Z;
}
-func Shift(c *rat, U PS) PS{
+export func Shift(c *rat, U PS) PS{
Z := mkPS();
go func(c *rat, U, Z PS){
put(c,Z);
// to a (finite) power series
/* BUG: NEED LEN OF ARRAY
-func Poly(a [] *rat) PS{
+export func Poly(a [] *rat) PS{
Z:=mkPS();
begin func(a [] *rat, Z PS){
j:=0;
// let V = v + x*VV
// then UV = u*v + x*(u*VV+v*UU) + x*x*UU*VV
-func Mul(U, V PS) PS{
+export func Mul(U, V PS) PS{
Z:=mkPS();
go func(U, V, Z PS){
<-Z.req;
// Differentiate
-func Diff(U PS) PS{
+export func Diff(U PS) PS{
Z:=mkPS();
go func(U, Z PS){
<-Z.req;
}
// Integrate, with const of integration
-func Integ(c *rat,U PS) PS{
+export func Integ(c *rat,U PS) PS{
Z:=mkPS();
go func(c *rat, U, Z PS){
put(c,Z);
// Binomial theorem (1+x)^c
-func Binom(c *rat) PS{
+export func Binom(c *rat) PS{
Z:=mkPS();
go func(c *rat, Z PS){
n := 1;
// u*ZZ + z*UU +x*UU*ZZ = 0
// ZZ = -UU*(z+x*ZZ)/u;
-func Recip(U PS) PS{
+export func Recip(U PS) PS{
Z:=mkPS();
go func(U, Z PS){
ZZ:=mkPS2();
// DZ = Z*DU
// integrate to get Z
-func Exp(U PS) PS{
+export func Exp(U PS) PS{
ZZ := mkPS2();
split(Integ(one,Mul(ZZ[0],Diff(U))),ZZ);
return ZZ[1];
// then S(U,V) = u + VV*S(V,UU)
// bug: a nonzero constant term is ignored
-func Subst(U, V PS) PS {
+export func Subst(U, V PS) PS {
Z:= mkPS();
go func(U, V, Z PS) {
VV := Split(V);
// Monomial Substition: U(c x^n)
// Each Ui is multiplied by c^i and followed by n-1 zeros
-func MonSubst(U PS, c0 *rat, n int) PS {
+export func MonSubst(U PS, c0 *rat, n int) PS {
Z:= mkPS();
go func(U, Z PS, c0 *rat, n int) {
c := one;
}
-func Init() {
+export func Init() {
chnameserial = -1;
seqno = 0;
chnames = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
}
}
-const N=10
+export const N=10
func checka(U PS, a []*rat, str string) {
for i := 0; i < N; i++ {
check(U, a[i], 1, str);
var chnameserial int
var seqno int
-func Init();
+export func Init();
func mkdch() *dch {
c := chnameserial % len(chnames);
}
}
-type PS *dch; // power series
-type PS2 *[2] PS; // pair of power series
+export type PS *dch; // power series
+export type PS2 *[2] PS; // pair of power series
-var Ones PS
-var Twos PS
+export var Ones PS
+export var Twos PS
func mkPS() *dch {
return mkdch()
}
// print eval in floating point of PS at x=c to n terms
-func
-Evaln(c *rat, U PS, n int)
+export func Evaln(c *rat, U PS, n int)
{
xn := float64(1);
x := float64(c.num)/float64(c.den);
}
// Print n terms of a power series
-func Printn(U PS, n int){
+export func Printn(U PS, n int){
done := false;
for ; !done && n>0; n-- {
u := get(U);
print(("\n"));
}
-func Print(U PS){
+export func Print(U PS){
Printn(U,1000000000);
}
// Make a pair of power series identical to a given power series
-func Split(U PS) *dch2{
+export func Split(U PS) *dch2{
UU := mkdch2();
go split(U,UU);
return UU;
}
// Add two power series
-func Add(U, V PS) PS{
+export func Add(U, V PS) PS{
Z := mkPS();
go func(U, V, Z PS){
var uv [] item;
}
// Multiply a power series by a constant
-func Cmul(c *rat,U PS) PS{
+export func Cmul(c *rat,U PS) PS{
Z := mkPS();
go func(c *rat, U, Z PS){
done := false;
// Subtract
-func Sub(U, V PS) PS{
+export func Sub(U, V PS) PS{
return Add(U, Cmul(neg(one), V));
}
// Multiply a power series by the monomial x^n
-func Monmul(U PS, n int) PS{
+export func Monmul(U PS, n int) PS{
Z := mkPS();
go func(n int, U PS, Z PS){
for ; n>0; n-- { put(zero,Z) }
// Multiply by x
-func Xmul(U PS) PS{
+export func Xmul(U PS) PS{
return Monmul(U,1);
}
-func Rep(c *rat) PS{
+export func Rep(c *rat) PS{
Z := mkPS();
go repeat(c,Z);
return Z;
// Monomial c*x^n
-func Mon(c *rat, n int) PS{
+export func Mon(c *rat, n int) PS{
Z:=mkPS();
go func(c *rat, n int, Z PS){
if(c.num!=0) {
return Z;
}
-func Shift(c *rat, U PS) PS{
+export func Shift(c *rat, U PS) PS{
Z := mkPS();
go func(c *rat, U, Z PS){
put(c,Z);
// to a (finite) power series
/* BUG: NEED LEN OF ARRAY
-func Poly(a [] *rat) PS{
+export func Poly(a [] *rat) PS{
Z:=mkPS();
begin func(a [] *rat, Z PS){
j:=0;
// let V = v + x*VV
// then UV = u*v + x*(u*VV+v*UU) + x*x*UU*VV
-func Mul(U, V PS) PS{
+export func Mul(U, V PS) PS{
Z:=mkPS();
go func(U, V, Z PS){
<-Z.req;
// Differentiate
-func Diff(U PS) PS{
+export func Diff(U PS) PS{
Z:=mkPS();
go func(U, Z PS){
<-Z.req;
}
// Integrate, with const of integration
-func Integ(c *rat,U PS) PS{
+export func Integ(c *rat,U PS) PS{
Z:=mkPS();
go func(c *rat, U, Z PS){
put(c,Z);
// Binomial theorem (1+x)^c
-func Binom(c *rat) PS{
+export func Binom(c *rat) PS{
Z:=mkPS();
go func(c *rat, Z PS){
n := 1;
// u*ZZ + z*UU +x*UU*ZZ = 0
// ZZ = -UU*(z+x*ZZ)/u;
-func Recip(U PS) PS{
+export func Recip(U PS) PS{
Z:=mkPS();
go func(U, Z PS){
ZZ:=mkPS2();
// DZ = Z*DU
// integrate to get Z
-func Exp(U PS) PS{
+export func Exp(U PS) PS{
ZZ := mkPS2();
split(Integ(one,Mul(ZZ[0],Diff(U))),ZZ);
return ZZ[1];
// then S(U,V) = u + VV*S(V,UU)
// bug: a nonzero constant term is ignored
-func Subst(U, V PS) PS {
+export func Subst(U, V PS) PS {
Z:= mkPS();
go func(U, V, Z PS) {
VV := Split(V);
// Monomial Substition: U(c x^n)
// Each Ui is multiplied by c^i and followed by n-1 zeros
-func MonSubst(U PS, c0 *rat, n int) PS {
+export func MonSubst(U PS, c0 *rat, n int) PS {
Z:= mkPS();
go func(U, Z PS, c0 *rat, n int) {
c := one;
}
-func Init() {
+export func Init() {
chnameserial = -1;
seqno = 0;
chnames = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
}
}
-const N=10
+export const N=10
func checka(U PS, a []*rat, str string) {
for i := 0; i < N; i++ {
check(U, a[i], 1, str);
var counter uint
var shift uint
-func GetValue() uint {
+export func GetValue() uint {
counter++;
return 1 << shift
}
-func Send(a, b chan uint) int {
+export func Send(a, b chan uint) int {
var i int;
LOOP:
for {
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
-func Generate(ch chan<- int) {
+export func Generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}
// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
-func Filter(in <-chan int, out chan<- int, prime int) {
+export 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 {
}
// The prime sieve: Daisy-chain Filter processes together.
-func Sieve(primes chan<- int) {
+export func Sieve(primes chan<- int) {
ch := make(chan int); // Create a new channel.
go Generate(ch); // Start Generate() as a subprocess.
for {
package main
-type T struct { i int; f float; s string; next *T }
+export type T struct { i int; f float; s string; next *T }
-type R struct { num int }
+export type R struct { num int }
func itor(a int) *R {
r := new(R);
}
}
-type P struct { a, b int };
-func NewP(a, b int) *P {
+export type P struct { a, b int };
+export func NewP(a, b int) *P {
return &P{a, b}
}
var b = int { 1 }; // ERROR "compos"
+func f() int
+
func main() {
- if sys.argc < 1 { } // ERROR "conver|incompatible"
+ if f < 1 { } // ERROR "conver|incompatible"
}
export type C struct
export type D interface
-type C struct { }
-type D interface { }
+export type C struct { }
+export type D interface { }
package main
-type (
+export type (
Point struct { x, y float };
Polar Point
)
package main
-type T struct {
+export type T struct {
x, y int;
}
package main
-type Type interface {
+export type Type interface {
TypeName() string;
}
-type TInt struct {
+export type TInt struct {
}
// TInt
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// ! $G $D/$F.go
+// # ! $G $D/$F.go
package main
-export Foo
+export foo
func main() {}
package main
-type Element interface {
+export type Element interface {
}
export type Vector struct {
package main
-type Element interface {
+export type Element interface {
}
-type Vector struct {
+export type Vector struct {
nelem int;
elem []Element;
}
-func New() *Vector {
+export func New() *Vector {
v := new(Vector);
v.nelem = 0;
v.elem = make([]Element, 10);
package main
-func Alloc(i int) int {
+export func Alloc(i int) int {
switch i {
default:
return 5;
package main
-type S struct {
+export type S struct {
};
func (p *S) M1a() ;
package main
-type T struct {
+export type T struct {
i int
}
package main
-type T *struct {}
+export type T *struct {}
func (x T) M () {} // ERROR "pointer|receiver"
package main
-type Element interface {
+export type Element interface {
}
-type Vector struct {
+export type Vector struct {
elem []Element;
}
return v.elem[i];
}
-type TStruct struct {
+export type TStruct struct {
name string;
fields *Vector;
}
package main
-type T struct {
+export type T struct {
s string;
}
package main
-type Box struct {};
+export type Box struct {};
var m map[string] *Box;
func main() {
package main
-func P(a []string) string {
+export func P(a []string) string {
s := "{";
for i := 0; i < 2; i++ {
if i > 0 {
package main
-type (
+export type (
Type struct;
Object struct;
)
-type Scope struct {
+export type Scope struct {
entries map[string] *Object;
}
-type Type struct {
+export type Type struct {
scope *Scope;
}
-type Object struct {
+export type Object struct {
typ *Type;
}
-func Lookup(scope *Scope) *Object {
+export func Lookup(scope *Scope) *Object {
return scope.entries["foo"];
}
package main
-type T struct { m map[int]int }
+export type T struct { m map[int]int }
func main() {
t := new(T);
t.m = make(map[int]int);
package bug0
-type T0 struct {
+export type T0 struct {
}
-export v0
-var v0 T0
+export var V0 T0
package main
-type Service struct {
+export type Service struct {
rpc [2]int;
}
package bug0
-export var v0 *() int;
-export var v1 *() (a int);
-export var v2 *() (a, b int);
+export var V0 *() int;
+export var V1 *() (a int);
+export var V2 *() (a, b int);
import P "bug0"
func main() {
- a0 := P.v0(); // works
- a1 := P.v1(); // works
- a2, b2 := P.v2(); // doesn't work
+ a0 := P.V0(); // works
+ a1 := P.V1(); // works
+ a2, b2 := P.V2(); // doesn't work
}
/*
package main
-type I1 interface {}
-type I2 interface { pr() }
+export type I1 interface {}
+export type I2 interface { pr() }
func e() I1;
package main
-type S struct {
+export type S struct {
}
func (p *S) M() {
print("M\n");
}
-type I interface {
+export type I interface {
M();
}
package main
-type A []int;
+export type A []int;
func main() {
a := &A{0};
package main
-type A []int;
+export type A []int;
func main() {
var a [3]A;
package main
-type A []int;
-type M map[int] int;
+export type A []int;
+export type M map[int] int;
func main() {
var a *A = &A{0};
package main
// Interface
-type I interface { F() int }
+export type I interface { F() int }
// Implements interface
-type S struct { }
+export type S struct { }
func (s *S) F() int { return 1 }
// Allocates S but returns I
// Arg is unused but important:
// if you take it out (and the 0s below)
// then the bug goes away.
-func NewI(i int) I {
+export func NewI(i int) I {
return new(S)
}
// Uses interface method.
-func Use(x I) {
+export func Use(x I) {
x.F()
}
package main
-const A = 0
+const a = 0
func f() {
- const A = 5
+ const a = 5
}
func main() {
- if A != 0 {
- panic("A=", A)
+ if a != 0 {
+ panic("a=", a)
}
}
package main
-type T struct { s string }
+export type T struct { s string }
var t = T{"hi"}
func main() {}
// license that can be found in the LICENSE file.
package main
-type I interface { };
+export type I interface { };
func foo1(i int) int { return i }
func foo2(i int32) int32 { return i }
func main() {
package main
-const B32 = 1<<32 - 1
-const C32 = (-1) & ((1<<32) - 1)
-const D32 = ^0
+export const B32 = 1<<32 - 1
+export const C32 = (-1) & ((1<<32) - 1)
+export const D32 = ^0
func main() {
if B32 != 0xFFFFFFFF {
import "strconv";
-type Test struct {
+export type Test struct {
f float64;
in string;
out string;
return 8, 8.0;
}
-type T struct {
+export type T struct {
x, y int;
}
hello, world
=========== ./interface2.go
-cannot convert type *main.S·interface2 to interface main.I·interface2: missing method Foo
+cannot convert type *main.S to interface main.I: missing method Foo
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
=========== ./interface3.go
-cannot convert type *main.S·interface3 to interface main.I2·interface3: missing method Name
+cannot convert type *main.S to interface main.I2: missing method Name
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
PASS
=========== bugs/bug041.go
-BUG: compilation succeeds incorrectly
+bugs/bug041.go:5: export of incomplete type t
=========== bugs/bug064.go
bugs/bug064.go:15: illegal types for operand: CALL
=========== fixedbugs/bug016.go
fixedbugs/bug016.go:7: overflow converting constant to uint
-=========== fixedbugs/bug025.go
-fixedbugs/bug025.go:7: variable exported but not defined: Foo
-
=========== fixedbugs/bug027.go
hi
0 44444
fixedbugs/bug081.go:5: no type x
=========== fixedbugs/bug083.go
-fixedbugs/bug083.dir/bug1.go:5: syntax error near T0
+BUG: succeeds incorrectly
=========== fixedbugs/bug086.go
fixedbugs/bug086.go:5: function ends without a return statement
fixedbugs/bug103.go:8: function requires a return type
=========== fixedbugs/bug113.go
-main.I·bug113 is int, not int32
+main.I is int, not int32
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
// ----------------------------------------------------------------------------
// Helper functions
-func ASSERT(p bool) {
+export func ASSERT(p bool) {
if !p {
// panic 0;
}
// ----------------------------------------------------------------------------
// Implementation of the HashMap
-type KeyType interface {
+export type KeyType interface {
Hash() uint32;
Match(other *KeyType) bool
}
-type ValueType interface {
+export type ValueType interface {
// empty interface
}
-type Entry struct {
+export type Entry struct {
key *KeyType;
value *ValueType;
}
// Using the Array type below doesn't seem to work
//type Array array [1024] Entry;
-type HashMap struct {
+export type HashMap struct {
map_ *[1024] Entry;
log2_capacity_ uint32;
occupancy_ uint32;
// ----------------------------------------------------------------------------
// Test code
-type Number struct {
+export type Number struct {
x uint32;
}
}
-func MakeNumber (x uint32) *Number {
+export func MakeNumber (x uint32) *Number {
var n *Number = new(Number);
n.x = x;
return n;
}
-var (
+export var (
Zero = Big.Rat(0, 1);
One = Big.Rat(1, 1);
)
-type Matrix struct {
+export type Matrix struct {
n, m int;
a []*Big.Rational;
}
}
-func NewMatrix(n, m int) *Matrix {
+export func NewMatrix(n, m int) *Matrix {
assert(0 <= n && 0 <= m);
a := new(Matrix);
a.n = n;
}
-func NewUnit(n int) *Matrix {
+export func NewUnit(n int) *Matrix {
a := NewMatrix(n, n);
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {
}
-func NewHilbert(n int) *Matrix {
+export func NewHilbert(n int) *Matrix {
a := NewMatrix(n, n);
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {
}
-func MakeRat(x Big.Natural) *Big.Rational {
+export func MakeRat(x Big.Natural) *Big.Rational {
return Big.MakeRat(Big.MakeInt(false, x), Big.Nat(1));
}
-func NewInverseHilbert(n int) *Matrix {
+export func NewInverseHilbert(n int) *Matrix {
a := NewMatrix(n, n);
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {
package main
-type I2 interface
+export type I2 interface
-type I1 interface {
+export type I1 interface {
foo() I2
}
-type I2 interface {
+export type I2 interface {
bar() I1
}
-type T int
+export type T int
func (t T) bar() I1;
func (t T) foo() I2 { return t }
func (t T) bar() I1 { return t }
package main
-type Inst interface {
+export type Inst interface {
Next() *Inst;
}
-type Regexp struct {
+export type Regexp struct {
code []Inst;
start Inst;
}
-type Start struct {
+export type Start struct {
foo *Inst;
}
func (start *Start) Next() *Inst { return nil }
-func AddInst(Inst) *Inst {
+export func AddInst(Inst) *Inst {
print("ok in addinst\n");
return nil
}
package main
-type S struct
+export type S struct
-type I interface {
+export type I interface {
Foo()
}
}
// hide S down here to avoid static warning
-type S struct {
+export type S struct {
}
package main
-type S struct { a int }
-type T struct { b string }
+export type S struct { a int }
+export type T struct { b string }
func (s *S) Name() int8 { return 1 }
func (t *T) Name() int64 { return 64 }
-type I1 interface { Name() int8 }
-type I2 interface { Name() int64 }
+export type I1 interface { Name() int8 }
+export type I2 interface { Name() int64 }
func main() {
var i1 I1;
package main
-type I interface { M() int64 }
+export type I interface { M() int64 }
-type BigPtr struct { a, b, c, d int64 }
+export type BigPtr struct { a, b, c, d int64 }
func (z *BigPtr) M() int64 { return z.a+z.b+z.c+z.d }
-type SmallPtr struct { a int32 }
+export type SmallPtr struct { a int32 }
func (z *SmallPtr) M() int64 { return int64(z.a) }
-type IntPtr int32
+export type IntPtr int32
func (z *IntPtr) M() int64 { return int64(*z) }
var bad bool
test("&intptr", &intptr);
}
-type Big struct { a, b, c, d int64 }
+export type Big struct { a, b, c, d int64 }
func (z Big) M() int64 { return z.a+z.b+z.c+z.d }
-type Small struct { a int32 }
+export type Small struct { a int32 }
func (z Small) M() int64 { return int64(z.a) }
-type Int int32
+export type Int int32
func (z Int) M() int64 { return int64(z) }
func nonptrs() {
package main
-type T struct { a int }
+export type T struct { a int }
var t *T
-type I interface { M() }
+export type I interface { M() }
var i I
func main() {
}
}
-type I1 interface { Get() int; Put(int); }
+export type I1 interface { Get() int; Put(int); }
-type S1 struct { i int }
+export type S1 struct { i int }
func (p S1) Get() int { return p.i }
func (p S1) Put(i int) { p.i = i }
check(s.i == 1, "f3 s");
}
-type S2 struct { i int }
+export type S2 struct { i int }
func (p *S2) Get() int { return p.i }
func (p *S2) Put(i int) { p.i = i }
check(s.i == 2, "f6 s");
}
-type I2 interface { Get() int64; Put(int64); }
+export type I2 interface { Get() int64; Put(int64); }
-type S3 struct { i, j, k, l int64 }
+export type S3 struct { i, j, k, l int64 }
func (p S3) Get() int64 { return p.l }
func (p S3) Put(i int64) { p.l = i }
check(s.l == 4, "f9 s");
}
-type S4 struct { i, j, k, l int64 }
+export type S4 struct { i, j, k, l int64 }
func (p *S4) Get() int64 { return p.l }
func (p *S4) Put(i int64) { p.l = i }
g float = 4.5 * float(iota);
)
-const (
+export const (
X = 0;
Y;
Z;
)
-const (
+export const (
A = 1 << iota;
B;
C;
package main
-export func
+func
setpd(a []int)
{
// print("setpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
}
}
-export func
+func
sumpd(a []int) int
{
// print("sumpd a=", a, " len=", len(a), " cap=", cap(a), "\n");
return t;
}
-export func
+func
setpf(a *[20]int)
{
// print("setpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
}
}
-export func
+func
sumpf(a *[20]int) int
{
// print("sumpf a=", a, " len=", len(a), " cap=", cap(a), "\n");
return randx%n;
}
-type Chan
+export type Chan
struct
{
sc,rc chan int; // send and recv chan
(
nproc int;
cval int;
- End int = 10000;
+ end int = 10000;
totr,tots int;
nc *Chan;
)
{
if v == v0 {
if v%100 == 75 {
- return End;
+ return end;
}
return v+1;
}
// print("send ", c.sv, "\n");
tots++;
c.sv = expect(c.sv, c.sv);
- if c.sv == End {
+ if c.sv == end {
c.sc = nil;
return true;
}
// print("recv ", v, "\n");
totr++;
c.rv = expect(c.rv, v);
- if c.rv == End {
+ if c.rv == end {
c.rc = nil;
return true;
}
package main
-type
+export type
I interface
{
test1,
******
******/
-type
+export type
SubpSubp struct
{
a7 int;
******
******/
-type
+export type
SubpSub struct
{
a6 int;
******
******/
-type
+export type
SubSubp struct
{
a5 int;
******
******/
-type
+export type
SubSub struct
{
a4 int;
******
******/
-type
+export type
Subp struct
{
a3 int;
******
******/
-type
+export type
Sub struct
{
a2 int;
******
******/
-type
+export type
S struct
{
a1 int;
type myint int;
type mystring string;
-type I0 interface {};
+export type I0 interface {};
func
f()
package main
-type S struct
+export type S struct
{
a,b int;
}
-type I1 interface
+export type I1 interface
{
f ()int;
}
-type I2 interface
+export type I2 interface
{
g,f ()int;
}
package main
-type Iputs interface
+export type Iputs interface
{
puts (s string);
}
// ---------
-type Print struct
+export type Print struct
{
whoami int;
put Iputs;
// ---------
-type Bio struct
+export type Bio struct
{
whoami int;
put Iputs;
// ---------
-type File struct
+export type File struct
{
whoami int;
put Iputs;
package main
-type C struct
+export type C struct
{
a int;
x *(p *C)int;
package main
-type Item interface
+export type Item interface
{
Print();
}
-type ListItem struct
+export type ListItem struct
{
item Item;
next *ListItem;
}
-type List struct
+export type List struct
{
head *ListItem;
}
}
// Something to put in a list
-type Integer struct
+export type Integer struct
{
val int;
}
const nilchar = 0;
-type (
+export type (
Atom struct;
List struct;
Slist struct;
)
-type Atom struct {
+export type Atom struct {
str string;
integer int;
next *Slist; /* in hash bucket */
}
-type List struct {
+export type List struct {
car *Slist;
cdr*Slist;
}
-type Slist struct {
+export type Slist struct {
isatom bool;
isstring bool;
//union {
// free(slist);
}
-func OpenFile();
-func Parse() *Slist;
+export func OpenFile();
+export func Parse() *Slist;
//Slist* atom(byte *s, int i);
var tokenbuf [100]byte;
var tokenlen int = 0;
-const EOF int = -1;
+export const EOF int = -1;
func main()
{
print("\n");
}
-func Get() int
+export func Get() int
{
var c int;
return c;
}
-func WhiteSpace(c int) bool
+export func WhiteSpace(c int) bool
{
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
-func NextToken()
+export func NextToken()
{
var i, c int;
var backslash bool;
}
}
-func Expect(c int)
+export func Expect(c int)
{
if token != c {
print("parse error: expected ", c, "\n");
}
// Parse a non-parenthesized list up to a closing paren or EOF
-func ParseList() *Slist
+export func ParseList() *Slist
{
var slist, retval *Slist;
return v;
}
-func Parse() *Slist
+export func Parse() *Slist
{
var slist *Slist;
return nil;
}
-func OpenFile()
+export func OpenFile()
{
input = "(defn foo (add 12 34))\n\x00";
inputindex = 0;
return 8, 8.0;
}
-type T struct {
+export type T struct {
x, y int;
}
var footprint uint64;
var allocated uint64;
func bigger() {
- if f := malloc.GetStats().sys; footprint < f {
+ if f := malloc.GetStats().Sys; footprint < f {
footprint = f;
if *chatty {
println("Footprint", footprint, " for ", allocated);
if i%(1<<10) == 0 && *chatty {
println(i);
}
- b := rand.rand() % len(blocks);
+ b := rand.Int() % len(blocks);
if blocks[b].base != nil {
// println("Free", blocks[b].siz, blocks[b].base);
malloc.Free(blocks[b].base);
allocated -= blocks[b].siz;
continue
}
- siz := uint64(rand.rand() >> (11 + rand.urand32() % 20));
+ siz := uint64(rand.Int() >> (11 + rand.Uint32() % 20));
base := malloc.Alloc(siz);
// ptr := uint64(syscall.BytePtr(base))+uint64(siz/2);
// obj, size, ref, ok := allocator.find(ptr);
var oldsys uint64;
func bigger() {
- if st := malloc.GetStats(); oldsys < st.sys {
- oldsys = st.sys;
+ if st := malloc.GetStats(); oldsys < st.Sys {
+ oldsys = st.Sys;
if *chatty {
- println(st.sys, " system bytes for ", st.alloc, " Go bytes");
+ println(st.Sys, " system bytes for ", st.Alloc, " Go bytes");
}
- if st.sys > 1e9 {
+ if st.Sys > 1e9 {
panicln("too big");
}
}
func main() {
flag.Parse();
- malloc.GetStats().alloc = 0; // ignore stacks
+ malloc.GetStats().Alloc = 0; // ignore stacks
for i := 0; i < 1<<8; i++ {
for j := 1; j <= 1<<22; j<<=1 {
if i == 0 && *chatty {
println("First alloc:", j);
}
b := malloc.Alloc(uint64(j));
- during := malloc.GetStats().alloc;
+ during := malloc.GetStats().Alloc;
malloc.Free(b);
- if a := malloc.GetStats().alloc; a != 0 {
+ if a := malloc.GetStats().Alloc; a != 0 {
panicln("malloc wrong count", a, "after", j, "during", during);
}
bigger();
var b []*byte;
var stats = malloc.GetStats();
-func OkAmount(size, n uintptr) bool {
+export func OkAmount(size, n uintptr) bool {
if n < size {
return false
}
return true
}
-func AllocAndFree(size, count int) {
+export func AllocAndFree(size, count int) {
if *chatty {
fmt.Printf("size=%d count=%d ...\n", size, count);
}
- n1 := stats.alloc;
+ n1 := stats.Alloc;
for i := 0; i < count; i++ {
b[i] = malloc.Alloc(uint64(size));
base, n := malloc.Lookup(b[i]);
if base != b[i] || !OkAmount(uintptr(size), n) {
panicln("lookup failed: got", base, n, "for", b[i]);
}
- if malloc.GetStats().sys > 1e9 {
+ if malloc.GetStats().Sys > 1e9 {
panicln("too much memory allocated");
}
}
- n2 := stats.alloc;
+ n2 := stats.Alloc;
if *chatty {
fmt.Printf("size=%d count=%d stats=%+v\n", size, count, *stats);
}
- n3 := stats.alloc;
+ n3 := stats.Alloc;
for j := 0; j < count; j++ {
i := j;
if *reverse {
i = count - 1 - j;
}
- alloc := stats.alloc;
+ alloc := stats.Alloc;
base, n := malloc.Lookup(b[i]);
if base != b[i] || !OkAmount(uintptr(size), n) {
panicln("lookup failed: got", base, n, "for", b[i]);
}
malloc.Free(b[i]);
- if stats.alloc != alloc - uint64(n) {
- panicln("free alloc got", stats.alloc, "expected", alloc - uint64(n), "after free of", n);
+ if stats.Alloc != alloc - uint64(n) {
+ panicln("free alloc got", stats.Alloc, "expected", alloc - uint64(n), "after free of", n);
}
- if malloc.GetStats().sys > 1e9 {
+ if malloc.GetStats().Sys > 1e9 {
panicln("too much memory allocated");
}
}
- n4 := stats.alloc;
+ n4 := stats.Alloc;
if *chatty {
fmt.Printf("size=%d count=%d stats=%+v\n", size, count, *stats);
const arraylen = 2; // BUG: shouldn't need this
-func P(a []string) string {
+export func P(a []string) string {
s := "{";
for i := 0; i < len(a); i++ {
if i > 0 {
package main
-type S string
-type S1 string
-type I int
-type I1 int
-type T struct { x int }
-type T1 T
+export type S string
+export type S1 string
+export type I int
+export type I1 int
+export type T struct { x int }
+export type T1 T
func (s S) val() int { return 1 }
func (s *S1) val() int { return 2 }
//func (t T) val() int { return 7 }
func (t *T1) val() int { return 8 }
-type Val interface {
+export type Val interface {
val() int
}
package main
-type T struct { }
+export type T struct { }
func (t *T) M(int, string); // GCCGO_ERROR "previous"
func (t *T) M(int, float) { } // ERROR "redeclared|redefinition"
package main
-type T struct {a int}
-type P *T
-type P1 *T
+export type T struct {a int}
+export type P *T
+export type P1 *T
func (p P) val() int { return 1 } // ERROR "receiver"
func (p *P1) val() int { return 1 } // ERROR "receiver"
package main
-type T [] int
+export type T [] int
func (t T) Len() int { return len(t) }
-type I interface {
+export type I interface {
Len() int
}
package main
-type T struct {
+export type T struct {
i int
}
-type IN interface {
+export type IN interface {
}
func main() {
package main
-type Number struct {
+export type Number struct {
next *Number
}
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
-func Generate(ch chan<- int) {
+export func Generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}
// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
-func Filter(in <-chan int, out chan<- int, prime int) {
+export 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 {
}
// The prime sieve: Daisy-chain Filter processes together.
-func Sieve() {
+export func Sieve() {
ch := make(chan int); // Create a new channel.
go Generate(ch); // Start Generate() as a subprocess.
for {
mask4 = 1 << iota;
)
-type (
+export type (
Empty interface {};
Point struct {
x, y int;
import "array"
-type S struct {
+export type S struct {
val int
}