2
2
3
3
use crate :: codegen:: cfg:: HashTy ;
4
4
use crate :: codegen:: Expression ;
5
+ <<<<<<< HEAD
6
+ use crate :: emit:: binary:: { self , Binary } ;
7
+ use crate :: emit:: soroban:: { SorobanTarget , GET_CONTRACT_DATA , LOG_FROM_LINEAR_MEMORY , PUT_CONTRACT_DATA } ;
8
+ =======
5
9
use crate :: emit:: binary:: Binary ;
6
10
use crate :: emit:: soroban:: { SorobanTarget , GET_CONTRACT_DATA , PUT_CONTRACT_DATA } ;
11
+ >>>>>>> 06798 cdeac6fd62ee98f5ae7da38f3af4933dc0f
7
12
use crate :: emit:: ContractArgs ;
8
13
use crate :: emit:: { TargetRuntime , Variable } ;
9
14
use crate :: emit_context;
@@ -13,10 +18,17 @@ use crate::sema::ast::{Function, Namespace, Type};
13
18
14
19
use inkwell:: types:: { BasicTypeEnum , IntType } ;
15
20
use inkwell:: values:: {
21
+ <<<<<<< HEAD
22
+ AnyValue , ArrayValue , AsValueRef , BasicMetadataValueEnum , BasicValue , BasicValueEnum , FunctionValue , IntValue , PointerValue
23
+ } ;
24
+
25
+ use inkwell:: AddressSpace ;
26
+ =======
16
27
ArrayValue , BasicMetadataValueEnum , BasicValue , BasicValueEnum , FunctionValue , IntValue ,
17
28
PointerValue ,
18
29
} ;
19
30
31
+ >>>>>>> 06798 cdeac6fd62ee98f5ae7da38f3af4933dc0f
20
32
use solang_parser:: pt:: Loc ;
21
33
22
34
use std:: collections:: HashMap ;
@@ -236,7 +248,76 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
236
248
237
249
/// Prints a string
238
250
/// TODO: Implement this function, with a call to the `log` function in the Soroban runtime.
251
+ <<<<<<< HEAD
252
+ fn print( & self , bin: & Binary , string: PointerValue , length: IntValue ) {
253
+
254
+
255
+
256
+ let mut toprint;
257
+ unsafe {
258
+ toprint = string. as_value_ref( ) . offset( 0 ) ;
259
+ println!( "TO PRINT! {:?}" , toprint) ;
260
+ }
261
+ //println!("print called with string: {:?} ", string.as_value_ref());
262
+ println!( "msg_pos: {:?}" , string) ;
263
+ println!( "length: {:?}" , length) ;
264
+
265
+ let msg_pos = bin. builder. build_ptr_to_int( string, bin. context. i64_type( ) , "msg_pos" ) . unwrap( ) ;
266
+
267
+ let msg_pos = msg_pos. const_cast( bin. context. i64_type( ) , false ) ;
268
+
269
+
270
+
271
+ println!( "msg_pos extracted: {:?}" , msg_pos) ;
272
+ println!( "=============================================================" ) ;
273
+
274
+
275
+
276
+
277
+ //let length = bin.context.i64_type().const_int(1024, false);
278
+
279
+ let length = length. const_cast( bin. context. i64_type( ) , false ) ;
280
+
281
+
282
+ let eight = bin. context. i64_type( ) . const_int( 8 , false ) ;
283
+ let four = bin. context. i64_type( ) . const_int( 4 , false ) ;
284
+ let zero = bin. context. i64_type( ) . const_int( 0 , false ) ;
285
+ let thirty_two = bin. context. i64_type( ) . const_int( 32 , false ) ;
286
+
287
+ // encode msg_pos and length
288
+ let msg_pos_encoded = bin. builder. build_left_shift( msg_pos, thirty_two, "temp" ) . unwrap( ) ;
289
+ let msg_pos_encoded = bin. builder. build_int_add( msg_pos_encoded, four, "msg_pos_encoded" ) . unwrap( ) ;
290
+
291
+
292
+
293
+ let length_encoded = bin. builder. build_left_shift( length, thirty_two, "temp" ) . unwrap( ) ;
294
+ let length_encoded = bin. builder. build_int_add( length_encoded, four, "length_encoded" ) . unwrap( ) ;
295
+
296
+
297
+ let zero_encoded = bin. builder. build_left_shift( zero, eight, "temp" ) . unwrap( ) ;
298
+
299
+
300
+ let eight_encoded = bin. builder. build_left_shift( eight, eight, "temp" ) . unwrap( ) ;
301
+ let eight_encoded = bin. builder. build_int_add( eight_encoded, four, "eight_encoded" ) . unwrap( ) ;
302
+
303
+
304
+
305
+
306
+ let call_res = bin. builder. build_call(
307
+ bin. module. get_function( LOG_FROM_LINEAR_MEMORY ) . unwrap( ) ,
308
+ & [
309
+ msg_pos_encoded. into( ) ,
310
+ length_encoded. into( ) ,
311
+ msg_pos_encoded. into( ) ,
312
+ four. into( ) ,
313
+ ] ,
314
+ "log" ,
315
+ ) . unwrap( ) ;
316
+
317
+ }
318
+ =======
239
319
fn print( & self , bin: & Binary , string: PointerValue , length: IntValue ) { }
320
+ >>>>>>> 06798 cdeac6fd62ee98f5ae7da38f3af4933dc0f
240
321
241
322
/// Return success without any result
242
323
fn return_empty_abi( & self , bin: & Binary ) {
0 commit comments