/**
* Check a Vector literal.
*/
public void checkVectorLiteral(IASNode iNode, Binding type_param)
{
IDefinition type_def = type_param.getDefinition();
IContainerNode contentsNode = ((VectorLiteralNode)iNode).getContentsNode();
if ( type_def != null )
{
boolean isNumericTypeOrBoolean = SemanticUtils.isNumericTypeOrBoolean(type_def, project);
String typeName = type_def.getBaseName();
boolean isInt = SemanticUtils.isBuiltin(type_def, BuiltinType.INT, project);
boolean isUint = SemanticUtils.isBuiltin(type_def, BuiltinType.UINT, project);
for ( int i = 0; i < contentsNode.getChildCount(); i++ )
{
IASNode literal_element = contentsNode.getChild(i);
if (isNumericTypeOrBoolean)
{
// check for loss of precision
if ( literal_element instanceof NumericLiteralNode )
{
INumericLiteralNode.INumericValue numeric = ((NumericLiteralNode)literal_element).getNumericValue();
if ( (isInt && ( numeric.toNumber() != numeric.toInt32())) ||
(isUint && ( numeric.toNumber() != numeric.toUint32())) )
{
addProblem(new LossyConversionProblem(literal_element, typeName));
}
}
// check for null values where they don't make sense
if (literal_element instanceof IExpressionNode)
{
IDefinition elementType = ((IExpressionNode)literal_element).resolveType(project);
boolean elementIsNull = SemanticUtils.isBuiltin(elementType, BuiltinType.NULL, project);
if (elementIsNull)
{
addProblem( new NullUsedWhereOtherExpectedProblem(literal_element, typeName));
}