diff options
| author | Luqman Aden <me@luqman.ca> | 2013-03-27 13:42:21 -0700 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2013-03-27 15:41:58 -0700 |
| commit | 203d691a6bf6795f3d1f77378696a4506dd550f2 (patch) | |
| tree | 345c876e08705654e22e34b5f08d9c92cf88990c /src/libsyntax | |
| parent | 727a565f1e65c415b018f26d878a0d3ebdc9e3ea (diff) | |
| download | rust-203d691a6bf6795f3d1f77378696a4506dd550f2.tar.gz rust-203d691a6bf6795f3d1f77378696a4506dd550f2.zip | |
libsyntax: use a struct for inline asm in ast.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/ext/asm.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 6 |
5 files changed, 40 insertions, 23 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 12d4e9d5e24..05c5f447993 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -600,10 +600,7 @@ pub enum expr_ { expr_ret(Option<@expr>), expr_log(log_level, @expr, @expr), - expr_inline_asm(@~str, // asm - ~[(@~str, @expr)], // inputs - ~[(@~str, @expr)], // outputs - @~str, bool, bool), // clobbers, volatile, align stack + expr_inline_asm(inline_asm), expr_mac(mac), @@ -940,6 +937,18 @@ impl to_bytes::IterBytes for Ty { #[auto_encode] #[auto_decode] #[deriving(Eq)] +pub struct inline_asm { + asm: @~str, + clobbers: @~str, + inputs: ~[(@~str, @expr)], + outputs: ~[(@~str, @expr)], + volatile: bool, + alignstack: bool +} + +#[auto_encode] +#[auto_decode] +#[deriving(Eq)] pub struct arg { mode: mode, is_mutbl: bool, diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index a014d8ccb8b..c3faf4f1e09 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -59,7 +59,7 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) match state { Asm => { asm = expr_to_str(cx, p.parse_expr(), - ~"inline assembly must be a string literal."); + ~"inline assembly must be a string literal."); } Outputs => { while *p.token != token::EOF && @@ -163,8 +163,14 @@ pub fn expand_asm(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree]) MRExpr(@ast::expr { id: cx.next_id(), callee_id: cx.next_id(), - node: ast::expr_inline_asm(@asm, inputs, outputs, - @cons, volatile, alignstack), + node: ast::expr_inline_asm(ast::inline_asm { + asm: @asm, + clobbers: @cons, + inputs: inputs, + outputs: outputs, + volatile: volatile, + alignstack: alignstack + }), span: sp }) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 9d4cf4e8939..6ba629a24e1 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -559,13 +559,15 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { fld.fold_expr(e) ) } - expr_inline_asm(asm, ins, outs, c, v, a) => { - expr_inline_asm( - asm, - ins.map(|&(c, in)| (c, fld.fold_expr(in))), - outs.map(|&(c, out)| (c, fld.fold_expr(out))), - c, v, a - ) + expr_inline_asm(a) => { + expr_inline_asm(inline_asm { + asm: a.asm, + clobbers: a.clobbers, + inputs: a.inputs.map(|&(c, in)| (c, fld.fold_expr(in))), + outputs: a.outputs.map(|&(c, out)| (c, fld.fold_expr(out))), + volatile: a.volatile, + alignstack: a.alignstack + }) } expr_mac(ref mac) => expr_mac(fold_mac((*mac))), expr_struct(path, ref fields, maybe_expr) => { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9fffed7074b..3b56017b8e0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1406,16 +1406,16 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { } } } - ast::expr_inline_asm(a, in, out, c, v, _) => { - if v { + ast::expr_inline_asm(a) => { + if a.volatile { word(s.s, ~"__volatile__ asm!"); } else { word(s.s, ~"asm!"); } popen(s); - print_string(s, *a); + print_string(s, *a.asm); word_space(s, ~":"); - for out.each |&(co, o)| { + for a.outputs.each |&(co, o)| { print_string(s, *co); popen(s); print_expr(s, o); @@ -1423,7 +1423,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { word_space(s, ~","); } word_space(s, ~":"); - for in.each |&(co, o)| { + for a.inputs.each |&(co, o)| { print_string(s, *co); popen(s); print_expr(s, o); @@ -1431,7 +1431,7 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { word_space(s, ~","); } word_space(s, ~":"); - print_string(s, *c); + print_string(s, *a.clobbers); pclose(s); } ast::expr_mac(ref m) => print_mac(s, (*m)), diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index a159c98d21b..daa16e867b9 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -565,11 +565,11 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { } expr_mac(ref mac) => visit_mac((*mac), e, v), expr_paren(x) => (v.visit_expr)(x, e, v), - expr_inline_asm(_, ins, outs, _, _, _) => { - for ins.each |&(_, in)| { + expr_inline_asm(ref a) => { + for a.inputs.each |&(_, in)| { (v.visit_expr)(in, e, v); } - for outs.each |&(_, out)| { + for a.outputs.each |&(_, out)| { (v.visit_expr)(out, e, v); } } |
