need to update argument list for the right context

This commit is contained in:
Partho
2025-05-06 15:20:43 -04:00
parent 07255a5193
commit 26b23a68fa
3 changed files with 53 additions and 1 deletions

View File

@ -124,6 +124,48 @@ int getArgumentNumber(Function_Stack *fs) {
return fs->arg;
}
TableNode* getRecordNumberType(TableNode* record, int arg){
if(record == NULL){
//case where NULL is being passed in
return undefined;
}
if(getAdInfoType(record) != TYPE_RECORD_TYPE){
//case where invalid argument number is being passed
return undefined;
}
if(arg<getRecLength(record)){
//case where invalid argument number is being passed
return undefined;
}
int count = 1;
TableNode* this = getFirstEntry(getRecList(record));
while(this != NULL && count<arg){
this = getNextEntry(this);
count++;
}
if(this == NULL){
//something went wrong. traversal is off
return undefined;
}
return getTypeEntry(this);
}
TableNode* getFunctionNumberType(TableNode* function, int arg){
if(function ==NULL){
//case where NULL is being passed in
return undefined;
}
if(arg<1){
//case where invalid argument number is being passed
return undefined;
}
if(getAdInfoType(getParameter(function)) != TYPE_RECORD_TYPE){
return getParameter(function);
}else{
return getRecordNumberType(getParameter(function), arg);
}
}
TableNode* getFunctionTypeContext(Function_Stack *fs) {
if (fs == NULL) {
printdebug(