Go to file
2024-11-25 09:08:52 +01:00
.vscode Initial Commit 2024-10-24 17:45:05 +02:00
app Initial Commit 2024-10-24 17:45:05 +02:00
src/MiniWasm Tracking PC through labels? 2024-11-25 09:08:52 +01:00
test binops 2024-11-06 12:41:23 +01:00
.gitignore Initial Commit 2024-10-24 17:45:05 +02:00
cabal.project.local Initial Commit 2024-10-24 17:45:05 +02:00
flake.lock Implemented blocks, loops and functions. But probably still wrong 2024-11-20 13:10:44 +01:00
flake.nix Initial Commit 2024-10-24 17:45:05 +02:00
miniwasm.cabal binops 2024-11-06 12:41:23 +01:00
README.md Initial Commit 2024-10-24 17:45:05 +02:00

miniwasm

Running the project

To compile and run the Cabal project, run the following command in the project's directory:

cabal run miniwasm # Prints the help menu
cabal run miniwasm <program> # Runs the specified MiniWasm program

To run the project's test suite, use the following command:

cabal run miniwasm-test
cabal run miniwasm-test -- <program> # Run just 1 test case (the -- is required)

Implementation notes

The project contains 4 main Haskell modules:

  • MiniWasm.Syntax: Contains the definition of the MiniWasm AST.
  • MiniWasm.Validation: Contains a fully-implemeted validation algorithm. You don't necessarily have to read this file, but it might help you when debugging if you get validation errors.
  • MiniWasm.Execution: Contains a stub implementation of the interpreter. This is the only file that you need to modify and submit.
  • MiniWasm.TestCases.Programs: Contains MiniWasm programs used as test cases for the interpreter.
  • MiniWasm.TestCases.SmallStep: Contains small unit tests verifying single steps of your interpreter.

Haskell language extensions

The project uses the GHC2021 language by default, which enables most "sane" language extensions (you can find the full list here).

On top of this, some record-related language extensions are enabled by default, since you'll likely be using records quite a lot in the interpreter:

  • OverloadedRecordDot: This enables the record.field syntax, which is more similar to most other languages. The record.field syntax also disambiguates field names better than Haskell's default field record notation.
  • RecordWildCards: This extension lets you bring all of a record's fields into scope when pattern-matching on it, helping avoid duplication, e.g. instead of Config{funcs, memory, locals, stack, instrs} you can write Config{..}.
  • NamedFieldPuns: This extension adds a shorter notation for creating and updating records, when setting fields to local variables of the same name. For example, it lets you write Config{stack} instead of Config{stack = stack} if you're initializing the stack field with a local variable also named stack.

You don't have to use the extensions if you don't want to, and you can also enable additional extensions, just make sure to enable them in the Execution.hs file (using the {-# LANGUAGE #-} pragma), and not in the .cabal file, as you won't be submitting back the .cabal file.