3#include "core/builtin/container/tbicontainable.inl"
10#include "core/ast/tpriorities.inl"
15#define TEMPLATE template <typename T>
19 typedef std::vector<elem> super;
26 while(
n >= this->size())
27 this->super::push_back(
elem());
28 return this->super::operator[](
n);
35 for(
int n = 0;
n < this->size();
n++) {
37 if(
matches.len() == 0)
continue;
45 if(!
first->isSamePrecedence(*
elem))
break;
54 using super::push_back;
57 WHEN(
elem.type > _topPriority) .ret();
60 _topPriority = _topPriority <
elem.type ? _topPriority :
elem.type;
68 T* ME::sub(std::function<
nbool(
const std::string&,
const T&)> l) {
return subs().get<T>(l); }
71 T* ME::sub() {
return subs().get<T>(); }
74 T* ME::sub(
const std::string& name) {
78 return subs().get<T>([&](
const std::string& key,
const T& val) {
79 BY_DI(
"sub: [%d/%d] %s --> %s@%s", ++n, subs().len(), name, key, (
void*) &val);
85 T* ME::sub(
const std::string& name,
const args& a) {
89 std::string argStr = a.toStr();
90 return subs().get<T>([&](
const std::string& key,
const T& val) {
92 if(key == name) p = val.prioritize(a);
94 BY_DI(
"sub: [%d/%d] %s(%s) --> %s@%s = %s", ++n, subs().len(), name, argStr, key, (
void*) &val,
101 tnarr<T, strTactic> ME::subAll(std::function<nbool(
const std::string&,
const T&)> l)
const {
102 return subs().getAll<T>(l);
106 tnarr<T, strTactic> ME::subAll()
const {
return subs().template getAll<T>(); }
109 tpriorities<T> ME::subAll(
const std::string& name)
const {
return subAll<T>(name,
nullptr); }
112 tpriorities<T> ME::subAll(
const std::string& name,
const args* a)
const {
119 std::string myName = getType().createNameWithParams();
120 std::string argStr = a ?
"(" + a->toStr() +
")" :
"";
122 tprioritiesBucket<T> ps;
123 const scope* e = &subs();
127 e->getContainer().each<T>([&](
const std::string& key,
const T& val) {
128 WHEN(key != name) .ret(
true);
130 p = a ? val.prioritize(*a) : EXACT_MATCH;
131 if(p != NO_MATCH) ps.push_back(*
new tprior<T>(val, p, lv));
133 const baseFunc* f = val.template cast<baseFunc>();
134 std::string valArgs = f ?
"(" + f->getParams().toStr() +
")" :
"";
135 BY_DI(
"subAll: [%d/%d] %s%s --> %s.%s%s@%s = priority(type=%s, lv=%d)", n++, subs().len(), name, argStr,
136 myName, key, valArgs, (
void*) &val, getPriorTypeName(p), lv);
147 tpriorities<T> ME::subAll(
const std::string& name,
const args& a)
const {
return subAll<T>(name, &a); }
tnchain< std::string, node, tnmap< std::string, node, immutableTactic > > scope
Symbol scope container.
Definition node.hpp:22
priorType
Definition tpriorities.hpp:10
@ NO_MATCH
Definition tpriorities.hpp:18