Skip to content
Snippets Groups Projects
Commit 89789777 authored by Frederik Hennig's avatar Frederik Hennig
Browse files

hold back expr evaluation for now

parent a333aa55
No related branches found
No related tags found
1 merge request!393Ternary Expressions, Improved Integer Divisions, and Iteration Space Fix
Pipeline #67191 passed
......@@ -757,36 +757,3 @@ class PsArrayInitList(PsExpression):
def __repr__(self) -> str:
return f"PsArrayInitList({repr(self._items)})"
def evaluate_expression(
expr: PsExpression, valuation: dict[str | PsSymbol, Any]
) -> Any:
"""Evaluate a pystencils backend expression tree with values assigned to symbols according to the given valuation.
Only a subset of expression nodes can be processed by this evaluator.
"""
def visit(node):
match node:
case PsSymbolExpr(symb):
if value := valuation.get(symb, None) is not None:
return value
else:
return valuation[symb.name]
case PsConstantExpr(c):
return c.value
case PsUnOp(op1) if node.python_operator is not None:
return node.python_operator(visit(op1))
case PsBinOp(op1, op2) if node.python_operator is not None:
return node.python_operator(visit(op1), visit(op2))
case other:
raise NotImplementedError(
f"Unable to evaluate {other}: No implementation available."
)
return visit(expr)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment