void ring_vm_refmeta_ringvmmemorylist ( void *pPointer ) { VM *pVM ; List *pList, *pList2 ; pVM = (VM *) pPointer ; pList = ring_list_new(0) ; ring_list_copy(pList,pVM->pMem); pList2 = RING_API_NEWLIST ; ring_list_copy(pList2,pList); ring_list_delete(pList); RING_API_RETLIST(pList2); }
List * ring_vm_newtempvar2 ( VM *pVM,const char *cStr,List *pList3 ) { List *pList,*pList2 ; pList = ring_vm_newvar2(cStr,pVM->pTempMem); ring_list_setint(pList,RING_VAR_TYPE,RING_VM_LIST); ring_list_setlist(pList,RING_VAR_VALUE); pList2 = ring_list_getlist(pList,RING_VAR_VALUE); ring_list_deleteallitems(pList2); ring_list_copy(pList2,pList3); return pList ; }
void ring_vm_refmeta_addmethod ( void *pPointer ) { List *pList, *pList2, *pList3 ; char *cStr ; int x ; VM *pVM ; /* Parameters : Object, MethodName, Anonymous Function */ pVM = (VM *) pPointer ; if ( RING_API_PARACOUNT != 3 ) { RING_API_ERROR(RING_API_BADPARACOUNT); return ; } if ( RING_API_ISLIST(1) && RING_API_ISSTRING(2) && RING_API_ISSTRING(3) ) { pList = RING_API_GETLIST(1) ; if ( ring_vm_oop_isobject(pList) ) { pList = (List *) ring_list_getlist(pList,RING_OBJECT_CLASSPOINTER); pList = (List *) ring_list_getlist(pList,RING_CLASSMAP_METHODSLIST); cStr = RING_API_GETSTRING(3); ring_string_lower(cStr); for ( x = 1 ; x <= ring_list_getsize(pVM->pFunctionsMap) ; x++ ) { pList2 = ring_list_getlist(pVM->pFunctionsMap,x); if ( strcmp(ring_list_getstring(pList2,RING_FUNCMAP_NAME),cStr) == 0 ) { /* Add new list to the class methods list */ pList3 = ring_list_newlist(pList); /* Copy function to class methods */ ring_list_copy(pList3,pList2); /* Set the Function Name */ ring_list_setstring(pList3,RING_FUNCMAP_NAME,ring_string_lower(RING_API_GETSTRING(2))); /* Refresh the HashTable */ ring_list_genhashtable2(pList); RING_API_RETNUMBER(1); return ; } } } else { RING_API_ERROR(RING_API_BADPARATYPE); } } else { RING_API_ERROR(RING_API_BADPARATYPE); } RING_API_RETNUMBER(0); }
void ring_vm_refmeta_setattribute ( void *pPointer ) { List *pList ; char *cStr ; int x ; if ( RING_API_PARACOUNT != 3 ) { RING_API_ERROR(RING_API_BADPARACOUNT); return ; } if ( RING_API_ISLIST(1) && RING_API_ISSTRING(2) ) { pList = RING_API_GETLIST(1) ; if ( ring_vm_oop_isobject(pList) ) { pList = ring_list_getlist(pList,RING_OBJECT_OBJECTDATA); cStr = RING_API_GETSTRING(2) ; ring_string_lower(cStr); for ( x = 1 ; x <= ring_list_getsize(pList) ; x++ ) { if ( strcmp(ring_list_getstring(ring_list_getlist(pList,x),RING_VAR_NAME),cStr) == 0 ) { pList = ring_list_getlist(pList,x) ; if ( RING_API_ISNUMBER(3) ) { ring_list_setdouble(pList,RING_VAR_VALUE,RING_API_GETNUMBER(3)); } else if ( RING_API_ISSTRING(3) ) { ring_list_setstring2(pList,RING_VAR_VALUE,RING_API_GETSTRING(3),RING_API_GETSTRINGSIZE(3)); } else if ( RING_API_ISLIST(3) ) { ring_list_setlist(pList,RING_VAR_VALUE); pList = ring_list_getlist(pList,RING_VAR_VALUE); ring_list_deleteallitems(pList); ring_list_copy(pList,RING_API_GETLIST(3)); } return ; } } RING_API_ERROR("Error : Property is not found!"); } else { RING_API_ERROR(RING_API_BADPARATYPE); } } else { RING_API_ERROR(RING_API_BADPARATYPE); } }
void ring_parser_icg_duplicate ( Parser *pParser,int nStart,int nEnd ) { List *pList,*pList2 ; int x ; #if RING_SHOWIC int y,nCount2 ; #endif assert(pParser != NULL); if ( (nStart <= nEnd) && ( nEnd <= ring_parser_icg_instructionscount(pParser) ) ) { for ( x = nStart ; x <= nEnd ; x++ ) { pList = ring_list_newlist(pParser->GenCode); pList2 = ring_list_getlist(pParser->GenCode,x); ring_list_copy(pList,pList2); #if RING_SHOWIC nCount2 = ring_list_getsize(pList); printf( "\n %6d [ %s ] ", ring_list_getsize(pParser->GenCode) , RING_IC_OP[ring_list_getint(pList,1)] ) ; if ( nCount2 > 1 ) { for ( y = 2 ; y <= nCount2 ; y++ ) { if ( ring_list_isstring(pList,y) ) { printf( " Operand : %s ",ring_list_getstring(pList,y) ) ; } else if ( ring_list_isnumber(pList,y) ) { if ( ring_list_isdouble(pList,y) ) { printf( " Operand : %f ",ring_list_getdouble(pList,y) ) ; } else { printf( " Operand : %5d ",ring_list_getint(pList,y) ) ; } } else { printf( " Operand : %5p ",ring_list_getpointer(pList,y) ) ; } } } #endif } } }
void ring_vm_refmeta_mergemethods ( void *pPointer ) { int x ; List *pList, *pList2, *pList3 ; VM *pVM ; char *cStr, *cStr2 ; /* ** We copy class methods from class to another class ** First Parameter = Dest Class Name, Second Para = Source Class Name ** The Source Class is expected to be without Parent Class and Without Attributes */ if ( RING_API_PARACOUNT != 2 ) { RING_API_ERROR(RING_API_BADPARACOUNT); return ; } if ( RING_API_ISSTRING(1) && RING_API_ISSTRING(2) ) { cStr = RING_API_GETSTRING(1) ; cStr2 = RING_API_GETSTRING(2) ; ring_string_lower(cStr); ring_string_lower(cStr2); pVM = (VM *) pPointer ; /* Get the Dest Class Methods List */ pList2 = NULL ; for ( x = 1 ; x <= ring_list_getsize(pVM->pClassesMap) ; x++ ) { pList = ring_list_getlist(pVM->pClassesMap,x) ; if ( strcmp(ring_list_getstring(pList,RING_CLASSMAP_CLASSNAME),cStr) == 0 ) { /* Check if the class is imported from a Package */ if ( ring_list_getsize(pList) == RING_CLASSMAP_IMPORTEDCLASSSIZE ) { pList = ring_list_getlist(pList,RING_CLASSMAP_POINTERTOLISTOFCLASSINSIDEPACKAGE); } pList2 = ring_list_getlist(pList,RING_CLASSMAP_METHODSLIST) ; break ; } } if ( pList2 == NULL ) { RING_API_ERROR("Error, Can't find the dest class!"); return ; } /* Get the Source Class Methods List */ pList3 = NULL ; for ( x = 1 ; x <= ring_list_getsize(pVM->pClassesMap) ; x++ ) { pList = ring_list_getlist(pVM->pClassesMap,x) ; if ( strcmp(ring_list_getstring(pList,RING_CLASSMAP_CLASSNAME),cStr2) == 0 ) { /* Check if the class is imported from a Package */ if ( ring_list_getsize(pList) == RING_CLASSMAP_IMPORTEDCLASSSIZE ) { pList = ring_list_getlist(pList,RING_CLASSMAP_POINTERTOLISTOFCLASSINSIDEPACKAGE); } pList3 = ring_list_getlist(pList,RING_CLASSMAP_METHODSLIST) ; break ; } } if ( pList3 == NULL ) { RING_API_ERROR("Error, Can't find the source class!"); return ; } /* Copy Methods from Source to Dest */ ring_list_copy(pList2,pList3); } else { RING_API_ERROR(RING_API_BADPARATYPE); } }