From 98a88b71bee890f38e136ee0d492c60fff0edbc1 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 5 Sep 2022 11:20:23 -0400 Subject: [PATCH] Updated tree and accessor semantics --- parser/accessors.go | 7 ++++--- parser/tree-tostring.go | 2 +- parser/tree.go | 5 ----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/parser/accessors.go b/parser/accessors.go index 28e51d9..fbf9a32 100644 --- a/parser/accessors.go +++ b/parser/accessors.go @@ -75,10 +75,11 @@ func (what Type) Mutable () (mutable bool) { return } -// Length returns the length of the type if the type is a fixed length array. -// Otherwise, it just returns zero. +// Length returns the length of the type. If it is greater than 1, that means +// the type is a fixed length array. func (what Type) Length () (length uint64) { - if what.kind == TypeKindArray { + length = 1 + if what.length > 1 { length = what.length } return diff --git a/parser/tree-tostring.go b/parser/tree-tostring.go index 77068cb..a7e8cb5 100644 --- a/parser/tree-tostring.go +++ b/parser/tree-tostring.go @@ -80,7 +80,7 @@ func (what Type) ToString () (output string) { output += "}" } - if what.kind == TypeKindArray { + if what.length > 1 { output += fmt.Sprint(":", what.length) } diff --git a/parser/tree.go b/parser/tree.go index fa47cc9..8f13b2c 100644 --- a/parser/tree.go +++ b/parser/tree.go @@ -55,9 +55,6 @@ const ( // TypeKindPointer means it's a pointer TypeKindPointer - // TypeKindArray means it's a fixed length array. - TypeKindArray - // TypeKindVariableArray means it's an array of variable length. TypeKindVariableArray ) @@ -68,8 +65,6 @@ type Type struct { mutable bool kind TypeKind - - // only applicable for fixed length arrays. length uint64 // only applicable for basic.