mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: count current amount of locals correctly
This commit is contained in:
parent
637f75d9ef
commit
c57d4cfff2
2 changed files with 21 additions and 4 deletions
|
@ -139,16 +139,18 @@ func (c *funcScope) stackSize() int64 {
|
|||
|
||||
// newVariable creates a new local variable or argument in the scope of the function.
|
||||
func (c *funcScope) newVariable(t varType, name string) int {
|
||||
c.i++
|
||||
var n int
|
||||
switch t {
|
||||
case varLocal:
|
||||
c.locals[name] = c.i
|
||||
n = len(c.locals)
|
||||
c.locals[name] = n
|
||||
case varArgument:
|
||||
c.arguments[name] = c.i
|
||||
n = len(c.arguments)
|
||||
c.arguments[name] = n
|
||||
default:
|
||||
panic("invalid type")
|
||||
}
|
||||
return c.i
|
||||
return n
|
||||
}
|
||||
|
||||
// newLocal creates a new local variable into the scope of the function.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue