Loading...
Searching...
No Matches
frame.hpp
Go to the documentation of this file.
1
2#pragma once
3
6
7struct immutableTest;
8struct frameTest;
9
10namespace by {
11
16 struct _nout scopeRegister {
17 str owner;
19 tstr<scope> linkedS; // linked scope to previous element of _stack.
20 };
21
22 class obj;
23 class baseFunc;
24
52 class _nout frame: public node, public dumpable { // TODO: may be obj, not node.
53 BY(CLASS(frame, node), VISIT())
54 friend struct ::frameTest;
55
56 public:
57 frame();
58 ~frame() override;
59
68 void add(const scope& existing);
69 void add(const scope* it) BY_SIDE_FUNC(add);
70 void add(const nbicontainer& existing);
71 void add(const nbicontainer* it) BY_SIDE_FUNC(add);
72 void add(const node& owner);
73 void add(const node* it) BY_SIDE_FUNC(add);
80 virtual void add(const node* owner, const scope& s);
81 void add(const node* owner, const scope* s) BY_SIDE_FUNC(s, add(owner, *s), void());
82
90 virtual void addLocal(const std::string& name, const node& n);
91 void addLocal(const std::string* name, const node& n) BY_SIDE_FUNC(name, addLocal(*name, n), void());
92 void addLocal(const std::string& name, const node* n) BY_SIDE_FUNC(n, addLocal(name, *n), void());
93 void addLocal(const std::string* name, const node* n) BY_SIDE_FUNC(name&& n, addLocal(*name, *n), void());
94 void addLocal(const nchar* name, const node& n) BY_SIDE_FUNC(name, addLocal(std::string(name), n), void());
95 void addLocal(const nchar* name, const node* n) BY_SIDE_FUNC(name&& n, addLocal(std::string(name), *n), void());
96
102 virtual void del();
103
112 virtual nbool setMe(const node& obj); // 'me' can be a mockNode during verification.
113 nbool setMe(const node* it) BY_SIDE_FUNC(setMe);
114 void setMe();
115
116 const node* getMe() const BY_CONST_FUNC(getMe())
117 node* getMe();
118
119 scope* getLocals();
120 const scope* getLocals() const BY_CONST_FUNC(getLocals())
121
129 virtual nbool addFunc(const baseFunc& new1);
130 nbool addFunc(const baseFunc* it) BY_SIDE_FUNC(addFunc);
131
137 void delFunc();
138
139 baseFunc* getFunc();
140 const baseFunc* getFunc() const BY_CONST_FUNC(getFunc())
141
147 node* getMeHaving(const node& sub);
148 node* getMeHaving(const node* it) BY_SIDE_FUNC(getMeHaving);
149 const node* getMeHaving(const node& sub) const BY_CONST_FUNC(getMeHaving(sub))
150 const node* getMeHaving(const node* sub) const BY_CONST_FUNC(getMeHaving(sub))
151
157 scope* getScopeHaving(const node& sub);
158 scope* getScopeHaving(const node* it) BY_SIDE_FUNC(getScopeHaving);
159 const scope* getScopeHaving(const node& sub) const BY_CONST_FUNC(getScopeHaving(sub))
160 const scope* getScopeHaving(const node* sub) const BY_CONST_FUNC(getScopeHaving(sub))
161
162 // node:
163 using node::subs;
164 scope& subs() override;
166
167 using super::prioritize;
168 priorType prioritize(const args& a) const override;
169
170 using super::eval;
171 str eval(const args& a) override;
172
173 void rel() override;
174
175 const std::vector<scopeRegister>& getScopeRegisters() const;
176
186 virtual nbool setRet(const node* it) const;
187
188 node* getRet() const;
189
190 void dump() const override;
191
192 private:
193 void _rel();
194 scopeRegister* _getTop();
195 const scopeRegister* _getTop() const BY_CONST_FUNC(_getTop())
196 void _dumpFunc() const;
197
198 template <typename T> T* _getOwner(const node* toFind, std::function<T*(nbool, scopeRegister&)> cl);
199
200 private:
201 str _me;
202 tnarr<baseFunc> _funcs;
203 std::vector<scopeRegister> _stack;
204 mutable str _ret;
205 };
206} // namespace by
Function or object evaluation arguments.
Definition args.hpp:22
Base class for all function types.
Definition baseFunc.hpp:41
Execution frame.
Definition frame.hpp:52
virtual void add(const node *owner, const scope &s)
Adds a scope associated with a specific owner node to the frame's scope chain.
virtual void del()
Deletes the top-most scope from the frame's scope chain.
virtual nbool setMe(const node &obj)
Sets the "me" object (context) for the current frame.
virtual void addLocal(const std::string &name, const node &n)
Adds a local symbol to the innermost local scope of the current frame.
void add(const scope &existing)
Adds an existing scope to the frame's scope chain.
Base class for all AST nodes in the byeol language.
Definition node.hpp:195
Byeol runtime environment object.
Definition obj.hpp:62
Definition tnarr.hpp:9
Scope registration entry for frame management.
Definition frame.hpp:16
priorType
Definition tpriorities.hpp:10
to Top