mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
To be consistent with the rest of LLVM codebase (and the rest of this file):
* Changed tabs to spaces * Removed a space between a function call and its arguments (...) llvm-svn: 8712
This commit is contained in:
parent
b0f3876248
commit
6f218c8b49
@ -27,7 +27,7 @@ namespace {
|
|||||||
InputArgv(cl::ConsumeAfter, cl::desc("<program arguments>..."));
|
InputArgv(cl::ConsumeAfter, cl::desc("<program arguments>..."));
|
||||||
|
|
||||||
cl::opt<std::string>
|
cl::opt<std::string>
|
||||||
MainFunction ("f", cl::desc("Function to execute"), cl::init("main"),
|
MainFunction("f", cl::desc("Function to execute"), cl::init("main"),
|
||||||
cl::value_desc("function name"));
|
cl::value_desc("function name"));
|
||||||
|
|
||||||
cl::opt<bool> TraceMode("trace", cl::desc("Enable Tracing"));
|
cl::opt<bool> TraceMode("trace", cl::desc("Enable Tracing"));
|
||||||
@ -37,10 +37,10 @@ namespace {
|
|||||||
cl::init(false));
|
cl::init(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::string> makeStringVector (const char **envp) {
|
static std::vector<std::string> makeStringVector(const char **envp) {
|
||||||
std::vector<std::string> rv;
|
std::vector<std::string> rv;
|
||||||
for (unsigned i = 0; envp[i]; ++i)
|
for (unsigned i = 0; envp[i]; ++i)
|
||||||
rv.push_back (envp[i]);
|
rv.push_back(envp[i]);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,21 +92,21 @@ static void *CreateArgv(ExecutionEngine *EE,
|
|||||||
/// from calling FnName, or -1 and prints an error msg. if the named
|
/// from calling FnName, or -1 and prints an error msg. if the named
|
||||||
/// function cannot be found.
|
/// function cannot be found.
|
||||||
///
|
///
|
||||||
int callAsMain (ExecutionEngine *EE, Module *M, const std::string &FnName,
|
int callAsMain(ExecutionEngine *EE, Module *M, const std::string &FnName,
|
||||||
const std::vector<std::string> &Args,
|
const std::vector<std::string> &Args,
|
||||||
const std::vector<std::string> &EnvVars) {
|
const std::vector<std::string> &EnvVars) {
|
||||||
Function *Fn = M->getNamedFunction (FnName);
|
Function *Fn = M->getNamedFunction(FnName);
|
||||||
if (!Fn) {
|
if (!Fn) {
|
||||||
std::cerr << "Function '" << FnName << "' not found in module.\n";
|
std::cerr << "Function '" << FnName << "' not found in module.\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
std::vector<GenericValue> GVArgs;
|
std::vector<GenericValue> GVArgs;
|
||||||
GenericValue GVArgc;
|
GenericValue GVArgc;
|
||||||
GVArgc.IntVal = Args.size ();
|
GVArgc.IntVal = Args.size();
|
||||||
GVArgs.push_back (GVArgc); // Arg #0 = argc.
|
GVArgs.push_back(GVArgc); // Arg #0 = argc.
|
||||||
GVArgs.push_back (PTOGV (CreateArgv (EE, Args))); // Arg #1 = argv.
|
GVArgs.push_back(PTOGV(CreateArgv(EE, Args))); // Arg #1 = argv.
|
||||||
GVArgs.push_back (PTOGV (CreateArgv (EE, EnvVars))); // Arg #2 = envp.
|
GVArgs.push_back(PTOGV(CreateArgv(EE, EnvVars))); // Arg #2 = envp.
|
||||||
return EE->run (Fn, GVArgs).IntVal;
|
return EE->run(Fn, GVArgs).IntVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -126,22 +126,22 @@ int main(int argc, char **argv, const char **envp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExecutionEngine *EE =
|
ExecutionEngine *EE =
|
||||||
ExecutionEngine::create (M, ForceInterpreter, TraceMode);
|
ExecutionEngine::create(M, ForceInterpreter, TraceMode);
|
||||||
assert (EE && "Couldn't create an ExecutionEngine, not even an interpreter?");
|
assert(EE && "Couldn't create an ExecutionEngine, not even an interpreter?");
|
||||||
|
|
||||||
// Add the module's name to the start of the vector of arguments to main().
|
// Add the module's name to the start of the vector of arguments to main().
|
||||||
// But delete .bc first, since programs (and users) might not expect to
|
// But delete .bc first, since programs (and users) might not expect to
|
||||||
// see it.
|
// see it.
|
||||||
const std::string ByteCodeFileSuffix (".bc");
|
const std::string ByteCodeFileSuffix(".bc");
|
||||||
if (InputFile.rfind (ByteCodeFileSuffix) ==
|
if (InputFile.rfind(ByteCodeFileSuffix) ==
|
||||||
InputFile.length () - ByteCodeFileSuffix.length ()) {
|
InputFile.length() - ByteCodeFileSuffix.length()) {
|
||||||
InputFile.erase (InputFile.length () - ByteCodeFileSuffix.length ());
|
InputFile.erase(InputFile.length() - ByteCodeFileSuffix.length());
|
||||||
}
|
}
|
||||||
InputArgv.insert(InputArgv.begin(), InputFile);
|
InputArgv.insert(InputArgv.begin(), InputFile);
|
||||||
|
|
||||||
// Run the main function!
|
// Run the main function!
|
||||||
int ExitCode = callAsMain (EE, M, MainFunction, InputArgv,
|
int ExitCode = callAsMain(EE, M, MainFunction, InputArgv,
|
||||||
makeStringVector (envp));
|
makeStringVector(envp));
|
||||||
|
|
||||||
// Now that we are done executing the program, shut down the execution engine
|
// Now that we are done executing the program, shut down the execution engine
|
||||||
delete EE;
|
delete EE;
|
||||||
|
Loading…
Reference in New Issue
Block a user