codegen-2 2.15.4__tar.gz → 2.15.6__tar.gz
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_2-2.15.4 → codegen_2-2.15.6}/PKG-INFO +1 -1
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/ast.py +8 -4
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/expr.py +1 -1
- {codegen_2-2.15.4 → codegen_2-2.15.6}/pyproject.toml +1 -1
- {codegen_2-2.15.4 → codegen_2-2.15.6}/LICENSE +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/README.md +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/__init__.py +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/__init__.py +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/program.py +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/statement.py +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/types.py +0 -0
- {codegen_2-2.15.4 → codegen_2-2.15.6}/codegen/models/var.py +0 -0
|
@@ -97,7 +97,7 @@ class AST:
|
|
|
97
97
|
def func(
|
|
98
98
|
self,
|
|
99
99
|
name: str,
|
|
100
|
-
vars: Sequence[DeferredVar | tuple[DeferredVar, Expr]],
|
|
100
|
+
vars: Sequence[Optional[DeferredVar] | tuple[DeferredVar, Expr]],
|
|
101
101
|
return_type: Optional[Expr] = None,
|
|
102
102
|
is_async: bool = False,
|
|
103
103
|
is_static: bool = False,
|
|
@@ -107,6 +107,9 @@ class AST:
|
|
|
107
107
|
"""Define a function. The input variables are deferred vars as they are created for this function (i.e., must not be predefined prior to this function)"""
|
|
108
108
|
grandchild_id = self.next_grandchild_id()
|
|
109
109
|
for vararg in vars:
|
|
110
|
+
if vararg is None:
|
|
111
|
+
continue
|
|
112
|
+
|
|
110
113
|
if isinstance(vararg, tuple):
|
|
111
114
|
var = vararg[0]
|
|
112
115
|
else:
|
|
@@ -127,6 +130,7 @@ class AST:
|
|
|
127
130
|
else var.get_var()
|
|
128
131
|
)
|
|
129
132
|
for var in vars
|
|
133
|
+
if var is not None
|
|
130
134
|
],
|
|
131
135
|
return_type,
|
|
132
136
|
is_async,
|
|
@@ -173,9 +177,9 @@ class AST:
|
|
|
173
177
|
|
|
174
178
|
def for_loop(self, item: DeferredVar, iter: Expr):
|
|
175
179
|
"""When we construct a for-loop, the item (or var) is always declared. We don't allow reassigning the variable in the for-loop."""
|
|
176
|
-
assert (
|
|
177
|
-
|
|
178
|
-
)
|
|
180
|
+
assert isinstance(item, DeferredVar) and item.has_not_been_created(), (
|
|
181
|
+
"The item must be a new variable"
|
|
182
|
+
)
|
|
179
183
|
var = self.prog.create_var(
|
|
180
184
|
item.name, item.key, self.next_grandchild_id(), item.force_name
|
|
181
185
|
)
|
|
@@ -17,7 +17,7 @@ class Expr(ABC):
|
|
|
17
17
|
raise NotImplementedError(self.__class__)
|
|
18
18
|
|
|
19
19
|
def to_wrapped_python(self):
|
|
20
|
-
if isinstance(self, (ExprVar, ExprConstant)):
|
|
20
|
+
if isinstance(self, (ExprVar, ExprConstant, ExprIdent)):
|
|
21
21
|
return self.to_python()
|
|
22
22
|
return f"({self.to_python()})"
|
|
23
23
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|