File tree Expand file tree Collapse file tree 8 files changed +104
-0
lines changed Expand file tree Collapse file tree 8 files changed +104
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ if (LIBSCRATCHCPP_USE_LLVM)
74
74
target_sources (scratchcpp
75
75
PUBLIC
76
76
include /scratchcpp/dev/compiler.h
77
+ include /scratchcpp/dev/compilercontext.h
77
78
include /scratchcpp/dev/compilervalue.h
78
79
include /scratchcpp/dev/compilerconstant.h
79
80
include /scratchcpp/dev/compilerlocalvariable.h
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ #include " ../global.h"
6
+ #include " ../spimpl.h"
7
+
8
+ namespace libscratchcpp
9
+ {
10
+
11
+ class IEngine ;
12
+ class Target ;
13
+ class CompilerContextPrivate ;
14
+
15
+ /* ! \brief The CompilerContext represents a context for a specific target which is used with the Compiler class. */
16
+ class LIBSCRATCHCPP_EXPORT CompilerContext
17
+ {
18
+ public:
19
+ CompilerContext (IEngine *engine, Target *target);
20
+ CompilerContext (const CompilerContext &) = delete ;
21
+ virtual ~CompilerContext () { }
22
+
23
+ IEngine *engine () const ;
24
+ Target *target () const ;
25
+
26
+ private:
27
+ spimpl::unique_impl_ptr<CompilerContextPrivate> impl;
28
+ };
29
+
30
+ } // namespace libscratchcpp
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ target_sources(scratchcpp
3
3
compiler.cpp
4
4
compiler_p.cpp
5
5
compiler_p.h
6
+ compilercontext.cpp
7
+ compilercontext_p.cpp
8
+ compilercontext_p.h
6
9
compilervalue.cpp
7
10
compilervalue_p.cpp
8
11
compilervalue_p.h
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #include < scratchcpp/dev/compilercontext.h>
4
+
5
+ #include " compilercontext_p.h"
6
+
7
+ using namespace libscratchcpp ;
8
+
9
+ /* ! Constructs CompilerContext. */
10
+ CompilerContext::CompilerContext (IEngine *engine, Target *target) :
11
+ impl(spimpl::make_unique_impl<CompilerContextPrivate>(engine, target))
12
+ {
13
+ }
14
+
15
+ /* ! Returns the engine of the project. */
16
+ IEngine *CompilerContext::engine () const
17
+ {
18
+ return impl->engine ;
19
+ }
20
+
21
+ /* ! Returns the target of this context. */
22
+ Target *CompilerContext::target () const
23
+ {
24
+ return impl->target ;
25
+ }
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #include " compilercontext_p.h"
4
+
5
+ using namespace libscratchcpp ;
6
+
7
+ CompilerContextPrivate::CompilerContextPrivate (IEngine *engine, Target *target) :
8
+ engine(engine),
9
+ target(target)
10
+ {
11
+ }
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ namespace libscratchcpp
6
+ {
7
+
8
+ class IEngine ;
9
+ class Target ;
10
+
11
+ struct CompilerContextPrivate
12
+ {
13
+ CompilerContextPrivate (IEngine *engine, Target *target);
14
+
15
+ IEngine *engine = nullptr ;
16
+ Target *target = nullptr ;
17
+ };
18
+
19
+ } // namespace libscratchcpp
Original file line number Diff line number Diff line change 1
1
add_executable (
2
2
compiler_test
3
3
compiler_test.cpp
4
+ compilercontext_test.cpp
4
5
compilervalue_test.cpp
5
6
compilerconstant_test.cpp
6
7
compilerlocalvariable_test.cpp
Original file line number Diff line number Diff line change
1
+ #include < scratchcpp/dev/compilercontext.h>
2
+ #include < enginemock.h>
3
+ #include < targetmock.h>
4
+
5
+ using namespace libscratchcpp ;
6
+
7
+ TEST (CompilerContextTest, Constructors)
8
+ {
9
+ EngineMock engine;
10
+ TargetMock target;
11
+ CompilerContext ctx (&engine, &target);
12
+ ASSERT_EQ (ctx.engine (), &engine);
13
+ ASSERT_EQ (ctx.target (), &target);
14
+ }
You can’t perform that action at this time.
0 commit comments