Commit fdf6761e authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: add typPtr

Passes toolstash -cmp.

Change-Id: I721348ed2122b6a9cd87ad2041b6ee3bf6b2bbb5
Reviewed-on: https://go-review.googlesource.com/21306Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent e3c74973
...@@ -1149,19 +1149,11 @@ var ( ...@@ -1149,19 +1149,11 @@ var (
) )
func initPtrto() { func initPtrto() {
ptrToUint8 = ptrto1(Types[TUINT8]) ptrToUint8 = typPtr(Types[TUINT8])
ptrToAny = ptrto1(Types[TANY]) ptrToAny = typPtr(Types[TANY])
ptrToString = ptrto1(Types[TSTRING]) ptrToString = typPtr(Types[TSTRING])
ptrToBool = ptrto1(Types[TBOOL]) ptrToBool = typPtr(Types[TBOOL])
ptrToInt32 = ptrto1(Types[TINT32]) ptrToInt32 = typPtr(Types[TINT32])
}
func ptrto1(t *Type) *Type {
t1 := typ(Tptr)
t1.Type = t
t1.Width = int64(Widthptr)
t1.Align = uint8(Widthptr)
return t1
} }
// Ptrto returns the Type *t. // Ptrto returns the Type *t.
...@@ -1187,7 +1179,7 @@ func Ptrto(t *Type) *Type { ...@@ -1187,7 +1179,7 @@ func Ptrto(t *Type) *Type {
case Types[TBOOL]: case Types[TBOOL]:
return ptrToBool return ptrToBool
} }
return ptrto1(t) return typPtr(t)
} }
func frame(context int) { func frame(context int) {
......
...@@ -267,6 +267,15 @@ func typeChan(elem *Type, dir uint8) *Type { ...@@ -267,6 +267,15 @@ func typeChan(elem *Type, dir uint8) *Type {
return t 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. // typWrapper returns a new wrapper psuedo-type.
func typWrapper(et EType, wrapped *Type) *Type { func typWrapper(et EType, wrapped *Type) *Type {
switch et { switch et {
......
...@@ -361,8 +361,7 @@ func typeinit() { ...@@ -361,8 +361,7 @@ func typeinit() {
dowidth(Types[TSTRING]) dowidth(Types[TSTRING])
dowidth(idealstring) dowidth(idealstring)
itable = typ(Tptr) itable = typPtr(Types[TUINT8])
itable.Type = Types[TUINT8]
} }
func lexinit1() { func lexinit1() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment