[opengtl-commits] [264] add a convenient function that return the llvm type that should be used when this type is the parameter of a function

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 264
Author:   cyrille
Date:     2008-06-29 10:50:27 +0200 (Sun, 29 Jun 2008)

Log Message:
-----------
add a convenient function that return the llvm type that should be used when this type is the parameter of a function

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-06-29 08:49:52 UTC (rev 263)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp	2008-06-29 08:50:27 UTC (rev 264)
@@ -124,6 +124,17 @@
   return llvm::PointerType::get( type(), 0);
 }
 
+const llvm::Type * Type::Private::asArgumentType() const
+{
+  if( dataType == Type::ARRAY or dataType == Type::STRUCTURE )
+  {
+    return pointerType();
+  } else {
+    return type();
+  }
+}
+
+
 void Type::Private::setType( const llvm::Type* _type)
 {
   GTL_ASSERT(m_type == 0);

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-06-29 08:49:52 UTC (rev 263)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h	2008-06-29 08:50:27 UTC (rev 264)
@@ -80,6 +80,11 @@
        * @return a pointer version of the type a.k.a. llvm::PointerType::get( type(), 0)
        */
       const llvm::Type * pointerType() const;
+      /**
+       * @return how the type will be used as function argument (usually return type(),
+       *         except for ARRAY and STRUCTURE where it return pointerType() )
+       */
+      const llvm::Type * asArgumentType() const;
       void addFunctionMember( const StructFunctionMember& );
       void addPrivateFunctionMember( const StructFunctionMember& );
       int memberToIndex(const GTLCore::String&);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/