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

Annotation of /trunk/ascxx/compiler.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2396 - (hide annotations) (download) (as text)
Mon Feb 28 05:15:02 2011 UTC (12 years ago) by jpye
File MIME type: text/x-c++src
File size: 2204 byte(s)
turn off bintoken messages to GUI.
1 johnpye 773 #include "compiler.h"
2    
3 jpye 1355 /* #define COMPILER_DEBUG */
4 jpye 2396 //#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 2389 bt_cmd = "make -f ascend/bintokens/Makefile ASCBT_TARGET=" + bt_libname + " ASCBT_SRC=" + bt_srcname;
27 johnpye 1046 bt_rm = "/bin/rm";
28 johnpye 773 }
29    
30     Compiler::~Compiler(){
31 jpye 1355 #ifdef COMPILER_DEBUG
32 johnpye 1046 CONSOLE_DEBUG("Destroying compiler...");;
33 jpye 1355 #endif
34 johnpye 773 }
35    
36     Compiler *
37     Compiler::instance(){
38     static Compiler *_instance = NULL;
39     if(_instance == NULL){
40     _instance = new Compiler();
41     }
42     return _instance;
43     }
44    
45     const bool
46     Compiler::getUseRelationSharing() const{
47     if(g_use_copyanon){
48 johnpye 1049 return true;
49 johnpye 773 }
50 johnpye 1049 return false;
51 johnpye 773 }
52    
53     void
54     Compiler::setUseRelationSharing(const bool &use_relation_sharing){
55 jpye 2389 g_use_copyanon = 0;
56 johnpye 773 if(use_relation_sharing){
57     g_use_copyanon = 1;
58     }
59     }
60    
61 johnpye 1046 void
62     Compiler::setBinaryCompilation(const bool &use_bintoken){
63     this->use_bintoken = use_bintoken;
64 jpye 1355 #ifdef BINTOKEN_DEBUG
65 johnpye 1046 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"usebintoken = %d",int(use_bintoken));
66 jpye 1355 #endif
67 johnpye 1046 }
68    
69     void
70     Compiler::sendBinaryCompilationOptions(){
71     if(use_bintoken && !bintoken_options_sent){
72 jpye 1355 #ifdef BINTOKEN_DEBUG
73 johnpye 1046 CONSOLE_DEBUG("SETUP BINTOKENS...");
74 jpye 1355 #endif
75 johnpye 1046 BinTokenSetOptions(bt_srcname.c_str(), bt_objname.c_str(), bt_libname.c_str()
76 jpye 2388 , bt_cmd.c_str(), bt_rm.c_str(), 1000/*maxrels*/, 1/*verbose*/, 0/*housekeep*/
77 johnpye 1046 );
78    
79 jpye 1355 #ifdef BINTOKEN_DEBUG
80 jpye 2389 CONSOLE_DEBUG("srcname = %s, objname = %s, libname = %s, cmd = %s, rm = %s",
81 johnpye 1046 bt_srcname.c_str(), bt_objname.c_str(), bt_libname.c_str(), bt_cmd.c_str(), bt_rm.c_str()
82     );
83 jpye 1355 #endif
84    
85 johnpye 1046 bintoken_options_sent = true;
86     }else{
87 johnpye 1317 /* ERROR_REPORTER_HERE(ASC_PROG_NOTE,"disabling bintoken compilation\n"); */
88 johnpye 1046 bintoken_options_sent = false;
89     BinTokenSetOptions(NULL,NULL,NULL,NULL,NULL,0,1,1);
90     }
91     }
92    
93 johnpye 773 Compiler *getCompiler(){
94     return Compiler::instance();
95     }

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