[opengtl-commits] [260] add a convenient function to create GTLCore:: Function with a given llvm::Function* |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 260
Author: cyrille
Date: 2008-06-29 10:47:58 +0200 (Sun, 29 Jun 2008)
Log Message:
-----------
add a convenient function to create GTLCore::Function with a given llvm::Function*
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp 2008-06-29 08:47:12 UTC (rev 259)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp 2008-06-29 08:47:58 UTC (rev 260)
@@ -104,3 +104,31 @@
data->setModule( _module );
return new GTLCore::Function( GTLCore::ScopedName("", _name), retType, data );
}
+
+GTLCore::Function* Function::Private::createInternalFunction(llvm::Module* _module, const GTLCore::String& _name, llvm::Function* _function, const GTLCore::Type* retType, int _count, ...)
+{
+ GTL_ASSERT( _function );
+ std::vector<GTLCore::Parameter> arguments;
+ va_list argp;
+ va_start(argp, _count);
+#ifndef _NDEBUG_
+ const llvm::FunctionType *FTy =
+ llvm::cast<llvm::FunctionType>(llvm::cast<llvm::PointerType>(_function->getType())->getElementType());
+#endif
+ for(int i = 0; i < _count; ++i)
+ {
+ const GTLCore::Type* type = va_arg(argp, const GTLCore::Type*);
+ arguments.push_back(GTLCore::Parameter("", type, false, false, GTLCore::Value() ) );
+#ifndef _NDEBUG_
+ GTL_DEBUG( *type->d->asArgumentType() << " == " << *FTy->getParamType(i) );
+ GTL_ASSERT( type->d->asArgumentType() == FTy->getParamType(i) );
+#endif
+ }
+ va_end(argp);
+ std::vector<llvm::Function*> functions(arguments.size() + 1);
+ functions[arguments.size() ] = _function;
+ GTLCore::Function::Data* data = new GTLCore::Function::Data(arguments, arguments.size() );
+ data->setFunctions( functions );
+ data->setModule( _module );
+ return new GTLCore::Function( GTLCore::ScopedName("", _name), retType, data );
+}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h 2008-06-29 08:47:12 UTC (rev 259)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h 2008-06-29 08:47:58 UTC (rev 260)
@@ -45,6 +45,7 @@
std::vector<FunctionCaller*> functionsCaller;
static GTLCore::Function* createExternalFunction(llvm::Module* _module, const GTLCore::String& _name, const GTLCore::String& _symbolName, const GTLCore::Type* retType, const std::vector<GTLCore::Parameter>& arguments);
static GTLCore::Function* createExternalFunction(llvm::Module* _module, const GTLCore::String& _name, const GTLCore::String& _symbolName, const GTLCore::Type* retType, int _count, ...);
+ static GTLCore::Function* createInternalFunction(llvm::Module* _module, const GTLCore::String& _name, llvm::Function* _function, const GTLCore::Type* retType, int _count, ...);
};
/**
* @internal