@@ -335,4 +335,62 @@ impl AbiMap {
335335 } )
336336 }
337337 }
338+
339+ // serialization
340+ pub fn to_json_object ( & self ) -> JsonObject {
341+ let mut json_obj = JsonObject :: new ( ) ;
342+ json_obj. insert ( "system" . to_owned ( ) , format ! ( "{}" , self . system) . to_owned ( ) . into ( ) ) ;
343+ json_obj. insert (
344+ "system-varargs" . to_owned ( ) ,
345+ format ! ( "{}" , self . system_varargs) . to_owned ( ) . into ( ) ,
346+ ) ;
347+ json_obj. insert ( "rust-cold" . to_owned ( ) , format ! ( "{}" , self . rust_cold) . to_owned ( ) . into ( ) ) ;
348+ if let Some ( abi) = self . efiapi {
349+ json_obj. insert ( "efiapi" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
350+ }
351+ if let Some ( abi) = self . stdcall {
352+ json_obj. insert ( "stdcall" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
353+ }
354+ if let Some ( abi) = self . fastcall {
355+ json_obj. insert ( "fastcall" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
356+ }
357+ if let Some ( abi) = self . thiscall {
358+ json_obj. insert ( "thiscall" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
359+ }
360+ if let Some ( abi) = self . vectorcall {
361+ json_obj. insert ( "vectorcall" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
362+ }
363+ if let Some ( abi) = self . win64 {
364+ json_obj. insert ( "win64" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
365+ }
366+ if let Some ( abi) = self . sysv64 {
367+ json_obj. insert ( "sysv64" . to_owned ( ) , format ! ( "{abi}" ) . to_owned ( ) . into ( ) ) ;
368+ }
369+ if self . cmse_nonsecure_entry {
370+ json_obj. insert ( "cmse-nonsecure-entry" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
371+ }
372+ if self . aapcs {
373+ json_obj. insert ( "aapcs" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
374+ }
375+ if self . gpu_kernel {
376+ json_obj. insert ( "gpu-kernel" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
377+ }
378+ if self . ptx_kernel {
379+ json_obj. insert ( "ptx-kernel" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
380+ }
381+ if self . avr_interrupt {
382+ json_obj. insert ( "avr-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
383+ }
384+ if self . msp430_interrupt {
385+ json_obj. insert ( "msp430-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
386+ }
387+ if self . riscv_interrupt {
388+ json_obj. insert ( "riscv-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
389+ }
390+ if self . x86_interrupt {
391+ json_obj. insert ( "x86-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) . into ( ) ) ;
392+ }
393+
394+ json_obj
395+ }
338396}
0 commit comments