mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-03 11:08:32 +00:00
Fine, go all of the way and check that the argument types are correct as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15797 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d297aea5f2
commit
f7bedf447e
@ -64,22 +64,36 @@ GenericValue JIT::runFunction(Function *F,
|
|||||||
void *FPtr = getPointerToFunction(F);
|
void *FPtr = getPointerToFunction(F);
|
||||||
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
|
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
|
||||||
const Type *RetTy = F->getReturnType();
|
const Type *RetTy = F->getReturnType();
|
||||||
|
const FunctionType *FTy = F->getFunctionType();
|
||||||
|
|
||||||
// Handle some common cases first.
|
// Handle some common cases first.
|
||||||
if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) {
|
if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) {
|
||||||
if (ArgValues.size() == 3) {
|
switch (ArgValues.size()) {
|
||||||
int (*PF)(int, char **, const char **) =
|
case 3:
|
||||||
(int(*)(int, char **, const char **))FPtr;
|
if (FTy->getNumParams() == 3 &&
|
||||||
|
(FTy->getParamType(0) == Type::IntTy ||
|
||||||
// Call the function.
|
FTy->getParamType(0) == Type::UIntTy) &&
|
||||||
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
isa<PointerType>(FTy->getParamType(1)) &&
|
||||||
(const char **)GVTOP(ArgValues[2]));
|
isa<PointerType>(FTy->getParamType(2))) {
|
||||||
return rv;
|
int (*PF)(int, char **, const char **) =
|
||||||
} else if (ArgValues.size() == 1) {
|
(int(*)(int, char **, const char **))FPtr;
|
||||||
int (*PF)(int) = (int(*)(int))FPtr;
|
|
||||||
rv.IntVal = PF(ArgValues[0].IntVal);
|
// Call the function.
|
||||||
return rv;
|
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
||||||
} else if (ArgValues.size() == 0) {
|
(const char **)GVTOP(ArgValues[2]));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (FTy->getNumParams() == 1 &&
|
||||||
|
(FTy->getParamType(0) == Type::IntTy ||
|
||||||
|
FTy->getParamType(0) == Type::UIntTy)) {
|
||||||
|
int (*PF)(int) = (int(*)(int))FPtr;
|
||||||
|
rv.IntVal = PF(ArgValues[0].IntVal);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
int (*PF)() = (int(*)())FPtr;
|
int (*PF)() = (int(*)())FPtr;
|
||||||
rv.IntVal = PF();
|
rv.IntVal = PF();
|
||||||
return rv;
|
return rv;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user