本文整理汇总了C++中TermList::length方法的典型用法代码示例。如果您正苦于以下问题:C++ TermList::length方法的具体用法?C++ TermList::length怎么用?C++ TermList::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TermList
的用法示例。
在下文中一共展示了TermList::length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if_block_create_input_placeholders_for_outer_pointers
void if_block_create_input_placeholders_for_outer_pointers(Term* ifCall)
{
Branch* contents = nested_contents(ifCall);
TermList outerTerms;
// Find outer pointers across each case
for (CaseIterator it(contents); it.unfinished(); it.advance()) {
list_outer_pointers(nested_contents(it.current()), &outerTerms);
}
ca_assert(ifCall->numInputs() == 0);
// Create input placeholders and add inputs for all outer pointers
for (int i=0; i < outerTerms.length(); i++) {
Term* outer = outerTerms[i];
set_input(ifCall, i, outer);
Term* placeholder = append_input_placeholder(nested_contents(ifCall));
rename(placeholder, outer->name);
// Go through each case and repoint to this new placeholder
for (CaseIterator it(contents); it.unfinished(); it.advance()) {
remap_pointers_quick(nested_contents(it.current()), outer, placeholder);
}
}
}
示例2: find_accessor_head_term
Term* find_accessor_head_term(Term* accessor)
{
TermList chain;
trace_accessor_chain(accessor, &chain);
if (chain.length() == 0)
return NULL;
return chain[0];
}
示例3: branch_add_pack_state
Term* branch_add_pack_state(Branch* branch)
{
TermList inputs;
get_list_of_state_outputs(branch, branch->length(), &inputs);
// Don't create anything if there are no state outputs
if (inputs.length() == 0)
return NULL;
return apply(branch, FUNCS.pack_state, inputs);
}
示例4: block_add_pack_state
Term* block_add_pack_state(Block* block)
{
TermList inputs;
list_inputs_to_pack_state(block, block->length(), &inputs);
// Don't create anything if there are no state outputs
if (inputs.length() == 0)
return NULL;
return apply(block, FUNCS.pack_state, inputs);
}
示例5: test_equals_function
void test_equals_function(TermList const& a, TermList const& b,
const char* aText, const char* bText, int line, const char* file)
{
if (a.length() != b.length()) {
std::cout << "List equality fail in " << file << ", line " << line << std::endl;
std::cout << " " << aText << " has " << a.length() << " items, ";
std::cout << bText << " has " << b.length() << " items." << std::endl;
declare_current_test_failed();
return;
}
for (int i=0; i < a.length(); i++) {
if (a[i] != b[i]) {
std::cout << "List equality fail in " << file << ", line " << line << std::endl;
std::cout << " " << aText << " != " << bText
<< " (index " << i << " differs)" << std::endl;
declare_current_test_failed();
return;
}
}
}
示例6: block_update_pack_state_calls
void block_update_pack_state_calls(Block* block)
{
if (block->stateType == NULL) {
// No state type, make sure there's no pack_state call.
// TODO: Handle this case properly (should search and destroy an existing pack_state call)
return;
}
int stateOutputIndex = block->length() - 1 - find_state_output(block)->index;
for (int i=0; i < block->length(); i++) {
Term* term = block->get(i);
if (term == NULL)
continue;
if (term->function == FUNCS.pack_state) {
// Update the inputs for this pack_state call
TermList inputs;
list_inputs_to_pack_state(block, i, &inputs);
set_inputs(term, inputs);
}
else if (should_have_preceeding_pack_state(term)) {
// Check if we need to insert a pack_state call
Term* existing = term->input(stateOutputIndex);
if (existing == NULL || existing->function != FUNCS.pack_state) {
TermList inputs;
list_inputs_to_pack_state(block, i, &inputs);
if (inputs.length() != 0) {
Term* pack_state = apply(block, FUNCS.pack_state, inputs);
move_before(pack_state, term);
// Only set as an input for a non-minor block.
if (term->nestedContents == NULL || !is_minor_block(term->nestedContents)) {
set_input(term, stateOutputIndex, pack_state);
set_input_hidden(term, stateOutputIndex, true);
set_input_implicit(term, stateOutputIndex, true);
}
// Advance i to compensate for the term just added
i++;
}
}
}
}
}
示例7: branch_update_existing_pack_state_calls
void branch_update_existing_pack_state_calls(Branch* branch)
{
if (branch->stateType == NULL) {
// No state type, make sure there's no pack_state call.
// TODO: Handle this case properly (should search and destroy an existing pack_state call)
return;
}
int stateOutputIndex = branch->length() - 1 - find_state_output(branch)->index;
for (int i=0; i < branch->length(); i++) {
Term* term = branch->get(i);
if (term == NULL)
continue;
if (term->function == FUNCS.pack_state) {
// Update the inputs for this pack_state call
TermList inputs;
get_list_of_state_outputs(branch, i, &inputs);
set_inputs(term, inputs);
}
if (term->function == FUNCS.exit_point) {
// Check if we need to insert a pack_state call
Term* existing = term->input(stateOutputIndex);
if (existing == NULL || existing->function != FUNCS.pack_state) {
TermList inputs;
get_list_of_state_outputs(branch, i, &inputs);
if (inputs.length() != 0) {
Term* pack_state = apply(branch, FUNCS.pack_state, inputs);
move_before(pack_state, term);
set_input(term, stateOutputIndex + 1, pack_state);
// Advance i to compensate for the term just added
i++;
}
}
}
}
}