Skip to content
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

[python] Fix the Function.calls semantic #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bindings/python/quokka/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,20 @@ def size(self) -> int:
@property
def calls(self) -> List[quokka.Chunk]:
"""Return the list of calls made by this chunk.
The semantic of a "call" is to jump or call to the **starting** chunk of a function.
Beware that this might lead to different results than the program call graph.

Note: The list is not deduplicated so a target may occur multiple time.
"""

calls = []
for inst_instance in self.program.references.resolve_calls(self, towards=False):
if isinstance(inst_instance, tuple):
calls.append(inst_instance[0])
else:
calls.append(inst_instance)
chunk = (
inst_instance[0] if isinstance(inst_instance, tuple) else inst_instance
)
# Check that the chunk is the **starting** chunk of a function
if chunk.start in self.program:
calls.append(chunk)

return calls

Expand Down
Loading