mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +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);
|
||||
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
|
||||
const Type *RetTy = F->getReturnType();
|
||||
const FunctionType *FTy = F->getFunctionType();
|
||||
|
||||
// Handle some common cases first.
|
||||
if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) {
|
||||
if (ArgValues.size() == 3) {
|
||||
int (*PF)(int, char **, const char **) =
|
||||
(int(*)(int, char **, const char **))FPtr;
|
||||
|
||||
// Call the function.
|
||||
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
||||
(const char **)GVTOP(ArgValues[2]));
|
||||
return rv;
|
||||
} else if (ArgValues.size() == 1) {
|
||||
int (*PF)(int) = (int(*)(int))FPtr;
|
||||
rv.IntVal = PF(ArgValues[0].IntVal);
|
||||
return rv;
|
||||
} else if (ArgValues.size() == 0) {
|
||||
switch (ArgValues.size()) {
|
||||
case 3:
|
||||
if (FTy->getNumParams() == 3 &&
|
||||
(FTy->getParamType(0) == Type::IntTy ||
|
||||
FTy->getParamType(0) == Type::UIntTy) &&
|
||||
isa<PointerType>(FTy->getParamType(1)) &&
|
||||
isa<PointerType>(FTy->getParamType(2))) {
|
||||
int (*PF)(int, char **, const char **) =
|
||||
(int(*)(int, char **, const char **))FPtr;
|
||||
|
||||
// Call the function.
|
||||
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
||||
(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;
|
||||
rv.IntVal = PF();
|
||||
return rv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user