Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rawValue: number | string,
instructionType: Valtype = "i32"
): NumericLiteral {
const original = rawValue;
// Remove numeric separators _
if (typeof rawValue === "string") {
rawValue = rawValue.replace(/_/g, "");
}
if (typeof rawValue === "number") {
return numberLiteral(rawValue, String(original));
} else {
switch (instructionType) {
case "i32": {
return numberLiteral(parse32I(rawValue), String(original));
}
case "u32": {
return numberLiteral(parseU32(rawValue), String(original));
}
case "i64": {
return longNumberLiteral(parse64I(rawValue), String(original));
}
case "f32": {
return floatLiteral(
parse32F(rawValue),
isNanLiteral(rawValue),
isInfLiteral(rawValue),
String(original)
);
}
// f64
export function numberLiteralFromRaw(rawValue) {
var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32";
var original = rawValue; // Remove numeric separators _
if (typeof rawValue === "string") {
rawValue = rawValue.replace(/_/g, "");
}
if (typeof rawValue === "number") {
return numberLiteral(rawValue, String(original));
} else {
switch (instructionType) {
case "i32":
{
return numberLiteral(parse32I(rawValue), String(original));
}
case "u32":
{
return numberLiteral(parseU32(rawValue), String(original));
}
case "i64":
{
return longNumberLiteral(parse64I(rawValue), String(original));
}
case "f32":
{
return floatLiteral(parse32F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original));
}