-
Notifications
You must be signed in to change notification settings - Fork 0
TIL Compiler API
A stack data type that works with bytes. It is used inside the compiler to store bytecode.
struct _til_bytes;
typedef struct _til_bytes* til_bytes_t;
Alloc and initialize a til_bytes_t instance.
til_bytes_t til_bytes_create();
Append a byte to a til_bytes_t instance.
void til_bytes_add
(til_bytes_t bytes, unsigned char b);
Append a bytes array to a til_bytes_t instance.
void til_bytes_add_str
(til_bytes_t bytes, unsigned char* a, size_t l);
Serialize and append a signed 16 bit integer to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_short
(til_bytes_t bytes, int16_t n);
Serialize and append an unsigned 16 bit integer to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_ushort
(til_bytes_t bytes, uint16_t n);
Serialize and append a signed 32 bit integer to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_int
(til_bytes_t bytes, int32_t n);
Serialize and append an unsigned 32 bit integer to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_uint
(til_bytes_t bytes, uint32_t n);
Serialize and append a signed 64 bit integer to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_long
(til_bytes_t bytes, int64_t n);
Serialize and append an unsigned 64 bit integer to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_ulong
(til_bytes_t bytes, uint64_t n);
Serialize and append a 32 bit floating point number to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_float32
(til_bytes_t bytes, float n);
Serialize and append a 64 bit floating point number to a til_bytes_t instance. Little-endian format is used for serialization.
void til_bytes_add_float64
(til_bytes_t bytes, double n);
Concatenate a til_bytes_t instance to another.
void til_bytes_cat
(til_bytes_t bytes, til_bytes_t b);
Write a til_bytes_t instance to a file
void til_bytes_print
(til_bytes_t bytes, FILE* file);
Copy the internal buffer of a til_bytes_t instance and return it.
unsigned char* til_bytes_get_buffer
(til_bytes_t bytes);
Return the number of bytes stored in a til_bytes_t instance.
size_t til_bytes_get_buffer_size
(til_bytes_t bytes);
Compile a type id string to bytecode, return 0 on success.
int til_serialize_type
(char *type, til_bytes_t bytes);
The core function of the library. Compile a TIL source string to bytecode.
On failure return NULL and set the content of err_ptr to the generated error. In this case *err_ptr must be freed.
til_bytes_t til_compile
(char *source, char** err_ptr);
Compile only the assembly code inside functions.
On failure return NULL and write the error in the err stack.
til_bytes_t til_assembler
(char* assembly, int initial_line, til_bytes_t err);