@@ -8,18 +8,23 @@ use crate::codegen::{
88
99use crate :: emit:: cfg:: emit_cfg;
1010use crate :: { emit:: Binary , sema:: ast} ;
11+ use funty:: Fundamental ;
1112use inkwell:: {
1213 context:: Context ,
1314 module:: { Linkage , Module } ,
1415} ;
1516use soroban_sdk:: xdr:: {
16- DepthLimitedWrite , ScEnvMetaEntry , ScSpecEntry , ScSpecFunctionInputV0 , ScSpecFunctionV0 ,
17- ScSpecTypeDef , StringM , WriteXdr ,
17+ Limited , Limits , ScEnvMetaEntry , ScEnvMetaEntryInterfaceVersion , ScSpecEntry ,
18+ ScSpecFunctionInputV0 , ScSpecFunctionV0 , ScSpecTypeDef , StringM , WriteXdr ,
1819} ;
1920use std:: ffi:: CString ;
2021use std:: sync;
2122
22- const SOROBAN_ENV_INTERFACE_VERSION : u64 = 90194313216 ;
23+ const SOROBAN_ENV_INTERFACE_VERSION : ScEnvMetaEntryInterfaceVersion =
24+ ScEnvMetaEntryInterfaceVersion {
25+ protocol : 22 ,
26+ pre_release : 0 ,
27+ } ;
2328pub const PUT_CONTRACT_DATA : & str = "l._" ;
2429pub const GET_CONTRACT_DATA : & str = "l.1" ;
2530pub const LOG_FROM_LINEAR_MEMORY : & str = "x._" ;
@@ -129,9 +134,15 @@ impl SorobanTarget {
129134 }
130135
131136 fn emit_env_meta_entries < ' a > ( context : & ' a Context , binary : & mut Binary < ' a > , opt : & ' a Options ) {
132- let mut meta = DepthLimitedWrite :: new ( Vec :: new ( ) , 10 ) ;
133- let soroban_env_interface_version =
134- opt. soroban_version . unwrap_or ( SOROBAN_ENV_INTERFACE_VERSION ) ;
137+ let mut meta = Limited :: new ( Vec :: new ( ) , Limits :: none ( ) ) ;
138+ let soroban_env_interface_version = opt. soroban_version ;
139+ let soroban_env_interface_version = match soroban_env_interface_version {
140+ Some ( version) => ScEnvMetaEntryInterfaceVersion {
141+ protocol : version. as_u32 ( ) ,
142+ pre_release : 0 ,
143+ } ,
144+ None => SOROBAN_ENV_INTERFACE_VERSION ,
145+ } ;
135146 ScEnvMetaEntry :: ScEnvMetaKindInterfaceVersion ( soroban_env_interface_version)
136147 . write_xdr ( & mut meta)
137148 . expect ( "writing env meta interface version to xdr" ) ;
@@ -146,7 +157,7 @@ impl SorobanTarget {
146157 ) {
147158 if cfg. public && !cfg. is_placeholder ( ) {
148159 // TODO: Emit custom type spec entries
149- let mut spec = DepthLimitedWrite :: new ( Vec :: new ( ) , 10 ) ;
160+ let mut spec = Limited :: new ( Vec :: new ( ) , Limits :: none ( ) ) ;
150161 ScSpecEntry :: FunctionV0 ( ScSpecFunctionV0 {
151162 name : name
152163 . try_into ( )
@@ -252,13 +263,13 @@ impl SorobanTarget {
252263 }
253264
254265 fn emit_initializer ( binary : & mut Binary , _ns : & ast:: Namespace ) {
255- let mut cfg = ControlFlowGraph :: new ( "init " . to_string ( ) , ASTFunction :: None ) ;
266+ let mut cfg = ControlFlowGraph :: new ( "__constructor " . to_string ( ) , ASTFunction :: None ) ;
256267
257268 cfg. public = true ;
258269 let void_param = ast:: Parameter :: new_default ( ast:: Type :: Void ) ;
259270 cfg. returns = sync:: Arc :: new ( vec ! [ void_param] ) ;
260271
261- Self :: emit_function_spec_entry ( binary. context , & cfg, "init " . to_string ( ) , binary) ;
272+ Self :: emit_function_spec_entry ( binary. context , & cfg, "__constructor " . to_string ( ) , binary) ;
262273
263274 let function_name = CString :: new ( STORAGE_INITIALIZER ) . unwrap ( ) ;
264275 let mut storage_initializers = binary
@@ -271,10 +282,11 @@ impl SorobanTarget {
271282 assert ! ( storage_initializers. next( ) . is_none( ) ) ;
272283
273284 let void_type = binary. context . i64_type ( ) . fn_type ( & [ ] , false ) ;
274- let init = binary
275- . module
276- . add_function ( "init" , void_type, Some ( Linkage :: External ) ) ;
277- let entry = binary. context . append_basic_block ( init, "entry" ) ;
285+ let constructor =
286+ binary
287+ . module
288+ . add_function ( "__constructor" , void_type, Some ( Linkage :: External ) ) ;
289+ let entry = binary. context . append_basic_block ( constructor, "entry" ) ;
278290
279291 binary. builder . position_at_end ( entry) ;
280292 binary
0 commit comments