ty: trans: added support for dropping trivial casts

This commit is contained in:
Stefan Plantikow 2011-11-30 17:58:08 +01:00 committed by Graydon Hoare
parent d116a6f2d3
commit 29f7cdffa4
4 changed files with 33 additions and 5 deletions

View file

@ -1,4 +1,4 @@
import std::{str, option};
import std::{str, option, int, map};
import codemap::span;
import ast::*;
@ -6,6 +6,13 @@ fn respan<copy T>(sp: span, t: T) -> spanned<T> {
ret {node: t, span: sp};
}
fn new_node_hash<copy V>() -> map::hashmap<node_id, V> {
fn node_id_hash(&&i: node_id) -> uint { ret int::hash(i as int); }
fn node_id_eq(&&a: node_id, &&b: node_id) -> bool
{ ret int::eq(a as int, b as int); }
ret map::mk_hashmap(node_id_hash, node_id_eq);
}
/* assuming that we're not in macro expansion */
fn mk_sp(lo: uint, hi: uint) -> span {
ret {lo: lo, hi: hi, expanded_from: codemap::os_none};