Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bebb3ac8
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,发现更多精彩内容 >>
提交
bebb3ac8
编写于
6月 09, 2017
作者:
H
Heejae Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some clean up
上级
b338bae8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
26 deletion
+48
-26
src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs
...pilers/CSharp/Portable/Compilation/MemberSemanticModel.cs
+1
-1
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
...arp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
+0
-1
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
...lers/CSharp/Portable/Operations/CSharpOperationFactory.cs
+1
-1
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs
...arp/Portable/Operations/CSharpOperationFactory_Methods.cs
+7
-7
src/Compilers/Core/Portable/Operations/OperationCache.cs
src/Compilers/Core/Portable/Operations/OperationCache.cs
+26
-3
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb
...lBasic/Portable/Operations/VisualBasicOperationFactory.vb
+1
-1
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb
...ortable/Operations/VisualBasicOperationFactory_Methods.vb
+12
-12
未找到文件。
src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs
浏览文件 @
bebb3ac8
...
...
@@ -1546,7 +1546,7 @@ private static Binder GetQueryEnclosingBinder(int position, CSharpSyntaxNode sta
}
while
(
node
!=
null
);
done
:
done
:
return
GetEnclosingBinderInternalWithinRoot
(
AdjustStartingNodeAccordingToNewRoot
(
startingNode
,
queryClause
.
Syntax
),
position
,
queryClause
.
Binder
,
queryClause
.
Syntax
);
}
...
...
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
浏览文件 @
bebb3ac8
...
...
@@ -622,7 +622,6 @@ private static ImmutableArray<RefKind> GetRefKindsOrNull(ArrayBuilder<RefKind> r
// then we need to create a temporary as usual. The step that
// produces the parameter array will need to deal with that
// eventuality.
if
(
IsBeginningOfParamArray
(
p
,
a
,
expanded
,
arguments
.
Length
,
rewrittenArguments
,
argsToParamsOpt
,
out
int
paramArrayArgumentCount
)
&&
a
+
paramArrayArgumentCount
==
rewrittenArguments
.
Length
)
{
...
...
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs
浏览文件 @
bebb3ac8
...
...
@@ -19,7 +19,7 @@ public IOperation Create(BoundNode boundNode)
return
null
;
}
return
_cache
.
Get
Value
(
boundNode
,
n
=>
CreateInternal
(
n
));
return
_cache
.
Get
OrCreateOperationFrom
(
boundNode
,
n
=>
CreateInternal
(
n
));
}
private
IOperation
CreateInternal
(
BoundNode
boundNode
)
...
...
src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs
浏览文件 @
bebb3ac8
...
...
@@ -31,7 +31,7 @@ private ImmutableArray<IOperation> ToStatements(BoundStatement statement)
private
ILiteralExpression
CreateIncrementOneLiteralExpression
(
BoundIncrementOperator
boundIncrementOperator
)
{
return
_cache
.
Get
Value
(
boundIncrementOperator
,
nameof
(
CreateIncrementOneLiteralExpression
),
(
increment
)
=>
return
_cache
.
Get
OrCreateOperationFrom
(
boundIncrementOperator
,
nameof
(
CreateIncrementOneLiteralExpression
),
(
increment
)
=>
{
string
text
=
increment
.
Syntax
.
ToString
();
bool
isInvalid
=
false
;
...
...
@@ -77,7 +77,7 @@ internal static IArgument CreateArgumentOperation(ArgumentKind kind, IParameterS
return
ImmutableArray
<
IArgument
>.
Empty
;
}
return
_cache
.
Get
Value
(
return
_cache
.
Get
OrCreateOperationsFrom
(
boundNode
,
nameof
(
DeriveArguments
),
(
n
)
=>
{
...
...
@@ -167,7 +167,7 @@ private static ITypeSymbol GetArrayCreationElementType(BoundArrayCreation creati
private
ImmutableArray
<
IOperation
>
GetBlockStatement
(
BoundBlock
block
)
{
// This is to filter out operations of kind None.
return
_cache
.
Get
Value
(
block
,
nameof
(
GetBlockStatement
),
return
_cache
.
Get
OrCreateOperationsFrom
(
block
,
nameof
(
GetBlockStatement
),
blockStatement
=>
{
return
blockStatement
.
Statements
.
Select
(
s
=>
Create
(
s
)).
Where
(
s
=>
s
.
Kind
!=
OperationKind
.
None
).
ToImmutableArray
();
...
...
@@ -176,7 +176,7 @@ private ImmutableArray<IOperation> GetBlockStatement(BoundBlock block)
private
ImmutableArray
<
ISwitchCase
>
GetSwitchStatementCases
(
BoundSwitchStatement
statement
)
{
return
_cache
.
Get
Value
(
statement
,
nameof
(
GetSwitchStatementCases
),
return
_cache
.
Get
OrCreateOperationsFrom
(
statement
,
nameof
(
GetSwitchStatementCases
),
switchStatement
=>
{
return
switchStatement
.
SwitchSections
.
SelectAsArray
(
switchSection
=>
...
...
@@ -228,14 +228,14 @@ private static BinaryOperationKind GetLabelEqualityKind(BoundSwitchLabel label)
private
ImmutableArray
<
IVariableDeclaration
>
GetVariableDeclarationStatementVariables
(
BoundLocalDeclaration
decl
)
{
return
_cache
.
Get
Value
(
decl
,
nameof
(
GetVariableDeclarationStatementVariables
),
return
_cache
.
Get
OrCreateOperationsFrom
(
decl
,
nameof
(
GetVariableDeclarationStatementVariables
),
declaration
=>
ImmutableArray
.
Create
(
OperationFactory
.
CreateVariableDeclaration
(
declaration
.
LocalSymbol
,
Create
(
declaration
.
InitializerOpt
),
declaration
.
Syntax
)));
}
private
ImmutableArray
<
IVariableDeclaration
>
GetVariableMultipleDeclarationStatementVariables
(
BoundMultipleLocalDeclarations
decl
)
{
return
_cache
.
Get
Value
(
decl
,
nameof
(
GetVariableMultipleDeclarationStatementVariables
),
return
_cache
.
Get
OrCreateOperationsFrom
(
decl
,
nameof
(
GetVariableMultipleDeclarationStatementVariables
),
multipleDeclarations
=>
multipleDeclarations
.
LocalDeclarations
.
SelectAsArray
(
declaration
=>
OperationFactory
.
CreateVariableDeclaration
(
declaration
.
LocalSymbol
,
Create
(
declaration
.
InitializerOpt
),
declaration
.
Syntax
)));
...
...
@@ -243,7 +243,7 @@ private ImmutableArray<IVariableDeclaration> GetVariableMultipleDeclarationState
private
ImmutableArray
<
IInterpolatedStringContent
>
GetInterpolatedStringExpressionParts
(
BoundInterpolatedString
boundInterpolatedString
)
{
return
_cache
.
Get
Value
(
boundInterpolatedString
,
nameof
(
GetInterpolatedStringExpressionParts
),
return
_cache
.
Get
OrCreateOperationsFrom
(
boundInterpolatedString
,
nameof
(
GetInterpolatedStringExpressionParts
),
interpolatedString
=>
interpolatedString
.
Parts
.
SelectAsArray
(
interpolatedStringContent
=>
CreateBoundInterpolatedStringContentOperation
(
interpolatedStringContent
)));
}
...
...
src/Compilers/Core/Portable/Operations/OperationCache.cs
浏览文件 @
bebb3ac8
...
...
@@ -2,21 +2,44 @@
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Immutable
;
namespace
Microsoft.CodeAnalysis
{
/// <summary>
/// Cache data associated with TBoundNode
/// </summary>
internal
class
OperationCache
<
TBoundNode
>
{
// REVIEW: not sure about perf of value tuple used as key on a dictionary. I might need custom type
// if it is somehow not good on perf
//
// cache's key is (TBoundNode, string) since some of TBoundNode has multiple data associated with it.
private
readonly
ConcurrentDictionary
<(
TBoundNode
key
,
string
kind
),
object
>
_cache
=
new
ConcurrentDictionary
<(
TBoundNode
key
,
string
kind
),
object
>(
concurrencyLevel
:
2
,
capacity
:
10
);
public
TRet
Get
Value
<
TNode
,
TRet
>(
TNode
key
,
Func
<
TNode
,
TRet
>
creator
)
public
TRet
Get
OrCreateOperationFrom
<
TNode
,
TRet
>(
TNode
key
,
Func
<
TNode
,
TRet
>
creator
)
where
TNode
:
TBoundNode
where
TRet
:
IOperation
{
return
Get
Value
(
key
,
"Root"
,
creator
);
return
Get
OrCreateOperationFrom
(
key
,
"Root"
,
creator
);
}
public
TRet
GetValue
<
TNode
,
TRet
>(
TNode
key
,
string
kind
,
Func
<
TNode
,
TRet
>
creator
)
public
TRet
GetOrCreateOperationFrom
<
TNode
,
TRet
>(
TNode
key
,
string
kind
,
Func
<
TNode
,
TRet
>
creator
)
where
TNode
:
TBoundNode
where
TRet
:
IOperation
{
return
GetValue
(
key
,
kind
,
creator
);
}
public
ImmutableArray
<
TRet
>
GetOrCreateOperationsFrom
<
TNode
,
TRet
>(
TNode
key
,
string
kind
,
Func
<
TNode
,
ImmutableArray
<
TRet
>>
creator
)
where
TNode
:
TBoundNode
where
TRet
:
IOperation
{
return
GetValue
(
key
,
kind
,
creator
);
}
private
TRet
GetValue
<
TNode
,
TRet
>(
TNode
key
,
string
kind
,
Func
<
TNode
,
TRet
>
creator
)
where
TNode
:
TBoundNode
{
return
(
TRet
)
_cache
.
GetOrAdd
((
key
,
kind
),
kv
=>
creator
((
TNode
)
kv
.
key
));
...
...
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb
浏览文件 @
bebb3ac8
...
...
@@ -13,7 +13,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return
Nothing
End
If
Return
_cache
.
Get
Value
(
boundNode
,
Function
(
n
)
CreateInternal
(
n
))
Return
_cache
.
Get
OrCreateOperationFrom
(
boundNode
,
Function
(
n
)
CreateInternal
(
n
))
End
Function
Private
Function
CreateInternal
(
boundNode
As
BoundNode
)
As
IOperation
...
...
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb
浏览文件 @
bebb3ac8
...
...
@@ -72,7 +72,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Private
Function
DeriveArgument
(
index
As
Integer
,
argument
As
BoundExpression
,
parameters
As
ImmutableArray
(
Of
VisualBasic
.
Symbols
.
ParameterSymbol
))
As
IArgument
Select
Case
argument
.
Kind
Case
BoundKind
.
ByRefArgumentWithCopyBack
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationFrom
(
argument
,
NameOf
(
DeriveArgument
),
Function
(
argumentValue
)
Dim
byRefArgument
=
DirectCast
(
argumentValue
,
BoundByRefArgumentWithCopyBack
)
...
...
@@ -90,7 +90,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
constantValue
:
=
Nothing
)
End
Function
)
Case
Else
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationFrom
(
argument
,
NameOf
(
DeriveArgument
),
Function
(
argumentValue
)
Dim
lastParameterIndex
=
parameters
.
Length
-
1
...
...
@@ -167,7 +167,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetSwitchStatementCases
(
statement
As
BoundSelectStatement
)
As
ImmutableArray
(
Of
ISwitchCase
)
Dim
cases
=
_cache
.
Get
Value
(
statement
,
NameOf
(
GetSwitchStatementCases
),
Dim
cases
=
_cache
.
Get
OrCreateOperationsFrom
(
statement
,
NameOf
(
GetSwitchStatementCases
),
Function
(
boundSelect
)
Return
boundSelect
.
CaseBlocks
.
SelectAsArray
(
Function
(
boundCaseBlock
)
...
...
@@ -249,7 +249,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetForLoopStatementBefore
(
boundForToStatement
As
BoundForToStatement
)
As
ImmutableArray
(
Of
IOperation
)
Dim
result
=
_cache
.
Get
Value
(
Dim
result
=
_cache
.
Get
OrCreateOperationsFrom
(
boundForToStatement
,
NameOf
(
GetForLoopStatementBefore
),
Function
(
boundFor
)
Dim
statements
As
ArrayBuilder
(
Of
IOperation
)
=
ArrayBuilder
(
Of
IOperation
).
GetInstance
()
...
...
@@ -295,7 +295,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetForLoopStatementAtLoopBottom
(
boundForToStatement
As
BoundForToStatement
)
As
ImmutableArray
(
Of
IOperation
)
Dim
result
=
_cache
.
Get
Value
(
Dim
result
=
_cache
.
Get
OrCreateOperationsFrom
(
boundForToStatement
,
NameOf
(
GetForLoopStatementAtLoopBottom
),
Function
(
boundFor
)
Dim
statements
As
ArrayBuilder
(
Of
IOperation
)
=
ArrayBuilder
(
Of
IOperation
).
GetInstance
()
...
...
@@ -334,7 +334,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetForWhileUntilLoopStatmentCondition
(
boundForToStatement
As
BoundForToStatement
)
As
IOperation
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationFrom
(
boundForToStatement
,
NameOf
(
GetForWhileUntilLoopStatmentCondition
),
Function
(
boundFor
)
As
IOperation
Dim
operationValue
=
Create
(
boundFor
.
LimitValue
)
...
...
@@ -397,7 +397,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
Private
Function
GetBlockStatementStatements
(
block
As
BoundBlock
)
As
ImmutableArray
(
Of
IOperation
)
' This is to filter out operations of kind None.
Dim
statements
=
_cache
.
Get
Value
(
Dim
statements
=
_cache
.
Get
OrCreateOperationsFrom
(
block
,
NameOf
(
GetBlockStatementStatements
),
Function
(
boundBlock
)
Return
boundBlock
.
Statements
.
Select
(
Function
(
n
)
Create
(
n
)).
Where
(
Function
(
s
)
s
.
Kind
<>
OperationKind
.
None
).
ToImmutableArray
()
...
...
@@ -406,7 +406,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetVariableDeclarationStatementVariables
(
statement
As
BoundDimStatement
)
As
ImmutableArray
(
Of
IVariableDeclaration
)
Dim
variables
=
_cache
.
Get
Value
(
Dim
variables
=
_cache
.
Get
OrCreateOperationsFrom
(
statement
,
NameOf
(
GetVariableDeclarationStatementVariables
),
Function
(
dimStatement
)
Dim
builder
=
ArrayBuilder
(
Of
IVariableDeclaration
).
GetInstance
()
...
...
@@ -427,7 +427,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetUsingStatementDeclaration
(
boundUsingStatement
As
BoundUsingStatement
)
As
IVariableDeclarationStatement
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationFrom
(
boundUsingStatement
,
NameOf
(
GetUsingStatementDeclaration
),
Function
(
boundUsing
)
Dim
declaration
=
If
(
boundUsing
.
ResourceList
.
IsDefaultOrEmpty
,
...
...
@@ -443,7 +443,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetAddHandlerStatementExpression
(
handlerStatement
As
BoundAddHandlerStatement
)
As
IOperation
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationFrom
(
handlerStatement
,
NameOf
(
GetAddHandlerStatementExpression
),
Function
(
statement
)
Dim
eventAccess
As
BoundEventAccess
=
TryCast
(
statement
.
EventAccess
,
BoundEventAccess
)
...
...
@@ -456,7 +456,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetRemoveStatementExpression
(
handlerStatement
As
BoundRemoveHandlerStatement
)
As
IOperation
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationFrom
(
handlerStatement
,
NameOf
(
GetRemoveStatementExpression
),
Function
(
statement
)
Dim
eventAccess
As
BoundEventAccess
=
TryCast
(
statement
.
EventAccess
,
BoundEventAccess
)
...
...
@@ -470,7 +470,7 @@ Namespace Microsoft.CodeAnalysis.Semantics
End
Function
Private
Function
GetInterpolatedStringExpressionParts
(
boundInterpolatedString
As
BoundInterpolatedStringExpression
)
As
ImmutableArray
(
Of
IInterpolatedStringContent
)
Return
_cache
.
Get
Value
(
Return
_cache
.
Get
OrCreateOperationsFrom
(
boundInterpolatedString
,
NameOf
(
GetInterpolatedStringExpressionParts
),
Function
(
interpolatedString
)
Return
interpolatedString
.
Contents
.
SelectAsArray
(
Function
(
interpolatedStringContent
)
CreateBoundInterpolatedStringContentOperation
(
interpolatedStringContent
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录