First cut at a "[] u8" slice type.

This commit is contained in:
Nigel Tao committed 2017-09-08 16:53:59 +10:00
1 parent ceedd8c3b9
commit 519ec373f2
15 files changed
+123 -32

No files matched your search

+5 -3
View File
@@ -456,9 +456,9 @@ func NewJump(keyword t.ID, label t.ID) *Jump {
// MaxTypeExprDepth is an advisory limit for a TypeExpr's recursion depth.
const MaxTypeExprDepth = 63
// TypeExpr is a type expression, such as "u32", "u32[..8]", "pkg.foo", "ptr T"
// or "[8] T":
// - ID0: <0|package name|IDPtr|IDOpenBracket>
// TypeExpr is a type expression, such as "u32", "u32[..8]", "pkg.foo", "ptr
// T", "[8] T" or "[] T":
// - ID0: <0|package name|IDPtr|IDOpenBracket|IDColon>
// - ID1: <0|type name>
// - LHS: <nil|Expr>
// - MHS: <nil|Expr>
@@ -468,6 +468,8 @@ const MaxTypeExprDepth = 63
//
// An IDOpenBracket ID0 means "[LHS] RHS". RHS is the inner type.
//
// An IDColon ID0 means "[] RHS". RHS is the inner type.
//
// Other ID0 values mean a (possibly package-qualified) type like "pkg.foo" or
// "foo". ID0 is the "pkg" or zero, ID1 is the "foo". Such a type can be
// refined as "foo[LHS..MHS]". LHS and MHS are Expr's, possibly nil. For
+3
View File
@@ -188,6 +188,9 @@ func (n *TypeExpr) appendString(buf []byte, tm *t.Map, depth uint32) []byte {
buf = n.ArrayLength().appendString(buf, tm, false, 0)
buf = append(buf, "] "...)
return n.Inner().appendString(buf, tm, depth)
case t.KeyColon:
buf = append(buf, "[] "...)
return n.Inner().appendString(buf, tm, depth)
default:
buf = append(buf, tm.ByID(n.Decorator())...)
buf = append(buf, '.')