Exemple #1
0
    RefPtr<Type> TypeReturn::Resolve( const EvalData& evalData, ITypeEnv* typeEnv, IValueBinder* binder )
    {
        UNREFERENCED_PARAMETER( evalData );
        UNREFERENCED_PARAMETER( typeEnv );

        HRESULT hr = S_OK;
        RefPtr<Type>    retType;

        hr = binder->GetReturnType( retType.Ref() );
        if ( FAILED( hr ) )
            return NULL;

        // TODO: is this the only type that can do this?
        //       is it only inner types that work with typeof( return ).T?
        //       or is it also enum members, or other things?
        if ( retType->AsTypeStruct() == NULL )
        {
            if ( Parts.size() == 0 )
                return retType;
            else
                return NULL;
        }

        return ResolveTypeChain( retType->GetDeclaration() );
    }
Exemple #2
0
    void FillValueTraits( EvalResult& result, Expression* expr )
    {
        result.ReadOnly = true;
        result.HasString = false;
        result.HasChildren = false;

        if ( !expr || expr->Kind == DataKind_Value )
        {
            RefPtr<Type>    type = result.ObjVal._Type;

            if ( (type->AsTypeStruct() != NULL)
                || type->IsSArray() )
            {
                // some types just don't allow assignment
            }
            else if ( result.ObjVal.Addr != 0 )
            {
                result.ReadOnly = false;
            }
            else if ( expr && expr->AsNamingExpression() != NULL ) 
            {
                Declaration* decl = expr->AsNamingExpression()->Decl;
                result.ReadOnly = (decl == NULL) || decl->IsConstant();
            }

            if ( (type->AsTypeNext() != NULL) && type->AsTypeNext()->GetNext()->IsChar() )
            {
                if ( type->IsPointer() || type->IsSArray() || type->IsDArray() )
                    result.HasString = true;
            }

            if ( type->IsPointer() || type->IsSArray() || type->IsDArray()  || type->IsAArray()
                || (type->AsTypeStruct() != NULL) )
            {
                result.HasChildren = true;
            }
        }
    }