diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 108 | ||||
-rw-r--r-- | src/wasm/wasm-interpreter.cpp | 2 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 100 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 41 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 32 |
6 files changed, 142 insertions, 145 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 7625d1f2a..b7c074377 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -52,7 +52,7 @@ void WasmBinaryWriter::write() { writeFunctionSignatures(); writeTableDeclarations(); writeMemory(); - writeEvents(); + writeTags(); writeGlobals(); writeExports(); writeStart(); @@ -278,12 +278,12 @@ void WasmBinaryWriter::writeImports() { writeType(global->type); o << U32LEB(global->mutable_); }); - ModuleUtils::iterImportedEvents(*wasm, [&](Event* event) { - BYN_TRACE("write one event\n"); - writeImportHeader(event); - o << U32LEB(int32_t(ExternalKind::Event)); - o << U32LEB(event->attribute); - o << U32LEB(getTypeIndex(event->sig)); + ModuleUtils::iterImportedTags(*wasm, [&](Tag* tag) { + BYN_TRACE("write one tag\n"); + writeImportHeader(tag); + o << U32LEB(int32_t(ExternalKind::Tag)); + o << U32LEB(tag->attribute); + o << U32LEB(getTypeIndex(tag->sig)); }); if (wasm->memory.imported()) { BYN_TRACE("write one memory\n"); @@ -460,8 +460,8 @@ void WasmBinaryWriter::writeExports() { case ExternalKind::Global: o << U32LEB(getGlobalIndex(curr->value)); break; - case ExternalKind::Event: - o << U32LEB(getEventIndex(curr->value)); + case ExternalKind::Tag: + o << U32LEB(getTagIndex(curr->value)); break; default: WASM_UNREACHABLE("unexpected extern kind"); @@ -523,9 +523,9 @@ uint32_t WasmBinaryWriter::getGlobalIndex(Name name) const { return it->second; } -uint32_t WasmBinaryWriter::getEventIndex(Name name) const { - auto it = indexes.eventIndexes.find(name); - assert(it != indexes.eventIndexes.end()); +uint32_t WasmBinaryWriter::getTagIndex(Name name) const { + auto it = indexes.tagIndexes.find(name); + assert(it != indexes.tagIndexes.end()); return it->second; } @@ -646,18 +646,18 @@ void WasmBinaryWriter::writeElementSegments() { finishSection(start); } -void WasmBinaryWriter::writeEvents() { - if (importInfo->getNumDefinedEvents() == 0) { +void WasmBinaryWriter::writeTags() { + if (importInfo->getNumDefinedTags() == 0) { return; } - BYN_TRACE("== writeEvents\n"); - auto start = startSection(BinaryConsts::Section::Event); - auto num = importInfo->getNumDefinedEvents(); + BYN_TRACE("== writeTags\n"); + auto start = startSection(BinaryConsts::Section::Tag); + auto num = importInfo->getNumDefinedTags(); o << U32LEB(num); - ModuleUtils::iterDefinedEvents(*wasm, [&](Event* event) { + ModuleUtils::iterDefinedTags(*wasm, [&](Tag* tag) { BYN_TRACE("write one\n"); - o << U32LEB(event->attribute); - o << U32LEB(getTypeIndex(event->sig)); + o << U32LEB(tag->attribute); + o << U32LEB(getTypeIndex(tag->sig)); }); finishSection(start); @@ -1419,8 +1419,8 @@ void WasmBinaryBuilder::read() { case BinaryConsts::Section::Table: readTableDeclarations(); break; - case BinaryConsts::Section::Event: - readEvents(); + case BinaryConsts::Section::Tag: + readTags(); break; default: { readUserSection(payloadLen); @@ -1956,11 +1956,11 @@ Name WasmBinaryBuilder::getGlobalName(Index index) { return wasm.globals[index]->name; } -Name WasmBinaryBuilder::getEventName(Index index) { - if (index >= wasm.events.size()) { - throwError("invalid event index"); +Name WasmBinaryBuilder::getTagName(Index index) { + if (index >= wasm.tags.size()) { + throwError("invalid tag index"); } - return wasm.events[index]->name; + return wasm.tags[index]->name; } void WasmBinaryBuilder::getResizableLimits(Address& initial, @@ -1994,7 +1994,7 @@ void WasmBinaryBuilder::readImports() { size_t memoryCounter = 0; size_t functionCounter = 0; size_t globalCounter = 0; - size_t eventCounter = 0; + size_t tagCounter = 0; for (size_t i = 0; i < num; i++) { BYN_TRACE("read one\n"); auto module = getInlineString(); @@ -2069,15 +2069,15 @@ void WasmBinaryBuilder::readImports() { wasm.addGlobal(std::move(curr)); break; } - case ExternalKind::Event: { - Name name(std::string("eimport$") + std::to_string(eventCounter++)); + case ExternalKind::Tag: { + Name name(std::string("eimport$") + std::to_string(tagCounter++)); auto attribute = getU32LEB(); auto index = getU32LEB(); auto curr = - builder.makeEvent(name, attribute, getSignatureByTypeIndex(index)); + builder.makeTag(name, attribute, getSignatureByTypeIndex(index)); curr->module = module; curr->base = base; - wasm.addEvent(std::move(curr)); + wasm.addTag(std::move(curr)); break; } default: { @@ -2705,8 +2705,8 @@ void WasmBinaryBuilder::processNames() { case ExternalKind::Global: curr->value = getGlobalName(index); break; - case ExternalKind::Event: - curr->value = getEventName(index); + case ExternalKind::Tag: + curr->value = getTagName(index); break; default: throwError("bad export kind"); @@ -2902,17 +2902,17 @@ void WasmBinaryBuilder::readElementSegments() { } } -void WasmBinaryBuilder::readEvents() { - BYN_TRACE("== readEvents\n"); - size_t numEvents = getU32LEB(); - BYN_TRACE("num: " << numEvents << std::endl); - for (size_t i = 0; i < numEvents; i++) { +void WasmBinaryBuilder::readTags() { + BYN_TRACE("== readTags\n"); + size_t numTags = getU32LEB(); + BYN_TRACE("num: " << numTags << std::endl); + for (size_t i = 0; i < numTags; i++) { BYN_TRACE("read one\n"); auto attribute = getU32LEB(); auto typeIndex = getU32LEB(); - wasm.addEvent(Builder::makeEvent("event$" + std::to_string(i), - attribute, - getSignatureByTypeIndex(typeIndex))); + wasm.addTag(Builder::makeTag("tag$" + std::to_string(i), + attribute, + getSignatureByTypeIndex(typeIndex))); } } @@ -6113,10 +6113,10 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { Name catchLabel = getNextLabel(); breakStack.push_back({catchLabel, curr->type}); - auto readCatchBody = [&](Type eventType) { + auto readCatchBody = [&](Type tagType) { auto start = expressionStack.size(); - if (eventType != Type::none) { - pushExpression(builder.makePop(eventType)); + if (tagType != Type::none) { + pushExpression(builder.makePop(tagType)); } processExpressions(); size_t end = expressionStack.size(); @@ -6137,12 +6137,12 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { lastSeparator == BinaryConsts::CatchAll) { if (lastSeparator == BinaryConsts::Catch) { auto index = getU32LEB(); - if (index >= wasm.events.size()) { - throwError("bad event index"); + if (index >= wasm.tags.size()) { + throwError("bad tag index"); } - auto* event = wasm.events[index].get(); - curr->catchEvents.push_back(event->name); - readCatchBody(event->sig.params); + auto* tag = wasm.tags[index].get(); + curr->catchTags.push_back(tag->name); + readCatchBody(tag->sig.params); } else { // catch_all if (curr->hasCatchAll()) { @@ -6240,12 +6240,12 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { void WasmBinaryBuilder::visitThrow(Throw* curr) { BYN_TRACE("zz node: Throw\n"); auto index = getU32LEB(); - if (index >= wasm.events.size()) { - throwError("bad event index"); + if (index >= wasm.tags.size()) { + throwError("bad tag index"); } - auto* event = wasm.events[index].get(); - curr->event = event->name; - size_t num = event->sig.params.size(); + auto* tag = wasm.tags[index].get(); + curr->tag = tag->name; + size_t num = tag->sig.params.size(); curr->operands.resize(num); for (size_t i = 0; i < num; i++) { curr->operands[num - i - 1] = popNonVoidExpression(); diff --git a/src/wasm/wasm-interpreter.cpp b/src/wasm/wasm-interpreter.cpp index f37758808..b49eeef4b 100644 --- a/src/wasm/wasm-interpreter.cpp +++ b/src/wasm/wasm-interpreter.cpp @@ -20,7 +20,7 @@ void Indenter::print() { #endif // WASM_INTERPRETER_DEBUG std::ostream& operator<<(std::ostream& o, const WasmException& exn) { - return o << exn.event << " " << exn.values; + return o << exn.tag << " " << exn.values; } } // namespace wasm diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 4f1cd412e..c688630c3 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -411,8 +411,8 @@ void SExpressionWasmBuilder::preParseImports(Element& curr) { parseTable(curr, true /* preParseImport */); } else if (id == MEMORY) { parseMemory(curr, true /* preParseImport */); - } else if (id == EVENT) { - parseEvent(curr, true /* preParseImport */); + } else if (id == TAG) { + parseTag(curr, true /* preParseImport */); } else { throw ParseException( "fancy import we don't support yet", curr.line, curr.col); @@ -455,8 +455,8 @@ void SExpressionWasmBuilder::parseModuleElement(Element& curr) { if (id == TYPE) { return; // already done } - if (id == EVENT) { - return parseEvent(curr); + if (id == TAG) { + return parseTag(curr); } std::cerr << "bad module element " << id.str << '\n'; throw ParseException("unknown module element", curr.line, curr.col); @@ -502,16 +502,16 @@ Name SExpressionWasmBuilder::getGlobalName(Element& s) { } } -Name SExpressionWasmBuilder::getEventName(Element& s) { +Name SExpressionWasmBuilder::getTagName(Element& s) { if (s.dollared()) { return s.str(); } else { // index size_t offset = atoi(s.str().c_str()); - if (offset >= eventNames.size()) { - throw ParseException("unknown event in getEventName", s.line, s.col); + if (offset >= tagNames.size()) { + throw ParseException("unknown tag in getTagName", s.line, s.col); } - return eventNames[offset]; + return tagNames[offset]; } } @@ -2454,11 +2454,11 @@ Expression* SExpressionWasmBuilder::makeTry(Element& s) { if (inner.size() < 2) { throw ParseException("invalid catch block", inner.line, inner.col); } - Name event = getEventName(*inner[1]); - if (!wasm.getEventOrNull(event)) { - throw ParseException("bad event name", inner[1]->line, inner[1]->col); + Name tag = getTagName(*inner[1]); + if (!wasm.getTagOrNull(tag)) { + throw ParseException("bad tag name", inner[1]->line, inner[1]->col); } - ret->catchEvents.push_back(getEventName(*inner[1])); + ret->catchTags.push_back(getTagName(*inner[1])); ret->catchBodies.push_back(makeMaybeBlock(inner, 2, type)); } @@ -2505,9 +2505,9 @@ Expression* SExpressionWasmBuilder::makeThrow(Element& s) { auto ret = allocator.alloc<Throw>(); Index i = 1; - ret->event = getEventName(*s[i++]); - if (!wasm.getEventOrNull(ret->event)) { - throw ParseException("bad event name", s[1]->line, s[1]->col); + ret->tag = getTagName(*s[i++]); + if (!wasm.getTagOrNull(ret->tag)) { + throw ParseException("bad tag name", s[1]->line, s[1]->col); } for (; i < s.size(); i++) { ret->operands.push_back(parseExpression(s[i])); @@ -2955,9 +2955,9 @@ void SExpressionWasmBuilder::parseExport(Element& s) { } else if (elementStartsWith(inner, GLOBAL)) { ex->kind = ExternalKind::Global; ex->value = getGlobalName(*inner[1]); - } else if (inner[0]->str() == EVENT) { - ex->kind = ExternalKind::Event; - ex->value = getEventName(*inner[1]); + } else if (inner[0]->str() == TAG) { + ex->kind = ExternalKind::Tag; + ex->value = getTagName(*inner[1]); } else { throw ParseException("invalid export", inner.line, inner.col); } @@ -2990,8 +2990,8 @@ void SExpressionWasmBuilder::parseImport(Element& s) { kind = ExternalKind::Table; } else if (elementStartsWith(*s[3], GLOBAL)) { kind = ExternalKind::Global; - } else if ((*s[3])[0]->str() == EVENT) { - kind = ExternalKind::Event; + } else if ((*s[3])[0]->str() == TAG) { + kind = ExternalKind::Tag; } else { newStyle = false; // either (param..) or (result..) } @@ -3016,9 +3016,9 @@ void SExpressionWasmBuilder::parseImport(Element& s) { name = Name("mimport$" + std::to_string(memoryCounter++)); } else if (kind == ExternalKind::Table) { name = Name("timport$" + std::to_string(tableCounter++)); - } else if (kind == ExternalKind::Event) { - name = Name("eimport$" + std::to_string(eventCounter++)); - eventNames.push_back(name); + } else if (kind == ExternalKind::Tag) { + name = Name("eimport$" + std::to_string(tagCounter++)); + tagNames.push_back(name); } else { throw ParseException("invalid import", s[3]->line, s[3]->col); } @@ -3107,21 +3107,21 @@ void SExpressionWasmBuilder::parseImport(Element& s) { } else { j = parseMemoryLimits(inner, j); } - } else if (kind == ExternalKind::Event) { - auto event = make_unique<Event>(); + } else if (kind == ExternalKind::Tag) { + auto tag = make_unique<Tag>(); if (j >= inner.size()) { - throw ParseException("event does not have an attribute", s.line, s.col); + throw ParseException("tag does not have an attribute", s.line, s.col); } auto& attrElem = *inner[j++]; if (!elementStartsWith(attrElem, ATTR) || attrElem.size() != 2) { throw ParseException("invalid attribute", attrElem.line, attrElem.col); } - event->attribute = atoi(attrElem[1]->c_str()); - j = parseTypeUse(inner, j, event->sig); - event->setName(name, hasExplicitName); - event->module = module; - event->base = base; - wasm.addEvent(event.release()); + tag->attribute = atoi(attrElem[1]->c_str()); + j = parseTypeUse(inner, j, tag->sig); + tag->setName(name, hasExplicitName); + tag->module = module; + tag->base = base; + wasm.addTag(tag.release()); } // If there are more elements, they are invalid if (j < inner.size()) { @@ -3436,23 +3436,23 @@ HeapType SExpressionWasmBuilder::parseHeapType(Element& s) { throw ParseException("invalid heap type", s.line, s.col); } -void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) { - auto event = make_unique<Event>(); +void SExpressionWasmBuilder::parseTag(Element& s, bool preParseImport) { + auto tag = make_unique<Tag>(); size_t i = 1; // Parse name if (s[i]->isStr() && s[i]->dollared()) { auto& inner = *s[i++]; - event->setExplicitName(inner.str()); - if (wasm.getEventOrNull(event->name)) { - throw ParseException("duplicate event", inner.line, inner.col); + tag->setExplicitName(inner.str()); + if (wasm.getTagOrNull(tag->name)) { + throw ParseException("duplicate tag", inner.line, inner.col); } } else { - event->name = Name::fromInt(eventCounter); - assert(!wasm.getEventOrNull(event->name)); + tag->name = Name::fromInt(tagCounter); + assert(!wasm.getTagOrNull(tag->name)); } - eventCounter++; - eventNames.push_back(event->name); + tagCounter++; + tagNames.push_back(tag->name); // Parse import, if any if (i < s.size() && elementStartsWith(*s[i], IMPORT)) { @@ -3469,14 +3469,14 @@ void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) { throw ParseException( "invalid import base name", importElem[2]->line, importElem[2]->col); } - event->module = importElem[1]->str(); - event->base = importElem[2]->str(); + tag->module = importElem[1]->str(); + tag->base = importElem[2]->str(); } // Parse export, if any if (i < s.size() && elementStartsWith(*s[i], EXPORT)) { auto& exportElem = *s[i++]; - if (event->module.is()) { + if (tag->module.is()) { throw ParseException("import and export cannot be specified together", exportElem.line, exportElem.col); @@ -3494,13 +3494,13 @@ void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) { throw ParseException( "duplicate export", exportElem[1]->line, exportElem[1]->col); } - ex->value = event->name; - ex->kind = ExternalKind::Event; + ex->value = tag->name; + ex->kind = ExternalKind::Tag; } // Parse attribute if (i >= s.size()) { - throw ParseException("event does not have an attribute", s.line, s.col); + throw ParseException("tag does not have an attribute", s.line, s.col); } auto& attrElem = *s[i++]; if (!elementStartsWith(attrElem, ATTR) || attrElem.size() != 2) { @@ -3510,17 +3510,17 @@ void SExpressionWasmBuilder::parseEvent(Element& s, bool preParseImport) { throw ParseException( "invalid attribute", attrElem[1]->line, attrElem[1]->col); } - event->attribute = atoi(attrElem[1]->c_str()); + tag->attribute = atoi(attrElem[1]->c_str()); // Parse typeuse - i = parseTypeUse(s, i, event->sig); + i = parseTypeUse(s, i, tag->sig); // If there are more elements, they are invalid if (i < s.size()) { throw ParseException("invalid element", s[i]->line, s[i]->col); } - wasm.addEvent(event.release()); + wasm.addTag(tag.release()); } void SExpressionWasmBuilder::validateHeapTypeUsingChild(Expression* child, diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index 3200e77a7..7b682a264 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -1858,7 +1858,7 @@ void BinaryInstWriter::emitCatch(Try* curr, Index i) { parent.writeExtraDebugLocation(curr, func, i); } o << int8_t(BinaryConsts::Catch) - << U32LEB(parent.getEventIndex(curr->catchEvents[i])); + << U32LEB(parent.getTagIndex(curr->catchTags[i])); } void BinaryInstWriter::emitCatchAll(Try* curr) { @@ -1879,7 +1879,7 @@ void BinaryInstWriter::emitDelegate(Try* curr) { } void BinaryInstWriter::visitThrow(Throw* curr) { - o << int8_t(BinaryConsts::Throw) << U32LEB(parent.getEventIndex(curr->event)); + o << int8_t(BinaryConsts::Throw) << U32LEB(parent.getTagIndex(curr->tag)); } void BinaryInstWriter::visitRethrow(Rethrow* curr) { diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index d704ee15e..a42ff36ec 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2071,9 +2071,9 @@ void FunctionValidator::visitTry(Try* curr) { "unreachable try-catch must have unreachable catch body"); } } - shouldBeTrue(curr->catchBodies.size() - curr->catchEvents.size() <= 1, + shouldBeTrue(curr->catchBodies.size() - curr->catchTags.size() <= 1, curr, - "the number of catch blocks and events do not match"); + "the number of catch blocks and tags do not match"); shouldBeFalse(curr->isCatch() && curr->isDelegate(), curr, @@ -2097,21 +2097,21 @@ void FunctionValidator::visitThrow(Throw* curr) { if (!info.validateGlobally) { return; } - auto* event = getModule()->getEventOrNull(curr->event); - if (!shouldBeTrue(!!event, curr, "throw's event must exist")) { + auto* tag = getModule()->getTagOrNull(curr->tag); + if (!shouldBeTrue(!!tag, curr, "throw's tag must exist")) { return; } - if (!shouldBeTrue(curr->operands.size() == event->sig.params.size(), + if (!shouldBeTrue(curr->operands.size() == tag->sig.params.size(), curr, - "event's param numbers must match")) { + "tag's param numbers must match")) { return; } size_t i = 0; - for (const auto& param : event->sig.params) { + for (const auto& param : tag->sig.params) { if (!shouldBeSubType(curr->operands[i]->type, param, curr->operands[i], - "event param types must match") && + "tag param types must match") && !info.quiet) { getStream() << "(on argument " << i << ")\n"; } @@ -2737,10 +2737,9 @@ static void validateExports(Module& module, ValidationInfo& info) { info.shouldBeTrue(name == Name("0") || name == module.memory.name, name, "module memory exports must be found"); - } else if (exp->kind == ExternalKind::Event) { - info.shouldBeTrue(module.getEventOrNull(name), - name, - "module event exports must be found"); + } else if (exp->kind == ExternalKind::Tag) { + info.shouldBeTrue( + module.getTagOrNull(name), name, "module tag exports must be found"); } else { WASM_UNREACHABLE("invalid ExternalKind"); } @@ -2978,13 +2977,13 @@ static void validateTables(Module& module, ValidationInfo& info) { } } -static void validateEvents(Module& module, ValidationInfo& info) { - if (!module.events.empty()) { +static void validateTags(Module& module, ValidationInfo& info) { + if (!module.tags.empty()) { info.shouldBeTrue(module.features.hasExceptionHandling(), - module.events[0]->name, - "Module has events (event-handling is disabled)"); + module.tags[0]->name, + "Module has tags (exception-handling is disabled)"); } - for (auto& curr : module.events) { + for (auto& curr : module.tags) { info.shouldBeEqual(curr->attribute, (unsigned)0, curr->attribute, @@ -2992,16 +2991,16 @@ static void validateEvents(Module& module, ValidationInfo& info) { info.shouldBeEqual(curr->sig.results, Type(Type::none), curr->name, - "Event type's result type should be none"); + "Tag type's result type should be none"); if (curr->sig.params.isTuple()) { info.shouldBeTrue(module.features.hasMultivalue(), curr->name, - "Multivalue event type (multivalue is not enabled)"); + "Multivalue tag type (multivalue is not enabled)"); } for (const auto& param : curr->sig.params) { info.shouldBeTrue(param.isConcrete(), curr->name, - "Values in an event should have concrete types"); + "Values in a tag should have concrete types"); } } } @@ -3048,7 +3047,7 @@ bool WasmValidator::validate(Module& module, Flags flags) { validateGlobals(module, info); validateMemory(module, info); validateTables(module, info); - validateEvents(module, info); + validateTags(module, info); validateModule(module, info); validateFeatures(module, info); } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index f769cb1f5..ea82bac39 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -96,7 +96,7 @@ Name SPECTEST("spectest"); Name PRINT("print"); Name EXIT("exit"); Name SHARED("shared"); -Name EVENT("event"); +Name TAG("tag"); Name ATTR("attr"); // Expressions @@ -1194,8 +1194,8 @@ Global* Module::getGlobal(Name name) { return getModuleElement(globalsMap, name, "getGlobal"); } -Event* Module::getEvent(Name name) { - return getModuleElement(eventsMap, name, "getEvent"); +Tag* Module::getTag(Name name) { + return getModuleElement(tagsMap, name, "getTag"); } template<typename Map> @@ -1227,8 +1227,8 @@ Global* Module::getGlobalOrNull(Name name) { return getModuleElementOrNull(globalsMap, name); } -Event* Module::getEventOrNull(Name name) { - return getModuleElementOrNull(eventsMap, name); +Tag* Module::getTagOrNull(Name name) { + return getModuleElementOrNull(tagsMap, name); } // TODO(@warchant): refactor all usages to use variant with unique_ptr @@ -1275,8 +1275,8 @@ Global* Module::addGlobal(Global* curr) { return addModuleElement(globals, globalsMap, curr, "addGlobal"); } -Event* Module::addEvent(Event* curr) { - return addModuleElement(events, eventsMap, curr, "addEvent"); +Tag* Module::addTag(Tag* curr) { + return addModuleElement(tags, tagsMap, curr, "addTag"); } Export* Module::addExport(std::unique_ptr<Export>&& curr) { @@ -1302,8 +1302,8 @@ Global* Module::addGlobal(std::unique_ptr<Global>&& curr) { return addModuleElement(globals, globalsMap, std::move(curr), "addGlobal"); } -Event* Module::addEvent(std::unique_ptr<Event>&& curr) { - return addModuleElement(events, eventsMap, std::move(curr), "addEvent"); +Tag* Module::addTag(std::unique_ptr<Tag>&& curr) { + return addModuleElement(tags, tagsMap, std::move(curr), "addTag"); } void Module::addStart(const Name& s) { start = s; } @@ -1334,9 +1334,7 @@ void Module::removeElementSegment(Name name) { void Module::removeGlobal(Name name) { removeModuleElement(globals, globalsMap, name); } -void Module::removeEvent(Name name) { - removeModuleElement(events, eventsMap, name); -} +void Module::removeTag(Name name) { removeModuleElement(tags, tagsMap, name); } template<typename Vector, typename Map, typename Elem> void removeModuleElements(Vector& v, @@ -1369,8 +1367,8 @@ void Module::removeElementSegments(std::function<bool(ElementSegment*)> pred) { void Module::removeGlobals(std::function<bool(Global*)> pred) { removeModuleElements(globals, globalsMap, pred); } -void Module::removeEvents(std::function<bool(Event*)> pred) { - removeModuleElements(events, eventsMap, pred); +void Module::removeTags(std::function<bool(Tag*)> pred) { + removeModuleElements(tags, tagsMap, pred); } void Module::updateMaps() { @@ -1394,9 +1392,9 @@ void Module::updateMaps() { for (auto& curr : globals) { globalsMap[curr->name] = curr.get(); } - eventsMap.clear(); - for (auto& curr : events) { - eventsMap[curr->name] = curr.get(); + tagsMap.clear(); + for (auto& curr : tags) { + tagsMap[curr->name] = curr.get(); } } |