aboutsummaryrefslogtreecommitdiff
path: root/include/bytecode
diff options
context:
space:
mode:
Diffstat (limited to 'include/bytecode')
-rw-r--r--include/bytecode/bytecode.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/include/bytecode/bytecode.h b/include/bytecode/bytecode.h
index c495d7a..a93fe4f 100644
--- a/include/bytecode/bytecode.h
+++ b/include/bytecode/bytecode.h
@@ -8,8 +8,8 @@
#include <setjmp.h>
-/*doc(Opcode)
- Variable length opcodes. Sizes range from 1 to 5 bytes.
+/*doc(Instructions)
+ Variable length instructions. Instruction size ranges from 1 to 5 bytes.
# Instruction formats
Instructions can be in 7 different formats:
1. 1 byte: Opcode(u8)
@@ -25,7 +25,8 @@
6.1 Opcode(u8) + register(i8) + label(i16)\
6.2 Opcode(u8) + register(i8) + intermediate(u16)\
6.3 Opcode(u8) + register(i8) + data(u16)\
- 6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16)
+ 6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16)\
+ 6.5 Opcode(u8) + stack_offset(i24)
7. 5 bytes: Opcode(u8) + index(u8) + index(u16) + num_args(u8)
# Registers
Registers have a range of 128. Local variables start from register 0 and increment while parameters start from -1
@@ -96,6 +97,19 @@ typedef struct {
/* TODO: Make sure this pragma pack works on all platforms */
#pragma pack(push, 1)
typedef struct {
+ u8 num_params;
+ u32 params_num_pointers;
+ u32 params_fixed_size;
+
+ u8 num_return_types;
+ u32 return_types_num_pointers;
+ u32 return_types_fixed_size;
+} BytecodeHeaderExternFunction;
+#pragma pack(pop)
+
+/* TODO: Make sure this pragma pack works on all platforms */
+#pragma pack(push, 1)
+typedef struct {
u32 function_index;
#define parser_index function_index
u32 extern_function_index;