@@ -153,6 +153,7 @@ static EsObject* OPT_KEY_dstack;
153153 */
154154
155155static EsObject * array_new (unsigned int attr );
156+ static EsObject * array_shared_new (EsObject * original , unsigned int attr );
156157
157158static EsObject * array_es_init_fat (void * fat , void * ptr , void * extra );
158159static void array_es_free (void * ptr , void * fat );
@@ -375,8 +376,8 @@ declop(execstack);
375376declop (type );
376377declop (cvn );
377378declop (cvs );
378-
379- /* cvlit, cvx, xcheck, executeonly, noacess, readonly,
379+ declop ( cvx );
380+ /* cvlit, xcheck, executeonly, noacess, readonly,
380381 rcheck, wcheck, cvi, cvr, cvrs, cvs,... */
381382
382383/* Operators for Virtual Memory Operators */
@@ -570,6 +571,7 @@ opt_init (void)
570571 defop (opt_system_dict , type , 1 , "any TYPE name" );
571572 defop (opt_system_dict , cvn , 1 , "string CVN name" );
572573 defop (opt_system_dict , cvs , 2 , "any string CVS string" );
574+ defop (opt_system_dict , cvx , 1 , "any CVX any" );
573575
574576 defop (opt_system_dict , null , 0 , "- NULL null" );
575577 defop (opt_system_dict , bind , 1 , "proc BIND proc" );
@@ -1973,6 +1975,14 @@ array_new (unsigned int attr)
19731975 return es_fatptr_new (OPT_TYPE_ARRAY , a , & attr );
19741976}
19751977
1978+ static EsObject *
1979+ array_shared_new (EsObject * original , unsigned int attr )
1980+ {
1981+ ptrArray * a = es_pointer_get (original );
1982+ ptrArrayRef (a );
1983+ return es_fatptr_new (OPT_TYPE_ARRAY , a , & attr );
1984+ }
1985+
19761986static EsObject *
19771987array_es_init_fat (void * fat , void * ptr , void * extra )
19781988{
@@ -1991,9 +2001,6 @@ array_es_free (void *ptr, void *fat)
19912001static int
19922002array_es_equal (const void * a , const void * afat , const void * b , const void * bfat )
19932003{
1994- if (((ArrayFat * )afat )-> attr != ((ArrayFat * )bfat )-> attr )
1995- return 0 ;
1996-
19972004 if (ptrArrayIsEmpty ((ptrArray * )a ) && ptrArrayIsEmpty ((ptrArray * )b ))
19982005 return 1 ;
19992006 else if (a == b )
@@ -3931,6 +3938,34 @@ op_cvs (OptVM *vm, EsObject *name)
39313938 return es_false ;
39323939}
39333940
3941+ static EsObject *
3942+ op_cvx (OptVM * vm , EsObject * name )
3943+ {
3944+ EsObject * o = ptrArrayLast (vm -> ostack );
3945+
3946+ if (es_object_get_type (o ) == OPT_TYPE_ARRAY
3947+ && (! (((ArrayFat * )es_fatptr_get (o ))-> attr & ATTR_EXECUTABLE )))
3948+ {
3949+ EsObject * xarray = array_shared_new (o ,
3950+ ((ArrayFat * )es_fatptr_get (o ))-> attr | ATTR_EXECUTABLE );
3951+ ptrArrayDeleteLast (vm -> ostack );
3952+ vm_ostack_push (vm , xarray );
3953+ es_object_unref (xarray );
3954+
3955+ }
3956+ else if (es_object_get_type (o ) == OPT_TYPE_NAME
3957+ && (! (((NameFat * )es_fatptr_get (o ))-> attr & ATTR_EXECUTABLE )))
3958+ {
3959+ EsObject * symbol = es_pointer_get (o );
3960+ EsObject * xname = name_new (symbol , ((NameFat * )es_fatptr_get (o ))-> attr | ATTR_EXECUTABLE );
3961+ ptrArrayDeleteLast (vm -> ostack );
3962+ vm_ostack_push (vm , xname );
3963+ es_object_unref (xname );
3964+ }
3965+
3966+ return es_false ;
3967+ }
3968+
39343969
39353970/*
39363971 * Misc operators
0 commit comments