Rename the implicit in variable to args

This commit is contained in:
Nigel Tao committed 2018-07-29 10:26:22 +10:00
1 parent 58ded30954
commit ca06083f8a
19 files changed
+254 -252

No files matched your search

+4 -4
View File
@@ -196,9 +196,9 @@ loop:
}
// o is a yield statement.
//
// Drop any facts involving in or this.
// Drop any facts involving args or this.
if err := q.facts.update(func(x *a.Expr) (*a.Expr, error) {
if x.Mentions(exprIn) || x.Mentions(exprThis) {
if x.Mentions(exprArgs) || x.Mentions(exprThis) {
return nil, nil
}
return x, nil
@@ -857,8 +857,8 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (a.Bounds, error) {
return a.Bounds{}, err
}
// TODO: delete this hack that only matches "in".
if n.LHS().AsExpr().Ident() == t.IDIn {
// TODO: delete this hack that only matches "args".
if n.LHS().AsExpr().Ident() == t.IDArgs {
for _, o := range q.astFunc.In().Fields() {
o := o.AsField()
if o.Name() == n.Ident() {
+2 -2
View File
@@ -418,7 +418,7 @@ func (c *Checker) checkStructDecl(node *a.Node) error {
setPlaceholderMBoundsMType(n.AsNode())
// A struct declaration implies a reset method.
in := a.NewStruct(0, n.Filename(), n.Line(), t.IDIn, nil)
in := a.NewStruct(0, n.Filename(), n.Line(), t.IDArgs, nil)
f := a.NewFunc(0, n.Filename(), n.Line(), qid[1], t.IDReset, in, nil, nil, nil)
if qid[0] != 0 {
f.AsNode().AsRaw().SetPackage(c.tm, qid[0])
@@ -548,7 +548,7 @@ func (c *Checker) checkFuncSignature(node *a.Node) error {
inTyp.AsNode().SetMType(typeExprTypeExpr)
localVars := typeMap{
t.IDIn: inTyp,
t.IDArgs: inTyp,
}
if qqid[1] != 0 {
if _, ok := c.structs[t.QID{qqid[0], qqid[1]}]; !ok {
+2 -2
View File
@@ -27,9 +27,9 @@ import (
)
var (
exprIn = a.NewExpr(0, 0, 0, t.IDIn, nil, nil, nil, nil)
exprThis = a.NewExpr(0, 0, 0, t.IDThis, nil, nil, nil, nil)
exprArgs = a.NewExpr(0, 0, 0, t.IDArgs, nil, nil, nil, nil)
exprNullptr = a.NewExpr(0, 0, 0, t.IDNullptr, nil, nil, nil, nil)
exprThis = a.NewExpr(0, 0, 0, t.IDThis, nil, nil, nil, nil)
)
var (
+1 -1
View File
@@ -632,7 +632,7 @@ func (q *checker) tcheckDot(n *a.Expr, depth uint32) error {
}
s := (*a.Struct)(nil)
if q.astFunc != nil && lQID[0] == 0 && lQID[1] == t.IDIn {
if q.astFunc != nil && lQID[0] == 0 && lQID[1] == t.IDArgs {
s = q.astFunc.In()
}
if s == nil {
+7 -7
View File
@@ -194,13 +194,13 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) {
flags |= a.FlagsImpure | a.FlagsSuspendible
p.src = p.src[1:]
}
inFields, err := p.parseList(t.IDCloseParen, (*parser).parseFieldNode)
argFields, err := p.parseList(t.IDCloseParen, (*parser).parseFieldNode)
if err != nil {
return nil, err
}
outTyp := (*a.TypeExpr)(nil)
out := (*a.TypeExpr)(nil)
if p.peek1() != t.IDOpenCurly {
outTyp, err = p.parseTypeExpr()
out, err = p.parseTypeExpr()
if err != nil {
return nil, err
}
@@ -225,8 +225,8 @@ func (p *parser) parseTopLevelDecl() (*a.Node, error) {
return nil, fmt.Errorf(`parse: expected (implicit) ";", got %q at %s:%d`, got, p.filename, p.line())
}
p.src = p.src[1:]
in := a.NewStruct(0, p.filename, line, t.IDIn, inFields)
return a.NewFunc(flags, p.filename, line, id0, id1, in, outTyp, asserts, body).AsNode(), nil
in := a.NewStruct(0, p.filename, line, t.IDArgs, argFields)
return a.NewFunc(flags, p.filename, line, id0, id1, in, out, asserts, body).AsNode(), nil
case t.IDError, t.IDSuspension:
keyword := p.src[0].ID
@@ -863,11 +863,11 @@ func (p *parser) parseIOBindExprNode() (*a.Node, error) {
case 0:
return e.AsNode(), nil
case t.IDDot:
if lhs := e.LHS().AsExpr(); lhs.Operator() == 0 && lhs.Ident() == t.IDIn {
if lhs := e.LHS().AsExpr(); lhs.Operator() == 0 && lhs.Ident() == t.IDArgs {
return e.AsNode(), nil
}
}
return nil, fmt.Errorf(`parse: expected "in.something", got %q at %s:%d`, e.Str(p.tm), p.filename, p.line())
return nil, fmt.Errorf(`parse: expected "args.something", got %q at %s:%d`, e.Str(p.tm), p.filename, p.line())
}
func (p *parser) parseIterateVarNode() (*a.Node, error) {
+5 -5
View File
@@ -443,9 +443,9 @@ const (
IDU32 = ID(0x126)
IDU64 = ID(0x127)
IDThis = ID(0x130)
IDIn = ID(0x131)
IDBase = ID(0x132)
IDArgs = ID(0x130)
IDBase = ID(0x131)
IDThis = ID(0x132)
// TODO Read/Write 24 bits? It might be useful for RGB triples.
@@ -732,9 +732,9 @@ var builtInsByID = [nBuiltInIDs]string{
IDU32: "u32",
IDU64: "u64",
IDThis: "this",
IDIn: "in",
IDArgs: "args",
IDBase: "base",
IDThis: "this",
IDUndoByte: "undo_byte",
IDReadU8: "read_u8",