🛰️航天仿真算法库 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
44 void setName(StringView name) override{}
45
48 virtual void accept(ExprVisitor& visitor) = 0;
49
52 virtual Value* eval() const = 0;
53
57 virtual Expr* exec() const {return const_cast<Expr*>(this);};
58
60 virtual errc_t setValue(Value* val) {return eErrorReadonly;};
61
65 virtual std::string getExpression(Object* context=nullptr) const = 0;
66};
67
68
69AST_NAMESPACE_END
表达式访问器
定义 ExprVisitor.hpp:61
表达式基类
定义 Expr.hpp:39
virtual Expr * exec() const
执行
定义 Expr.hpp:57
virtual void accept(ExprVisitor &visitor)=0
接受表达式访问者
virtual errc_t setValue(Value *val)
设置表达式的值
定义 Expr.hpp:60
virtual Value * eval() const =0
求值
void setName(StringView name) override
设置对象的名称
定义 Expr.hpp:44
virtual std::string getExpression(Object *context=nullptr) const =0
获取表达式的字符串表示
对象基类,继承自该类的对象可以使用运行时类型信息相关功能,实现强弱引用计数、运行时元信息(属性访问、序列化等)等基础功能
定义 Object.hpp:86
值对象基类
定义 Value.hpp:43