static void ring_showtime ( void ) { time_t timer ; char buffer[50] ; struct tm*tm_info ; clock_t myclock ; time(&timer); tm_info = localtime(&timer); strftime(buffer,50,"Date : %Y/%m/%d Time : %H:%M:%S", tm_info); printf( "\n" ) ; ring_print_line(); puts(buffer); myclock = clock(); printf( "Clock : %ld \n", myclock ) ; ring_print_line(); }
void ring_parser_icg_showoutput ( List *pListGenCode,int nStatus ) { int x,y,nCount,nCount2 ; List *pList ; assert(pListGenCode != NULL); /* Header */ printf( "\n\n" ) ; ring_print_line(); if ( nStatus == 1 ) { puts("Byte Code - Before Execution by the VM"); } else { puts("Byte Code - After Execution by the VM"); } ring_print_line(); nCount = ring_list_getsize(pListGenCode); if ( nCount > 0 ) { printf( "\n %6s %10s %10s\n", "PC","OPCode","Data" ) ; for ( x = 1 ; x <= nCount ; x++ ) { pList = ring_list_getlist(pListGenCode,x); nCount2 = ring_list_getsize(pList); printf( "\n %6d %10s ", x , RING_IC_OP[ring_list_getint(pList,1)] ) ; if ( nCount2 > 1 ) { for ( y = 2 ; y <= nCount2 ; y++ ) { if ( ring_list_isstring(pList,y) ) { printf( " %5s ",ring_list_getstring(pList,y) ) ; } else if ( ring_list_isnumber(pList,y) ) { if ( ring_list_isdouble(pList,y) ) { printf( " %f",ring_list_getdouble(pList,y) ) ; } else { printf( " %5d ",ring_list_getint(pList,y) ) ; } } else { printf( " %5p ",ring_list_getpointer(pList,y) ) ; } } } } printf( "\n" ) ; } /* End */ puts(""); ring_print_line(); puts(""); }
RING_API void ring_state_main ( int argc, char *argv[] ) { int x,nCGI,nRun,nPrintIC,nPrintICFinal,nTokens,nRules,nIns,nPerformance,nSRC,nGenObj ; const char *cStr ; /* Init Values */ nCGI = 0 ; nRun = 1 ; nPrintIC = 0 ; nPrintICFinal = 0 ; nTokens = 0 ; nRules = 0 ; nIns = 0 ; nPerformance = 0 ; cStr = NULL ; nSRC = 0 ; nGenObj = 0 ; signal(SIGSEGV,segfaultaction); #if RING_TESTUNITS ring_testallunits(); #endif if ( argc > 1 ) { for ( x = 1 ; x < argc ; x++ ) { if ( strcmp(argv[x],"-cgi") == 0 ) { nCGI = 1 ; } else if ( strcmp(argv[x],"-tokens") == 0 ) { nTokens = 1 ; } else if ( strcmp(argv[x],"-rules") == 0 ) { nRules = 1 ; } else if ( strcmp(argv[x],"-ic") == 0 ) { nPrintIC = 1 ; } else if ( strcmp(argv[x],"-norun") == 0 ) { nRun = 0 ; } else if ( strcmp(argv[x],"-icfinal") == 0 ) { nPrintICFinal = 1 ; } else if ( strcmp(argv[x],"-ins") == 0 ) { nIns = 1 ; } else if ( strcmp(argv[x],"-performance") == 0 ) { nPerformance = 1 ; } else if ( strcmp(argv[x],"-go") == 0 ) { nGenObj = 1 ; } else if ( ( ring_issourcefile(argv[x]) || ring_isobjectfile(argv[x])) && nSRC == 0 ) { cStr = argv[x] ; nSRC = 1 ; } } } #if RING_TESTPERFORMANCE if ( nPerformance ) { ring_showtime(); } #endif srand(time(NULL)); /* Check Startup ring.ring */ if ( ring_fexists("ring.ring") && argc == 1 ) { ring_execute("ring.ring",nCGI,nRun,nPrintIC,nPrintICFinal,nTokens,nRules,nIns,nGenObj,argc,argv); exit(0); } /* Print Version */ if ( (argc == 1) || (cStr == NULL) ) { ring_print_line(); printf( "Ring version %s \n2013-2016, Mahmoud Fayed <*****@*****.**>\n",RING_VERSION ) ; puts("Usage : ring filename.ring [Options]"); ring_print_line(); /* Options */ puts("-tokens : Print a list of tokens in the source code file"); puts("-rules : Print grammar rules applied on the tokens"); puts("-ic : Print the intermediate byte code (before execution)"); puts("-icfinal : Print the final byte code (after execution)"); puts("-cgi : Print http response header before error messages"); puts("-norun : Don't run the program after compiling"); puts("-ins : Print instruction operation code before execution"); puts("-clock : Print clock before and after program execution"); puts("-go : Generate object file"); ring_print_line(); exit(0); } ring_execute(cStr,nCGI,nRun,nPrintIC,nPrintICFinal,nTokens,nRules,nIns,nGenObj,argc,argv); #if RING_TESTPERFORMANCE if ( nPerformance ) { ring_showtime(); } #endif }