⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sde.c

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 C
📖 第 1 页 / 共 2 页
字号:
            new_stratumTableSize = stratumTableSize == 0?                                  INIT_SIZE_STRATUM :                                  stratumTableSize * 2;            allocSize = new_stratumTableSize * (int)sizeof(StratumTableRecord);            new_stratumTable = jvmtiAllocate((jint)allocSize);            if ( new_stratumTable == NULL ) {                EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY, "SDE stratum table");            }            if ( stratumTable!=NULL ) {                (void)memcpy(new_stratumTable, stratumTable,                        stratumTableSize * (int)sizeof(StratumTableRecord));                jvmtiDeallocate(stratumTable);            }            stratumTable     = new_stratumTable;            stratumTableSize = new_stratumTableSize;        }    }    private String readLine(void) {        char *initialPos;        char ch;        ignoreWhite();        initialPos = sdePos;        while (((ch = *sdePos) != '\n') && (ch != '\r')) {            if (ch == 0) {                syntax("unexpected EOF");            }            ++sdePos;        }        *sdePos++ = 0; /* null terminate string - mangles SDE */        /* check for CR LF */        if ((ch == '\r') && (*sdePos == '\n')) {            ++sdePos;        }        ignoreWhite(); /* leading white */        return initialPos;    }    private int defaultStratumTableIndex(void) {        if ((defaultStratumIndex == -1) && (defaultStratumId != null)) {            defaultStratumIndex =                 stratumTableIndex(defaultStratumId);        }        return defaultStratumIndex;    }       private int stratumTableIndex(String stratumId) {        int i;        if (stratumId == null) {            return defaultStratumTableIndex();        }        for (i = 0; i < (stratumIndex-1); ++i) {            if (strcmp(stratumTable[i].id, stratumId) == 0) {                return i;            }        }        return defaultStratumTableIndex();    }   /***************************** * below functions/methods are written to compile under either Java or C *  * Needed support functions: *   sdePeek() *   sdeRead() *   sdeAdvance() *   readLine() *   assureLineTableSize() *   assureFileTableSize() *   assureStratumTableSize() *   syntax(String) * *   stratumTableIndex(String) * * Needed support variables: *   lineTable *   lineIndex *   fileTable *   fileIndex *   currentFileId * * Needed types: *   String * * Needed constants: *   NullString */    private void ignoreWhite(void) {        char ch;        while (((ch = sdePeek()) == ' ') || (ch == '\t')) {            sdeAdvance();        }    }    private void ignoreLine(void) {        char ch;        do {           ch = sdeRead();        } while ((ch != '\n') && (ch != '\r'));                /* check for CR LF */        if ((ch == '\r') && (sdePeek() == '\n')) {            sdeAdvance();        }        ignoreWhite(); /* leading white */    }    private int readNumber(void) {        int value = 0;        char ch;        ignoreWhite();        while (((ch = sdePeek()) >= '0') && (ch <= '9')) {            sdeAdvance();            value = (value * 10) + ch - '0';        }        ignoreWhite();        return value;    }    private void storeFile(int fileId, String sourceName, String sourcePath) {        assureFileTableSize();        fileTable[fileIndex].fileId = fileId;        fileTable[fileIndex].sourceName = sourceName;        fileTable[fileIndex].sourcePath = sourcePath;        ++fileIndex;    }    private void fileLine(void) {        int hasAbsolute = 0; /* acts as boolean */        int fileId;        String sourceName;        String sourcePath = null;        /* is there an absolute filename? */        if (sdePeek() == '+') {            sdeAdvance();            hasAbsolute = 1;        }        fileId = readNumber();        sourceName = readLine();        if (hasAbsolute == 1) {            sourcePath = readLine();        }        storeFile(fileId, sourceName, sourcePath);    }    private void storeLine(int jplsStart, int jplsEnd, int jplsLineInc,                   int njplsStart, int njplsEnd, int fileId) {        assureLineTableSize();        lineTable[lineIndex].jplsStart = jplsStart;        lineTable[lineIndex].jplsEnd = jplsEnd;        lineTable[lineIndex].jplsLineInc = jplsLineInc;        lineTable[lineIndex].njplsStart = njplsStart;        lineTable[lineIndex].njplsEnd = njplsEnd;        lineTable[lineIndex].fileId = fileId;        ++lineIndex;    }    /**     * Parse line translation info.  Syntax is     *     <NJ-start-line> [ # <file-id> ] [ , <line-count> ] :      *                 <J-start-line> [ , <line-increment> ] CR     */    private void lineLine(void) {        int lineCount = 1;        int lineIncrement = 1;        int njplsStart;        int jplsStart;        njplsStart = readNumber();        /* is there a fileID? */        if (sdePeek() == '#') {            sdeAdvance();            currentFileId = readNumber();        }        /* is there a line count? */        if (sdePeek() == ',') {            sdeAdvance();            lineCount = readNumber();        }        if (sdeRead() != ':') {            syntax("expected ':'");        }        jplsStart = readNumber();        if (sdePeek() == ',') {            sdeAdvance();            lineIncrement = readNumber();        }        ignoreLine(); /* flush the rest */                storeLine(jplsStart,                  jplsStart + (lineCount * lineIncrement) -1,                  lineIncrement,                  njplsStart,                  njplsStart + lineCount -1,                  currentFileId);    }    /**     * Until the next stratum section, everything after this     * is in stratumId - so, store the current indicies.     */    private void storeStratum(String stratumId) {        /* remove redundant strata */        if (stratumIndex > 0) {            if ((stratumTable[stratumIndex-1].fileIndex                                             == fileIndex) &&                (stratumTable[stratumIndex-1].lineIndex                                             == lineIndex)) {                /* nothing changed overwrite it */                --stratumIndex;            }        }        /* store the results */        assureStratumTableSize();        stratumTable[stratumIndex].id = stratumId;        stratumTable[stratumIndex].fileIndex = fileIndex;        stratumTable[stratumIndex].lineIndex = lineIndex;        ++stratumIndex;        currentFileId = 0;    }    /**     * The beginning of a stratum's info     */    private void stratumSection(void) {        storeStratum(readLine());    }    private void fileSection(void) {        ignoreLine();        while (sdePeek() != '*') {            fileLine();        }    }    private void lineSection(void) {        ignoreLine();        while (sdePeek() != '*') {            lineLine();        }    }    /**     * Ignore a section we don't know about.     */    private void ignoreSection(void) {        ignoreLine();        while (sdePeek() != '*') {            ignoreLine();        }    }    /**     * A base "Java" stratum is always available, though     * it is not in the SourceDebugExtension.     * Create the base stratum.     */    private void createJavaStratum(void) {        baseStratumIndex = stratumIndex;        storeStratum(BASE_STRATUM_NAME);        storeFile(1, jplsFilename, NullString);        /* JPL line numbers cannot exceed 65535 */        storeLine(1, 65536, 1, 1, 65536, 1);        storeStratum("Aux"); /* in case they don't declare */    }    /**     * Decode a SourceDebugExtension which is in SourceMap format.     * This is the entry point into the recursive descent parser.     */    private void decode(void) {        /* check for "SMAP" - allow EOF if not ours */        if (strlen(sourceDebugExtension) <= 4 ||            (sdeRead() != 'S') ||            (sdeRead() != 'M') ||            (sdeRead() != 'A') ||            (sdeRead() != 'P')) {            return; /* not our info */        }        ignoreLine(); /* flush the rest */        jplsFilename = readLine();        defaultStratumId = readLine();        createJavaStratum();        while (true) {            if (sdeRead() != '*') {                syntax("expected '*'");            }            switch (sdeRead()) {                case 'S':                     stratumSection();                    break;                case 'F':                     fileSection();                    break;                case 'L':                     lineSection();                    break;                case 'E':                     /* set end points */                    storeStratum("*terminator*");                     sourceMapIsValid = true;                    return;                default:                    ignoreSection();            }        }    }    /***************** query functions ***********************/    private int stiLineTableIndex(int sti, int jplsLine) {        int i;        int lineIndexStart;        int lineIndexEnd;        lineIndexStart = stratumTable[sti].lineIndex;        /* one past end */        lineIndexEnd = stratumTable[sti+1].lineIndex;         for (i = lineIndexStart; i < lineIndexEnd; ++i) {            if ((jplsLine >= lineTable[i].jplsStart) &&                            (jplsLine <= lineTable[i].jplsEnd)) {                return i;            }        }        return -1;    }    private int stiLineNumber(int sti, int lti, int jplsLine) {        return lineTable[lti].njplsStart +                 (((jplsLine - lineTable[lti].jplsStart) /                                    lineTable[lti].jplsLineInc));    }#if 0/* not referenced */    private int fileTableIndex(int sti, int fileId) {        int i;        int fileIndexStart = stratumTable[sti].fileIndex;        /* one past end */        int fileIndexEnd = stratumTable[sti+1].fileIndex;         for (i = fileIndexStart; i < fileIndexEnd; ++i) {            if (fileTable[i].fileId == fileId) {                return i;            }        }        return -1;    }    private int stiFileTableIndex(int sti, int lti) {        return fileTableIndex(sti, lineTable[lti].fileId);    }#endif    private jboolean isValid(void) {        return sourceMapIsValid;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -