about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2013-09-10 00:04:29 +0200
committerFlorian Hahn <flo@fhahn.com>2013-09-13 00:47:30 +0200
commit2b5f4b55c0238932ee991102b612858d4b3deb6c (patch)
tree88dc41b1bac43ac174ea23fa233bfdd36855e29e /src/rt
parentb0e13e0d0e61b4147c8c62856c50cf727f7c918f (diff)
downloadrust-2b5f4b55c0238932ee991102b612858d4b3deb6c.tar.gz
rust-2b5f4b55c0238932ee991102b612858d4b3deb6c.zip
Convert rust_crate_map.cpp to Rust
Conflicts:
	src/libstd/rt/logging.rs
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_crate_map.cpp69
-rw-r--r--src/rt/rust_crate_map.h105
-rw-r--r--src/rt/rustrt.def.in1
3 files changed, 0 insertions, 175 deletions
diff --git a/src/rt/rust_crate_map.cpp b/src/rt/rust_crate_map.cpp
deleted file mode 100644
index e6206fd7bcb..00000000000
--- a/src/rt/rust_crate_map.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#include "rust_crate_map.h"
-#include <set>
-
-void iter_module_map(const mod_entry* map,
-                    void (*fn)(void* fptr, void* env, const mod_entry *entry),
-                    void* fptr,
-                    void* env
-                    ) {
-    for (const mod_entry* cur = map; cur->name; cur++) {
-        fn(fptr, env, cur);
-    }
-}
-
-void iter_crate_map(const cratemap* map,
-                    void (*fn)(void* fptr, void* env, const mod_entry *entry),
-                    void *fptr,
-                    void *env,
-                    std::set<const cratemap*>& visited) {
-    if (visited.find(map) == visited.end()) {
-        // Mark this crate visited
-        visited.insert(map);
-        // First iterate this crate
-        iter_module_map(map->entries(), fn, fptr, env);
-        // Then recurse on linked crates
-        for (cratemap::iterator i = map->begin(),
-                e = map->end(); i != e; ++i) {
-            iter_crate_map(*i, fn, fptr, env, visited);
-        }
-    }
-}
-
-void iter_crate_map(const cratemap* map,
-                    void (*fn)(void* fptr, void* env, const mod_entry *entry),
-                    void *fptr,
-                    void *env
-                    ) {
-    std::set<const cratemap*> visited;
-    iter_crate_map(map, fn, fptr, env, visited);
-}
-
-extern "C" CDECL void
-rust_iter_crate_map(const cratemap* map,
-                    void (*fn)(void* fptr, void* env, const mod_entry *entry),
-                    void *fptr,
-                    void *env
-                    ) {
-    return iter_crate_map(map, fn, fptr, env);
-}
-
-
-//
-// Local Variables:
-// mode: C++
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
diff --git a/src/rt/rust_crate_map.h b/src/rt/rust_crate_map.h
deleted file mode 100644
index 1bcb2aa8f7e..00000000000
--- a/src/rt/rust_crate_map.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#ifndef RUST_CRATE_MAP_H
-#define RUST_CRATE_MAP_H
-
-#include "rust_globals.h"
-#include <stdint.h>
-
-struct mod_entry {
-    const char* name;
-    uint32_t* log_level;
-};
-
-class cratemap;
-
-class cratemap_v0 {
-    friend class cratemap;
-    const mod_entry *m_entries;
-    const cratemap* m_children[1];
-};
-
-class cratemap {
-private:
-    int32_t m_version;
-    const void *m_annihilate_fn;
-    const mod_entry* m_entries;
-    const cratemap* m_children[1];
-
-    inline int32_t version() const {
-        switch (m_version) {
-        case 1:     return 1;
-        default:    return 0;
-        }
-    }
-
-public:
-    typedef const cratemap *const *iterator;
-
-    inline const void *annihilate_fn() const {
-        switch (version()) {
-        case 0: return NULL;
-        case 1: return m_annihilate_fn;
-        default: assert(false && "Unknown crate map version!");
-            return NULL; // Appease -Werror=return-type
-        }
-    }
-
-    inline const mod_entry *entries() const {
-        switch (version()) {
-        case 0: return reinterpret_cast<const cratemap_v0 *>(this)->m_entries;
-        case 1: return m_entries;
-        default: assert(false && "Unknown crate map version!");
-            return NULL; // Appease -Werror=return-type
-        }
-    }
-
-    inline const iterator begin() const {
-        switch (version()) {
-        case 0:
-            return &reinterpret_cast<const cratemap_v0 *>(this)->
-                m_children[0];
-        case 1:
-            return &m_children[0];
-        default: assert(false && "Unknown crate map version!");
-            return NULL; // Appease -Werror=return-type
-        }
-    }
-
-    inline const iterator end() const {
-        iterator i = begin();
-        while (*i)
-            i++;
-        return i;
-    }
-};
-
-void iter_module_map(const mod_entry* map,
-                     void (*fn)(void* fptr, void* env, const mod_entry *entry),
-                     void *fptr,
-                     void *env);
-
-void iter_crate_map(const cratemap* map,
-                    void (*fn)(void* fptr, void* env, const mod_entry *entry),
-                    void *fptr,
-                    void *env);
-
-//
-// Local Variables:
-// mode: C++
-// fill-column: 78;
-// indent-tabs-mode: nil
-// c-basic-offset: 4
-// buffer-file-coding-system: utf-8-unix
-// End:
-//
-
-#endif /* RUST_CRATE_MAP_H */
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index bf3500e4c72..af6daed1a3e 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -181,7 +181,6 @@ rust_valgrind_stack_register
 rust_valgrind_stack_deregister
 rust_take_env_lock
 rust_drop_env_lock
-rust_iter_crate_map
 rust_running_on_valgrind
 rust_get_num_cpus
 rust_get_global_args_ptr