forked from solstice/solstice
Struct field access (slightly buggy)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user