Exemple #1
0
//inline
struct pstack * push(struct pstack *s, void* d)
{
    if(s==NULL) s = newstack();
    if(s->size == s->maxsize) resize(s);

    s->items[s->size++] = d;
    return s;
}
Exemple #2
0
void OSR::findLeadingOpnd(Inst* newDef, SsaOpnd* opnd) {
    Node* node = newDef->getNode();
    LoopNode* lnode = this->loopTree->getLoopNode(node, false);
    OSRInductionDetector::InstStack newstack(this->mm);
    OSROpndInfo oinfo = OSRInductionDetector::processOpnd(loopTree, lnode, newstack, opnd);
    if (oinfo.isHeaderFound()) {
        writeLeadingOperand(opnd, (SsaOpnd*) oinfo.getHeader());
    }
}
Exemple #3
0
int main(int argc, char**argv)
{
    FreqNode *root;
    char *alltext;
    FreqNode *buffer[256] = { NULL };
    NodeLList *txtfreqs = newlist();
    NodeLList *auxlist;
    Stack *auxstack;
    char auxchar;
    char auxchar2;
    int i, j;
    int numvalidsymbols;
    int highestfreq;
    int isfirst;
    
    if (argc == 1) {
        printf("Error: Missing filename as argument.\n");
        exit(-1);
    }

    alltext = readfile(argv[1], buffer);

    numvalidsymbols = 0;
    for (i = 0; i < 256; i++) {
        if (buffer[i] &&
            strcmp(buffer[i]->sym, " ") >= 0 &&
            strcmp(buffer[i]->sym, "~") <= 0
            ) {
            numvalidsymbols++;
        }
    }

    isfirst = 1;
    for (i = 0; i < numvalidsymbols; i++) {
        for (j = 32; j < 127; j++) {
            if (buffer[j] && isfirst) {
                highestfreq = j;
                isfirst = 0;
            } else if (buffer[j] && buffer[j]->freq > buffer[highestfreq]->freq) {
                highestfreq = j;
            }
        }
        addend(&txtfreqs, buffer[highestfreq]);
        buffer[highestfreq] = NULL;
        isfirst = 1;
    }

    auxlist = copylist(txtfreqs);
    root = huffman(&txtfreqs, numvalidsymbols-1);
    auxstack = newstack();
    auxchar = 0 << 7 | 0 << 6 | 0 << 5 | 0 << 4 | 0 << 3 | 0 << 2 | 0 << 1 | 0 << 0;
    push(&auxstack, auxchar);
    generatehuffcodes(&root, &auxstack, 0);
    writefile(argv[1], alltext, root, auxlist, numvalidsymbols);
    return 0;
}