2024-10-31 21:08:48 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2024-11-04 01:43:43 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "../../runtime/runtime_common.h"
|
2024-10-31 21:08:48 +03:00
|
|
|
|
|
|
|
|
/* 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 */
|
2024-11-04 01:43:43 +03:00
|
|
|
char *get_string(bytefile *f, size_t pos);
|
2024-10-31 21:08:48 +03:00
|
|
|
|
|
|
|
|
/* Gets a name for a public symbol */
|
2024-11-04 01:43:43 +03:00
|
|
|
char *get_public_name(bytefile *f, size_t i);
|
2024-10-31 21:08:48 +03:00
|
|
|
|
|
|
|
|
/* Gets an offset for a public symbol */
|
2024-11-04 01:43:43 +03:00
|
|
|
size_t get_public_offset(bytefile *f, size_t i);
|
2024-10-31 21:08:48 +03:00
|
|
|
|
|
|
|
|
// ---
|