Example #1
0
bool asCDataType::CanBeInstantiated() const
{
    if( GetSizeOnStackDWords() == 0 ) // Void
        return false;

    if( !IsObject() && !IsFuncdef() ) // Primitives
        return true;

    if (IsNullHandle()) // null
        return false;

    if( IsObjectHandle() && !(typeInfo->flags & asOBJ_NOHANDLE) ) // Handles
        return true;

    // Funcdefs cannot be instantiated without being handles
    // The exception being delegates, but these can only be created as temporary objects
    if (IsFuncdef())
        return false;

    asCObjectType *ot = typeInfo->CastToObjectType();
    if( ot && (ot->flags & asOBJ_REF) && ot->beh.factories.GetLength() == 0 ) // ref types without factories
        return false;

    if( ot && (ot->flags & asOBJ_ABSTRACT) && !IsObjectHandle() ) // Can't instantiate abstract classes
        return false;

    return true;
}
asCString asCDataType::Format(bool includeNamespace) const
{
	if( IsNullHandle() )
		return "<null handle>";

	asCString str;

	if( isReadOnly )
		str = "const ";

	if( includeNamespace )
	{
		if( objectType )
			str += objectType->nameSpace->name + "::";
		else if( funcDef )
			str += funcDef->nameSpace->name + "::";
	}

	if( tokenType != ttIdentifier )
	{
		str += asCTokenizer::GetDefinition(tokenType);
	}
	else if( IsArrayType() && objectType && !objectType->engine->ep.expandDefaultArrayToTemplate )
	{
		str += objectType->templateSubType.Format(includeNamespace);
		str += "[]";
	}
	else if( funcDef )
	{
		str += funcDef->name;
	}
	else if( objectType )
	{
		str += objectType->name;
		if( objectType->flags & asOBJ_TEMPLATE )
		{
			str += "<";
			str += objectType->templateSubType.Format(includeNamespace);
			str += ">";
		}
	}
	else
	{
		str = "<unknown>";
	}

	if( isObjectHandle )
	{
		str += "@";
		if( isConstHandle )
			str += "const";
	}

    if( isReference )
		str += "&";

	return str;
}
Example #3
0
bool asCDataType::IsObject() const
{
	if( IsPrimitive() )
		return false;

	// Null handle doesn't have an object type but should still be considered an object
	if( objectType == 0 )
		return IsNullHandle();

	return true;
}
Example #4
0
bool asCDataType::IsObject() const
{
    if( IsPrimitive() )
        return false;

    // Null handle doesn't have an object type but should still be considered an object
    if( typeInfo == 0 )
        return IsNullHandle();

    // Template subtypes shouldn't be considered objects
    return typeInfo->CastToObjectType() ? true : false;
}
asCString asCDataType::Format() const
{
	if( IsNullHandle() )
		return "<null handle>";

	asCString str;

	if( isReadOnly )
		str = "const ";

	if( tokenType != ttIdentifier )
	{
		str += asGetTokenDefinition(tokenType);
	}
	else if( IsArrayType() )
	{
		str += objectType->templateSubType.Format();
		str += "[]";
	}
	else if( funcDef )
	{
		str += funcDef->name;
	}
	else if( objectType )
	{
		str += objectType->name;
		if( objectType->flags & asOBJ_TEMPLATE )
		{
			str += "<";
			str += objectType->templateSubType.Format();
			str += ">";
		}
	}
	else
	{
		str = "<unknown>";
	}

	if( isObjectHandle )
	{
		str += "@";
		if( isConstHandle )
			str += "const";
	}

    if( isReference )
		str += "&";

	return str;
}
Example #6
0
asCString asCDataType::Format(bool includeNamespace) const
{
	if( IsNullHandle() )
		return "<null handle>";

	asCString str;

	if( isReadOnly )
		str = "const ";

	if( includeNamespace )
	{
		if( objectType )
			str += objectType->nameSpace->name + "::";
		else if( funcDef )
			str += funcDef->nameSpace->name + "::";
	}

	if( tokenType != ttIdentifier )
	{
		str += asCTokenizer::GetDefinition(tokenType);
	}
	else if( IsArrayType() && objectType && !objectType->engine->ep.expandDefaultArrayToTemplate )
	{
		asASSERT( objectType->templateSubTypes.GetLength() == 1 );
		str += objectType->templateSubTypes[0].Format(includeNamespace);
		str += "[]";
	}
	else if( funcDef )
	{
		str += funcDef->name;
	}
	else if( objectType )
	{
		str += objectType->name;
		if( objectType->templateSubTypes.GetLength() > 0 )
		{
			str += "<";
			for( asUINT subtypeIndex = 0; subtypeIndex < objectType->templateSubTypes.GetLength(); subtypeIndex++ )
			{
				str += objectType->templateSubTypes[subtypeIndex].Format(includeNamespace);
				if( subtypeIndex != objectType->templateSubTypes.GetLength()-1 )
					str += ",";
			}
			str += ">";
		}
	}
	else
	{
		str = "<unknown>";
	}

	if( isObjectHandle )
	{
		str += "@";
		if( isConstHandle )
			str += "const";
	}

    if( isReference )
		str += "&";

	return str;
}
Example #7
0
asCString asCDataType::Format(asSNameSpace *currNs, bool includeNamespace) const
{
    if( IsNullHandle() )
        return "<null handle>";

    asCString str;

    if( isReadOnly )
        str = "const ";

    // If the type is not declared in the current namespace, then the namespace
    // must always be informed to guarantee that the correct type is informed
    if (includeNamespace || (typeInfo && typeInfo->nameSpace != currNs))
    {
        if (typeInfo && typeInfo->nameSpace && typeInfo->nameSpace->name != "")
            str += typeInfo->nameSpace->name + "::";
    }
    if (typeInfo && typeInfo->nameSpace == 0)
    {
        // If funcDef->nameSpace is null it means the funcDef was declared as member of
        // another type, in which case the scope should be built with the name of that type
        str += typeInfo->CastToFuncdefType()->parentClass->name + "::";
    }

    if( tokenType != ttIdentifier )
    {
        str += asCTokenizer::GetDefinition(tokenType);
    }
    else if( IsArrayType() && typeInfo && !typeInfo->engine->ep.expandDefaultArrayToTemplate )
    {
        asCObjectType *ot = typeInfo->CastToObjectType();
        asASSERT( ot && ot->templateSubTypes.GetLength() == 1 );
        str += ot->templateSubTypes[0].Format(currNs, includeNamespace);
        str += "[]";
    }
    else if(typeInfo)
    {
        str += typeInfo->name;
        asCObjectType *ot = typeInfo->CastToObjectType();
        if( ot && ot->templateSubTypes.GetLength() > 0 )
        {
            str += "<";
            for( asUINT subtypeIndex = 0; subtypeIndex < ot->templateSubTypes.GetLength(); subtypeIndex++ )
            {
                str += ot->templateSubTypes[subtypeIndex].Format(currNs, includeNamespace);
                if( subtypeIndex != ot->templateSubTypes.GetLength()-1 )
                    str += ",";
            }
            str += ">";
        }
    }
    else if( isAuto )
    {
        str += "<auto>";
    }
    else
    {
        str = "<unknown>";
    }

    if( isObjectHandle )
    {
        str += "@";
        if( isConstHandle )
            str += "const";
    }

    if( isReference )
        str += "&";

    return str;
}
Example #8
0
asCString asCDataType::Format(asSNameSpace *currNs, bool includeNamespace) const
{
	if( IsNullHandle() )
		return "<null handle>";

	asCString str;

	if( isReadOnly )
		str = "const ";

	// If the type is not declared in the current namespace, then the namespace
	// must always be informed to guarantee that the correct type is informed
	if( includeNamespace || (objectType && objectType->nameSpace != currNs) || (funcDef && funcDef->nameSpace != currNs) )
	{
		if( objectType && objectType->nameSpace->name != "" )
			str += objectType->nameSpace->name + "::";
		else if( funcDef && funcDef->nameSpace->name != "" )
			str += funcDef->nameSpace->name + "::";
	}

	if( tokenType != ttIdentifier )
	{
		str += asCTokenizer::GetDefinition(tokenType);
	}
	else if( IsArrayType() && objectType && !objectType->engine->ep.expandDefaultArrayToTemplate )
	{
		asASSERT( objectType->templateSubTypes.GetLength() == 1 );
		str += objectType->templateSubTypes[0].Format(currNs, includeNamespace);
		str += "[]";
	}
	else if( funcDef )
	{
		str += funcDef->name;
	}
	else if( objectType )
	{
		str += objectType->name;
		if( objectType->templateSubTypes.GetLength() > 0 )
		{
			str += "<";
			for( asUINT subtypeIndex = 0; subtypeIndex < objectType->templateSubTypes.GetLength(); subtypeIndex++ )
			{
				str += objectType->templateSubTypes[subtypeIndex].Format(currNs, includeNamespace);
				if( subtypeIndex != objectType->templateSubTypes.GetLength()-1 )
					str += ",";
			}
			str += ">";
		}
	}
	else if( isAuto )
	{
		if( isObjectHandle )
			str += "<auto@>";
		else
			str += "<auto>";
	}
	else
	{
		str = "<unknown>";
	}

	if( isObjectHandle )
	{
		str += "@";
		if( isConstHandle )
			str += "const";
	}

    if( isReference )
		str += "&";

	return str;
}