]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add typPtr
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 29 Mar 2016 17:18:43 +0000 (10:18 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 30 Mar 2016 17:19:59 +0000 (17:19 +0000)
Passes toolstash -cmp.

Change-Id: I721348ed2122b6a9cd87ad2041b6ee3bf6b2bbb5
Reviewed-on: https://go-review.googlesource.com/21306
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/type.go
src/cmd/compile/internal/gc/universe.go

index 96fe21968661bd6eab02afc37e92f56863239886..6262910634406cf72cc4d6d02846b73ea926e866 100644 (file)
@@ -1149,19 +1149,11 @@ var (
 )
 
 func initPtrto() {
-       ptrToUint8 = ptrto1(Types[TUINT8])
-       ptrToAny = ptrto1(Types[TANY])
-       ptrToString = ptrto1(Types[TSTRING])
-       ptrToBool = ptrto1(Types[TBOOL])
-       ptrToInt32 = ptrto1(Types[TINT32])
-}
-
-func ptrto1(t *Type) *Type {
-       t1 := typ(Tptr)
-       t1.Type = t
-       t1.Width = int64(Widthptr)
-       t1.Align = uint8(Widthptr)
-       return t1
+       ptrToUint8 = typPtr(Types[TUINT8])
+       ptrToAny = typPtr(Types[TANY])
+       ptrToString = typPtr(Types[TSTRING])
+       ptrToBool = typPtr(Types[TBOOL])
+       ptrToInt32 = typPtr(Types[TINT32])
 }
 
 // Ptrto returns the Type *t.
@@ -1187,7 +1179,7 @@ func Ptrto(t *Type) *Type {
        case Types[TBOOL]:
                return ptrToBool
        }
-       return ptrto1(t)
+       return typPtr(t)
 }
 
 func frame(context int) {
index c6a2dd92a32c0b85513790faaddad4c5480cf8b2..2240a59c16fe97bb047a7d192e25a84916765a18 100644 (file)
@@ -267,6 +267,15 @@ func typeChan(elem *Type, dir uint8) *Type {
        return t
 }
 
+// typPtr returns a new pointer type pointing to t.
+func typPtr(elem *Type) *Type {
+       t := typ(Tptr)
+       t.Type = elem
+       t.Width = int64(Widthptr)
+       t.Align = uint8(Widthptr)
+       return t
+}
+
 // typWrapper returns a new wrapper psuedo-type.
 func typWrapper(et EType, wrapped *Type) *Type {
        switch et {
index db323ea6d05df7a8f79e93d12ec186cf1727bb1e..20c1c8c4d52c499837b0b717b0e3881f1649e2a1 100644 (file)
@@ -361,8 +361,7 @@ func typeinit() {
        dowidth(Types[TSTRING])
        dowidth(idealstring)
 
-       itable = typ(Tptr)
-       itable.Type = Types[TUINT8]
+       itable = typPtr(Types[TUINT8])
 }
 
 func lexinit1() {