Static ALL THE THINGS

This commit is contained in:
Igor M 2024-03-13 19:21:04 +02:00
parent fb02841863
commit 8e9bacaedc
6 changed files with 12 additions and 0 deletions

View file

@ -55,6 +55,8 @@ const char *TYPE_STR[] = {
};
const size_t NARGS = sizeof(ARGS) / sizeof(ARGS[0]);
static
ArgMeta arg_meta(char arg) {
for (size_t ii = 0; ii < NARGS; ii += 1) {
ArgMeta meta = ARGS[ii];

View file

@ -6,6 +6,7 @@ typedef struct ByteVec_s {
size_t len;
} ByteVec;
static
AsmError ensure_push(ByteVec *vec, size_t el_size, size_t extra) {
if (vec->len + extra < vec->len) {
return ErrOutOfMemory;

View file

@ -5,6 +5,7 @@ typedef struct InstHtNode_s {
} InstHtNode;
typedef InstHtNode *InstHt;
static
uint32_t inst_hash(const char *s, size_t len) {
uint32_t hash = 0;
uint32_t mul = 75;
@ -15,6 +16,7 @@ uint32_t inst_hash(const char *s, size_t len) {
return hash;
}
static
InstHt build_lookup(void) {
const size_t size = 256;
InstHt table = (InstHt)malloc(size * sizeof(InstHtNode));
@ -40,6 +42,7 @@ InstHt build_lookup(void) {
return table;
}
static
size_t inst_lookup(InstHt ht, const char *s, size_t len) {
uint32_t hash = inst_hash(s, len);
uint8_t *node = (uint8_t *)&ht[(size_t)(hash & 0xff)];

View file

@ -174,9 +174,11 @@ AsmError push_int_le(char *buf, uint64_t val, size_t size, uint8_t sign) {
buf[ii] = val & 0xff;
val >>= 8;
}
return ErrOk;
}
static
AsmError assemble_instr(InstHt ht, char *input, size_t len, Token *tok,
ByteVec *rv, HoleVec *holes) {
const InstDesc *inst;

View file

@ -1,3 +1,4 @@
static
int parse_register(char *name, size_t len) {
if (name[0] != 'r') {
return 256; // Register name should start with 'r'

View file

@ -18,6 +18,7 @@ typedef struct Token_s {
uint64_t num;
} Token;
static
Token token_ident(char *input, size_t len, size_t pos) {
size_t start = pos;
while (pos < len) {
@ -33,6 +34,7 @@ Token token_ident(char *input, size_t len, size_t pos) {
return (Token){TokIdent, start, pos - start, 0};
}
static
Token token_number(char *input, size_t len, size_t pos) {
char *ptr = &input[pos];
char next = '\0';
@ -109,6 +111,7 @@ Token token_number(char *input, size_t len, size_t pos) {
}
}
static
Token token(char *input, size_t len, size_t pos) {
char chr, chru;
char *ptr = &input[pos];