new interpreter file, basic interprater state implementaion

This commit is contained in:
ProgramSnail 2024-10-11 17:07:04 +03:00
parent e07987fd2a
commit 0cdfa3911d
7 changed files with 499 additions and 20 deletions

28
byterun/include/parser.h Normal file
View file

@ -0,0 +1,28 @@
#pragma once
#include <stdio.h>
/* The unpacked representation of bytecode file */
typedef struct {
char *string_ptr; /* A pointer to the beginning of the string table */
int *public_ptr; /* A pointer to the beginning of publics table */
char *code_ptr; /* A pointer to the bytecode itself */
int *global_ptr; /* A pointer to the global area */
int stringtab_size; /* The size (in bytes) of the string table */
int global_area_size; /* The size (in words) of global area */
int public_symbols_number; /* The number of public symbols */
char buffer[0];
} bytefile;
/* Gets a string from a string table by an index */
char *get_string(bytefile *f, int pos);
/* Gets a name for a public symbol */
char *get_public_name(bytefile *f, int i);
/* Gets an offset for a publie symbol */
int get_public_offset(bytefile *f, int i);
bytefile *read_file(char *fname);
void dump_file(FILE *f, bytefile *bf);