Commit d3e0972c authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

correctly ordered table dump

-n -a assembler removed from output
parent 5c191f9a
......@@ -129,10 +129,11 @@ namespace cecko {
auto arg_reader = [this](char opt, auto&& get_val) -> bool {
switch (opt)
{
case 'o':
if (!oname.empty())
case 'a':
if (!aname.empty())
return false;
oname = get_val();
aname = get_val();
a_to_out = false;
return true;
case 'c':
if (!covname.empty())
......@@ -144,6 +145,14 @@ namespace cecko {
return false;
covlinename = get_val();
return true;
case 'n':
a_to_out = false;
return true;
case 'o':
if (!oname.empty())
return false;
oname = get_val();
return true;
case 'z':
if (!!outp_owner_)
return false;
......@@ -156,6 +165,7 @@ namespace cecko {
return false;
}
outp_ = &*outp_owner_;
a_to_out = false;
}
return true;
default:
......@@ -168,8 +178,9 @@ namespace cecko {
bool main_state_code::dump_code() const
{
out() << "========== IR module ==========" << std::endl;
if (a_to_out)
{
out() << "========== IR module ==========" << std::endl;
std::stringstream oss;
the_tables.dump_ir_module(oss);
for (;;)
......@@ -182,6 +193,19 @@ namespace cecko {
}
}
if (!aname.empty())
{
std::ofstream af(aname);
if (!af.good())
{
std::cout << "Cannot open output file \"" << aname << "\"" << std::endl;
}
else
{
the_tables.dump_ir_module(af);
}
}
if (!oname.empty())
{
auto oec = the_tables.write_bitcode_module(oname);
......
......@@ -66,7 +66,9 @@ namespace cecko {
class main_state_code : public main_state_parser {
public:
std::string oname;
std::string oname; // binary output
std::string aname; // assembly output
bool a_to_out = true; // assembly to out()
int app_argc = 0;
char** app_argv = nullptr;
......
......@@ -19,7 +19,7 @@ namespace cecko {
CIDecl CKVoidType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "void" + decl_dtor(false, false, dtor); }
CIDecl CKBoolType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "bool" + decl_dtor(false, false, dtor); }
CIDecl CKBoolType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "_Bool" + decl_dtor(false, false, dtor); }
CIDecl CKCharType::declaration(bool is_const, const CIDecl& dtor) const { return decl_const(is_const) + "char" + decl_dtor(false, false, dtor); }
......
......@@ -138,9 +138,20 @@ namespace cecko {
template<typename F>
void for_each(F&& f) const
{
for (auto&& a : data_)
using container_pair_obs = const std::pair< const CIName, T>*;
auto pair_less = [](auto a, auto b) {
return a->first < b->first;
};
using ordering_set = std::vector< container_pair_obs>;
ordering_set os(data_.size(), nullptr);
std::transform(data_.begin(), data_.end(), os.begin(),
[](auto&& a) {
return &a;
});
std::sort(os.begin(), os.end(), pair_less);
for (auto&& p : os)
{
f(&a.second);
f(&p->second);
}
}
private:
......
......@@ -3,63 +3,63 @@ struct Str{
const char*key;
struct Str*next;
};
int main(int,char**);
bool test();
void fibtest();
void argreverttest(int,char**);
int printf(const char*,...);
int sscanf(const char*,const char*,...);
void*memset(void*,int,int);
void pop_front(struct Str**);
void pointerarithmeticstest();
bool empty(struct Str**);
_Bool empty(struct Str**);
int fib(int);
void fibtest();
const char*front(struct Str**);
struct Str*get_str();
int main(int,char**);
void*memset(void*,int,int);
void pointerarithmeticstest();
void pop_front(struct Str**);
int printf(const char*,...);
void push_front(struct Str**,const char*);
const char*front(struct Str**);
int scanf(const char*,...);
int sprintf(char*,const char*,...);
int sscanf(const char*,const char*,...);
void stringtest();
bool status;
int array_end;
_Bool test();
struct Str array[1000];
int array_end;
struct Str*root;
int main(int argc,char**argv){
_Bool status;
void argreverttest(int argc,char**argv){
int i;
const char*z;
}
bool test(){
_Bool empty(struct Str**rootp){
}
void fibtest(){
int fib(int x){
int s;
}
void fibtest(){
int n;
int s;
}
void argreverttest(int argc,char**argv){
int i;
const char*z;
const char*front(struct Str**rootp){
}
void pop_front(struct Str**rootp){
struct Str*get_str(){
struct Str*p;
}
int main(int argc,char**argv){
}
void pointerarithmeticstest(){
char*e;
char arr[27];
char ch;
char*e;
char*p;
char arr[27];
}
bool empty(struct Str**rootp){
}
int fib(int x){
int s;
}
struct Str*get_str(){
struct Str*p;
void pop_front(struct Str**rootp){
}
void push_front(struct Str**rootp,const char*key){
struct Str*p;
}
const char*front(struct Str**rootp){
}
void stringtest(){
char t[40];
int i;
char arr[100];
int i;
char t[40];
}
_Bool test(){
}
========== cecko3 done ==========
......@@ -3,66 +3,65 @@ struct Str{
const char*key;
struct Str*next;
};
int main(int,char**);
bool test();
void fibtest();
void argreverttest(int,char**);
int printf(const char*,...);
int sscanf(const char*,const char*,...);
void*memset(void*,int,int);
void pop_front(struct Str**);
void pointerarithmeticstest();
bool empty(struct Str**);
_Bool empty(struct Str**);
int fib(int);
void fibtest();
const char*front(struct Str**);
struct Str*get_str();
int main(int,char**);
void*memset(void*,int,int);
void pointerarithmeticstest();
void pop_front(struct Str**);
int printf(const char*,...);
void push_front(struct Str**,const char*);
const char*front(struct Str**);
int scanf(const char*,...);
int sprintf(char*,const char*,...);
int sscanf(const char*,const char*,...);
void stringtest();
bool status;
int array_end;
_Bool test();
struct Str array[1000];
int array_end;
struct Str*root;
int main(int argc,char**argv){
_Bool status;
void argreverttest(int argc,char**argv){
int i;
const char*z;
}
bool test(){
_Bool empty(struct Str**rootp){
}
void fibtest(){
int fib(int x){
int s;
}
void fibtest(){
int n;
int s;
}
void argreverttest(int argc,char**argv){
int i;
const char*z;
const char*front(struct Str**rootp){
}
void pop_front(struct Str**rootp){
struct Str*get_str(){
struct Str*p;
}
int main(int argc,char**argv){
}
void pointerarithmeticstest(){
char*e;
char arr[27];
char ch;
char*e;
char*p;
char arr[27];
}
bool empty(struct Str**rootp){
}
int fib(int x){
int s;
}
struct Str*get_str(){
struct Str*p;
void pop_front(struct Str**rootp){
}
void push_front(struct Str**rootp,const char*key){
struct Str*p;
}
const char*front(struct Str**rootp){
}
void stringtest(){
char t[40];
int i;
char arr[100];
int i;
char t[40];
}
_Bool test(){
}
========== IR module ==========
========== starting main() ==========
This is test1.c main()
... argreverttest ...
......
......@@ -3,66 +3,65 @@ struct Str{
const char*key;
struct Str*next;
};
int main(int,char**);
bool test();
void fibtest();
void argreverttest(int,char**);
int printf(const char*,...);
int sscanf(const char*,const char*,...);
void*memset(void*,int,int);
void pop_front(struct Str**);
void pointerarithmeticstest();
bool empty(struct Str**);
_Bool empty(struct Str**);
int fib(int);
void fibtest();
const char*front(struct Str**);
struct Str*get_str();
int main(int,char**);
void*memset(void*,int,int);
void pointerarithmeticstest();
void pop_front(struct Str**);
int printf(const char*,...);
void push_front(struct Str**,const char*);
const char*front(struct Str**);
int scanf(const char*,...);
int sprintf(char*,const char*,...);
int sscanf(const char*,const char*,...);
void stringtest();
bool status;
int array_end;
_Bool test();
struct Str array[1000];
int array_end;
struct Str*root;
int main(int argc,char**argv){
_Bool status;
void argreverttest(int argc,char**argv){
int i;
const char*z;
}
bool test(){
_Bool empty(struct Str**rootp){
}
void fibtest(){
int fib(int x){
int s;
}
void fibtest(){
int n;
int s;
}
void argreverttest(int argc,char**argv){
int i;
const char*z;
const char*front(struct Str**rootp){
}
void pop_front(struct Str**rootp){
struct Str*get_str(){
struct Str*p;
}
int main(int argc,char**argv){
}
void pointerarithmeticstest(){
char*e;
char arr[27];
char ch;
char*e;
char*p;
char arr[27];
}
bool empty(struct Str**rootp){
}
int fib(int x){
int s;
}
struct Str*get_str(){
struct Str*p;
void pop_front(struct Str**rootp){
}
void push_front(struct Str**rootp,const char*key){
struct Str*p;
}
const char*front(struct Str**rootp){
}
void stringtest(){
char t[40];
int i;
char arr[100];
int i;
char t[40];
}
_Bool test(){
}
========== IR module ==========
========== starting main() ==========
This is test1.c main()
... argreverttest ...
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment