diff options
author | Ayke van Laethem <[email protected]> | 2021-01-13 17:22:13 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-01-15 14:43:43 +0100 |
commit | a848d720db6e533ea8b014e9bcc76e5c9c73f9b5 (patch) | |
tree | 80d73791eda6a8d3cf6640de305e3bea9310884a /loader | |
parent | dbc438b2ae23414241b693b03697410248b44768 (diff) | |
download | tinygo-a848d720db6e533ea8b014e9bcc76e5c9c73f9b5.tar.gz tinygo-a848d720db6e533ea8b014e9bcc76e5c9c73f9b5.zip |
compiler: refactor and add tests
This commit finally introduces unit tests for the compiler, to check
whether input Go code is converted to the expected output IR.
To make this necessary, a few refactors were needed. Hopefully these
refactors (to compile a program package by package instead of all at
once) will eventually become standard, so that packages can all be
compiled separate from each other and be cached between compiles.
Diffstat (limited to 'loader')
-rw-r--r-- | loader/ssa.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/loader/ssa.go b/loader/ssa.go index c3b87c495..f97511ee3 100644 --- a/loader/ssa.go +++ b/loader/ssa.go @@ -16,3 +16,11 @@ func (p *Program) LoadSSA() *ssa.Program { return prog } + +// LoadSSA constructs the SSA form of this package. +// +// The program must already be parsed and type-checked with the .Parse() method. +func (p *Package) LoadSSA() *ssa.Package { + prog := ssa.NewProgram(p.program.fset, ssa.SanityCheckFunctions|ssa.BareInits|ssa.GlobalDebug) + return prog.CreatePackage(p.Pkg, p.Files, &p.info, true) +} |