return s.newValue1(op, Types[TINT], s.expr(n.Left))
case n.Left.Type.IsString(): // string; not reachable for OCAP
return s.newValue1(ssa.OpStringLen, Types[TINT], s.expr(n.Left))
+ case n.Left.Type.IsMap():
+ s.Unimplementedf("unhandled len(map)")
+ return nil
+ case n.Left.Type.IsChan():
+ if n.Op == OCAP {
+ s.Unimplementedf("unhandled cap(chan)")
+ } else {
+ s.Unimplementedf("unhandled len(chan)")
+ }
+ return nil
default: // array
return s.constInt(Types[TINT], n.Left.Type.Bound)
}
return t.Etype == TSTRING
}
+func (t *Type) IsMap() bool {
+ return t.Etype == TMAP
+}
+
+func (t *Type) IsChan() bool {
+ return t.Etype == TCHAN
+}
+
func (t *Type) IsSlice() bool {
return t.Etype == TARRAY && t.Bound < 0
}