From 3b822f8b1787cd79e7df1de2b387001d87cd007e Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 9 Dec 2017 16:03:18 +1100 Subject: [PATCH] Rename some arguments for consistency --- lang/check/bounds.go | 16 ++++++++-------- lang/check/type.go | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 64008678..a95bd2d5 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -1168,35 +1168,35 @@ func (q *checker) bcheckExprAssociativeOp(n *a.Expr, depth uint32) (*big.Int, *b return lMin, lMax, nil } -func (q *checker) bcheckTypeExpr(n *a.TypeExpr) (*big.Int, *big.Int, error) { - if n.IsIdeal() { +func (q *checker) bcheckTypeExpr(typ *a.TypeExpr) (*big.Int, *big.Int, error) { + if typ.IsIdeal() { // TODO: can an ideal type be refined?? return nil, nil, nil } - switch n.Decorator().Key() { + switch typ.Decorator().Key() { case t.KeyPtr, t.KeyOpenBracket, t.KeyColon: return nil, nil, nil } - switch n.Name().Key() { + switch typ.Name().Key() { case t.KeyReader1, t.KeyWriter1: return nil, nil, nil } b := [2]*big.Int{} - if key := n.Name().Key(); key < t.Key(len(numTypeBounds)) { + if key := typ.Name().Key(); key < t.Key(len(numTypeBounds)) { b = numTypeBounds[key] } if b[0] == nil || b[1] == nil { return nil, nil, nil } - if n.IsRefined() { - if x := n.Min(); x != nil { + if typ.IsRefined() { + if x := typ.Min(); x != nil { if cv := x.ConstValue(); cv != nil && b[0].Cmp(cv) < 0 { b[0] = cv } } - if x := n.Max(); x != nil { + if x := typ.Max(); x != nil { if cv := x.ConstValue(); cv != nil && b[1].Cmp(cv) > 0 { b[1] = cv } diff --git a/lang/check/type.go b/lang/check/type.go index 3fcfa304..71ffc83a 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -1106,17 +1106,17 @@ func (q *checker) tcheckExprAssociativeOp(n *a.Expr, depth uint32) error { return fmt.Errorf("check: unrecognized token.Key (0x%X) for tcheckExprAssociativeOp", n.ID0().Key()) } -func (q *checker) tcheckTypeExpr(n *a.TypeExpr, depth uint32) error { +func (q *checker) tcheckTypeExpr(typ *a.TypeExpr, depth uint32) error { if depth > a.MaxTypeExprDepth { return fmt.Errorf("check: type expression recursion depth too large") } depth++ swtch: - switch n.Decorator().Key() { + switch typ.Decorator().Key() { case 0: - if n.Name().IsNumType() { - for _, b := range n.Bounds() { + if typ.Name().IsNumType() { + for _, b := range typ.Bounds() { if b == nil { continue } @@ -1129,22 +1129,22 @@ swtch: } break } - if n.Min() != nil || n.Max() != nil { + if typ.Min() != nil || typ.Max() != nil { // TODO: reject. You can only refine numeric types. } - switch n.Name().Key() { + switch typ.Name().Key() { case t.KeyBool, t.KeyStatus, t.KeyReader1, t.KeyWriter1: break swtch } for _, s := range q.c.structs { - if s.ID == n.Name() { + if s.ID == typ.Name() { break swtch } } - return fmt.Errorf("check: %q is not a type", n.Name().Str(q.tm)) + return fmt.Errorf("check: %q is not a type", typ.Name().Str(q.tm)) case t.KeyOpenBracket: - aLen := n.ArrayLength() + aLen := typ.ArrayLength() if err := q.tcheckExpr(aLen, 0); err != nil { return err } @@ -1155,18 +1155,18 @@ swtch: // TODO: also check t.KeyNptr? Where else should we look for nptr? case t.KeyPtr, t.KeyColon: - if err := q.tcheckTypeExpr(n.Inner(), depth); err != nil { + if err := q.tcheckTypeExpr(typ.Inner(), depth); err != nil { return err } default: // TODO: don't hard-code deflate.decoder as an acceptable type. - if q.tm.ByID(n.Decorator()) == "deflate" && q.tm.ByID(n.Name()) == "decoder" { + if q.tm.ByID(typ.Decorator()) == "deflate" && q.tm.ByID(typ.Name()) == "decoder" { break } return fmt.Errorf("check: unrecognized node for tcheckTypeExpr") } - n.Node().SetTypeChecked() + typ.Node().SetTypeChecked() return nil }