3 ms·
I'm not sure how relevant my code is, but I did something similar using Proxies[0] for a game engine built on javascript (RPG Maker MV) following some useful ad
by ldd 9y ago
I'm not sure how relevant my code is, but I did something similar using Proxies[0] for a game engine built on javascript (RPG Maker MV) following some useful advice I found online[1].
I presume that the same type of logic could be used to make more powerful loggers.
[0]:https://github.com/ldd/plugin-analyzer https://github.com/ldd/plugin-analyzer
[1]:http://exploringjs.com/es6/ch_proxies.html#sec_proxies-explained http://exploringjs.com/es6/ch_proxies.html#sec_proxies-expla...
- Schampu 9y agoProxies are definitely a nice catch, but won't allow full code instrumentation. Iroh doesn't use proxies but patches the submitted code to allow full code instrumentation including call tree recording and full ES5 code support. If you're wondering what the patched code looks like: Input: function add(a, b) { return a + b; }; add(2, 4); Output: const $$STx1 = Iroh.stages["$$STx1"]; var $$frameValue = void 0; $$STx1.$45(5) function add(a, b) { $$STx1.$4(6, this, add, arguments); return $$STx1.$1(1, "add", $$STx1.$32(7, 1, a, b)); $$STx1.$5(6, this); } ; $$STx1.$44($$frameValue = $$STx1.$2(4, this, add, null, [$$STx1.$30(2, 2), $$STx1.$30(3, 4)])); $$STx1.$46(5, $$frameValue)
- ldd 9y agopartial call tree recording is supported, I think. Take a look at section "28.3.2 Intercepting method calls" from the link I posted above. More importantly, you are entirely right about ES5 support. Babel doesn't polyfill Proxies, and the google polyfill is not as powerful.
- Schampu 9y agoInteresting! One of the main challenges of Iroh was to always keep track of all branches (calls, ifs, loops..) correctly. All listeners provide an indent value which represents the level of branch deepness and can be used in code flow visualizations. When your program is inside a function->loop->if and a return is inside there, then you have to manually leave if->loop until you get to according function to return on.