loadsys()
timings.Start("fe", "parse")
- var lines uint
- for _, infile := range flag.Args() {
- block = 1
- iota_ = -1000000
- imported_unsafe = false
- lines += parseFile(infile)
- if nsyntaxerrors != 0 {
- errorexit()
- }
- }
+ lines := parseFiles(flag.Args())
timings.Stop()
timings.AddEvent(int64(lines), "lines")
"cmd/internal/src"
)
+func parseFiles(filenames []string) uint {
+ var lines uint
+ for _, filename := range filenames {
+ lines += parseFile(filename)
+ if nsyntaxerrors != 0 {
+ errorexit()
+ }
+ }
+ return lines
+}
+
func parseFile(filename string) uint {
f, err := os.Open(filename)
if err != nil {
p.file(file)
- if !imported_unsafe {
- for _, pos := range p.linknames {
- p.error(syntax.Error{Pos: pos, Msg: "//go:linkname only allowed in Go files that import \"unsafe\""})
- }
- }
-
if nsyntaxerrors == 0 {
testdclstack()
}
}
func (p *noder) file(file *syntax.File) {
+ block = 1
+ iota_ = -1000000
+ imported_unsafe = false
+
p.lineno(file.PkgName)
mkpackage(file.PkgName.Value)
xtop = append(xtop, p.decls(file.DeclList)...)
+ if !imported_unsafe {
+ for _, pos := range p.linknames {
+ p.error(syntax.Error{Pos: pos, Msg: "//go:linkname only allowed in Go files that import \"unsafe\""})
+ }
+ }
+
// For compatibility with old code only (comparisons w/ toolstash):
// The old line number tracking simply continued incrementing the
// virtual line number (lexlineno) and using it also for lineno.