OptionalCatchBindingTransformer.js 511 B

12345678910111213141516171819
  1. import {TokenType as tt} from "../parser/tokenizer/types";
  2. import Transformer from "./Transformer";
  3. export default class OptionalCatchBindingTransformer extends Transformer {
  4. constructor( tokens, nameManager) {
  5. super();this.tokens = tokens;this.nameManager = nameManager;;
  6. }
  7. process() {
  8. if (this.tokens.matches2(tt._catch, tt.braceL)) {
  9. this.tokens.copyToken();
  10. this.tokens.appendCode(` (${this.nameManager.claimFreeName("e")})`);
  11. return true;
  12. }
  13. return false;
  14. }
  15. }