summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/binary-writer.cc26
-rw-r--r--src/binary.h2
-rw-r--r--test/binary/bad-event-after-global.txt (renamed from test/binary/bad-event-after-export.txt)2
-rw-r--r--test/binary/bad-event-before-memory.txt (renamed from test/binary/bad-event-before-global.txt)6
4 files changed, 18 insertions, 18 deletions
diff --git a/src/binary-writer.cc b/src/binary-writer.cc
index 6c0a73db..e5c9c4d2 100644
--- a/src/binary-writer.cc
+++ b/src/binary-writer.cc
@@ -1011,6 +1011,19 @@ Result BinaryWriter::WriteModule() {
EndSection();
}
+ assert(module_->events.size() >= module_->num_event_imports);
+ Index num_events = module_->events.size() - module_->num_event_imports;
+ if (num_events) {
+ BeginKnownSection(BinarySection::Event);
+ WriteU32Leb128(stream_, num_events, "event count");
+ for (size_t i = 0; i < num_events; ++i) {
+ WriteHeader("event", i);
+ const Event* event = module_->events[i + module_->num_event_imports];
+ WriteEventType(event);
+ }
+ EndSection();
+ }
+
assert(module_->globals.size() >= module_->num_global_imports);
Index num_globals = module_->globals.size() - module_->num_global_imports;
if (num_globals) {
@@ -1025,19 +1038,6 @@ Result BinaryWriter::WriteModule() {
EndSection();
}
- assert(module_->events.size() >= module_->num_event_imports);
- Index num_events = module_->events.size() - module_->num_event_imports;
- if (num_events) {
- BeginKnownSection(BinarySection::Event);
- WriteU32Leb128(stream_, num_events, "event count");
- for (size_t i = 0; i < num_events; ++i) {
- WriteHeader("event", i);
- const Event* event = module_->events[i + module_->num_event_imports];
- WriteEventType(event);
- }
- EndSection();
- }
-
if (module_->exports.size()) {
BeginKnownSection(BinarySection::Export);
WriteU32Leb128(stream_, module_->exports.size(), "num exports");
diff --git a/src/binary.h b/src/binary.h
index 01c9b95a..a1fc555f 100644
--- a/src/binary.h
+++ b/src/binary.h
@@ -36,8 +36,8 @@
V(Function, function, 3) \
V(Table, table, 4) \
V(Memory, memory, 5) \
- V(Global, global, 6) \
V(Event, event, 13) \
+ V(Global, global, 6) \
V(Export, export, 7) \
V(Start, start, 8) \
V(Elem, elem, 9) \
diff --git a/test/binary/bad-event-after-export.txt b/test/binary/bad-event-after-global.txt
index bcfcc185..ae236831 100644
--- a/test/binary/bad-event-after-export.txt
+++ b/test/binary/bad-event-after-global.txt
@@ -3,7 +3,7 @@
;;; ARGS2: --enable-exceptions
magic
version
-section(EXPORT) { count[0] }
+section(GLOBAL) { count[0] }
section(EVENT) { count[0] }
(;; STDERR ;;;
000000d: error: section Event out of order
diff --git a/test/binary/bad-event-before-global.txt b/test/binary/bad-event-before-memory.txt
index ae0758f1..992531f0 100644
--- a/test/binary/bad-event-before-global.txt
+++ b/test/binary/bad-event-before-memory.txt
@@ -4,8 +4,8 @@
magic
version
section(EVENT) { count[0] }
-section(GLOBAL) { count[0] }
+section(MEMORY) { count[0] }
(;; STDERR ;;;
-000000d: error: section Global out of order
-000000d: error: section Global out of order
+000000d: error: section Memory out of order
+000000d: error: section Memory out of order
;;; STDERR ;;)