frame.hpp
Go to the documentation of this file.
1
2#pragma once
3
6#include "core/ast/tmock.hpp"
7
8struct immutableTest;
9struct frameTest;
10
11namespace by {
12
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
29 class _nout frame: public node, public dumpable { // TODO: may be obj, not node.
30 BY(CLASS(frame, node), VISIT())
31 friend class verifier;
32 friend struct ::frameTest;
33 friend class baseObj;
34
35 public:
36 frame();
37 ~frame() override;
38
40 void add(const scope& existing);
41 void add(const scope* it) BY_SIDE_FUNC(add);
42 void add(const nbicontainer& existing);
43 void add(const nbicontainer* it) BY_SIDE_FUNC(add);
44 void add(const node& owner);
45 void add(const node* it) BY_SIDE_FUNC(add);
46 virtual void add(const node* owner, const scope& s);
47 void add(const node* owner, const scope* s) BY_SIDE_FUNC(s, add(owner, *s), void());
48
49 virtual void addLocal(const std::string& name, const node& n);
50 void addLocal(const std::string* name, const node& n) BY_SIDE_FUNC(name, addLocal(*name, n), void());
51 void addLocal(const std::string& name, const node* n) BY_SIDE_FUNC(n, addLocal(name, *n), void());
52 void addLocal(const std::string* name, const node* n) BY_SIDE_FUNC(name&& n, addLocal(*name, *n), void());
53 void addLocal(const nchar* name, const node& n) BY_SIDE_FUNC(name, addLocal(std::string(name), n), void());
54 void addLocal(const nchar* name, const node* n) BY_SIDE_FUNC(name&& n, addLocal(std::string(name), *n), void());
55
56 virtual void del();
57
58 virtual nbool setMe(const node& obj); // 'me' can be a mockNode during verification.
59 nbool setMe(const node* it) BY_SIDE_FUNC(setMe);
60 void setMe();
61
62 const node* getMe() const BY_CONST_FUNC(getMe())
63 node* getMe();
64
65 scope* getLocals();
66 const scope* getLocals() const BY_CONST_FUNC(getLocals())
67
68 virtual nbool addFunc(const baseFunc& new1);
69 nbool addFunc(const baseFunc* it) BY_SIDE_FUNC(addFunc);
70
71 void delFunc();
72
73 baseFunc* getFunc();
74 const baseFunc* getFunc() const BY_CONST_FUNC(getFunc())
75
76 node* getMeHaving(const node& sub);
77 node* getMeHaving(const node* it) BY_SIDE_FUNC(getMeHaving);
78 const node* getMeHaving(const node& sub) const BY_CONST_FUNC(getMeHaving(sub))
79 const node* getMeHaving(const node* sub) const BY_CONST_FUNC(getMeHaving(sub))
80
81 scope* getScopeHaving(const node& sub);
82 scope* getScopeHaving(const node* it) BY_SIDE_FUNC(getScopeHaving);
83 const scope* getScopeHaving(const node& sub) const BY_CONST_FUNC(getScopeHaving(sub))
84 const scope* getScopeHaving(const node* sub) const BY_CONST_FUNC(getScopeHaving(sub))
85
86 // node:
87 using node::subs;
88 scope& subs() override;
89 tstr<nbicontainer> mySubs() const override;
90
91 using super::prioritize;
92 priorType prioritize(const args& a) const override;
93
94 using super::run;
95 str run(const args& a) override;
96
97 void rel() override;
98
99 const std::vector<scopeRegister>& getScopeRegisters() const;
100
101 virtual nbool setRet(const node& newRet) const;
102 virtual nbool setRet(const node* it) const;
103
104 node* getRet() const;
105
106 void dump() const override;
107
108 private:
109 void _rel();
110 scopeRegister* _getTop();
111 const scopeRegister* _getTop() const BY_CONST_FUNC(_getTop())
112
113 template <typename T> T* _getOwner(const node* toFind, std::function<T*(nbool, scopeRegister&)> cl);
114
115 private:
116 str _me;
117 tnarr<baseFunc> _funcs;
118 std::vector<scopeRegister> _stack;
119 mutable str _ret;
120 };
121} // namespace by
Function call arguments container.
Definition: args.hpp:13
Base class for all function types.
Definition: baseFunc.hpp:18
Base class for all objects in byeol language.
Definition: baseObj.hpp:24
Interface for objects that can dump their state.
Definition: dumpable.hpp:12
Execution frame for byeol runtime.
Definition: frame.hpp:29
void add(const scope &existing)
Base class for all AST nodes in byeol language.
Definition: node.hpp:30
Managed object in byeol programming environment.
Definition: obj.hpp:19
Definition: tnarr.hpp:9
Definition: tnbicontainer.hpp:8
AST verifier for semantic analysis.
Definition: verifier.hpp:20
Scope registration entry for frame management.
Definition: frame.hpp:16
priorType
the lower value, the higher priority.
Definition: tpriorities.hpp:8