Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
cce4ee97
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cce4ee97
编写于
5月 16, 2018
作者:
N
Neal Gafter
提交者:
GitHub
5月 16, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26846 from gafter/master-25692
Produce much better code for CInt(Fix(number))
上级
3e1fdacc
faabbdf9
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
1390 addition
and
301 deletion
+1390
-301
src/Compilers/Core/Portable/WellKnownMember.cs
src/Compilers/Core/Portable/WellKnownMember.cs
+3
-0
src/Compilers/Core/Portable/WellKnownMembers.cs
src/Compilers/Core/Portable/WellKnownMembers.cs
+303
-287
src/Compilers/Core/Portable/WellKnownTypes.cs
src/Compilers/Core/Portable/WellKnownTypes.cs
+3
-0
src/Compilers/VisualBasic/Portable/CodeGen/EmitConversion.vb
src/Compilers/VisualBasic/Portable/CodeGen/EmitConversion.vb
+0
-7
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.vb
...rtable/Lowering/LocalRewriter/LocalRewriter_Conversion.vb
+26
-5
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenExpression.vb
...pilers/VisualBasic/Test/Emit/CodeGen/CodeGenExpression.vb
+1050
-0
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/WellKnownTypeValidationTests.vb
.../Test/Symbol/SymbolsTests/WellKnownTypeValidationTests.vb
+5
-2
未找到文件。
src/Compilers/Core/Portable/WellKnownMember.cs
浏览文件 @
cce4ee97
...
...
@@ -433,6 +433,9 @@ internal enum WellKnownMember
System_Runtime_CompilerServices_IsUnmanagedAttribute__ctor
,
Microsoft_VisualBasic_Conversion__FixSingle
,
Microsoft_VisualBasic_Conversion__FixDouble
,
Count
}
}
src/Compilers/Core/Portable/WellKnownMembers.cs
浏览文件 @
cce4ee97
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
src/Compilers/Core/Portable/WellKnownTypes.cs
浏览文件 @
cce4ee97
...
...
@@ -274,6 +274,8 @@ internal enum WellKnownType
System_Runtime_InteropServices_UnmanagedType
,
System_Runtime_CompilerServices_IsUnmanagedAttribute
,
Microsoft_VisualBasic_Conversion
,
NextAvailable
,
}
...
...
@@ -541,6 +543,7 @@ internal static class WellKnownTypes
"System.ReadOnlySpan`1"
,
"System.Runtime.InteropServices.UnmanagedType"
,
"System.Runtime.CompilerServices.IsUnmanagedAttribute"
,
"Microsoft.VisualBasic.Conversion"
,
};
private
readonly
static
Dictionary
<
string
,
WellKnownType
>
s_nameToTypeIdMap
=
new
Dictionary
<
string
,
WellKnownType
>((
int
)
Count
);
...
...
src/Compilers/VisualBasic/Portable/CodeGen/EmitConversion.vb
浏览文件 @
cce4ee97
...
...
@@ -123,13 +123,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGen
Private
Sub
EmitConvertSimpleNumeric
(
conversion
As
BoundConversion
,
typeFrom
As
PrimitiveTypeCode
,
typeTo
As
PrimitiveTypeCode
,
checked
As
Boolean
)
Debug
.
Assert
(
typeFrom
.
IsIntegral
()
OrElse
typeFrom
.
IsFloatingPoint
()
OrElse
typeFrom
=
PrimitiveTypeCode
.
Char
)
Debug
.
Assert
(
typeTo
.
IsIntegral
()
OrElse
typeTo
.
IsFloatingPoint
())
Debug
.
Assert
(
Not
(
typeFrom
.
IsFloatingPoint
()
AndAlso
typeTo
.
IsIntegral
()
AndAlso
Not
(
conversion
.
Operand
.
Kind
=
BoundKind
.
Call
AndAlso
DirectCast
(
conversion
.
Operand
,
BoundCall
).
Method
.
Equals
(
Me
.
_module
.
SourceModule
.
ContainingSourceAssembly
.
DeclaringCompilation
.
GetWellKnownTypeMember
(
WellKnownMember
.
System_Math__RoundDouble
)))),
"About to ignore VB rules for rounding float numbers."
)
_builder
.
EmitNumericConversion
(
typeFrom
,
typeTo
,
checked
)
End
Sub
...
...
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.vb
浏览文件 @
cce4ee97
...
...
@@ -1295,19 +1295,24 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private
Function
RewriteFloatingToIntegralConversion
(
node
As
BoundConversion
,
typeFrom
As
TypeSymbol
,
underlyingTypeTo
As
TypeSymbol
)
As
BoundExpression
Debug
.
Assert
(
typeFrom
.
IsFloatingType
()
AndAlso
underlyingTypeTo
.
IsIntegralType
())
Dim
result
As
BoundExpression
=
node
Dim
operand
=
node
.
Operand
Dim
mathRound
As
MethodSymbol
' Call Math.Round method to enforce VB style rounding.
' CInt(Fix(number)) and the like can be simplified to just truncate the number to the integral type
If
operand
.
Kind
=
BoundKind
.
Call
Then
Dim
callOperand
=
DirectCast
(
operand
,
BoundCall
)
If
IsFixInvocation
(
callOperand
)
Then
Return
New
BoundConversion
(
node
.
Syntax
,
callOperand
.
Arguments
(
0
),
node
.
ConversionKind
,
node
.
Checked
,
node
.
ExplicitCastInCode
,
node
.
Type
)
End
If
End
If
' Call Math.Round method to enforce VB style rounding.
Const
memberId
As
WellKnownMember
=
WellKnownMember
.
System_Math__RoundDouble
mathRound
=
DirectCast
(
Compilation
.
GetWellKnownTypeMember
(
memberId
),
MethodSymbol
)
Dim
mathRound
As
MethodSymbol
=
DirectCast
(
Compilation
.
GetWellKnownTypeMember
(
memberId
),
MethodSymbol
)
If
Not
ReportMissingOrBadRuntimeHelper
(
node
,
memberId
,
mathRound
)
Then
' If we got here and passed badness check, it should be safe to assume that we have
' a "good" symbol for Double type
Dim
operand
=
node
.
Operand
#If DEBUG Then
Dim
useSiteDiagnostics
As
HashSet
(
Of
DiagnosticInfo
)
=
Nothing
#End If
...
...
@@ -1334,6 +1339,22 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return
result
End
Function
Private
Function
IsFixInvocation
(
node
As
BoundCall
)
As
Boolean
' Quick test to eliminate most calls to something other that Conversion.Fix
If
Not
"Fix"
.
Equals
(
node
.
Method
.
Name
)
Then
Return
False
End
If
Select
Case
node
.
Type
.
SpecialType
Case
SpecialType
.
System_Single
Return
node
.
Method
=
Me
.
Compilation
.
GetWellKnownTypeMember
(
WellKnownMember
.
Microsoft_VisualBasic_Conversion__FixSingle
)
Case
SpecialType
.
System_Double
Return
node
.
Method
=
Me
.
Compilation
.
GetWellKnownTypeMember
(
WellKnownMember
.
Microsoft_VisualBasic_Conversion__FixDouble
)
Case
Else
Return
False
End
Select
End
Function
#End Region
#Region "DirectCast"
...
...
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenExpression.vb
0 → 100644
浏览文件 @
cce4ee97
此差异已折叠。
点击以展开。
src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/WellKnownTypeValidationTests.vb
浏览文件 @
cce4ee97
...
...
@@ -537,7 +537,8 @@ End Namespace
WellKnownType
.
Microsoft_VisualBasic_ApplicationServices_ApplicationBase
,
WellKnownType
.
Microsoft_VisualBasic_ApplicationServices_WindowsFormsApplicationBase
,
WellKnownType
.
Microsoft_VisualBasic_Information
,
WellKnownType
.
Microsoft_VisualBasic_Interaction
WellKnownType
.
Microsoft_VisualBasic_Interaction
,
WellKnownType
.
Microsoft_VisualBasic_Conversion
' Not embedded, so not available.
Continue
For
Case
WellKnownType
.
System_FormattableString
,
...
...
@@ -674,7 +675,9 @@ End Namespace
WellKnownMember
.
Microsoft_VisualBasic_Information__SystemTypeName
,
WellKnownMember
.
Microsoft_VisualBasic_Information__TypeName
,
WellKnownMember
.
Microsoft_VisualBasic_Information__VbTypeName
,
WellKnownMember
.
Microsoft_VisualBasic_Interaction__CallByName
WellKnownMember
.
Microsoft_VisualBasic_Interaction__CallByName
,
WellKnownMember
.
Microsoft_VisualBasic_Conversion__FixSingle
,
WellKnownMember
.
Microsoft_VisualBasic_Conversion__FixDouble
' The type is not embedded, so the member is not available.
Continue
For
Case
WellKnownMember
.
System_Array__Empty
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录