harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

type_store.h (1921B)


      1 #ifndef HARE_TYPESTORE_H
      2 #define HARE_TYPESTORE_H
      3 #include "ast.h"
      4 #include "lex.h"
      5 #include "types.h"
      6 
      7 #define TYPE_STORE_BUCKETS 65536
      8 
      9 struct type_bucket {
     10 	struct type type;
     11 	struct type_bucket *next;
     12 };
     13 
     14 struct context;
     15 
     16 struct type_store {
     17 	struct type_bucket *buckets[TYPE_STORE_BUCKETS];
     18 	struct context *check_context;
     19 };
     20 
     21 // Applies the type reduction algorithm to the given tagged union.
     22 const struct type *type_store_reduce_result(struct type_store *store,
     23 		struct type_tagged_union *in);
     24 
     25 struct ast_type;
     26 
     27 const struct type *type_store_lookup_atype(
     28 	struct type_store *store, const struct ast_type *atype);
     29 
     30 struct dimensions type_store_lookup_dimensions(
     31 	struct type_store *store, const struct ast_type *atype);
     32 
     33 const struct type *builtin_type_for_storage(
     34 	enum type_storage storage, bool is_const);
     35 
     36 const struct type *type_store_lookup_with_flags(struct type_store *store,
     37 	const struct type *type, unsigned int flags);
     38 
     39 const struct type *type_store_lookup_pointer(struct type_store *store,
     40 	const struct type *referent, unsigned int ptrflags);
     41 
     42 const struct type *type_store_lookup_array(struct type_store *store,
     43 	const struct type *members, size_t len, bool expandable);
     44 
     45 const struct type *type_store_lookup_slice(struct type_store *store,
     46 	const struct type *members);
     47 
     48 const struct type *type_store_lookup_alias(struct type_store *store,
     49 	const struct type *secondary);
     50 
     51 const struct type *type_store_lookup_tagged(struct type_store *store,
     52 	struct type_tagged_union *tags);
     53 
     54 // Returns a (non-tagged) union of the members of a tagged union type
     55 const struct type *type_store_tagged_to_union(
     56 	struct type_store *store, const struct type *tagged);
     57 
     58 const struct type *type_store_lookup_tuple(struct type_store *store,
     59 	struct type_tuple *values, struct location loc);
     60 
     61 const struct type *type_store_lookup_enum(struct type_store *store,
     62 	const struct ast_type *atype, bool exported);
     63 
     64 #endif