Loading...
Searching...
No Matches
tmock.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "core/ast/node.hpp"
6#include "core/internal/coreInternal.hpp"
7
8namespace by {
9
19 template <typename T> class _nout tmock: public T {
20 BY(ME(tmock, T))
21
22 public:
23 tmock(): super() {}
24
25 tmock(const T& org): super(), _org(org) {}
26
27 tmock(const T* org): super(), _org(org) {}
28
29 public:
30 const ntype& getType() const override {
31 if(_org) return _org->getType();
32 return ttype<node>::get();
33 }
34
35 using super::subs;
36
37 scope& subs() override {
38 if(_org) return _org->subs();
39 return dumScope::singleton();
40 }
41
42 using super::prioritize;
43
44 priorType prioritize(const args& a) const override {
45 if(_org) return _org->prioritize(a);
46 return NO_MATCH;
47 }
48
49 using super::eval;
50
51 str eval(const args& a) override {
52 if(_org) return _org->eval(a);
53 return str();
54 }
55
56 clonable* clone() const override {
57 if(_org) return _org->clone();
58 return new me(*this);
59 }
60
61 const src& getSrc() const override {
62 if(_org) return _org->getSrc();
63 return super::getSrc();
64 }
65
66 using super::cast;
67
68 void* cast(const type& to) override {
69 if(ttype<me>::get().isSub(to)) return this;
70 if(_org) return _org->cast(to);
71 return nullptr;
72 }
73
74 clonable* cloneDeep() const override { return clone(); }
75
76 void onCloneDeep(const clonable& from) override {}
77
78 protected:
79 using super::_setSrc;
80
81 void _setSrc(const src& s) override {
82 if(!_org) return;
83 coreInternal::setSrc(*_org, s);
84 }
85
86 private:
87 str _org;
88 };
89
90 typedef tmock<node> mockNode;
91} // namespace by
Function or object evaluation arguments.
Definition args.hpp:22
represents native c++ type system for byeol language
Definition ntype.hpp:33
Source location information.
Definition src.hpp:15
Proxy template for type parameter T.
Definition tmock.hpp:19
Definition tnarr.hpp:9
priorType
Definition tpriorities.hpp:10
@ NO_MATCH
Definition tpriorities.hpp:18
to Top