Implemented and tested variable declaration

Assignment, etc. is still to come, as are types.
This commit is contained in:
2024-10-13 15:02:42 +11:00
parent 1ad6bdff70
commit 80734563b9
18 changed files with 498 additions and 99 deletions

View File

@@ -91,8 +91,7 @@ Toy_String* Toy_createStringLength(Toy_Bucket** bucketHandle, const char* cstrin
return result;
}
TOY_API Toy_String* Toy_createNameString(Toy_Bucket** bucketHandle, const char* cname, Toy_ValueType type) {
unsigned int length = strlen(cname);
Toy_String* Toy_createNameStringLength(Toy_Bucket** bucketHandle, const char* cname, unsigned int length, Toy_ValueType type) {
//name strings can't be broken up
if (sizeof(Toy_String) + length + 1 > (*bucketHandle)->capacity) {
@@ -196,6 +195,15 @@ unsigned int Toy_getStringRefCount(Toy_String* str) {
return str->refCount;
}
Toy_ValueType Toy_getNameStringType(Toy_String* str) {
if (str->type != TOY_STRING_NAME) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Can't get the variable type of a non-name string\n" TOY_CC_RESET);
exit(-1);
}
return str->as.name.type;
}
char* Toy_getStringRawBuffer(Toy_String* str) {
if (str->type == TOY_STRING_NAME) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Can't get raw string buffer of a name string\n" TOY_CC_RESET);