From 881d6064d23d9da5c7ff368bc7d41d271290deff Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 15 Dec 2009 15:27:16 -0800 Subject: 1) Change default gofmt default settings for parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067 --- src/pkg/exp/eval/bridge.go | 74 +++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'src/pkg/exp/eval/bridge.go') diff --git a/src/pkg/exp/eval/bridge.go b/src/pkg/exp/eval/bridge.go index fed27930f..43a6fd30d 100644 --- a/src/pkg/exp/eval/bridge.go +++ b/src/pkg/exp/eval/bridge.go @@ -5,9 +5,9 @@ package eval import ( - "log"; - "go/token"; - "reflect"; + "log" + "go/token" + "reflect" ) /* @@ -15,8 +15,8 @@ import ( */ var ( - evalTypes = make(map[reflect.Type]Type); - nativeTypes = make(map[Type]reflect.Type); + evalTypes = make(map[reflect.Type]Type) + nativeTypes = make(map[Type]reflect.Type) ) // TypeFromNative converts a regular Go type into a the corresponding @@ -26,14 +26,14 @@ func TypeFromNative(t reflect.Type) Type { return et } - var nt *NamedType; + var nt *NamedType if t.Name() != "" { - name := t.PkgPath() + "·" + t.Name(); - nt = &NamedType{token.Position{}, name, nil, true, make(map[string]Method)}; - evalTypes[t] = nt; + name := t.PkgPath() + "·" + t.Name() + nt = &NamedType{token.Position{}, name, nil, true, make(map[string]Method)} + evalTypes[t] = nt } - var et Type; + var et Type switch t := t.(type) { case *reflect.BoolType: et = BoolType @@ -73,24 +73,24 @@ func TypeFromNative(t reflect.Type) Type { case *reflect.ChanType: log.Crashf("%T not implemented", t) case *reflect.FuncType: - nin := t.NumIn(); + nin := t.NumIn() // Variadic functions have DotDotDotType at the end - varidic := false; + varidic := false if nin > 0 { if _, ok := t.In(nin - 1).(*reflect.DotDotDotType); ok { - varidic = true; - nin--; + varidic = true + nin-- } } - in := make([]Type, nin); + in := make([]Type, nin) for i := range in { in[i] = TypeFromNative(t.In(i)) } - out := make([]Type, t.NumOut()); + out := make([]Type, t.NumOut()) for i := range out { out[i] = TypeFromNative(t.Out(i)) } - et = NewFuncType(in, varidic, out); + et = NewFuncType(in, varidic, out) case *reflect.InterfaceType: log.Crashf("%T not implemented", t) case *reflect.MapType: @@ -100,16 +100,16 @@ func TypeFromNative(t reflect.Type) Type { case *reflect.SliceType: et = NewSliceType(TypeFromNative(t.Elem())) case *reflect.StructType: - n := t.NumField(); - fields := make([]StructField, n); + n := t.NumField() + fields := make([]StructField, n) for i := 0; i < n; i++ { - sf := t.Field(i); + sf := t.Field(i) // TODO(austin) What to do about private fields? - fields[i].Name = sf.Name; - fields[i].Type = TypeFromNative(sf.Type); - fields[i].Anonymous = sf.Anonymous; + fields[i].Name = sf.Name + fields[i].Type = TypeFromNative(sf.Type) + fields[i].Anonymous = sf.Anonymous } - et = NewStructType(fields); + et = NewStructType(fields) case *reflect.UnsafePointerType: log.Crashf("%T not implemented", t) default: @@ -118,35 +118,35 @@ func TypeFromNative(t reflect.Type) Type { if nt != nil { if _, ok := et.(*NamedType); !ok { - nt.Complete(et); - et = nt; + nt.Complete(et) + et = nt } } - nativeTypes[et] = t; - evalTypes[t] = et; + nativeTypes[et] = t + evalTypes[t] = et - return et; + return et } // TypeOfNative returns the interpreter Type of a regular Go value. -func TypeOfNative(v interface{}) Type { return TypeFromNative(reflect.Typeof(v)) } +func TypeOfNative(v interface{}) Type { return TypeFromNative(reflect.Typeof(v)) } /* * Function bridging */ type nativeFunc struct { - fn func(*Thread, []Value, []Value); - in, out int; + fn func(*Thread, []Value, []Value) + in, out int } func (f *nativeFunc) NewFrame() *Frame { - vars := make([]Value, f.in+f.out); - return &Frame{nil, vars}; + vars := make([]Value, f.in+f.out) + return &Frame{nil, vars} } -func (f *nativeFunc) Call(t *Thread) { f.fn(t, t.f.Vars[0:f.in], t.f.Vars[f.in:f.in+f.out]) } +func (f *nativeFunc) Call(t *Thread) { f.fn(t, t.f.Vars[0:f.in], t.f.Vars[f.in:f.in+f.out]) } // FuncFromNative creates an interpreter function from a native // function that takes its in and out arguments as slices of @@ -161,6 +161,6 @@ func FuncFromNative(fn func(*Thread, []Value, []Value), t *FuncType) FuncValue { // the type will be given as a nil pointer to a function with the // desired signature. func FuncFromNativeTyped(fn func(*Thread, []Value, []Value), t interface{}) (*FuncType, FuncValue) { - ft := TypeOfNative(t).(*FuncType); - return ft, FuncFromNative(fn, ft); + ft := TypeOfNative(t).(*FuncType) + return ft, FuncFromNative(fn, ft) } -- cgit v1.2.3