private and protected fields

This commit is contained in:
2026-04-12 21:16:59 +10:00
parent d24462f844
commit f384e19c06
9 changed files with 133 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ typedef enum SolsTokenType {
STT_OP_GREATER, STT_OP_LESSER, STT_OP_EQUAL, STT_OP_INEQUAL, STT_OP_EQGREATER, STT_OP_EQLESSER,
STT_KW_DEF, STT_KW_LAMBDA, STT_KW_RETURN,
STT_KW_USE, STT_KW_STRUCT, STT_KW_CONSTRUCTOR, STT_KW_DESTRUCTOR,
STT_KW_PRIVATE, STT_KW_PROTECTED,
STT_KW_PUTS, STT_KW_IF, STT_KW_WHILE,
STT_KW_NEW, STT_KW_GROUND, STT_LINE_END, STT_COMMA
} SolsTokenType;

View File

@@ -1,5 +1,4 @@
#include "SolsType.h"
#include "lexer.h"
#include "../include/error.h"
#include "../include/estr.h"
#include <groundvm.h>
@@ -18,7 +17,9 @@ ResultType(SolsType, charptr) createSolsType(SolsTypeType in) {
.children.count = 0,
.children.at = ptr,
.typeIsKnown = true,
.needsGroundStruct = false
.needsGroundStruct = false,
.metadata.isPrivate = false,
.metadata.isProtected = false
};
return Success(SolsType, charptr, type);
}
@@ -37,7 +38,9 @@ ResultType(SolsType, charptr) createIdentifiedSolsType(char* in) {
.children.count = 0,
.children.at = NULL,
.typeIsKnown = false,
.needsGroundStruct = false
.needsGroundStruct = false,
.metadata.isPrivate = false,
.metadata.isProtected = false
}));
}
@@ -50,7 +53,8 @@ ResultType(SolsType, charptr) copySolsType(SolsType* type) {
.returnType = NULL,
.children.count = type->children.count,
.children.capacity = type->children.capacity,
.children.at = NULL
.children.at = NULL,
.metadata = type->metadata
};
if (type->identifierType != NULL) {

View File

@@ -68,6 +68,11 @@ typedef struct SolsType {
size_t count;
size_t capacity;
} children;
struct {
bool isPrivate;
bool isProtected;
} metadata;
} SolsType;
// Assists with holding child types in the SolsType struct.

View File

@@ -17,6 +17,8 @@ struct _SolsTokenTypeMap SolsTokenTypeMap[] = {
{"struct", STT_KW_STRUCT},
{"constructor", STT_KW_CONSTRUCTOR},
{"destructor", STT_KW_DESTRUCTOR},
{"private", STT_KW_PRIVATE},
{"protected", STT_KW_PROTECTED},
{"ground", STT_KW_GROUND},
{"new", STT_KW_NEW},
{"{", STT_OPEN_CURLY},