Implemented compilation finished events

This commit is contained in:
Eduard Urbach 2024-06-30 11:41:59 +02:00
parent b8c011d742
commit aba9cf2412
Signed by: eduard
GPG key ID: 49226B848C78F6C8
8 changed files with 72 additions and 50 deletions

View file

@ -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]