s502 assembler
A very simple assembler for the 6502 line of processors written in C
|
Simple key->value map (str->int) More...
#include <map.h>
Public Member Functions | |
Map * | map_new () |
Create a new map with 0 elements. More... | |
int | map_set (Map *map, char *name, int value) |
Sets a key in the map. More... | |
int | map_get (Map *map, char *name) |
Get the value of a key. More... | |
void | map_free (Map *map) |
Free the map with all associated memory. More... | |
void | map_debug_print (Map *map) |
Print all key-value pairs of the map. More... | |
Data Fields | |
struct MapEntry * | head |
Private Member Functions | |
struct MapEntry * | map_find (Map *map, char *key) |
Find a key in a map. More... | |
Simple key->value map (str->int)
Implemented with a linked list.
Should only store non-negative values, as "NOT FOUND" value is -1
void map_debug_print | ( | Map * | map | ) |
Find a key in a map.
map | map to search in |
key | key to search for |
Definition at line 35 of file map.c.
References head, MAP_MAX_KEY_LEN, and MapEntry::next.
void map_free | ( | Map * | map | ) |
Free the map with all associated memory.
map | the map to free |
Frees the map itself, so it's pointer will be invalid and should be NULLed!
Definition at line 62 of file map.c.
Referenced by state_free().
int map_get | ( | Map * | map, |
char * | name | ||
) |
Get the value of a key.
map | the map to search in |
name | key to search for |
Definition at line 75 of file map.c.
Referenced by number_get_raw(), and pass_one().
Map * map_new | ( | ) |
Create a new map with 0 elements.
Definition at line 17 of file map.c.
Referenced by state_new().
int map_set | ( | Map * | map, |
char * | name, | ||
int | value | ||
) |
Sets a key in the map.
map | map to set key in |
name | key to set |
value | non-negative value to set for the key |
Definition at line 43 of file map.c.
Referenced by pass_one(), and state_parse_commandline().
struct MapEntry* Map::head |
Definition at line 35 of file map.h.
Referenced by map_debug_print(), map_find(), map_free(), map_new(), and map_set().