mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:57:35 +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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue