mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:07:44 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -21,7 +21,7 @@ namespace Operators {
|
|||
template<typename Lhs, typename Rhs> \
|
||||
auto operator()(Lhs lhs, Rhs rhs) const { return lhs operation rhs; } \
|
||||
\
|
||||
static StringView name() { return #operation; } \
|
||||
static StringView name() { return #operation##sv; } \
|
||||
}
|
||||
|
||||
DEFINE_BINARY_OPERATOR(Equals, ==);
|
||||
|
@ -54,7 +54,7 @@ struct Divide {
|
|||
}
|
||||
}
|
||||
|
||||
static StringView name() { return "/"; }
|
||||
static StringView name() { return "/"sv; }
|
||||
};
|
||||
struct Modulo {
|
||||
template<typename Lhs, typename Rhs>
|
||||
|
@ -69,19 +69,19 @@ struct Modulo {
|
|||
return AK::Result<Lhs, StringView>(lhs % rhs);
|
||||
}
|
||||
|
||||
static StringView name() { return "%"; }
|
||||
static StringView name() { return "%"sv; }
|
||||
};
|
||||
struct BitShiftLeft {
|
||||
template<typename Lhs, typename Rhs>
|
||||
auto operator()(Lhs lhs, Rhs rhs) const { return lhs << (rhs % (sizeof(lhs) * 8)); }
|
||||
|
||||
static StringView name() { return "<<"; }
|
||||
static StringView name() { return "<<"sv; }
|
||||
};
|
||||
struct BitShiftRight {
|
||||
template<typename Lhs, typename Rhs>
|
||||
auto operator()(Lhs lhs, Rhs rhs) const { return lhs >> (rhs % (sizeof(lhs) * 8)); }
|
||||
|
||||
static StringView name() { return ">>"; }
|
||||
static StringView name() { return ">>"sv; }
|
||||
};
|
||||
struct BitRotateLeft {
|
||||
template<typename Lhs, typename Rhs>
|
||||
|
@ -94,7 +94,7 @@ struct BitRotateLeft {
|
|||
return (lhs << rhs) | (lhs >> ((-rhs) & mask));
|
||||
}
|
||||
|
||||
static StringView name() { return "rotate_left"; }
|
||||
static StringView name() { return "rotate_left"sv; }
|
||||
};
|
||||
struct BitRotateRight {
|
||||
template<typename Lhs, typename Rhs>
|
||||
|
@ -107,7 +107,7 @@ struct BitRotateRight {
|
|||
return (lhs >> rhs) | (lhs << ((-rhs) & mask));
|
||||
}
|
||||
|
||||
static StringView name() { return "rotate_right"; }
|
||||
static StringView name() { return "rotate_right"sv; }
|
||||
};
|
||||
struct Minimum {
|
||||
template<typename Lhs, typename Rhs>
|
||||
|
@ -126,7 +126,7 @@ struct Minimum {
|
|||
return min(lhs, rhs);
|
||||
}
|
||||
|
||||
static StringView name() { return "minimum"; }
|
||||
static StringView name() { return "minimum"sv; }
|
||||
};
|
||||
struct Maximum {
|
||||
template<typename Lhs, typename Rhs>
|
||||
|
@ -145,7 +145,7 @@ struct Maximum {
|
|||
return max(lhs, rhs);
|
||||
}
|
||||
|
||||
static StringView name() { return "maximum"; }
|
||||
static StringView name() { return "maximum"sv; }
|
||||
};
|
||||
struct CopySign {
|
||||
template<typename Lhs, typename Rhs>
|
||||
|
@ -159,7 +159,7 @@ struct CopySign {
|
|||
static_assert(DependentFalse<Lhs, Rhs>, "Invalid types to CopySign");
|
||||
}
|
||||
|
||||
static StringView name() { return "copysign"; }
|
||||
static StringView name() { return "copysign"sv; }
|
||||
};
|
||||
|
||||
// Unary
|
||||
|
@ -168,7 +168,7 @@ struct EqualsZero {
|
|||
template<typename Lhs>
|
||||
auto operator()(Lhs lhs) const { return lhs == 0; }
|
||||
|
||||
static StringView name() { return "== 0"; }
|
||||
static StringView name() { return "== 0"sv; }
|
||||
};
|
||||
struct CountLeadingZeros {
|
||||
template<typename Lhs>
|
||||
|
@ -183,7 +183,7 @@ struct CountLeadingZeros {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "clz"; }
|
||||
static StringView name() { return "clz"sv; }
|
||||
};
|
||||
struct CountTrailingZeros {
|
||||
template<typename Lhs>
|
||||
|
@ -198,7 +198,7 @@ struct CountTrailingZeros {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "ctz"; }
|
||||
static StringView name() { return "ctz"sv; }
|
||||
};
|
||||
struct PopCount {
|
||||
template<typename Lhs>
|
||||
|
@ -210,19 +210,19 @@ struct PopCount {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "popcnt"; }
|
||||
static StringView name() { return "popcnt"sv; }
|
||||
};
|
||||
struct Absolute {
|
||||
template<typename Lhs>
|
||||
auto operator()(Lhs lhs) const { return AK::abs(lhs); }
|
||||
|
||||
static StringView name() { return "abs"; }
|
||||
static StringView name() { return "abs"sv; }
|
||||
};
|
||||
struct Negate {
|
||||
template<typename Lhs>
|
||||
auto operator()(Lhs lhs) const { return -lhs; }
|
||||
|
||||
static StringView name() { return "== 0"; }
|
||||
static StringView name() { return "== 0"sv; }
|
||||
};
|
||||
struct Ceil {
|
||||
template<typename Lhs>
|
||||
|
@ -236,7 +236,7 @@ struct Ceil {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "ceil"; }
|
||||
static StringView name() { return "ceil"sv; }
|
||||
};
|
||||
struct Floor {
|
||||
template<typename Lhs>
|
||||
|
@ -250,7 +250,7 @@ struct Floor {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "floor"; }
|
||||
static StringView name() { return "floor"sv; }
|
||||
};
|
||||
struct Truncate {
|
||||
template<typename Lhs>
|
||||
|
@ -264,7 +264,7 @@ struct Truncate {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "truncate"; }
|
||||
static StringView name() { return "truncate"sv; }
|
||||
};
|
||||
struct NearbyIntegral {
|
||||
template<typename Lhs>
|
||||
|
@ -278,7 +278,7 @@ struct NearbyIntegral {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "round"; }
|
||||
static StringView name() { return "round"sv; }
|
||||
};
|
||||
struct SquareRoot {
|
||||
template<typename Lhs>
|
||||
|
@ -292,7 +292,7 @@ struct SquareRoot {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static StringView name() { return "sqrt"; }
|
||||
static StringView name() { return "sqrt"sv; }
|
||||
};
|
||||
|
||||
template<typename Result>
|
||||
|
@ -303,7 +303,7 @@ struct Wrap {
|
|||
return static_cast<MakeUnsigned<Result>>(bit_cast<MakeUnsigned<Lhs>>(lhs));
|
||||
}
|
||||
|
||||
static StringView name() { return "wrap"; }
|
||||
static StringView name() { return "wrap"sv; }
|
||||
};
|
||||
|
||||
template<typename ResultT>
|
||||
|
@ -331,7 +331,7 @@ struct CheckedTruncate {
|
|||
return static_cast<ResultT>(truncated);
|
||||
}
|
||||
|
||||
static StringView name() { return "truncate.checked"; }
|
||||
static StringView name() { return "truncate.checked"sv; }
|
||||
};
|
||||
|
||||
template<typename ResultT>
|
||||
|
@ -342,7 +342,7 @@ struct Extend {
|
|||
return lhs;
|
||||
}
|
||||
|
||||
static StringView name() { return "extend"; }
|
||||
static StringView name() { return "extend"sv; }
|
||||
};
|
||||
|
||||
template<typename ResultT>
|
||||
|
@ -354,7 +354,7 @@ struct Convert {
|
|||
return static_cast<ResultT>(signed_interpretation);
|
||||
}
|
||||
|
||||
static StringView name() { return "convert"; }
|
||||
static StringView name() { return "convert"sv; }
|
||||
};
|
||||
|
||||
template<typename ResultT>
|
||||
|
@ -365,7 +365,7 @@ struct Reinterpret {
|
|||
return bit_cast<ResultT>(lhs);
|
||||
}
|
||||
|
||||
static StringView name() { return "reinterpret"; }
|
||||
static StringView name() { return "reinterpret"sv; }
|
||||
};
|
||||
|
||||
struct Promote {
|
||||
|
@ -376,7 +376,7 @@ struct Promote {
|
|||
return static_cast<double>(lhs);
|
||||
}
|
||||
|
||||
static StringView name() { return "promote"; }
|
||||
static StringView name() { return "promote"sv; }
|
||||
};
|
||||
|
||||
struct Demote {
|
||||
|
@ -391,7 +391,7 @@ struct Demote {
|
|||
return static_cast<float>(lhs);
|
||||
}
|
||||
|
||||
static StringView name() { return "demote"; }
|
||||
static StringView name() { return "demote"sv; }
|
||||
};
|
||||
|
||||
template<typename InitialType>
|
||||
|
@ -405,7 +405,7 @@ struct SignExtend {
|
|||
return static_cast<Lhs>(initial_value);
|
||||
}
|
||||
|
||||
static StringView name() { return "extend"; }
|
||||
static StringView name() { return "extend"sv; }
|
||||
};
|
||||
|
||||
template<typename ResultT>
|
||||
|
@ -439,7 +439,7 @@ struct SaturatingTruncate {
|
|||
return convert(trunc(lhs));
|
||||
}
|
||||
|
||||
static StringView name() { return "truncate.saturating"; }
|
||||
static StringView name() { return "truncate.saturating"sv; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ ErrorOr<void, ValidationError> Validator::validate(Module& module)
|
|||
if (m_context.types.size() > index.value()) {
|
||||
m_context.functions.append(m_context.types[index.value()]);
|
||||
} else {
|
||||
result = Errors::invalid("TypeIndex");
|
||||
result = Errors::invalid("TypeIndex"sv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ ErrorOr<void, ValidationError> Validator::validate(StartSection const& section)
|
|||
TRY(validate(section.function().index()));
|
||||
FunctionType const& type = m_context.functions[section.function().index().value()];
|
||||
if (!type.parameters().is_empty() || !type.results().is_empty())
|
||||
return Errors::invalid("start function signature");
|
||||
return Errors::invalid("start function signature"sv);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -186,10 +186,10 @@ ErrorOr<void, ValidationError> Validator::validate(DataSection const& section)
|
|||
auto expression_result = TRY(validate(active.offset, { ValueType(ValueType::I32) }));
|
||||
|
||||
if (!expression_result.is_constant)
|
||||
return Errors::invalid("active data initializer");
|
||||
return Errors::invalid("active data initializer"sv);
|
||||
|
||||
if (expression_result.result_types.size() != 1 || !expression_result.result_types.first().is_of_kind(ValueType::I32))
|
||||
return Errors::invalid("active data initializer type", ValueType(ValueType::I32), expression_result.result_types);
|
||||
return Errors::invalid("active data initializer type"sv, ValueType(ValueType::I32), expression_result.result_types);
|
||||
|
||||
return {};
|
||||
}));
|
||||
|
@ -208,9 +208,9 @@ ErrorOr<void, ValidationError> Validator::validate(ElementSection const& section
|
|||
TRY(validate(active.index));
|
||||
auto expression_result = TRY(validate(active.expression, { ValueType(ValueType::I32) }));
|
||||
if (!expression_result.is_constant)
|
||||
return Errors::invalid("active element initializer");
|
||||
return Errors::invalid("active element initializer"sv);
|
||||
if (expression_result.result_types.size() != 1 || !expression_result.result_types.first().is_of_kind(ValueType::I32))
|
||||
return Errors::invalid("active element initializer type", ValueType(ValueType::I32), expression_result.result_types);
|
||||
return Errors::invalid("active element initializer type"sv, ValueType(ValueType::I32), expression_result.result_types);
|
||||
return {};
|
||||
}));
|
||||
}
|
||||
|
@ -224,9 +224,9 @@ ErrorOr<void, ValidationError> Validator::validate(GlobalSection const& section)
|
|||
TRY(validate(type));
|
||||
auto expression_result = TRY(validate(entry.expression(), { type.type() }));
|
||||
if (!expression_result.is_constant)
|
||||
return Errors::invalid("global variable initializer");
|
||||
return Errors::invalid("global variable initializer"sv);
|
||||
if (expression_result.result_types.size() != 1 || !expression_result.result_types.first().is_of_kind(type.type().kind()))
|
||||
return Errors::invalid("global variable initializer type", ValueType(ValueType::I32), expression_result.result_types);
|
||||
return Errors::invalid("global variable initializer type"sv, ValueType(ValueType::I32), expression_result.result_types);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -1338,7 +1338,7 @@ VALIDATE_INSTRUCTION(ref_func)
|
|||
TRY(validate(index));
|
||||
|
||||
if (!m_context.references.contains(index))
|
||||
return Errors::invalid("function reference");
|
||||
return Errors::invalid("function reference"sv);
|
||||
|
||||
is_constant = true;
|
||||
stack.append(ValueType(ValueType::FunctionReference));
|
||||
|
@ -1363,10 +1363,10 @@ VALIDATE_INSTRUCTION(select)
|
|||
auto arg0_type = stack.take_last();
|
||||
auto& arg1_type = stack.last();
|
||||
if (!index_type.is_of_kind(ValueType::I32))
|
||||
return Errors::invalid("select index type", ValueType(ValueType::I32), index_type);
|
||||
return Errors::invalid("select index type"sv, ValueType(ValueType::I32), index_type);
|
||||
|
||||
if (arg0_type != arg1_type)
|
||||
return Errors::invalid("select argument types", Vector { arg0_type, arg0_type }, Vector { arg0_type, arg1_type });
|
||||
return Errors::invalid("select argument types"sv, Vector { arg0_type, arg0_type }, Vector { arg0_type, arg1_type });
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -1375,7 +1375,7 @@ VALIDATE_INSTRUCTION(select_typed)
|
|||
{
|
||||
auto& required_types = instruction.arguments().get<Vector<ValueType>>();
|
||||
if (required_types.size() != 1)
|
||||
return Errors::invalid("select types", "exactly one type", required_types);
|
||||
return Errors::invalid("select types"sv, "exactly one type"sv, required_types);
|
||||
|
||||
if (stack.size() < 3)
|
||||
return Errors::invalid_stack_state(stack, Tuple { ValueType(ValueType::I32), required_types.first(), required_types.first() });
|
||||
|
@ -1384,10 +1384,10 @@ VALIDATE_INSTRUCTION(select_typed)
|
|||
auto arg0_type = stack.take_last();
|
||||
auto& arg1_type = stack.last();
|
||||
if (!index_type.is_of_kind(ValueType::I32))
|
||||
return Errors::invalid("select index type", ValueType(ValueType::I32), index_type);
|
||||
return Errors::invalid("select index type"sv, ValueType(ValueType::I32), index_type);
|
||||
|
||||
if (arg0_type != arg1_type || arg0_type != required_types.first())
|
||||
return Errors::invalid("select argument types", Vector { required_types.first(), required_types.first() }, Vector { arg0_type, arg1_type });
|
||||
return Errors::invalid("select argument types"sv, Vector { required_types.first(), required_types.first() }, Vector { arg0_type, arg1_type });
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -1445,7 +1445,7 @@ VALIDATE_INSTRUCTION(global_set)
|
|||
auto& global = m_context.globals[index.value()];
|
||||
|
||||
if (!global.is_mutable())
|
||||
return Errors::invalid("global variable for global.set");
|
||||
return Errors::invalid("global variable for global.set"sv);
|
||||
|
||||
TRY(stack.take(global.type()));
|
||||
|
||||
|
@ -1525,10 +1525,10 @@ VALIDATE_INSTRUCTION(table_copy)
|
|||
auto& rhs_table = m_context.tables[args.rhs.value()];
|
||||
|
||||
if (lhs_table.element_type() != rhs_table.element_type())
|
||||
return Errors::non_conforming_types("table.copy", lhs_table.element_type(), rhs_table.element_type());
|
||||
return Errors::non_conforming_types("table.copy"sv, lhs_table.element_type(), rhs_table.element_type());
|
||||
|
||||
if (!lhs_table.element_type().is_reference())
|
||||
return Errors::invalid("table.copy element type", "a reference type", lhs_table.element_type());
|
||||
return Errors::invalid("table.copy element type"sv, "a reference type"sv, lhs_table.element_type());
|
||||
|
||||
TRY((stack.take<ValueType::I32, ValueType::I32, ValueType::I32>()));
|
||||
|
||||
|
@ -1546,7 +1546,7 @@ VALIDATE_INSTRUCTION(table_init)
|
|||
auto& element_type = m_context.elements[args.element_index.value()];
|
||||
|
||||
if (table.element_type() != element_type)
|
||||
return Errors::non_conforming_types("table.init", table.element_type(), element_type);
|
||||
return Errors::non_conforming_types("table.init"sv, table.element_type(), element_type);
|
||||
|
||||
TRY((stack.take<ValueType::I32, ValueType::I32, ValueType::I32>()));
|
||||
|
||||
|
@ -1568,7 +1568,7 @@ VALIDATE_INSTRUCTION(i32_load)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(i32))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(i32));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(i32));
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I32));
|
||||
|
@ -1581,7 +1581,7 @@ VALIDATE_INSTRUCTION(i64_load)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(i64))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(i64));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(i64));
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1594,7 +1594,7 @@ VALIDATE_INSTRUCTION(f32_load)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(float))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(float));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(float));
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::F32));
|
||||
|
@ -1607,7 +1607,7 @@ VALIDATE_INSTRUCTION(f64_load)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(double))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(double));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(double));
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::F64));
|
||||
|
@ -1620,7 +1620,7 @@ VALIDATE_INSTRUCTION(i32_load16_s)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 16 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 16 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 16 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I32));
|
||||
|
@ -1633,7 +1633,7 @@ VALIDATE_INSTRUCTION(i32_load16_u)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 16 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 16 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 16 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I32));
|
||||
|
@ -1646,7 +1646,7 @@ VALIDATE_INSTRUCTION(i32_load8_s)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 8 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 8 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 8 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I32));
|
||||
|
@ -1659,7 +1659,7 @@ VALIDATE_INSTRUCTION(i32_load8_u)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 8 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 8 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 8 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I32));
|
||||
|
@ -1672,7 +1672,7 @@ VALIDATE_INSTRUCTION(i64_load32_s)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 32 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 32 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 32 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1685,7 +1685,7 @@ VALIDATE_INSTRUCTION(i64_load32_u)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 32 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 32 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 32 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1698,7 +1698,7 @@ VALIDATE_INSTRUCTION(i64_load16_s)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 16 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 16 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 16 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1711,7 +1711,7 @@ VALIDATE_INSTRUCTION(i64_load16_u)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 16 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 16 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 16 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1724,7 +1724,7 @@ VALIDATE_INSTRUCTION(i64_load8_s)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 8 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 8 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 8 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1737,7 +1737,7 @@ VALIDATE_INSTRUCTION(i64_load8_u)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 8 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 8 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 8 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32>()));
|
||||
stack.append(ValueType(ValueType::I64));
|
||||
|
@ -1750,7 +1750,7 @@ VALIDATE_INSTRUCTION(i32_store)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(i32))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(i32));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(i32));
|
||||
|
||||
TRY((stack.take<ValueType::I32, ValueType::I32>()));
|
||||
|
||||
|
@ -1763,7 +1763,7 @@ VALIDATE_INSTRUCTION(i64_store)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(i64))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(i64));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(i64));
|
||||
|
||||
TRY((stack.take<ValueType::I64, ValueType::I32>()));
|
||||
|
||||
|
@ -1776,7 +1776,7 @@ VALIDATE_INSTRUCTION(f32_store)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(float))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(float));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(float));
|
||||
|
||||
TRY((stack.take<ValueType::F32, ValueType::I32>()));
|
||||
|
||||
|
@ -1789,7 +1789,7 @@ VALIDATE_INSTRUCTION(f64_store)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > sizeof(double))
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, sizeof(double));
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, sizeof(double));
|
||||
|
||||
TRY((stack.take<ValueType::F64, ValueType::I32>()));
|
||||
|
||||
|
@ -1802,7 +1802,7 @@ VALIDATE_INSTRUCTION(i32_store16)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 16 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 16 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 16 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32, ValueType::I32>()));
|
||||
|
||||
|
@ -1815,7 +1815,7 @@ VALIDATE_INSTRUCTION(i32_store8)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 8 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 8 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 8 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I32, ValueType::I32>()));
|
||||
|
||||
|
@ -1828,7 +1828,7 @@ VALIDATE_INSTRUCTION(i64_store32)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 32 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 32 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 32 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I64, ValueType::I32>()));
|
||||
|
||||
|
@ -1841,7 +1841,7 @@ VALIDATE_INSTRUCTION(i64_store16)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 16 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 16 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 16 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I64, ValueType::I32>()));
|
||||
|
||||
|
@ -1854,7 +1854,7 @@ VALIDATE_INSTRUCTION(i64_store8)
|
|||
|
||||
auto& arg = instruction.arguments().get<Instruction::MemoryArgument>();
|
||||
if ((1ull << arg.align) > 8 / 8)
|
||||
return Errors::out_of_bounds("memory op alignment", 1ull << arg.align, 0, 8 / 8);
|
||||
return Errors::out_of_bounds("memory op alignment"sv, 1ull << arg.align, 0, 8 / 8);
|
||||
|
||||
TRY((stack.take<ValueType::I64, ValueType::I32>()));
|
||||
|
||||
|
@ -1925,7 +1925,7 @@ VALIDATE_INSTRUCTION(unreachable)
|
|||
VALIDATE_INSTRUCTION(structured_end)
|
||||
{
|
||||
if (m_entered_scopes.is_empty())
|
||||
return Errors::invalid("usage of structured end");
|
||||
return Errors::invalid("usage of structured end"sv);
|
||||
|
||||
auto last_scope = m_entered_scopes.take_last();
|
||||
m_context = m_parent_contexts.take_last();
|
||||
|
@ -1938,7 +1938,7 @@ VALIDATE_INSTRUCTION(structured_end)
|
|||
m_block_details.take_last();
|
||||
break;
|
||||
case ChildScopeKind::IfWithElse:
|
||||
return Errors::invalid("usage of if without an else clause that appears to have one anyway");
|
||||
return Errors::invalid("usage of if without an else clause that appears to have one anyway"sv);
|
||||
}
|
||||
|
||||
auto& results = last_block_type.results();
|
||||
|
@ -1955,10 +1955,10 @@ VALIDATE_INSTRUCTION(structured_end)
|
|||
VALIDATE_INSTRUCTION(structured_else)
|
||||
{
|
||||
if (m_entered_scopes.is_empty())
|
||||
return Errors::invalid("usage of structured else");
|
||||
return Errors::invalid("usage of structured else"sv);
|
||||
|
||||
if (m_entered_scopes.last() != ChildScopeKind::IfWithElse)
|
||||
return Errors::invalid("usage of structured else");
|
||||
return Errors::invalid("usage of structured else"sv);
|
||||
|
||||
auto& block_type = m_entered_blocks.last();
|
||||
auto& results = block_type.results();
|
||||
|
@ -2108,7 +2108,7 @@ VALIDATE_INSTRUCTION(br_table)
|
|||
VALIDATE_INSTRUCTION(return_)
|
||||
{
|
||||
if (!m_context.return_.has_value())
|
||||
return Errors::invalid("use of return outside function");
|
||||
return Errors::invalid("use of return outside function"sv);
|
||||
|
||||
auto& return_types = m_context.return_->types();
|
||||
for (size_t i = 0; i < return_types.size(); ++i)
|
||||
|
@ -2142,7 +2142,7 @@ VALIDATE_INSTRUCTION(call_indirect)
|
|||
|
||||
auto& table = m_context.tables[args.table.value()];
|
||||
if (!table.element_type().is_reference())
|
||||
return Errors::invalid("table element type for call.indirect", "a reference type", table.element_type());
|
||||
return Errors::invalid("table element type for call.indirect"sv, "a reference type"sv, table.element_type());
|
||||
|
||||
auto& type = m_context.types[args.type.value()];
|
||||
|
||||
|
@ -2170,7 +2170,7 @@ ErrorOr<void, ValidationError> Validator::validate(Instruction const& instructio
|
|||
#undef M
|
||||
default:
|
||||
is_constant = false;
|
||||
return Errors::invalid("instruction opcode");
|
||||
return Errors::invalid("instruction opcode"sv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,11 +200,11 @@ public:
|
|||
ErrorOr<void, ValidationError> take(ValueType type, SourceLocation location = SourceLocation::current())
|
||||
{
|
||||
if (is_empty())
|
||||
return Errors::invalid("stack state", type, "<nothing>", location);
|
||||
return Errors::invalid("stack state"sv, type, "<nothing>"sv, location);
|
||||
|
||||
auto type_on_stack = take_last();
|
||||
if (type_on_stack != type)
|
||||
return Errors::invalid("stack state", type, type_on_stack, location);
|
||||
return Errors::invalid("stack state"sv, type, type_on_stack, location);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -287,13 +287,13 @@ private:
|
|||
else
|
||||
builder.appendff("Invalid stack state in <unknown>: ");
|
||||
|
||||
builder.append("Expected [ ");
|
||||
builder.append("Expected [ "sv);
|
||||
|
||||
expected.apply_as_args([&]<typename... Ts>(Ts const&... args) {
|
||||
(builder.appendff("{} ", args), ...);
|
||||
});
|
||||
|
||||
builder.append("], but found [ ");
|
||||
builder.append("], but found [ "sv);
|
||||
|
||||
auto actual_size = stack.actual_size();
|
||||
for (size_t i = 1; i <= min(count, actual_size); ++i) {
|
||||
|
|
|
@ -117,7 +117,7 @@ static ParseResult<ParseUntilAnyOfResult<T>> parse_until_any_of(InputStream& str
|
|||
|
||||
ParseResult<ValueType> ValueType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ValueType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ValueType"sv);
|
||||
u8 tag;
|
||||
stream >> tag;
|
||||
if (stream.has_any_error())
|
||||
|
@ -142,7 +142,7 @@ ParseResult<ValueType> ValueType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<ResultType> ResultType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ResultType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ResultType"sv);
|
||||
auto types = parse_vector<ValueType>(stream);
|
||||
if (types.is_error())
|
||||
return types.error();
|
||||
|
@ -151,7 +151,7 @@ ParseResult<ResultType> ResultType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<FunctionType> FunctionType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("FunctionType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("FunctionType"sv);
|
||||
u8 tag;
|
||||
stream >> tag;
|
||||
if (stream.has_any_error())
|
||||
|
@ -174,7 +174,7 @@ ParseResult<FunctionType> FunctionType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<Limits> Limits::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Limits");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Limits"sv);
|
||||
u8 flag;
|
||||
stream >> flag;
|
||||
if (stream.has_any_error())
|
||||
|
@ -200,7 +200,7 @@ ParseResult<Limits> Limits::parse(InputStream& stream)
|
|||
|
||||
ParseResult<MemoryType> MemoryType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("MemoryType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("MemoryType"sv);
|
||||
auto limits_result = Limits::parse(stream);
|
||||
if (limits_result.is_error())
|
||||
return limits_result.error();
|
||||
|
@ -209,7 +209,7 @@ ParseResult<MemoryType> MemoryType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<TableType> TableType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("TableType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("TableType"sv);
|
||||
auto type_result = ValueType::parse(stream);
|
||||
if (type_result.is_error())
|
||||
return type_result.error();
|
||||
|
@ -223,7 +223,7 @@ ParseResult<TableType> TableType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<GlobalType> GlobalType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("GlobalType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("GlobalType"sv);
|
||||
auto type_result = ValueType::parse(stream);
|
||||
if (type_result.is_error())
|
||||
return type_result.error();
|
||||
|
@ -241,7 +241,7 @@ ParseResult<GlobalType> GlobalType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<BlockType> BlockType::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("BlockType");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("BlockType"sv);
|
||||
u8 kind;
|
||||
stream >> kind;
|
||||
if (stream.has_any_error())
|
||||
|
@ -277,7 +277,7 @@ ParseResult<BlockType> BlockType::parse(InputStream& stream)
|
|||
|
||||
ParseResult<Vector<Instruction>> Instruction::parse(InputStream& stream, InstructionPointer& ip)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Instruction");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Instruction"sv);
|
||||
u8 byte;
|
||||
stream >> byte;
|
||||
if (stream.has_any_error())
|
||||
|
@ -733,7 +733,7 @@ ParseResult<Vector<Instruction>> Instruction::parse(InputStream& stream, Instruc
|
|||
|
||||
ParseResult<CustomSection> CustomSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("CustomSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("CustomSection"sv);
|
||||
auto name = parse_name(stream);
|
||||
if (name.is_error())
|
||||
return name.error();
|
||||
|
@ -756,7 +756,7 @@ ParseResult<CustomSection> CustomSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<TypeSection> TypeSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("TypeSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("TypeSection"sv);
|
||||
auto types = parse_vector<FunctionType>(stream);
|
||||
if (types.is_error())
|
||||
return types.error();
|
||||
|
@ -765,7 +765,7 @@ ParseResult<TypeSection> TypeSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<ImportSection::Import> ImportSection::Import::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Import");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Import"sv);
|
||||
auto module = parse_name(stream);
|
||||
if (module.is_error())
|
||||
return module.error();
|
||||
|
@ -797,7 +797,7 @@ ParseResult<ImportSection::Import> ImportSection::Import::parse(InputStream& str
|
|||
|
||||
ParseResult<ImportSection> ImportSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ImportSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ImportSection"sv);
|
||||
auto imports = parse_vector<Import>(stream);
|
||||
if (imports.is_error())
|
||||
return imports.error();
|
||||
|
@ -806,7 +806,7 @@ ParseResult<ImportSection> ImportSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<FunctionSection> FunctionSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("FunctionSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("FunctionSection"sv);
|
||||
auto indices = parse_vector<size_t>(stream);
|
||||
if (indices.is_error())
|
||||
return indices.error();
|
||||
|
@ -821,7 +821,7 @@ ParseResult<FunctionSection> FunctionSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<TableSection::Table> TableSection::Table::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Table");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Table"sv);
|
||||
auto type = TableType::parse(stream);
|
||||
if (type.is_error())
|
||||
return type.error();
|
||||
|
@ -830,7 +830,7 @@ ParseResult<TableSection::Table> TableSection::Table::parse(InputStream& stream)
|
|||
|
||||
ParseResult<TableSection> TableSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("TableSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("TableSection"sv);
|
||||
auto tables = parse_vector<Table>(stream);
|
||||
if (tables.is_error())
|
||||
return tables.error();
|
||||
|
@ -839,7 +839,7 @@ ParseResult<TableSection> TableSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<MemorySection::Memory> MemorySection::Memory::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Memory");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Memory"sv);
|
||||
auto type = MemoryType::parse(stream);
|
||||
if (type.is_error())
|
||||
return type.error();
|
||||
|
@ -848,7 +848,7 @@ ParseResult<MemorySection::Memory> MemorySection::Memory::parse(InputStream& str
|
|||
|
||||
ParseResult<MemorySection> MemorySection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("MemorySection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("MemorySection"sv);
|
||||
auto memories = parse_vector<Memory>(stream);
|
||||
if (memories.is_error())
|
||||
return memories.error();
|
||||
|
@ -857,7 +857,7 @@ ParseResult<MemorySection> MemorySection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<Expression> Expression::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Expression");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Expression"sv);
|
||||
InstructionPointer ip { 0 };
|
||||
auto instructions = parse_until_any_of<Instruction, 0x0b>(stream, ip);
|
||||
if (instructions.is_error())
|
||||
|
@ -868,7 +868,7 @@ ParseResult<Expression> Expression::parse(InputStream& stream)
|
|||
|
||||
ParseResult<GlobalSection::Global> GlobalSection::Global::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Global");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Global"sv);
|
||||
auto type = GlobalType::parse(stream);
|
||||
if (type.is_error())
|
||||
return type.error();
|
||||
|
@ -880,7 +880,7 @@ ParseResult<GlobalSection::Global> GlobalSection::Global::parse(InputStream& str
|
|||
|
||||
ParseResult<GlobalSection> GlobalSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("GlobalSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("GlobalSection"sv);
|
||||
auto result = parse_vector<Global>(stream);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -889,7 +889,7 @@ ParseResult<GlobalSection> GlobalSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<ExportSection::Export> ExportSection::Export::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Export");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Export"sv);
|
||||
auto name = parse_name(stream);
|
||||
if (name.is_error())
|
||||
return name.error();
|
||||
|
@ -918,7 +918,7 @@ ParseResult<ExportSection::Export> ExportSection::Export::parse(InputStream& str
|
|||
|
||||
ParseResult<ExportSection> ExportSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ExportSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ExportSection"sv);
|
||||
auto result = parse_vector<Export>(stream);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -927,7 +927,7 @@ ParseResult<ExportSection> ExportSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<StartSection::StartFunction> StartSection::StartFunction::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("StartFunction");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("StartFunction"sv);
|
||||
auto index = GenericIndexParser<FunctionIndex>::parse(stream);
|
||||
if (index.is_error())
|
||||
return index.error();
|
||||
|
@ -936,7 +936,7 @@ ParseResult<StartSection::StartFunction> StartSection::StartFunction::parse(Inpu
|
|||
|
||||
ParseResult<StartSection> StartSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("StartSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("StartSection"sv);
|
||||
auto result = StartFunction::parse(stream);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -1014,7 +1014,7 @@ ParseResult<ElementSection::SegmentType7> ElementSection::SegmentType7::parse(In
|
|||
|
||||
ParseResult<ElementSection::Element> ElementSection::Element::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Element");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Element"sv);
|
||||
u8 tag;
|
||||
stream >> tag;
|
||||
if (stream.has_any_error())
|
||||
|
@ -1082,7 +1082,7 @@ ParseResult<ElementSection::Element> ElementSection::Element::parse(InputStream&
|
|||
|
||||
ParseResult<ElementSection> ElementSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ElementSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("ElementSection"sv);
|
||||
auto result = parse_vector<Element>(stream);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -1091,7 +1091,7 @@ ParseResult<ElementSection> ElementSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<Locals> Locals::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Locals");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Locals"sv);
|
||||
size_t count;
|
||||
if (!LEB128::read_unsigned(stream, count))
|
||||
return with_eof_check(stream, ParseError::InvalidSize);
|
||||
|
@ -1108,7 +1108,7 @@ ParseResult<Locals> Locals::parse(InputStream& stream)
|
|||
|
||||
ParseResult<CodeSection::Func> CodeSection::Func::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Func");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Func"sv);
|
||||
auto locals = parse_vector<Locals>(stream);
|
||||
if (locals.is_error())
|
||||
return locals.error();
|
||||
|
@ -1120,7 +1120,7 @@ ParseResult<CodeSection::Func> CodeSection::Func::parse(InputStream& stream)
|
|||
|
||||
ParseResult<CodeSection::Code> CodeSection::Code::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Code");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Code"sv);
|
||||
size_t size;
|
||||
if (!LEB128::read_unsigned(stream, size))
|
||||
return with_eof_check(stream, ParseError::InvalidSize);
|
||||
|
@ -1141,7 +1141,7 @@ ParseResult<CodeSection::Code> CodeSection::Code::parse(InputStream& stream)
|
|||
|
||||
ParseResult<CodeSection> CodeSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("CodeSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("CodeSection"sv);
|
||||
auto result = parse_vector<Code>(stream);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -1150,7 +1150,7 @@ ParseResult<CodeSection> CodeSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<DataSection::Data> DataSection::Data::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Data");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Data"sv);
|
||||
u8 tag;
|
||||
stream >> tag;
|
||||
if (stream.has_any_error())
|
||||
|
@ -1191,7 +1191,7 @@ ParseResult<DataSection::Data> DataSection::Data::parse(InputStream& stream)
|
|||
|
||||
ParseResult<DataSection> DataSection::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("DataSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("DataSection"sv);
|
||||
auto data = parse_vector<Data>(stream);
|
||||
if (data.is_error())
|
||||
return data.error();
|
||||
|
@ -1201,7 +1201,7 @@ ParseResult<DataSection> DataSection::parse(InputStream& stream)
|
|||
|
||||
ParseResult<DataCountSection> DataCountSection::parse([[maybe_unused]] InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("DataCountSection");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("DataCountSection"sv);
|
||||
u32 value;
|
||||
if (!LEB128::read_unsigned(stream, value)) {
|
||||
if (stream.unreliable_eof()) {
|
||||
|
@ -1216,7 +1216,7 @@ ParseResult<DataCountSection> DataCountSection::parse([[maybe_unused]] InputStre
|
|||
|
||||
ParseResult<Module> Module::parse(InputStream& stream)
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Module");
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger("Module"sv);
|
||||
u8 buf[4];
|
||||
if (!stream.read_or_error({ buf, 4 }))
|
||||
return with_eof_check(stream, ParseError::InvalidInput);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue