Implemented switch statements
This commit is contained in:
parent
09ec8d8446
commit
52d1de042c
10 changed files with 170 additions and 27 deletions
|
@ -20,11 +20,6 @@ func Count(body AST, buffer []byte, kind token.Kind, name string) uint8 {
|
|||
case *Define:
|
||||
count += node.Expression.Count(buffer, kind, name)
|
||||
|
||||
case *Return:
|
||||
if node.Value != nil {
|
||||
count += node.Value.Count(buffer, kind, name)
|
||||
}
|
||||
|
||||
case *If:
|
||||
count += node.Condition.Count(buffer, kind, name)
|
||||
count += Count(node.Body, buffer, kind, name)
|
||||
|
@ -33,6 +28,20 @@ func Count(body AST, buffer []byte, kind token.Kind, name string) uint8 {
|
|||
case *Loop:
|
||||
count += Count(node.Body, buffer, kind, name)
|
||||
|
||||
case *Return:
|
||||
if node.Value != nil {
|
||||
count += node.Value.Count(buffer, kind, name)
|
||||
}
|
||||
|
||||
case *Switch:
|
||||
for _, c := range node.Cases {
|
||||
if c.Condition != nil {
|
||||
count += c.Condition.Count(buffer, kind, name)
|
||||
}
|
||||
|
||||
count += Count(c.Body, buffer, kind, name)
|
||||
}
|
||||
|
||||
default:
|
||||
panic("unknown AST type")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue