/[ascend]/trunk/ascxx/compiler.cpp
ViewVC logotype

Annotation of /trunk/ascxx/compiler.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2388 - (hide annotations) (download) (as text)
Tue Feb 15 03:36:18 2011 UTC (13 years ago) by jpye
File MIME type: text/x-c++src
File size: 2245 byte(s)
Added test suite for bintokens, now working correctly in test environment.
1 johnpye 773 #include "compiler.h"
2    
3 jpye 1355 /* #define COMPILER_DEBUG */
4 jpye 2388 #define BINTOKEN_DEBUG
5 jpye 1355
6 johnpye 780 extern "C"{
7 jpye 2018 #include <ascend/compiler/compiler.h>
8     #include <ascend/compiler/bintoken.h>
9     #include <ascend/utilities/error.h>
10 johnpye 780 }
11 johnpye 773
12     using namespace std;
13    
14     Compiler::Compiler(){
15 jpye 1355 #ifdef COMPILE_DEBUG
16 johnpye 1046 CONSOLE_DEBUG("Creating compiler");
17 jpye 1355 #endif
18 johnpye 1046
19     /* set some default for bintoken compilation */
20 johnpye 1049 use_bintoken = false;
21 johnpye 1046 bintoken_options_sent = false;
22     bt_targetstem = "/tmp/asc_bintoken";
23     bt_srcname = bt_targetstem + ".c";
24     bt_objname = bt_targetstem + ".o";
25     bt_libname = bt_targetstem + ".so";
26 jpye 2045 bt_cmd = "cd ~/ascend/ascend/bintokens && "
27     "make -f ~/ascend/ascend/bintokens/Makefile"
28     " ASCBT_TARGET=" + bt_libname;
29 johnpye 1046 bt_rm = "/bin/rm";
30 johnpye 773 }
31    
32     Compiler::~Compiler(){
33 jpye 1355 #ifdef COMPILER_DEBUG
34 johnpye 1046 CONSOLE_DEBUG("Destroying compiler...");;
35 jpye 1355 #endif
36 johnpye 773 }
37    
38     Compiler *
39     Compiler::instance(){
40     static Compiler *_instance = NULL;
41     if(_instance == NULL){
42     _instance = new Compiler();
43     }
44     return _instance;
45     }
46    
47     const bool
48     Compiler::getUseRelationSharing() const{
49     if(g_use_copyanon){
50 johnpye 1049 return true;
51 johnpye 773 }
52 johnpye 1049 return false;
53 johnpye 773 }
54    
55     void
56     Compiler::setUseRelationSharing(const bool &use_relation_sharing){
57     if(use_relation_sharing){
58     g_use_copyanon = 1;
59     }
60     g_use_copyanon = 0;
61     }
62    
63 johnpye 1046 void
64     Compiler::setBinaryCompilation(const bool &use_bintoken){
65     this->use_bintoken = use_bintoken;
66 jpye 1355 #ifdef BINTOKEN_DEBUG
67 johnpye 1046 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"usebintoken = %d",int(use_bintoken));
68 jpye 1355 #endif
69 johnpye 1046 }
70    
71     void
72     Compiler::sendBinaryCompilationOptions(){
73     if(use_bintoken && !bintoken_options_sent){
74 jpye 1355 #ifdef BINTOKEN_DEBUG
75 johnpye 1046 CONSOLE_DEBUG("SETUP BINTOKENS...");
76 jpye 1355 #endif
77 johnpye 1046 BinTokenSetOptions(bt_srcname.c_str(), bt_objname.c_str(), bt_libname.c_str()
78 jpye 2388 , bt_cmd.c_str(), bt_rm.c_str(), 1000/*maxrels*/, 1/*verbose*/, 0/*housekeep*/
79 johnpye 1046 );
80    
81 jpye 1355 #ifdef BINTOKEN_DEBUG
82 johnpye 1046 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"srcname = %s, objname = %s, libname = %s, cmd = %s, rm = %s",
83     bt_srcname.c_str(), bt_objname.c_str(), bt_libname.c_str(), bt_cmd.c_str(), bt_rm.c_str()
84     );
85 jpye 1355 #endif
86    
87 johnpye 1046 bintoken_options_sent = true;
88     }else{
89 johnpye 1317 /* ERROR_REPORTER_HERE(ASC_PROG_NOTE,"disabling bintoken compilation\n"); */
90 johnpye 1046 bintoken_options_sent = false;
91     BinTokenSetOptions(NULL,NULL,NULL,NULL,NULL,0,1,1);
92     }
93     }
94    
95 johnpye 773 Compiler *getCompiler(){
96     return Compiler::instance();
97     }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22