diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-11 15:34:05 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-11 15:34:05 -0500 |
commit | 3fcd2b27dd2de683abb4b20c7617352d7c3ea229 (patch) | |
tree | 6880b227a4914110d7bb4293fb1b3c324c0582b7 /types.h | |
parent | 30f1ae4c7e0c07a722f1fa4d770409246ed9788c (diff) |
started #cache, but not fully working yet
Diffstat (limited to 'types.h')
-rw-r--r-- | types.h | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -131,6 +131,7 @@ typedef struct BlockArr { ArrBlock *blocks; } BlockArr; +/* initialize to 0 */ typedef struct HashTable { void *data; bool *occupied; @@ -229,6 +230,7 @@ typedef enum { DIRECT_FOREIGN, DIRECT_BUILTIN, DIRECT_INCLUDE, + DIRECT_CACHE, DIRECT_COUNT } Directive; @@ -594,7 +596,8 @@ typedef struct ForExpr { enum { FN_EXPR_FOREIGN = 0x01, - FN_EXPR_EXPORT = 0x02 /* set by sdecls_cgen.c */ + FN_EXPR_EXPORT = 0x02, /* set by sdecls_cgen.c */ + FN_EXPR_CACHE = 0x04 }; typedef struct FnExpr { @@ -614,6 +617,7 @@ typedef struct FnExpr { the first element is a u64 value whose ith bit (1<<i) is 1 if the ith semi-constant parameter is constant. */ + HashTable *cache; /* only set for FN_EXPR_CACHE */ struct { /* if name = NULL, this is an anonymous function, and id will be the ID of the fn. */ Identifier name; @@ -624,10 +628,15 @@ typedef struct FnExpr { typedef struct Instance { Value val; /* key into hash table */ - FnExpr *fn; /* the typed function */ - struct { - U64 id; - } c; + union { + struct { + FnExpr *fn; /* the typed function */ + struct { + U64 id; + } c; + }; + Value *ret_val; /* return value (for #cached functions). pointer must stay fixed, so this is a Value * */ + }; } Instance; typedef struct CastExpr { |