Hash :
f0401f0c
Author :
Thomas de Grivel
Date :
2024-03-04T14:19:12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
/* c3
* Copyright 2022-2024 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
/**
* @file tag.h
* @brief Run-time type annotations.
*
* Structure to add a type tag to data.
*/
#ifndef LIBC3_TAG_H
#define LIBC3_TAG_H
#include <stdarg.h>
#include "tag_init.h"
#include "tag_type.h"
#define TAG_FIRST (&g_tag_first)
#define TAG_LAST (&g_tag_last)
extern s_tag g_tag_first;
extern s_tag g_tag_last;
/* Stack-allocation compatible functions, call tag_clean after use. */
void tag_clean (s_tag *tag);
s_tag * tag_init (s_tag *tag);
s_tag * tag_init_1 (s_tag *tag, const char *p);
s_tag * tag_init_call_cast (s_tag *tag, const s_sym *type);
/* Heap-allocation functions, call tag_delete after use. */
void tag_delete (s_tag *tag);
s_tag * tag_new (void);
s_tag * tag_new_1 (const char *p);
/* Observers */
u64 tag_hash_u64 (const s_tag *tag);
uw tag_hash_uw (const s_tag *tag);
s_str * tag_inspect (const s_tag *tag, s_str *dest);
bool tag_ident_is_bound (const s_tag *tag);
bool tag_is_bound_var (const s_tag *tag);
bool tag_is_number (const s_tag *tag);
bool tag_is_unbound_var (const s_tag *tag);
bool tag_is_zero(const s_tag *tag);
s8 tag_number_compare (const s_tag *a, const s_tag *b);
uw * tag_size (const s_tag *tag, uw *dest);
ffi_type tag_to_ffi_type(const s_tag *tag);
const s_sym ** tag_type (const s_tag *tag, const s_sym **type);
/* Operators. */
s_tag * tag_1 (s_tag *tag, const char *p);
s_tag * tag_integer_cast_to_s16 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_s32 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_s64 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_s8 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_u16 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_u32 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_u64 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_cast_to_u8 (const s_tag *tag, s_tag *dest);
s_tag * tag_integer_reduce (s_tag *tag);
s_tag * tag_list_1 (s_tag *tag, const char *p);
bool tag_to_const_pointer (const s_tag *tag, const s_sym *type,
const void **dest);
bool tag_to_ffi_pointer (s_tag *tag, const s_sym *type, void **dest);
bool tag_to_pointer (s_tag *tag, const s_sym *type, void **dest);
/* C3 operators. */
s_tag * tag_add (const s_tag *a, const s_tag *b, s_tag *dest);
bool * tag_and (const s_tag *a, const s_tag *b, bool *dest);
s_tag * tag_band (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_bnot (const s_tag *tag, s_tag *dest);
s_tag * tag_bor (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_brackets (const s_tag *tag, const s_tag *address,
s_tag *dest);
s_tag * tag_bxor (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_div (const s_tag *a, const s_tag *b, s_tag *dest);
bool * tag_lt (const s_tag *a, const s_tag *b, bool *dest);
bool * tag_lte (const s_tag *a, const s_tag *b, bool *dest);
bool * tag_gt (const s_tag *a, const s_tag *b, bool *dest);
bool * tag_gte (const s_tag *a, const s_tag *b, bool *dest);
bool * tag_eq (const s_tag *a, const s_tag *b, bool *dest);
s_tag * tag_equal (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_mod (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_mul (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_neg (const s_tag *tag, s_tag *dest);
bool * tag_not (const s_tag *tag, bool *dest);
bool * tag_not_eq (const s_tag *a, const s_tag *b, bool *dest);
bool * tag_or (const s_tag *a, const s_tag *b, bool *dest);
s_tag * tag_paren (const s_tag *tag, s_tag *dest);
s_tag * tag_shift_left (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_shift_right (const s_tag *a, const s_tag *b, s_tag *dest);
s_tag * tag_sqrt (const s_tag *tag, s_tag *dest);
s_tag * tag_sub (const s_tag *a, const s_tag *b, s_tag *dest);
#endif /* LIBC3_TAG_H */