compiler: support compiling individual .go files

For example:

    tinygo run ./src/examples/test/test.go
This commit is contained in:
Ayke van Laethem
2018-09-24 15:35:50 +02:00
parent a561e9a9ac
commit 1b229a8f8b
2 changed files with 29 additions and 3 deletions
+5 -1
View File
@@ -169,7 +169,11 @@ func (c *Compiler) Parse(mainPath string) error {
ParserMode: parser.ParseComments,
}
config.Import("runtime")
config.Import(mainPath)
if strings.HasSuffix(mainPath, ".go") {
config.CreateFromFilenames("main", mainPath)
} else {
config.Import(mainPath)
}
lprogram, err := config.Load()
if err != nil {
return err