diff options
author | Florian Jung <flo@thinkpad.(none)> | 2011-01-10 20:39:51 +0100 |
---|---|---|
committer | Florian Jung <flo@thinkpad.(none)> | 2011-01-11 14:24:49 +0100 |
commit | db04e2fb861ed7ccef5a7339e9860ca5c2590a7c (patch) | |
tree | 4f2e2efe0f403981ae0d2ad47319dd1e253182f0 /synth/load.cpp | |
parent | e32591388a18c8226e61b8f88b031ed7c88ca153 (diff) |
In-synth-cli can now (re)load programs. maybe SEGFAULTING?
Diffstat (limited to 'synth/load.cpp')
-rw-r--r-- | synth/load.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/synth/load.cpp b/synth/load.cpp index 9b80106..b60c535 100644 --- a/synth/load.cpp +++ b/synth/load.cpp @@ -7,6 +7,8 @@ #include "util.h" #include "globals.h" +#include "parser.h" +#include "note_loader.h" using namespace std; @@ -196,3 +198,48 @@ void read_config(const char *cfg, bool complain=true) output_warning("WARNING: could not open config file '"+string(cfg)+"'.\nignoring this file..."); } } + +bool load_program(string file, program_t& prog) +{ + if (file!="") + { + try + { + prog=parse(file); + + // try to load the appropriate .so file + if (access( (file+".so").c_str(), R_OK ) == 0) + { + try + { + load_note_from_so(file+".so", prog); + output_verbose("NOTE: loaded shared object for program '"+file+"'"); + } + catch (string err) + { + output_note("NOTE: could not load shared object '"+file+".so"+"':\n" + " "+err+"\n" + " this is not fatal, the note has been loaded properly, but generic\n" + " unoptimized (slow) code will be used."); + } + } + + return true; + } + catch (string err) + { + output_warning("WARNING: error parsing '"+file+"': "+err+"\n" + " this is not fatal, but the program has NOT been loaded! defaulting to a\n" + " simple program and going on..."); + prog=default_program; + + return false; + } + } + else + { + prog=default_program; + + return true; + } +} |