Skip to content

Commit eb3c0c9

Browse files
greenhatbitwalker
authored andcommitted
fix: after rebase, add Wasm CM record type conversion,
temporary use of u64 for Felt in WIT.
1 parent 30d8b9f commit eb3c0c9

File tree

11 files changed

+1422
-1306
lines changed

11 files changed

+1422
-1306
lines changed

frontend-wasm/src/component/types/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ impl TypeInformation {
17271727

17281728
pub fn interface_type_to_ir(
17291729
ty: &InterfaceType,
1730-
_component_types: &ComponentTypes,
1730+
component_types: &ComponentTypes,
17311731
) -> miden_hir_type::Type {
17321732
match ty {
17331733
InterfaceType::Bool => miden_hir_type::Type::I1,
@@ -1743,14 +1743,20 @@ pub fn interface_type_to_ir(
17431743
InterfaceType::Float64 => todo!(),
17441744
InterfaceType::Char => todo!(),
17451745
InterfaceType::String => todo!(),
1746-
InterfaceType::Record(_) => todo!(),
1746+
InterfaceType::Record(idx) => {
1747+
let tys = component_types.records[*idx]
1748+
.fields
1749+
.iter()
1750+
.map(|f| interface_type_to_ir(&f.ty, component_types));
1751+
miden_hir_type::Type::Struct(miden_hir_type::StructType::new(tys))
1752+
}
17471753
InterfaceType::Variant(_) => todo!(),
17481754
InterfaceType::List(_) => todo!(),
17491755
InterfaceType::Tuple(tuple_idx) => {
1750-
let tys = _component_types.tuples[*tuple_idx]
1756+
let tys = component_types.tuples[*tuple_idx]
17511757
.types
17521758
.iter()
1753-
.map(|t| interface_type_to_ir(t, _component_types));
1759+
.map(|t| interface_type_to_ir(t, component_types));
17541760
miden_hir_type::Type::Struct(miden_hir_type::StructType::new(tys))
17551761
}
17561762
InterfaceType::Flags(_) => todo!(),

frontend-wasm/src/config.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use std::borrow::Cow;
1+
use alloc::{borrow::Cow, collections::BTreeMap};
22

33
use miden_core::crypto::hash::RpoDigest;
44
use miden_hir::{FunctionExportName, FunctionInvocationMethod, InterfaceFunctionIdent};
5-
use rustc_hash::FxHashMap;
65

76
/// Represents Miden VM codegen metadata for a function import.
87
/// This struct will have more fields in the future e.g. where the function
@@ -42,10 +41,10 @@ pub struct WasmTranslationConfig {
4241
/// Import metadata for MAST hashes, calling convention, of
4342
/// each imported function. Having it here might be a temporary solution,
4443
/// later we might want to move it to Wasm custom section.
45-
pub import_metadata: FxHashMap<InterfaceFunctionIdent, ImportMetadata>,
44+
pub import_metadata: BTreeMap<InterfaceFunctionIdent, ImportMetadata>,
4645

4746
/// Export metadata for calling convention, etc.
48-
pub export_metadata: FxHashMap<FunctionExportName, ExportMetadata>,
47+
pub export_metadata: BTreeMap<FunctionExportName, ExportMetadata>,
4948
}
5049

5150
impl Default for WasmTranslationConfig {

0 commit comments

Comments
 (0)