use c++11 variadic templates in Compiler::call

This commit is contained in:
Joshua Warner
2014-07-12 09:41:52 -06:00
committed by Joshua Warner
parent d8ddc95315
commit 060b5c8f13
5 changed files with 261 additions and 249 deletions

View File

@ -25,6 +25,37 @@ class TraceHandler {
virtual void handleTrace(Promise* address, unsigned argumentIndex) = 0;
};
template<size_t N>
class Args {
public:
ir::Value* values[N];
template<class... Ts>
Args(Ts... ts) : values{ts...}
{
}
operator util::Slice<ir::Value*> () {
return util::Slice<ir::Value*>(&values[0], N);
}
};
inline Args<0> args()
{
return Args<0>();
}
inline Args<1> args(ir::Value* first)
{
return Args<1> { first};
}
template<class... Ts>
inline Args<1 + util::ArgumentCount<Ts...>::Result> args(ir::Value* first, Ts... rest)
{
return Args<1 + util::ArgumentCount<Ts...>::Result> { first, rest... };
}
class Compiler {
public:
class Client {
@ -83,12 +114,11 @@ class Compiler {
virtual unsigned topOfStack() = 0;
virtual ir::Value* peek(unsigned footprint, unsigned index) = 0;
virtual ir::Value* call(ir::Value* address,
virtual ir::Value* nativeCall(ir::Value* address,
unsigned flags,
TraceHandler* traceHandler,
ir::Type resultType,
unsigned argumentCount,
...) = 0;
util::Slice<ir::Value*> arguments) = 0;
virtual ir::Value* stackCall(ir::Value* address,
unsigned flags,