From 29060a1139e4896d5075ced9e2cba03130b9a96c Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Tue, 19 Dec 2023 14:56:41 +0100 Subject: [PATCH] Add start of spec --- spec.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 spec.md diff --git a/spec.md b/spec.md new file mode 100644 index 0000000..15b2793 --- /dev/null +++ b/spec.md @@ -0,0 +1,77 @@ +# Spec for ByteCode + +:: All value starting with `0x` are hexadecimal + +|-----------------------------------------------------------------------------| +| Header | +|-----------------------------------------------------------------------------| +| Struct registration | +|-----------------------------------------------------------------------------| +| Global variable registration | +|-----------------------------------------------------------------------------| +| Function registration | +|-----------------------------------------------------------------------------| +| Start function | +|-----------------------------------------------------------------------------| + +## Header + +1. The file starts with: + +``` +0x55 0x1E 0x53 0x0A +``` + +## Struct registration + +|-----------------------------------------------------------------------------| +| 0x01 0xZZZZZZZZ 0x | +|-----------------------------------------------------------------------------| + +Struct ID for: +- __Int__: `0x00000001` +- __String__: `0x00000002` +- __Bool__: `0x00000003` +- __Void__: `0x00000004` +- __Char__: `0x00000005` + +1. The section starts with: + +``` +0x00 0x06 0x07 0x00 +``` + + + +2. Struct are a list of other struct of built-in types + +- Struct start + +``` +0x01 +``` + +- Struct name (Int32) is an `ID` of the struct name. + +All reference to this struct will be with the `ID`. + +- Number of fields (Int16) + +- Each fild is a `ID` of the field type + +- Struct end + +``` +0x00 +``` + + +``` +struct a { + int +} + +struct b { + a +} +```