mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Don't pass too many arguments into runFunction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15801 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5c3389a084
commit
f24d09933c
@ -102,14 +102,21 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
|
||||
std::vector<GenericValue> GVArgs;
|
||||
GenericValue GVArgc;
|
||||
GVArgc.IntVal = argv.size();
|
||||
GVArgs.push_back(GVArgc); // Arg #0 = argc.
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, argv))); // Arg #1 = argv.
|
||||
assert(((char **)GVTOP(GVArgs[1]))[0] && "argv[0] was null after CreateArgv");
|
||||
|
||||
std::vector<std::string> EnvVars;
|
||||
for (unsigned i = 0; envp[i]; ++i)
|
||||
EnvVars.push_back(envp[i]);
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, EnvVars))); // Arg #2 = envp.
|
||||
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
|
||||
if (NumArgs) {
|
||||
GVArgs.push_back(GVArgc); // Arg #0 = argc.
|
||||
if (NumArgs > 1) {
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, argv))); // Arg #1 = argv.
|
||||
assert(((char **)GVTOP(GVArgs[1]))[0] &&
|
||||
"argv[0] was null after CreateArgv");
|
||||
if (NumArgs > 2) {
|
||||
std::vector<std::string> EnvVars;
|
||||
for (unsigned i = 0; envp[i]; ++i)
|
||||
EnvVars.push_back(envp[i]);
|
||||
GVArgs.push_back(PTOGV(CreateArgv(this, EnvVars))); // Arg #2 = envp.
|
||||
}
|
||||
}
|
||||
}
|
||||
return runFunction(Fn, GVArgs).IntVal;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user