[opengtl-commits] [716] don' t use the type of the argument when generating the function parameter |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 716
Author: cyrille
Date: 2009-04-09 16:10:17 +0200 (Thu, 09 Apr 2009)
Log Message:
-----------
don't use the type of the argument when generating the function parameter
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2009-04-09 13:21:26 UTC (rev 715)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2009-04-09 14:10:17 UTC (rev 716)
@@ -319,14 +319,21 @@
llvm::Constant* CodeGenerator::convertConstantArrayToVector(llvm::Constant* constant, const Type* constantType, const Type* type)
{
- llvm::ConstantArray* arrayConstant = dynamic_cast<llvm::ConstantArray*>(constant);
+ GTL_DEBUG(*constant);
+ GTL_DEBUG(*constant->getType());
+ llvm::ConstantStruct* arrayConstant = dynamic_cast<llvm::ConstantStruct*>(constant->getOperand(0));
GTL_ASSERT(arrayConstant);
GTL_ASSERT(constantType->dataType() == Type::ARRAY );
- GTL_ASSERT(constantType->dataType() == Type::VECTOR );
+ GTL_ASSERT(type->dataType() == Type::VECTOR );
+ GTL_ASSERT(arrayConstant->getNumOperands() == 3 );
+ llvm::Constant* values = arrayConstant->getOperand(2)->getOperand(0)->getOperand(0);
+ GTL_DEBUG(*values);
+ GTL_ASSERT(dynamic_cast<llvm::ConstantArray*>(values) );
std::vector<llvm::Constant*> constants;
- for(unsigned int i = 0; i < arrayConstant->getNumOperands(); ++i )
+ for(unsigned int i = 0; i < values->getNumOperands(); ++i )
{
- constants.push_back(arrayConstant->getOperand(i));
+ GTL_DEBUG(*values->getOperand(i));
+ constants.push_back(values->getOperand(i));
if( constants.size() == type->vectorSize() )
{
break;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2009-04-09 13:21:26 UTC (rev 715)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2009-04-09 14:10:17 UTC (rev 716)
@@ -347,7 +347,13 @@
AST::Expression* ParserBase::parseCoumpoundExpression( const Type* _type, bool _constantExpression )
{
- GTL_ASSERT( _type );
+// GTL_ASSERT( _type );
+ bool autoType = false;
+ if( not _type )
+ {
+ _type = GTLCore::TypesManager::getArray(GTLCore::Type::Float); // TODO: delay the selection of the type of te coumpound to later
+ autoType = true;
+ }
GTL_DEBUG( *_type );
Token::Type endToken;
@@ -374,13 +380,17 @@
const Type* subtype = _type->d->subtypeAt( index );
if( d->currentToken.type == Token::STARTBRACE )
{
- GTL_ASSERT( subtype );
GTL_DEBUG( index << " " << *subtype );
if( subtype->dataType() != Type::STRUCTURE and subtype->dataType() != Type::ARRAY )
{
- GTL_DEBUG("unexpected");
- reportUnexpected( d->currentToken );
- return 0;
+ if(autoType) {
+ subtype = _type;
+ _type = GTLCore::TypesManager::getArray(_type);
+ } else {
+ GTL_DEBUG("unexpected");
+ reportUnexpected( d->currentToken );
+ return 0;
+ }
}
expression = parseCoumpoundExpression( subtype, _constantExpression );
} else {
@@ -1387,7 +1397,7 @@
return arguments;
} else {
int posArg = arguments.size();
- AST::Expression* expression = parseExpression( false, _parameters[ posArg + firstParameter].type() );
+ AST::Expression* expression = parseExpression( false, 0 );
if(not expression)
{
return arguments;