5252
5353
5454#include "fmtdy.h"
55- #include "fmtno.h"
5655#include "mps.h"
5756#include <assert.h>
5857#include <string.h>
@@ -516,8 +515,7 @@ mps_res_t dylan_scan1(mps_ss_t mps_ss, mps_addr_t *object_io)
516515 return MPS_RES_OK ;
517516}
518517
519- static mps_res_t dylan_scan (mps_ss_t mps_ss ,
520- mps_addr_t base , mps_addr_t limit )
518+ mps_res_t dylan_scan (mps_ss_t mps_ss , mps_addr_t base , mps_addr_t limit )
521519{
522520 mps_res_t res ;
523521 mps_addr_t prev = base ;
@@ -534,21 +532,6 @@ static mps_res_t dylan_scan(mps_ss_t mps_ss,
534532 return MPS_RES_OK ;
535533}
536534
537- /* dylan_class -- return pointer indicating class of object
538- *
539- * Return wrapper pointer, except for broken hearts or padding
540- */
541-
542- static mps_addr_t dylan_class (mps_addr_t obj )
543- {
544- mps_word_t first_word = ((mps_word_t * )obj )[0 ];
545-
546- if ((first_word & 3 ) != 0 ) /* broken heart or padding */
547- return NULL ;
548- else
549- return (mps_addr_t )first_word ;
550- }
551-
552535mps_res_t dylan_scan1_weak (mps_ss_t mps_ss , mps_addr_t * object_io )
553536{
554537 mps_addr_t * assoc ;
@@ -695,20 +678,7 @@ mps_addr_t dylan_skip(mps_addr_t object)
695678 return (mps_addr_t )p ;
696679}
697680
698- static void dylan_copy (mps_addr_t old , mps_addr_t new )
699- {
700- char * base = (char * )old ;
701- char * limit = (char * )dylan_skip (old );
702- size_t length ;
703- assert (base < limit );
704- length = (size_t )(limit - base );
705- assert (dylan_wrapper_check (* (mps_word_t * * )old ));
706- /* .improve.memcpy: Can do better here as we know that new and old
707- will be aligned (to MPS_PF_ALIGN) */
708- (void )memcpy (new , old , length );
709- }
710-
711- static mps_addr_t dylan_isfwd (mps_addr_t object )
681+ mps_addr_t dylan_isfwd (mps_addr_t object )
712682{
713683 mps_word_t h , tag ;
714684
@@ -720,7 +690,7 @@ static mps_addr_t dylan_isfwd(mps_addr_t object)
720690 return NULL ;
721691}
722692
723- static void dylan_fwd (mps_addr_t old , mps_addr_t new )
693+ void dylan_fwd (mps_addr_t old , mps_addr_t new )
724694{
725695 mps_word_t * p ;
726696 mps_addr_t limit ;
@@ -761,101 +731,39 @@ mps_bool_t dylan_ispad(mps_addr_t addr)
761731}
762732
763733
764- /* The dylan format structures */
765-
766- static struct mps_fmt_A_s dylan_fmt_A_s =
767- {
768- ALIGN ,
769- dylan_scan ,
770- dylan_skip ,
771- dylan_copy ,
772- dylan_fwd ,
773- dylan_isfwd ,
774- dylan_pad
775- };
776-
777- static struct mps_fmt_B_s dylan_fmt_B_s =
778- {
779- ALIGN ,
780- dylan_scan ,
781- dylan_skip ,
782- dylan_copy ,
783- dylan_fwd ,
784- dylan_isfwd ,
785- dylan_pad ,
786- dylan_class
787- };
788-
789- /* Functions returning the dylan format structures */
790-
791- mps_fmt_A_s * dylan_fmt_A (void )
792- {
793- return & dylan_fmt_A_s ;
794- }
795-
796- mps_fmt_B_s * dylan_fmt_B (void )
797- {
798- return & dylan_fmt_B_s ;
799- }
800-
801- /* Format variety-independent version that picks the right format
802- * variety and creates it. */
734+ /* Create Dylan object format. */
803735
804736mps_res_t dylan_fmt (mps_fmt_t * mps_fmt_o , mps_arena_t arena )
805737{
806- return mps_fmt_create_B (mps_fmt_o , arena , dylan_fmt_B ());
807- }
808-
809- /* The weak format structures */
810-
811- static struct mps_fmt_A_s dylan_fmt_A_weak_s =
812- {
813- ALIGN ,
814- dylan_scan_weak ,
815- dylan_skip ,
816- no_copy ,
817- no_fwd ,
818- no_isfwd ,
819- no_pad
820- };
821-
822- static struct mps_fmt_B_s dylan_fmt_B_weak_s =
823- {
824- ALIGN ,
825- dylan_scan_weak ,
826- dylan_skip ,
827- no_copy ,
828- no_fwd ,
829- no_isfwd ,
830- no_pad ,
831- dylan_class
832- };
833-
834- /* Functions returning the weak format structures */
835-
836- mps_fmt_A_s * dylan_fmt_A_weak (void )
837- {
838- return & dylan_fmt_A_weak_s ;
839- }
840-
841-
842- mps_fmt_B_s * dylan_fmt_B_weak (void )
843- {
844- return & dylan_fmt_B_weak_s ;
738+ mps_res_t res ;
739+ MPS_ARGS_BEGIN (args ) {
740+ MPS_ARGS_ADD (args , MPS_KEY_ALIGN , ALIGN );
741+ MPS_ARGS_ADD (args , MPS_KEY_FMT_SCAN , dylan_scan );
742+ MPS_ARGS_ADD (args , MPS_KEY_FMT_SKIP , dylan_skip );
743+ MPS_ARGS_ADD (args , MPS_KEY_FMT_FWD , dylan_fwd );
744+ MPS_ARGS_ADD (args , MPS_KEY_FMT_ISFWD , dylan_isfwd );
745+ MPS_ARGS_ADD (args , MPS_KEY_FMT_PAD , dylan_pad );
746+ res = mps_fmt_create_k (mps_fmt_o , arena , args );
747+ } MPS_ARGS_END (args );
748+ return res ;
845749}
846750
847751
848- /* Format variety-independent version that picks the right format
849- * variety and creates it. */
752+ /* Create Dylan weak object format. */
850753
851754mps_res_t dylan_fmt_weak (mps_fmt_t * mps_fmt_o , mps_arena_t arena )
852755{
853- return mps_fmt_create_B (mps_fmt_o , arena , dylan_fmt_B_weak ());
756+ mps_res_t res ;
757+ MPS_ARGS_BEGIN (args ) {
758+ MPS_ARGS_ADD (args , MPS_KEY_ALIGN , ALIGN );
759+ MPS_ARGS_ADD (args , MPS_KEY_FMT_SCAN , dylan_scan_weak );
760+ MPS_ARGS_ADD (args , MPS_KEY_FMT_SKIP , dylan_skip );
761+ res = mps_fmt_create_k (mps_fmt_o , arena , args );
762+ } MPS_ARGS_END (args );
763+ return res ;
854764}
855765
856766
857-
858-
859767/* C. COPYRIGHT AND LICENSE
860768 *
861769 * Copyright (C) 2001-2020 Ravenbrook Limited <https://www.ravenbrook.com/>.
0 commit comments