diff options
Diffstat (limited to 'src/cmd/compile/internal/gc/noder.go')
-rw-r--r-- | src/cmd/compile/internal/gc/noder.go | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/cmd/compile/internal/gc/noder.go b/src/cmd/compile/internal/gc/noder.go index c83b60dcd4..3e8703f050 100644 --- a/src/cmd/compile/internal/gc/noder.go +++ b/src/cmd/compile/internal/gc/noder.go @@ -19,6 +19,7 @@ import ( "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/syntax" + "cmd/compile/internal/typecheck" "cmd/compile/internal/types" "cmd/internal/objabi" "cmd/internal/src" @@ -160,7 +161,7 @@ type noder struct { func (p *noder) funcBody(fn *ir.Func, block *syntax.BlockStmt) { oldScope := p.scope p.scope = 0 - funchdr(fn) + typecheck.StartFuncBody(fn) if block != nil { body := p.stmts(block.List) @@ -173,7 +174,7 @@ func (p *noder) funcBody(fn *ir.Func, block *syntax.BlockStmt) { fn.Endlineno = base.Pos } - funcbody() + typecheck.FinishFuncBody() p.scope = oldScope } @@ -261,7 +262,7 @@ func (p *noder) node() { p.checkUnused(pragma) } - Target.Decls = append(Target.Decls, p.decls(p.file.DeclList)...) + typecheck.Target.Decls = append(typecheck.Target.Decls, p.decls(p.file.DeclList)...) base.Pos = src.NoXPos clearImports() @@ -273,7 +274,7 @@ func (p *noder) processPragmas() { p.errorAt(l.pos, "//go:linkname only allowed in Go files that import \"unsafe\"") continue } - n := ir.AsNode(lookup(l.local).Def) + n := ir.AsNode(typecheck.Lookup(l.local).Def) if n == nil || n.Op() != ir.ONAME { // TODO(mdempsky): Change to p.errorAt before Go 1.17 release. // base.WarnfAt(p.makeXPos(l.pos), "//go:linkname must refer to declared function or variable (will be an error in Go 1.17)") @@ -285,7 +286,7 @@ func (p *noder) processPragmas() { } n.Sym().Linkname = l.remote } - Target.CgoPragmas = append(Target.CgoPragmas, p.pragcgobuf...) + typecheck.Target.CgoPragmas = append(typecheck.Target.CgoPragmas, p.pragcgobuf...) } func (p *noder) decls(decls []syntax.Decl) (l []ir.Node) { @@ -342,7 +343,7 @@ func (p *noder) importDecl(imp *syntax.ImportDecl) { } if !ipkg.Direct { - Target.Imports = append(Target.Imports, ipkg) + typecheck.Target.Imports = append(typecheck.Target.Imports, ipkg) } ipkg.Direct = true @@ -350,7 +351,7 @@ func (p *noder) importDecl(imp *syntax.ImportDecl) { if imp.LocalPkgName != nil { my = p.name(imp.LocalPkgName) } else { - my = lookup(ipkg.Name) + my = typecheck.Lookup(ipkg.Name) } pack := ir.NewPkgName(p.pos(imp), my, ipkg) @@ -366,7 +367,7 @@ func (p *noder) importDecl(imp *syntax.ImportDecl) { return } if my.Def != nil { - redeclare(pack.Pos(), my, "as imported package name") + typecheck.Redeclared(pack.Pos(), my, "as imported package name") } my.Def = pack my.Lastlineno = pack.Pos() @@ -401,7 +402,7 @@ func (p *noder) varDecl(decl *syntax.VarDecl) []ir.Node { } p.setlineno(decl) - return variter(names, typ, exprs) + return typecheck.DeclVars(names, typ, exprs) } // constState tracks state between constant specifiers within a @@ -449,7 +450,7 @@ func (p *noder) constDecl(decl *syntax.ConstDecl, cs *constState) []ir.Node { if decl.Values == nil { v = ir.DeepCopy(n.Pos(), v) } - declare(n, dclcontext) + typecheck.Declare(n, typecheck.DeclContext) n.Ntype = typ n.Defn = v @@ -469,7 +470,7 @@ func (p *noder) constDecl(decl *syntax.ConstDecl, cs *constState) []ir.Node { func (p *noder) typeDecl(decl *syntax.TypeDecl) ir.Node { n := p.declName(ir.OTYPE, decl.Name) - declare(n, dclcontext) + typecheck.Declare(n, typecheck.DeclContext) // decl.Type may be nil but in that case we got a syntax error during parsing typ := p.typeExprOrNil(decl.Type) @@ -514,7 +515,7 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) ir.Node { if len(t.Params) > 0 || len(t.Results) > 0 { base.ErrorfAt(f.Pos(), "func init must have no arguments and no return values") } - Target.Inits = append(Target.Inits, f) + typecheck.Target.Inits = append(typecheck.Target.Inits, f) } if types.LocalPkg.Name == "main" && name.Name == "main" { @@ -541,7 +542,7 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) ir.Node { } if fun.Recv == nil { - declare(f.Nname, ir.PFUNC) + typecheck.Declare(f.Nname, ir.PFUNC) } p.funcBody(f, fun.Body) @@ -704,7 +705,7 @@ func (p *noder) expr(expr syntax.Expr) ir.Node { pos, op := p.pos(expr), p.unOp(expr.Op) switch op { case ir.OADDR: - return nodAddrAt(pos, x) + return typecheck.NodAddrAt(pos, x) case ir.ODEREF: return ir.NewStarExpr(pos, x) } @@ -950,7 +951,7 @@ func (p *noder) embedded(typ syntax.Expr) *ir.Field { } sym := p.packname(typ) - n := ir.NewField(p.pos(typ), lookup(sym.Name), importName(sym).(ir.Ntype), nil) + n := ir.NewField(p.pos(typ), typecheck.Lookup(sym.Name), importName(sym).(ir.Ntype), nil) n.Embedded = true if isStar { @@ -1136,8 +1137,8 @@ func (p *noder) assignList(expr syntax.Expr, defn ir.Node, colas bool) []ir.Node } newOrErr = true - n := NewName(sym) - declare(n, dclcontext) + n := typecheck.NewName(sym) + typecheck.Declare(n, typecheck.DeclContext) n.Defn = defn defn.PtrInit().Append(ir.NewDecl(base.Pos, ir.ODCL, n)) res[i] = n @@ -1245,8 +1246,8 @@ func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitch n.List.Set(p.exprList(clause.Cases)) } if tswitch != nil && tswitch.Tag != nil { - nn := NewName(tswitch.Tag.Sym()) - declare(nn, dclcontext) + nn := typecheck.NewName(tswitch.Tag.Sym()) + typecheck.Declare(nn, typecheck.DeclContext) n.Vars = []ir.Node{nn} // keep track of the instances for reporting unused nn.Defn = tswitch @@ -1466,7 +1467,7 @@ var tokenForLitKind = [...]token.Token{ } func (p *noder) name(name *syntax.Name) *types.Sym { - return lookup(name.Value) + return typecheck.Lookup(name.Value) } func (p *noder) mkname(name *syntax.Name) ir.Node { |