@@ -2,7 +2,6 @@ | |||
#define L2_BITSET_H | |||
#include <stdlib.h> | |||
#include <stdint.h> | |||
typedef long long int l2_bitset_entry; | |||
@@ -0,0 +1,8 @@ | |||
#ifndef L2_GEN_H | |||
#define L2_GEN_H | |||
#include "../io.h" | |||
void l2_gen_stack_frame(struct l2_bufio_writer *writer); | |||
#endif |
@@ -37,7 +37,7 @@ struct l2_bufio_writer { | |||
void l2_bufio_writer_init(struct l2_bufio_writer *b, struct l2_io_writer *w); | |||
void l2_bufio_flush(struct l2_bufio_writer *b); | |||
static inline void l2_bufio_put(struct l2_bufio_writer *b, char ch); | |||
static inline void l2_bufio_put_n(struct l2_bufio_writer *b, const char *ptr, size_t len); | |||
static inline void l2_bufio_put_n(struct l2_bufio_writer *b, const void *ptr, size_t len); | |||
/* | |||
* Useful readers and writers | |||
@@ -98,7 +98,7 @@ static inline void l2_bufio_put(struct l2_bufio_writer *b, char ch) { | |||
b->buf[b->idx++] = ch; | |||
} | |||
static inline void l2_bufio_put_n(struct l2_bufio_writer *b, const char *ptr, size_t len) { | |||
static inline void l2_bufio_put_n(struct l2_bufio_writer *b, const void *ptr, size_t len) { | |||
size_t freespace = sizeof(b->buf) - b->idx; | |||
if (len < freespace) { | |||
memcpy(b->buf + b->idx, ptr, len); |
@@ -1,7 +1,7 @@ | |||
#ifndef L2_PARSE_LEX_H | |||
#define L2_PARSE_LEX_H | |||
#include "io.h" | |||
#include "../io.h" | |||
enum l2_token_kind { | |||
L2_TOK_OPEN_PAREN, |
@@ -2,7 +2,13 @@ | |||
#define L2_PARSE_H | |||
#include "lex.h" | |||
#include "../io.h" | |||
void l2_parse(); | |||
struct l2_parse_state { | |||
struct l2_lexer *lexer; | |||
struct l2_bufio_writer writer; | |||
}; | |||
void l2_parse_program(struct l2_parse_state *state); | |||
#endif |
@@ -3,8 +3,8 @@ | |||
#include <stdlib.h> | |||
#include "bytecode.h" | |||
#include "bitset.h" | |||
#include "../bytecode.h" | |||
#include "../bitset.h" | |||
struct l2_vm_value { | |||
enum l2_value_flags { |
@@ -0,0 +1,11 @@ | |||
#include "gen/gen.h" | |||
#include "bytecode.h" | |||
static void put(struct l2_bufio_writer *writer, l2_word word) { | |||
l2_bufio_put_n(writer, &word, sizeof(word)); | |||
} | |||
void l2_gen_stack_frame(struct l2_bufio_writer *writer) { | |||
put(writer, L2_OP_ALLOC_NAMESPACE); | |||
} |
@@ -0,0 +1,7 @@ | |||
#include "parse/parse.h" | |||
#include "gen/gen.h" | |||
void l2_parse_program(struct l2_parse_state *state) { | |||
l2_gen_stack_frame(&state->writer); | |||
} |