Skip to content

Commit d2767cf

Browse files
committed
Added uses_variables method
1 parent 846df89 commit d2767cf

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

synth/syntax/program.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ def __hash__(self) -> int:
2525
def __repr__(self) -> str:
2626
return self.__str__()
2727

28+
def uses_variables(self) -> bool:
29+
"""
30+
Returns true if a variable is used.
31+
"""
32+
return False
33+
2834
def used_variables(self) -> Set[int]:
2935
"""
3036
Returns the set of used variables numbers in this program.
@@ -139,6 +145,9 @@ def __init__(self, variable: int, type: Type = UnknownType()):
139145
def is_invariant(self, constant_types: Set[PrimitiveType]) -> bool:
140146
return False
141147

148+
def uses_variables(self) -> bool:
149+
return True
150+
142151
def clone(self) -> "Program":
143152
return Variable(self.variable)
144153

@@ -297,6 +306,11 @@ def is_constant(self) -> bool:
297306
arg.is_constant() for arg in self.arguments
298307
)
299308

309+
def uses_variables(self) -> bool:
310+
return self.function.uses_variables() or any(
311+
arg.uses_variables() for arg in self.arguments
312+
)
313+
300314
def constants(self) -> Generator[Optional["Constant"], None, None]:
301315
g = [self.function.constants()] + [arg.constants() for arg in self.arguments]
302316
for gen in g:
@@ -382,6 +396,9 @@ def all_constants_instantiation(
382396
def __eq__(self, other: Any) -> bool:
383397
return isinstance(other, Lambda) and self.body == other.body
384398

399+
def uses_variables(self) -> bool:
400+
return self.body.uses_variables()
401+
385402
def __add_used_variables__(self, vars: Set[int]) -> None:
386403
return self.body.__add_used_variables__(vars)
387404

0 commit comments

Comments
 (0)