Reduced memory usage
This commit is contained in:
parent
04ba68a075
commit
3ea2f280d9
@ -11,8 +11,13 @@ func (f *Function) AddVariable(variable *scope.Variable) {
|
|||||||
f.Comment("%s = %s (%d uses)", variable.Name, variable.Register, variable.Alive)
|
f.Comment("%s = %s (%d uses)", variable.Name, variable.Register, variable.Alive)
|
||||||
}
|
}
|
||||||
|
|
||||||
scope := f.CurrentScope()
|
s := f.CurrentScope()
|
||||||
variable.Scope = scope
|
variable.Scope = s
|
||||||
scope.Variables[variable.Name] = variable
|
|
||||||
scope.Use(variable.Register)
|
if s.Variables == nil {
|
||||||
|
s.Variables = map[string]*scope.Variable{}
|
||||||
|
}
|
||||||
|
|
||||||
|
s.Variables[variable.Name] = variable
|
||||||
|
s.Use(variable.Register)
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,10 @@ func NewFunction(name string, file *fs.File, body []token.Token) *Function {
|
|||||||
File: file,
|
File: file,
|
||||||
Body: body,
|
Body: body,
|
||||||
Assembler: asm.Assembler{
|
Assembler: asm.Assembler{
|
||||||
Instructions: make([]asm.Instruction, 0, 32),
|
Instructions: make([]asm.Instruction, 0, 8),
|
||||||
},
|
},
|
||||||
Stack: scope.Stack{
|
Stack: scope.Stack{
|
||||||
Scopes: []*scope.Scope{
|
Scopes: []*scope.Scope{{}},
|
||||||
{Variables: map[string]*scope.Variable{}},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
cpu: cpu.CPU{
|
cpu: cpu.CPU{
|
||||||
All: x64.AllRegisters,
|
All: x64.AllRegisters,
|
||||||
|
Loading…
Reference in New Issue
Block a user