diff options
author | David Robillard <d@drobilla.net> | 2009-10-06 20:29:06 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-10-06 20:29:06 +0000 |
commit | 31586bbff8588f8eab127bf57bc311d38ad8e1e0 (patch) | |
tree | fd2b38c0bc57a17559a78a98b8e9c3e8cda8bddb /src/tuplr.cpp | |
parent | f55fa30ac2169357ca089a6a4c73c14480841e6e (diff) | |
download | resp-31586bbff8588f8eab127bf57bc311d38ad8e1e0.tar.gz resp-31586bbff8588f8eab127bf57bc311d38ad8e1e0.tar.bz2 resp-31586bbff8588f8eab127bf57bc311d38ad8e1e0.zip |
Fully abstract backend interface.
git-svn-id: http://svn.drobilla.net/resp/tuplr@197 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/tuplr.cpp')
-rw-r--r-- | src/tuplr.cpp | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/tuplr.cpp b/src/tuplr.cpp index f8cc246..481885c 100644 --- a/src/tuplr.cpp +++ b/src/tuplr.cpp @@ -48,16 +48,7 @@ print_usage(char* name, bool error) int main(int argc, char** argv) { - PEnv penv; - TEnv tenv(penv); - initLang(penv, tenv); - - Engine* engine = tuplr_new_engine(); - CEnv* cenv = new CEnv(penv, tenv, engine); - - cenv->push(); - Object::pool.lock(); - + // Read command line arguments map<string,string> args; list<string> files; for (int i = 1; i < argc; ++i) { @@ -78,17 +69,35 @@ main(int argc, char** argv) } } + PEnv penv; + TEnv tenv(penv); + initLang(penv, tenv); + + Engine* engine = NULL; + + map<string,string>::const_iterator a = args.find("-b"); + const string backend_name = (a != args.end() ? a->second : "llvm"); + + if (backend_name == "llvm") + engine = tuplr_new_llvm_engine(); + + if (!engine) { + std::cerr << "Unable to open backend " << backend_name << std::endl; + return 1; + } + + CEnv* cenv = new CEnv(penv, tenv, engine); cenv->args = args; + cenv->push(); + + Object::pool.lock(); int ret = 0; - string output; - map<string,string>::const_iterator a = args.find("-o"); - if (a != args.end()) - output = a->second; + a = args.find("-o"); + const string output = (a != args.end()) ? a->second : ""; - a = args.find("-p"); - if (a != args.end()) { + if (args.find("-p") != args.end()) { ifstream is(files.front().c_str()); if (is.good()) { Cursor loc; @@ -131,7 +140,7 @@ main(int argc, char** argv) } delete cenv; - tuplr_free_engine(engine); + delete engine; return ret; } |