Commit Graph
15 Commits
Author SHA1 Message Date
t3hn3rd 7cc4459dfd Merge branch 'feature/builtin-types' into develop 2026-02-24 13:04:25 +00:00
t3hn3rd ae344e7495 Merge branch 'feature/binary-tests' into develop 2026-02-24 13:04:20 +00:00
t3hn3rd 430ebcd203 feature: added built-in types as a OS/RTL->VM decoupling mechanism
- Added src/wasm/types/wasm.types.builtin.pas as a decoupling unit.
- Updated all units to only use these types.
- Added linter step (lint.ps1) to enforce usage of these types.
2026-02-24 13:03:27 +00:00
t3hn3rd 835f6f86cc feature: Binary E2E tests
Implemented the following E2E tests:
- src/wasm/test/wasm.test.binary.addnums.pas
- src/wasm/test/wasm.test.binary.arithmetic.pas
- src/wasm/test/wasm.test.binary.locals.pas
- src/wasm/test/wasm.test.binary.memroundtrip.pas
- src/wasm/test/wasm.test.binary.return42.pas
2026-02-24 12:26:43 +00:00
t3hn3rd a5192366ed Merge branch 'hotfix/readme.1' into develop 2026-02-24 00:47:36 +00:00
t3hn3rd d3cd71072b hotfix: Fixed errors & formatting in generated ReadMe
- Incorrect link to the Asuro project.
- Formatting issues.
2026-02-24 00:47:23 +00:00
t3hn3rd e40d8e9ed5 Merge branch 'feature/readme' into develop 2026-02-24 00:42:31 +00:00
t3hn3rd fca24af1b0 docs: add project README
Add README.md documenting WASURO's architecture, implemented opcodes,
parsed sections, build instructions, testing, and constraints.

Covers:
- Project overview (WASM VM for Asuro OS, Standard Pascal, bare-metal)
- Source tree layout and key components (VM, parser, stack, heap, emu layer)
- Full table of implemented opcodes (control, variables, constants,
  i32/i64 arithmetic/bitwise/comparison, f32/f64 comparison,
  memory loads/stores, memory.size/grow)
- Parsed WASM binary sections
- Build and test instructions (build.bat / build.bat test)
- Kernel compatibility constraints (no RTL, no classes)
2026-02-24 00:42:17 +00:00
t3hn3rd 8c16550bd4 Merge branch 'feature/test-suite' into develop 2026-02-24 00:38:11 +00:00
t3hn3rd 9a3b813c96 Merge branch 'feature/opcode-parser-implementation' into develop 2026-02-24 00:38:06 +00:00
t3hn3rd 8a4bb2ca35 Merge branch 'feature/build-scripts' into develop 2026-02-24 00:38:00 +00:00
t3hn3rd ff28299132 feature: add build script and update .gitignore
Add build.bat for compiling WASURO with FPC 3.2.2 (x86_64-win64).
Supports optional "test" argument to enable the test suite.

build.bat:
- Configures FPC with all source unit paths (emu, wasm, parser,
  sections, types, vm, test infrastructure)
- Outputs to bin/WASURO.exe, intermediate units to lib/
- "build.bat test" passes -dRUN_TESTS to include test units
- Debug info enabled (-gw3)
- Propagates FPC exit code on failure

.gitignore:
- Add AGENTS.md (AI agent instructions, not project source), this file
should be personal choice, not dictated at a project level.
2026-02-24 00:37:37 +00:00
t3hn3rd dc67262477 feature: add comprehensive WASM test suite (374 tests)
Add a full test framework and 123 test files covering infrastructure,
parser sections, and VM opcodes. All 374 tests pass; exit code reflects
failure count for CI/CD integration.

Test framework (wasm.test.framework):
- Assert helpers: assert_true, assert_i32/i64/u32/u64/f32/f64/bool
- Context builders: make_test_context, setup_test_locals, setup_test_globals
- Global counters: TotalTests, PassedTests, FailedTests

Test runner (wasm.test, WASURO.lpr):
- Master runner calls all 108 test units and prints summary
- halt(FailedTests) returns exit code for pipeline consumption
- Gated behind {$IFDEF RUN_TESTS} / build.bat test

Infrastructure tests (3 units):
- Stack push/pop for i32, i64, f32, f64
- Heap read/write across all widths (8/16/32/64-bit)
- LEB128 unsigned/signed encoding/decoding

Parser tests (8 units):
- type, function, export, code, global, memory, start, data sections

Opcode tests (97 units, ~374 assertions):
- Control: nop, unreachable, drop, select, return
- Variables: local.get/set/tee, global.get/set
- Constants: i32/i64/f32/f64.const
- I32: all arithmetic, bitwise, and comparison ops (29 units)
- I64: all arithmetic, bitwise, and comparison ops (29 units)
- F32/F64: all comparison ops (12 units)
- Memory loads: i32/i64/f32/f64.load + sign/zero-extending variants (14 units)
- Memory stores: i32/i64/f32/f64.store + narrowing variants (9 units)
2026-02-24 00:34:49 +00:00
t3hn3rd d34997aa4e feature: implement WASM parser sections and VM opcode handlers
Parser implementations:
- dataSection: parse segments, evaluate i32.const offset expressions,
  copy data bytes into linear memory
- globalSection: parse globals with init expression evaluation and
  type/mutability handling
- memorySection: parse memory limits (initial/max pages, flags)
- startSection: parse start function index
- wasm.parser: route new section types to their handlers

VM opcode implementations:
- Control: nop, unreachable (trap), drop, select, return
- Variables: local.get/set/tee, global.get/set
- Constants: i32.const, i64.const, f32.const, f64.const
- I32 arithmetic: add, sub, mul, div_s, div_u, rem_s, rem_u,
  clz, ctz, popcnt
- I32 bitwise: and, or, xor, shl, shr_s, shr_u, rotl, rotr
- I32 comparison: eqz, eq, ne, lt_s/u, gt_s/u, le_s/u, ge_s/u
- I64 arithmetic: add, sub, mul, div_s, div_u, rem_s, rem_u,
  clz, ctz, popcnt
- I64 bitwise: and, or, xor, shl, shr_s, shr_u, rotl, rotr
- I64 comparison: eqz, eq, ne, lt_s/u, gt_s/u, le_s/u, ge_s/u
- F32/F64 comparison: eq, ne, lt, gt, le, ge
- Memory loads: i32/i64/f32/f64.load, i32.load8_s/u, i32.load16_s/u,
  i64.load8_s/u, i64.load16_s/u, i64.load32_s/u
- Memory stores: i32/i64/f32/f64.store, i32.store8, i32.store16,
  i64.store8, i64.store16, i64.store32
- Memory management: memory.size, memory.grow

Bug fixes:
- memory.grow: guard against uint32 underflow when growing 0 pages
- select: fix off-by-one stack indexing for val1/val2
- i32/i64.shr_s: use manual arithmetic shift right (logical shift +
  sign-bit mask fill) instead of RTL intrinsics for bare-metal
  kernel compatibility

Type additions:
- wasm.types: new records and pointer types for globals, locals,
  and section structures
2026-02-24 00:31:36 +00:00
t3hn3rd 3361286352 Initial commit 2026-02-23 23:02:58 +00:00