Exemple #1
0
static Macro* NewMacro (const StrBuf* Name, unsigned char Style)
/* Generate a new macro entry, initialize and return it */
{
    /* Allocate memory */
    Macro* M = xmalloc (sizeof (Macro));

    /* Initialize the macro struct */
    InitHashNode (&M->Node);
    M->LocalCount = 0;
    M->Locals     = 0;
    M->ParamCount = 0;
    M->Params     = 0;
    M->TokCount   = 0;
    M->TokRoot    = 0;
    M->TokLast    = 0;
    SB_Init (&M->Name);
    SB_Copy (&M->Name, Name);
    M->Expansions = 0;
    M->Style      = Style;
    M->Incomplete = 1;

    /* Insert the macro into the hash table */
    HT_Insert (&MacroTab, &M->Node);

    /* Return the new macro struct */
    return M;
}
Exemple #2
0
static Macro* NewMacro (const StrBuf* Name, unsigned char Style)
/* Generate a new macro entry, initialize and return it */
{
    /* Allocate memory */
    Macro* M = xmalloc (sizeof (Macro));

    /* Initialize the macro struct */
    InitHashNode (&M->Node, M);
    M->LocalCount = 0;
    M->Locals     = 0;
    M->ParamCount = 0;
    M->Params     = 0;
    M->TokCount	  = 0;
    M->TokRoot    = 0;
    M->TokLast    = 0;
    M->Style	  = Style;
    M->Name       = AUTO_STRBUF_INITIALIZER;
    SB_Copy (&M->Name, Name);

    /* Insert the macro into the global macro list */
    M->List = MacroRoot;
    MacroRoot = M;

    /* Insert the macro into the hash table */
    HT_Insert (&MacroTab, &M->Node);

    /* Return the new macro struct */
    return M;
}
Exemple #3
0
static LineInfo* NewLineInfo (const LineInfoKey* Key)
/* Create and return a new line info. Usage will be zero. */
{
    /* Allocate memory */
    LineInfo* LI = xmalloc (sizeof (LineInfo));

    /* Initialize the fields */
    InitHashNode (&LI->Node);
    LI->Id        = ~0U;
    LI->Key       = *Key;
    LI->RefCount  = 0;
    InitCollection (&LI->Spans);
    InitCollection (&LI->OpenSpans);

    /* Add it to the hash table, so we will find it if necessary */
    HT_Insert (&LineInfoTab, LI);

    /* Return the new struct */
    return LI;
}
Exemple #4
0
static FileEntry* NewFileEntry (unsigned Name, FileType Type,
                                unsigned long Size, unsigned long MTime)
/* Create a new FileEntry, insert it into the tables and return it */
{
    /* Allocate memory for the entry */
    FileEntry* F = xmalloc (sizeof (FileEntry));

    /* Initialize the fields */
    InitHashNode (&F->Node);
    F->Name     = Name;
    F->Index    = CollCount (&FileTab) + 1;     /* First file has index #1 */
    F->Type     = Type;
    F->Size     = Size;
    F->MTime    = MTime;

    /* Insert the file into the file table */
    CollAppend (&FileTab, F);

    /* Insert the entry into the hash table */
    HT_Insert (&HashTab, F);

    /* Return the new entry */
    return F;
}