This is a creation in Article, where the information may have evolved or changed.
The previous article probably said some how to read XG's source code, but later because too lazy, always do not want to write some very systematic things, so feel or some worth to say about writing a bit, do a memo.
In fact, the general content of XG is placed in the SRC/CMD/GC, and the entire compilation phase is the most important thing is to go.y this file, because this is the Bison syntax definition file. In fact, go in the compilation phase will simply put all the content into the nodelist data structure as the result of parsing, and then export to write a *.6 (such as the AMD64 architecture), this. 6 of the file is probably this:
Amd64
Exports automatically generated from
Test.go in package "main"
$$//Exports
Package Main
Func "". Main ()
var "". Initdone Road Uint8
Func "". Init ()
$$//local types
$$
....
Specific file format, you can refer to the implementation of the DumpObj function in SRC/CMD/GC/OBJ.C
And if we write an import in the source file, it will actually import the obj file into the current lexical parsing process, such as
Import xxx
It just loads the pkg/amd64-linux/xxx.a in, and then parses the obj file.
If we look at GO.Y's syntax analysis definition, we will see many definitions of hidden and there naming, such as Import_there, Hidden_import, etc., which are actually defined from the obj file.
Another example is that we might see some syntax definitions that don't exist in the source code at all, but it did compile because the source files were inserted into some other fragments as needed during the compilation, such as some libraries of builtin or some of the Lib libraries that were customized.
Understanding this, basically on the go to the compilation process has a knowledge of the fact that the go to compile the process of doing is to turn it into obj finished, at least we do not see more work at the moment. The next step is to get a deeper understanding of the implementation of the XL, which is part of the process of turning obj into executable code, which should be more interesting.