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); }
RING_API RingState * ring_state_delete ( RingState *pRingState ) { if ( pRingState->pRingFilesList != NULL ) { pRingState->pRingFilesList = ring_list_delete(pRingState->pRingFilesList); pRingState->pRingFilesStack = ring_list_delete(pRingState->pRingFilesStack); } if ( pRingState->pRingGenCode != NULL ) { pRingState->pRingGenCode = ring_list_delete(pRingState->pRingGenCode); pRingState->pRingFunctionsMap = ring_list_delete(pRingState->pRingFunctionsMap); pRingState->pRingClassesMap = ring_list_delete(pRingState->pRingClassesMap); pRingState->pRingPackagesMap = ring_list_delete(pRingState->pRingPackagesMap); if ( pRingState->pRingCFunctions != NULL ) { /* We check because the execution may end by the compiler error */ pRingState->pRingCFunctions = ring_list_delete(pRingState->pRingCFunctions); } } if ( pRingState->pVM != NULL ) { ring_vm_delete(pRingState->pVM); } free( pRingState ) ; return NULL ; }
GTreeView::~GTreeView() { ring_list_delete(this->pParaList); }
int ring_objfile_readfile ( const char *cFileName,RingState *pRingState ) { FILE *fObj; signed char c ; List *pListFunctions, *pListClasses, *pListPackages, *pListCode, *pList, *pListStack ; int nActiveList,nValue,nBraceEnd ; double dValue ; char *cString ; char cKey[11] ; char cFileType[100] ; strcpy(cKey,"ringstring"); /* Create Lists */ pListFunctions = ring_list_new(0); pListClasses = ring_list_new(0); pListPackages = ring_list_new(0); pListCode = ring_list_new(0); pListStack = ring_list_new(0); pList = NULL ; /* Set Active List (1=functions 2=classes 3=packages 4=code) */ nActiveList = 0 ; nBraceEnd = 0 ; /* Open File */ fObj = fopen(cFileName , "rb" ); if ( fObj==NULL ) { printf( "Can't open file %s \n ",cFileName ) ; return 0 ; } fread( cFileType , 1 , 18 , fObj ); cFileType[18] = '\0' ; if ( strcmp(cFileType,"# Ring Object File") != 0 ) { printf( "The file type is not correct - the VM expect a ring object file\n" ) ; return 0 ; } c = getc(fObj); fread( cFileType , 1 , 13 , fObj ); cFileType[13] = '\0' ; if ( strcmp(cFileType,"# Version 1.1") != 0 ) { printf( "The file version is not correct - the VM expect a ring object file version 1.1\n" ) ; return 0 ; } /* Process File */ c = getc(fObj); while ( c != EOF ) { /* Check Char */ switch ( c ) { case '#' : /* Read Line */ while ( c != '\n' ) { c = getc(fObj); #ifdef DEBUG_OBJFILE printf( "%c ",c ) ; #endif } #ifdef DEBUG_OBJFILE puts("Read Comment ! "); #endif break ; case '{' : nActiveList++ ; switch ( nActiveList ) { case 1 : pList = pListFunctions ; break ; case 2 : pList = pListClasses ; break ; case 3 : pList = pListPackages ; break ; case 4 : pList = pListCode ; break ; } break ; case '[' : c = getc(fObj); switch ( c ) { case 'S' : c = getc(fObj); fscanf( fObj , "[%d]" , &nValue ) ; cString = (char *) malloc(nValue+1) ; fread( cString , 1 , nValue , fObj ); cString[nValue] = '\0' ; /* Decrypt String */ ring_objfile_xorstring(cString,nValue,cKey,10); ring_list_addstring2(pList,cString,nValue); free( cString ) ; #ifdef DEBUG_OBJFILE printf( "Read String %s Size %d \n",cString,nValue ) ; #endif break ; case 'I' : c = getc(fObj); fscanf( fObj , "%d" , &nValue ) ; ring_list_addint(pList,nValue); #ifdef DEBUG_OBJFILE printf( "Read Number %d \n ",nValue ) ; #endif break ; case 'D' : c = getc(fObj); fscanf( fObj , "%lf" , &dValue ) ; ring_list_adddouble(pList,dValue); #ifdef DEBUG_OBJFILE printf( "Read Double %d \n",dValue ) ; #endif break ; case 'P' : ring_list_addpointer(pList,NULL); /* Read Line */ while ( c != '\n' ) { c = getc(fObj); } #ifdef DEBUG_OBJFILE puts("Read Pointer "); #endif break ; case 'T' : ring_list_addpointer(pListStack,pList); pList = ring_list_newlist(pList); /* Read Line */ while ( c != '\n' ) { c = getc(fObj); } #ifdef DEBUG_OBJFILE puts("Read T "); #endif break ; case 'E' : pList = (List *) ring_list_getpointer(pListStack,ring_list_getsize(pListStack)) ; ring_list_deletelastitem(pListStack); /* Read Line */ while ( c != '\n' ) { c = getc(fObj); } #ifdef DEBUG_OBJFILE puts("Read E "); #endif break ; case 'L' : /* Read Until { */ while ( c != '{' ) { c = getc(fObj); } ring_list_addpointer(pListStack,pList); pList = ring_list_newlist(pList); nBraceEnd = 1 ; #ifdef DEBUG_OBJFILE puts("Read L "); #endif break ; } break ; case '}' : if ( nBraceEnd ) { pList = (List *) ring_list_getpointer(pListStack,ring_list_getsize(pListStack)) ; ring_list_deletelastitem(pListStack); nBraceEnd = 0 ; #ifdef DEBUG_OBJFILE puts("Read } "); #endif } break ; } c = getc(fObj); } /* Close File */ fclose( fObj ) ; ring_list_delete(pListStack); /* Update Ring State */ #ifdef DEBUG_OBJFILE puts("Old Code List "); ring_list_print(pRingState->pRingGenCode); #endif /* Update Lists */ pRingState->pRingFunctionsMap = pListFunctions ; pRingState->pRingClassesMap = pListClasses ; pRingState->pRingPackagesMap = pListPackages ; pRingState->pRingGenCode = pListCode ; #ifdef DEBUG_OBJFILE puts("Update Done! "); puts("New Code List "); ring_list_print(pRingState->pRingGenCode); #endif /* Update Classes Pointers */ ring_objfile_updateclassespointers(pRingState); return 1 ; }
GBluetoothServer::~GBluetoothServer() { ring_list_delete(this->pParaList); }
GTabWidget::~GTabWidget() { ring_list_delete(this->pParaList); }
GDrag::~GDrag() { ring_list_delete(this->pParaList); }
int ring_parser_stmt ( Parser *pParser ) { int x,nMark1,nMark2,nMark3,nStart,nEnd,nPerformanceLocations ; String *pString ; List *pMark,*pMark2,*pMark3,*pList2 ; double nNum1 ; char cStr[50] ; nPerformanceLocations = 0 ; char cFileName[200] ; assert(pParser != NULL); /* Statement --> Load Literal */ if ( ring_parser_iskeyword(pParser,K_LOAD) ) { ring_parser_nexttoken(pParser); if ( ring_parser_isliteral(pParser) ) { /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_FILENAME); ring_parser_icg_newoperand(pParser,pParser->TokenText); ring_parser_icg_newoperation(pParser,ICO_BLOCKFLAG); pMark = ring_parser_icg_getactiveoperation(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Load' Literal"); #endif /* No package at the start of the file */ pParser->ClassesMap = pParser->pRingState->pRingClassesMap ; strcpy(cFileName,pParser->TokenText); if ( ring_fexists(pParser->TokenText) == 0 ) { ring_exefolder(cFileName); strcat(cFileName,pParser->TokenText); if ( ring_fexists(cFileName) == 0 ) { strcpy(cFileName,pParser->TokenText); } } ring_scanner_readfile(cFileName,pParser->pRingState); /* ** Generate Code ** Return NULL */ ring_parser_icg_newoperation(pParser,ICO_RETNULL); nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark1); /* Set Active File */ ring_parser_icg_newoperation(pParser,ICO_FILENAME); ring_parser_icg_newoperand(pParser,ring_list_getstring(pParser->pRingState->pRingFilesStack,ring_list_getsize(pParser->pRingState->pRingFilesStack))); ring_parser_nexttoken(pParser); return 1 ; } return 0 ; } /* Statement --> See Expr */ if ( ring_parser_iskeyword(pParser,K_SEE) ) { ring_parser_nexttoken(pParser); /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_FUNCEXE); x = ring_parser_expr(pParser); /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_PRINT); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'See' Expr"); #endif return x ; } /* Statement --> Give Identifier */ if ( ring_parser_iskeyword(pParser,K_GIVE) ) { ring_parser_nexttoken(pParser); if ( ring_parser_isidentifier(pParser) ) { /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_LOADADDRESS); ring_parser_icg_newoperand(pParser,pParser->TokenText); ring_parser_nexttoken(pParser); x = ring_parser_mixer(pParser); if ( x == 0 ) { return 0 ; } /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_GIVE); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Give' Identifier|ListItem|Object.Attribute"); #endif return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_VARNAME); return 0 ; } } /* Statement --> For Identifier = Expr to Expr {Statement} Next | For Identifier in Expr {Statemen */ if ( ring_parser_iskeyword(pParser,K_FOR) ) { ring_parser_nexttoken(pParser); if ( ring_parser_isidentifier(pParser) ) { pString = ring_string_new(pParser->TokenText); ring_parser_nexttoken(pParser); if ( ring_parser_isoperator(pParser,"=") ) { /* ** Generate Code ** Mark for Exit command to go to outside the loop */ ring_parser_icg_newoperation(pParser,ICO_EXITMARK); pMark3 = ring_parser_icg_getactiveoperation(pParser); ring_parser_icg_newoperation(pParser,ICO_LOADAFIRST); ring_parser_icg_newoperand(pParser,ring_string_get(pString)); ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { /* ** Generate Code ** Before Equal ( = ) not += , -= ,... etc */ ring_parser_icg_newoperation(pParser,ICO_BEFOREEQUAL); ring_parser_icg_newoperandint(pParser,0); ring_parser_icg_newoperation(pParser,ICO_ASSIGNMENT); nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_icg_newoperation(pParser,ICO_LOADAPUSHV); ring_parser_icg_newoperand(pParser,ring_string_get(pString)); if ( ring_parser_iskeyword(pParser,K_TO) ) { ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; /* Generate Code */ if ( (ring_parser_icg_getlastoperation(pParser) == ICO_PUSHN) && (ring_parser_icg_newlabel(pParser) == (nMark1+2)) ) { /* ** We check nMark2+2 to avoid executing next instructions when we have expr ** for example for x = 1 to 10+5 */ nNum1 = ring_list_getdouble(pParser->ActiveGenCodeList,2) ; ring_parser_icg_deletelastoperation(pParser); ring_parser_icg_setlastoperation(pParser,ICO_JUMPVARLENUM); ring_parser_icg_newoperanddouble(pParser,nNum1); /* Add Locations Needed for Instruction change for performance */ nPerformanceLocations = 1 ; } else { ring_parser_icg_newoperation(pParser,ICO_JUMPFOR); } pMark = ring_parser_icg_getactiveoperation(pParser); /* Step <expr> */ x = ring_parser_step(pParser,&nMark1); if ( x == 0 ) { ring_string_delete(pString); return 0 ; } #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'For' Identifier '=' Expr to Expr ['step' Expr]"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } if ( ring_parser_iskeyword(pParser,K_NEXT) ) { /* Generate Code */ nMark3 = ring_parser_icg_newlabel(pParser); /* Increment Jump */ ring_parser_icg_newoperation(pParser,ICO_INCJUMP); ring_parser_icg_newoperand(pParser,ring_string_get(pString)); ring_parser_icg_newoperandint(pParser,nMark1); /* Add Locations needed for instruction change for performance */ ring_parser_icg_newoperandint(pParser,0); ring_parser_icg_newoperandint(pParser,0); nMark2 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark2); /* Performance Locations */ if ( nPerformanceLocations ) { /* Add Locations Needed for Instruction JUMPVARLENUM change for performance */ ring_parser_icg_addoperandint(pMark,0); ring_parser_icg_addoperandint(pMark,0); } /* Set Exit Mark */ ring_parser_icg_addoperandint(pMark3,nMark2); /* Set Loop Mark */ ring_parser_icg_addoperandint(pMark3,nMark3); /* End Loop (Remove Exit Mark) */ ring_parser_icg_newoperation(pParser,ICO_POPEXITMARK); /* POP Step */ ring_parser_icg_newoperation(pParser,ICO_POPSTEP); ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Next --> 'Next'"); #endif ring_string_delete(pString); return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_NEXT); } } } } } else if ( ring_parser_iskeyword(pParser,K_IN) ) { /* Generate Code */ sprintf( cStr , "n_sys_var_%d" , ring_parser_icg_instructionscount(pParser) ) ; /* Mark for Exit command to go to outside the loop */ ring_parser_icg_newoperation(pParser,ICO_EXITMARK); pMark3 = ring_parser_icg_getactiveoperation(pParser); ring_parser_icg_newoperation(pParser,ICO_LOADADDRESS); ring_parser_icg_newoperand(pParser,cStr); ring_parser_icg_newoperation(pParser,ICO_PUSHN); ring_parser_icg_newoperanddouble(pParser,1.0); /* Before Equal ( = ) not += , -= ,... etc */ ring_parser_icg_newoperation(pParser,ICO_BEFOREEQUAL); ring_parser_icg_newoperandint(pParser,0); ring_parser_icg_newoperation(pParser,ICO_ASSIGNMENT); /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_icg_newoperation(pParser,ICO_LOADAPUSHV); ring_parser_icg_newoperand(pParser,cStr); ring_parser_icg_newoperation(pParser,ICO_LOADFUNC); ring_parser_icg_newoperand(pParser,"len"); nStart = ring_parser_icg_instructionscount(pParser) + 1 ; ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; /* Generate Code */ nEnd = ring_parser_icg_instructionscount(pParser) ; /* Note (nEnd-1) , -1 to remove instruction PushV (avoid error with for x in string) */ if ( ring_parser_icg_getlastoperation(pParser) == ICO_PUSHV ) { nEnd-- ; } ring_parser_icg_newoperation(pParser,ICO_CALL); /* Generate 0 For Operator OverLoading */ ring_parser_icg_newoperandint(pParser,0); ring_parser_icg_newoperation(pParser,ICO_JUMPFOR); pMark = ring_parser_icg_getactiveoperation(pParser); ring_parser_icg_newoperation(pParser,ICO_LOADAFIRST); ring_parser_icg_newoperand(pParser,ring_string_get(pString)); ring_parser_icg_duplicate(pParser,nStart,nEnd); ring_parser_icg_newoperation(pParser,ICO_LOADAPUSHV); ring_parser_icg_newoperand(pParser,cStr); ring_parser_icg_newoperation(pParser,ICO_LOADINDEXADDRESS); /* Generate 0 For Operator OverLoading */ ring_parser_icg_newoperandint(pParser,0); /* Item by reference */ ring_parser_icg_newoperation(pParser,ICO_SETREFERENCE); /* Step <expr> */ x = ring_parser_step(pParser,&nMark1); if ( x == 0 ) { ring_string_delete(pString); return 0 ; } #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'For' Identifier 'in' Expr ['step' Expr]"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } if ( ring_parser_iskeyword(pParser,K_NEXT) ) { ring_parser_nexttoken(pParser); /* Generate Code */ nMark3 = ring_parser_icg_newlabel(pParser); /* Increment Jump */ ring_parser_icg_newoperation(pParser,ICO_INCJUMP); ring_parser_icg_newoperand(pParser,cStr); ring_parser_icg_newoperandint(pParser,nMark1); /* Add Locations needed for instruction change for performance */ ring_parser_icg_newoperandint(pParser,0); ring_parser_icg_newoperandint(pParser,0); nMark2 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark2); /* Set Exit Mark */ ring_parser_icg_addoperandint(pMark3,nMark2); /* Set Loop Mark */ ring_parser_icg_addoperandint(pMark3,nMark3); /* End Loop (Remove Exit Mark) */ ring_parser_icg_newoperation(pParser,ICO_POPEXITMARK); /* POP Step */ ring_parser_icg_newoperation(pParser,ICO_POPSTEP); /* Remove Reference Value */ ring_parser_icg_newoperation(pParser,ICO_LOADAFIRST); ring_parser_icg_newoperand(pParser,ring_string_get(pString)); ring_parser_icg_newoperation(pParser,ICO_KILLREFERENCE); ring_parser_icg_newoperation(pParser,ICO_PUSHN); ring_parser_icg_newoperanddouble(pParser,1.0); /* Before Equal ( = ) not += , -= ,... etc */ ring_parser_icg_newoperation(pParser,ICO_BEFOREEQUAL); ring_parser_icg_newoperandint(pParser,0); ring_parser_icg_newoperation(pParser,ICO_ASSIGNMENT); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Next --> 'Next'"); #endif ring_string_delete(pString); return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_NEXT); } } } ring_string_delete(pString); } return 0 ; } /* Statement --> IF Expr Statements OK */ if ( ring_parser_iskeyword(pParser,K_IF) ) { ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; /* ** First Condition ** Generate Code */ ring_parser_icg_newoperation(pParser,ICO_JUMPZERO); pMark = ring_parser_icg_getactiveoperation(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'If' Expr {Statement} { But } [Else] Ok"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } /* Generate Code */ pList2 = ring_list_new(0); ring_parser_icg_newoperation(pParser,ICO_JUMP); ring_list_addpointer(pList2,ring_parser_icg_getactiveoperation(pParser)); /* { 'But' Statements } 'Else' Statements */ while ( ring_parser_iskeyword(pParser,K_BUT) ) { /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark1); ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_JUMPZERO); pMark = ring_parser_icg_getactiveoperation(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : But --> 'But' Expr {Statement}"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_JUMP); ring_list_addpointer(pList2,ring_parser_icg_getactiveoperation(pParser)); } } if ( ring_parser_iskeyword(pParser,K_ELSE) ) { /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark1); pMark = NULL ; ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Else --> 'Else' {Statement} "); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } } if ( ring_parser_iskeyword(pParser,K_OK) ) { /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); if ( pMark != NULL ) { ring_parser_icg_addoperandint(pMark,nMark1); } if ( ring_list_getsize(pList2) > 0 ) { for ( x = 1 ; x <= ring_list_getsize(pList2) ; x++ ) { ring_parser_icg_addoperandint(((List *) ring_list_getpointer(pList2,x)),nMark1); } } ring_list_delete(pList2); ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Ok --> 'OK'"); #endif return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_OK); ring_list_delete(pList2); } } return 0 ; } /* Statement --> WHILE Expr Statements END */ if ( ring_parser_iskeyword(pParser,K_WHILE) ) { /* ** Generate Code ** Mark for Exit command to go to outsize the loop */ ring_parser_icg_newoperation(pParser,ICO_EXITMARK); pMark3 = ring_parser_icg_getactiveoperation(pParser); nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_JUMPZERO); pMark = ring_parser_icg_getactiveoperation(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'While' Expr {Statement} End"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } if ( ring_parser_iskeyword(pParser,K_END) ) { /* Generate Code */ nMark3 = ring_parser_icg_newlabel(pParser); ring_parser_icg_newoperation(pParser,ICO_JUMP); ring_parser_icg_newoperandint(pParser,nMark1); nMark2 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark2); /* Set Exit Mark */ ring_parser_icg_addoperandint(pMark3,nMark2); /* Set Loop Mark */ ring_parser_icg_addoperandint(pMark3,nMark3); /* End Loop (Remove Exit Mark) */ ring_parser_icg_newoperation(pParser,ICO_POPEXITMARK); ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : End --> 'End'"); #endif return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_END); } } return 0 ; } /* Statement --> DO Statements AGAIN Expr */ if ( ring_parser_iskeyword(pParser,K_DO) ) { /* ** Generate Code ** Mark for Exit command to go to outsize the loop */ ring_parser_icg_newoperation(pParser,ICO_EXITMARK); pMark3 = ring_parser_icg_getactiveoperation(pParser); nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Do' {Statement} Again"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } if ( ring_parser_iskeyword(pParser,K_AGAIN) ) { /* Generate Code */ ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { /* Generate Code (Test Condition) */ ring_parser_icg_newoperation(pParser,ICO_JUMPZERO); pMark = ring_parser_icg_getactiveoperation(pParser); /* Generate Code */ nMark3 = ring_parser_icg_newlabel(pParser); ring_parser_icg_newoperation(pParser,ICO_JUMP); ring_parser_icg_newoperandint(pParser,nMark1); nMark2 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark2); /* Set Exit Mark */ ring_parser_icg_addoperandint(pMark3,nMark2); /* Set Loop Mark */ ring_parser_icg_addoperandint(pMark3,nMark3); /* End Loop (Remove Exit Mark) */ ring_parser_icg_newoperation(pParser,ICO_POPEXITMARK); pParser->nAssignmentFlag = 1 ; #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Again --> 'Again' Expr"); #endif return 1 ; } } else { ring_parser_error(pParser,RING_PARSER_ERROR_AGAIN); } return 0 ; } /* Statement --> Return Expr */ if ( ring_parser_iskeyword(pParser,K_RETURN) ) { ring_parser_nexttoken(pParser); x = 1 ; if ( ring_parser_isendline(pParser) == 0 ) { /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_FUNCEXE); pParser->nAssignmentFlag = 0 ; x = ring_parser_expr(pParser); pParser->nAssignmentFlag = 1 ; /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_ENDFUNCEXE); ring_parser_icg_newoperation(pParser,ICO_RETURN); } else { /* ** Generate Code ** Return NULL */ ring_parser_icg_newoperation(pParser,ICO_RETNULL); } #if RING_PARSERTRACE if ( x == 1 ) { RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Return'"); } #endif return x ; } /* Statement --> Try {Statement} Catch {Statement} Done */ if ( ring_parser_iskeyword(pParser,K_TRY) ) { ring_parser_nexttoken(pParser); /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_TRY); pMark = ring_parser_icg_getactiveoperation(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Try' {Statement} Catch Done"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } if ( ring_parser_iskeyword(pParser,K_CATCH) ) { ring_parser_nexttoken(pParser); /* ** Generate Code ** Jump from end of try block to label after done */ ring_parser_icg_newoperation(pParser,ICO_JUMP); pMark2 = ring_parser_icg_getactiveoperation(pParser); nMark1 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark,nMark1); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Catch --> 'Catch' {Statement}"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } if ( ring_parser_iskeyword(pParser,K_DONE) ) { #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Done --> 'Done'"); #endif ring_parser_nexttoken(pParser); /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_JUMP); pMark3 = ring_parser_icg_getactiveoperation(pParser); nMark2 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark2,nMark2); ring_parser_icg_newoperation(pParser,ICO_DONE); nMark3 = ring_parser_icg_newlabel(pParser); ring_parser_icg_addoperandint(pMark3,nMark3); return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_NODONE); } } else { ring_parser_error(pParser,RING_PARSER_ERROR_NOCATCH); } } /* Statement --> Bye (Close the Program) */ if ( ring_parser_iskeyword(pParser,K_BYE) ) { ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Bye' "); #endif /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_BYE); return 1 ; } /* Statement --> Exit (Go to outside the loop) */ if ( ring_parser_iskeyword(pParser,K_EXIT) ) { ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Exit' "); #endif /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_EXIT); /* Check Number (Exit from more than one loop) */ if ( ring_parser_isnumber(pParser) ) { ring_parser_icg_newoperanddouble(pParser,atof(pParser->TokenText)); ring_parser_nexttoken(pParser); } return 1 ; } /* Statement --> Loop (Continue) */ if ( ring_parser_iskeyword(pParser,K_LOOP) ) { ring_parser_nexttoken(pParser); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Loop'"); #endif /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_LOOP); /* Check Number (Continue from more than one loop) */ if ( ring_parser_isnumber(pParser) ) { ring_parser_icg_newoperanddouble(pParser,atof(pParser->TokenText)); ring_parser_nexttoken(pParser); } return 1 ; } /* Statement --> Switch Expr { ON Expr {Statement} } OFF */ if ( ring_parser_iskeyword(pParser,K_SWITCH) ) { ring_parser_nexttoken(pParser); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> 'Switch' Expr {ON} [Other] OFF"); #endif RING_PARSER_IGNORENEWLINE ; /* ON Statements */ pList2 = ring_list_new(0); pMark = NULL ; while ( ring_parser_iskeyword(pParser,K_ON) ) { ring_parser_nexttoken(pParser); /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); if ( pMark != NULL ) { ring_parser_icg_addoperandint(pMark,nMark1); } ring_parser_icg_newoperation(pParser,ICO_DUPLICATE); pParser->nAssignmentFlag = 0 ; if ( ring_parser_expr(pParser) ) { pParser->nAssignmentFlag = 1 ; /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_EQUAL); ring_parser_icg_newoperation(pParser,ICO_JUMPZERO); pMark = ring_parser_icg_getactiveoperation(pParser); ring_parser_icg_newoperation(pParser,ICO_FREESTACK); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : ON --> 'on' Expr {Statement}"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } /* Generate Code */ ring_parser_icg_newoperation(pParser,ICO_JUMP); ring_list_addpointer(pList2,ring_parser_icg_getactiveoperation(pParser)); } } /* Other */ if ( ring_parser_iskeyword(pParser,K_OTHER) ) { ring_parser_nexttoken(pParser); /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); if ( pMark != NULL ) { ring_parser_icg_addoperandint(pMark,nMark1); pMark = NULL ; } ring_parser_icg_newoperation(pParser,ICO_FREESTACK); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Other --> 'Other' {Statement}"); #endif while ( ring_parser_stmt(pParser) ) { if ( pParser->ActiveToken == pParser->TokensCount ) { break ; } } } /* OFF */ if ( ring_parser_iskeyword(pParser,K_OFF) ) { ring_parser_nexttoken(pParser); /* Generate Code */ nMark1 = ring_parser_icg_newlabel(pParser); if ( pMark != NULL ) { ring_parser_icg_addoperandint(pMark,nMark1); } if ( ring_list_getsize(pList2) > 0 ) { for ( x = 1 ; x <= ring_list_getsize(pList2) ; x++ ) { ring_parser_icg_addoperandint(((List *) ring_list_getpointer(pList2,x)),nMark1); } } ring_list_delete(pList2); ring_parser_icg_newoperation(pParser,ICO_FREESTACK); #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : OFF --> 'Off'"); #endif return 1 ; } else { ring_parser_error(pParser,RING_PARSER_ERROR_SWITCHOFF); } } else { ring_parser_error(pParser,RING_PARSER_ERROR_SWITCHEXPR); } } /* Statement --> epslion */ if ( ring_parser_epslion(pParser) ) { return 1 ; } /* Statement --> Expr */ if ( ring_parser_expr(pParser) ) { #if RING_PARSERTRACE RING_STATE_CHECKPRINTRULES puts("Rule : Statement --> Expr "); #endif ring_parser_icg_newoperation(pParser,ICO_FREESTACK); return 1 ; } return 0 ; }
GNetworkAccessManager::~GNetworkAccessManager() { ring_list_delete(this->pParaList); }
GVideoWidget::~GVideoWidget() { ring_list_delete(this->pParaList); }
GDial::~GDial() { ring_list_delete(this->pParaList); }
GSlider::~GSlider() { ring_list_delete(this->pParaList); }
GTcpServer::~GTcpServer() { ring_list_delete(this->pParaList); }
GPlainTextEdit::~GPlainTextEdit() { ring_list_delete(this->pParaList); }