Refactored code structure
This commit is contained in:
@ -30,3 +30,14 @@ func (c *CPU) FindFree(registers []Register) (Register, bool) {
|
||||
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (c *CPU) MustUseFree(registers []Register) Register {
|
||||
register, exists := c.FindFree(registers)
|
||||
|
||||
if !exists {
|
||||
panic("no free registers")
|
||||
}
|
||||
|
||||
c.Use(register)
|
||||
return register
|
||||
}
|
||||
|
Reference in New Issue
Block a user