From 969a394a9451fc2eac24ba30522c603f664d4a1a Mon Sep 17 00:00:00 2001 From: "Iskander (Alex) Sharipov" Date: Sat, 1 Jan 2022 18:07:16 +0300 Subject: [PATCH] dsl: add ExprType.HasPointers() predicate (#336) --- dsl/dsl.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dsl/dsl.go b/dsl/dsl.go index 8ef50586..6b4f6ff4 100644 --- a/dsl/dsl.go +++ b/dsl/dsl.go @@ -216,6 +216,18 @@ func (ExprType) Implements(typ typeName) bool { return boolResult } // Is reports whether a type is identical to a given type. func (ExprType) Is(typ string) bool { return boolResult } +// HasPointers reports whether a type contains at least one pointer. +// +// We try to be as close to the Go sense of pointer-free objects as possible, +// therefore string type is not considered to be a pointer-free type. +// +// This function may return "true" for some complicated cases as a +// conservative result. It never returns "false" for a type that +// actually contains a pointer. +// +// So this function is mostly useful for !HasPointers() form. +func (ExprType) HasPointers() bool { return boolResult } + // OfKind reports whether a matched expr type is compatible with the specified kind. // // Only a few "kinds" are recognized, the list is provided below.