about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorStefan Plantikow <stefan.plantikow@googlemail.com>2011-11-30 17:58:08 +0100
committerGraydon Hoare <graydon@mozilla.com>2011-12-02 11:38:24 -0800
commit29f7cdffa4688aa539be4f0f6d2eab7f5af8a2d6 (patch)
tree47a1d7d795e90841d4f38b3566616d36fe0b8069 /src/comp/syntax
parentd116a6f2d39d6fe9484b5c1b5f818756a78fd3bc (diff)
downloadrust-29f7cdffa4688aa539be4f0f6d2eab7f5af8a2d6.tar.gz
rust-29f7cdffa4688aa539be4f0f6d2eab7f5af8a2d6.zip
ty: trans: added support for dropping trivial casts
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast_util.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs
index d8b52300e91..3129c28d4fa 100644
--- a/src/comp/syntax/ast_util.rs
+++ b/src/comp/syntax/ast_util.rs
@@ -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};