lexlineno = 1
const BOM = 0xFEFF
+ loadsys()
+
for _, infile = range flag.Args() {
if trace && Debug['x'] != 0 {
fmt.Printf("--- %s ---\n", infile)
return "", false
}
+// loadsys loads the definitions for the low-level runtime and unsafe functions,
+// so that the compiler can generate calls to them,
+// but does not make the names "runtime" or "unsafe" visible as packages.
+func loadsys() {
+ if Debug['A'] != 0 {
+ return
+ }
+
+ block = 1
+ iota_ = -1000000
+
+ importpkg = Runtimepkg
+ cannedimports("runtime.Builtin", runtimeimport)
+ thenewparser.import_package()
+ thenewparser.import_there()
+
+ importpkg = unsafepkg
+ cannedimports("unsafe.o", unsafeimport)
+ thenewparser.import_package()
+ thenewparser.import_there()
+
+ importpkg = nil
+}
+
func fakeimport() {
importpkg = mkpkg("fake")
cannedimports("fake.o", "$$\n")
errorexit()
}
- importpkg = mkpkg(f.U.(string))
- cannedimports("unsafe.o", unsafeimport)
+ importpkg = unsafepkg
+ cannedimports("unsafe.o", "package unsafe\n\n$$\n\n")
imported_unsafe = true
return
}
// parse_file sets up a new parser and parses a single Go source file.
func parse_file() {
thenewparser = parser{}
- thenewparser.loadsys()
thenewparser.next()
thenewparser.file()
}
-// loadsys loads the definitions for the low-level runtime functions,
-// so that the compiler can generate calls to them,
-// but does not make the name "runtime" visible as a package.
-func (p *parser) loadsys() {
- if trace && Debug['x'] != 0 {
- defer p.trace("loadsys")()
- }
-
- importpkg = Runtimepkg
-
- if Debug['A'] != 0 {
- cannedimports("runtime.Builtin", "package runtime safe\n\n$$\n\n")
- } else {
- cannedimports("runtime.Builtin", runtimeimport)
- }
-
- p.import_package()
- p.import_there()
-
- importpkg = nil
-}
-
type parser struct {
tok int32 // next token (one-token look-ahead)
op Op // valid if tok == LASOP