added get number of entries function

This commit is contained in:
Partho Bhattacharya
2025-03-27 19:23:05 -04:00
parent 3686a64948
commit 8f1c7590bd
2 changed files with 104 additions and 5 deletions

View File

@ -103,6 +103,14 @@ AdInfo *CreatePrimitiveInfo(int size) {
// only gets the size of a primitive type
int getPrimSize(TableNode *definition) {
if (definition == NULL){
printf("passed an NULL entry to getPrimSize function. Invalid.\n");
return -1;
}
if (definition->additionalinfo == NULL){
printf("node has NULL additionalinfo. Invalid.\n");
return -1;
}
if (strcmp(getType(definition), "primitive") != 0) {
printf("not checking the size of a primitive -- invalid op\n");
return 0;
@ -133,6 +141,11 @@ AdInfo *CreateArrayInfo(int dim, /*int* sizes,*/ TableNode *type) {
}
// This gets the number of dimensions from array info
int getNumArrDim(TableNode *definition) {
if (definition == NULL){
printf("passed an NULL entry to getNumArrDim function. Invalid.\n");
return -1;
}
if(
if (strcmp(getType(definition), "array") != 0) {
printf("not checking the dim of an array -- invalid op\n");
return 0;
@ -181,6 +194,16 @@ SymbolTable *getRecList(TableNode *definition) {
return definition->additionalinfo->RecAdInfo->recordScope;
}
int getRecSize(SymbolTable* tn){
int s = 0;
TableNode* cur = getFirstEntry(tn);
while(getNextEntry(cur) != NULL){
s++;
cur = getNextEntry(cur);
}
return s;
}
// below function takes a bool to see if parameter should be decomposed or not
// note that functions only take one input and have one output
// using "as" the input record can be decomposed to give the illusion of
@ -484,7 +507,7 @@ char *getName(TableNode *tn) {
printf("passed a NULL table entry to getName\n");
return "";
}
if(tn->theType == NULL){
if(tn->theName == NULL){
printf("name of entry is currently NULL, undefined \n");
return "";
}