mirror of
https://github.com/fluencelabs/marine.git
synced 2025-06-17 08:51:30 +00:00
Improve arrays and record passing scheme (#76)
This commit is contained in:
@ -37,12 +37,16 @@ pub(crate) fn ptype_to_itype_checked(
|
||||
ParsedType::U64(_) => Ok(IType::U64),
|
||||
ParsedType::F32(_) => Ok(IType::F32),
|
||||
ParsedType::F64(_) => Ok(IType::F64),
|
||||
ParsedType::Boolean(_) => Ok(IType::I32),
|
||||
ParsedType::Boolean(_) => Ok(IType::Boolean),
|
||||
ParsedType::Utf8Str(_) => Ok(IType::String),
|
||||
ParsedType::Utf8String(_) => Ok(IType::String),
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let array_itype = ptype_to_itype_checked(ty, wit_resolver)?;
|
||||
Ok(IType::Array(Box::new(array_itype)))
|
||||
if let IType::U8 = array_itype {
|
||||
Ok(IType::ByteArray)
|
||||
} else {
|
||||
Ok(IType::Array(Box::new(array_itype)))
|
||||
}
|
||||
}
|
||||
ParsedType::Record(record_name, _) => {
|
||||
let record_type_id = wit_resolver.get_record_type_id(record_name)?;
|
||||
@ -66,12 +70,16 @@ pub(crate) fn ptype_to_itype_unchecked(
|
||||
ParsedType::U64(_) => IType::U64,
|
||||
ParsedType::F32(_) => IType::F32,
|
||||
ParsedType::F64(_) => IType::F64,
|
||||
ParsedType::Boolean(_) => IType::I32,
|
||||
ParsedType::Boolean(_) => IType::Boolean,
|
||||
ParsedType::Utf8Str(_) => IType::String,
|
||||
ParsedType::Utf8String(_) => IType::String,
|
||||
ParsedType::Vector(ty, _) => {
|
||||
let array_itype = ptype_to_itype_unchecked(ty, wit_resolver);
|
||||
IType::Array(Box::new(array_itype))
|
||||
if let IType::U8 = array_itype {
|
||||
IType::ByteArray
|
||||
} else {
|
||||
IType::Array(Box::new(array_itype))
|
||||
}
|
||||
}
|
||||
ParsedType::Record(record_name, _) => {
|
||||
let record_type_id = wit_resolver.get_record_type_id_unchecked(record_name);
|
||||
|
Reference in New Issue
Block a user