compat.fhdl.structure: fix If/Elif/Else after 32446831
.
This commit is contained in:
parent
9a1048af50
commit
9eb81609d6
|
@ -55,21 +55,21 @@ class If(ast.Switch):
|
||||||
cond = Value.wrap(cond)
|
cond = Value.wrap(cond)
|
||||||
if len(cond) != 1:
|
if len(cond) != 1:
|
||||||
cond = cond.bool()
|
cond = cond.bool()
|
||||||
super().__init__(cond, {"1": ast.Statement.wrap(stmts)})
|
super().__init__(cond, {("1",): ast.Statement.wrap(stmts)})
|
||||||
|
|
||||||
@deprecated("instead of `.Elif(cond, ...)`, use `with m.Elif(cond): ...`")
|
@deprecated("instead of `.Elif(cond, ...)`, use `with m.Elif(cond): ...`")
|
||||||
def Elif(self, cond, *stmts):
|
def Elif(self, cond, *stmts):
|
||||||
cond = Value.wrap(cond)
|
cond = Value.wrap(cond)
|
||||||
if len(cond) != 1:
|
if len(cond) != 1:
|
||||||
cond = cond.bool()
|
cond = cond.bool()
|
||||||
self.cases = OrderedDict(("-" + k, v) for k, v in self.cases.items())
|
self.cases = OrderedDict((("-" + k,), v) for (k,), v in self.cases.items())
|
||||||
self.cases["1" + "-" * len(self.test)] = ast.Statement.wrap(stmts)
|
self.cases[("1" + "-" * len(self.test),)] = ast.Statement.wrap(stmts)
|
||||||
self.test = Cat(self.test, cond)
|
self.test = Cat(self.test, cond)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@deprecated("instead of `.Else(...)`, use `with m.Else(): ...`")
|
@deprecated("instead of `.Else(...)`, use `with m.Else(): ...`")
|
||||||
def Else(self, *stmts):
|
def Else(self, *stmts):
|
||||||
self.cases["-" * len(self.test)] = ast.Statement.wrap(stmts)
|
self.cases[()] = ast.Statement.wrap(stmts)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue