Struct field access (slightly buggy)

This commit is contained in:
2026-04-10 10:14:23 +10:00
parent 5841a7a999
commit fd08b7cdb7
3 changed files with 41 additions and 0 deletions

View File

@@ -213,3 +213,12 @@ ResultType(GroundArg, charptr) createGroundArgFromSolsType(SolsType* type, struc
}
return Error(GroundArg, charptr, "How did we get here?");
}
ResultType(SolsType, charptr) findStructMemberType(SolsType* type, char* member) {
for (size_t i = 0; i < type->children.count; i++) {
if (strcmp(type->children.at[i].name, member) == 0) {
return Success(SolsType, charptr, type->children.at[i].type);
}
}
return Error(SolsType, charptr, "Could not find member");
}

View File

@@ -114,4 +114,7 @@ void freeSolsType(SolsType* type);
// Compares two SolsTypes
bool compareTypes(SolsType* left, SolsType* right);
// Finds the type of a struct member. Errors if the member is not found.
ResultType(SolsType, charptr) findStructMemberType(SolsType* type, char* member);
#endif