From 1435f1d43c4021741b0cc1d9fbdf6f575de07cb3 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 4 May 2018 13:24:58 +1000 Subject: [PATCH] Remove ptr base.u8 methods --- lang/ast/ast.go | 2 -- lang/builtin/builtin.go | 13 ++++--------- lang/check/check.go | 1 - lang/check/resolve.go | 20 -------------------- lang/check/type.go | 11 ----------- 5 files changed, 4 insertions(+), 43 deletions(-) diff --git a/lang/ast/ast.go b/lang/ast/ast.go index 29604819..8a7320c4 100644 --- a/lang/ast/ast.go +++ b/lang/ast/ast.go @@ -669,8 +669,6 @@ const MaxTypeExprDepth = 63 // type. LHS is the receiver type, which may be nil. If non-nil, it will be a // pointee type: "T" instead of "ptr T", "ptr ptr T", etc. // -// TODO: is "pointee type" correct for the built-in ptr base.u8 methods?? -// // TODO: method effects: "foo" vs "foo!" vs "foo?". // // A zero ID0 means a (possibly package-qualified) type like "pkg.foo" or diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index a795f4b3..39712a60 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -134,21 +134,16 @@ var Funcs = []string{ "image_config.initialize!(pixfmt u32, pixsub u32, width u32, height u32, num_loops u32)()", } -// The "T" types here are placeholders for "ptr base.u8" or generic "slice U" -// types. After tokenizing (but before parsing) these XxxFunc strings (e.g. in -// the lang/check package), replace the "T" receiver type with the "◊" diamond, -// to avoid collision with a user-defined "T" type. +// The "T" types here are placeholders for generic "slice U" types. After +// tokenizing (but before parsing) these SliceFunc strings (e.g. in the +// lang/check package), replace the "T" receiver type with the "◊" diamond, to +// avoid collision with a user-defined "T" type. const ( PlaceholderOldName = t.IDCapitalT PlaceholderNewName = t.IDDiamond ) -// TODO: drop the U8. -var PtrU8Funcs = []string{ - // TODO: a length method. -} - var SliceFuncs = []string{ "T.copy_from_slice(s T)(ret u64)", "T.length()(ret u64)", diff --git a/lang/check/check.go b/lang/check/check.go index 9ec61773..9bf07376 100644 --- a/lang/check/check.go +++ b/lang/check/check.go @@ -160,7 +160,6 @@ type Checker struct { useBaseNames map[t.ID]struct{} builtInFuncs map[t.QQID]*a.Func - builtInPtrU8Funcs map[t.QQID]*a.Func builtInSliceFuncs map[t.QQID]*a.Func unsortedStructs []*a.Struct } diff --git a/lang/check/resolve.go b/lang/check/resolve.go index 0375b0f1..aeb8db93 100644 --- a/lang/check/resolve.go +++ b/lang/check/resolve.go @@ -80,17 +80,6 @@ func (c *Checker) builtInFunc(qqid t.QQID) (*a.Func, error) { return c.builtInFuncs[qqid], nil } -func (c *Checker) builtInPtrU8Func(qqid t.QQID) (*a.Func, error) { - if c.builtInPtrU8Funcs == nil { - err := error(nil) - c.builtInPtrU8Funcs, err = parseBuiltInFuncs(c.tm, builtin.PtrU8Funcs, true) - if err != nil { - return nil, err - } - } - return c.builtInPtrU8Funcs[qqid], nil -} - func (c *Checker) builtInSliceFunc(qqid t.QQID) (*a.Func, error) { if c.builtInSliceFuncs == nil { err := error(nil) @@ -158,15 +147,6 @@ func (c *Checker) resolveFunc(typ *a.TypeExpr) (*a.Func, error) { return f, nil } - } else if lTyp.Decorator() == t.IDPtr && (lTyp.Inner().QID() == t.QID{t.IDBase, t.IDU8}) { - qqid[0] = t.IDBase - qqid[1] = t.IDDiamond - if f, err := c.builtInPtrU8Func(qqid); err != nil { - return nil, err - } else if f != nil { - return f, nil - } - } else { if f, err := c.builtInFunc(qqid); err != nil { return nil, err diff --git a/lang/check/type.go b/lang/check/type.go index 810d7e75..e7f4b3da 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -658,17 +658,6 @@ func (q *checker) tcheckDot(n *a.Expr, depth uint32) error { n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), lTyp.Node(), nil, nil)) return nil - } else if ptrLTyp := lhs.MType(); ptrLTyp.Decorator() == t.IDPtr && (lQID == t.QID{t.IDBase, t.IDU8}) { - qqid[0] = t.IDBase - qqid[1] = t.IDDiamond - if f, err := q.c.builtInPtrU8Func(qqid); err != nil { - return err - } else if f == nil { - return fmt.Errorf("check: no ptr base.u8 method %q", n.Ident().Str(q.tm)) - } - n.SetMType(a.NewTypeExpr(t.IDFunc, 0, n.Ident(), ptrLTyp.Node(), nil, nil)) - return nil - } else if lTyp.Decorator() != 0 { return fmt.Errorf("check: invalid type %q for dot-expression LHS %q", lTyp.Str(q.tm), lhs.Str(q.tm)) }