File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ if (LIBSCRATCHCPP_USE_LLVM)
6969 target_compile_definitions (scratchcpp PUBLIC USE_LLVM)
7070 target_sources (scratchcpp
7171 PUBLIC
72+ include /scratchcpp/dev/executablecode.h
7273 include /scratchcpp/dev/executioncontext.h
7374 )
7475
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0
2+
3+ #pragma once
4+
5+ #include < memory>
6+
7+ #include " ../global.h"
8+
9+ namespace libscratchcpp
10+ {
11+
12+ class ExecutionContext ;
13+ class Target ;
14+
15+ /* ! \brief The ExecutableCode class represents the code of a compiled Scratch script. */
16+ class LIBSCRATCHCPP_EXPORT ExecutableCode
17+ {
18+ public:
19+ virtual ~ExecutableCode () { }
20+
21+ /* ! Runs the script until it finishes or yields. */
22+ virtual void run (ExecutionContext *context) = 0;
23+
24+ /* ! Stops the code. isFinished() will return true. */
25+ virtual void kill (ExecutionContext *context) = 0;
26+
27+ /* ! Resets the code to run from the start. */
28+ virtual void reset (ExecutionContext *context) = 0;
29+
30+ /* ! Returns true if the code is stopped or finished. */
31+ virtual bool isFinished (ExecutionContext *context) const = 0;
32+
33+ /* ! Pauses the script (when it's executed using run() again) until resolvePromise() is called. */
34+ virtual void promise () = 0;
35+
36+ /* ! Resolves the promise and resumes the script. */
37+ virtual void resolvePromise () = 0;
38+
39+ /* ! Creates an execution context for the given Target. */
40+ virtual std::shared_ptr<ExecutionContext> createExecutionContext (Target *target) const = 0;
41+ };
42+
43+ } // namespace libscratchcpp
You can’t perform that action at this time.
0 commit comments