mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-29 22:21:51 +00:00
We can do better when reporting the status of one-liner script execution.
Change the prototype of ScriptInterpreter::ExecuteOneLine() to return bool instead of void and take one additional parameter as CommandReturnObject *. Propagate the status of one-liner execution back appropriately. llvm-svn: 109899
This commit is contained in:
1 parent
fe1a4944b1
commit
7dc2e4784e
7 files changed
+37
-16
No files matched your search
@@ -258,17 +258,28 @@ ScriptInterpreterPython::~ScriptInterpreterPython ()
|
||||
Py_Finalize ();
|
||||
}
|
||||
|
||||
void
|
||||
ScriptInterpreterPython::ExecuteOneLine (CommandInterpreter &interpreter, const char *command)
|
||||
bool
|
||||
ScriptInterpreterPython::ExecuteOneLine (CommandInterpreter &interpreter,
|
||||
const char *command,
|
||||
CommandReturnObject *result = 0)
|
||||
{
|
||||
if (command)
|
||||
{
|
||||
int success;
|
||||
|
||||
success = PyRun_SimpleString (command);
|
||||
if (success != 0)
|
||||
interpreter.GetDebugger().GetErrorStream().Printf ("error: python failed attempting to evaluate '%s'\n", command);
|
||||
if (success == 0)
|
||||
return true;
|
||||
|
||||
// The one-liner failed. Append the error message.
|
||||
if (result)
|
||||
result->AppendErrorWithFormat ("python failed attempting to evaluate '%s'\n", command);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result)
|
||||
result->AppendError ("empty command passed to python\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user