forked from OSchip/llvm-project
Dispatch without hash table lookup.
Cmd used to be the single central place to dispatch. It is not longer the case because we have a logic for readProvideOrAssignment(). This patch removes the hash table so that evrything is in a single function. This is slightly verbose but should improve readability. Differential Revision: https://reviews.llvm.org/D24200 llvm-svn: 280524
This commit is contained in:
parent
cd6b12b12e
commit
a27eeccade
|
@ -620,7 +620,6 @@ private:
|
|||
void readExtern();
|
||||
void readGroup();
|
||||
void readInclude();
|
||||
void readNothing() {}
|
||||
void readOutput();
|
||||
void readOutputArch();
|
||||
void readOutputFormat();
|
||||
|
@ -656,27 +655,11 @@ private:
|
|||
void readGlobal(StringRef VerStr);
|
||||
void readLocal();
|
||||
|
||||
const static StringMap<Handler> Cmd;
|
||||
ScriptConfiguration &Opt = *ScriptConfig;
|
||||
StringSaver Saver = {ScriptConfig->Alloc};
|
||||
bool IsUnderSysroot;
|
||||
};
|
||||
|
||||
const StringMap<elf::ScriptParser::Handler> elf::ScriptParser::Cmd = {
|
||||
{"ENTRY", &ScriptParser::readEntry},
|
||||
{"EXTERN", &ScriptParser::readExtern},
|
||||
{"GROUP", &ScriptParser::readGroup},
|
||||
{"INCLUDE", &ScriptParser::readInclude},
|
||||
{"INPUT", &ScriptParser::readGroup},
|
||||
{"OUTPUT", &ScriptParser::readOutput},
|
||||
{"OUTPUT_ARCH", &ScriptParser::readOutputArch},
|
||||
{"OUTPUT_FORMAT", &ScriptParser::readOutputFormat},
|
||||
{"PHDRS", &ScriptParser::readPhdrs},
|
||||
{"SEARCH_DIR", &ScriptParser::readSearchDir},
|
||||
{"SECTIONS", &ScriptParser::readSections},
|
||||
{"VERSION", &ScriptParser::readVersion},
|
||||
{";", &ScriptParser::readNothing}};
|
||||
|
||||
void ScriptParser::readVersionScript() {
|
||||
readVersionScriptCommand();
|
||||
if (!atEOF())
|
||||
|
@ -710,8 +693,31 @@ void ScriptParser::readVersion() {
|
|||
void ScriptParser::readLinkerScript() {
|
||||
while (!atEOF()) {
|
||||
StringRef Tok = next();
|
||||
if (Handler Fn = Cmd.lookup(Tok)) {
|
||||
(this->*Fn)();
|
||||
if (Tok == ";")
|
||||
continue;
|
||||
|
||||
if (Tok == "ENTRY") {
|
||||
readEntry();
|
||||
} else if (Tok == "EXTERN") {
|
||||
readExtern();
|
||||
} else if (Tok == "GROUP" || Tok == "INPUT") {
|
||||
readGroup();
|
||||
} else if (Tok == "INCLUDE") {
|
||||
readInclude();
|
||||
} else if (Tok == "OUTPUT") {
|
||||
readOutput();
|
||||
} else if (Tok == "OUTPUT_ARCH") {
|
||||
readOutputArch();
|
||||
} else if (Tok == "OUTPUT_FORMAT") {
|
||||
readOutputFormat();
|
||||
} else if (Tok == "PHDRS") {
|
||||
readPhdrs();
|
||||
} else if (Tok == "SEARCH_DIR") {
|
||||
readSearchDir();
|
||||
} else if (Tok == "SECTIONS") {
|
||||
readSections();
|
||||
} else if (Tok == "VERSION") {
|
||||
readVersion();
|
||||
} else if (SymbolAssignment *Cmd = readProvideOrAssignment(Tok)) {
|
||||
if (Opt.HasContents)
|
||||
Opt.Commands.emplace_back(Cmd);
|
||||
|
|
Loading…
Reference in New Issue