diff options
| author | Stefan Plantikow <stefan.plantikow@googlemail.com> | 2011-12-23 01:57:35 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-12-28 18:02:49 +0100 |
| commit | 7fd62bb2b57e71899748bdb9fed24b5fc5474a67 (patch) | |
| tree | b4b9a27116265524e7b993ba8c77a59c10dff910 /src | |
| parent | b9b9b3e5705bc6cad760538441a5b3654dd55e58 (diff) | |
| download | rust-7fd62bb2b57e71899748bdb9fed24b5fc5474a67.tar.gz rust-7fd62bb2b57e71899748bdb9fed24b5fc5474a67.zip | |
Made matching machine types equal to float, int, uint (fixes #1376)
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/middle/ty.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index df78cbc3d85..f8e079dc800 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -626,6 +626,25 @@ pure fn struct(cx: ctxt, typ: t) -> sty { } } +// Returns struact(cx, typ) but replaces all occurences of platform +// dependent primitive types with their machine type equivalent +pure fn mach_struct(cx: ctxt, cfg: @session::config, typ: t) -> sty { + alt interner::get(*cx.ts, typ).struct { + ty_named(t, _) { mach_struct(cx, cfg, t) } + s { mach_sty(cfg, s) } + } +} + +// Converts s to its machine type equivalent +pure fn mach_sty(cfg: @session::config, s: sty) -> sty { + alt s { + ty_int(ast::ty_i.) { ty_int(cfg.int_type) } + ty_uint(ast::ty_u.) { ty_uint(cfg.uint_type) } + ty_float(ast::ty_f.) { ty_float(cfg.float_type) } + s { s } + } +} + pure fn ty_name(cx: ctxt, typ: t) -> option::t<@str> { alt interner::get(*cx.ts, typ).struct { ty_named(_, n) { some(n) } @@ -1752,7 +1771,9 @@ mod unify { // Simple structural type comparison. fn struct_cmp(cx: @ctxt, expected: t, actual: t) -> result { - if struct(cx.tcx, expected) == struct(cx.tcx, actual) { + let tcx = cx.tcx; + let cfg = tcx.sess.get_targ_cfg(); + if mach_struct(tcx, cfg, expected) == mach_struct(tcx, cfg, actual) { ret ures_ok(expected); } ret ures_err(terr_mismatch); |
