Exemplo n.º 1
0
    void parse() {
        optionalHeaderOffset_ = source_->pos() - sizeof(optionalHeader_.Magic);

        parseFileHeader();
        parseOptionalHeader();
        parseSections();
        parseSymbols();
        parseImports();
    }
Exemplo n.º 2
0
    void parse() {
        optionalHeaderOffset_ = source_->pos() - sizeof(optionalHeader_.Magic);

        parseFileHeader();
        parseOptionalHeader();
        parseSections();
        parseSymbols();
        parseImports();
        parseExports();
        image_->setEntryPoint(optionalHeader_.ImageBase + optionalHeader_.AddressOfEntryPoint);
    }
Exemplo n.º 3
0
void Parser_Perl::parse()
{
    QString continuation;
    QString *name=new QString();
    QString parent;
    PerlSymbol *parentSymbol=NULL;

    const char *line;
    int line_skip = 0;
    char const *longStringLiteral = NULL;

    while ((line = (const char *) fileReadLine ()) != NULL)
    {
        const char *cp = line;
        char const *keyword;
        //int indent;
        cp = skipSpace (cp);
        if (*cp == '\0')  /* skip blank line */
            continue;
        /* Skip comment if we are not inside a multi-line string. */
        if (*cp == '#' && !longStringLiteral)
            continue;
        /* Deal with line continuation. */
        if (!line_skip) continuation="";
        continuation+=QString(line);
        //vStringStripTrailing(continuation);


        cp = line = continuation.toLatin1().data();
        cp = skipSpace (cp);
        line_skip = 0;

        /* Deal with def and class keywords. */
        keyword = findDefinitionOrClass (cp);
        //printf("LINE_:%s\n",line);
        if (keyword)
        {
            bool found = false;
            bool is_class = false;

            if (!strncmp (keyword, "sub ", 4) && isspace(keyword[3]))
            {
                cp = skipSpace (keyword + 4);
                found = true;
            }
            else if (!strncmp (keyword, "package", 7) && isspace(keyword[7]))
            {
                cp = skipSpace (keyword + 7);
                found = true;
                is_class = true;
            }

            if (found)
            {
                PerlSymbol *symbol = NULL;

                if (is_class)
                {
                    symbol = makeClass (cp, 0);
                    parentSymbol=symbol;
                }
                else
                    symbol = makeFunction(cp, name, parentSymbol);
            }
        }


        /* Find global and class variables */
#ifdef SHOW_VARIABLES
        //char const *variable = findVariable(line);
        char const* variable;
        if (variable)
        {
            const char *start = variable;

            vStringClear (name);
            while (isIdentifierCharacter ((int) *start))
            {
                vStringPut (name, (int) *start);
                ++start;
            }
            vStringTerminate (name);

            PerlSymbol *symbol = NULL;
            PerlSymbol *parentSymbol = getParent(indent);


            symbol = new PerlSymbol(parentSymbol, vStringToQString(name));
            symbol->setIndent(indent);
            symbol->setLine(this->getSourceLineNumber());
            symbol->setIconType(Symbol::IconVar);
        }
#endif

        /* Find and parse imports */
#ifdef SHOW_IMPORTS
        parseImports(line);
#endif
    }

    /* Clean up all memory we allocated. */
    if(name)delete name;
}