[opengtl-commits] [331] * fix binaryExpression returning either a float/integer/ boolean instead of the real type that could be a vector |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 331
Author: cyrille
Date: 2008-08-31 11:18:10 +0200 (Sun, 31 Aug 2008)
Log Message:
-----------
* fix binaryExpression returning either a float/integer/boolean instead of the real type that could be a vector
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
trunk/OpenGTL/OpenShiva/tests/convolution/blur.shiva
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp 2008-08-31 08:29:20 UTC (rev 330)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp 2008-08-31 09:18:10 UTC (rev 331)
@@ -45,15 +45,8 @@
{
const GTLCore::Type* type1 = m_lhs->type();
const GTLCore::Type* type2 = m_rhs->type();
- if( type1 == GTLCore::Type::Float or type2 == GTLCore::Type::Float )
- {
- return GTLCore::Type::Float;
- }
- if( type1 == GTLCore::Type::Integer32 or type2 == GTLCore::Type::Integer32 )
- {
- return GTLCore::Type::Integer32;
- }
- return GTLCore::Type::Boolean;
+ GTL_ASSERT( type1 == type2 );
+ return type1;
}
void BinaryExpression::markAsReturnExpression()
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-08-31 08:29:20 UTC (rev 330)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-08-31 09:18:10 UTC (rev 331)
@@ -164,6 +164,7 @@
return result;
}
GTL_DEBUG("Create cast instruction");
+ GTL_DEBUG( *_value << " to " << *_targetType );
GTL_ASSERT(_targetType->d->type()->isFirstClassType());
GTL_ASSERT(_value->getType()->isFirstClassType());
return llvm::CastInst::create(
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp 2008-08-31 08:29:20 UTC (rev 330)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ConvertCenter_p.cpp 2008-08-31 09:18:10 UTC (rev 331)
@@ -49,6 +49,7 @@
public:
virtual AST::ConvertExpression* create( AST::Expression* value, const GTLCore::Type* _dstType ) const
{
+ GTL_ASSERT( canConvertBetween( value->type(), _dstType ));
return new AST::DefaultConvertExpression( value, _dstType );
}
virtual bool canConvertBetween( const GTLCore::Type* srcType, const GTLCore::Type* dstType) const
@@ -108,6 +109,7 @@
}
// Select the conversion with the highest priority
const Type* type = Type::Private::selectType(value1->type(), value2->type());
+ GTL_DEBUG( "Selected " << *type << " for " << *value1->type() << " and " << *value2->type());
return std::pair<AST::Expression*, AST::Expression*>( createConvertExpression(value1, type), createConvertExpression(value2, type)) ;
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-08-31 08:29:20 UTC (rev 330)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp 2008-08-31 09:18:10 UTC (rev 331)
@@ -1238,6 +1238,7 @@
} else {
std::pair<AST::Expression*, AST::Expression*> ce = d->compiler->convertCenter()->createConvertExpressions( lhs, rhs );
+ GTL_DEBUG( "Convert from (" << *lhs->type() << ", " << *rhs->type() << " ) to ( " << *ce.first->type() << ", " << *ce.second->type() << " )" );
if( not ce.first or not ce.second )
{
reportError( "Can do a binary operation only on two numbers", token );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp 2008-08-31 08:29:20 UTC (rev 330)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.cpp 2008-08-31 09:18:10 UTC (rev 331)
@@ -251,6 +251,7 @@
const Type* Type::Private::selectType(const Type* type1, const Type* type2)
{
+ GTL_ASSERT( (type1->isNumber() or type1->dataType() == Type::VECTOR ) and (type2->isNumber() or type2->dataType() == Type::VECTOR ) );
if( type1 == type2 )
{
return type1;
Modified: trunk/OpenGTL/OpenShiva/tests/convolution/blur.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/convolution/blur.shiva 2008-08-31 08:29:20 UTC (rev 330)
+++ trunk/OpenGTL/OpenShiva/tests/convolution/blur.shiva 2008-08-31 09:18:10 UTC (rev 331)
@@ -11,7 +11,6 @@
float2 point3;
point3[0] = result.x + 1;
point3[1] = result.y + 1;
- pixel v4 = img.sampleNearest( point1 ) + img.sampleNearest( point2 ) + img.sampleNearest( point3 );
- result = v4 / 3.0;
+ result = ( img.sampleNearest( point1 ) + img.sampleNearest( point2 ) + img.sampleNearest( point3 ) ) / 3.0;
}
}