@@ -808,76 +808,6 @@ action_proc_notequal(Reduce *rc, Compile *compile,
808808 }
809809}
810810
811- static void *
812- action_proc_join_sub (Reduce * rc , PElement * pe ,
813- PElement * a , PElement * b , PElement * out )
814- {
815- if (PEISMANAGEDSTRING (a )) {
816- PElement tail ;
817-
818- // expand the static string into a list
819- reduce_clone_list (rc , a , pe );
820- PEPUTPE (& tail , b );
821- }
822- else if (PEISELIST (a )) {
823- }
824- else if (PEISNODE (a ) && PEGETVAL (a )-> type == TAG_CONS ) {
825- HeapNode * cons = PEGETVAL (a );
826- PElement hd ;
827- PEPOINTLEFT (hn , & hd );
828- PElement tl ;
829- PEPOINTRIGHT (hn , & tl );
830-
831- PElement t ;
832- if (!heap_list_add (rc -> heap , & tl , & t ))
833- reduce_throw (rc );
834- PEPUTP (& t ,
835- }
836- else
837- g_assert (FALSE);
838-
839-
840- if (!heap_list_cat (rc , a , b , pe ))
841- return a ;
842-
843- PEPUTPE (out , pe );
844-
845- return NULL ;
846- }
847-
848- static void
849- action_proc_join (Reduce * rc , Compile * compile ,
850- int op , const char * name , HeapNode * * arg , PElement * out )
851- {
852- PElement left , right ;
853- PElement * a = & left ;
854- PElement * b = & right ;
855-
856- PEPOINTRIGHT (arg [1 ], & left );
857- PEPOINTRIGHT (arg [0 ], & right );
858-
859- if (PEISIMAGE (a ) && PEISIMAGE (b )) {
860- g_autoptr (VipsArrayImage ) c =
861- vips_array_image_newv (2 , PEGETIMAGE (a ), PEGETIMAGE (b ));
862-
863- vo_callva (rc , out , "bandjoin" , c );
864- }
865- else if (PEISLIST (a ) && PEISLIST (b )) {
866- if (reduce_safe_pointer (rc ,
867- (reduce_safe_pointer_fn ) action_proc_join_sub ,
868- a , b , out , NULL ))
869- action_boperror (rc , compile , error_get_sub (), op , name , a , b );
870- }
871- else if (PEISIMAGE (a ) && PEISELIST (b )) {
872- PEPUTPE (out , a );
873- }
874- else if (PEISIMAGE (b ) && PEISELIST (a )) {
875- PEPUTPE (out , b );
876- }
877- else
878- action_boperror (rc , compile , NULL , op , name , a , b );
879- }
880-
881811static void
882812action_proc_index (Reduce * rc , Compile * compile ,
883813 int op , const char * name , HeapNode * * arg , PElement * out )
@@ -932,6 +862,74 @@ action_proc_exp(Reduce *rc, Compile *compile,
932862 action_boperror (rc , compile , NULL , op , name , a , b );
933863}
934864
865+ static void *
866+ action_proc_join_sub (Reduce * rc , PElement * pe ,
867+ PElement * a , PElement * b , PElement * out )
868+ {
869+ if (PEISELIST (a ))
870+ PEPUTPE (pe , b );
871+ else if (PEISMANAGEDSTRING (a )) {
872+ PElement new_list = * pe ;
873+
874+ // expand the static string into a list
875+ reduce_clone_list (rc , a , & new_list );
876+ // and overwrite the terminating [] with b
877+ PEPUTPE (& new_list , b );
878+ }
879+ else if (PEISNODE (a ) && PEGETVAL (a )-> type == TAG_CONS ) {
880+ /*
881+ HeapNode *cons = PEGETVAL(a);
882+ PElement hd;
883+ PEPOINTLEFT(hn, &hd);
884+ PElement tl;
885+ PEPOINTRIGHT(hn, &tl);
886+
887+ PElement t;
888+ if (!heap_list_add(rc->heap, &tl, &t))
889+ reduce_throw(rc);
890+
891+ PEPUTP(&t,
892+
893+ // we were using this
894+ if (!heap_list_cat(rc, a, b, pe))
895+ return a;
896+
897+ */
898+ }
899+ else
900+ g_assert (FALSE);
901+
902+ PEPUTPE (out , pe );
903+
904+ return NULL ;
905+ }
906+
907+ static void
908+ action_proc_join (Reduce * rc , Compile * compile , int op , const char * name ,
909+ PElement * a , PElement * b , PElement * out )
910+ {
911+ if (PEISIMAGE (a ) && PEISIMAGE (b )) {
912+ g_autoptr (VipsArrayImage ) c =
913+ vips_array_image_newv (2 , PEGETIMAGE (a ), PEGETIMAGE (b ));
914+
915+ vo_callva (rc , out , "bandjoin" , c );
916+ }
917+ else if (PEISLIST (a ) && PEISLIST (b )) {
918+ if (reduce_safe_pointer (rc ,
919+ (reduce_safe_pointer_fn ) action_proc_join_sub ,
920+ a , b , out , NULL ))
921+ action_boperror (rc , compile , error_get_sub (), op , name , a , b );
922+ }
923+ else if (PEISIMAGE (a ) && PEISELIST (b )) {
924+ PEPUTPE (out , a );
925+ }
926+ else if (PEISIMAGE (b ) && PEISELIST (a )) {
927+ PEPUTPE (out , b );
928+ }
929+ else
930+ action_boperror (rc , compile , NULL , op , name , a , b );
931+ }
932+
935933/* Left shift.
936934 */
937935static void
@@ -1268,10 +1266,6 @@ action_proc_bop_strict(Reduce *rc, Compile *compile,
12681266 action_proc_index (rc , compile , op , name , arg , out );
12691267 break ;
12701268
1271- case BI_JOIN :
1272- action_proc_join (rc , compile , op , name , arg , out );
1273- break ;
1274-
12751269 case BI_EQ :
12761270 action_proc_equal (rc , compile , op , name , arg , out );
12771271 break ;
@@ -1314,6 +1308,10 @@ action_proc_bop_strict(Reduce *rc, Compile *compile,
13141308 action_proc_exp (rc , compile , op , name , a , b , out );
13151309 break ;
13161310
1311+ case BI_JOIN :
1312+ action_proc_join (rc , compile , op , name , a , b , out );
1313+ break ;
1314+
13171315 case BI_LSHIFT :
13181316 action_proc_lshift (rc , compile , op , name , a , b , out );
13191317 break ;
0 commit comments