aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-09-24 14:18:50 +0200
committerAyke van Laethem <[email protected]>2018-09-24 15:46:05 +0200
commit8a468786dfa371113f363f00c3fb0fbc6f30ed6b (patch)
treef02400adaa5414935c11c1114f22257d357d9cf4 /main.go
parentddd4a39cb85a5e652e82edf0d0475f0b5218235b (diff)
downloadtinygo-8a468786dfa371113f363f00c3fb0fbc6f30ed6b.tar.gz
tinygo-8a468786dfa371113f363f00c3fb0fbc6f30ed6b.zip
compiler: use config struct for options
Diffstat (limited to 'main.go')
-rw-r--r--main.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/main.go b/main.go
index 635b4e57f..2965bb08d 100644
--- a/main.go
+++ b/main.go
@@ -9,7 +9,6 @@ import (
"os"
"os/exec"
"path/filepath"
- "runtime"
"strings"
"github.com/aykevl/llvm/bindings/go/llvm"
@@ -18,7 +17,14 @@ import (
// Helper function for Compiler object.
func Compile(pkgName, outpath string, spec *TargetSpec, printIR, dumpSSA bool, printSizes string, action func(string) error) error {
- c, err := compiler.NewCompiler(pkgName, spec.Triple, dumpSSA)
+ config := compiler.Config{
+ Triple: spec.Triple,
+ Debug: true, // TODO: make configurable
+ DumpSSA: dumpSSA,
+ RootDir: sourceDir(),
+ BuildTags: spec.BuildTags,
+ }
+ c, err := compiler.NewCompiler(pkgName, config)
if err != nil {
return err
}
@@ -32,7 +38,7 @@ func Compile(pkgName, outpath string, spec *TargetSpec, printIR, dumpSSA bool, p
fmt.Println(c.IR())
}()
}
- return c.Parse(pkgName, sourceDir(), spec.BuildTags)
+ return c.Parse(pkgName)
}()
if parseErr != nil {
return parseErr
@@ -190,11 +196,14 @@ func Flash(pkgName, target, port string, printIR, dumpSSA bool, printSizes strin
// Run the specified package directly (using JIT or interpretation).
func Run(pkgName string) error {
- c, err := compiler.NewCompiler(pkgName, llvm.DefaultTargetTriple(), false)
+ config := compiler.Config{
+ RootDir: sourceDir(),
+ }
+ c, err := compiler.NewCompiler(pkgName, config)
if err != nil {
return errors.New("compiler: " + err.Error())
}
- err = c.Parse(pkgName, sourceDir(), []string{runtime.GOOS, runtime.GOARCH})
+ err = c.Parse(pkgName)
if err != nil {
return errors.New("compiler: " + err.Error())
}