66 lines
2.2 KiB
C
66 lines
2.2 KiB
C
/*
|
|
* nanowasm, a tiny WebAssembly/Wasm interpreter
|
|
* Copyright (C) 2023-2024 Xavier Del Campo Romero
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#ifndef SECTIONS_H
|
|
#define SECTIONS_H
|
|
|
|
#include <nanowasm/nw.h>
|
|
#include <nw/types.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
struct section
|
|
{
|
|
const struct nw_mod_cfg *cfg;
|
|
FILE *f;
|
|
};
|
|
|
|
int section_custom_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_type_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_import_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_function_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_table_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_memory_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_global_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_export_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_start_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_element_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_code_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
int section_data_check(const struct section *s, struct nw_mod *m, unsigned long len);
|
|
|
|
struct section_function
|
|
{
|
|
varuint32 type, index, nreturn;
|
|
};
|
|
|
|
struct section_code
|
|
{
|
|
long start;
|
|
};
|
|
|
|
int section_function(const struct section *s, const struct nw_mod *m,
|
|
varuint32 idx, struct section_function *f);
|
|
int section_code(const struct section *s, const struct nw_mod *m,
|
|
varuint32 idx, struct section_code *c);
|
|
|
|
int section_code_push(FILE *f, long pc, struct nw_frame *fr);
|
|
int section_type_push(FILE *f, const struct nw_mod *m, varuint32 idx,
|
|
struct nw_frame *fr);
|
|
int section_global_push(FILE *f, const struct nw_mod *m, struct nw_interp *i);
|
|
|
|
struct resizable_limits
|
|
{
|
|
bool max_available;
|
|
size_t sz, max;
|
|
};
|
|
|
|
int check_resizable_limits(FILE *f, struct resizable_limits *r);
|
|
|
|
#endif
|