aboutsummaryrefslogtreecommitdiff
path: root/src/checker/entity.cpp
diff options
context:
space:
mode:
authorgingerBill <ginger.bill.22@gmail.com>2016-07-12 23:53:34 +0100
committergingerBill <ginger.bill.22@gmail.com>2016-07-12 23:53:34 +0100
commitaa6a2caecb759522914ba82cc506e60270ad1ab0 (patch)
tree68a5cf5479606bc1b10deb4cf63af01e7e513136 /src/checker/entity.cpp
parent9f90ff50cf4f93e6c6bb622bc2098dc7cea7f240 (diff)
Random Order File Scope Declaration
Diffstat (limited to 'src/checker/entity.cpp')
-rw-r--r--src/checker/entity.cpp52
1 files changed, 43 insertions, 9 deletions
diff --git a/src/checker/entity.cpp b/src/checker/entity.cpp
index e93a11822..d90d08cfd 100644
--- a/src/checker/entity.cpp
+++ b/src/checker/entity.cpp
@@ -23,6 +23,7 @@ struct Entity {
Scope *parent;
Token token;
Type *type;
+ isize order;
union {
struct { Value value; } constant;
@@ -53,14 +54,47 @@ Entity *alloc_entity(gbAllocator a, EntityKind kind, Scope *parent, Token token,
return entity;
}
+Entity *make_entity_variable(gbAllocator a, Scope *parent, Token token, Type *type) {
+ Entity *entity = alloc_entity(a, Entity_Variable, parent, token, type);
+ return entity;
+}
+
+Entity *make_entity_constant(gbAllocator a, Scope *parent, Token token, Type *type, Value value) {
+ Entity *entity = alloc_entity(a, Entity_Constant, parent, token, type);
+ entity->constant.value = value;
+ return entity;
+}
+
+Entity *make_entity_type_name(gbAllocator a, Scope *parent, Token token, Type *type) {
+ Entity *entity = alloc_entity(a, Entity_TypeName, parent, token, type);
+ return entity;
+}
+
+Entity *make_entity_param(gbAllocator a, Scope *parent, Token token, Type *type) {
+ Entity *entity = alloc_entity(a, Entity_Variable, parent, token, type);
+ entity->variable.used = true;
+ return entity;
+}
+Entity *make_entity_field(gbAllocator a, Scope *parent, Token token, Type *type) {
+ Entity *entity = alloc_entity(a, Entity_Variable, parent, token, type);
+ entity->variable.is_field = true;
+ return entity;
+}
+
+Entity *make_entity_procedure(gbAllocator a, Scope *parent, Token token, Type *signature_type) {
+ Entity *entity = alloc_entity(a, Entity_Procedure, parent, token, signature_type);
+ return entity;
+}
+
+Entity *make_entity_builtin(gbAllocator a, Scope *parent, Token token, Type *type, BuiltinProcedureId id) {
+ Entity *entity = alloc_entity(a, Entity_Builtin, parent, token, type);
+ entity->builtin.id = id;
+ return entity;
+}
+
+Entity *make_entity_dummy_variable(gbAllocator a, Scope *file_scope, Token token) {
+ token.string = make_string("_");
+ return make_entity_variable(a, file_scope, token, NULL);
+}
-// NOTE(bill): Defined in "checker.cpp"
-Entity *make_entity_variable (Checker *c, Scope *parent, Token token, Type *type);
-Entity *make_entity_constant (Checker *c, Scope *parent, Token token, Type *type, Value value);
-Entity *make_entity_type_name(Checker *c, Scope *parent, Token token, Type *type);
-Entity *make_entity_param (Checker *c, Scope *parent, Token token, Type *type);
-Entity *make_entity_field (Checker *c, Scope *parent, Token token, Type *type);
-Entity *make_entity_procedure(Checker *c, Scope *parent, Token token, Type *signature_type);
-Entity *make_entity_builtin (Checker *c, Scope *parent, Token token, Type *type, i32 id);
-Entity *make_entity_dummy_variable(Checker *c, Token token);