P4C
The P4 Compiler
Loading...
Searching...
No Matches
context.h
1/*
2 * SPDX-FileCopyrightText: 2022 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_COMMON_COMPILER_CONTEXT_H_
8#define BACKENDS_P4TOOLS_COMMON_COMPILER_CONTEXT_H_
9
10#include "backends/p4tools/common/compiler/configuration.h"
11#include "frontends/common/parser_options.h"
12
13namespace P4::P4Tools {
14
16template <typename OptionsType>
17class CompileContext : public virtual P4CContext {
18 public:
21 static CompileContext &get() { return CompileContextStack::top<CompileContext>(); }
22
23 CompileContext() = default;
24
25 template <typename OptionsDerivedType>
27 : _optionsInstance(context.options()) {}
28
30 OptionsType &options() override { return _optionsInstance; }
31
32 protected:
34
35 private:
37 OptionsType _optionsInstance;
38};
39
40} // namespace P4::P4Tools
41
42#endif /* BACKENDS_P4TOOLS_COMMON_COMPILER_CONTEXT_H_ */
A compilation context for P4Tools that provides a custom compiler configuration.
Definition context.h:17
const CompilerConfiguration & getConfigImpl() override
Definition context.h:33
OptionsType & options() override
Definition context.h:30
static CompileContext & get()
Definition context.h:21
Definition backends/p4tools/common/compiler/configuration.h:18
static const CompilerConfiguration & get()
Definition backends/p4tools/common/compiler/configuration.h:23
Definition common/compiler/compiler_result.cpp:7
static CompileContextType & top()
Definition compile_context.h:39