mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
If an entity is inserted into a scope already exists by the same name, it will not report as an error any more
This commit is contained in:
+14
-5
@@ -415,20 +415,28 @@ Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
StringHashKey key = string_hash_string(name);
|
StringHashKey key = string_hash_string(name);
|
||||||
|
Entity **found = nullptr;
|
||||||
|
Entity *result = nullptr;
|
||||||
|
|
||||||
mutex_lock(&s->mutex);
|
mutex_lock(&s->mutex);
|
||||||
defer (mutex_unlock(&s->mutex));
|
defer (mutex_unlock(&s->mutex));
|
||||||
|
|
||||||
Entity **found = string_map_get(&s->elements, key);
|
found = string_map_get(&s->elements, key);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
return *found;
|
if (entity != *found) {
|
||||||
|
result = *found;
|
||||||
|
}
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
if (s->parent != nullptr && (s->parent->flags & ScopeFlag_Proc) != 0) {
|
if (s->parent != nullptr && (s->parent->flags & ScopeFlag_Proc) != 0) {
|
||||||
Entity **found = string_map_get(&s->parent->elements, key);
|
found = string_map_get(&s->parent->elements, key);
|
||||||
if (found) {
|
if (found) {
|
||||||
if ((*found)->flags & EntityFlag_Result) {
|
if ((*found)->flags & EntityFlag_Result) {
|
||||||
return *found;
|
if (entity != *found) {
|
||||||
|
result = *found;
|
||||||
|
}
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,7 +445,8 @@ Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity) {
|
|||||||
if (entity->scope == nullptr) {
|
if (entity->scope == nullptr) {
|
||||||
entity->scope = s;
|
entity->scope = s;
|
||||||
}
|
}
|
||||||
return nullptr;
|
end:;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *scope_insert(Scope *s, Entity *entity) {
|
Entity *scope_insert(Scope *s, Entity *entity) {
|
||||||
|
|||||||
Reference in New Issue
Block a user