11use alloc:: { borrow:: ToOwned , collections:: BTreeMap , sync:: Arc , vec:: Vec } ;
22
3+ use midenc_frontend_wasm:: FrontendOutput ;
34use midenc_hir:: { interner:: Symbol , BuilderExt , OpBuilder , SourceSpan } ;
45#[ cfg( feature = "std" ) ]
56use midenc_session:: Path ;
@@ -16,6 +17,8 @@ pub struct LinkOutput {
1617 pub world : builtin:: WorldRef ,
1718 /// The IR component which is the primary input being compiled
1819 pub component : builtin:: ComponentRef ,
20+ /// The serialized AccountComponentMetadata (name, description, storage layout, etc.)
21+ pub account_component_metadata_bytes : Option < Vec < u8 > > ,
1922 /// The set of Miden Assembly sources to be provided to the assembler to satisfy link-time
2023 /// dependencies
2124 pub masm : Vec < Arc < miden_assembly:: ast:: Module > > ,
@@ -109,7 +112,10 @@ impl Stage for LinkStage {
109112 // Parse and translate the component WebAssembly using the constructed World
110113 let component_wasm =
111114 component_wasm. ok_or_else ( || Report :: msg ( "expected at least one wasm input" ) ) ?;
112- let component = match component_wasm {
115+ let FrontendOutput {
116+ component,
117+ account_component_metadata_bytes,
118+ } = match component_wasm {
113119 #[ cfg( feature = "std" ) ]
114120 InputType :: Real ( path) => parse_hir_from_wasm_file ( & path, world, context. clone ( ) ) ?,
115121 #[ cfg( not( feature = "std" ) ) ]
@@ -138,6 +144,7 @@ impl Stage for LinkStage {
138144 Ok ( LinkOutput {
139145 world,
140146 component,
147+ account_component_metadata_bytes,
141148 masm,
142149 mast,
143150 packages,
@@ -150,7 +157,7 @@ fn parse_hir_from_wasm_file(
150157 path : & Path ,
151158 world : builtin:: WorldRef ,
152159 context : Rc < Context > ,
153- ) -> CompilerResult < builtin :: ComponentRef > {
160+ ) -> CompilerResult < FrontendOutput > {
154161 use std:: io:: Read ;
155162
156163 log:: debug!( "parsing hir from wasm at {}" , path. display( ) ) ;
@@ -172,12 +179,12 @@ fn parse_hir_from_wasm_bytes(
172179 bytes : & [ u8 ] ,
173180 context : Rc < Context > ,
174181 config : & wasm:: WasmTranslationConfig ,
175- ) -> CompilerResult < builtin :: ComponentRef > {
176- let component = wasm:: translate ( bytes, config, context. clone ( ) ) ?;
182+ ) -> CompilerResult < FrontendOutput > {
183+ let outpub = wasm:: translate ( bytes, config, context. clone ( ) ) ?;
177184 log:: debug!(
178185 "parsed hir component from wasm bytes with first module name: {}" ,
179- component. borrow( ) . id( )
186+ outpub . component. borrow( ) . id( )
180187 ) ;
181188
182- Ok ( component )
189+ Ok ( outpub )
183190}
0 commit comments