@@ -335,4 +335,60 @@ 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 ( ) , self . system . as_str ( ) . to_owned ( ) . into ( ) ) ;
343+ json_obj
344+ . insert ( "system-varargs" . to_owned ( ) , self . system_varargs . as_str ( ) . to_owned ( ) . into ( ) ) ;
345+ json_obj. insert ( "rust-cold" . to_owned ( ) , self . rust_cold . as_str ( ) . to_owned ( ) . into ( ) ) ;
346+ if let Some ( abi) = self . efiapi {
347+ json_obj. insert ( "efiapi" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
348+ }
349+ if let Some ( abi) = self . stdcall {
350+ json_obj. insert ( "stdcall" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
351+ }
352+ if let Some ( abi) = self . fastcall {
353+ json_obj. insert ( "fastcall" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
354+ }
355+ if let Some ( abi) = self . thiscall {
356+ json_obj. insert ( "thiscall" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
357+ }
358+ if let Some ( abi) = self . vectorcall {
359+ json_obj. insert ( "vectorcall" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
360+ }
361+ if let Some ( abi) = self . win64 {
362+ json_obj. insert ( "win64" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
363+ }
364+ if let Some ( abi) = self . sysv64 {
365+ json_obj. insert ( "sysv64" . to_owned ( ) , abi. as_str ( ) . to_owned ( ) . into ( ) ) ;
366+ }
367+ if self . cmse_nonsecure_entry {
368+ json_obj. insert ( "cmse-nonsecure-entry" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
369+ }
370+ if self . aapcs {
371+ json_obj. insert ( "aapcs" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
372+ }
373+ if self . gpu_kernel {
374+ json_obj. insert ( "gpu-kernel" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
375+ }
376+ if self . ptx_kernel {
377+ json_obj. insert ( "ptx-kernel" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
378+ }
379+ if self . avr_interrupt {
380+ json_obj. insert ( "avr-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
381+ }
382+ if self . msp430_interrupt {
383+ json_obj. insert ( "msp430-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
384+ }
385+ if self . riscv_interrupt {
386+ json_obj. insert ( "riscv-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
387+ }
388+ if self . x86_interrupt {
389+ json_obj. insert ( "x86-interrupt" . to_owned ( ) , JsonValue :: Bool ( true ) ) ;
390+ }
391+
392+ json_obj
393+ }
338394}
0 commit comments