return false;
}
- return this->emitCallVoid(Func, Initializer);
+ return this->emitCall(Func, Initializer);
} else if (const auto *InitList = dyn_cast<InitListExpr>(Initializer)) {
const Record *R = getRecord(InitList->getType());
return false;
}
- // Primitive return value, just call it.
- if (T)
- return this->emitCall(*T, Func, E);
-
- // Void Return value, easy.
- if (ReturnType->isVoidType())
- return this->emitCallVoid(Func, E);
-
- // Non-primitive return value with Return Value Optimization,
- // we already have a pointer on the stack to write the result into.
- if (Func->hasRVO())
- return this->emitCallVoid(Func, E);
+ // In any case call the function. The return value will end up on the stack and
+ // if the function has RVO, we already have the pointer on the stack to write
+ // the result into.
+ return this->emitCall(Func, E);
} else {
assert(false && "We don't support non-FunctionDecl callees right now.");
}
return ReturnValue<T>(S.Stk.pop<T>(), Result);
}
-bool EvalEmitter::emitCallVoid(const Function *Func, const SourceInfo &Info) {
- APValue VoidResult;
- InterpFrame *before = S.Current;
- (void)before;
- S.Current = new InterpFrame(S, Func, {});
- bool Success = Interpret(S, VoidResult);
- assert(VoidResult.isAbsent());
- assert(S.Current == before);
- return Success;
-}
-
bool EvalEmitter::emitRetVoid(const SourceInfo &Info) { return true; }
bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
return true;
}
-static bool CallVoid(InterpState &S, CodePtr &PC, const Function *Func) {
- APValue VoidResult;
- S.Current = new InterpFrame(S, const_cast<Function *>(Func), PC);
- bool Success = Interpret(S, VoidResult);
- assert(VoidResult.isAbsent());
-
- return Success;
-}
-
static bool RetVoid(InterpState &S, CodePtr &PC, APValue &Result) {
S.CallStackDepth--;
return true;
}
-template <PrimType Name, class T = typename PrimConv<Name>::T>
-static bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
+inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
auto NewFrame = std::make_unique<InterpFrame>(S, Func, PC);
if (Func->hasThisPointer()) {
if (!CheckInvoke(S, PC, NewFrame->getThis())) {
def Call : Opcode {
let Args = [ArgFunction];
- let Types = [AllTypeClass];
- let ChangesPC = 1;
- let HasGroup = 1;
-}
-
-def CallVoid : Opcode {
- let Args = [ArgFunction];
let Types = [];
let ChangesPC = 1;
- let HasCustomEval = 1;
}
//===----------------------------------------------------------------------===//