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
13
namespace
P4::P4Tools
{
14
16
template
<
typename
OptionsType>
17
class
CompileContext :
public
virtual
P4CContext {
18
public
:
21
static
CompileContext &
get
() {
return
CompileContextStack::top<CompileContext>
(); }
22
23
CompileContext
() =
default
;
24
25
template
<
typename
OptionsDerivedType>
26
explicit
CompileContext
(
CompileContext<OptionsDerivedType>
&context)
27
: _optionsInstance(context.options()) {}
28
30
OptionsType &
options
()
override
{
return
_optionsInstance; }
31
32
protected
:
33
const
CompilerConfiguration
&
getConfigImpl
()
override
{
return
CompilerConfiguration::get
(); }
34
35
private
:
37
OptionsType _optionsInstance;
38
};
39
40
}
// namespace P4::P4Tools
41
42
#endif
/* BACKENDS_P4TOOLS_COMMON_COMPILER_CONTEXT_H_ */
P4::P4Tools::CompileContext
A compilation context for P4Tools that provides a custom compiler configuration.
Definition
context.h:17
P4::P4Tools::CompileContext::getConfigImpl
const CompilerConfiguration & getConfigImpl() override
Definition
context.h:33
P4::P4Tools::CompileContext::options
OptionsType & options() override
Definition
context.h:30
P4::P4Tools::CompileContext::get
static CompileContext & get()
Definition
context.h:21
P4::P4Tools::CompilerConfiguration
Definition
backends/p4tools/common/compiler/configuration.h:18
P4::P4Tools::CompilerConfiguration::get
static const CompilerConfiguration & get()
Definition
backends/p4tools/common/compiler/configuration.h:23
P4::P4Tools
Definition
common/compiler/compiler_result.cpp:7
P4::CompileContextStack::top
static CompileContextType & top()
Definition
compile_context.h:39
backends
p4tools
common
compiler
context.h
Generated by
1.13.2