1. (list ...) 2. string-* functions 3. (native str) to resolve native functions at runtime 4. Memory fuckups in compiler core unit loading 5. Now can call non-identifiers in compiler
67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
#pragma once
|
|
#include "hash.h"
|
|
#include "vector.h"
|
|
|
|
#define NAME_GLOBAL 1
|
|
#define NAME_LOCAL 2
|
|
#define NAME_EXTERNAL 3
|
|
#define NAME_ARGUMENT 4
|
|
|
|
struct unit;
|
|
|
|
struct context {
|
|
struct unit *root;
|
|
struct context *parent;
|
|
struct function *owner;
|
|
size_t var_counter;
|
|
struct hash vars;
|
|
};
|
|
|
|
struct ext_ref {
|
|
size_t unit_index;
|
|
size_t entry_index;
|
|
char name[64];
|
|
};
|
|
|
|
struct ext_unit_entry {
|
|
char name[64];
|
|
};
|
|
|
|
struct ext_unit {
|
|
struct vector exports;
|
|
char name[64];
|
|
};
|
|
|
|
struct function {
|
|
size_t index;
|
|
size_t local_count;
|
|
size_t argc;
|
|
struct node *args, *body;
|
|
struct vector bytecode;
|
|
};
|
|
|
|
struct export {
|
|
size_t index;
|
|
char name[64];
|
|
};
|
|
|
|
struct unit {
|
|
struct context global;
|
|
|
|
struct vector strtab;
|
|
struct vector functions;
|
|
struct vector exports;
|
|
struct vector ext_refs;
|
|
struct vector ext_units;
|
|
};
|
|
|
|
void unit_init(struct unit *u);
|
|
void ctx_init(struct context *c, struct context *p);
|
|
struct function *unit_lambda(struct unit *u);
|
|
int unit_ext_load(struct unit *self, const char *unit);
|
|
int ctx_lookup_name(struct context *ctx, const char *name, int *kind, size_t *index);
|
|
int unit_lookup_global(struct unit *unit, const char *name, size_t *index);
|
|
int unit_insert_string(struct unit *unit, const char *text, size_t *index);
|
|
|
|
void emit_insn(struct function *fn, uint32_t insn);
|