codegen-2 2.7.2__py3-none-any.whl → 2.8.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codegen/models/expr.py +2 -0
- codegen/models/statement.py +18 -0
- {codegen_2-2.7.2.dist-info → codegen_2-2.8.1.dist-info}/METADATA +1 -1
- {codegen_2-2.7.2.dist-info → codegen_2-2.8.1.dist-info}/RECORD +6 -6
- {codegen_2-2.7.2.dist-info → codegen_2-2.8.1.dist-info}/LICENSE +0 -0
- {codegen_2-2.7.2.dist-info → codegen_2-2.8.1.dist-info}/WHEEL +0 -0
codegen/models/expr.py
CHANGED
codegen/models/statement.py
CHANGED
|
@@ -253,6 +253,24 @@ class ExceptionStatement(Statement):
|
|
|
253
253
|
return "raise " + self.expr.to_python()
|
|
254
254
|
|
|
255
255
|
|
|
256
|
+
@dataclass
|
|
257
|
+
class AssertionStatement(Statement):
|
|
258
|
+
expr: Expr
|
|
259
|
+
error_msg: Optional[Expr] = None
|
|
260
|
+
|
|
261
|
+
def to_python(self):
|
|
262
|
+
if self.error_msg:
|
|
263
|
+
return f"assert {self.expr.to_python()}, {self.error_msg.to_python()}"
|
|
264
|
+
return f"assert {self.expr.to_python()}"
|
|
265
|
+
|
|
266
|
+
def to_typescript(self):
|
|
267
|
+
if self.error_msg:
|
|
268
|
+
return f"if (!({self.expr.to_typescript()})) throw new Error({self.error_msg.to_typescript()});"
|
|
269
|
+
return (
|
|
270
|
+
f"if (!({self.expr.to_typescript()})) throw new Error('Assertion failed');"
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
256
274
|
@dataclass
|
|
257
275
|
class ForLoopStatement(Statement):
|
|
258
276
|
item: Var
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
codegen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
codegen/models/__init__.py,sha256=j__FrDdGOILIo9jqEDElL3YP69h0xkL2SqrMxSqgpTc,457
|
|
3
3
|
codegen/models/ast.py,sha256=qq1xeWCMbTUXoOXszVYYPTaN-eiPJHdoTbsYbz5MKUo,10518
|
|
4
|
-
codegen/models/expr.py,sha256=
|
|
4
|
+
codegen/models/expr.py,sha256=nmUd3rr4WDYZ83WihD8wRPiw9gJz5UJQFjZIc-n7PWM,11214
|
|
5
5
|
codegen/models/program.py,sha256=mrvtOp9WpaZ6B5KOGpFFLBXMtSCo-BpuGCEgipUuBV8,5062
|
|
6
|
-
codegen/models/statement.py,sha256=
|
|
6
|
+
codegen/models/statement.py,sha256=wyn4245e0eVXPnsKU8SifOA8uDZzD1SoNzGe5CT_n18,9442
|
|
7
7
|
codegen/models/types.py,sha256=Dl-wzGB1viA7EZj2CuTrZe1F133Q6ENVr_yRqxhde8M,178
|
|
8
8
|
codegen/models/var.py,sha256=sOzDrqJHkAgA2Tqhh6IelW3dDe2o7us6HPjaRBVKmCQ,2722
|
|
9
|
-
codegen_2-2.
|
|
10
|
-
codegen_2-2.
|
|
11
|
-
codegen_2-2.
|
|
12
|
-
codegen_2-2.
|
|
9
|
+
codegen_2-2.8.1.dist-info/LICENSE,sha256=Ea6itrykT9pvPGd0Kgl6FbrqdDwKswPZJmXMFVjUBqw,1064
|
|
10
|
+
codegen_2-2.8.1.dist-info/METADATA,sha256=zdccB4v1pFGt1S2ZlXw2KqNexTPyE5E1h7ifFXCUrTc,487
|
|
11
|
+
codegen_2-2.8.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
12
|
+
codegen_2-2.8.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|