[opengtl-commits] [378] array also have the count field |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 378
Author: cyrille
Date: 2008-09-07 23:18:13 +0200 (Sun, 07 Sep 2008)
Log Message:
-----------
array also have the count field
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp 2008-09-07 20:01:24 UTC (rev 377)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/AccessorExpression.cpp 2008-09-07 21:18:13 UTC (rev 378)
@@ -32,6 +32,7 @@
#include "../Type_p.h"
#include "../Utils_p.h"
+#include "../wrappers/ArrayWrap.h"
#include "../wrappers/StructWrap.h"
using namespace GTLCore::AST;
@@ -78,7 +79,7 @@
GTL_DEBUG("ArraySizeAccessorExpression::pointer");
std::vector<llvm::Value*> indexes;
indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); // Access the structure of the array
- indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); // Access the size of the array
+ indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_SIZE)); // Access the size of the array
return llvm::GetElementPtrInst::Create( m_parent->pointer( _gc, _bb),
indexes.begin(), indexes.end(), "", _bb);
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp 2008-09-07 20:01:24 UTC (rev 377)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp 2008-09-07 21:18:13 UTC (rev 378)
@@ -71,6 +71,7 @@
if( m_type->dataType() == Type::ARRAY )
{
std::vector<llvm::Constant*> arrayStruct;
+ arrayStruct.push_back( _gc.codeGenerator()->integerToConstant( 0 ) );
arrayStruct.push_back( _gc.codeGenerator()->integerToConstant( members.size() ) );
llvm::Constant* constant = llvm::ConstantArray::get(
llvm::ArrayType::get( arrayType->d->type(), members.size()), members );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-09-07 20:01:24 UTC (rev 377)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-09-07 21:18:13 UTC (rev 378)
@@ -135,6 +135,7 @@
d->arrayType = _arrayType;
std::vector< const llvm::Type * > types;
+ types.push_back(llvm::Type::Int32Ty); // Counter from structure
types.push_back(llvm::Type::Int32Ty);
types.push_back( llvm::PointerType::get( _arrayType->d->type(), 0));
d->setType( llvm::StructType::get(types));
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp 2008-09-07 20:01:24 UTC (rev 377)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Visitor_p.cpp 2008-09-07 21:18:13 UTC (rev 378)
@@ -315,7 +315,7 @@
_pointerType->embeddedType(), _donttouch, _allocatedInMemory );
std::vector<llvm::Value*> indexes;
indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)); // Access the structure of the array
- indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, 1)); // Access the size of the array
+ indexes.push_back( llvm::ConstantInt::get(llvm::Type::Int32Ty, ArrayWrap::POS_DATA )); // Access the data of the array
// Init the size
llvm::Value* ptrToData = llvm::GetElementPtrInst::Create( _pointer, indexes.begin(), indexes.end(), "", endBodyBlock);
new llvm::FreeInst( new llvm::LoadInst( ptrToData, "", endBodyBlock ), endBodyBlock );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h 2008-09-07 20:01:24 UTC (rev 377)
+++ trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h 2008-09-07 21:18:13 UTC (rev 378)
@@ -25,13 +25,13 @@
* @ingroup GTLCore
* @internal
*/
-// STRUCT_HEADER
struct ArrayWrap {
+ STRUCT_HEADER
int size;
void* data;
enum ArrayIndexes {
- POS_SIZE = 0, // STRUCT_FIRST_ELEMENT,
- POS_DATA = 1 // STRUCT_FIRST_ELEMENT + 1,
+ POS_SIZE = STRUCT_FIRST_ELEMENT,
+ POS_DATA = STRUCT_FIRST_ELEMENT + 1,
};
};