Keep ExpnId abstract by providing conversions

This commit is contained in:
Keegan McAllister 2014-09-28 09:25:48 -07:00
parent 9d60de93e2
commit 8826fdfe37
7 changed files with 21 additions and 8 deletions

View file

@ -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 {