pub fn tokens_to_cpp(ecx: &ExtCtxt, tokens: &[Spanned<String>]) -> String {
    let codemap = ecx.parse_sess.codemap();

    let mut last_pos = codemap.lookup_char_pos(DUMMY_SP.lo);
    let mut column = 0;
    let mut contents = String::new();

    for token in tokens {
        if token.span != DUMMY_SP {
            let pos = codemap.lookup_char_pos(token.span.lo);

            if pos.file.name == pos.file.name && pos.line == last_pos.line + 1 {
                contents.push('\n');
                column = 0;
            } else if pos.file.name != pos.file.name || pos.line != last_pos.line {
                contents.push('\n');
                contents.push_str(&span_to_cpp_directive(ecx, token.span));
                contents.push('\n');
                column = 0;
            }

            // Pad the code such that the token remains on the same column
            while column < pos.col.0 {
                contents.push(' ');
                column += 1;
            }
            last_pos = pos;
        }

        column += token.node.len();
        contents.push_str(&token.node);
    }

    return contents;
}
/// Join tokens, using `#line` C preprocessor directives to maintain span
/// information.
Join tokens, using `#line` C preprocessor directives to maintain span
information.
Join tokens using ` #line ` C preprocessor directives to maintain span information .
pub fn tokens_to_cpp(ecx: &ExtCtxt, tokens: &[Spanned<String>]) -> String {
    let codemap = ecx.parse_sess.codemap();
    let mut last_pos = codemap.lookup_char_pos(DUMMY_SP.lo);
    let mut column = 0;
    let mut contents = String::new();
    for token in tokens {
        if token.span != DUMMY_SP {
            let pos = codemap.lookup_char_pos(token.span.lo);
            if pos.file.name == pos.file.name && pos.line == last_pos.line + 1 {
                contents.push('\n');
                column = 0;
            } else if pos.file.name != pos.file.name || pos.line != last_pos.line {
                contents.push('\n');
                contents.push_str(&span_to_cpp_directive(ecx, token.span));
                contents.push('\n');
                column = 0;
            }
            // Pad the code such that the token remains on the same column
            while column < pos.col.0 {
                contents.push(' ');
                column += 1;
            }
            last_pos = pos;
        }
        column += token.node.len();
        contents.push_str(&token.node);
    }
    return contents;
}
pub fn tokens_to_cpp ( ecx : & ExtCtxt , tokens : & [ Spanned < String > ] ) -> String { let codemap = ecx . parse_sess . codemap ( ) ; let mut last_pos = codemap . lookup_char_pos ( DUMMY_SP . lo ) ; let mut column = 0 ; let mut contents = String :: new ( ) ; for token in tokens { if token . span != DUMMY_SP { let pos = codemap . lookup_char_pos ( token . span . lo ) ; if pos . file . name == pos . file . name && pos . line == last_pos . line + 1 { contents . push ( '\n' ) ; column = 0 ; } else if pos . file . name != pos . file . name || pos . line != last_pos . line { contents . push ( '\n' ) ; contents . push_str ( & span_to_cpp_directive ( ecx , token . span ) ) ; contents . push ( '\n' ) ; column = 0 ; } // Pad the code such that the token remains on the same column while column < pos . col . 0 { contents . push ( ' ' ) ; column += 1 ; } last_pos = pos ; } column += token . node . len ( ) ; contents . push_str ( & token . node ) ; } return contents ; }
Join tokens, using `#line` C preprocessor directives to maintain span
information.
Join tokens using ` #line ` C preprocessor directives to maintain span information .
ecx
&ExtCtxt
tokens
&[Spanned<String>]
ecx
&ExtCtxt
tokens
&[Spanned<String>]