⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variableclassification.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 2 页
字号:
        If m_InstanceExpression IsNot Nothing Then            Dim exp As Type = m_InstanceExpression.ExpressionType            If exp.IsValueType AndAlso exp.IsByRef = False Then                exp = exp.MakeByRefType            End If            result = m_InstanceExpression.GenerateCode(Info.Clone(True, False, exp)) AndAlso result        End If        If FieldInfo IsNot Nothing Then            If Info.IsRHS Then                If Info.DesiredType.IsByRef Then                    Emitter.EmitLoadVariableLocation(Info, FieldInfo)                Else                    Emitter.EmitLoadVariable(Info, FieldInfo)                End If            Else                Dim rInfo As EmitInfo = Info.Clone(True, False, FieldInfo.FieldType)                Helper.Assert(Info.RHSExpression IsNot Nothing)                Helper.Assert(Info.RHSExpression.Classification.IsValueClassification)                result = Info.RHSExpression.Classification.GenerateCode(rInfo) AndAlso result                Emitter.EmitConversion(Info.RHSExpression.ExpressionType, FieldInfo.FieldType, Info.Clone(Info.RHSExpression.ExpressionType))                Emitter.EmitStoreField(Info, FieldInfo)            End If        ElseIf LocalBuilder IsNot Nothing Then            If Info.IsRHS Then                Emitter.EmitLoadVariable(Info, LocalBuilder)            Else                Dim rInfo As EmitInfo = Info.Clone(True, False, LocalBuilder.LocalType)                Helper.Assert(Info.RHSExpression IsNot Nothing, "RHSExpression Is Nothing!")                Helper.Assert(Info.RHSExpression.Classification.IsValueClassification OrElse Info.RHSExpression.Classification.CanBeValueClassification)                result = Info.RHSExpression.Classification.GenerateCode(rInfo) AndAlso result                Emitter.EmitConversion(info.RHSExpression.ExpressionType, LocalBuilder.LocalType, Info)                Emitter.EmitStoreVariable(Info, LocalBuilder)            End If        ElseIf ParameterInfo IsNot Nothing Then            Dim isByRef As Boolean = ParameterInfo.ParameterType.IsByRef            Dim isByRefStructure As Boolean = isByRef AndAlso ParameterInfo.ParameterType.GetElementType.IsValueType            Helper.Assert(m_InstanceExpression Is Nothing)            If Info.IsRHS Then                If isByRef Then                    Helper.NotImplemented()                Else                    Emitter.EmitLoadVariable(Info, ParameterInfo)                End If            Else                Dim rInfo As EmitInfo                If isByRefStructure Then                    Emitter.EmitLoadVariable(Info.Clone(ParameterInfo.ParameterType), ParameterInfo)                    rInfo = Info.Clone(True, False, ParameterInfo.ParameterType.GetElementType)                ElseIf isByRef Then                    Emitter.EmitLoadVariableLocation(Info, ParameterInfo)                    rInfo = Info.Clone(True, False, ParameterInfo.ParameterType.GetElementType)                Else                    rInfo = Info.Clone(True, False, ParameterInfo.ParameterType)                End If                Helper.Assert(Info.RHSExpression IsNot Nothing, "RHSExpression Is Nothing!")                Helper.Assert(Info.RHSExpression.Classification.IsValueClassification)                result = Info.RHSExpression.Classification.GenerateCode(rInfo) AndAlso result                If isByRef = False Then                    Emitter.EmitConversion(Info.RHSExpression.ExpressionType, ParameterInfo.ParameterType, Info)                End If                If isByRefStructure Then                    Emitter.EmitStoreObject(Info, ParameterInfo.ParameterType.GetElementType)                Else                    Emitter.EmitStoreVariable(Info, ParameterInfo)                End If            End If        ElseIf Me.m_Variable IsNot Nothing Then                If Info.IsRHS Then                    Helper.NotImplemented()                Else                    Dim rInfo As EmitInfo = Info.Clone(True, False, m_Variable.VariableType)                    Helper.Assert(Info.RHSExpression IsNot Nothing)                    Helper.Assert(Info.RHSExpression.Classification.IsValueClassification)                    result = Info.RHSExpression.Classification.GenerateCode(rInfo) AndAlso result                    Emitter.EmitConversion(Info.RHSExpression.ExpressionType, m_Variable.VariableType, Info)                    Emitter.EmitStoreVariable(Info, m_Variable.LocalBuilder)                    Helper.NotImplemented()                End If        ElseIf m_ArrayVariable IsNot Nothing Then                If Info.IsRHS Then                    result = Me.GenerateCodeAsValue(Info) AndAlso result                Else                    result = Helper.EmitStoreArrayElement(Info, m_ArrayVariable, m_Arguments) AndAlso result                End If        ElseIf m_Method IsNot Nothing Then                If Info.IsRHS Then                    Emitter.EmitLoadVariable(Info, m_Method.DefaultReturnVariable)                Else                    Helper.Assert(Info.RHSExpression IsNot Nothing, "RHSExpression Is Nothing!")                    Helper.Assert(Info.RHSExpression.Classification.IsValueClassification)                    result = Info.RHSExpression.Classification.GenerateCode(Info.Clone(True, False, m_Method.DefaultReturnVariable.LocalType)) AndAlso result                    Emitter.EmitStoreVariable(Info, m_Method.DefaultReturnVariable)                End If        Else                Throw New InternalException(Me)        End If        Return result    End Function    ReadOnly Property InstanceExpression() As Expression        Get            Return m_InstanceExpression        End Get    End Property    <Obsolete()> Overloads Function ReclassifyToValue() As ValueClassification        Return New ValueClassification(Me)    End Function    ''' <summary>    ''' A variable declaration which refers to the implicitly declared local variable    ''' for methods with return values (functions and get properties)    ''' </summary>    ''' <param name="Parent"></param>    ''' <param name="method"></param>    ''' <remarks></remarks>    Sub New(ByVal Parent As ParsedObject, ByVal method As IMethod)        MyBase.New(Classifications.Variable, Parent)        Helper.Assert(TypeOf method Is FunctionDeclaration OrElse TypeOf method Is PropertyDeclaration)        m_Method = method    End Sub    Sub New(ByVal Parent As ParsedObject, ByVal parameter As Parameter)        MyBase.New(Classifications.Variable, Parent)        m_Parameter = parameter        m_ParameterInfo = New ParameterDescriptor(m_Parameter)    End Sub    Sub New(ByVal Parent As ParsedObject, ByVal variable As VariableDeclaration, Optional ByVal InstanceExpression As Expression = Nothing)        MyBase.New(Classifications.Variable, Parent)        m_Variable = variable        m_InstanceExpression = InstanceExpression    End Sub    Sub New(ByVal Parent As ParsedObject, ByVal Expression As Expression, ByVal ExpressionType As Type)        MyBase.new(Classifications.Variable, Parent)        m_Expression = Expression        m_ExpressionType = ExpressionType    End Sub    Sub New(ByVal Parent As ParsedObject, ByVal variable As FieldInfo, ByVal InstanceExpression As Expression)        MyBase.New(Classifications.Variable, Parent)        m_FieldInfo = variable        m_InstanceExpression = InstanceExpression        Helper.Assert(m_InstanceExpression Is Nothing OrElse m_InstanceExpression.IsResolved)        Helper.Assert((m_FieldInfo.IsStatic AndAlso m_InstanceExpression Is Nothing) OrElse (m_FieldInfo.IsStatic = False AndAlso m_InstanceExpression IsNot Nothing))    End Sub    ''' <summary>    ''' Creates a variable classification for an array access.    ''' </summary>    ''' <param name="Parent"></param>    ''' <param name="Arguments"></param>    ''' <remarks></remarks>    Sub New(ByVal Parent As ParsedObject, ByVal ArrayVariableExpression As Expression, ByVal Arguments As ArgumentList)        MyBase.New(Classifications.Variable, Parent)        m_ArrayVariable = ArrayVariableExpression        m_Arguments = Arguments        Helper.Assert(ArrayVariable IsNot Nothing)        Helper.Assert(Arguments IsNot Nothing)    End Sub    ReadOnly Property Type() As Type 'Descriptor        Get            Dim result As Type            If m_ExpressionType IsNot Nothing Then                result = m_ExpressionType            ElseIf m_Method IsNot Nothing Then                result = m_Method.Signature.ReturnType            ElseIf m_Variable IsNot Nothing Then                result = m_Variable.VariableType            ElseIf m_FieldInfo IsNot Nothing Then                If m_FieldInfo.DeclaringType.IsEnum Then                    result = m_FieldInfo.DeclaringType                Else                    result = m_FieldInfo.FieldType                End If            ElseIf m_Parameter IsNot Nothing Then                result = m_Parameter.ParameterType            ElseIf m_ArrayVariable IsNot Nothing Then                result = m_ArrayVariable.ExpressionType.GetElementType            Else                Throw New InternalException(Me)            End If            Helper.Assert(result IsNot Nothing)            Return result        End Get    End PropertyEnd Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -