mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
JSSpecCompiler: Provide an adequate command line interface
This commit is contained in:
parent
867ce0df52
commit
6ed069ea8d
10 changed files with 226 additions and 33 deletions
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/StringView.h>
|
||||
|
||||
#include "Forward.h"
|
||||
|
||||
namespace JSSpecCompiler {
|
||||
|
||||
class CompilationStep {
|
||||
public:
|
||||
CompilationStep(StringView name)
|
||||
: m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~CompilationStep() = default;
|
||||
virtual void run(TranslationUnitRef translation_unit) = 0;
|
||||
|
||||
StringView name() const { return m_name; }
|
||||
|
||||
private:
|
||||
StringView m_name;
|
||||
};
|
||||
|
||||
class NonOwningCompilationStep : public CompilationStep {
|
||||
public:
|
||||
template<typename Func>
|
||||
NonOwningCompilationStep(StringView name, Func&& func)
|
||||
: CompilationStep(name)
|
||||
, m_func(func)
|
||||
{
|
||||
}
|
||||
|
||||
void run(TranslationUnitRef translation_unit) override { m_func(translation_unit); }
|
||||
|
||||
private:
|
||||
AK::Function<void(TranslationUnitRef)> m_func;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue