int run_file() { Node *ptree; AstNode *stree; EmCodeObject *co; EmObject *retval; ptree = parse(); if (ptree) { printtree(ptree); stree = ast_from_ptree(ptree); printstree(stree); co = compile_ast_tree(stree); printobj((EmObject *)co, stdout); INCREF(&nulobj); retval = run_codeobject(co, NULL, &nulobj); if (retval) DECREF(retval); freetree(ptree); freestree(stree); } fclose(source.fp); return 1; }
int run_prompt() { Node *ptree; AstNode *stree; EmCodeObject *co; Environment *env; EmObject *retval; env = newenv(vm->topenv); while (1) { ptree = parse(); if (ptree) { if (ptree->type != MAGIC_COMMAND) { // printtree(ptree); stree = ast_from_ptree(ptree); // printstree(stree); co = compile_ast_tree(stree); INCREF(&nulobj); retval = run_codeobject(co, env, &nulobj); if (retval) DECREF(retval); vm_reset_for_prompt(); freetree(ptree); freestree(stree); } else { // MAGIC_COMMAND printf("got magic command %d\n", CHILD(ptree,0)->type); if (NCH(ptree) == 2) { printf("magic command arg = %s\n", CHILD(ptree,1)->lexeme); } if (CHILD(ptree,0)->type == MCA_EXIT) { freetree(ptree); // release memory before exit break; } // Always release memory of parse tree freetree(ptree); } } } env_free(env); return 1; }
Sint procmaxmatches(MMcallinfo *mmcallinfo,Multiseq *subjectmultiseq) { Matchprocessinfo matchprocessinfo; Uint filenum, filelen; Sint retcode; Uchar *filecontent; double start, finish; /*fprintf(stderr,"# construct suffix tree for sequence of length %lu\n", (Showuint) subjectmultiseq->totallength); fprintf(stderr,"# (maximum reference length is %lu)\n", (Showuint) getmaxtextlenstree()); fprintf(stderr,"# (maximum query length is %lu)\n", (Showuint) ~((Uint)0));*/ start = omp_get_wtime(); if(constructprogressstree (&matchprocessinfo.stree, subjectmultiseq->sequence, subjectmultiseq->totallength, NULL, NULL, NULL) != 0) { return -1; } finish = omp_get_wtime(); /*fprintf(stderr,"# CONSTRUCTIONTIME %s %s %.2f\n", &mmcallinfo->program[0],&mmcallinfo->subjectfile[0], getruntime());*/ matchprocessinfo.subjectmultiseq = subjectmultiseq; matchprocessinfo.minmatchlength = mmcallinfo->minmatchlength; matchprocessinfo.showstring = mmcallinfo->showstring; matchprocessinfo.showsequencelengths = mmcallinfo->showsequencelengths; matchprocessinfo.showreversepositions = mmcallinfo->showreversepositions; matchprocessinfo.forward = mmcallinfo->forward; matchprocessinfo.fourcolumn = mmcallinfo->fourcolumn; matchprocessinfo.cmum = mmcallinfo->cmum; matchprocessinfo.cmumcand = mmcallinfo->cmumcand; matchprocessinfo.reversecomplement = mmcallinfo->reversecomplement; matchprocessinfo.chunks = mmcallinfo->chunks; if(mmcallinfo->cmum) { INITARRAY(&matchprocessinfo.mumcandtab,MUMcandidate); } retcode = getmaxdesclen(subjectmultiseq); if(retcode < 0) { return -2; } matchprocessinfo.maxdesclength = (Uint) retcode; for(filenum=0; filenum < mmcallinfo->numofqueryfiles; filenum++) { filecontent = CREATEMEMORYMAP (mmcallinfo->queryfilelist[filenum], True, &filelen); if (filecontent == NULL || filelen == 0) { ERROR2("cannot open file \"%s\" or file \"%s\" is empty", mmcallinfo->queryfilelist[filenum], mmcallinfo->queryfilelist[filenum]); return -3; } if (scanmultiplefastafile (&matchprocessinfo.querymultiseq, mmcallinfo->queryfilelist[filenum], mmcallinfo->matchnucleotidesonly ? MMREPLACEMENTCHARQUERY : 0, filecontent, filelen) != 0) { return -4; } /*fprintf(stderr, "# matching query-file \"%s\"\n# against subject-file \"%s\"\n", mmcallinfo->queryfilelist[filenum], mmcallinfo->subjectfile);*/ if (overallsequences (False, &matchprocessinfo.querymultiseq, (void *) &matchprocessinfo, findmaxmatchesonbothstrands) != 0) { return -5; } freemultiseq(&matchprocessinfo.querymultiseq); } if(mmcallinfo->cmum) { FREEARRAY(&matchprocessinfo.mumcandtab,MUMcandidate); } freestree (&matchprocessinfo.stree); fprintf(stdout,"ST=%f,",(double) (finish-start)); return 0; }