Skip to content

Commit 3182c5c

Browse files
committed
---
yaml --- r: 138945 b: refs/heads/try2 c: 666e1b4 h: refs/heads/master i: 138943: d2b88e2 v: v3
1 parent a7bf8ff commit 3182c5c

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: bcc6c3e3dbf4dc42129b46fba23be4f47c83e809
8+
refs/heads/try2: 666e1b463600841ae593a1468a837dc59bb7cab5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
11+
12+
13+
/*
14+
* Inline assembly support.
15+
*/
16+
17+
use core::prelude::*;
18+
19+
use ast;
20+
use codemap::span;
21+
use ext::base;
22+
use ext::base::*;
23+
24+
pub fn expand_asm(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
25+
-> base::MacResult {
26+
let args = get_exprs_from_tts(cx, tts);
27+
if args.len() == 0 {
28+
cx.span_fatal(sp, "ast! takes at least 1 argument.");
29+
}
30+
let asm =
31+
expr_to_str(cx, args[0],
32+
~"inline assembly must be a string literal.");
33+
let cons = if args.len() > 1 {
34+
expr_to_str(cx, args[1],
35+
~"constraints must be a string literal.")
36+
} else { ~"" };
37+
38+
MRExpr(@ast::expr {
39+
id: cx.next_id(),
40+
callee_id: cx.next_id(),
41+
node: ast::expr_inline_asm(@asm, @cons),
42+
span: sp
43+
})
44+
}
45+
46+
//
47+
// Local Variables:
48+
// mode: rust
49+
// fill-column: 78;
50+
// indent-tabs-mode: nil
51+
// c-basic-offset: 4
52+
// buffer-file-coding-system: utf-8-unix
53+
// End:
54+
//

branches/try2/src/libsyntax/ext/base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ pub fn syntax_expander_table() -> SyntaxEnv {
198198
ext::source_util::expand_mod));
199199
syntax_expanders.insert(@~"proto",
200200
builtin_item_tt(ext::pipes::expand_proto));
201+
syntax_expanders.insert(@~"asm",
202+
builtin_normal_tt(ext::asm::expand_asm));
201203
syntax_expanders.insert(
202204
@~"trace_macros",
203205
builtin_normal_tt(ext::trace_macros::expand_trace_macros));

branches/try2/src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
14021402
word(s.s, ~"__asm__");
14031403
popen(s);
14041404
print_string(s, *a);
1405-
word_space(s, ~", ");
1405+
word_space(s, ~",");
14061406
print_string(s, *c);
14071407
pclose(s);
14081408
}

branches/try2/src/libsyntax/syntax.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub mod print {
6060
}
6161

6262
pub mod ext {
63+
pub mod asm;
6364
pub mod base;
6465
pub mod expand;
6566

0 commit comments

Comments
 (0)