]> git.proxmox.com Git - rustc.git/blame - src/librustc_trans/trans/llrepr.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / librustc_trans / trans / llrepr.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11use trans::context::CrateContext;
12use trans::type_::Type;
13use llvm::ValueRef;
14
15pub trait LlvmRepr {
16 fn llrepr(&self, ccx: &CrateContext) -> String;
17}
18
19impl<T:LlvmRepr> LlvmRepr for [T] {
20 fn llrepr(&self, ccx: &CrateContext) -> String {
21 let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
22 format!("[{}]", reprs.connect(","))
23 }
24}
25
26impl LlvmRepr for Type {
27 fn llrepr(&self, ccx: &CrateContext) -> String {
28 ccx.tn().type_to_string(*self)
29 }
30}
31
32impl LlvmRepr for ValueRef {
33 fn llrepr(&self, ccx: &CrateContext) -> String {
34 ccx.tn().val_to_string(*self)
35 }
36}