compiler: rename .Parse() to .Compiler()
The fact it was called Parse() is more of a historical accident, as the compiler started out using the Go AST directly instead of Go SSA.
Этот коммит содержится в:
родитель
1b229a8f8b
коммит
6191d4e1ac
2 изменённых файлов: 7 добавлений и 4 удалений
|
@ -141,11 +141,14 @@ func NewCompiler(pkgName string, config Config) (*Compiler, error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
// Return the LLVM module. Only valid after a successful compile.
|
||||
func (c *Compiler) Module() llvm.Module {
|
||||
return c.mod
|
||||
}
|
||||
|
||||
func (c *Compiler) Parse(mainPath string) error {
|
||||
// Compile the given package path or .go file path. Return an error when this
|
||||
// fails (in any stage).
|
||||
func (c *Compiler) Compile(mainPath string) error {
|
||||
tripleSplit := strings.Split(c.Triple, "-")
|
||||
|
||||
config := loader.Config{
|
||||
|
|
6
main.go
6
main.go
|
@ -32,13 +32,13 @@ func Compile(pkgName, outpath string, spec *TargetSpec, printIR, dumpSSA bool, p
|
|||
// Compile Go code to IR.
|
||||
parseErr := func() error {
|
||||
if printIR {
|
||||
// Run this even if c.Parse() panics.
|
||||
// Run this even if c.Compile() panics.
|
||||
defer func() {
|
||||
fmt.Println("Generated LLVM IR:")
|
||||
fmt.Println(c.IR())
|
||||
}()
|
||||
}
|
||||
return c.Parse(pkgName)
|
||||
return c.Compile(pkgName)
|
||||
}()
|
||||
if parseErr != nil {
|
||||
return parseErr
|
||||
|
@ -203,7 +203,7 @@ func Run(pkgName string) error {
|
|||
if err != nil {
|
||||
return errors.New("compiler: " + err.Error())
|
||||
}
|
||||
err = c.Parse(pkgName)
|
||||
err = c.Compile(pkgName)
|
||||
if err != nil {
|
||||
return errors.New("compiler: " + err.Error())
|
||||
}
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче