builtinExceptions.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var _ = require('lodash');
  2. var tree = require('../lib/tree');
  3. var treeStructure = require('../structure');
  4. module.exports = function(scope) {
  5. // bad name. this is for low level exceptions like division.
  6. scope.canHaveNativeExceptions = false;
  7. // divide by 0
  8. // null reference
  9. scope.varsDeclared = scope.flatExp.map(function(e) {
  10. if(!e.loc || e.loc.start.line != 17) return;
  11. console.log(e.type, e);
  12. console.log('-------------');
  13. });
  14. scope.varsRefd = _.where(scope.flatExp, {type: 'BinaryExpression'}).map(function(e) {
  15. return {
  16. name: collectIdName(e),
  17. ast: e,
  18. };
  19. });
  20. /*
  21. { type: 'MemberExpression',
  22. object:
  23. { type: 'Identifier',
  24. name: 't',
  25. loc: { source: null, start: [Object], end: [Object] } },
  26. property:
  27. { type: 'Identifier',
  28. name: 'u',
  29. loc: { source: null, start: [Object], end: [Object] } },
  30. computed: false,
  31. loc:
  32. { source: null,
  33. start: { line: 17, column: 1 },
  34. end: { line: 17, column: 4 } } }
  35. { type: 'MemberExpression',
  36. object:
  37. { type: 'MemberExpression',
  38. object: { type: 'Identifier', name: 't', loc: [Object] },
  39. property: { type: 'Identifier', name: 'u', loc: [Object] },
  40. computed: false,
  41. loc: { source: null, start: [Object], end: [Object] } },
  42. property:
  43. { type: 'Identifier',
  44. name: 'k',
  45. loc: { source: null, start: [Object], end: [Object] } },
  46. computed: false,
  47. loc:
  48. { source: null,
  49. start: { line: 17, column: 1 },
  50. end: { line: 17, column: 6 } } }
  51. */
  52. };
  53. // object references have deeply nested identifier names.
  54. function collectIdName(id) {
  55. if(id.type == 'Identifier');
  56. console.log(id);
  57. }