Files
ground-rewrite/src/libmain.c

161 lines
5.0 KiB
C
Raw Normal View History

2026-06-13 19:45:36 +10:00
#include "../include/ground.h"
GroundValue _GroundNewValueInt(GroundInt in);
GroundValue _GroundNewValueDouble(GroundDouble in);
GroundValue _GroundNewValueChar(GroundChar in);
GroundValue _GroundNewValueBool(GroundBool in);
GroundValue _GroundNewValueList(GroundList in);
GroundValue _GroundNewValueString(GroundString in);
GroundValue _GroundNewValueFunction(GroundFunction in);
GroundValue _GroundNewValueStruct(GroundStruct in);
GroundValue _GroundNewValueObject(GroundObject in);
GroundArg _GroundNewArgValue(GroundValue value);
GroundArg _GroundNewArgValueRef(const char* ref);
GroundArg _GroundNewArgDirectRef(const char* ref);
GroundArg _GroundNewArgLineRef(const char* ref);
GroundArg _GroundNewArgLabelRef(const char* ref);
GroundArg _GroundNewArgFunctionRef(const char* ref);
GroundArg _GroundNewArgTypeRef(const char* ref);
GroundList _GroundNewList();
GroundString _GroundNewString(const char* in);
GroundFunction _GroundNewFunction(GroundState* state);
GroundFunction _GroundNewNativeFunction(void* function, size_t argc, ...);
GroundStruct _GroundNewStruct();
GroundObject _GroundNewObject(GroundStruct* in);
GroundError _GroundNewError(GroundValue* in);
GroundInstruction _GroundNewInstruction(enum GroundInstructionType type);
GroundProgram _GroundNewProgram();
GroundType _GroundNewType(enum GroundTypeType type, ...);
void _GroundFreeValue(GroundValue* in);
void _GroundFreeList(GroundList* in);
void _GroundFreeString(GroundString* in);
void _GroundFreeFunction(GroundFunction* in);
void _GroundFreeStruct(GroundStruct* in);
void _GroundFreeObject(GroundObject* in);
GroundValue _GroundCopyValue(GroundValue* in);
GroundList _GroundCopyList(GroundList* in);
GroundString _GroundCopyString(GroundString* in);
GroundFunction _GroundCopyFunction(GroundFunction* in);
GroundStruct _GroundCopyStruct(GroundStruct* in);
GroundObject _GroundCopyObject(GroundObject* in);
GroundArg _GroundCopyArg(GroundArg* in);
GroundInstruction _GroundCopyInstruction(GroundInstruction* in);
GroundProgram _GroundCopyProgram(GroundProgram* in);
GroundState _GroundCopyState(GroundState* in);
void _GroundListAppend(GroundList* list, GroundValue value);
void _GroundInstructionAppend(GroundInstruction* instruction, GroundArg arg);
void _GroundInstructionExecute(GroundInstruction* instruction, GroundState* state);
void _GroundProgramAppend(GroundProgram* program, GroundInstruction instruction);
void _GroundProgramExecute(GroundProgram* program, GroundState* state);
void _GroundFunctionAppendInstruction(GroundFunction* function, GroundInstruction instruction);
void _GroundFunctionAppendArg(GroundFunction* function, const char* argName);
void _GroundStructAddField(GroundStruct* gs, const char* id, GroundValue value);
struct _Ground Ground = {
.Flags = {
.error = false
},
.New = {
.Value = {
.Int = _GroundNewValueInt,
.Double = _GroundNewValueDouble,
.Char = _GroundNewValueChar,
.Bool = _GroundNewValueBool,
.List = _GroundNewValueList,
.String = _GroundNewValueString,
.Function = _GroundNewValueFunction,
.Struct = _GroundNewValueStruct,
.Object = _GroundNewValueObject,
},
.Arg = {
.Value = _GroundNewArgValue,
.ValueRef = _GroundNewArgValueRef,
.DirectRef = _GroundNewArgDirectRef,
.LineRef = _GroundNewArgLineRef,
.LabelRef = _GroundNewArgLabelRef,
.FunctionRef = _GroundNewArgFunctionRef,
.TypeRef = _GroundNewArgTypeRef,
},
.List = _GroundNewList,
.String = _GroundNewString,
.Function = _GroundNewFunction,
.Struct = _GroundNewStruct,
.Object = _GroundNewObject,
.Error = _GroundNewError,
.NativeFunction = _GroundNewNativeFunction,
.Instruction = _GroundNewInstruction,
.Program = _GroundNewProgram,
.Type = _GroundNewType,
},
.Free = {
.Value = _GroundFreeValue,
.List = _GroundFreeList,
.String = _GroundFreeString,
.Function = _GroundFreeFunction,
.Struct = _GroundFreeStruct,
.Object = _GroundFreeObject,
},
.Copy = {
.Value = _GroundCopyValue,
.List = _GroundCopyList,
.String = _GroundCopyString,
.Function = _GroundCopyFunction,
.Struct = _GroundCopyStruct,
.Object = _GroundCopyObject,
.Arg = _GroundCopyArg,
.Instruction = _GroundCopyInstruction,
.Program = _GroundCopyProgram,
.State = _GroundCopyState,
},
.List = {
.append = _GroundListAppend,
},
.Instruction = {
.append = _GroundInstructionAppend,
.execute = _GroundInstructionExecute,
},
.Program = {
.append = _GroundProgramAppend,
.execute = _GroundProgramExecute,
},
.Function = {
.appendInstruction = _GroundFunctionAppendInstruction,
.appendArg = _GroundFunctionAppendArg,
},
.Struct = {
.addField = _GroundStructAddField,
},
};