Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
811 B
1
Indexable
Never
Object *findVariable(char* variableName) {
    struct list_scope *scope = current;
    struct list_variable *temp;

    // Traverse the chain of scopes from the current scope to the global scope
    while (scope != NULL) {
        // Traverse the list of variables in the current scope
        list_for_each_entry(temp, scope->queue, list) {
            if (strcmp(temp->variableInfo.symbol->name, variableName) == 0) {
                if(temp->variableInfo.type == 1){
                    if(strcmp(temp->variableInfo.symbol->name, "x") == 0) temp->variableInfo.type = 6;
                    else temp->variableInfo.type = 8;
                }
                return &temp->variableInfo;
            }
        }
        scope = list_entry(scope->chain.next, struct list_scope, chain);

    }
    return NULL;
}
Leave a Comment