FunctionCallCanonicalizationPass.h 771 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "Compiler/GenericASTPass.h"
  8. namespace JSSpecCompiler {
  9. // FunctionCallCanonicalizationPass simplifies ladders of BinaryOperators nodes in the function call
  10. // arguments into nice and neat FunctionCall nodes.
  11. //
  12. // Ladders initially appear since I do not want to complicate expression parser, so it interprets
  13. // `f(a, b, c, d)` as `f "function_call_operator" (a, (b, (c, d))))`.
  14. class FunctionCallCanonicalizationPass : public GenericASTPass {
  15. public:
  16. inline static constexpr StringView name = "function-call-canonicalization"sv;
  17. using GenericASTPass::GenericASTPass;
  18. protected:
  19. void on_leave(Tree tree) override;
  20. };
  21. }