summaryrefslogtreecommitdiff
path: root/src/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.h')
-rw-r--r--src/ast.h41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/ast.h b/src/ast.h
index 9d196899..1e9d177d 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -21,6 +21,10 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+#include <string>
+#include <vector>
+
#include "binding-hash.h"
#include "common.h"
#include "type-vector.h"
@@ -140,6 +144,10 @@ struct FuncDeclaration {
};
struct Func {
+ WABT_DISALLOW_COPY_AND_ASSIGN(Func);
+ Func();
+ ~Func();
+
StringSlice name;
FuncDeclaration decl;
TypeVector local_types;
@@ -198,7 +206,7 @@ struct Import {
/* an imported func is has the type Func so it can be more easily
* included in the Module's vector of funcs; but only the
* FuncDeclaration will have any useful information */
- Func func;
+ Func* func;
Table table;
Memory memory;
Global global;
@@ -233,9 +241,9 @@ struct ModuleField {
ModuleFieldType type;
struct ModuleField* next;
union {
- Func func;
+ Func* func;
Global global;
- Import import;
+ Import* import;
Export export_;
FuncType func_type;
Table table;
@@ -247,6 +255,10 @@ struct ModuleField {
};
struct Module {
+ WABT_DISALLOW_COPY_AND_ASSIGN(Module);
+ Module();
+ ~Module();
+
Location loc;
StringSlice name;
ModuleField* first_field;
@@ -349,7 +361,7 @@ static const int kCommandTypeCount = WABT_ENUM_COUNT(CommandType);
struct Command {
CommandType type;
union {
- Module module;
+ Module* module;
Action action;
struct { StringSlice module_name; Var var; } register_;
struct { Action action; ConstVector expected; } assert_return;
@@ -365,6 +377,10 @@ struct Command {
WABT_DEFINE_VECTOR(command, Command);
struct Script {
+ WABT_DISALLOW_COPY_AND_ASSIGN(Script);
+ Script();
+ ~Script();
+
CommandVector commands;
BindingHash module_bindings;
};
@@ -439,7 +455,6 @@ Expr* new_unreachable_expr(void);
/* destruction functions. not needed unless you're creating your own AST
elements */
-void destroy_script(struct Script*);
void destroy_action(struct Action*);
void destroy_block(struct Block*);
void destroy_command_vector_and_elements(CommandVector*);
@@ -452,10 +467,8 @@ void destroy_expr_list(Expr*);
void destroy_func_declaration(FuncDeclaration*);
void destroy_func_signature(FuncSignature*);
void destroy_func_type(FuncType*);
-void destroy_func(Func*);
void destroy_import(Import*);
void destroy_memory(Memory*);
-void destroy_module(Module*);
void destroy_raw_module(RawModule*);
void destroy_table(Table*);
void destroy_var_vector_and_elements(VarVector*);
@@ -489,16 +502,10 @@ ExportPtr get_export_by_name(const Module* module, const StringSlice* name);
Module* get_first_module(const Script* script);
Module* get_module_by_var(const Script* script, const Var* var);
-void make_type_binding_reverse_mapping(const TypeVector*,
- const BindingHash*,
- StringSliceVector* out_reverse_mapping);
-
-typedef void (*DuplicateBindingCallback)(BindingHashEntry* a,
- BindingHashEntry* b,
- void* user_data);
-void find_duplicate_bindings(const BindingHash*,
- DuplicateBindingCallback callback,
- void* user_data);
+void make_type_binding_reverse_mapping(
+ const TypeVector&,
+ const BindingHash&,
+ std::vector<std::string>* out_reverse_mapping);
static WABT_INLINE bool decl_has_func_type(const FuncDeclaration* decl) {
return static_cast<bool>(