mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-06-07 22:29:27 +00:00
Expand on the callgraph tests.
This commit is contained in:
parent
40d9c57d64
commit
a84cd4de8c
|
@ -33,6 +33,8 @@ def construct_callgraph(program):
|
||||||
potential_calls = node['potentially-calls']
|
potential_calls = node['potentially-calls']
|
||||||
if routine.name in potential_calls:
|
if routine.name in potential_calls:
|
||||||
potentially_called_by.append(name)
|
potentially_called_by.append(name)
|
||||||
|
if getattr(routine, 'explicitly_marked_as_called', None) or routine.name == 'main':
|
||||||
|
potentially_called_by.append('*marked*')
|
||||||
graph[routine.name]['potentially-called-by'] = potentially_called_by
|
graph[routine.name]['potentially-called-by'] = potentially_called_by
|
||||||
|
|
||||||
return graph
|
return graph
|
||||||
|
|
|
@ -10,14 +10,112 @@ called.
|
||||||
|
|
||||||
-> Tests for functionality "Dump callgraph info for SixtyPical program"
|
-> Tests for functionality "Dump callgraph info for SixtyPical program"
|
||||||
|
|
||||||
The `main` routine is always called.
|
The `main` routine is always called. The thing that it will
|
||||||
|
be called by is the system, but the callgraph analyzer will
|
||||||
|
simply consider it to be "marked as called".
|
||||||
|
|
||||||
| define main routine
|
| define main routine
|
||||||
| {
|
| {
|
||||||
| }
|
| }
|
||||||
= {
|
= {
|
||||||
= "main": {
|
= "main": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "*marked*"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": []
|
||||||
|
= }
|
||||||
|
= }
|
||||||
|
|
||||||
|
If a routine is called by another routine, this fact will be noted.
|
||||||
|
|
||||||
|
| define main routine
|
||||||
|
| {
|
||||||
|
| call other
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define other routine
|
||||||
|
| {
|
||||||
|
| }
|
||||||
|
= {
|
||||||
|
= "main": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "*marked*"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": [
|
||||||
|
= "other"
|
||||||
|
= ]
|
||||||
|
= },
|
||||||
|
= "other": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "main"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": []
|
||||||
|
= }
|
||||||
|
= }
|
||||||
|
|
||||||
|
If a routine is not called by another routine, and it is not `main`
|
||||||
|
and it is not explicitly marked as preserved, this absence will be
|
||||||
|
noted, and a compiler or linker will be permitted to omit it from
|
||||||
|
the final executable.
|
||||||
|
|
||||||
|
| define main routine
|
||||||
|
| {
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define other routine
|
||||||
|
| {
|
||||||
|
| }
|
||||||
|
= {
|
||||||
|
= "main": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "*marked*"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": []
|
||||||
|
= },
|
||||||
|
= "other": {
|
||||||
= "potentially-called-by": [],
|
= "potentially-called-by": [],
|
||||||
= "potentially-calls": []
|
= "potentially-calls": []
|
||||||
= }
|
= }
|
||||||
= }
|
= }
|
||||||
|
|
||||||
|
If two routines potentially call each other, this will be noted,
|
||||||
|
even if nothing else potentially calls either of those routines.
|
||||||
|
This may change in the future.
|
||||||
|
|
||||||
|
| define main routine
|
||||||
|
| {
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define other1 routine
|
||||||
|
| {
|
||||||
|
| call other2
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define other2 routine
|
||||||
|
| {
|
||||||
|
| call other1
|
||||||
|
| }
|
||||||
|
= {
|
||||||
|
= "main": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "*marked*"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": []
|
||||||
|
= },
|
||||||
|
= "other1": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "other2"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": [
|
||||||
|
= "other2"
|
||||||
|
= ]
|
||||||
|
= },
|
||||||
|
= "other2": {
|
||||||
|
= "potentially-called-by": [
|
||||||
|
= "other1"
|
||||||
|
= ],
|
||||||
|
= "potentially-calls": [
|
||||||
|
= "other1"
|
||||||
|
= ]
|
||||||
|
= }
|
||||||
|
= }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user