-
Notifications
You must be signed in to change notification settings - Fork 0
/
asmfmt.hpp
63 lines (58 loc) · 1.84 KB
/
asmfmt.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef ASMFMT_HPP
#define ASMFMT_HPP
/* Copyright (c) 2019 by NEC Corporation
* This file is part of ve-jit */
#include "asmfmt_fwd.hpp"
#include <sstream>
#include <deque>
#include <iostream>
#include <assert.h>
#if ASMFMTREMOVE < 1
inline void AsmFmtCols::clear()
{
a->str("");
a->clear();
}
inline std::string AsmFmtCols::str() const {
return a->str();
}
inline AsmFmtCols * AsmFmtCols::setParent( AsmFmtCols* p ) {
AsmFmtCols *ret=parent;
parent = p;
return ret;
}
template<typename PAIRCONTAINER> inline
std::size_t AsmFmtCols::scope( PAIRCONTAINER const& pairs, std::string const& block_name ){
assert( stack_defs.size() == stack_undefs.size() );
// trimmed substitution --> macro strings
StringPairs defs;
//std::deque<std::string> un;
{
bool name_out = false;
std::string comment("{ BEG ");
comment.append(block_name);
if( stack_undefs.empty() ) comment.append(" (GLOBAL)");
auto const iend = pairs.end();
auto iter = pairs.begin();
std::string line;
for( ; iter != iend; ++iter ){
if( !name_out ){
line = this->fmt_def(iter->first, iter->second, comment);
name_out = true;
}else{
line = this->fmt_def(iter->first, iter->second);
}
(*a) << line;
defs.push_trimmed(iter->first, iter->second);
}
if(!name_out) rcom(comment);
}
// create the reverse-order #undef string immediately?
stack_undefs.push_back(defs2undefs(defs, block_name));
stack_defs .push_back(defs);
//std::cout<<"\nscope-->undefs:\n"<<stack_undefs.top()<<std::endl;
return defs.size();
}
#endif //ASMFMTREMOVE < 1
// vim: ts=4 sw=4 et cindent cino=^=l0,\:.5s,=-.5s,N-s,g.5s,b1 cinkeys=0{,0},0),\:,0#,!^F,o,O,e,0=break
#endif // ASMFMT_HPP