forked from ground/cground
Function calling
This commit is contained in:
34
src/types.h
34
src/types.h
@@ -12,7 +12,7 @@ typedef enum GroundInstType {
|
||||
} GroundInstType;
|
||||
|
||||
typedef enum GroundValueType {
|
||||
INT, DOUBLE, STRING, CHAR, BOOL, LIST, CUSTOM, NONE
|
||||
INT, DOUBLE, STRING, CHAR, BOOL, LIST, FUNCTION, CUSTOM, NONE
|
||||
} GroundValueType;
|
||||
|
||||
typedef enum GroundArgType {
|
||||
@@ -24,6 +24,7 @@ typedef enum ListAccessStatus {
|
||||
} ListAccessStatus;
|
||||
|
||||
struct GroundValue;
|
||||
struct GroundFunction;
|
||||
|
||||
struct List;
|
||||
|
||||
@@ -52,6 +53,7 @@ typedef struct GroundValue {
|
||||
char charVal;
|
||||
bool boolVal;
|
||||
List listVal;
|
||||
struct GroundFunction* fnVal;
|
||||
void* customVal;
|
||||
} data;
|
||||
} GroundValue;
|
||||
@@ -92,6 +94,33 @@ typedef struct GroundInstruction {
|
||||
} args;
|
||||
} GroundInstruction;
|
||||
|
||||
/*
|
||||
* Represents a Ground program or function.
|
||||
*/
|
||||
typedef struct GroundProgram {
|
||||
GroundInstruction* instructions;
|
||||
size_t size;
|
||||
} GroundProgram;
|
||||
|
||||
/*
|
||||
* Represents the argument typing for a GroundFunction.
|
||||
*/
|
||||
typedef struct GroundFunctionArgs {
|
||||
GroundValueType type;
|
||||
char* name;
|
||||
} GroundFunctionArgs;
|
||||
|
||||
/*
|
||||
* Represents a Ground function.
|
||||
*/
|
||||
typedef struct GroundFunction {
|
||||
GroundFunctionArgs* args;
|
||||
size_t argSize;
|
||||
GroundValueType returnType;
|
||||
GroundProgram program;
|
||||
} GroundFunction;
|
||||
|
||||
|
||||
// Creates a GroundValue containing (in), with type INT.
|
||||
GroundValue createIntGroundValue(int64_t in);
|
||||
|
||||
@@ -110,6 +139,9 @@ GroundValue createBoolGroundValue(bool in);
|
||||
// Creates a GroundValue containing (in), with type LIST.
|
||||
GroundValue createListGroundValue(List in);
|
||||
|
||||
// Creates a GroundValue conatining (in), with type FUNCTION.
|
||||
GroundValue createFunctionGroundValue(GroundFunction* in);
|
||||
|
||||
// Creates a deep copy of a GroundValue
|
||||
GroundValue copyGroundValue(const GroundValue* gv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user