Skip to content

Commit

Permalink
[lldb/Lua] Add missing boiler plate to ScriptInterpreter.
Browse files Browse the repository at this point in the history
 - Fix enum entry order.
 - Fix missing enum case in CommandObjectBreakpointCommand.
 - Add Lua entry to swtich in LanguageToString and simplify the code.
  • Loading branch information
JDevlieghere committed Dec 22, 2019
1 parent 0fe131a commit acdda13
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lldb/include/lldb/lldb-enumerations.h
Expand Up @@ -211,11 +211,11 @@ enum DescriptionLevel {

/// Script interpreter types.
enum ScriptLanguage {
eScriptLanguageNone,
eScriptLanguageNone = 0,
eScriptLanguagePython,
eScriptLanguageLua,
eScriptLanguageDefault = eScriptLanguagePython,
eScriptLanguageUnknown
eScriptLanguageUnknown,
eScriptLanguageDefault = eScriptLanguagePython
};

/// Register numbering types.
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Commands/CommandObjectBreakpointCommand.cpp
Expand Up @@ -307,6 +307,7 @@ are no syntax errors may indicate that a function was declared but never called.
m_use_script_language = true;
break;
case eScriptLanguageNone:
case eScriptLanguageUnknown:
m_use_script_language = false;
break;
}
Expand Down
24 changes: 10 additions & 14 deletions lldb/source/Interpreter/ScriptInterpreter.cpp
Expand Up @@ -43,21 +43,16 @@ void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
}

std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) {
std::string return_value;

switch (language) {
case eScriptLanguageNone:
return_value = "None";
break;
return "None";
case eScriptLanguagePython:
return_value = "Python";
break;
return "Python";
case eScriptLanguageLua:
return "Lua";
case eScriptLanguageUnknown:
return_value = "Unknown";
break;
return "Unknown";
}

return return_value;
}

lldb::ScriptLanguage
Expand All @@ -66,6 +61,8 @@ ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
return eScriptLanguageNone;
if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
return eScriptLanguagePython;
if (language.equals_lower(LanguageToString(eScriptLanguageLua)))
return eScriptLanguageLua;
return eScriptLanguageUnknown;
}

Expand All @@ -82,13 +79,12 @@ Status ScriptInterpreter::SetBreakpointCommandCallback(
}

Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(
std::vector<BreakpointOptions *> &bp_options_vec,
const char *function_name,
std::vector<BreakpointOptions *> &bp_options_vec, const char *function_name,
StructuredData::ObjectSP extra_args_sp) {
Status error;
for (BreakpointOptions *bp_options : bp_options_vec) {
error = SetBreakpointCommandCallbackFunction(bp_options, function_name,
extra_args_sp);
error = SetBreakpointCommandCallbackFunction(bp_options, function_name,
extra_args_sp);
if (!error.Success())
return error;
}
Expand Down

0 comments on commit acdda13

Please sign in to comment.