about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs5
-rw-r--r--src/libsyntax/codemap.rs14
-rw-r--r--src/libsyntax/ext/asm.rs13
-rw-r--r--src/libsyntax/fold.rs6
-rw-r--r--src/libsyntax/lib.rs1
5 files changed, 33 insertions, 6 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 38d8136c1a1..0fee3ff3218 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -10,7 +10,7 @@
 
 // The Rust abstract syntax tree.
 
-use codemap::{Span, Spanned, DUMMY_SP};
+use codemap::{Span, Spanned, DUMMY_SP, ExpnId};
 use abi::Abi;
 use ast_util;
 use owned_slice::OwnedSlice;
@@ -983,7 +983,8 @@ pub struct InlineAsm {
     pub clobbers: InternedString,
     pub volatile: bool,
     pub alignstack: bool,
-    pub dialect: AsmDialect
+    pub dialect: AsmDialect,
+    pub expn_id: ExpnId,
 }
 
 /// represents an argument in a function header
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 9072889463c..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)]
+#[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 {
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index 4b8c3376cad..702be0c0eee 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -13,6 +13,7 @@
  */
 
 use ast;
+use codemap;
 use codemap::Span;
 use ext::base;
 use ext::base::*;
@@ -198,6 +199,15 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         }
     }
 
+    let expn_id = cx.codemap().record_expansion(codemap::ExpnInfo {
+        call_site: sp,
+        callee: codemap::NameAndSpan {
+            name: "asm".to_string(),
+            format: codemap::MacroBang,
+            span: None,
+        },
+    });
+
     MacExpr::new(P(ast::Expr {
         id: ast::DUMMY_NODE_ID,
         node: ast::ExprInlineAsm(ast::InlineAsm {
@@ -208,7 +218,8 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             clobbers: token::intern_and_get_ident(cons.as_slice()),
             volatile: volatile,
             alignstack: alignstack,
-            dialect: dialect
+            dialect: dialect,
+            expn_id: expn_id,
         }),
         span: sp
     }))
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 91a339a73f7..53be7f2c20c 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -1279,7 +1279,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
                 clobbers,
                 volatile,
                 alignstack,
-                dialect
+                dialect,
+                expn_id,
             }) => ExprInlineAsm(InlineAsm {
                 inputs: inputs.move_map(|(c, input)| {
                     (c, folder.fold_expr(input))
@@ -1292,7 +1293,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
                 clobbers: clobbers,
                 volatile: volatile,
                 alignstack: alignstack,
-                dialect: dialect
+                dialect: dialect,
+                expn_id: expn_id,
             }),
             ExprMac(mac) => ExprMac(folder.fold_mac(mac)),
             ExprStruct(path, fields, maybe_expr) => {
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index 7a504d22c1e..a4271544146 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -33,6 +33,7 @@ extern crate debug;
 #[phase(plugin, link)] extern crate log;
 extern crate serialize;
 extern crate term;
+extern crate libc;
 
 pub mod util {
     pub mod interner;