string comparisons

This commit is contained in:
gingerBill
2016-08-15 13:46:01 +01:00
parent 0f48a7d299
commit 3ed75b22a3
14 changed files with 1176 additions and 195 deletions
+9 -9
View File
@@ -242,7 +242,7 @@ void check_close_scope(Checker *c) {
}
void scope_lookup_parent_entity(Scope *s, String name, Scope **scope, Entity **entity) {
u64 key = hash_string(name);
HashKey key = hash_string(name);
for (; s != NULL; s = s->parent) {
Entity **found = map_get(&s->elements, key);
if (found) {
@@ -262,7 +262,7 @@ Entity *scope_lookup_entity(Scope *s, String name) {
}
Entity *current_scope_lookup_entity(Scope *s, String name) {
u64 key = hash_string(name);
HashKey key = hash_string(name);
Entity **found = map_get(&s->elements, key);
if (found)
return *found;
@@ -273,7 +273,7 @@ Entity *current_scope_lookup_entity(Scope *s, String name) {
Entity *scope_insert_entity(Scope *s, Entity *entity) {
String name = entity->token.string;
u64 key = hash_string(name);
HashKey key = hash_string(name);
Entity **found = map_get(&s->elements, key);
if (found)
return *found;
@@ -465,7 +465,7 @@ void add_type_and_value(CheckerInfo *i, AstNode *expression, AddressingMode mode
void add_entity_definition(CheckerInfo *i, AstNode *identifier, Entity *entity) {
GB_ASSERT(identifier != NULL);
GB_ASSERT(identifier->kind == AstNode_Ident);
u64 key = hash_pointer(identifier);
HashKey key = hash_pointer(identifier);
map_set(&i->definitions, key, entity);
}
@@ -484,7 +484,7 @@ void add_entity(Checker *c, Scope *scope, AstNode *identifier, Entity *entity) {
void add_entity_use(CheckerInfo *i, AstNode *identifier, Entity *entity) {
GB_ASSERT(identifier != NULL);
GB_ASSERT(identifier->kind == AstNode_Ident);
u64 key = hash_pointer(identifier);
HashKey key = hash_pointer(identifier);
map_set(&i->uses, key, entity);
}
@@ -648,7 +648,7 @@ void check_parsed_files(Checker *c) {
case_end;
case_ast_node(id, ImportDecl, decl);
case_ast_node(ld, LoadDecl, decl);
// NOTE(bill): ignore
case_end;
@@ -662,7 +662,7 @@ void check_parsed_files(Checker *c) {
gb_for_array(i, c->info.entities.entries) {
auto *entry = &c->info.entities.entries[i];
Entity *e = cast(Entity *)cast(uintptr)entry->key;
Entity *e = cast(Entity *)cast(uintptr)entry->key.key;
DeclInfo *d = entry->value;
check_entity_decl(c, e, d, NULL);
}
@@ -679,8 +679,8 @@ void check_parsed_files(Checker *c) {
// Add untyped expression values
gb_for_array(i, c->info.untyped.entries) {
auto *entry = c->info.untyped.entries + i;
u64 key = entry->key;
AstNode *expr = cast(AstNode *)cast(uintptr)key;
HashKey key = entry->key;
AstNode *expr = cast(AstNode *)cast(uintptr)key.key;
ExpressionInfo *info = &entry->value;
if (info != NULL && expr != NULL) {
if (is_type_typed(info->type)) {
+6 -4
View File
@@ -41,7 +41,7 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node) {
Token name_token = i->token;
// TODO(bill): is the curr_scope correct?
Entity *e = make_entity_field(c->allocator, c->context.scope, name_token, type);
u64 key = hash_string(name_token.string);
HashKey key = hash_string(name_token.string);
if (map_get(&entity_map, key)) {
// TODO(bill): Scope checking already checks the declaration
error(&c->error_collector, name_token, "`%.*s` is already declared in this structure", LIT(name_token.string));
@@ -615,8 +615,10 @@ b32 check_is_expr_vector_index(Checker *c, AstNode *expr) {
expr = unparen_expr(expr);
if (expr->kind == AstNode_IndexExpr) {
ast_node(ie, IndexExpr, expr);
Type *t = get_base_type(type_of_expr(&c->info, ie->expr));
return is_type_vector(t);
Type *t = type_of_expr(&c->info, ie->expr);
if (t != NULL) {
return is_type_vector(get_base_type(t));
}
}
return false;
}
@@ -1057,7 +1059,7 @@ void check_binary_expr(Checker *c, Operand *x, AstNode *node) {
void update_expr_type(Checker *c, AstNode *e, Type *type, b32 final) {
u64 key = hash_pointer(e);
HashKey key = hash_pointer(e);
ExpressionInfo *found = map_get(&c->info.untyped, key);
if (found == NULL)
return;