Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
e6020725
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e6020725
编写于
3月 14, 2012
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactoring CallResolver to use context objects
上级
7ef65c00
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
325 addition
and
237 deletion
+325
-237
compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
...rc/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
+1
-1
compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java
...tend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java
+6
-5
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java
...brains/jet/lang/resolve/calls/BasicResolutionContext.java
+38
-0
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
...rc/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
+223
-225
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java
...g/jetbrains/jet/lang/resolve/calls/ResolutionContext.java
+46
-0
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.java
.../lang/resolve/calls/ValueArgumentsToParametersMapper.java
+3
-3
compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java
...s/jet/lang/types/expressions/ExpressionTypingContext.java
+8
-3
未找到文件。
compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
浏览文件 @
e6020725
...
...
@@ -91,7 +91,7 @@ public class AnnotationResolver {
private
OverloadResolutionResults
<
FunctionDescriptor
>
resolveType
(
@NotNull
JetScope
scope
,
@NotNull
JetAnnotationEntry
entryElement
,
@NotNull
AnnotationDescriptor
descriptor
,
BindingTrace
trace
)
{
OverloadResolutionResults
<
FunctionDescriptor
>
results
=
callResolver
.
resolveCall
(
trace
,
scope
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
entryElement
),
NO_EXPECTED_TYPE
,
DataFlowInfo
.
EMPTY
);
OverloadResolutionResults
<
FunctionDescriptor
>
results
=
callResolver
.
resolve
Function
Call
(
trace
,
scope
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
entryElement
),
NO_EXPECTED_TYPE
,
DataFlowInfo
.
EMPTY
);
JetType
annotationType
=
results
.
getResultingDescriptor
().
getReturnType
();
if
(
results
.
isSuccess
())
{
descriptor
.
setAnnotationType
(
annotationType
);
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java
浏览文件 @
e6020725
...
...
@@ -23,6 +23,7 @@ import com.intellij.util.containers.Queue;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.descriptors.*
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext
;
import
org.jetbrains.jet.lang.resolve.calls.CallMaker
;
import
org.jetbrains.jet.lang.resolve.calls.CallResolver
;
import
org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults
;
...
...
@@ -167,7 +168,7 @@ public class BodyResolver {
assert
descriptor
.
getKind
()
==
ClassKind
.
TRAIT
;
return
;
}
OverloadResolutionResults
<
FunctionDescriptor
>
results
=
callResolver
.
resolveCall
(
OverloadResolutionResults
<
FunctionDescriptor
>
results
=
callResolver
.
resolve
Function
Call
(
context
.
getTrace
(),
scopeForConstructor
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
call
),
NO_EXPECTED_TYPE
,
DataFlowInfo
.
EMPTY
);
if
(
results
.
isSuccess
())
{
...
...
@@ -345,7 +346,7 @@ public class BodyResolver {
public
void
visitDelegationToSuperCallSpecifier
(
JetDelegatorToSuperCall
call
)
{
JetTypeReference
typeReference
=
call
.
getTypeReference
();
if
(
typeReference
!=
null
)
{
callResolver
.
resolveCall
(
context
.
getTrace
(),
scopeForSupertypeInitializers
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
call
),
NO_EXPECTED_TYPE
,
dataFlowInfo
);
callResolver
.
resolve
Function
Call
(
context
.
getTrace
(),
scopeForSupertypeInitializers
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
call
),
NO_EXPECTED_TYPE
,
dataFlowInfo
);
}
}
...
...
@@ -355,9 +356,9 @@ public class BodyResolver {
// TODO : check: if a this() call is present, no other initializers are allowed
ClassDescriptor
classDescriptor
=
descriptor
.
getContainingDeclaration
();
callResolver
.
resolveCall
(
context
.
getTrace
(),
scopeForSupertypeInitializers
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
call
),
NO_EXPECTED_TYPE
,
dataFlowInfo
);
callResolver
.
resolve
Function
Call
(
context
.
getTrace
(),
scopeForSupertypeInitializers
,
CallMaker
.
makeCall
(
ReceiverDescriptor
.
NO_RECEIVER
,
null
,
call
),
NO_EXPECTED_TYPE
,
dataFlowInfo
);
// call.getThisReference(),
// classDescriptor,
// classDescriptor.getDefaultType(),
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/BasicResolutionContext.java
0 → 100644
浏览文件 @
e6020725
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.jet.lang.resolve.calls
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.Call
;
import
org.jetbrains.jet.lang.resolve.BindingTrace
;
import
org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
;
import
org.jetbrains.jet.lang.resolve.scopes.JetScope
;
import
org.jetbrains.jet.lang.types.JetType
;
/**
* @author abreslav
*/
public
class
BasicResolutionContext
extends
ResolutionContext
{
@NotNull
public
static
BasicResolutionContext
create
(
@NotNull
BindingTrace
trace
,
@NotNull
JetScope
scope
,
@NotNull
Call
call
,
@NotNull
JetType
expectedType
,
@NotNull
DataFlowInfo
dataFlowInfo
)
{
return
new
BasicResolutionContext
(
trace
,
scope
,
call
,
expectedType
,
dataFlowInfo
);
}
private
BasicResolutionContext
(
BindingTrace
trace
,
JetScope
scope
,
Call
call
,
JetType
expectedType
,
DataFlowInfo
dataFlowInfo
)
{
super
(
trace
,
scope
,
call
,
expectedType
,
dataFlowInfo
);
}
}
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
浏览文件 @
e6020725
此差异已折叠。
点击以展开。
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionContext.java
0 → 100644
浏览文件 @
e6020725
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.jet.lang.resolve.calls
;
import
org.jetbrains.jet.lang.psi.Call
;
import
org.jetbrains.jet.lang.resolve.BindingTrace
;
import
org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
;
import
org.jetbrains.jet.lang.resolve.scopes.JetScope
;
import
org.jetbrains.jet.lang.types.JetType
;
/**
* @author abreslav
*/
public
abstract
class
ResolutionContext
{
/*package*/
final
BindingTrace
trace
;
/*package*/
final
JetScope
scope
;
/*package*/
final
Call
call
;
/*package*/
final
JetType
expectedType
;
/*package*/
final
DataFlowInfo
dataFlowInfo
;
protected
ResolutionContext
(
BindingTrace
trace
,
JetScope
scope
,
Call
call
,
JetType
expectedType
,
DataFlowInfo
dataFlowInfo
)
{
this
.
trace
=
trace
;
this
.
scope
=
scope
;
this
.
call
=
call
;
this
.
expectedType
=
expectedType
;
this
.
dataFlowInfo
=
dataFlowInfo
;
}
public
BasicResolutionContext
toBasic
()
{
return
BasicResolutionContext
.
create
(
trace
,
scope
,
call
,
expectedType
,
dataFlowInfo
);
}
}
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.java
浏览文件 @
e6020725
...
...
@@ -38,7 +38,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
*/
/*package*/
class
ValueArgumentsToParametersMapper
{
public
static
<
D
extends
CallableDescriptor
>
boolean
mapValueArgumentsToParameters
(
@NotNull
ResolutionTask
<
D
>
task
,
@NotNull
Call
call
,
@NotNull
TracingStrategy
tracing
,
@NotNull
ResolvedCallImpl
<
D
>
candidateCall
)
{
...
...
@@ -58,7 +58,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
parameterByName
.
put
(
valueParameter
.
getName
(),
valueParameter
);
}
List
<?
extends
ValueArgument
>
valueArguments
=
task
.
getCall
()
.
getValueArguments
();
List
<?
extends
ValueArgument
>
valueArguments
=
call
.
getValueArguments
();
boolean
error
=
false
;
boolean
someNamed
=
false
;
...
...
@@ -117,7 +117,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
}
}
List
<
JetExpression
>
functionLiteralArguments
=
task
.
getCall
()
.
getFunctionLiteralArguments
();
List
<
JetExpression
>
functionLiteralArguments
=
call
.
getFunctionLiteralArguments
();
if
(!
functionLiteralArguments
.
isEmpty
())
{
JetExpression
possiblyLabeledFunctionLiteral
=
functionLiteralArguments
.
get
(
0
);
...
...
compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingContext.java
浏览文件 @
e6020725
...
...
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import
org.jetbrains.jet.lang.descriptors.VariableDescriptor
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.resolve.BindingTrace
;
import
org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext
;
import
org.jetbrains.jet.lang.resolve.calls.CallMaker
;
import
org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults
;
import
org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
;
...
...
@@ -153,9 +154,13 @@ public class ExpressionTypingContext {
////////// Call resolution utilities
private
BasicResolutionContext
makeResolutionContext
(
@NotNull
Call
call
)
{
return
BasicResolutionContext
.
create
(
trace
,
scope
,
call
,
expectedType
,
dataFlowInfo
);
}
@NotNull
public
OverloadResolutionResults
<
FunctionDescriptor
>
resolveCallWithGivenName
(
@NotNull
Call
call
,
@NotNull
JetReferenceExpression
functionReference
,
@NotNull
String
name
)
{
return
expressionTypingServices
.
getCallResolver
().
resolveCallWithGivenName
(
trace
,
scope
,
call
,
functionReference
,
name
,
expectedType
,
dataFlowInfo
);
return
expressionTypingServices
.
getCallResolver
().
resolveCallWithGivenName
(
makeResolutionContext
(
call
),
functionReference
,
name
);
}
@NotNull
...
...
@@ -166,14 +171,14 @@ public class ExpressionTypingContext {
@Nullable
public
FunctionDescriptor
resolveCall
(
@NotNull
ReceiverDescriptor
receiver
,
@Nullable
ASTNode
callOperationNode
,
@NotNull
JetCallExpression
callExpression
)
{
OverloadResolutionResults
<
FunctionDescriptor
>
results
=
expressionTypingServices
.
getCallResolver
().
resolveCall
(
trace
,
scope
,
CallMaker
.
makeCall
(
receiver
,
callOperationNode
,
callExpression
),
expectedType
,
dataFlowInfo
);
OverloadResolutionResults
<
FunctionDescriptor
>
results
=
expressionTypingServices
.
getCallResolver
().
resolve
Function
Call
(
trace
,
scope
,
CallMaker
.
makeCall
(
receiver
,
callOperationNode
,
callExpression
),
expectedType
,
dataFlowInfo
);
return
results
.
singleResult
()
?
results
.
getResultingDescriptor
()
:
null
;
}
@NotNull
public
OverloadResolutionResults
<
VariableDescriptor
>
resolveSimpleProperty
(
@NotNull
ReceiverDescriptor
receiver
,
@Nullable
ASTNode
callOperationNode
,
@NotNull
JetSimpleNameExpression
nameExpression
)
{
Call
call
=
CallMaker
.
makePropertyCall
(
receiver
,
callOperationNode
,
nameExpression
);
return
expressionTypingServices
.
getCallResolver
().
resolveSimpleProperty
(
trace
,
scope
,
call
,
expectedType
,
dataFlowInfo
);
return
expressionTypingServices
.
getCallResolver
().
resolveSimpleProperty
(
makeResolutionContext
(
call
)
);
}
@NotNull
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录