コード例 #1
0
ファイル: error.c プロジェクト: Michaelangel007/cc65
static void AddNotifications (const Collection* LineInfos)
/* Output additional notifications for an error or warning */
{
    unsigned I;
    unsigned Output;
    unsigned Skipped;

    /* The basic line info is always in slot zero. It has been used to
    ** output the actual error or warning. The following slots may contain
    ** more information. Check them and print additional notifications if
    ** they're present, but limit the number to a reasonable value.
    */
    for (I = 1, Output = 0, Skipped = 0; I < CollCount (LineInfos); ++I) {
        /* Get next line info */
        const LineInfo* LI = CollConstAt (LineInfos, I);
        /* Check the type and output an appropriate note */
        const char* Msg;
        switch (GetLineInfoType (LI)) {

        case LI_TYPE_ASM:
            Msg = "Expanded from here";
            break;

        case LI_TYPE_EXT:
            Msg = "Assembler code generated from this line";
            break;

        case LI_TYPE_MACRO:
            Msg = "Macro was defined here";
            break;

        case LI_TYPE_MACPARAM:
            Msg = "Macro parameter came from here";
            break;

        default:
            /* No output */
            Msg = 0;
            break;

        }

        /* Output until an upper limit of messages is reached */
        if (Msg) {
            if (Output < MAX_NOTES) {
                PrintMsg (GetSourcePos (LI), "Note", "%s", Msg);
                ++Output;
            } else {
                ++Skipped;
            }
        }
    }

    /* Add a note if we have more stuff that we won't output */
    if (Skipped > 0) {
        const LineInfo* LI = CollConstAt (LineInfos, 0);
        PrintMsg (GetSourcePos (LI), "Note",
                  "Dropping %u additional line infos", Skipped);
    }
}
コード例 #2
0
ファイル: condasm.c プロジェクト: MonteCarlos/cc65
void CheckOpenIfs (void)
/* Called from the scanner before closing an input file. Will check for any
** open .ifs in this file.
*/
{
    const LineInfo* LI;

    while (1) {
        /* Get the current file number and check if the topmost entry on the
        ** .IF stack was inserted with this file number
        */
        IfDesc* D = GetCurrentIf ();
        if (D == 0) {
            /* There are no open .IFs */
            break;
        }

        LI = CollConstAt (&D->LineInfos, 0);
        if (GetSourcePos (LI)->Name != CurTok.Pos.Name) {
            /* The .if is from another file, bail out */
            break;
        }

        /* Start of .if is in the file we're about to leave */
        LIError (&D->LineInfos, "Conditional assembly branch was never closed");
        FreeIf ();
    }

    /* Calculate the new overall .IF condition */
    CalcOverallIfCond ();
}
コード例 #3
0
ファイル: error.c プロジェクト: Michaelangel007/cc65
void ErrorMsg (const Collection* LineInfos, const char* Format, va_list ap)
/* Print an error message */
{
    /* The first entry in the collection is that of the actual source pos */
    const LineInfo* LI = CollConstAt (LineInfos, 0);

    /* Output an error for this position */
    VPrintMsg (GetSourcePos (LI), "Error", Format, ap);

    /* Add additional notifications if necessary */
    AddNotifications (LineInfos);

    /* Count errors */
    ++ErrorCount;
}
コード例 #4
0
ファイル: error.c プロジェクト: Michaelangel007/cc65
static void WarningMsg (const Collection* LineInfos, const char* Format, va_list ap)
/* Print warning message. */
{
    /* The first entry in the collection is that of the actual source pos */
    const LineInfo* LI = CollConstAt (LineInfos, 0);

    /* Output a warning for this position */
    VPrintMsg (GetSourcePos (LI), "Warning", Format, ap);

    /* Add additional notifications if necessary */
    AddNotifications (LineInfos);

    /* Count warnings */
    ++WarningCount;
}