Browse Source

more stuff

master
Martin Dørum 3 years ago
parent
commit
4c5f575e85

+ 0
- 1
include/lang2/bitset.h View File

@@ -2,7 +2,6 @@
#define L2_BITSET_H

#include <stdlib.h>
#include <stdint.h>

typedef long long int l2_bitset_entry;


+ 8
- 0
include/lang2/gen/gen.h View File

@@ -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

+ 2
- 2
include/lang2/io.h View File

@@ -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
- 1
include/lang2/parse/lex.h View File

@@ -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,

+ 7
- 1
include/lang2/parse/parse.h View File

@@ -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

+ 2
- 2
include/lang2/vm/vm.h View File

@@ -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 {

+ 11
- 0
src/gen/gen.c View File

@@ -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);
}

+ 7
- 0
src/parse/parse.c View File

@@ -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);
}

Loading…
Cancel
Save