diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-04-26 12:48:13 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-08 22:14:39 +0200 |
commit | aa4d8d26b971f18921a1a6a368ef15fd5b8e2457 (patch) | |
tree | 9f176cf97261eb6b6b14ccedab894331077d0a7c /Userland/Libraries/LibWasm/Constants.h | |
parent | 56a6d7924eeeb38df065494c9f3a9b476225abf7 (diff) | |
download | serenity-aa4d8d26b971f18921a1a6a368ef15fd5b8e2457.zip |
LibWasm: Start implementing a basic WebAssembly binary format parser
This can currently parse a really simple module.
Note that it cannot parse the DataCount section, and it's still missing
almost all of the instructions.
This commit also adds a 'wasm' test utility that tries to parse a given
webassembly binary file.
It currently does nothing but exit when the parse fails, but it's a
start :^)
Diffstat (limited to 'Userland/Libraries/LibWasm/Constants.h')
-rw-r--r-- | Userland/Libraries/LibWasm/Constants.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWasm/Constants.h b/Userland/Libraries/LibWasm/Constants.h new file mode 100644 index 0000000000..9d5f346fc6 --- /dev/null +++ b/Userland/Libraries/LibWasm/Constants.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Types.h> + +namespace Wasm::Constants { + +// Value +static constexpr auto i32_tag = 0x7f; +static constexpr auto i64_tag = 0x7e; +static constexpr auto f32_tag = 0x7d; +static constexpr auto f64_tag = 0x7c; +static constexpr auto function_reference_tag = 0x70; +static constexpr auto extern_reference_tag = 0x6f; + +// Function +static constexpr auto function_signature_tag = 0x60; + +// Global +static constexpr auto const_tag = 0x00; +static constexpr auto var_tag = 0x01; + +// Block +static constexpr auto empty_block_tag = 0x40; + +// Import section +static constexpr auto extern_function_tag = 0x00; +static constexpr auto extern_table_tag = 0x01; +static constexpr auto extern_memory_tag = 0x02; +static constexpr auto extern_global_tag = 0x03; + +} |