🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
Expr.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstUtil/Object.hpp"
25#include "AstScript/ScriptAPI.hpp"
26
27AST_NAMESPACE_BEGIN
28
29class Value;
30
38class AST_SCRIPT_API Expr: public Object
39{
40public:
41 using Object::Object;
42 ~Expr() override = default;
43
46 virtual void accept(ExprVisitor& visitor) = 0;
47
50 virtual Value* eval() const = 0;
51
55 virtual Expr* exec() const {return const_cast<Expr*>(this);};
56
58 virtual errc_t setValue(Value* val) {return eErrorReadonly;};
59
63 virtual std::string getExpression(Object* context=nullptr) const = 0;
64};
65
66
67AST_NAMESPACE_END
表达式访问器
定义 ExprVisitor.hpp:58
表达式基类
定义 Expr.hpp:39
virtual Expr * exec() const
执行
定义 Expr.hpp:55
virtual void accept(ExprVisitor &visitor)=0
接受表达式访问者
virtual errc_t setValue(Value *val)
设置表达式的值
定义 Expr.hpp:58
virtual Value * eval() const =0
求值
virtual std::string getExpression(Object *context=nullptr) const =0
获取表达式的字符串表示
对象基类,继承自该类的对象可以使用运行时类型信息相关功能,实现强弱引用计数、运行时元信息(属性访问、序列化等)等基础功能
定义 Object.hpp:81
值对象基类
定义 Value.hpp:36