This commit is contained in:
thrust26 2017-10-08 19:04:48 +02:00
commit 64e4153bca
3 changed files with 25 additions and 19 deletions

View File

@ -211,13 +211,13 @@ string Debugger::autoExec()
{
ostringstream buf;
// autoexec.stella is always run
FilesystemNode autoexec(myOSystem.baseDir() + "autoexec.stella");
// autoexec.script is always run
FilesystemNode autoexec(myOSystem.baseDir() + "autoexec.script");
buf << "autoExec():" << endl
<< myParser->exec(autoexec) << endl;
// Also, "romname.stella" if present
FilesystemNode romname(myOSystem.romFile().getPathWithExt(".stella"));
// Also, "romname.script" if present
FilesystemNode romname(myOSystem.romFile().getPathWithExt(".script"));
buf << myParser->exec(romname) << endl;
// Init builtins

View File

@ -129,7 +129,7 @@ string DebuggerParser::exec(const FilesystemNode& file)
{
ifstream in(file.getPath());
if(!in.is_open())
return red("autoexec file \'" + file.getShortPath() + "\' not found");
return red("script file \'" + file.getShortPath() + "\' not found");
ostringstream buf;
int count = 0;
@ -142,13 +142,13 @@ string DebuggerParser::exec(const FilesystemNode& file)
run(command);
count++;
}
buf << "Executed " << count << " commands from \""
buf << "\nExecuted " << count << " commands from \""
<< file.getShortPath() << "\"";
return buf.str();
}
else
return red("autoexec file \'" + file.getShortPath() + "\' not found");
return red("script file \'" + file.getShortPath() + "\' not found");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -572,12 +572,16 @@ string DebuggerParser::trapStatus(const Trap& trap)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool DebuggerParser::saveScriptFile(string file)
string DebuggerParser::saveScriptFile(string file)
{
if( file.find_last_of('.') == string::npos )
file += ".stella";
// Append 'script' extension when necessary
if(file.find_last_of('.') == string::npos)
file += ".script";
ofstream out(file);
FilesystemNode node(debugger.myOSystem.defaultSaveDir() + file);
ofstream out(node.getPath());
if(!out.is_open())
return "Unable to save script to " + node.getShortPath();
FunctionDefMap funcs = debugger.getFunctionDefMap();
for(const auto& f: funcs)
@ -608,7 +612,7 @@ bool DebuggerParser::saveScriptFile(string file)
for(const auto& cond: conds)
out << "breakif {" << cond << "}" << endl;
return out.good();
return "saved " + node.getShortPath() + " OK";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -959,8 +963,13 @@ void DebuggerParser::executeDump()
// "exec"
void DebuggerParser::executeExec()
{
FilesystemNode file(argStrings[0]);
commandResult << exec(file);
// Append 'script' extension when necessary
string file = argStrings[0];
if(file.find_last_of('.') == string::npos)
file += ".script";
FilesystemNode node(debugger.myOSystem.defaultSaveDir() + file);
commandResult << exec(node);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1429,10 +1438,7 @@ void DebuggerParser::executeS()
// "save"
void DebuggerParser::executeSave()
{
if(saveScriptFile(argStrings[0]))
commandResult << "saved script to file " << argStrings[0];
else
commandResult << red("I/O error");
commandResult << saveScriptFile(argStrings[0]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -65,7 +65,7 @@ class DebuggerParser
bool getArgs(const string& command, string& verb);
bool validateArgs(int cmd);
string eval();
bool saveScriptFile(string file);
string saveScriptFile(string file);
private:
enum { kNumCommands = 76 };