Skip to content

Commit bfd50bd

Browse files
bogglemarijnh
authored andcommitted
---
yaml --- r: 6947 b: refs/heads/master c: 7fd62bb h: refs/heads/master i: 6945: f365c9f 6943: 459982d v: v3
1 parent 96f7faf commit bfd50bd

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b9b9b3e5705bc6cad760538441a5b3654dd55e58
2+
refs/heads/master: 7fd62bb2b57e71899748bdb9fed24b5fc5474a67

trunk/src/comp/middle/ty.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,25 @@ pure fn struct(cx: ctxt, typ: t) -> sty {
626626
}
627627
}
628628

629+
// Returns struact(cx, typ) but replaces all occurences of platform
630+
// dependent primitive types with their machine type equivalent
631+
pure fn mach_struct(cx: ctxt, cfg: @session::config, typ: t) -> sty {
632+
alt interner::get(*cx.ts, typ).struct {
633+
ty_named(t, _) { mach_struct(cx, cfg, t) }
634+
s { mach_sty(cfg, s) }
635+
}
636+
}
637+
638+
// Converts s to its machine type equivalent
639+
pure fn mach_sty(cfg: @session::config, s: sty) -> sty {
640+
alt s {
641+
ty_int(ast::ty_i.) { ty_int(cfg.int_type) }
642+
ty_uint(ast::ty_u.) { ty_uint(cfg.uint_type) }
643+
ty_float(ast::ty_f.) { ty_float(cfg.float_type) }
644+
s { s }
645+
}
646+
}
647+
629648
pure fn ty_name(cx: ctxt, typ: t) -> option::t<@str> {
630649
alt interner::get(*cx.ts, typ).struct {
631650
ty_named(_, n) { some(n) }
@@ -1752,7 +1771,9 @@ mod unify {
17521771

17531772
// Simple structural type comparison.
17541773
fn struct_cmp(cx: @ctxt, expected: t, actual: t) -> result {
1755-
if struct(cx.tcx, expected) == struct(cx.tcx, actual) {
1774+
let tcx = cx.tcx;
1775+
let cfg = tcx.sess.get_targ_cfg();
1776+
if mach_struct(tcx, cfg, expected) == mach_struct(tcx, cfg, actual) {
17561777
ret ures_ok(expected);
17571778
}
17581779
ret ures_err(terr_mismatch);

0 commit comments

Comments
 (0)