move to meson for build system
This commit is contained in:
parent
fdd1ee61b5
commit
9616fb616e
28 changed files with 123 additions and 24 deletions
29
src/chunk.c
Normal file
29
src/chunk.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "chunk.h"
|
||||
#include "vendor/yar.h"
|
||||
|
||||
V chunk_emit_byte(Bc *chunk, U8 byte) { *yar_append(chunk) = byte; }
|
||||
|
||||
V chunk_emit_sleb128(Bc *chunk, I num) {
|
||||
I more = 1;
|
||||
while (more) {
|
||||
U8 byte = num & 0x7f;
|
||||
num >>= 7;
|
||||
if ((num == 0 && !(byte & 0x40)) || (num == -1 && (byte & 0x40))) {
|
||||
more = 0;
|
||||
} else {
|
||||
byte |= 0x80;
|
||||
}
|
||||
chunk_emit_byte(chunk, byte);
|
||||
}
|
||||
}
|
||||
|
||||
I chunk_add_constant(Bc *chunk, O value) {
|
||||
I mark = chunk->constants.count;
|
||||
*yar_append(&chunk->constants) = value;
|
||||
return mark;
|
||||
}
|
||||
|
||||
V chunk_free(Bc *chunk) {
|
||||
yar_free(&chunk->constants);
|
||||
yar_free(chunk);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue