docs
This commit is contained in:
parent
3d40dce97c
commit
fb49aa18f2
2 changed files with 14 additions and 9 deletions
|
|
@ -704,15 +704,10 @@ class Script:
|
||||||
unresolvable: Optional[Set[str]] = None,
|
unresolvable: Optional[Set[str]] = None,
|
||||||
) -> "Script":
|
) -> "Script":
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
Dict of resolved values
|
New (deep-copied) script that resolves inner variables as much
|
||||||
|
as possible.
|
||||||
Raises
|
|
||||||
------
|
|
||||||
ScriptVariableNotResolved
|
|
||||||
If specifying a filter of variable to resolve, and one of them does not.
|
|
||||||
"""
|
"""
|
||||||
unresolvable: Set[str] = unresolvable or {}
|
unresolvable: Set[str] = unresolvable or {}
|
||||||
resolved: Dict[Variable, Resolvable] = {}
|
resolved: Dict[Variable, Resolvable] = {}
|
||||||
|
|
@ -753,6 +748,9 @@ class Script:
|
||||||
|
|
||||||
return copy.deepcopy(self).add_parsed(
|
return copy.deepcopy(self).add_parsed(
|
||||||
{var_name: self._variables[var_name] for var_name in unresolvable}
|
{var_name: self._variables[var_name] for var_name in unresolvable}
|
||||||
| {var.name: SyntaxTree(ast=[definition]) for var, definition in resolved.items()}
|
| {
|
||||||
|
var.name: ResolvedSyntaxTree(ast=[definition])
|
||||||
|
for var, definition in resolved.items()
|
||||||
|
}
|
||||||
| {var.name: SyntaxTree(ast=[definition]) for var, definition in unresolved.items()}
|
| {var.name: SyntaxTree(ast=[definition]) for var, definition in unresolved.items()}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -367,6 +367,10 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
||||||
unresolved_variables: Dict[Variable, Argument],
|
unresolved_variables: Dict[Variable, Argument],
|
||||||
custom_functions: Dict[str, "VariableDependency"],
|
custom_functions: Dict[str, "VariableDependency"],
|
||||||
):
|
):
|
||||||
|
"""
|
||||||
|
If the conditional partially resolvable enough to warrant evaluation,
|
||||||
|
perform it here.
|
||||||
|
"""
|
||||||
if self.is_subset_of(
|
if self.is_subset_of(
|
||||||
variables=resolved_variables, custom_function_definitions=custom_functions
|
variables=resolved_variables, custom_function_definitions=custom_functions
|
||||||
):
|
):
|
||||||
|
|
@ -424,6 +428,10 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
||||||
unresolved_variables: Dict[Variable, Argument],
|
unresolved_variables: Dict[Variable, Argument],
|
||||||
custom_functions: Dict[str, "VariableDependency"],
|
custom_functions: Dict[str, "VariableDependency"],
|
||||||
) -> Optional[Argument]:
|
) -> Optional[Argument]:
|
||||||
|
"""
|
||||||
|
If a function has enough (but not all) resolved parameters to warrant a return,
|
||||||
|
perform it here.
|
||||||
|
"""
|
||||||
if self.name == "array_at":
|
if self.name == "array_at":
|
||||||
if (
|
if (
|
||||||
isinstance(self.args[0], UnresolvedArray)
|
isinstance(self.args[0], UnresolvedArray)
|
||||||
|
|
@ -451,7 +459,6 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
||||||
num_input_args=len(self.args)
|
num_input_args=len(self.args)
|
||||||
)
|
)
|
||||||
|
|
||||||
# If the function is conditional, only run if its entirety is resolvable
|
|
||||||
if conditional_return_args:
|
if conditional_return_args:
|
||||||
return self._partial_resolve_conditional(
|
return self._partial_resolve_conditional(
|
||||||
resolved_variables=resolved_variables,
|
resolved_variables=resolved_variables,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue