print.js 693 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var _ = require('lodash');
  2. // perhaps a switch to print out stuff based on some sort of 'xpath' for function scopes
  3. // perhaps an interactive scope explorer
  4. module.exports = function(write) {
  5. var M = {
  6. scopes: function(scope, indent) {
  7. indent = indent || '';
  8. // console.log(scope);
  9. write(indent + 'Name: ' + scope.name);
  10. write(indent + 'Params: ' + _.pluck(scope.params, 'name').join(', '));
  11. write(indent + 'VarRef: ' + _.pluck(scope.varsRefd, 'name').join(', '));
  12. if(scope.fnDec.length) {
  13. write(indent + 'SubFns: ');
  14. scope.fnDec.map(function(s) {
  15. M.scopes(s, indent + ' ');
  16. });
  17. }
  18. write(indent);
  19. },
  20. }
  21. return M;
  22. }