algorand / algorand/pyteal

Improve subroutine evaluation code (post frame pointers)

Đang mở
#599 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Team Scytale
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

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.