Compare commits

...
Author SHA1 Message Date
t3hn3rd d12ad11746 feature: implement control flow opcodes, extract constants & helpers
## Control Flow Opcodes
- Implemented all 10 remaining stub control flow opcodes:
  block, loop, if, else, end, br, br_if, br_table, call, call_indirect
- Rewrote return opcode to walk control stack and restore call frames
- Fixed tick() hang: now halts when IP >= Limit

## Refactoring
- Extracted WASM_HDR_MAGIC and CTRL_FRAME_* constants to wasm.types.constants.pas
- Extracted push_control_frame, scan_forward, do_branch helpers to wasm.vm.control.pas
- Updated wasm.parser.pas to reference constants via wasm.types.constants

## Tests
- Added 9 new test units (25 tests):
  block, loop, if, end, br, br_if, br_table, call, call_indirect
- Added E2E binary test: 115-byte handcrafted WASM binary exercising
  all control flow opcodes (2 functions, expected result=30)
- All 425/425 tests passing
2026-02-24 14:46:30 +00:00
t3hn3rd 679973c6e9 Merge branch 'feature/type-refactoring' into develop 2026-02-24 13:24:15 +00:00
t3hn3rd 68df3565cb feature: types refactored from one monolithic file to seperation of duties
- wasm.types.context.pas
- wasm.types.enums.pas
- wasm.types.sections.pas
- wasm.types.values.pas
2026-02-24 13:23:46 +00:00
t3hn3rd 862e3254df Merge branch 'hotfix/binary-test-builtins' into develop 2026-02-24 13:05:42 +00:00
159 changed files with 1794 additions and 335 deletions

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ uses
types,
wasm.types,
wasm.types.context,
wasm.parser,
wasm.vm, wasm.test.binary.return42,
wasm.types.stack
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.enums, wasm.types.values, wasm.types.sections, wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types, wasm.types.heap;
wasm.types.context, wasm.types.heap;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.enums, wasm.types.sections, wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.sections, wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.enums, wasm.types.sections, wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types, wasm.types.heap;
wasm.types.sections, wasm.types.context, wasm.types.heap;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types;
wasm.types.enums, wasm.types.values, wasm.types.sections, wasm.types.context;
procedure handle(buffer: TWASMPUInt8; section_length: TWASMUInt32; ctx: PWASMProcessContext);
+3 -3
View File
@@ -4,8 +4,8 @@ interface
uses
wasm.types.builtin, lmemorymanager, console, leb128,
wasm.types, wasm.types.heap, wasm.types.stack,
wasm.parser.sections;
wasm.types.enums, wasm.types.sections, wasm.types.context, wasm.types.heap, wasm.types.stack,
wasm.parser.sections, wasm.types.constants;
function parse(buffer: TWASMPUInt8; buffer_end: TWASMPUInt8) : PWASMProcessContext;
@@ -66,7 +66,7 @@ begin
writestringln('[wasm.parser] Parsing WASM Binary');
// Check for the WASM Magic
if(TWASMPUInt32(pos)^ = wasm.types.WASM_HDR_MAGIC) then begin
if(TWASMPUInt32(pos)^ = wasm.types.constants.WASM_HDR_MAGIC) then begin
writestringln('[wasm.parser] Binary is valid.');
// Set binary to valid
+1 -1
View File
@@ -4,7 +4,7 @@ interface
uses
wasm.types.builtin,
wasm.types,
wasm.types.enums, wasm.types.context,
wasm.parser.sections.customSection,
wasm.parser.sections.typeSection,
wasm.parser.sections.importSection,
@@ -18,7 +18,7 @@ procedure run;
implementation
uses
wasm.types.builtin, console, wasm.types, wasm.types.stack,
wasm.types.builtin, console, wasm.types.context, wasm.types.stack,
wasm.parser, wasm.vm, wasm.test.framework;
const
@@ -20,7 +20,7 @@ procedure run;
implementation
uses
wasm.types.builtin, console, wasm.types, wasm.types.stack,
wasm.types.builtin, console, wasm.types.context, wasm.types.stack,
wasm.parser, wasm.vm, wasm.test.framework;
const
File diff suppressed because it is too large. Load diff
@@ -23,7 +23,7 @@ procedure run;
implementation
uses
wasm.types.builtin, console, wasm.types, wasm.types.stack,
wasm.types.builtin, console, wasm.types.context, wasm.types.stack,
wasm.parser, wasm.vm, wasm.test.framework;
const
@@ -21,7 +21,7 @@ procedure run;
implementation
uses
wasm.types.builtin, console, wasm.types, wasm.types.stack,
wasm.types.builtin, console, wasm.types.context, wasm.types.stack,
wasm.parser, wasm.vm, wasm.test.framework;
const
Loaded 20 of 159 files, more files were not shown because too many files have changed in this diff. Show more