Skip to content

Commit

Permalink
Merge pull request #155 from myuon/issue-134
Browse files Browse the repository at this point in the history
  • Loading branch information
myuon authored Oct 9, 2023
2 parents 41b65e3 + 01e73b6 commit 4b2fc7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 352 deletions.
78 changes: 21 additions & 57 deletions quartz/ir_code_gen.qz
Original file line number Diff line number Diff line change
Expand Up @@ -473,43 +473,6 @@ module IrCodeGenerator {
decls.extend(self.generate_prepare_strings().try);
decls.extend(self.generate_prepare_itables().try);

decls.push(IrTerm {
t_func: IrFunc {
name: "reflection_get_type_rep_id",
params: make[vec[struct {
name: string,
type_: IrType,
}]](struct {
name: "p",
type_: IrType {
t_address: true,
},
}),
result_type: IrType {
t_address: true,
},
body: make[vec[IrTerm]](IrTerm {
t_return: IrReturn {
value: IrTerm {
t_load: struct {
type_: IrType {
t_address: true,
},
address: IrTerm {
t_ident: "p",
},
offset: IrTerm {
t_i32: 0,
},
},
},
},
}),
escaping: make[vec[string]](),
..nil,
},
});

let result = vec_clone(self.imports);
result.extend(decls);

Expand Down Expand Up @@ -628,10 +591,13 @@ module IrCodeGenerator {
}

elements.push(IrTerm {
t_func: self.function(d.t_func!, make[vec[struct {
name: string,
type_: Type,
}]]()).try,
t_func: self.function(
d.t_func!,
make[vec[struct {
name: string,
type_: Type,
}]](),
).try,
});
}
if d.t_let != nil {
Expand Down Expand Up @@ -1210,10 +1176,14 @@ module IrCodeGenerator {
};
}

fun function(self, func: Function, captures: vec[struct {
name: string,
type_: Type,
}]): IrFunc or error {
fun function(
self,
func: Function,
captures: vec[struct {
name: string,
type_: Type,
}],
): IrFunc or error {
self.current_function_name = func.name.data;
self.function_no_allocation = func.no_allocation;
self.captures = captures;
Expand Down Expand Up @@ -3137,12 +3107,12 @@ module IrCodeGenerator {
t_load: struct {
type_: IrType::new(c.type_),
address: IrTerm {
t_ident: c.name
t_ident: c.name,
},
offset: IrTerm {
t_i32: 0,
},
}
},
},
});
}
Expand All @@ -3153,11 +3123,7 @@ module IrCodeGenerator {
type_: IrType {
t_address: true,
},
value: self.generate_array(
"struct",
captures_ir,
values,
).try,
value: self.generate_array("struct", captures_ir, values).try,
},
});

Expand All @@ -3175,11 +3141,9 @@ module IrCodeGenerator {
};
} else if expr.t_closure_call != nil {
let callee_type = expr.t_closure_call!.callee_type;
callee_type.t_closure!.params.push(
Type {
t_any: true,
},
);
callee_type.t_closure!.params.push(Type {
t_any: true,
});

let terms = make[vec[IrTerm]]();
for arg in expr.t_closure_call!.args {
Expand Down
Loading

0 comments on commit 4b2fc7c

Please sign in to comment.