diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-06-15 12:14:56 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-06-15 12:14:56 +0100 |
| commit | 23f9f9064e99e559f57b35a5f84a9525f8023bd9 (patch) | |
| tree | 6884a9ed6133485f38d78d0d3c3c359e6a5118cc /src/checker.cpp | |
| parent | a134307dcde9aac03323c15f8dfc5642f438fe56 (diff) | |
Add CheckerInfo API functions
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 1647ceaee..82e68e483 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -757,7 +757,6 @@ void destroy_checker(Checker *c) { } - Entity *entity_of_ident(CheckerInfo *i, AstNode *identifier) { if (identifier->kind == AstNode_Ident) { Entity **found = map_get(&i->definitions, hash_pointer(identifier)); @@ -772,7 +771,6 @@ Entity *entity_of_ident(CheckerInfo *i, AstNode *identifier) { return NULL; } - TypeAndValue type_and_value_of_expr(CheckerInfo *i, AstNode *expression) { TypeAndValue result = {}; TypeAndValue *found = map_get(&i->types, hash_pointer(expression)); @@ -780,7 +778,6 @@ TypeAndValue type_and_value_of_expr(CheckerInfo *i, AstNode *expression) { return result; } - Type *type_of_expr(CheckerInfo *i, AstNode *expr) { TypeAndValue tav = type_and_value_of_expr(i, expr); if (tav.mode != Addressing_Invalid) { @@ -796,6 +793,41 @@ Type *type_of_expr(CheckerInfo *i, AstNode *expr) { return NULL; } +Entity *implicit_entity_of_node(CheckerInfo *i, AstNode *clause) { + Entity **found = map_get(&i->implicits, hash_pointer(clause)); + if (found != NULL) { + return *found; + } + return NULL; +} + +DeclInfo *decl_info_of_entity(CheckerInfo *i, Entity *e) { + if (e != NULL) { + DeclInfo **found = map_get(&i->entities, hash_pointer(e)); + if (found != NULL) { + return *found; + } + } + return NULL; +} + +DeclInfo *decl_info_of_ident(CheckerInfo *i, AstNode *ident) { + return decl_info_of_entity(i, entity_of_ident(i, ident)); +} + +AstFile *ast_file_of_filename(CheckerInfo *i, String filename) { + AstFile **found = map_get(&i->files, hash_string(filename)); + if (found != NULL) { + return *found; + } + return NULL; +} + + + + + + void add_untyped(CheckerInfo *i, AstNode *expression, bool lhs, AddressingMode mode, Type *basic_type, ExactValue value) { map_set(&i->untyped, hash_pointer(expression), make_expr_info(lhs, mode, basic_type, value)); @@ -906,6 +938,9 @@ void add_implicit_entity(Checker *c, AstNode *node, Entity *e) { } + + + void add_type_info_type(Checker *c, Type *t) { if (t == NULL) { return; |