fix
This commit is contained in:
parent
82dc29b0d5
commit
6156a263f0
4 changed files with 28 additions and 26 deletions
|
|
@ -725,7 +725,9 @@ class Script:
|
||||||
if name not in unresolvable
|
if name not in unresolvable
|
||||||
}
|
}
|
||||||
|
|
||||||
to_partially_resolve: Set[Variable] = {Variable(name) for name in output_filter} if output_filter else set(unresolved.keys())
|
to_partially_resolve: Set[Variable] = (
|
||||||
|
{Variable(name) for name in output_filter} if output_filter else set(unresolved.keys())
|
||||||
|
)
|
||||||
|
|
||||||
partially_resolved = True
|
partially_resolved = True
|
||||||
while partially_resolved:
|
while partially_resolved:
|
||||||
|
|
@ -762,27 +764,33 @@ class Script:
|
||||||
# which means we can iterate again
|
# which means we can iterate again
|
||||||
partially_resolved |= definition != maybe_resolved
|
partially_resolved |= definition != maybe_resolved
|
||||||
|
|
||||||
return {
|
if output_filter:
|
||||||
var.name: ResolvedSyntaxTree(ast=[definition])
|
out: Dict[str, SyntaxTree] = {}
|
||||||
for var, definition in resolved.items()
|
for name in output_filter:
|
||||||
} | {var.name: SyntaxTree(ast=[definition]) for var, definition in unresolved.items()}
|
variable_name = Variable(name)
|
||||||
|
if variable_name in resolved:
|
||||||
|
out[name] = ResolvedSyntaxTree(ast=[resolved[variable_name]])
|
||||||
|
else:
|
||||||
|
out[name] = SyntaxTree(ast=[unresolved[variable_name]])
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
||||||
|
return {
|
||||||
|
var.name: ResolvedSyntaxTree(ast=[definition]) for var, definition in resolved.items()
|
||||||
|
} | {var.name: SyntaxTree(ast=[definition]) for var, definition in unresolved.items()}
|
||||||
|
|
||||||
def resolve_partial(
|
def resolve_partial(
|
||||||
self,
|
self,
|
||||||
unresolvable: Optional[Set[str]] = None,
|
unresolvable: Optional[Set[str]] = None,
|
||||||
) -> "Script":
|
) -> "Script":
|
||||||
out = self._resolve_partial(unresolvable=unresolvable)
|
out = self._resolve_partial(unresolvable=unresolvable)
|
||||||
|
|
||||||
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} | out
|
||||||
| out
|
)
|
||||||
)
|
|
||||||
|
|
||||||
def resolve_partial_once(
|
def resolve_partial_once(
|
||||||
self,
|
self, variable_definitions: Dict[str, SyntaxTree], unresolvable: Optional[Set[str]] = None
|
||||||
variable_definitions: Dict[str, SyntaxTree],
|
|
||||||
unresolvable: Optional[Set[str]] = None
|
|
||||||
) -> Dict[str, SyntaxTree]:
|
) -> Dict[str, SyntaxTree]:
|
||||||
try:
|
try:
|
||||||
self.add_parsed(variable_definitions)
|
self.add_parsed(variable_definitions)
|
||||||
|
|
|
||||||
|
|
@ -371,13 +371,6 @@ class BuiltInFunction(Function, BuiltInFunctionType):
|
||||||
If the conditional partially resolvable enough to warrant evaluation,
|
If the conditional partially resolvable enough to warrant evaluation,
|
||||||
perform it here.
|
perform it here.
|
||||||
"""
|
"""
|
||||||
if self.is_subset_of(
|
|
||||||
variables=resolved_variables, custom_function_definitions=custom_functions
|
|
||||||
):
|
|
||||||
return self.resolve(
|
|
||||||
resolved_variables=resolved_variables,
|
|
||||||
custom_functions=custom_functions,
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.name == "if":
|
if self.name == "if":
|
||||||
maybe_resolvable_arg, is_resolvable = VariableDependency.try_partial_resolve(
|
maybe_resolvable_arg, is_resolvable = VariableDependency.try_partial_resolve(
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,9 @@ class VariableDependency(ABC):
|
||||||
for arg in args:
|
for arg in args:
|
||||||
maybe_resolvable_args.append(arg)
|
maybe_resolvable_args.append(arg)
|
||||||
|
|
||||||
|
if hasattr(arg, "ast"):
|
||||||
|
print("sfdsf")
|
||||||
|
|
||||||
if isinstance(arg, Lambda) and arg.value in custom_functions:
|
if isinstance(arg, Lambda) and arg.value in custom_functions:
|
||||||
if not custom_functions[arg.value].is_subset_of(
|
if not custom_functions[arg.value].is_subset_of(
|
||||||
variables=resolved_variables,
|
variables=resolved_variables,
|
||||||
|
|
|
||||||
|
|
@ -254,12 +254,10 @@ def _validate_formatter(
|
||||||
if resolve_partial and not is_static_formatter:
|
if resolve_partial and not is_static_formatter:
|
||||||
formatter_hash = get_md5_hash(formatter_validator.format_string)
|
formatter_hash = get_md5_hash(formatter_validator.format_string)
|
||||||
|
|
||||||
parsed = (
|
parsed = mock_script.resolve_partial_once(
|
||||||
mock_script.resolve_partial_once(
|
variable_definitions={formatter_hash: formatter_validator.parsed},
|
||||||
variable_definitions={formatter_hash: formatter_validator.parsed},
|
unresolvable=unresolved_variables,
|
||||||
unresolvable=unresolved_variables
|
)[formatter_hash]
|
||||||
)[formatter_hash]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add lambda functions to custom function names, if it's custom
|
# Add lambda functions to custom function names, if it's custom
|
||||||
for lambda_func in parsed.lambdas:
|
for lambda_func in parsed.lambdas:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue