Skip to content

Commit

Permalink
fix: after rebase, add Wasm CM record type conversion,
Browse files Browse the repository at this point in the history
temporary use of u64 for Felt in WIT.
  • Loading branch information
greenhat authored and bitwalker committed Mar 15, 2024
1 parent 30d8b9f commit eb3c0c9
Show file tree
Hide file tree
Showing 11 changed files with 1,422 additions and 1,306 deletions.
14 changes: 10 additions & 4 deletions frontend-wasm/src/component/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ impl TypeInformation {

pub fn interface_type_to_ir(
ty: &InterfaceType,
_component_types: &ComponentTypes,
component_types: &ComponentTypes,
) -> miden_hir_type::Type {
match ty {
InterfaceType::Bool => miden_hir_type::Type::I1,
Expand All @@ -1743,14 +1743,20 @@ pub fn interface_type_to_ir(
InterfaceType::Float64 => todo!(),
InterfaceType::Char => todo!(),
InterfaceType::String => todo!(),
InterfaceType::Record(_) => todo!(),
InterfaceType::Record(idx) => {
let tys = component_types.records[*idx]
.fields
.iter()
.map(|f| interface_type_to_ir(&f.ty, component_types));
miden_hir_type::Type::Struct(miden_hir_type::StructType::new(tys))
}
InterfaceType::Variant(_) => todo!(),
InterfaceType::List(_) => todo!(),
InterfaceType::Tuple(tuple_idx) => {
let tys = _component_types.tuples[*tuple_idx]
let tys = component_types.tuples[*tuple_idx]
.types
.iter()
.map(|t| interface_type_to_ir(t, _component_types));
.map(|t| interface_type_to_ir(t, component_types));
miden_hir_type::Type::Struct(miden_hir_type::StructType::new(tys))
}
InterfaceType::Flags(_) => todo!(),
Expand Down
7 changes: 3 additions & 4 deletions frontend-wasm/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::borrow::Cow;
use alloc::{borrow::Cow, collections::BTreeMap};

use miden_core::crypto::hash::RpoDigest;
use miden_hir::{FunctionExportName, FunctionInvocationMethod, InterfaceFunctionIdent};
use rustc_hash::FxHashMap;

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

/// Export metadata for calling convention, etc.
pub export_metadata: FxHashMap<FunctionExportName, ExportMetadata>,
pub export_metadata: BTreeMap<FunctionExportName, ExportMetadata>,
}

impl Default for WasmTranslationConfig {
Expand Down
Loading

0 comments on commit eb3c0c9

Please sign in to comment.