Skip to content

Commit

Permalink
codegen: Skip true type dependency cache for boxed types
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpfard authored and awesomekling committed Feb 18, 2023
1 parent 953089b commit ba0c036
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions selfhost/codegen.jakt
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,14 @@ struct CodeGenerator {
fn extract_dependencies_from(this, type_id: TypeId, dependency_graph: [String : [String]], top_level: bool) throws -> [String] {
mut dependencies: [String] = []

if dependency_graph.contains(type_id.to_string()) {
let type_ = .program.get_type(type_id)
if not type_.is_boxed(program: .program) and dependency_graph.contains(type_id.to_string()) {
for dependency in dependency_graph.get(type_id.to_string())! {
dependencies.push(dependency)
}
return dependencies
}

let type_ = .program.get_type(type_id)
let inner_dependencies = match type_ {
Enum(enum_id) => .extract_dependencies_from_enum(enum_id, dependency_graph, top_level)
GenericEnumInstance(id) => .extract_dependencies_from_enum(enum_id: id, dependency_graph, top_level)
Expand Down
7 changes: 7 additions & 0 deletions selfhost/types.jakt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ boxed enum Type {
Function(params: [TypeId], can_throw: bool, return_type_id: TypeId, pseudo_function_id: FunctionId)
Self


fn is_boxed(this, program: CheckedProgram) -> bool => match this {
Struct(struct_id) | GenericInstance(id: struct_id) => program.get_struct(struct_id).record_type is Class
Enum(enum_id) | GenericEnumInstance(id: enum_id) => program.get_enum(enum_id).is_boxed
else => false
}

fn is_concrete(this) -> bool => match this {
TypeVariable | Self | Unknown => false
else => true
Expand Down

0 comments on commit ba0c036

Please sign in to comment.