Add ability to set semanitc parent of a cpp_variable
This commit is contained in:
parent
ba6fd12dce
commit
12432de30d
2 changed files with 17 additions and 17 deletions
|
|
@ -27,16 +27,16 @@ public:
|
|||
static std::unique_ptr<cpp_variable> build(const cpp_entity_index& idx, cpp_entity_id id,
|
||||
std::string name, std::unique_ptr<cpp_type> type,
|
||||
std::unique_ptr<cpp_expression> def,
|
||||
cpp_storage_class_specifiers spec,
|
||||
bool is_constexpr);
|
||||
cpp_storage_class_specifiers spec, bool is_constexpr,
|
||||
type_safe::optional<cpp_entity_ref> semantic_parent
|
||||
= {});
|
||||
|
||||
/// \returns A newly created variable that is a declaration.
|
||||
/// A declaration will not be registered and it does not have the default value.
|
||||
static std::unique_ptr<cpp_variable> build_declaration(cpp_entity_id definition_id,
|
||||
std::string name,
|
||||
std::unique_ptr<cpp_type> type,
|
||||
cpp_storage_class_specifiers spec,
|
||||
bool is_constexpr);
|
||||
static std::unique_ptr<cpp_variable> build_declaration(
|
||||
cpp_entity_id definition_id, std::string name, std::unique_ptr<cpp_type> type,
|
||||
cpp_storage_class_specifiers spec, bool is_constexpr,
|
||||
type_safe::optional<cpp_entity_ref> semantic_parent = {});
|
||||
|
||||
/// \returns The [cppast::cpp_storage_specifiers]() on that variable.
|
||||
cpp_storage_class_specifiers storage_class() const noexcept
|
||||
|
|
|
|||
|
|
@ -12,26 +12,26 @@ cpp_entity_kind cpp_variable::kind() noexcept
|
|||
return cpp_entity_kind::variable_t;
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_variable> cpp_variable::build(const cpp_entity_index& idx, cpp_entity_id id,
|
||||
std::string name, std::unique_ptr<cpp_type> type,
|
||||
std::unique_ptr<cpp_expression> def,
|
||||
cpp_storage_class_specifiers spec,
|
||||
bool is_constexpr)
|
||||
std::unique_ptr<cpp_variable> cpp_variable::build(
|
||||
const cpp_entity_index& idx, cpp_entity_id id, std::string name, std::unique_ptr<cpp_type> type,
|
||||
std::unique_ptr<cpp_expression> def, cpp_storage_class_specifiers spec, bool is_constexpr,
|
||||
type_safe::optional<cpp_entity_ref> semantic_parent)
|
||||
{
|
||||
auto result = std::unique_ptr<cpp_variable>(
|
||||
new cpp_variable(std::move(name), std::move(type), std::move(def), spec, is_constexpr));
|
||||
result->set_semantic_parent(std::move(semantic_parent));
|
||||
idx.register_definition(std::move(id), type_safe::cref(*result));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_variable> cpp_variable::build_declaration(cpp_entity_id definition_id,
|
||||
std::string name,
|
||||
std::unique_ptr<cpp_type> type,
|
||||
cpp_storage_class_specifiers spec,
|
||||
bool is_constexpr)
|
||||
std::unique_ptr<cpp_variable> cpp_variable::build_declaration(
|
||||
cpp_entity_id definition_id, std::string name, std::unique_ptr<cpp_type> type,
|
||||
cpp_storage_class_specifiers spec, bool is_constexpr,
|
||||
type_safe::optional<cpp_entity_ref> semantic_parent)
|
||||
{
|
||||
auto result = std::unique_ptr<cpp_variable>(
|
||||
new cpp_variable(std::move(name), std::move(type), nullptr, spec, is_constexpr));
|
||||
result->set_semantic_parent(std::move(semantic_parent));
|
||||
result->mark_declaration(definition_id);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue