From what I can remember the Control-Flow Graphs for which I have seen images have mostly been of single functions. So basically just statements with perhaps looping. But I am wondering what a control-flow graph would look like for a function, which may reference nested functions, which may reference other nested functions, etc.
For example, here is a set of functions:
function a(x) {
var m = b(x)
var n = c(x)
return m + n
}
function b(x) {
var m = d(x)
var n = e(x)
return m * n
}
function c(x) {
var m = d(x)
var n = e(x)
return m - n
}
function d(x) {
var i = x
var o
while (i--) {
if (i % 2 == 0) {
o += (x * 2)
} else {
o -= (x * 3)
}
}
return o
}
function e(x) {
var i = x
var o
while (i--) {
if (i % 3 == 0) {
o += (x * 3)
} else {
o -= (x + 3)
}
}
return o
}
Wondering what it would look like as a Control-Flow Graph, or maybe just the nesting part to get started.
a(x)
___________|___________
| |
var m = b(x) var n = c(x)
| |
? ?
Hoping to do this without inlining the functions, which is just an artifact of the example functions chosen.