about summary refs log tree commit diff
path: root/src/comp/util
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-10-19 14:54:10 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-10-19 14:54:10 -0700
commitb8cca0971fc2dcd5f4bf4ac2ce82c1c635da0279 (patch)
tree9744ef42235ff93c1534461210c80b0f9ecb35b0 /src/comp/util
parent10d628dbd06ec71956c7849c24822dde8710c2bd (diff)
downloadrust-b8cca0971fc2dcd5f4bf4ac2ce82c1c635da0279.tar.gz
rust-b8cca0971fc2dcd5f4bf4ac2ce82c1c635da0279.zip
Teach trans to allocate, initialize and load from local variables.
Diffstat (limited to 'src/comp/util')
-rw-r--r--src/comp/util/common.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs
index a5b77c0e793..20bff22dda5 100644
--- a/src/comp/util/common.rs
+++ b/src/comp/util/common.rs
@@ -1,5 +1,6 @@
 import std._uint;
 import std._int;
+import front.ast;
 
 type pos = rec(uint line, uint col);
 type span = rec(str filename, pos lo, pos hi);
@@ -43,6 +44,24 @@ fn new_str_hash[V]() -> std.map.hashmap[str,V] {
     ret std.map.mk_hashmap[str,V](hasher, eqer);
 }
 
+fn new_def_hash[V]() -> std.map.hashmap[ast.def_id,V] {
+
+    fn hash(&ast.def_id d) -> uint {
+        let uint u = d._0 as uint;
+        u <<= 16u;
+        u |= d._1 as uint;
+        ret u;
+    }
+
+    fn eq(&ast.def_id a, &ast.def_id b) -> bool {
+        ret a._0 == b._0 && a._1 == b._1;
+    }
+
+    let std.map.hashfn[ast.def_id] hasher = hash;
+    let std.map.eqfn[ast.def_id] eqer = eq;
+    ret std.map.mk_hashmap[ast.def_id,V](hasher, eqer);
+}
+
 fn istr(int i) -> str {
     ret _int.to_str(i, 10u);
 }