[RFC] esgraph: control flow graph builder

195 views
Skip to first unread message

Arpad Borsos

unread,
Apr 29, 2013, 5:20:51 PM4/29/13
to esp...@googlegroups.com
Hi

So the goal is to create a CFG from esprima AST. Since it was the first time I worked with a CFG (or even create one), I might have missed something.
This code is actually a year old, I’ve just found some motivation now to get it properly packaged.

`esgraph(ast)` returns an array with entry and exit node.
Each node is linked to its successor using `normal`, `true`, `false` or `exception` edges and to its predecessors using the `prev` array.
`node.astNode` is the original Statement or Expression.

There are some things that are not handled yet, like WithStatement and labeled `continue`/`break`, and I’m not sure its worth the trouble for lack of real world code using those constructs.

Code is over at https://github.com/Swatinem/esgraph

Would love some constructive feedback :-)
-Arpad

Ariya Hidayat

unread,
May 1, 2013, 1:43:49 AM5/1/13
to esp...@googlegroups.com
Hi Arpad,

esgraph looks really cool indeed!

There's also a possibly-related project, dfatool
(https://github.com/pissang/dfatool). Since I haven't spent enough
time looking at both dfatool and esgraph, I can't really say whether
there is some overlap or not.

Also, like in many JavaScript (micro)library, the most popular license
is BSD or MIT. I don't understand enough about LGPLv3 to assess its
implication, but I thought I let you know about this.

Keep up the good work!

Thanks.

Regards,


--
Ariya Hidayat, http://ariya.ofilabs.com
http://twitter.com/ariyahidayat
http://gplus.to/ariyahidayat

Arpad Borsos

unread,
May 1, 2013, 5:55:30 AM5/1/13
to esp...@googlegroups.com
Hi Ariya.

dfatool does indeed look a lot like what I was doing. esgraph was part of my masters thesis where I implemented a dfa/cfa for js for type infererence / code completion purposes.
Code is over at https://github.com/Swatinem/analyses but not really in a publishable state, so I wanted to clean it up and separate it into different modules. Still a lot of work ahead of me :-D

Concerning the license, I’m not an expert either. But as far as I understand it, mit/bsd allows you to make a proprietary fork, whereas gpl forces you to contribute improvements back. Otherwise you can link/use lgpl libraries just fine from proprietary projects.
So its a matter of opinion really. :-)

Thanks for the feedback!
-Arpad
Reply all
Reply to author
Forward
0 new messages