Implemented compilation finished events
This commit is contained in:
parent
b8c011d742
commit
aba9cf2412
8 changed files with 72 additions and 50 deletions
|
@ -20,6 +20,7 @@ type Function struct {
|
|||
|
||||
// Compile turns a function into machine code.
|
||||
func (f *Function) Compile() {
|
||||
defer close(f.finished)
|
||||
f.assembler.Label(f.Name)
|
||||
f.err = f.CompileTokens(f.Body)
|
||||
f.assembler.Return()
|
||||
|
@ -124,6 +125,11 @@ func (f *Function) String() string {
|
|||
return f.Name
|
||||
}
|
||||
|
||||
// Wait will block until the compilation finishes.
|
||||
func (f *Function) Wait() {
|
||||
<-f.finished
|
||||
}
|
||||
|
||||
// identifierExists returns true if the identifier has been defined.
|
||||
func (f *Function) identifierExists(name string) bool {
|
||||
_, exists := f.variables[name]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue