From b131d3c39635939d9f7c88aff78e43df191d14be Mon Sep 17 00:00:00 2001 From: QuanQuan-CHO <12011619@mail.sustech.edu.cn> Date: Thu, 11 Jan 2024 19:09:26 +0800 Subject: [PATCH] [Phase4] Update `README.md` --- phase4/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/phase4/README.md b/phase4/README.md index cfac684..f291d94 100644 --- a/phase4/README.md +++ b/phase4/README.md @@ -6,3 +6,29 @@ **12111611 Ruixiang Jiang** + + +## Design + +### Procedure Call + +#### Active Variables + +Before function call, we only need to store the active variables before invoking the function + +The active variables are stored in the set `active_vars`, which is easy to maintain + +The set will be updated only in three cases: + +- `x := ...` +- `PARAM x` +- `READ x` + +We only need to add `x` to `active_vars` while translating the TACs + +When we get TACs like `IF x [op] y GOTO label`, we **don't** need to add `x` and `y` to `active_vars`, because `x` and `y` must be already declared in the form of the above three cases + +Finally, clear the set after getting a new function TAC `FUNCTION f :` + + +