summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/context-decls.cpp6
-rw-r--r--src/parser/contexts.h14
-rw-r--r--src/parser/parsers.h48
3 files changed, 35 insertions, 33 deletions
diff --git a/src/parser/context-decls.cpp b/src/parser/context-decls.cpp
index 8e9638ae7..c124689d3 100644
--- a/src/parser/context-decls.cpp
+++ b/src/parser/context-decls.cpp
@@ -84,7 +84,7 @@ Result<Table*> ParseDeclsCtx::addTableDecl(Index pos,
ImportNames* importNames,
TableType type) {
auto t = std::make_unique<Table>();
- t->indexType = type.indexType;
+ t->addressType = type.addressType;
t->initial = type.limits.initial;
t->max = type.limits.max ? *type.limits.max : Table::kUnlimitedSize;
if (name.is()) {
@@ -139,7 +139,7 @@ Result<Memory*> ParseDeclsCtx::addMemoryDecl(Index pos,
ImportNames* importNames,
MemType type) {
auto m = std::make_unique<Memory>();
- m->indexType = type.indexType;
+ m->addressType = type.addressType;
m->initial = type.limits.initial;
m->max = type.limits.max ? *type.limits.max : Memory::kUnlimitedSize;
m->shared = type.shared;
@@ -178,7 +178,7 @@ Result<> ParseDeclsCtx::addImplicitData(DataStringT&& data) {
auto d = std::make_unique<DataSegment>();
d->memory = mem.name;
d->isPassive = false;
- d->offset = Builder(wasm).makeConstPtr(0, mem.indexType);
+ d->offset = Builder(wasm).makeConstPtr(0, mem.addressType);
d->data = std::move(data);
d->name = Names::getValidDataSegmentName(wasm, "implicit-data");
wasm.addDataSegment(std::move(d));
diff --git a/src/parser/contexts.h b/src/parser/contexts.h
index b0cd1458b..807b6c003 100644
--- a/src/parser/contexts.h
+++ b/src/parser/contexts.h
@@ -46,7 +46,7 @@ struct Limits {
};
struct MemType {
- Type indexType;
+ Type addressType;
Limits limits;
bool shared;
};
@@ -57,7 +57,7 @@ struct Memarg {
};
struct TableType {
- Type indexType;
+ Type addressType;
Limits limits;
};
@@ -965,8 +965,8 @@ struct ParseDeclsCtx : NullTypeParserCtx, NullInstrParserCtx {
Limits getLimitsFromElems(Index elems) { return {elems, elems}; }
- TableType makeTableType(Type indexType, Limits limits, TypeT) {
- return {indexType, limits};
+ TableType makeTableType(Type addressType, Limits limits, TypeT) {
+ return {addressType, limits};
}
std::vector<char> makeDataString() { return {}; }
@@ -979,8 +979,8 @@ struct ParseDeclsCtx : NullTypeParserCtx, NullInstrParserCtx {
return {size, size};
}
- MemType makeMemType(Type indexType, Limits limits, bool shared) {
- return {indexType, limits, shared};
+ MemType makeMemType(Type addressType, Limits limits, bool shared) {
+ return {addressType, limits, shared};
}
Result<TypeUseT>
@@ -1273,7 +1273,7 @@ struct ParseModuleTypesCtx : TypeParserCtx<ParseModuleTypesCtx>,
LimitsT getLimitsFromElems(ElemListT) { return Ok{}; }
- Type makeTableType(Type indexType, LimitsT, Type type) { return type; }
+ Type makeTableType(Type addressType, LimitsT, Type type) { return type; }
LimitsT getLimitsFromData(DataStringT) { return Ok{}; }
MemTypeT makeMemType(Type, LimitsT, bool) { return Ok{}; }
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index 02c2e9e47..b6699aab6 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -47,10 +47,10 @@ template<typename Ctx> Result<typename Ctx::LimitsT> limits32(Ctx&);
template<typename Ctx> Result<typename Ctx::LimitsT> limits64(Ctx&);
template<typename Ctx> Result<typename Ctx::MemTypeT> memtype(Ctx&);
template<typename Ctx>
-Result<typename Ctx::MemTypeT> memtypeContinued(Ctx&, Type indexType);
+Result<typename Ctx::MemTypeT> memtypeContinued(Ctx&, Type addressType);
template<typename Ctx> Result<typename Ctx::TableTypeT> tabletype(Ctx&);
template<typename Ctx>
-Result<typename Ctx::TableTypeT> tabletypeContinued(Ctx&, Type indexType);
+Result<typename Ctx::TableTypeT> tabletypeContinued(Ctx&, Type addressType);
template<typename Ctx> Result<typename Ctx::GlobalTypeT> globaltype(Ctx&);
template<typename Ctx> Result<uint32_t> tupleArity(Ctx&);
@@ -780,45 +780,46 @@ template<typename Ctx> Result<typename Ctx::LimitsT> limits64(Ctx& ctx) {
// note: the index type 'i32' or 'i64' is already parsed to simplify parsing of
// memory abbreviations.
template<typename Ctx> Result<typename Ctx::MemTypeT> memtype(Ctx& ctx) {
- Type indexType = Type::i32;
+ Type addressType = Type::i32;
if (ctx.in.takeKeyword("i64"sv)) {
- indexType = Type::i64;
+ addressType = Type::i64;
} else {
ctx.in.takeKeyword("i32"sv);
}
- return memtypeContinued(ctx, indexType);
+ return memtypeContinued(ctx, addressType);
}
template<typename Ctx>
-Result<typename Ctx::MemTypeT> memtypeContinued(Ctx& ctx, Type indexType) {
- assert(indexType == Type::i32 || indexType == Type::i64);
- auto limits = indexType == Type::i32 ? limits32(ctx) : limits64(ctx);
+Result<typename Ctx::MemTypeT> memtypeContinued(Ctx& ctx, Type addressType) {
+ assert(addressType == Type::i32 || addressType == Type::i64);
+ auto limits = addressType == Type::i32 ? limits32(ctx) : limits64(ctx);
CHECK_ERR(limits);
bool shared = false;
if (ctx.in.takeKeyword("shared"sv)) {
shared = true;
}
- return ctx.makeMemType(indexType, *limits, shared);
+ return ctx.makeMemType(addressType, *limits, shared);
}
// tabletype ::= (limits32 | 'i32' limits32 | 'i64' limit64) reftype
template<typename Ctx> Result<typename Ctx::TableTypeT> tabletype(Ctx& ctx) {
- Type indexType = Type::i32;
+ Type addressType = Type::i32;
if (ctx.in.takeKeyword("i64"sv)) {
- indexType = Type::i64;
+ addressType = Type::i64;
} else {
ctx.in.takeKeyword("i32"sv);
}
- return tabletypeContinued(ctx, indexType);
+ return tabletypeContinued(ctx, addressType);
}
template<typename Ctx>
-Result<typename Ctx::TableTypeT> tabletypeContinued(Ctx& ctx, Type indexType) {
- auto limits = indexType == Type::i32 ? limits32(ctx) : limits64(ctx);
+Result<typename Ctx::TableTypeT> tabletypeContinued(Ctx& ctx,
+ Type addressType) {
+ auto limits = addressType == Type::i32 ? limits32(ctx) : limits64(ctx);
CHECK_ERR(limits);
auto type = reftype(ctx);
CHECK_ERR(type);
- return ctx.makeTableType(indexType, *limits, *type);
+ return ctx.makeTableType(addressType, *limits, *type);
}
// globaltype ::= t:valtype => const t
@@ -3036,9 +3037,9 @@ template<typename Ctx> MaybeResult<> table(Ctx& ctx) {
auto import = inlineImport(ctx.in);
CHECK_ERR(import);
- auto indexType = Type::i32;
+ auto addressType = Type::i32;
if (ctx.in.takeKeyword("i64"sv)) {
- indexType = Type::i64;
+ addressType = Type::i64;
} else {
ctx.in.takeKeyword("i32"sv);
}
@@ -3077,10 +3078,10 @@ template<typename Ctx> MaybeResult<> table(Ctx& ctx) {
if (!ctx.in.takeRParen()) {
return ctx.in.err("expected end of inline elems");
}
- ttype = ctx.makeTableType(indexType, ctx.getLimitsFromElems(list), *type);
+ ttype = ctx.makeTableType(addressType, ctx.getLimitsFromElems(list), *type);
elems = std::move(list);
} else {
- auto tabtype = tabletypeContinued(ctx, indexType);
+ auto tabtype = tabletypeContinued(ctx, addressType);
CHECK_ERR(tabtype);
ttype = *tabtype;
}
@@ -3119,9 +3120,9 @@ template<typename Ctx> MaybeResult<> memory(Ctx& ctx) {
auto import = inlineImport(ctx.in);
CHECK_ERR(import);
- auto indexType = Type::i32;
+ auto addressType = Type::i32;
if (ctx.in.takeKeyword("i64"sv)) {
- indexType = Type::i64;
+ addressType = Type::i64;
} else {
ctx.in.takeKeyword("i32"sv);
}
@@ -3137,10 +3138,11 @@ template<typename Ctx> MaybeResult<> memory(Ctx& ctx) {
if (!ctx.in.takeRParen()) {
return ctx.in.err("expected end of inline data");
}
- mtype = ctx.makeMemType(indexType, ctx.getLimitsFromData(*datastr), false);
+ mtype =
+ ctx.makeMemType(addressType, ctx.getLimitsFromData(*datastr), false);
data = *datastr;
} else {
- auto type = memtypeContinued(ctx, indexType);
+ auto type = memtypeContinued(ctx, addressType);
CHECK_ERR(type);
mtype = *type;
}