File tree Expand file tree Collapse file tree 5 files changed +83
-0
lines changed
Expand file tree Collapse file tree 5 files changed +83
-0
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,6 @@ target_sources(scratchcpp
33 executioncontext.cpp
44 executioncontext_p.cpp
55 executioncontext_p.h
6+ internal /llvmexecutioncontext.cpp
7+ internal /llvmexecutioncontext.h
68)
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+
3+ #include " llvmexecutioncontext.h"
4+
5+ using namespace libscratchcpp ;
6+
7+ LLVMExecutionContext::LLVMExecutionContext (Target *target) :
8+ ExecutionContext(target)
9+ {
10+ }
11+
12+ size_t LLVMExecutionContext::pos () const
13+ {
14+ return m_pos;
15+ }
16+
17+ void LLVMExecutionContext::setPos (size_t newPos)
18+ {
19+ m_pos = newPos;
20+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+
3+ #pragma once
4+
5+ #include < scratchcpp/dev/executioncontext.h>
6+
7+ namespace libscratchcpp
8+ {
9+
10+ class LLVMExecutionContext : public ExecutionContext
11+ {
12+ public:
13+ LLVMExecutionContext (Target *target);
14+
15+ size_t pos () const ;
16+ void setPos (size_t newPos);
17+
18+ private:
19+ size_t m_pos = 0 ;
20+ };
21+
22+ } // namespace libscratchcpp
Original file line number Diff line number Diff line change 1+ add_executable (
2+ llvm_test
3+ llvmexecutioncontext_test.cpp
4+ )
5+
6+ target_link_libraries (
7+ llvm_test
8+ GTest::gtest_main
9+ GTest::gmock_main
10+ scratchcpp
11+ scratchcpp_mocks
12+ )
13+
14+ gtest_discover_tests(llvm_test)
Original file line number Diff line number Diff line change 1+ #include < scratchcpp/target.h>
2+ #include < dev/engine/internal/llvmexecutioncontext.h>
3+
4+ #include " ../../common.h"
5+
6+ using namespace libscratchcpp ;
7+
8+ TEST (LLVMExecutionContextTest, Constructor)
9+ {
10+ Target target;
11+ LLVMExecutionContext ctx (&target);
12+ ASSERT_EQ (ctx.target (), &target);
13+ }
14+
15+ TEST (LLVMExecutionContextTest, Pos)
16+ {
17+ LLVMExecutionContext ctx (nullptr );
18+ ASSERT_EQ (ctx.pos (), 0 );
19+
20+ ctx.setPos (1 );
21+ ASSERT_EQ (ctx.pos (), 1 );
22+
23+ ctx.setPos (356 );
24+ ASSERT_EQ (ctx.pos (), 356 );
25+ }
You can’t perform that action at this time.
0 commit comments