Improve subroutine evaluation code (post frame pointers)
- Ngôn ngữ chính
- Python
- Star
- 288
- Fork
- 138
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
This issue deals with code implemented in #584 and #562.
In those PRs, to probe info for `has_return` and `type_of` of subroutine declaration, subroutines are evaluated twice: once with ScratchVar arguments, and once with frame pointer arguments. Then during compilation the appropriate version of subroutine evaulator is chosen and used in code generation.
Generally speaking it would be nice to avoid having to evaluate every subroutine twice. Once way of doing that could be with something like a `ProxyExpr`:
```python
class ProxyExpr(Expr):
def __init__(self, type_of: TealType):
super().__init__()
self.representing: Expr | None = None
def resolve_to(self, expr: Expr):
self.representing = expr
def __teal__(self, options: "CompileOptions"):
if self.representing is None:
raise TealInternalError("Not assigned....")
return self.representing.__teal__(options)
```
The idea would be to use this as a placeholder before compilation to evaluate the subroutine, then assign the `ProxyExpr` to its actual value once that's known at compile time.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.