change to uint8_t for bytecode to reduce wasted bytes
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
#include "function.h"
|
||||
#include "../translator.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
size_t translate_parsed_function(Translated *translated,
|
||||
ParsedFunction *parsedFunction) {
|
||||
DArray temp_bytecode;
|
||||
darray_init(&temp_bytecode, sizeof(uint64_t));
|
||||
DArray main_bytecode = translated->bytecode;
|
||||
translated->bytecode = temp_bytecode;
|
||||
DArray _temp_bytecode;
|
||||
darray_init(&_temp_bytecode, sizeof(uint8_t));
|
||||
translated->bytecode = _temp_bytecode;
|
||||
translate_parsed(translated, parsedFunction->body);
|
||||
size_t function_bytecode_offset =
|
||||
arena_push(&translated->constants, translated->bytecode.data,
|
||||
translated->bytecode.size*translated->bytecode.element_size);
|
||||
size_t function_bytecode_length = translated->bytecode.size;
|
||||
darray_free(&translated->bytecode, NULL);
|
||||
translated->bytecode = main_bytecode;
|
||||
darray_free(&temp_bytecode, NULL);
|
||||
size_t start = push_instruction_code(translated, OP_LOAD_FUNCTION);
|
||||
size_t start = push_instruction_byte(translated, OP_LOAD_FUNCTION);
|
||||
size_t offset = arena_push(&translated->constants, parsedFunction->name,
|
||||
strlen(parsedFunction->name));
|
||||
push_instruction_code(translated, offset);
|
||||
|
||||
Reference in New Issue
Block a user