本文整理汇总了C++中Branch::move方法的典型用法代码示例。如果您正苦于以下问题:C++ Branch::move方法的具体用法?C++ Branch::move怎么用?C++ Branch::move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch::move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_implicit_placeholders
void add_implicit_placeholders(Term* forTerm)
{
Branch* contents = nested_contents(forTerm);
std::string listName = forTerm->input(0)->name;
Term* iterator = for_loop_get_iterator(contents);
std::string iteratorName = iterator->name;
std::vector<std::string> reboundNames;
list_names_that_this_branch_rebinds(contents, reboundNames);
int inputIndex = 1;
for (size_t i=0; i < reboundNames.size(); i++) {
std::string const& name = reboundNames[i];
if (name == listName)
continue;
if (name == iteratorName)
continue;
Term* original = find_name_at(forTerm, name.c_str());
// The name might not be found, for certain parser errors.
if (original == NULL)
continue;
Term* result = contents->get(name);
// Create input_placeholder
Term* input = apply(contents, FUNCS.input, TermList(), name_from_string(name));
Type* type = find_common_type(original->type, result->type);
change_declared_type(input, type);
contents->move(input, inputIndex);
set_input(forTerm, inputIndex, original);
// Repoint terms to use our new input_placeholder
for (BranchIterator it(contents); it.unfinished(); it.advance())
remap_pointers_quick(*it, original, input);
// Create output_placeholder
Term* term = apply(contents, FUNCS.output, TermList(result), name_from_string(name));
// Move output into the correct output slot
contents->move(term, contents->length() - 1 - inputIndex);
inputIndex++;
}
}
示例2: if_block_append_case
Term* if_block_append_case(Term* ifBlock, Term* input)
{
Branch* contents = nested_contents(ifBlock);
int insertPos = 0;
for (int i=0; i < contents->length(); i++) {
Term* term = contents->get(i);
if (term->function == FUNCS.input)
insertPos = term->index + 1;
// Insert position is right after the last non-default case.
if (term->function == FUNCS.case_func && term->input(0) != NULL)
insertPos = term->index + 1;
}
Term* newCase = apply(contents, FUNCS.case_func, TermList(input));
contents->move(newCase, insertPos);
// Add existing input placeholders to this case
for (int i=0;; i++) {
Term* placeholder = get_input_placeholder(contents, i);
if (placeholder == NULL) break;
Term* localPlaceholder = append_input_placeholder(nested_contents(newCase));
change_declared_type(localPlaceholder, placeholder->type);
}
return newCase;
}