sim: support Case

This commit is contained in:
Sebastien Bourdeauducq 2015-09-17 17:25:06 +08:00
parent 9d3fd50950
commit ec1d4edf84
1 changed files with 8 additions and 1 deletions

View File

@ -130,8 +130,15 @@ class Evaluator:
self.execute(s.t) self.execute(s.t)
else: else:
self.execute(s.f) self.execute(s.f)
elif isinstance(s, Case):
test = self.eval(s.test)
for k, v in s.cases.items():
if isinstance(k, Constant) and k.value == test:
self.execute(v)
return
if "default" in s.cases:
self.execute(s.cases["default"])
else: else:
# TODO: Case
raise NotImplementedError raise NotImplementedError