diff options
| author | gingerBill <bill@gingerbill.org> | 2020-04-06 11:38:53 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-04-06 11:38:53 +0100 |
| commit | ae97c1111a0084e289a2b9e25038e8493ef923a1 (patch) | |
| tree | 6636c4f71f374a41d77db587a53cbbf7167adb9f /src/llvm_backend.cpp | |
| parent | f38d7b02f3d677c4043ec37494abbd916b1d5d99 (diff) | |
Fix -llvm-api for `typeid` comparison with a Type itself
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 6ceae29f8..42352fb2e 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -5259,10 +5259,19 @@ lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) { case Token_Gt: case Token_GtEq: { - lbValue left = lb_build_expr(p, be->left); - Type *type = default_type(tv.type); - lbValue right = lb_build_expr(p, be->right); + lbValue left = {}; + lbValue right = {}; + + if (be->left->tav.mode == Addressing_Type) { + left = lb_typeid(p->module, be->left->tav.type, t_typeid); + } + if (be->right->tav.mode == Addressing_Type) { + right = lb_typeid(p->module, be->right->tav.type, t_typeid); + } + if (left.value == nullptr) left = lb_build_expr(p, be->left); + if (right.value == nullptr) right = lb_build_expr(p, be->right); lbValue cmp = lb_emit_comp(p, be->op.kind, left, right); + Type *type = default_type(tv.type); return lb_emit_conv(p, cmp, type); } |