LCOV - code coverage report
Current view: top level - src/compiler/hash_tables - value_set.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 11 90.9 %
Date: 2016-11-30 13:12:14 Functions: 4 12 33.3 %
Branches: 8 24 33.3 %

           Branch data     Line data    Source code
       1                 :            :  /* Note: only one hash table can be implemented a single file. */
       2                 :            : #include "../symbols.h"
       3                 :            : #include "hash/ht_hash_function.h"
       4                 :            : 
       5                 :        350 : static size_t value_hash_function(const void *key, size_t key_len)
       6                 :            : {
       7                 :            :     const fb_value_t *value = key;
       8                 :            : 
       9                 :            :     (void)key_len;
      10                 :            : 
      11   [ +  +  +  - ]:        175 :     switch (value->type) {
      12                 :            :     case vt_int:
      13                 :        109 :         return ht_int_hash_function((void *)(size_t)(value->i ^ value->type), sizeof(value->i));
      14                 :            :     case vt_uint:
      15                 :         64 :         return ht_int_hash_function((void *)(size_t)(value->u ^ value->type), sizeof(value->u));
      16                 :            :     case vt_bool:
      17                 :          2 :         return ht_int_hash_function((void *)(size_t)(value->b ^ value->type), sizeof(value->b));
      18                 :            :     default:
      19                 :            :         return 0;
      20                 :            :     }
      21                 :            : }
      22                 :            : 
      23                 :            : #define HT_HASH_FUNCTION value_hash_function
      24                 :            : 
      25                 :            : #include "hash/hash_table_def.h"
      26         [ #  # ]:        590 : DEFINE_HASH_TABLE(fb_value_set)
      27                 :            : #include "hash/hash_table_impl.h"
      28                 :            : 
      29                 :            : static inline int ht_match(const void *key, size_t len, fb_value_t *item)
      30                 :            : {
      31                 :            :     const fb_value_t *value = key;
      32                 :            : 
      33                 :            :     (void)len;
      34                 :            : 
      35 [ +  - ][ #  # ]:         14 :     if (value->type != item->type) {
                 [ +  - ]
      36                 :            :         return 0;
      37                 :            :     }
      38   [ +  +  -  - ]:         14 :     switch (value->type) {
           [ #  #  #  # ]
           [ +  -  -  - ]
      39                 :            :     case vt_int:
      40                 :         10 :         return value->i == item->i;
      41                 :            :     case vt_uint:
      42                 :          4 :         return value->u == item->u;
      43                 :            :     case vt_bool:
      44                 :          0 :         return value->b == item->b;
      45                 :            :     default:
      46                 :            :         return 0;
      47                 :            :     }
      48                 :            : }
      49                 :            : 
      50                 :            : static inline const void *ht_key(fb_value_t *value)
      51                 :            : {
      52                 :            :     return value;
      53                 :            : }
      54                 :            : 
      55                 :            : static inline size_t ht_key_len(fb_value_t *value)
      56                 :            : {
      57                 :            :     (void)value;
      58                 :            : 
      59                 :            :     return 0;
      60                 :            : }

Generated by: LCOV version 1.12