Skip to content

Commit

Permalink
cleanup wasm code
Browse files Browse the repository at this point in the history
do code more transparent
  • Loading branch information
jmalak committed Feb 22, 2024
1 parent b32db04 commit 442d28d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 18 additions & 4 deletions bld/wasm/c/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool in_prologue;

static assume_info AssumeTable[ASSUME_LAST];

symbol_queue Tables[TAB_LAST];// tables of definitions
symbol_queue Tables[TAB_SIZE];// tables of definitions
module_info ModuleInfo;

static seg_list *ProcStack = NULL;
Expand Down Expand Up @@ -577,7 +577,8 @@ void dir_init( dir_node *dir, int tab )
*/
{
dir->line_num = LineNumber;
dir->next = dir->prev = NULL;
dir->next = NULL;
dir->prev = NULL;

switch( tab ) {
case TAB_SEG:
Expand Down Expand Up @@ -667,20 +668,33 @@ void dir_init( dir_node *dir, int tab )
}

static void dir_move_to_tail( dir_node *dir, int tab )
/****************************************************/
/*****************************************************
* move item which is already in the list to the end of list
* expect the item is not last item that the list contains
* at minimum two items
*/
{
/*
* already on tail, no action
*/
if( dir->next == NULL )
return;
/*
* first remove it from list
*/
dir->next->prev = dir->prev;
if( dir->prev == NULL ) {
Tables[tab].head = dir->next;
} else {
dir->prev->next = dir->next;
}
/*
* add it to tail
*/
dir->next = NULL;
dir->prev = Tables[tab].tail;
dir->prev->next = dir;
Tables[tab].tail = dir;
dir->next = NULL;
}

static dir_node *RemoveFromTable( dir_node *dir )
Expand Down
7 changes: 3 additions & 4 deletions bld/wasm/h/directiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ typedef enum {
#define NUM_OS 2

enum {
TAB_FIRST = 0,
TAB_SEG = TAB_FIRST, // order seg, grp, lname is important
TAB_SEG, // order seg, grp, lname is important
TAB_GRP,
TAB_LIB,
TAB_EXT,
Expand All @@ -86,7 +85,7 @@ enum {
TAB_CLASS_LNAME,
TAB_STRUCT,
TAB_FPPATCH,
TAB_LAST,
TAB_SIZE,
TAB_COMM // TAB_COMM is not included in tables, it is assigned to TAB_EXT
}; // tables for definitions

Expand Down Expand Up @@ -362,7 +361,7 @@ extern module_info ModuleInfo;

extern seg_list *CurrSeg; // points to stack of opened segments

extern symbol_queue Tables[TAB_LAST]; // tables of definitions
extern symbol_queue Tables[TAB_SIZE]; // tables of definitions

/*---------------------------------------------------------------------------*/

Expand Down

0 comments on commit 442d28d

Please sign in to comment.