bool exprNodeIdentifierResolve(Node* n, Function* f, CompileUnit* u)
{
    Object* o;
    if (elfGetObject(n->name, f, u, &o)) {
        n->type = o->type;
        n->location = elfDecodeLocation(f, o->location, &n->locType);
        return true;
    } else {
        printf("Object %s not found\n", n->name);
    }
    return false;
}
bool exprNodeArrowResolve(Node *n, Function *f, CompileUnit *u)
{
  if(n->expression->resolve(n->expression, f, u)) {
    TypeEnum tt = n->expression->type->type;
    if(tt != TYPE_pointer) {
      printf("Object not of pointer type\n");
      return false;
    }
    tt = n->expression->type->pointer->type;
    
    if(tt == TYPE_struct ||
       tt == TYPE_union) {
      u32 loc = debuggerReadMemory(n->expression->location);
      Type *t = n->expression->type->pointer;
      int count = t->structure->memberCount;
      int i = 0;
      while(i < count) {
        Member *m = &t->structure->members[i];
        if(strcmp(m->name, n->name) == 0) {
          // found member
          n->type = m->type;
          if(tt == TYPE_struct) {
            n->location = elfDecodeLocation(f, m->location, &n->locType,
                                            loc);
            n->objLocation = loc;
          } else {
            n->location = loc;
            n->objLocation = loc;
          }
          n->locType = LOCATION_memory;
          n->member = m;
          return true;
        }
        i++;
      }
      printf("Member %s not found\n", n->name);
    } else {
      printf("Object is not of structure type\n");
    }
  }
  return false;
}
bool exprNodeDotResolve(Node* n, Function* f, CompileUnit* u)
{
    if (n->expression->resolve(n->expression, f, u)) {
        TypeEnum tt = n->expression->type->type;

        if (tt == TYPE_struct || tt == TYPE_union) {
            uint32_t loc = n->expression->location;
            Type* t = n->expression->type;
            int count = t->structure->memberCount;
            int i = 0;
            while (i < count) {
                Member* m = &t->structure->members[i];
                if (strcmp(m->name, n->name) == 0) {
                    // found member
                    n->type = m->type;
                    if (tt == TYPE_struct) {
                        n->location = elfDecodeLocation(f, m->location, &n->locType,
                            loc);
                        n->objLocation = loc;
                    } else {
                        n->location = loc;
                        n->locType = n->expression->locType;
                        n->objLocation = loc;
                    }
                    n->member = m;
                    return true;
                }
                i++;
            }
            printf("Member %s not found\n", n->name);
        } else {
            printf("Object is not of structure type\n");
        }
    }
    return false;
}