Skip to content

Commit

Permalink
cpp_import/clang: Resolve class bases' namespaces before resolving them
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpfard committed Oct 3, 2023
1 parent 02e730e commit 9068b24
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions selfhost/cpp_import/clang.jakt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ fn function_names_from(cursor: CXCursor) throws -> (String, ExternalName?) {
return (name, extern_name)
}

enum ScopeSemanticParent {
name: String

Namespace
Record
}

struct TemplateParameters {
params: [CheckedGenericParameter]
defaults: [TypeId?]
Expand Down Expand Up @@ -1779,14 +1786,45 @@ class CppImportProcessor {

mut super_struct_ids: [StructId] = []
for base in bases {
match program.get_type(.cached_type_of_cursor(
mut base_scope_id = parent_scope_id
visit(
base
fn[&mut base_scope_id, &mut program](
anon cursor: CXCursor
anon parent: CXCursor
) throws -> CXChildVisitResult {
match clang_getCursorKind(cursor) {
CXCursor_NamespaceRef => {
let name = name_from(cursor)
let scope = program.get_scope(base_scope_id)
let result = program.find_namespace_in_scope(
scope_id: base_scope_id
name
)
if result.has_value() {
base_scope_id = result!.0
} else {
// :shrug:
return CXChildVisitResult::CXChildVisit_Break
}
}
else => {}
}
return CXChildVisitResult::CXChildVisit_Continue
}
)

let type = program.get_type(.cached_type_of_cursor(
cursor: base
&mut program
scope_id: parent_scope_id
scope_id: base_scope_id
module_id
)) {
))
match type {
GenericInstance(id) | Struct(id) => { super_struct_ids.push(id) }
else => {}
else => {
eprintln("[ICE] Base type of {} is not a struct or generic instance: {}", specialized_name, type)
}
}
}

Expand Down

0 comments on commit 9068b24

Please sign in to comment.