<commit_before>Provides utilities for loading and running WASM modules

Built on top of the [Wasmer](https://github.com/wasmerio/wasmer) runtime.

## Setup

Run `dart run wasm:setup` to build the Wasmer runtime.

## Basic Usage

As a simple example, we'll try to call the following C function from Dart using
`package:wasm`. For a more detailed example that uses WASI, check out the
example directory.

```c++
extern "C" int square(int n) { return n * n; }
```

We can compile this C++ code to WASM using a recent version of the
[clang compiler](https://clang.llvm.org/get_started.html):

```bash
clang --target=wasm32 -nostdlib -Wl,--export-all -Wl,--no-entry -o square.wasm square.cc
```

Then we can load and run it like this:

```dart
import 'dart:io';
import 'package:wasm/wasm.dart';

void main() {
  final data = File('square.wasm').readAsBytesSync();
  final mod = WasmModule(data);
  print(mod.describe());
  final inst = mod.builder().build();
  final square = inst.lookupFunction('square');
  print(square(12));
}
```

This should print:

```
export memory: memory
export function: int32 square(int32)

144
```<commit_msg>Add more detail to sample (#32)<commit_after>Provides utilities for loading and running WASM modules

Built on top of the [Wasmer](https://github.com/wasmerio/wasmer) runtime.

## Setup

Run `dart run wasm:setup` to build the Wasmer runtime.

## Basic Usage

As a simple example, we'll try to call a simple C function from Dart using
`package:wasm`. For a more detailed example that uses WASI, check out the
example directory.

1. First create new Dart app folder: `dart create wasmtest`

1. Then add a new file `square.cc` with the following contents:

    ```c++
    extern "C" int square(int n) { return n * n; }
    ```

1. We can compile this C++ code to WASM using a recent version of the
[clang compiler](https://clang.llvm.org/get_started.html):

    ```bash
    clang --target=wasm32 -nostdlib -Wl,--export-all -Wl,--no-entry -o square.wasm square.cc
    ```

Then we can load and run it like this:

1. Add a dependency to package `wasm` in `pubspec.yaml` and run `dart pub get`

1. Replace the contents of `bin/wasmtest.dart` with:

    ```dart
    import 'dart:io';
    import 'package:wasm/wasm.dart';
    
    void main() {
      final data = File('square.wasm').readAsBytesSync();
      final mod = WasmModule(data);
      print(mod.describe());
      final inst = mod.builder().build();
      final square = inst.lookupFunction('square');
      print(square(12));
    }
    ```

1. Run the Dart program: `dart run`

This should print:

```
export memory: memory
export function: int32 square(int32)

144
```
{'fraction_non_alphanumeric': 0.12843691148775896, 'fraction_numerical': 0.011299435028248588, 'mean_word_length': 3.7008849557522123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7600082', 'n_tokens_mistral': 909, 'n_tokens_neox': 852, 'n_words': 317}