Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/wabt/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,8 @@ class ScriptModule {
ScriptModuleType type() const { return type_; }
virtual const Location& location() const = 0;

bool is_definition;

protected:
explicit ScriptModule(ScriptModuleType type) : type_(type) {}

Expand Down Expand Up @@ -1506,6 +1508,7 @@ class CommandMixin : public Command {
class ModuleCommand : public CommandMixin<CommandType::Module> {
public:
Module module;
bool is_definition;
};

class ScriptModuleCommand : public CommandMixin<CommandType::ScriptModule> {
Expand Down
1 change: 1 addition & 0 deletions include/wabt/token.def
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ WABT_TOKEN(Bin, "bin")
WABT_TOKEN(Item, "item")
WABT_TOKEN(Data, "data")
WABT_TOKEN(Declare, "declare")
WABT_TOKEN(Definition, "definition")
WABT_TOKEN(Delegate, "delegate")
WABT_TOKEN(Do, "do")
WABT_TOKEN(Either, "either")
Expand Down
13 changes: 12 additions & 1 deletion src/binary-writer-spec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ void BinaryWriterSpec::WriteCommands() {
case CommandType::Module: {
const Module& module = cast<ModuleCommand>(command)->module;
std::string filename = GetModuleFilename(kWasmExtension);
if (cast<ModuleCommand>(command)->is_definition) {
WriteKey("definition");
WriteString("true");
WriteSeparator();
}
WriteLocation(module.loc);
WriteSeparator();
if (!module.name.empty()) {
Expand All @@ -488,8 +493,14 @@ void BinaryWriterSpec::WriteCommands() {

case CommandType::ScriptModule: {
auto* script_module_command = cast<ScriptModuleCommand>(command);
auto* script_module = script_module_command->script_module.get();
const auto& module = script_module_command->module;
std::string filename = GetModuleFilename(kWasmExtension);
if (script_module->is_definition) {
WriteKey("definition");
WriteString("true");
WriteSeparator();
}
WriteLocation(module.loc);
WriteSeparator();
if (!module.name.empty()) {
Expand All @@ -499,7 +510,7 @@ void BinaryWriterSpec::WriteCommands() {
}
WriteKey("filename");
WriteEscapedString(GetBasename(filename));
WriteScriptModule(filename, *script_module_command->script_module);
WriteScriptModule(filename, *script_module);
num_modules_++;
last_module_index = i;
break;
Expand Down
1 change: 1 addition & 0 deletions src/lexer-keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ code, TokenType::Code
data.drop, TokenType::DataDrop, Opcode::DataDrop
data, TokenType::Data
declare, TokenType::Declare
definition, TokenType::Definition
delegate, TokenType::Delegate
do, TokenType::Do
drop, TokenType::Drop, Opcode::Drop
Expand Down
Loading
Loading