🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
Interpreter.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "SymbolTable.hpp"
25#include "SymbolScope.hpp"
26#include "CallStack.hpp"
27#include "ScriptContext.hpp"
28#include <string>
29
30AST_NAMESPACE_BEGIN
31
32
37class AST_SCRIPT_API Interpreter
38{
39public:
40 Interpreter() = default;
42
47 SymbolScope* currentScope() { return &symbolScope_; }
48
54 void interpret(StringView code);
55
56
61 const std::string& errString() const { return errString_; }
62
63
68 void setErrString(StringView err) { errString_ = std::string(err); }
69
70
74 void clearErrString() { errString_.clear(); }
75
76protected:
78 std::string errString_;
79};
80
86public:
88 : InterpreterContext(&interpreter)
89 {
90 }
92 : interpreter_(interpreter)
93 {
94 aScript_SetInterpreter(interpreter);
95 }
97 {
98 aScript_RemoveInterpreter(interpreter_);
99 }
100private:
101 Interpreter* interpreter_;
102};
103
104
105
106AST_NAMESPACE_END
解释器上下文守卫
定义 Interpreter.hpp:85
解释器
定义 Interpreter.hpp:38
SymbolScope * currentScope()
获取当前作用域
定义 Interpreter.hpp:47
void clearErrString()
清除错误字符串
定义 Interpreter.hpp:74
void setErrString(StringView err)
设置错误字符串
定义 Interpreter.hpp:68
std::string errString_
错误字符串
定义 Interpreter.hpp:78
const std::string & errString() const
获取错误字符串
定义 Interpreter.hpp:61
SymbolScope symbolScope_
当前作用域
定义 Interpreter.hpp:77
符号作用域
定义 SymbolScope.hpp:38
void aScript_RemoveInterpreter(Interpreter *interpreter)
移除解释器指针
定义 ScriptContext.cpp:82
void aScript_SetInterpreter(Interpreter *interpreter)
设置解释器指针
定义 ScriptContext.cpp:77