forked from ground/cground
List stuff
This commit is contained in:
32
src/types.h
32
src/types.h
@@ -19,6 +19,10 @@ typedef enum GroundArgType {
|
||||
VALUE, VALREF, DIRREF, LINEREF, LABEL, FNREF, TYPEREF
|
||||
} GroundArgType;
|
||||
|
||||
typedef enum ListAccessStatus {
|
||||
LIST_OKAY, LIST_OUT_OF_BOUNDS, LIST_FIXME
|
||||
} ListAccessStatus;
|
||||
|
||||
struct GroundValue;
|
||||
|
||||
struct List;
|
||||
@@ -43,14 +47,25 @@ typedef struct GroundValue {
|
||||
} GroundValue;
|
||||
|
||||
/*
|
||||
* Currently unused. Max, implement this sometime soon.
|
||||
* Custom data type that stores Ground values.
|
||||
* Associated functions:
|
||||
* createList(), appendToList(), getListAt(), setListAt()
|
||||
*/
|
||||
typedef struct List {
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
GroundValue* values;
|
||||
} List;
|
||||
|
||||
/*
|
||||
* Indicates status when accessing a list.
|
||||
* Associated functions:
|
||||
* getListAt()
|
||||
*/
|
||||
typedef struct ListAccess {
|
||||
ListAccessStatus status;
|
||||
GroundValue* value;
|
||||
} ListAccess;
|
||||
|
||||
/*
|
||||
* Stores arguments for the GroundInstruction struct.
|
||||
* Associated functions:
|
||||
@@ -125,4 +140,17 @@ void addArgToInstruction(GroundInstruction* gi, GroundArg arg);
|
||||
// Prints out a GroundInstruction.
|
||||
void printGroundInstruction(GroundInstruction* gi);
|
||||
|
||||
// Creates a Ground list
|
||||
List createList();
|
||||
|
||||
// Add item (value) to List (list)
|
||||
void appendToList(List* list, GroundValue value);
|
||||
|
||||
// Gets item at index (idx) from list (list). If there is an error, it
|
||||
// will be indicated in the status field.
|
||||
ListAccess getListAt(List* list, int idx);
|
||||
|
||||
// Sets an item in list (list) at index (idx) to GroundValue (value).
|
||||
ListAccessStatus setListAt(List* list, int idx, GroundValue value);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user