diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2014-09-28 09:25:48 -0700 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2014-09-28 09:25:48 -0700 |
| commit | 8826fdfe37a7cbf901ddced1d7e2b4320e117461 (patch) | |
| tree | 57de8f22e51d09f717d60361bcf4049aa5ec4de9 /src/libsyntax/codemap.rs | |
| parent | 9d60de93e2c5af1b69201b5e3bcf8943ae5df664 (diff) | |
| download | rust-8826fdfe37a7cbf901ddced1d7e2b4320e117461.tar.gz rust-8826fdfe37a7cbf901ddced1d7e2b4320e117461.zip | |
Keep ExpnId abstract by providing conversions
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index d44de7862a3..e9b2556c53e 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -26,6 +26,7 @@ source code snippets, etc. use serialize::{Encodable, Decodable, Encoder, Decoder}; use std::cell::RefCell; use std::rc::Rc; +use libc::c_uint; pub trait Pos { fn from_uint(n: uint) -> Self; @@ -223,11 +224,22 @@ pub struct ExpnInfo { pub callee: NameAndSpan } -#[deriving(PartialEq, Eq, Clone, Show, Hash)] -pub struct ExpnId(pub u32); +#[deriving(PartialEq, Eq, Clone, Show, Hash, Encodable, Decodable)] +pub struct ExpnId(u32); pub static NO_EXPANSION: ExpnId = ExpnId(-1); +impl ExpnId { + pub fn from_llvm_cookie(cookie: c_uint) -> ExpnId { + ExpnId(cookie as u32) + } + + pub fn to_llvm_cookie(self) -> i32 { + let ExpnId(cookie) = self; + cookie as i32 + } +} + pub type FileName = String; pub struct FileLines { |
