24#include "llvm-c/Core.h"
25#include "llvm-c/Types.h"
130#define SIZE_OF_VALUE_PALYLOAD 8
143#define TYPE(value_ref) ((value_ref)->type)
144#define METADATA(value_ref) ((value_ref)->metadata)
145#define IS_A(value_ref, field) (TYPE(value_ref) == (field))
146#define IS_TRUE(value_ref) (TYPE(value_ref) == VTrue)
147#define IS_FALSE(value_ref) (TYPE(value_ref) == VFalse)
148#define IS_NIL(value_ref) (TYPE(value_ref) == VNil)
150#define AS_I64(value_ref) ((value_ref)->as.i64)
151#define AS_F64(value_ref) ((value_ref)->as.f64)
152#define AS_CLOSURE(value_ref) ((value_ref)->as.closure)
153#define AS_NS(value_ref) ((value_ref)->as.ns)
154#define AS_STRING(value_ref) ((value_ref)->as.string)
155#define AS_SYMBOL(value_ref) ((value_ref)->as.symbol)
156#define AS_ERROR(value_ref) ((value_ref)->as.error)
157#define AS_LIST(value_ref) ((value_ref)->as.list)
158#define AS_KEYWORD(value_ref) ((value_ref)->as.keyword)
159#define AS_SEQ(value_ref) ((value_ref)->as.seq)
160#define AS_MAP(value_ref) ((value_ref)->as.map)
164[[nodiscard]] [[gnu::nonnull(1)]] [[gnu::returns_nonnull]]
170 LLVMTypeRef i64t = LLVMInt64TypeInContext(llctx);
173 LLVMTypeRef i8t = LLVMInt8TypeInContext(llctx);
174 LLVMTypeRef ptrt = LLVMPointerType(i8t, 0);
176 LLVMTypeRef fields[3];
181 LLVMTypeRef st = LLVMStructCreateNamed(llctx,
"srn_value_t");
182 LLVMStructSetBody(st, fields, 3, 0);
srn_metadata_t absurd_metadata
We use this for testing. Defined once in core.c.
static LLVMTypeRef srn_llvm_value_t(LLVMContextRef llctx)
LLVM type for srn_value_t in LLVM IR. { i64, ptr, i64 }.
@ IR_TYPE_Error
IR_TYPE_Error should be last.
struct srn_string_t srn_string_t
srn_value_t * srn_value_make(srn_context_t *ctx, srn_value_tag_t tag, srn_metadata_t *metadata, void *payload)
Creates a new serene value.
struct srn_keyword_t srn_keyword_t
struct srn_namespace_t srn_namespace_t
@ VError
VError should be last.
struct srn_map_t srn_map_t
#define SIZE_OF_VALUE_PALYLOAD
struct srn_fiber_mutex_t srn_fiber_mutex_t
struct srn_error_t srn_error_t
struct srn_symbol_t srn_symbol_t
struct srn_expr_t srn_expr_t
struct srn_seq_t srn_seq_t
struct srn_list_t srn_list_t
enum srn_value_tag_e srn_value_tag_t
This is an implementation of bit - partitioned, persistent, immutable sequence For more information,...
A runtime error, a tag classifying the failure and a human-readable message.
srn_fiber_mutex_t * ns_map_lock
hmap_t * namespaces
A hashmap that maps namespace names to their value.
A persistent, immutable map.
A persistent, immutable, indexed sequence.
uint16_t buffer_id
ID of the source buffer that is registered with the source manager.
uint32_t len
Length of the form in bytes.
uint32_t offset
Byte offset of the form's first byte in the buffer.
srn_node_type_t type
This type field is a bare number value that we split into a few ranges.
srn_fiber_mutex_t * lock
Since multiple fibers can work on the same node at the same time, writers have to acquire the lock.
srn_metadata_t * metadata
void * data
An opaque pointer that depending on the type might point to totally different type of data.
srn_metadata_t * metadata
int64_t i64
We represent all the immidiate numbers with this field and cast as we to an appropriate type.
union srn_value_t::@333325137367112222275110336355257173264057161216 as
IMPORTANT NOTE: The size of this union should never be larger than a word.