Cleaned up function type
This commit is contained in:
parent
f870a5f1f8
commit
67b3a3d820
14 changed files with 310 additions and 294 deletions
|
@ -18,7 +18,7 @@ func (f *Function) CompileVariableDefinition(expr *expression.Expression) error
|
|||
return errors.New(&errors.VariableAlreadyExists{Name: name}, f.File, expr.Children[0].Token.Position)
|
||||
}
|
||||
|
||||
reg, exists := f.CPU.FindFree(f.CPU.General)
|
||||
reg, exists := f.cpu.FindFree(f.cpu.General)
|
||||
|
||||
if !exists {
|
||||
panic("no free registers")
|
||||
|
@ -42,8 +42,8 @@ func (f *Function) CompileVariableDefinition(expr *expression.Expression) error
|
|||
|
||||
func (f *Function) addVariable(variable *Variable) {
|
||||
variable.UsesRemaining = countIdentifier(f.Body, variable.Name)
|
||||
f.Variables[variable.Name] = variable
|
||||
f.CPU.Use(variable.Register)
|
||||
f.variables[variable.Name] = variable
|
||||
f.cpu.Use(variable.Register)
|
||||
}
|
||||
|
||||
func (f *Function) useVariable(variable *Variable) {
|
||||
|
@ -54,7 +54,7 @@ func (f *Function) useVariable(variable *Variable) {
|
|||
}
|
||||
|
||||
if variable.UsesRemaining == 0 {
|
||||
f.CPU.Free(variable.Register)
|
||||
f.cpu.Free(variable.Register)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue