harec

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

type_store.h (2305B)


      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 location loc, 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 	struct location loc, const struct type *referent, unsigned int ptrflags);
     41 
     42 const struct type *type_store_lookup_array(struct type_store *store,
     43 	struct location loc, const struct type *members, size_t len,
     44 	bool expandable);
     45 
     46 const struct type *type_store_lookup_slice(struct type_store *store,
     47 	struct location loc, const struct type *members);
     48 
     49 // Looks up a type alias, which may be incomplete. If the dimensions of the
     50 // type are known, provide them as a hint in the dims argument (which can be
     51 // NULL otherwise). This is used as a hint to skip adding padding to packed
     52 // struct types.
     53 const struct type *type_store_lookup_alias(struct type_store *store,
     54 	const struct type *secondary, const struct dimensions *dims);
     55 
     56 const struct type *type_store_lookup_tagged(struct type_store *store,
     57 	struct location loc, struct type_tagged_union *tags);
     58 
     59 // Returns a (non-tagged) union of the members of a tagged union type
     60 const struct type *type_store_tagged_to_union(
     61 	struct type_store *store, const struct type *tagged);
     62 
     63 const struct type *type_store_lookup_tuple(struct type_store *store,
     64 	 struct location loc, struct type_tuple *values);
     65 
     66 const struct type *type_store_lookup_enum(struct type_store *store,
     67 	const struct ast_type *atype, bool exported);
     68 
     69 #endif