production-parameter.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = exports.PARAM_YIELD = exports.PARAM_RETURN = exports.PARAM_IN = exports.PARAM_AWAIT = exports.PARAM = void 0;
  6. exports.functionFlags = functionFlags;
  7. const PARAM = 0b0000,
  8. PARAM_YIELD = 0b0001,
  9. PARAM_AWAIT = 0b0010,
  10. PARAM_RETURN = 0b0100,
  11. PARAM_IN = 0b1000;
  12. exports.PARAM_IN = PARAM_IN;
  13. exports.PARAM_RETURN = PARAM_RETURN;
  14. exports.PARAM_AWAIT = PARAM_AWAIT;
  15. exports.PARAM_YIELD = PARAM_YIELD;
  16. exports.PARAM = PARAM;
  17. class ProductionParameterHandler {
  18. constructor() {
  19. this.stacks = [];
  20. }
  21. enter(flags) {
  22. this.stacks.push(flags);
  23. }
  24. exit() {
  25. this.stacks.pop();
  26. }
  27. currentFlags() {
  28. return this.stacks[this.stacks.length - 1];
  29. }
  30. get hasAwait() {
  31. return (this.currentFlags() & PARAM_AWAIT) > 0;
  32. }
  33. get hasYield() {
  34. return (this.currentFlags() & PARAM_YIELD) > 0;
  35. }
  36. get hasReturn() {
  37. return (this.currentFlags() & PARAM_RETURN) > 0;
  38. }
  39. get hasIn() {
  40. return (this.currentFlags() & PARAM_IN) > 0;
  41. }
  42. }
  43. exports.default = ProductionParameterHandler;
  44. function functionFlags(isAsync, isGenerator) {
  45. return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);
  46. }
  47. //# sourceMappingURL=production-parameter.js.map