DaoArray* DaoProcess_PutVectorComplex( DaoProcess *self, dao_complex *array, daoint N ) { DaoArray *res = DaoProcess_PutArray( self ); DaoArray_SetNumType( res, DAO_COMPLEX ); if( array ) DaoArray_SetVectorFloat64( res, (double*)array, N ); return res; }
DaoArray* DaoProcess_PutVectorFloat64( DaoProcess *self, double *array, daoint N ) { DaoArray *res = DaoProcess_PutArray( self ); DaoArray_SetNumType( res, DAO_FLOAT ); if( array ) DaoArray_SetVectorFloat64( res, array, N ); return res; }
DaoArray* DaoProcess_PutVectorInt64( DaoProcess *self, long long *array, daoint N ) { DaoArray *res = DaoProcess_PutArray( self ); DaoArray_SetNumType( res, DAO_INTEGER ); if( array ) DaoArray_SetVectorInt64( res, array, N ); return res; }
DaoArray* DaoProcess_PutVectorUInt32( DaoProcess *self, unsigned int *array, daoint N ) { DaoArray *res = DaoProcess_PutArray( self ); DaoArray_SetNumType( res, DAO_INTEGER ); if( array ) DaoArray_SetVectorUInt32( res, array, N ); return res; }
DaoArray* DaoProcess_PutVectorSInt16( DaoProcess *self, signed short *array, daoint N ) { DaoArray *res = DaoProcess_PutArray( self ); DaoArray_SetNumType( res, DAO_INTEGER ); if( array ) DaoArray_SetVectorSInt16( res, array, N ); return res; }
void DaoValue_SetType( DaoValue *to, DaoType *tp ) { DaoVmSpace *vms; DaoType *tp2; DNode *it; if( to->type != tp->tid && tp->tid != DAO_ANY ) return; if( tp->attrib & DAO_TYPE_SPEC ) return; switch( to->type ){ #ifdef DAO_WITH_NUMARRAY case DAO_ARRAY : if( to->xArray.size ) return; if( tp->tid != DAO_ARRAY || tp->args == NULL || tp->args->size == 0 ) break; tp = tp->args->items.pType[0]; if( tp->tid == DAO_NONE || tp->tid > DAO_COMPLEX ) break; DaoArray_SetNumType( (DaoArray*) to, tp->tid ); break; #endif case DAO_LIST : /* var x: any = {}, x->ctype should be list<any> */ if( tp->tid == DAO_ANY ){ vms = DaoType_GetVmSpace( tp ); tp = vms->typeListAny; } if( to->xList.ctype && !(to->xList.ctype->attrib & DAO_TYPE_UNDEF) ) break; GC_Assign( & to->xList.ctype, tp ); break; case DAO_MAP : if( tp->tid == DAO_ANY ){ vms = DaoType_GetVmSpace( tp ); tp = vms->typeMapAny; } if( to->xMap.ctype && !(to->xMap.ctype->attrib & DAO_TYPE_UNDEF) ) break; GC_Assign( & to->xMap.ctype, tp ); break; case DAO_TUPLE : tp2 = to->xTuple.ctype; if( tp->tid == DAO_ANY ) break; if( tp->args->size ==0 ) break; /* not to the generic tuple type */ if( tp2 == NULL || tp2->mapNames == NULL || tp2->mapNames->size ==0 ){ GC_Assign( & to->xTuple.ctype, tp ); break; } if( tp->mapNames == NULL || tp->mapNames->size ) break; for(it=DMap_First(tp2->mapNames); it!=NULL; it=DMap_Next(tp2->mapNames, it)){ if( DMap_Find( tp->mapNames, it->key.pVoid ) == NULL ) break; } if( it ) break; GC_Assign( & to->xTuple.ctype, tp ); break; default : break; } }
void DaoValue_SetType( DaoValue *to, DaoType *tp ) { DaoType *tp2; DNode *it; if( to->type != tp->tid && tp->tid != DAO_ANY ) return; if( tp->attrib & DAO_TYPE_SPEC ) return; switch( to->type ){ #ifdef DAO_WITH_NUMARRAY case DAO_ARRAY : if( to->xArray.size ) return; if( tp->tid != DAO_ARRAY || tp->nested == NULL || tp->nested->size == 0 ) break; tp = tp->nested->items.pType[0]; if( tp->tid == DAO_NONE || tp->tid > DAO_COMPLEX ) break; DaoArray_SetNumType( (DaoArray*) to, tp->tid ); break; #endif case DAO_LIST : /* v : any = {}, v->unitype should be list<any> */ if( tp->tid == DAO_ANY ) tp = dao_list_any; if( to->xList.unitype && !(to->xList.unitype->attrib & DAO_TYPE_UNDEF) ) break; GC_ShiftRC( tp, to->xList.unitype ); to->xList.unitype = tp; break; case DAO_MAP : if( tp->tid == DAO_ANY ) tp = dao_map_any; if( to->xMap.unitype && !(to->xMap.unitype->attrib & DAO_TYPE_UNDEF) ) break; GC_ShiftRC( tp, to->xMap.unitype ); to->xMap.unitype = tp; break; case DAO_TUPLE : tp2 = to->xTuple.unitype; if( tp->tid == DAO_ANY ) break; if( tp->nested->size ==0 ) break; /* not to the generic tuple type */ if( tp2 == NULL || tp2->mapNames == NULL || tp2->mapNames->size ==0 ){ GC_ShiftRC( tp, to->xTuple.unitype ); to->xTuple.unitype = tp; break; } if( tp->mapNames == NULL || tp->mapNames->size ) break; for(it=DMap_First(tp2->mapNames); it!=NULL; it=DMap_Next(tp2->mapNames, it)){ if( DMap_Find( tp->mapNames, it->key.pVoid ) == NULL ) break; } if( it ) break; GC_ShiftRC( tp, to->xTuple.unitype ); to->xTuple.unitype = tp; break; default : break; } }