qasm/qasm.cpp

129 lines
2.4 KiB
C++
Raw Normal View History

2019-11-11 23:56:03 +00:00
#include "app.h"
#include "asm.h"
#define CLASS PAL_APPCLASS
// return a pointer to the actual Application class
PAL_BASEAPP *PAL::appFactory(void)
{
return (new CLASS());
}
// you MUST supply this array 'appOptions'. NULL line and end.
programOption PAL::appOptions[] =
{
{ "debug", "d", "enable debug info (repeat for more verbosity)", "", false, true},
{ "config", "f", "load configuration data from a <file>", "<file>", false, false},
{ "exec", "x", "execute a command", "<command>", false, false},
2019-11-11 23:56:03 +00:00
{ "", "", "", "", false, false}
};
int CLASS::runServerApp(PAL_EVENTMANAGER *em)
{
int res = -1;
if (em != NULL)
{
PAL_BASEAPP::runServerApp(em);
2019-11-12 18:13:15 +00:00
#if 0
2019-11-11 23:56:03 +00:00
PAL_HTTPSERVERTASK *server = new PAL_HTTPSERVERTASK("httptask");
if (server != NULL)
{
em->startTask(server);
server->initServer(getConfig("http.listen", "0.0.0.0:9080"), false, 64);
res = 0;
}
2019-11-12 18:13:15 +00:00
#endif
2019-11-11 23:56:03 +00:00
}
return (res);
}
int CLASS::runCommandLineApp(void)
{
TFileProcessor *t = NULL;
std::string line;
// only called if SERVERAPP not defined
int res = -1;
//LOG_DEBUG << "command line mode" << endl;
if (commandargs.size()==0)
{
fprintf(stderr,"No files given (--help for help)\n\n");
return(res);
}
2019-11-11 23:56:03 +00:00
for (ArgVec::const_iterator it = commandargs.begin(); it != commandargs.end(); ++it)
{
Poco::File fn(*it);
std::string p = fn.path();
Poco::Path path(p);
//logger().information(path.toString());
std::string e = toUpper(path.getExtension());
std::string cmd = Poco::toUpper(getConfig("option.exec", "asm"));
2019-11-11 23:56:03 +00:00
if (cmd.length() > 0)
2019-11-11 23:56:03 +00:00
{
if (cmd == "REFORMAT")
{
res = 0;
t = new TMerlinConverter();
if (t != NULL)
{
t->init();
std::string f = path.toString();
t->processfile(f);
t->process();
t->complete();
res = (t->errorct > 0) ? -1 : 0;
delete t;
t = NULL;
}
}
else if (cmd == "ASM")
{
if (e == "S")
{
//logger().information("ASM: " + path.toString());
t = new T65816Asm();
}
if (e == "LNK")
{
//logger().information("LNK: " + path.toString());
t = new T65816Link();
}
if (t != NULL)
{
t->init();
std::string f = path.toString();
t->processfile(f);
t->process();
t->complete();
res = (t->errorct > 0) ? -1 : 0;
delete t;
t = NULL;
}
else
{
printf("not supported type\n");
}
}
else
{
fprintf(stderr,"Invalid command: <%s>\n\n", cmd.c_str());
}
2019-11-11 23:56:03 +00:00
}
}
return (res);
}