// make fake type to check later to
// trigger channel argument check.
- t1 := typ(TCHANARGS)
-
- t1.Type = t
+ t1 := typWrapper(TCHANARGS, t)
checkwidth(t1)
case TCHANARGS:
- t1 := t.Type
- dowidth(t.Type) // just in case
+ t1 := t.Wrapped()
+ dowidth(t1) // just in case
if t1.Type.Width >= 1<<16 {
Yyerror("channel element type too large (>64kB)")
}
// make fake type to check later to
// trigger function argument computation.
case TFUNC:
- t1 := typ(TFUNCARGS)
-
- t1.Type = t
+ t1 := typWrapper(TFUNCARGS, t)
checkwidth(t1)
-
- // width of func type is pointer
- w = int64(Widthptr)
+ w = int64(Widthptr) // width of func type is pointer
// function is 3 cated structures;
// compute their widths as side-effect.
case TFUNCARGS:
- t1 := t.Type
-
- w = widstruct(t.Type, t1.Recvs(), 0, 0)
- w = widstruct(t.Type, t1.Params(), w, Widthreg)
- w = widstruct(t.Type, t1.Results(), w, Widthreg)
+ t1 := t.Wrapped()
+ w = widstruct(t1, t1.Recvs(), 0, 0)
+ w = widstruct(t1, t1.Params(), w, Widthreg)
+ w = widstruct(t1, t1.Results(), w, Widthreg)
t1.Argwid = w
if w%int64(Widthreg) != 0 {
Warn("bad type %v %d\n", t1, w)
return t
}
+// typWrapper returns a new wrapper psuedo-type.
+func typWrapper(et EType, wrapped *Type) *Type {
+ switch et {
+ case TCHANARGS, TFUNCARGS, TDDDFIELD:
+ default:
+ Fatalf("typWrapper bad etype %s", et)
+ }
+ t := typ(et)
+ t.Type = wrapped
+ return t
+}
+
func newField() *Field {
return &Field{
Offset: BADWIDTH,
return t.Type
}
+// Wrapped returns the type that pseudo-type t wraps.
+func (t *Type) Wrapped() *Type {
+ switch t.Etype {
+ case TCHANARGS, TFUNCARGS, TDDDFIELD:
+ default:
+ Fatalf("Type.Wrapped %s", t.Etype)
+ }
+ return t.Type
+}
+
func (t *Type) Methods() *Fields {
// TODO(mdempsky): Validate t?
return &t.methods