node.hpp
Go to the documentation of this file.
1
2#pragma once
3
6#include "core/type/ntype.hpp"
10
11namespace by {
12
13 class ases;
14 class args;
15 class visitor;
16 class visitInfo;
17 class baseObj;
18 class src;
19 class modifier;
20 template <typename K, typename V, typename defaultContainer> class tnchain;
21
22 typedef tnchain<std::string, node, tnmap<std::string, node, immutableTactic>> scope;
23
24 template <typename T> class tmock;
25
30 class _nout node: public instance, public frameInteractable {
31 BY(ADT(node, instance))
32 friend class exprMaker; // for _setSrc
33 template <typename T> friend class tmock;
34
35 public:
36 me& operator[](const std::string& name);
37 const me& operator[](const std::string& name) const BY_CONST_FUNC(operator[](name));
38 me& operator[](const std::string* it);
39 const me& operator[](const std::string* it) const BY_CONST_FUNC(operator[](it));
40 me& operator[](const nchar* name);
41 const me& operator[](const nchar* name) const BY_CONST_FUNC(operator[](name));
42
43 public:
44 nbool in(const node& elem) const;
45 nbool in(const node* elem) const;
46
47 virtual scope& subs() = 0;
48 const scope& subs() const BY_CONST_FUNC(subs())
49 virtual tstr<nbicontainer> mySubs() const;
50
55 const node* deduce(const node& it) const;
56 const node* deduce(const node* it) const BY_SIDE_FUNC(deduce);
57
58 template <typename T> T* sub(std::function<nbool(const std::string&, const T&)> l);
59 template <typename T>
60 const T* sub(std::function<nbool(const std::string&, const T&)> l) const BY_CONST_FUNC(sub<T>(l))
61 template <typename T = me> T* sub();
62 template <typename T = me> const T* sub() const BY_CONST_FUNC(sub<T>())
63 template <typename T = me> T* sub(const std::string& name);
64 template <typename T = me> T* sub(const std::string* it) BY_SIDE_FUNC(sub);
65 template <typename T = me> const T* sub(const std::string& name) const BY_CONST_FUNC(sub<T>(name))
66 template <typename T = me> const T* sub(const std::string* name) const BY_CONST_FUNC(sub<T>(name))
67 template <typename T = me> T* sub(const std::string& name, const args& a);
68 template <typename T = me>
69 T* sub(const std::string* name, const args& a) BY_SIDE_FUNC(name, sub(*name, a), nullptr);
70 template <typename T = me>
71 const T* sub(const std::string& name, const args& a) const BY_CONST_FUNC(sub<T>(name, a))
72 template <typename T = me>
73 const T* sub(const std::string* name, const args& a) const BY_CONST_FUNC(sub<T>(name, a))
74
75 template <typename T> tnarr<T, strTactic> subAll(std::function<nbool(const std::string&, const T&)> l) const;
76 template <typename T = me> tnarr<T, strTactic> subAll() const;
77 template <typename T = me> tpriorities<T> subAll(const std::string& name) const;
78 template <typename T = me>
79 tpriorities<T> subAll(const std::string* it) const BY_SIDE_FUNC(subAll<T>)
80
81
90 template <typename T = me>
91 tpriorities<T> subAll(const std::string& name, const args* a) const;
92 template <typename T = me> tpriorities<T> subAll(const std::string& name, const args& a) const;
93 template <typename T = me>
94 tpriorities<T> subAll(const std::string* name, const args* a) const
95 BY_SIDE_FUNC(name, subAll<T>(*name, a), tpriorities<T>());
96 template <typename T = me>
97 tpriorities<T> subAll(const std::string* name, const args& a) const
98 BY_SIDE_FUNC(name, subAll<T>(*name, a), tpriorities<T>());
99
100 bool canRun(const args& a) const;
101 virtual priorType prioritize(const args& a) const = 0;
102 priorType prioritize(const args* it) const BY_SIDE_FUNC(it, prioritize(*it), NO_MATCH);
103
104 virtual str run(const args& a) = 0;
105 str run(const args* it) BY_SIDE_FUNC(run);
106 str run(const std::string& name, const args& a);
107 str run(const std::string& name, const args* a) BY_SIDE_FUNC(a, run(name, a), str());
108 str run(const std::string* name, const args& a) BY_SIDE_FUNC(name, run(*name, a), str());
109 str run(const std::string* name, const args* a) BY_SIDE_FUNC(name&& a, run(*name, *a), str());
110 str run(const std::string& name);
111 str run(const std::string* it) BY_SIDE_FUNC(run);
112 str run();
113
116 virtual void rel() {}
117
118 template <typename T> nbool is() const { return is(ttype<T>::get()); }
119
120 nbool is(const typeProvidable& to) const;
121 nbool is(const typeProvidable* it) const BY_SIDE_FUNC(is);
122 nbool is(const type& to) const;
123 nbool is(const type* it) const BY_SIDE_FUNC(is);
124
125 template <typename T> tstr<T> as() const { return as(ttype<T>::get()); }
126
127 str as(const typeProvidable& to) const;
128 str as(const typeProvidable* it) const BY_SIDE_FUNC(as);
129 str as(const type& to) const;
130 str as(const type* it) const BY_SIDE_FUNC(as);
131
132 template <typename T> nbool isImpli() const { return isImpli(ttype<T>::get()); }
133
134 virtual nbool isImpli(const type& to) const;
135 nbool isImpli(const typeProvidable& to) const;
136 nbool isImpli(const typeProvidable* it) const BY_SIDE_FUNC(isImpli);
137
138 template <typename T> tstr<T> asImpli() const { return asImpli(ttype<T>::get()); }
139
140 virtual str asImpli(const type& to) const;
141 str asImpli(const typeProvidable& to) const;
142 str asImpli(const typeProvidable* it) const BY_SIDE_FUNC(asImpli);
143
144 virtual const src& getSrc() const;
145
149 virtual nbool isComplete() const;
150
165 virtual str getEval() const;
166
167 virtual void accept(const visitInfo& i, visitor& v);
168
169 using frameInteractable::inFrame;
170 void inFrame(const bicontainable* args) const override;
171 using frameInteractable::outFrame;
172 void outFrame() const override;
173
174 virtual const modifier& getModifier() const;
175
176 protected:
177 virtual str _onRunSub(node& sub, const args& a);
178 virtual void _setSrc(const src& s);
179 void _setSrc(const src* it) BY_SIDE_FUNC(_setSrc);
180 };
181
182 extern template class tnmap<std::string, node>;
184} // namespace by
Function call arguments container.
Definition: args.hpp:13
Factory for creating expressions with source location information.
Definition: exprMaker.hpp:17
Interface for frame interaction.
Definition: frameInteractable.hpp:15
Base class for all managed instances in memlite system.
Definition: instance.hpp:20
Access modifier for class members and func.
Definition: modifier.hpp:12
Base class for all AST nodes in byeol language.
Definition: node.hpp:30
virtual nbool isComplete() const
virtual str getEval() const
const node * deduce(const node &it) const
Source location information.
Definition: src.hpp:11
Strong reference binding tactic.
Definition: strTactic.hpp:12
Template bidirectional container interface.
Definition: tbicontainable.hpp:17
Mock object template for testing and verification.
Definition: tmock.hpp:13
Definition: tnarr.hpp:9
Definition: tnmap.hpp:11
Collection of prioritized elements.
Definition: tpriorities.hpp:53
Strong reference smart pointer with strict type checking.
Definition: tstr.hpp:13
Template type wrapper for type metadata management.
Definition: ttype.hpp:16
Visitor context information.
Definition: visitInfo.hpp:10
Base visitor class for AST traversal.
Definition: visitor.hpp:20
priorType
the lower value, the higher priority.
Definition: tpriorities.hpp:8