thunks.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. var _ = require('lodash');
  2. var tree = require('../lib/tree');
  3. var treeStructure = require('../structure').scopes;
  4. /*
  5. */
  6. module.exports = function(scope) {
  7. scope.fnAST = [];
  8. };
  9. var handlers = {
  10. Program: returnArg,
  11. EmptyStatement: returnArg,
  12. BlockStatement: returnArg,
  13. ExpressionStatement: returnArg,
  14. IfStatement: returnArg,
  15. LabeledStatement: returnArg,
  16. BreakStatement: returnArg,
  17. ContinueStatement: returnArg,
  18. WithStatement: returnArg,
  19. SwitchStatement: returnArg,
  20. ReturnStatement: returnArg,
  21. ThrowStatement: returnArg,
  22. TryStatement: returnArg,
  23. WhileStatement: returnArg,
  24. DoWhileStatement: returnArg,
  25. ForStatement: returnArg,
  26. ForInStatement: returnArg,
  27. DebugggerStatement: returnArg,
  28. FunctionDeclaration: returnArg,
  29. VariableDeclaration: returnArg,
  30. VariableDeclarator: returnArg,
  31. ArgExpression: returnArg,
  32. ArrayExpression: returnArg,
  33. ObjectExpression: returnArg,
  34. FunctionExpression: returnArg,
  35. SequenceExpression: returnArg,
  36. UnaryExpression: returnArg,
  37. BinaryExpression: returnArg,
  38. AssignmentExpression: returnArg,
  39. UpdateExpression: returnArg,
  40. LogicalExpression: returnArg,
  41. ConditionalExpression: returnArg,
  42. NewExpression: returnArg,
  43. CallExpression: returnArg,
  44. MemberExpression: returnArg,
  45. SwitchCase: returnArg,
  46. CatchClause: returnArg,
  47. Identifier: returnArg,
  48. Literal: returnArg,
  49. };
  50. function returnArg(x) { return x; };
  51. function c(name, args) {
  52. return {
  53. type: 'fnCall',
  54. name: name,
  55. args: args,
  56. };
  57. }
  58. function t(body) {
  59. return {
  60. type: 'thunk',
  61. body: body,
  62. }
  63. }