1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // Generate.cc -- |
---|
8 | // |
---|
9 | // Author : Richard C. Bilson |
---|
10 | // Created On : Mon May 18 07:44:20 2015 |
---|
11 | // Last Modified By : Andrew Beach |
---|
12 | // Last Modified On : Wed May 19 13:05:00 2017 |
---|
13 | // Update Count : 6 |
---|
14 | // |
---|
15 | |
---|
16 | #include <iostream> // for ostream, endl, operator<< |
---|
17 | #include <list> // for list |
---|
18 | #include <string> // for operator<< |
---|
19 | |
---|
20 | #include "CodeGenerator.h" // for CodeGenerator, doSemicolon, oper... |
---|
21 | #include "GenType.h" // for genPrettyType |
---|
22 | #include "Generate.h" |
---|
23 | #include "Parser/LinkageSpec.h" // for isBuiltin, isGeneratable |
---|
24 | #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode |
---|
25 | #include "SynTree/Declaration.h" // for Declaration |
---|
26 | #include "SynTree/Type.h" // for Type |
---|
27 | |
---|
28 | using namespace std; |
---|
29 | |
---|
30 | namespace CodeGen { |
---|
31 | void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks ) { |
---|
32 | CodeGen::CodeGenerator cgv( os, pretty, generateC, lineMarks ); |
---|
33 | for ( auto & dcl : translationUnit ) { |
---|
34 | if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) { |
---|
35 | os << cgv.lineDirective(dcl); |
---|
36 | dcl->accept(cgv); |
---|
37 | if ( doSemicolon( dcl ) ) { |
---|
38 | os << ";"; |
---|
39 | } // if |
---|
40 | os << std::endl; |
---|
41 | } // if |
---|
42 | } // for |
---|
43 | } |
---|
44 | |
---|
45 | void generate( BaseSyntaxNode * node, std::ostream & os ) { |
---|
46 | if ( Type * type = dynamic_cast< Type * >( node ) ) { |
---|
47 | os << CodeGen::genPrettyType( type, "" ); |
---|
48 | } else { |
---|
49 | CodeGen::CodeGenerator cgv( os, true, false, false ); |
---|
50 | node->accept( cgv ); |
---|
51 | } |
---|
52 | os << std::endl; |
---|
53 | } |
---|
54 | } // namespace CodeGen |
---|
55 | |
---|
56 | // Local Variables: // |
---|
57 | // tab-width: 4 // |
---|
58 | // mode: c++ // |
---|
59 | // compile-command: "make install" // |
---|
60 | // End: // |
---|