MCPcopy Create free account
hub / github.com/covscript/covscript / find_id_ref

Method find_id_ref

sources/compiler/compiler.cpp:503–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501 };
502
503 bool compiler_type::find_id_ref(tree_type<token_base *>::iterator it, const std::string &id)
504 {
505 if (!it.usable())
506 return false;
507 token_base *token = it.data();
508 if (token == nullptr)
509 return false;
510 switch (token->get_type()) {
511 default:
512 break;
513 case token_types::id:
514 return static_cast<token_id *>(token)->get_id().get_id() == id;
515 case token_types::expr:
516 return find_id_ref(static_cast<token_expr *>(it.data())->get_tree().root(), id);
517 case token_types::array: {
518 for (auto &tree : static_cast<token_array *>(token)->get_array()) {
519 if (find_id_ref(tree.root(), id))
520 return true;
521 }
522 return false;
523 }
524 }
525 if (find_id_ref(it.left(), id) || find_id_ref(it.right(), id))
526 return true;
527 else
528 return false;
529 }
530
531 void
532 compiler_type::trim_expr(tree_type<token_base *> &tree, tree_type<token_base *>::iterator it, trim_type do_trim)

Callers

nothing calls this directly

Calls 6

dataMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80
usableMethod · 0.45
get_typeMethod · 0.45
rootMethod · 0.45

Tested by

no test coverage detected