void Private::MakeSequence( Node const & node, Expression const & rule, IdSetTable const & table, CallSequence & seq) { /* reducing the range of callee */ size_t cnt = 0U; std::vector<size_t> rule_list; for (auto & pair : rule) { auto & caller_set = table[pair.first]; if (caller_set.find(node.id) != caller_set.end()) rule_list.push_back(cnt); cnt++; } /* search for callee */ if (!rule_list.empty()) { for (auto & child : node.children) { for (auto & rule_idx : rule_list) { auto callee_set = table[rule[rule_idx].second]; if (callee_set.find(child.id) != callee_set.end()) seq.push_back(std::make_pair(&node, &child)); } MakeSequence(child, rule, table, seq); } } else for (auto & child : node.children) MakeSequence(child, rule, table, seq); }
int m_Enumerate(Object *in, Object *out) { int i; int *ip = NULL; char *cp = NULL; out[0] = NULL; icheck(in[0], "start"); icheck(in[1], "end"); if (in[2]) { if (!DXExtractInteger(in[2], &i) || (i <= 0)) { DXSetError(ERROR_BAD_PARAMETER, "#10020", "count"); goto error; } ip = &i; } icheck(in[3], "delta"); if (in[4] && !DXExtractString(in[4], &cp)) { DXSetError(ERROR_BAD_PARAMETER, "#10200", "method"); goto error; } out[0] = (Object)MakeSequence((Array)in[0], (Array)in[1], ip, (Array)in[3], cp); error: return out[0] ? OK : ERROR; }