-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring of expressions #1287
Comments
How would you ensure, for example, that an |
With the exception of Z3 expressions the idea is that the returned concrete type is never accessed. def generate_check(expr: expr.Name, lang: type(LangExpr)) -> str:
lang_expr = Equal(Mod(expr, Number(2), Number(0)).to_lang_expr(lang)
return str(lang_expr) Depending on In case of recursive calls of different Z3 is a bit of a special case here as we intend to use the expressions directly which would require at least assertions to get the correct types for mypy. |
So you propose to remove the restriction that expressions can only be constructed of expressions of the same language? Currently, an Ada expression can only be constructed of Ada expressions. In your example, the constructor would look as follows: class AdaAdd(AdaExpr):
def __init__(self, *terms: AdaExpr) -> None:
super().__init__()
self.terms = list(terms) To be able to recursively convert a RecordFlux expression into an class AdaAdd(AdaExpr):
def __init__(self, *terms: LangExpr) -> None:
super().__init__()
self.terms = list(terms) So an |
I missed a detail here. The only thing I'm not completely sure about is the implication of |
Currently our internal expression have two different conversion functions for Z3 and Ada expressions. To reduce the redundancy and improve adaption for further target languages this mechanism should be generic. The idea is to create a base class for language specific expressions that provided methods to create native language expressions:
The conversion methods in
Expr
would then be replaced with a method that takes the desired class type and returns an expression of that type:This approach may be subject to change while its feasibility is investigated.
The text was updated successfully, but these errors were encountered: