diff options
Diffstat (limited to 'types.h')
-rw-r--r-- | types.h | 57 |
1 files changed, 34 insertions, 23 deletions
@@ -448,18 +448,41 @@ typedef struct Field { size_t offset; /* offset during compile time */ } Field; + +enum { + BLOCK_IS_FN = 0x01, + BLOCK_IS_NMS = 0x02, + BLOCK_FINDING_TYPES = 0x04, + BLOCK_FOUND_TYPES = 0x08 +}; +typedef U8 BlockFlags; +typedef struct Block { + BlockFlags flags; + Location where; + Identifiers idents; + struct Statement *stmts; + struct Expression *ret_expr; /* the return expression of this block, e.g. {foo(); 3} => 3 NULL for no expression. */ +} Block; + enum { STRUCT_DEF_FOUND_OFFSETS = 0x01, STRUCT_DEF_CGEN_DECLARED = 0x02, - STRUCT_DEF_CGEN_DEFINED = 0x04 + STRUCT_DEF_CGEN_DEFINED = 0x04, + STRUCT_DEF_RESOLVED = 0x08 }; - typedef struct StructDef { Field *fields; Location where; U8 flags; - size_t size; /* size of this struct during compile time */ - size_t align; + Block scope; /* to make sure that parameters live somewhere. fields are not kept here. */ + union { + HashTable instances; + struct { + size_t size; /* size of this struct during compile time */ + size_t align; + U64 instance_id; /* ID of instance */ + }; + }; Identifier name; struct Declaration *params; struct { @@ -469,21 +492,6 @@ typedef struct StructDef { } StructDef; -enum { - BLOCK_IS_FN = 0x01, - BLOCK_IS_NMS = 0x02, - BLOCK_FINDING_TYPES = 0x04, - BLOCK_FOUND_TYPES = 0x08 -}; -typedef U8 BlockFlags; -typedef struct Block { - BlockFlags flags; - Location where; - Identifiers idents; - struct Statement *stmts; - struct Expression *ret_expr; /* the return expression of this block, e.g. {foo(); 3} => 3 NULL for no expression. */ -} Block; - typedef enum { EXPR_LITERAL_FLOAT, EXPR_LITERAL_INT, @@ -628,11 +636,14 @@ typedef struct FnExpr { typedef struct Instance { Value val; /* key into hash table */ - struct { - FnExpr *fn; /* the typed function */ + union { struct { - U64 id; - } c; + FnExpr *fn; /* the typed function */ + struct { + U64 id; + } c; + }; + StructDef struc; }; } Instance; |