more simplifying
This commit is contained in:
parent
26c2045a74
commit
3d40dce97c
2 changed files with 10 additions and 21 deletions
|
|
@ -4,6 +4,7 @@ from dataclasses import dataclass
|
|||
from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from typing import Type
|
||||
from typing import Union
|
||||
|
||||
|
|
@ -422,8 +423,7 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
|||
resolved_variables: Dict[Variable, Resolvable],
|
||||
unresolved_variables: Dict[Variable, Argument],
|
||||
custom_functions: Dict[str, "VariableDependency"],
|
||||
) -> Argument:
|
||||
# TODO: arg optimization
|
||||
) -> Optional[Argument]:
|
||||
if self.name == "array_at":
|
||||
if (
|
||||
isinstance(self.args[0], UnresolvedArray)
|
||||
|
|
|
|||
|
|
@ -258,25 +258,22 @@ class VariableDependency(ABC):
|
|||
Attempts to resolve a list of arguments. Returns a tuple of them post partially resolved,
|
||||
and a boolean indicating whether all of them are fully resolved.
|
||||
"""
|
||||
maybe_resolvable_args: List[Resolvable | Argument | "VariableDependency"] = []
|
||||
maybe_resolvable_args: List[Argument] = []
|
||||
is_resolvable = True
|
||||
for arg in args:
|
||||
if isinstance(arg, Lambda) and arg.value in custom_functions:
|
||||
maybe_resolvable_args.append(arg)
|
||||
maybe_resolvable_args.append(arg)
|
||||
|
||||
if isinstance(arg, Lambda) and arg.value in custom_functions:
|
||||
if not custom_functions[arg.value].is_subset_of(
|
||||
variables=resolved_variables,
|
||||
custom_function_definitions=custom_functions,
|
||||
):
|
||||
is_resolvable = False
|
||||
|
||||
elif isinstance(arg, VariableDependency):
|
||||
maybe_resolvable_args.append(
|
||||
arg.partial_resolve(
|
||||
resolved_variables=resolved_variables,
|
||||
unresolved_variables=unresolved_variables,
|
||||
custom_functions=custom_functions,
|
||||
)
|
||||
maybe_resolvable_args[-1] = arg.partial_resolve(
|
||||
resolved_variables=resolved_variables,
|
||||
unresolved_variables=unresolved_variables,
|
||||
custom_functions=custom_functions,
|
||||
)
|
||||
|
||||
if not isinstance(maybe_resolvable_args[-1], Resolvable):
|
||||
|
|
@ -284,15 +281,7 @@ class VariableDependency(ABC):
|
|||
elif isinstance(arg, Variable):
|
||||
if arg not in resolved_variables:
|
||||
is_resolvable = False
|
||||
|
||||
if arg in unresolved_variables:
|
||||
maybe_resolvable_args.append(unresolved_variables[arg])
|
||||
else:
|
||||
# Must be unresolvable
|
||||
maybe_resolvable_args.append(arg)
|
||||
else:
|
||||
maybe_resolvable_args.append(arg)
|
||||
else:
|
||||
maybe_resolvable_args.append(arg)
|
||||
maybe_resolvable_args[-1] = unresolved_variables[arg]
|
||||
|
||||
return maybe_resolvable_args, is_resolvable
|
||||
|
|
|
|||
Loading…
Reference in a new issue