mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 23:08:46 +00:00
fixes, cleanup, some copies removed
This commit is contained in:
parent
2589f6166f
commit
d90a8cf89f
16 changed files with 373 additions and 666 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <ostream>
|
||||
|
||||
extern "C" {
|
||||
#include "parser.h"
|
||||
#include "utils.h"
|
||||
}
|
||||
|
||||
|
|
@ -46,29 +47,12 @@ enum class Cmd : int8_t {
|
|||
|
||||
Bytefile *read_file(const char *fname);
|
||||
|
||||
static inline int ip_read_int(char **ip, const Bytefile &bf) {
|
||||
if (*ip + sizeof(int) > bf.code_ptr + bf.code_size) {
|
||||
failure("last command is invalid, int parameter can not be read\n");
|
||||
}
|
||||
*ip += sizeof(int);
|
||||
return *(int *)((*ip) - sizeof(int));
|
||||
}
|
||||
|
||||
static inline uint8_t ip_read_byte(char **ip, const Bytefile &bf) {
|
||||
if (*ip + sizeof(char) > bf.code_ptr + bf.code_size) {
|
||||
failure("last command is invalid, byte parameter can not be read\n");
|
||||
}
|
||||
return *(*ip)++;
|
||||
}
|
||||
|
||||
static inline uint8_t ip_read_byte_unsafe(char **ip) { return *(*ip)++; }
|
||||
|
||||
static inline const char *ip_read_string(char **ip, const Bytefile &bf) {
|
||||
return get_string(&bf, ip_read_int(ip, bf));
|
||||
}
|
||||
|
||||
std::pair<Cmd, uint8_t> parse_command(char **ip, const Bytefile &bf);
|
||||
std::pair<Cmd, uint8_t> parse_command(char **ip, const Bytefile &bf,
|
||||
std::pair<Cmd, uint8_t> parse_command(char **ip, const Bytefile *bf);
|
||||
std::pair<Cmd, uint8_t> parse_command(char **ip, const Bytefile *bf,
|
||||
std::ostream &out);
|
||||
|
||||
std::pair<Cmd, uint8_t> parse_command_name(char **ip, const Bytefile *bf);
|
||||
|
||||
bool is_command_name(char *ip, const Bytefile *bf, Cmd cmd);
|
||||
|
||||
void print_file(const Bytefile &bf, std::ostream &out);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue