Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
eb7db21c
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,发现更多精彩内容 >>
提交
eb7db21c
编写于
3月 31, 2011
作者:
A
Andrey Breslav
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some CF generated for closures
上级
01105c8c
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
641 addition
and
266 deletion
+641
-266
idea/src/org/jetbrains/jet/JetNodeTypes.java
idea/src/org/jetbrains/jet/JetNodeTypes.java
+2
-0
idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
+1
-1
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java
...src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java
+2
-2
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java
.../jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java
+121
-0
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphBuilder.java
...rg/jetbrains/jet/lang/cfg/JetControlFlowGraphBuilder.java
+3
-3
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java
...c/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java
+64
-18
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/FunctionLiteralValueInstruction.java
.../lang/cfg/pseudocode/FunctionLiteralValueInstruction.java
+34
-0
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.java
...jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.java
+17
-5
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.java
...etbrains/jet/lang/cfg/pseudocode/InstructionWithNext.java
+5
-4
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java
...g/cfg/pseudocode/JetControlFlowInstructionsGenerator.java
+160
-106
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/JetElementInstruction.java
...brains/jet/lang/cfg/pseudocode/JetElementInstruction.java
+20
-0
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java
...src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java
+59
-18
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/ReadValueInstruction.java
...tbrains/jet/lang/cfg/pseudocode/ReadValueInstruction.java
+4
-4
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/UnsupportedElementInstruction.java
...et/lang/cfg/pseudocode/UnsupportedElementInstruction.java
+24
-0
idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
.../org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
+67
-58
idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java
idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java
+7
-7
idea/src/org/jetbrains/jet/lang/psi/JetContainerNode.java
idea/src/org/jetbrains/jet/lang/psi/JetContainerNode.java
+7
-0
idea/src/org/jetbrains/jet/lang/psi/JetContinueExpression.java
...src/org/jetbrains/jet/lang/psi/JetContinueExpression.java
+0
-8
idea/src/org/jetbrains/jet/lang/psi/JetLabelQualifiedExpression.java
...g/jetbrains/jet/lang/psi/JetLabelQualifiedExpression.java
+4
-2
idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java
...c/org/jetbrains/jet/lang/resolve/BindingTraceContext.java
+7
-1
idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java
...g/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java
+1
-1
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
+1
-1
idea/src/org/jetbrains/jet/lang/types/BindingTrace.java
idea/src/org/jetbrains/jet/lang/types/BindingTrace.java
+4
-0
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
+4
-4
idea/src/org/jetbrains/jet/lexer/_JetLexer.java
idea/src/org/jetbrains/jet/lexer/_JetLexer.java
+2
-2
idea/testData/psi/Expressions_ERR.txt
idea/testData/psi/Expressions_ERR.txt
+5
-5
idea/testData/psi/When_ERR.txt
idea/testData/psi/When_ERR.txt
+16
-16
未找到文件。
idea/src/org/jetbrains/jet/JetNodeTypes.java
浏览文件 @
eb7db21c
...
...
@@ -94,6 +94,8 @@ public interface JetNodeTypes {
JetNodeType
OPERATION_REFERENCE
=
new
JetNodeType
(
"OPERATION_REFERENCE"
,
JetSimpleNameExpression
.
class
);
JetNodeType
LABEL_REFERENCE
=
new
JetNodeType
(
"LABEL_REFERENCE"
,
JetSimpleNameExpression
.
class
);
JetNodeType
LABEL_QUALIFIER
=
new
JetNodeType
(
"LABEL_QUALIFIER"
,
JetContainerNode
.
class
);
JetNodeType
THIS_EXPRESSION
=
new
JetNodeType
(
"THIS_EXPRESSION"
,
JetThisExpression
.
class
);
JetNodeType
BINARY_EXPRESSION
=
new
JetNodeType
(
"BINARY_EXPRESSION"
,
JetBinaryExpression
.
class
);
JetNodeType
BINARY_WITH_TYPE
=
new
JetNodeType
(
"BINARY_WITH_TYPE"
,
JetBinaryExpressionWithTypeRHS
.
class
);
...
...
idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
浏览文件 @
eb7db21c
...
...
@@ -196,7 +196,7 @@ public class ExpressionCodegen extends JetVisitor {
public
void
visitConstantExpression
(
JetConstantExpression
expression
)
{
myStack
.
push
(
StackValue
.
constant
(
expression
.
getValue
()));
/*
Object value = e
xpression
.getValue();
Object value = e
lement
.getValue();
v.aconst(value);
if (value instanceof Integer) {
...
...
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilder.java
浏览文件 @
eb7db21c
...
...
@@ -40,8 +40,8 @@ public interface JetControlFlowBuilder {
void
exitTryFinally
();
// Subroutines
void
enterSubroutine
(
@NotNull
JetElement
subroutine
);
void
exitSubroutine
(
@NotNull
JetElement
subroutine
);
void
enterSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
isFunctionLiteral
);
void
exitSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
functionLiteral
);
@Nullable
JetElement
getCurrentSubroutine
();
...
...
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowBuilderAdapter.java
0 → 100644
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.psi.JetBlockExpression
;
import
org.jetbrains.jet.lang.psi.JetElement
;
import
org.jetbrains.jet.lang.psi.JetExpression
;
/**
* @author abreslav
*/
public
class
JetControlFlowBuilderAdapter
implements
JetControlFlowBuilder
{
protected
JetControlFlowBuilder
builder
;
public
JetControlFlowBuilderAdapter
(
JetControlFlowBuilder
builder
)
{
this
.
builder
=
builder
;
}
@Override
public
void
readNode
(
@NotNull
JetExpression
expression
)
{
builder
.
readNode
(
expression
);
}
@Override
@NotNull
public
Label
createUnboundLabel
()
{
return
builder
.
createUnboundLabel
();
}
@Override
public
void
bindLabel
(
@NotNull
Label
label
)
{
builder
.
bindLabel
(
label
);
}
@Override
public
void
jump
(
@NotNull
Label
label
)
{
builder
.
jump
(
label
);
}
@Override
public
void
jumpOnFalse
(
@NotNull
Label
label
)
{
builder
.
jumpOnFalse
(
label
);
}
@Override
public
void
jumpOnTrue
(
@NotNull
Label
label
)
{
builder
.
jumpOnTrue
(
label
);
}
@Override
public
void
nondeterministicJump
(
Label
label
)
{
builder
.
nondeterministicJump
(
label
);
}
@Override
public
Label
getEntryPoint
(
@NotNull
JetElement
labelElement
)
{
return
builder
.
getEntryPoint
(
labelElement
);
}
@Override
public
Label
getExitPoint
(
@NotNull
JetElement
labelElement
)
{
return
builder
.
getExitPoint
(
labelElement
);
}
@Override
public
Label
enterLoop
(
@NotNull
JetExpression
expression
,
Label
loopExitPoint
)
{
return
builder
.
enterLoop
(
expression
,
loopExitPoint
);
}
@Override
public
void
exitLoop
(
@NotNull
JetExpression
expression
)
{
builder
.
exitLoop
(
expression
);
}
@Override
@Nullable
public
JetElement
getCurrentLoop
()
{
return
builder
.
getCurrentLoop
();
}
@Override
public
void
enterTryFinally
(
@NotNull
JetBlockExpression
expression
)
{
builder
.
enterTryFinally
(
expression
);
}
@Override
public
void
exitTryFinally
()
{
builder
.
exitTryFinally
();
}
@Override
public
void
enterSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
isFunctionLiteral
)
{
builder
.
enterSubroutine
(
subroutine
,
isFunctionLiteral
);
}
@Override
public
void
exitSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
functionLiteral
)
{
builder
.
exitSubroutine
(
subroutine
,
functionLiteral
);
}
@Override
@Nullable
public
JetElement
getCurrentSubroutine
()
{
return
builder
.
getCurrentSubroutine
();
}
@Override
public
void
returnValue
(
@NotNull
JetElement
subroutine
)
{
builder
.
returnValue
(
subroutine
);
}
@Override
public
void
returnNoValue
(
@NotNull
JetElement
subroutine
)
{
builder
.
returnNoValue
(
subroutine
);
}
@Override
public
void
unsupported
(
JetElement
element
)
{
builder
.
unsupported
(
element
);
}
}
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphBuilder.java
浏览文件 @
eb7db21c
...
...
@@ -155,8 +155,8 @@ package org.jetbrains.jet.lang.cfg;
// }
//
// @Override
// public void readNode(JetExpression e
xpression
) {
// createNode(e
xpression
);
// public void readNode(JetExpression e
lement
) {
// createNode(e
lement
);
// }
//
// @Override
...
...
@@ -236,7 +236,7 @@ package org.jetbrains.jet.lang.cfg;
// }
//
// @Override
// public void enterTryFinally(JetBlockExpression e
xpression
) {
// public void enterTryFinally(JetBlockExpression e
lement
) {
// throw new UnsupportedOperationException(); // TODO
// }
//
...
...
idea/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg
;
import
com.intellij.lang.ASTNode
;
import
com.intellij.psi.tree.IElementType
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.JetSemanticServices
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.types.BindingTrace
;
import
org.jetbrains.jet.lexer.JetTokens
;
import
java.util.*
;
...
...
@@ -18,10 +19,12 @@ public class JetControlFlowProcessor {
private
final
JetSemanticServices
semanticServices
;
private
final
JetControlFlowBuilder
builder
;
private
final
BindingTrace
trace
;
public
JetControlFlowProcessor
(
JetSemanticServices
semanticServices
,
JetControlFlowBuilder
builder
)
{
public
JetControlFlowProcessor
(
JetSemanticServices
semanticServices
,
BindingTrace
trace
,
JetControlFlowBuilder
builder
)
{
this
.
semanticServices
=
semanticServices
;
this
.
builder
=
builder
;
this
.
trace
=
trace
;
}
public
void
generate
(
@NotNull
JetElement
subroutineElement
,
@NotNull
JetExpression
body
)
{
...
...
@@ -29,11 +32,16 @@ public class JetControlFlowProcessor {
}
public
void
generateSubroutineControlFlow
(
@NotNull
JetElement
subroutineElement
,
@NotNull
List
<?
extends
JetElement
>
body
,
boolean
preferBlocks
)
{
builder
.
enterSubroutine
(
subroutineElement
);
if
(
subroutineElement
instanceof
JetNamedDeclaration
)
{
JetNamedDeclaration
namedDeclaration
=
(
JetNamedDeclaration
)
subroutineElement
;
enterLabeledElement
(
namedDeclaration
.
getName
(),
namedDeclaration
);
}
boolean
functionLiteral
=
subroutineElement
instanceof
JetFunctionLiteralExpression
;
builder
.
enterSubroutine
(
subroutineElement
,
functionLiteral
);
for
(
JetElement
statement
:
body
)
{
statement
.
accept
(
new
CFPVisitor
(
preferBlocks
));
}
builder
.
exitSubroutine
(
subroutineElement
);
builder
.
exitSubroutine
(
subroutineElement
,
functionLiteral
);
}
private
void
enterLabeledElement
(
@NotNull
String
labelName
,
@NotNull
JetElement
labeledElement
)
{
...
...
@@ -46,16 +54,36 @@ public class JetControlFlowProcessor {
}
private
void
exitElement
(
JetElement
element
)
{
// for (Iterator<Map.Entry<String, JetElement>> iterator = labeledElements.entrySet().iterator(); iterator.hasNext(); ) {
// Map.Entry<String, JetElement> entry = iterator.next();
// if (entry.getValue() == element) {
// iterator.remove();
// }
// }
// TODO : really suboptimal
for
(
Iterator
<
Map
.
Entry
<
String
,
Stack
<
JetElement
>>>
mapIter
=
labeledElements
.
entrySet
().
iterator
();
mapIter
.
hasNext
();
)
{
Map
.
Entry
<
String
,
Stack
<
JetElement
>>
entry
=
mapIter
.
next
();
Stack
<
JetElement
>
stack
=
entry
.
getValue
();
for
(
Iterator
<
JetElement
>
stackIter
=
stack
.
iterator
();
stackIter
.
hasNext
();
)
{
JetElement
recorded
=
stackIter
.
next
();
if
(
recorded
==
element
)
{
stackIter
.
remove
();
}
}
if
(
stack
.
isEmpty
())
{
mapIter
.
remove
();
}
}
}
private
JetElement
resolveLabel
(
@NotNull
String
labelName
,
@NotNull
ASTNode
labelNode
)
{
throw
new
UnsupportedOperationException
();
// TODO
@Nullable
private
JetElement
resolveLabel
(
@NotNull
String
labelName
,
@NotNull
JetSimpleNameExpression
labelExpression
)
{
Stack
<
JetElement
>
stack
=
labeledElements
.
get
(
labelName
);
if
(
stack
==
null
||
stack
.
isEmpty
())
{
semanticServices
.
getErrorHandler
().
unresolvedReference
(
labelExpression
);
return
null
;
}
else
if
(
stack
.
size
()
>
1
)
{
semanticServices
.
getErrorHandler
().
genericWarning
(
labelExpression
.
getNode
(),
"There is more than one label with such a name in this scope"
);
}
JetElement
result
=
stack
.
peek
();
trace
.
recordLabelResolution
(
labelExpression
,
result
);
return
result
;
}
private
class
CFPVisitor
extends
JetVisitor
{
...
...
@@ -74,6 +102,7 @@ public class JetControlFlowProcessor {
visitor
=
new
CFPVisitor
(
preferBlock
);
}
element
.
accept
(
visitor
);
exitElement
(
element
);
}
@Override
...
...
@@ -88,8 +117,14 @@ public class JetControlFlowProcessor {
@Override
public
void
visitLabelQualifiedExpression
(
JetLabelQualifiedExpression
expression
)
{
enterLabeledElement
(
expression
.
getLabelName
(),
expression
.
getLabeledExpression
());
value
(
expression
.
getLabeledExpression
(),
false
);
String
labelName
=
expression
.
getLabelName
();
JetExpression
labeledExpression
=
expression
.
getLabeledExpression
();
visitLabeledExpression
(
labelName
,
labeledExpression
);
}
private
void
visitLabeledExpression
(
@NotNull
String
labelName
,
@NotNull
JetExpression
labeledExpression
)
{
enterLabeledElement
(
labelName
,
labeledExpression
);
value
(
labeledExpression
,
false
);
}
@Override
...
...
@@ -121,6 +156,17 @@ public class JetControlFlowProcessor {
}
}
@Override
public
void
visitUnaryExpression
(
JetUnaryExpression
expression
)
{
IElementType
operationType
=
expression
.
getOperationSign
().
getReferencedNameElementType
();
if
(
JetTokens
.
LABELS
.
contains
(
operationType
))
{
visitLabeledExpression
(
expression
.
getOperationSign
().
getReferencedName
().
substring
(
1
),
expression
.
getBaseExpression
());
}
else
{
visitElement
(
expression
);
}
}
@Override
public
void
visitIfExpression
(
JetIfExpression
expression
)
{
value
(
expression
.
getCondition
(),
false
);
...
...
@@ -135,7 +181,7 @@ public class JetControlFlowProcessor {
value
(
elseBranch
,
true
);
}
builder
.
bindLabel
(
resultLabel
);
// builder.readNode(e
xpression
);
// builder.readNode(e
lement
);
}
@Override
...
...
@@ -210,7 +256,7 @@ public class JetControlFlowProcessor {
public
void
visitBreakExpression
(
JetBreakExpression
expression
)
{
JetSimpleNameExpression
labelElement
=
expression
.
getTargetLabel
();
Label
exitPoint
=
(
labelElement
!=
null
)
?
builder
.
getExitPoint
(
labelElement
)
?
builder
.
getExitPoint
(
resolveLabel
(
expression
.
getLabelName
(),
expression
.
getTargetLabel
())
)
:
builder
.
getExitPoint
(
builder
.
getCurrentLoop
());
builder
.
jump
(
exitPoint
);
}
...
...
@@ -219,7 +265,7 @@ public class JetControlFlowProcessor {
public
void
visitContinueExpression
(
JetContinueExpression
expression
)
{
JetSimpleNameExpression
labelElement
=
expression
.
getTargetLabel
();
if
(
labelElement
!=
null
)
{
builder
.
jump
(
builder
.
getEntryPoint
(
labelElement
));
builder
.
jump
(
builder
.
getEntryPoint
(
resolveLabel
(
expression
.
getLabelName
(),
expression
.
getTargetLabel
())
));
}
else
{
builder
.
jump
(
builder
.
getEntryPoint
(
builder
.
getCurrentLoop
()));
...
...
@@ -234,7 +280,7 @@ public class JetControlFlowProcessor {
}
JetSimpleNameExpression
labelElement
=
expression
.
getTargetLabel
();
JetElement
subroutine
=
(
labelElement
!=
null
)
?
resolveLabel
(
expression
.
getLabelName
(),
expression
.
getTargetLabel
()
.
getNode
()
)
?
resolveLabel
(
expression
.
getLabelName
(),
expression
.
getTargetLabel
())
:
builder
.
getCurrentSubroutine
();
if
(
returnedExpression
==
null
)
{
builder
.
returnNoValue
(
subroutine
);
...
...
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/FunctionLiteralValueInstruction.java
0 → 100644
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg.pseudocode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.JetElement
;
/**
* @author abreslav
*/
public
class
FunctionLiteralValueInstruction
extends
InstructionWithNext
{
private
Pseudocode
body
;
public
FunctionLiteralValueInstruction
(
@NotNull
JetElement
element
)
{
super
(
element
);
}
public
Pseudocode
getBody
()
{
return
body
;
}
public
void
setBody
(
Pseudocode
body
)
{
this
.
body
=
body
;
}
@Override
public
void
accept
(
InstructionVisitor
visitor
)
{
visitor
.
visitFunctionLiteralValue
(
this
);
}
@Override
public
String
toString
()
{
return
"rf("
+
element
.
getText
()
+
")"
;
}
}
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionVisitor.java
浏览文件 @
eb7db21c
...
...
@@ -4,8 +4,12 @@ package org.jetbrains.jet.lang.cfg.pseudocode;
* @author abreslav
*/
public
class
InstructionVisitor
{
public
void
visitRead
(
ValueInstruction
instruction
)
{
visitInstruction
(
instruction
);
public
void
visitReadValue
(
ReadValueInstruction
instruction
)
{
visitInstructionWithNext
(
instruction
);
}
public
void
visitFunctionLiteralValue
(
FunctionLiteralValueInstruction
instruction
)
{
visitInstructionWithNext
(
instruction
);
}
public
void
visitUnconditionalJump
(
UnconditionalJumpInstruction
instruction
)
{
...
...
@@ -24,6 +28,14 @@ public class InstructionVisitor {
visitJump
(
instruction
);
}
public
void
visitNondeterministicJump
(
NondeterministicJumpInstruction
instruction
)
{
visitJump
(
instruction
);
}
public
void
visitUnsupportedElementInstruction
(
UnsupportedElementInstruction
instruction
)
{
visitInstructionWithNext
(
instruction
);
}
public
void
visitSubroutineExit
(
SubroutineExitInstruction
instruction
)
{
visitInstruction
(
instruction
);
}
...
...
@@ -32,10 +44,10 @@ public class InstructionVisitor {
visitInstruction
(
instruction
);
}
public
void
visitInstruction
(
Instruction
instruction
)
{
public
void
visitInstructionWithNext
(
InstructionWithNext
instruction
)
{
visitInstruction
(
instruction
);
}
public
void
visitNondeterministicJump
(
NondeterministicJumpInstruction
instruction
)
{
visitJump
(
instruction
);
public
void
visitInstruction
(
Instruction
instruction
)
{
}
}
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/InstructionWithNext.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg.pseudocode
;
import
org.jetbrains.jet.lang.psi.JetExpression
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.JetElement
;
/**
* @author abreslav
*/
public
abstract
class
InstructionWithNext
extends
Expression
Instruction
{
public
abstract
class
InstructionWithNext
extends
JetElement
Instruction
{
private
Instruction
next
;
p
ublic
InstructionWithNext
(
JetExpression
expression
)
{
super
(
e
xpression
);
p
rotected
InstructionWithNext
(
@NotNull
JetElement
element
)
{
super
(
e
lement
);
}
public
Instruction
getNext
()
{
...
...
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/JetControlFlowInstructionsGenerator.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg.pseudocode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.cfg.JetControlFlowBuilder
;
import
org.jetbrains.jet.lang.cfg.JetControlFlowBuilderAdapter
;
import
org.jetbrains.jet.lang.cfg.Label
;
import
org.jetbrains.jet.lang.psi.JetBlockExpression
;
import
org.jetbrains.jet.lang.psi.JetElement
;
...
...
@@ -14,7 +16,55 @@ import java.util.Stack;
/**
* @author abreslav
*/
public
class
JetControlFlowInstructionsGenerator
implements
JetControlFlowBuilder
{
public
class
JetControlFlowInstructionsGenerator
extends
JetControlFlowBuilderAdapter
{
private
int
labelCount
=
0
;
private
final
Stack
<
JetControlFlowInstructionsGeneratorWorker
>
builders
=
new
Stack
<
JetControlFlowInstructionsGeneratorWorker
>();
public
JetControlFlowInstructionsGenerator
()
{
super
(
null
);
pushBuilder
();
}
private
void
pushBuilder
()
{
Pseudocode
parentPseudocode
=
builder
==
null
?
new
Pseudocode
(
null
)
:
builders
.
peek
().
getPseudocode
();
JetControlFlowInstructionsGeneratorWorker
worker
=
new
JetControlFlowInstructionsGeneratorWorker
(
parentPseudocode
);
builders
.
push
(
worker
);
builder
=
worker
;
}
private
JetControlFlowInstructionsGeneratorWorker
popBuilder
()
{
JetControlFlowInstructionsGeneratorWorker
worker
=
builders
.
pop
();
builder
=
builders
.
peek
();
return
worker
;
}
@Override
public
void
enterSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
isFunctionLiteral
)
{
if
(
isFunctionLiteral
)
{
pushBuilder
();
builder
.
enterSubroutine
(
subroutine
,
false
);
}
else
{
super
.
enterSubroutine
(
subroutine
,
isFunctionLiteral
);
}
}
@Override
public
void
exitSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
functionLiteral
)
{
super
.
exitSubroutine
(
subroutine
,
functionLiteral
);
if
(
functionLiteral
)
{
JetControlFlowInstructionsGeneratorWorker
worker
=
popBuilder
();
JetControlFlowInstructionsGeneratorWorker
builder
=
builders
.
peek
();
FunctionLiteralValueInstruction
instruction
=
new
FunctionLiteralValueInstruction
(
subroutine
);
builder
.
add
(
instruction
);
instruction
.
setBody
(
worker
.
getPseudocode
());
}
}
public
Pseudocode
getPseudocode
()
{
return
builders
.
peek
().
getPseudocode
();
}
private
static
class
BlockInfo
{
private
final
JetElement
element
;
...
...
@@ -40,137 +90,141 @@ public class JetControlFlowInstructionsGenerator implements JetControlFlowBuilde
}
}
private
final
Stack
<
BlockInfo
>
loopInfo
=
new
Stack
<
BlockInfo
>();
private
final
Stack
<
BlockInfo
>
subroutine
Info
=
new
Stack
<
BlockInfo
>();
private
final
Map
<
JetElement
,
BlockInfo
>
elementToBlockInfo
=
new
HashMap
<
JetElement
,
BlockInfo
>();
private
class
JetControlFlowInstructionsGeneratorWorker
implements
JetControlFlowBuilder
{
private
final
Stack
<
BlockInfo
>
loop
Info
=
new
Stack
<
BlockInfo
>();
private
final
Stack
<
BlockInfo
>
subroutineInfo
=
new
Stack
<
BlockInfo
>();
private
int
labelCount
=
0
;
private
final
Map
<
JetElement
,
BlockInfo
>
elementToBlockInfo
=
new
HashMap
<
JetElement
,
BlockInfo
>()
;
private
final
Pseudocode
pseudocode
=
new
Pseudocode
()
;
private
final
Pseudocode
pseudocode
;
public
Pseudocode
getPseudocode
(
)
{
return
pseudocode
;
}
private
JetControlFlowInstructionsGeneratorWorker
(
@Nullable
Pseudocode
parent
)
{
this
.
pseudocode
=
new
Pseudocode
(
parent
)
;
}
private
void
add
(
Instruction
instruction
)
{
pseudocode
.
getInstructions
().
add
(
instruction
)
;
}
public
Pseudocode
getPseudocode
(
)
{
return
pseudocode
;
}
@NotNull
@Override
public
final
Label
createUnboundLabel
()
{
return
new
Label
(
"l"
+
labelCount
++);
}
private
void
add
(
Instruction
instruction
)
{
pseudocode
.
addInstruction
(
instruction
);
}
@Override
public
final
Label
enterLoop
(
@NotNull
JetExpression
expression
,
Label
loopExitPoint
)
{
Label
label
=
createUnboundLabel
();
bindLabel
(
label
);
BlockInfo
blockInfo
=
new
BlockInfo
(
expression
,
label
,
loopExitPoint
);
loopInfo
.
push
(
blockInfo
);
elementToBlockInfo
.
put
(
expression
,
blockInfo
);
return
label
;
}
@NotNull
@Override
public
final
Label
createUnboundLabel
()
{
return
new
Label
(
"l"
+
labelCount
++);
}
@Override
public
final
void
exitLoop
(
@NotNull
JetExpression
expression
)
{
BlockInfo
info
=
loopInfo
.
pop
();
elementToBlockInfo
.
remove
(
expression
);
bindLabel
(
info
.
getExitPoint
());
}
@Override
public
final
Label
enterLoop
(
@NotNull
JetExpression
expression
,
Label
loopExitPoint
)
{
Label
label
=
createUnboundLabel
();
bindLabel
(
label
);
BlockInfo
blockInfo
=
new
BlockInfo
(
expression
,
label
,
loopExitPoint
);
loopInfo
.
push
(
blockInfo
);
elementToBlockInfo
.
put
(
expression
,
blockInfo
);
return
label
;
}
@Override
public
JetElement
getCurrentLoop
()
{
return
loopInfo
.
empty
()
?
null
:
loopInfo
.
peek
().
getElement
();
}
@Override
public
final
void
exitLoop
(
@NotNull
JetExpression
expression
)
{
BlockInfo
info
=
loopInfo
.
pop
();
elementToBlockInfo
.
remove
(
expression
);
bindLabel
(
info
.
getExitPoint
());
}
@Override
public
void
enterSubroutine
(
@NotNull
JetElement
subroutine
)
{
Label
entryPoint
=
createUnboundLabel
();
BlockInfo
blockInfo
=
new
BlockInfo
(
subroutine
,
entryPoint
,
createUnboundLabel
());
subroutineInfo
.
push
(
blockInfo
);
elementToBlockInfo
.
put
(
subroutine
,
blockInfo
);
bindLabel
(
entryPoint
);
}
@Override
public
JetElement
getCurrentLoop
()
{
return
loopInfo
.
empty
()
?
null
:
loopInfo
.
peek
().
getElement
();
}
@Override
public
JetElement
getCurrentSubroutine
()
{
return
subroutineInfo
.
empty
()
?
null
:
subroutineInfo
.
peek
().
getElement
();
}
@Override
public
void
enterSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
isFunctionLiteral
)
{
Label
entryPoint
=
createUnboundLabel
();
BlockInfo
blockInfo
=
new
BlockInfo
(
subroutine
,
entryPoint
,
createUnboundLabel
());
subroutineInfo
.
push
(
blockInfo
);
elementToBlockInfo
.
put
(
subroutine
,
blockInfo
);
bindLabel
(
entryPoint
);
}
@Override
public
Label
getEntryPoint
(
@NotNull
JetElement
labelElement
)
{
return
elementToBlockInfo
.
get
(
labelElement
).
getEntryPoi
nt
();
}
@Override
public
JetElement
getCurrentSubroutine
(
)
{
return
subroutineInfo
.
empty
()
?
null
:
subroutineInfo
.
peek
().
getEleme
nt
();
}
@Override
public
Label
getExitPoint
(
@NotNull
JetElement
labelElement
)
{
return
elementToBlockInfo
.
get
(
labelElement
).
getExitPoint
();
}
@Override
public
Label
getEntryPoint
(
@NotNull
JetElement
labelElement
)
{
return
elementToBlockInfo
.
get
(
labelElement
).
getEntryPoint
();
}
@Override
public
Label
getExitPoint
(
@NotNull
JetElement
labelElement
)
{
return
elementToBlockInfo
.
get
(
labelElement
).
getExitPoint
();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public
void
exitSubroutine
(
@NotNull
JetElement
subroutine
)
{
bindLabel
(
getExitPoint
(
subroutine
));
add
(
new
SubroutineExitInstruction
(
subroutine
));
elementToBlockInfo
.
remove
(
subroutine
);
}
@Override
public
void
exitSubroutine
(
@NotNull
JetElement
subroutine
,
boolean
functionLiteral
)
{
bindLabel
(
getExitPoint
(
subroutine
));
add
(
new
SubroutineExitInstruction
(
subroutine
));
elementToBlockInfo
.
remove
(
subroutine
);
}
@Override
public
void
returnValue
(
@NotNull
JetElement
subroutine
)
{
add
(
new
ReturnValueInstruction
(
getExitPoint
(
subroutine
)));
}
@Override
public
void
returnValue
(
@NotNull
JetElement
subroutine
)
{
add
(
new
ReturnValueInstruction
(
getExitPoint
(
subroutine
)));
}
@Override
public
void
returnNoValue
(
@NotNull
JetElement
subroutine
)
{
add
(
new
ReturnNoValueInstruction
(
getExitPoint
(
subroutine
)));
}
@Override
public
void
returnNoValue
(
@NotNull
JetElement
subroutine
)
{
add
(
new
ReturnNoValueInstruction
(
getExitPoint
(
subroutine
)));
}
@Override
public
void
readNode
(
@NotNull
JetExpression
expression
)
{
add
(
new
ValueInstruction
(
expression
));
}
@Override
public
void
readNode
(
@NotNull
JetExpression
expression
)
{
add
(
new
Read
ValueInstruction
(
expression
));
}
@Override
public
void
jump
(
@NotNull
Label
label
)
{
add
(
new
UnconditionalJumpInstruction
(
label
));
}
@Override
public
void
jump
(
@NotNull
Label
label
)
{
add
(
new
UnconditionalJumpInstruction
(
label
));
}
@Override
public
void
jumpOnFalse
(
@NotNull
Label
label
)
{
add
(
new
ConditionalJumpInstruction
(
false
,
label
));
}
@Override
public
void
jumpOnFalse
(
@NotNull
Label
label
)
{
add
(
new
ConditionalJumpInstruction
(
false
,
label
));
}
@Override
public
void
jumpOnTrue
(
@NotNull
Label
label
)
{
add
(
new
ConditionalJumpInstruction
(
true
,
label
));
}
@Override
public
void
jumpOnTrue
(
@NotNull
Label
label
)
{
add
(
new
ConditionalJumpInstruction
(
true
,
label
));
}
@Override
public
void
bindLabel
(
@NotNull
Label
label
)
{
pseudocode
.
getLabels
().
put
(
label
,
pseudocode
.
getInstructions
().
size
()
);
}
@Override
public
void
bindLabel
(
@NotNull
Label
label
)
{
pseudocode
.
addLabel
(
label
);
}
@Override
public
void
nondeterministicJump
(
Label
label
)
{
add
(
new
NondeterministicJumpInstruction
(
label
));
}
@Override
public
void
nondeterministicJump
(
Label
label
)
{
add
(
new
NondeterministicJumpInstruction
(
label
));
}
@Override
public
void
enterTryFinally
(
@NotNull
JetBlockExpression
expression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
void
enterTryFinally
(
@NotNull
JetBlockExpression
expression
)
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
void
exitTryFinally
()
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
void
exitTryFinally
()
{
throw
new
UnsupportedOperationException
();
// TODO
}
@Override
public
void
unsupported
(
JetElement
element
)
{
throw
new
IllegalStateException
(
"Unsupported element: "
+
element
.
getText
()
+
" "
+
element
);
@Override
public
void
unsupported
(
JetElement
element
)
{
add
(
new
UnsupportedElementInstruction
(
element
));
}
}
}
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/
Expression
Instruction.java
→
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/
JetElement
Instruction.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg.pseudocode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.JetE
xpression
;
import
org.jetbrains.jet.lang.psi.JetE
lement
;
/**
* @author abreslav
*/
public
abstract
class
Expression
Instruction
extends
Instruction
{
protected
final
JetE
xpression
expression
;
public
abstract
class
JetElement
Instruction
extends
Instruction
{
protected
final
JetE
lement
element
;
public
ExpressionInstruction
(
@NotNull
JetExpression
expression
)
{
this
.
e
xpression
=
expression
;
public
JetElementInstruction
(
@NotNull
JetElement
element
)
{
this
.
e
lement
=
element
;
}
@NotNull
public
JetE
xpression
getExpression
()
{
return
e
xpression
;
public
JetE
lement
getElement
()
{
return
e
lement
;
}
}
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/Pseudocode.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg.pseudocode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lang.cfg.Label
;
import
java.io.PrintStream
;
...
...
@@ -13,12 +14,28 @@ public class Pseudocode {
private
final
List
<
Instruction
>
instructions
=
new
ArrayList
<
Instruction
>();
private
final
Map
<
Label
,
Integer
>
labels
=
new
LinkedHashMap
<
Label
,
Integer
>();
public
List
<
Instruction
>
getInstructions
()
{
return
instructions
;
@Nullable
private
final
Pseudocode
parent
;
public
Pseudocode
(
Pseudocode
parent
)
{
this
.
parent
=
parent
;
}
public
void
addInstruction
(
Instruction
instruction
)
{
instructions
.
add
(
instruction
);
}
public
void
addLabel
(
Label
label
)
{
labels
.
put
(
label
,
instructions
.
size
());
}
public
Map
<
Label
,
Integer
>
getLabels
()
{
return
labels
;
@Nullable
private
Integer
resolveLabel
(
Label
targetLabel
)
{
Integer
result
=
labels
.
get
(
targetLabel
);
if
(
result
==
null
&&
parent
!=
null
)
{
return
parent
.
resolveLabel
(
targetLabel
);
}
return
result
;
}
public
void
postProcess
()
{
...
...
@@ -27,7 +44,7 @@ public class Pseudocode {
final
int
currentPosition
=
i
;
instruction
.
accept
(
new
InstructionVisitor
()
{
@Override
public
void
visit
Read
(
ValueInstruction
instruction
)
{
public
void
visit
InstructionWithNext
(
InstructionWithNext
instruction
)
{
instruction
.
setNext
(
getNextPosition
(
currentPosition
));
}
...
...
@@ -57,6 +74,12 @@ public class Pseudocode {
visitJump
(
instruction
);
}
@Override
public
void
visitFunctionLiteralValue
(
FunctionLiteralValueInstruction
instruction
)
{
instruction
.
getBody
().
postProcess
();
super
.
visitFunctionLiteralValue
(
instruction
);
}
@Override
public
void
visitSubroutineExit
(
SubroutineExitInstruction
instruction
)
{
// Nothing
...
...
@@ -72,7 +95,7 @@ public class Pseudocode {
@NotNull
private
Instruction
getJumpTarget
(
@NotNull
Label
targetLabel
)
{
Integer
targetPosition
=
labels
.
get
(
targetLabel
);
Integer
targetPosition
=
resolveLabel
(
targetLabel
);
return
getTargetInstruction
(
targetPosition
);
}
...
...
@@ -87,7 +110,7 @@ public class Pseudocode {
}
Label
label
=
((
UnconditionalJumpInstruction
)
targetInstruction
).
getTargetLabel
();
targetPosition
=
labels
.
get
(
label
);
targetPosition
=
resolveLabel
(
label
);
}
}
...
...
@@ -111,15 +134,19 @@ public class Pseudocode {
}
public
void
dumpGraph
(
@NotNull
final
PrintStream
out
)
{
out
.
println
(
"digraph g {"
);
String
graphHeader
=
"digraph g"
;
dumpSubgraph
(
out
,
graphHeader
,
new
int
[
1
],
""
);
}
private
void
dumpSubgraph
(
final
PrintStream
out
,
String
graphHeader
,
final
int
[]
count
,
String
style
)
{
out
.
println
(
graphHeader
+
" {"
);
final
Map
<
Instruction
,
String
>
nodeToName
=
new
HashMap
<
Instruction
,
String
>();
int
count
=
0
;
for
(
Instruction
node
:
instructions
)
{
if
(
node
instanceof
UnconditionalJumpInstruction
)
{
continue
;
}
String
name
=
"n"
+
count
++;
String
name
=
"n"
+
count
[
0
]
++;
nodeToName
.
put
(
node
,
name
);
String
text
=
node
.
toString
();
int
newline
=
text
.
indexOf
(
"\n"
);
...
...
@@ -133,11 +160,25 @@ public class Pseudocode {
else
if
(
node
instanceof
NondeterministicJumpInstruction
)
{
shape
=
"Mdiamond"
;
}
else
if
(
node
instanceof
UnsupportedElementInstruction
)
{
shape
=
"box, fillcolor=red, style=filled"
;
}
else
if
(
node
instanceof
FunctionLiteralValueInstruction
)
{
shape
=
"Mcircle"
;
}
out
.
println
(
name
+
"[label=\""
+
text
+
"\", shape="
+
shape
+
"];"
);
}
for
(
final
Instruction
fromInst
:
instructions
)
{
fromInst
.
accept
(
new
InstructionVisitor
()
{
@Override
public
void
visitFunctionLiteralValue
(
FunctionLiteralValueInstruction
instruction
)
{
int
index
=
count
[
0
];
instruction
.
getBody
().
dumpSubgraph
(
out
,
"subgraph f"
+
index
,
count
,
"color=blue;\ntlabel = \"process #"
+
index
+
"\";"
);
printEdge
(
out
,
nodeToName
.
get
(
instruction
),
"n"
+
index
,
null
);
visitInstructionWithNext
(
instruction
);
}
@Override
public
void
visitUnconditionalJump
(
UnconditionalJumpInstruction
instruction
)
{
// Nothing
...
...
@@ -145,13 +186,13 @@ public class Pseudocode {
@Override
public
void
visitJump
(
AbstractJumpInstruction
instruction
)
{
write
Edge
(
out
,
nodeToName
.
get
(
instruction
),
nodeToName
.
get
(
instruction
.
getResolvedTarget
()),
null
);
print
Edge
(
out
,
nodeToName
.
get
(
instruction
),
nodeToName
.
get
(
instruction
.
getResolvedTarget
()),
null
);
}
@Override
public
void
visitNondeterministicJump
(
NondeterministicJumpInstruction
instruction
)
{
visitJump
(
instruction
);
write
Edge
(
out
,
nodeToName
.
get
(
instruction
),
nodeToName
.
get
(
instruction
.
getNext
()),
null
);
print
Edge
(
out
,
nodeToName
.
get
(
instruction
),
nodeToName
.
get
(
instruction
.
getNext
()),
null
);
}
@Override
...
...
@@ -167,13 +208,13 @@ public class Pseudocode {
@Override
public
void
visitConditionalJump
(
ConditionalJumpInstruction
instruction
)
{
String
from
=
nodeToName
.
get
(
instruction
);
write
Edge
(
out
,
from
,
nodeToName
.
get
(
instruction
.
getNextOnFalse
()),
"no"
);
write
Edge
(
out
,
from
,
nodeToName
.
get
(
instruction
.
getNextOnTrue
()),
"yes"
);
print
Edge
(
out
,
from
,
nodeToName
.
get
(
instruction
.
getNextOnFalse
()),
"no"
);
print
Edge
(
out
,
from
,
nodeToName
.
get
(
instruction
.
getNextOnTrue
()),
"yes"
);
}
@Override
public
void
visit
Read
(
ValueInstruction
instruction
)
{
write
Edge
(
out
,
nodeToName
.
get
(
instruction
),
nodeToName
.
get
(
instruction
.
getNext
()),
null
);
public
void
visit
InstructionWithNext
(
InstructionWithNext
instruction
)
{
print
Edge
(
out
,
nodeToName
.
get
(
instruction
),
nodeToName
.
get
(
instruction
.
getNext
()),
null
);
}
@Override
...
...
@@ -187,11 +228,11 @@ public class Pseudocode {
}
});
}
out
.
println
(
style
);
out
.
println
(
"}"
);
out
.
close
();
}
private
void
write
Edge
(
PrintStream
out
,
String
from
,
String
to
,
String
label
)
{
private
void
print
Edge
(
PrintStream
out
,
String
from
,
String
to
,
String
label
)
{
if
(
label
!=
null
)
{
label
=
"[label=\""
+
label
+
"\"]"
;
}
...
...
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/ValueInstruction.java
→
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/
Read
ValueInstruction.java
浏览文件 @
eb7db21c
...
...
@@ -6,19 +6,19 @@ import org.jetbrains.jet.lang.psi.JetExpression;
/**
* @author abreslav
*/
public
class
ValueInstruction
extends
InstructionWithNext
{
public
class
Read
ValueInstruction
extends
InstructionWithNext
{
public
ValueInstruction
(
@NotNull
JetExpression
expression
)
{
public
Read
ValueInstruction
(
@NotNull
JetExpression
expression
)
{
super
(
expression
);
}
@Override
public
void
accept
(
InstructionVisitor
visitor
)
{
visitor
.
visitRead
(
this
);
visitor
.
visitRead
Value
(
this
);
}
@Override
public
String
toString
()
{
return
"r("
+
e
xpression
.
getText
()
+
")"
;
return
"r("
+
e
lement
.
getText
()
+
")"
;
}
}
idea/src/org/jetbrains/jet/lang/cfg/pseudocode/UnsupportedElementInstruction.java
0 → 100644
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.cfg.pseudocode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.lang.psi.JetElement
;
/**
* @author abreslav
*/
public
class
UnsupportedElementInstruction
extends
InstructionWithNext
{
protected
UnsupportedElementInstruction
(
@NotNull
JetElement
element
)
{
super
(
element
);
}
@Override
public
void
accept
(
InstructionVisitor
visitor
)
{
visitor
.
visitUnsupportedElementInstruction
(
this
);
}
@Override
public
String
toString
()
{
return
"unsupported("
+
element
+
" : "
+
element
.
getText
()
+
")"
;
}
}
idea/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
浏览文件 @
eb7db21c
...
...
@@ -227,9 +227,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* e
xpression
* : attributes e
xpression
* : "(" e
xpression
")" // see tupleLiteral
* e
lement
* : attributes e
lement
* : "(" e
lement
")" // see tupleLiteral
* : literalConstant
* : functionLiteral
* : tupleLiteral
...
...
@@ -238,7 +238,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
* : expressionWithPrecedences
* : if
* : try
* : "typeof" "(" e
xpression
")"
* : "typeof" "(" e
lement
")"
* : "new" constructorInvocation
* : objectLiteral
* : declaration
...
...
@@ -249,14 +249,14 @@ public class JetExpressionParsing extends AbstractJetParsing {
*/
public
void
parseExpression
()
{
if
(!
atSet
(
EXPRESSION_FIRST
))
{
error
(
"Expecting an e
xpression
"
);
error
(
"Expecting an e
lement
"
);
return
;
}
parseBinaryExpression
(
Precedence
.
ASSIGNMENT
);
}
/*
* e
xpression (operation expression
)*
* e
lement (operation element
)*
*
* see the precedence table
*/
...
...
@@ -427,7 +427,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* e
xpression
(getEntryPoint? functionLiteral)?
* e
lement
(getEntryPoint? functionLiteral)?
*/
protected
boolean
parseCallWithClosure
()
{
boolean
success
=
false
;
...
...
@@ -447,9 +447,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* atomicExpression
* : tupleLiteral // or parenthesized e
xpression
* : tupleLiteral // or parenthesized e
lement
* : "this" getEntryPoint? ("<" type ">")?
* : "typeof" "(" e
xpression
")"
* : "typeof" "(" e
lement
")"
* : "new" constructorInvocation
* : objectLiteral
* : jump
...
...
@@ -535,8 +535,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
parseFunctionLiteral
();
}
else
if
(!
parseLiteralConstant
())
{
// TODO: better recovery if FIRST(e
xpression
) did not match
errorWithRecovery
(
"Expecting an e
xpression
"
,
EXPRESSION_FOLLOW
);
// TODO: better recovery if FIRST(e
lement
) did not match
errorWithRecovery
(
"Expecting an e
lement
"
,
EXPRESSION_FOLLOW
);
}
}
...
...
@@ -581,7 +581,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* when
* : "when" "(" (modifiers "val" SimpleName "=")? e
xpression
")" "{"
* : "when" "(" (modifiers "val" SimpleName "=")? e
lement
")" "{"
* whenEntry*
* "}"
* ;
...
...
@@ -622,8 +622,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* whenEntry
* // TODO : consider empty after =>
* : whenConditionIf{","} (when | "=>" e
xpression
SEMI)
* : "else" ("continue" | "=>" e
xpression
SEMI)
* : whenConditionIf{","} (when | "=>" e
lement
SEMI)
* : "else" ("continue" | "=>" e
lement
SEMI)
* ;
*/
private
void
parseWhenEntry
()
{
...
...
@@ -633,7 +633,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance
();
// ELSE_KEYWORD
if
(!
at
(
CONTINUE_KEYWORD
)
&&
!
at
(
DOUBLE_ARROW
))
{
errorUntil
(
"Expecting 'continue' or '=> e
xpression
'"
,
TokenSet
.
create
(
CONTINUE_KEYWORD
,
DOUBLE_ARROW
,
errorUntil
(
"Expecting 'continue' or '=> e
lement
'"
,
TokenSet
.
create
(
CONTINUE_KEYWORD
,
DOUBLE_ARROW
,
RBRACE
,
EOL_OR_SEMICOLON
));
}
...
...
@@ -641,14 +641,14 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance
();
// DOUBLE_ARROW
if
(
atSet
(
WHEN_CONDITION_RECOVERY_SET
))
{
error
(
"Expecting an e
xpression
"
);
error
(
"Expecting an e
lement
"
);
}
else
{
parseExpression
();
}
}
else
if
(
at
(
CONTINUE_KEYWORD
))
{
advance
();
// CONTINUE_KEYWORD
}
else
if
(!
atSet
(
WHEN_CONDITION_RECOVERY_SET
))
{
errorAndAdvance
(
"Expecting 'continue' or '=> e
xpression
'"
);
errorAndAdvance
(
"Expecting 'continue' or '=> e
lement
'"
);
}
}
else
{
parseWhenEntryNotElse
();
...
...
@@ -659,7 +659,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* : whenConditionIf{","} (when | "=>" e
xpression
SEMI)
* : whenConditionIf{","} (when | "=>" e
lement
SEMI)
*/
private
void
parseWhenEntryNotElse
()
{
while
(
true
)
{
...
...
@@ -673,7 +673,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
else
{
expect
(
DOUBLE_ARROW
,
"Expecting '=>' or 'when'"
,
WHEN_CONDITION_RECOVERY_SET
);
if
(
atSet
(
WHEN_CONDITION_RECOVERY_SET
))
{
error
(
"Expecting an e
xpression
"
);
error
(
"Expecting an e
lement
"
);
}
else
{
parseExpression
();
}
...
...
@@ -683,7 +683,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* whenConditionIf
* : pattern ("if" "(" e
xpression
")")?
* : pattern ("if" "(" e
lement
")")?
* ;
*/
private
void
parseWhenConditionIf
()
{
...
...
@@ -705,9 +705,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* whenCondition
* : e
xpression
* : e
lement
* : "." postfixExpression typeArguments? valueArguments?
* : ("in" | "!in") e
xpression
* : ("in" | "!in") e
lement
* : ("is" | "!is") isRHS
* ;
*/
...
...
@@ -718,7 +718,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance
();
// IN_KEYWORD or NOT_IN
if
(
atSet
(
WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW
))
{
error
(
"Expecting an e
xpression
"
);
error
(
"Expecting an e
lement
"
);
}
else
{
parseExpression
();
}
...
...
@@ -739,7 +739,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
}
else
{
if
(
atSet
(
WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW
))
{
error
(
"Expecting an e
xpression
, is-condition or in-condition"
);
error
(
"Expecting an e
lement
, is-condition or in-condition"
);
}
else
{
parseExpression
();
}
...
...
@@ -782,7 +782,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
myJetParsing
.
parseTypeRef
();
if
(
at
(
AT
))
{
errorAndAdvance
(
"'@' is allowed only after a decomposer e
xpression
, not after a type"
);
errorAndAdvance
(
"'@' is allowed only after a decomposer e
lement
, not after a type"
);
}
if
(
myBuilder
.
getCurrentOffset
()
<
expressionEndOffset
)
{
rollbackMarker
.
rollbackTo
();
...
...
@@ -853,8 +853,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
* binding
* : "is" pattern
* : "!is" pattern
* : "in" e
xpression
* : "!in" e
xpression
* : "in" e
lement
* : "!in" e
lement
* : ":" type
* ;
*/
...
...
@@ -882,7 +882,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* arrayAccess
* : "[" e
xpression
{","} "]"
* : "[" e
lement
{","} "]"
* ;
*/
private
void
parseArrayAccess
()
{
...
...
@@ -894,9 +894,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance
();
// LBRACKET
while
(
true
)
{
if
(
at
(
COMMA
))
errorAndAdvance
(
"Expecting an index e
xpression
"
);
if
(
at
(
COMMA
))
errorAndAdvance
(
"Expecting an index e
lement
"
);
if
(
at
(
RBRACKET
))
{
error
(
"Expecting an index e
xpression
"
);
error
(
"Expecting an index e
lement
"
);
break
;
}
parseExpression
();
...
...
@@ -1073,13 +1073,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* expressions
* : SEMI* e
xpression
{SEMI+} SEMI*
* : SEMI* e
lement
{SEMI+} SEMI*
*/
public
void
parseExpressions
()
{
while
(
at
(
SEMICOLON
))
advance
();
// SEMICOLON
while
(!
eof
()
&&
!
at
(
RBRACE
))
{
if
(!
atSet
(
EXPRESSION_FIRST
))
{
errorAndAdvance
(
"Expecting an e
xpression
"
);
errorAndAdvance
(
"Expecting an e
lement
"
);
}
if
(
atSet
(
EXPRESSION_FIRST
))
{
parseExpression
();
...
...
@@ -1126,7 +1126,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* doWhile
* : "do" e
xpression "while" "(" expression
")"
* : "do" e
lement "while" "(" element
")"
* ;
*/
private
void
parseDoWhile
()
{
...
...
@@ -1149,7 +1149,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* while
* : "while" "(" e
xpression ")" expression
* : "while" "(" e
lement ")" element
* ;
*/
private
void
parseWhile
()
{
...
...
@@ -1168,7 +1168,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* for
* : "for" "(" attributes valOrVar? SimpleName (":" type)? "in" e
xpression ")" expression
* : "for" "(" attributes valOrVar? SimpleName (":" type)? "in" e
lement ")" element
* ;
*
* TODO: empty loop body (at the end of the block)?
...
...
@@ -1207,7 +1207,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* e
xpression
* e
lement
*/
private
void
parseControlStructureBody
()
{
PsiBuilder
.
Marker
body
=
mark
();
...
...
@@ -1263,7 +1263,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* if
* : "if" "(" e
xpression ")" expression SEMI? ("else" expression
)?
* : "if" "(" e
lement ")" element SEMI? ("else" element
)?
* ;
*/
private
void
parseIf
()
{
...
...
@@ -1296,7 +1296,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* "(" e
xpression
")"
* "(" e
lement
")"
*/
private
void
parseCondition
()
{
myBuilder
.
disableNewlines
();
...
...
@@ -1321,13 +1321,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance
();
// BREAK_KEYWORD or CONTINUE_KEYWORD
if
(!
eol
()
&&
atSet
(
LABELS
))
advance
();
// LABELS
parseLabel
();
marker
.
done
(
type
);
}
/*
* "return" getEntryPoint? e
xpression
?
* "return" getEntryPoint? e
lement
?
*/
private
void
parseReturn
()
{
assert
_at
(
RETURN_KEYWORD
);
...
...
@@ -1336,9 +1336,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance
();
// RETURN_KEYWORD
if
(
atSet
(
LABELS
))
{
advance
();
// LABELS
}
parseLabel
();
if
(
atSet
(
EXPRESSION_FIRST
)
&&
!
at
(
EOL_OR_SEMICOLON
))
parseExpression
();
...
...
@@ -1346,7 +1344,22 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* : "throw" expression
* labels
*/
private
void
parseLabel
()
{
if
(!
eol
()
&&
atSet
(
LABELS
))
{
PsiBuilder
.
Marker
labelWrap
=
mark
();
PsiBuilder
.
Marker
mark
=
mark
();
advance
();
// LABELS
mark
.
done
(
LABEL_REFERENCE
);
labelWrap
.
done
(
LABEL_QUALIFIER
);
}
}
/*
* : "throw" element
*/
private
void
parseThrow
()
{
assert
_at
(
THROW_KEYWORD
);
...
...
@@ -1379,7 +1392,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* "typeof" "(" e
xpression
")"
* "typeof" "(" e
lement
")"
*/
private
void
parseTypeOf
()
{
assert
_at
(
TYPEOF_KEYWORD
);
...
...
@@ -1399,13 +1412,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* tupleLiteral // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an e
xpression
in parentheses
* tupleLiteral // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an e
lement
in parentheses
* // to put a tuple, write write ((e))
* : "(" ((SimpleName "=")? e
xpression
){","} ")"
* : "(" ((SimpleName "=")? e
lement
){","} ")"
* ;
*
* e
xpression
* : "(" e
xpression
")"
* e
lement
* : "(" e
lement
")"
* ;
*
* TODO: duplication with valueArguments (but for the error messages)
...
...
@@ -1422,7 +1435,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
while
(
true
)
{
while
(
at
(
COMMA
))
{
tuple
=
true
;
errorAndAdvance
(
"Expecting a tuple entry (e
xpression
)"
);
errorAndAdvance
(
"Expecting a tuple entry (e
lement
)"
);
}
if
(
at
(
IDENTIFIER
)
&&
lookahead
(
1
)
==
EQ
)
{
...
...
@@ -1441,7 +1454,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
tuple
=
true
;
if
(
at
(
RPAR
))
{
error
(
"Expecting a tuple entry (e
xpression
)"
);
error
(
"Expecting a tuple entry (e
lement
)"
);
break
;
}
}
...
...
@@ -1463,11 +1476,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
PsiBuilder
.
Marker
mark
=
mark
();
advance
();
// THIS_KEYWORD
if
(
atSet
(
LABELS
))
{
PsiBuilder
.
Marker
label
=
mark
();
advance
();
// LABELS
label
.
done
(
LABEL_REFERENCE
);
}
parseLabel
();
if
(
at
(
LT
))
{
// This may be "this < foo" or "this<foo>", thus the backtracking
...
...
@@ -1492,7 +1501,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* valueArguments
* : "(" (SimpleName "=")? ("out" | "ref")? e
xpression
{","} ")"
* : "(" (SimpleName "=")? ("out" | "ref")? e
lement
{","} ")"
* ;
*/
public
void
parseValueArgumentList
()
{
...
...
@@ -1521,7 +1530,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* (SimpleName "=")? ("out" | "ref")? e
xpression
* (SimpleName "=")? ("out" | "ref")? e
lement
*/
private
void
parseValueArgument
()
{
PsiBuilder
.
Marker
argument
=
mark
();
...
...
idea/src/org/jetbrains/jet/lang/parsing/JetParsing.java
浏览文件 @
eb7db21c
...
...
@@ -311,7 +311,7 @@ public class JetParsing extends AbstractJetParsing {
/*
* attribute
* // : SimpleName{"."} (valueArguments | "=" e
xpression
)?
* // : SimpleName{"."} (valueArguments | "=" e
lement
)?
* [for recovery: userType valueArguments?]
* ;
*/
...
...
@@ -683,7 +683,7 @@ public class JetParsing extends AbstractJetParsing {
* : modifiers ("val" | "var")
* typeParameters? (type "." | attributes)?
* SimpleName (":" type)?
* ("=" e
xpression
SEMI?)?
* ("=" e
lement
SEMI?)?
* (getter? setter? | setter? getter?) SEMI?
* ;
*/
...
...
@@ -883,7 +883,7 @@ public class JetParsing extends AbstractJetParsing {
/*
* functionBody
* : block
* : "=" e
xpression
* : "=" e
lement
* ;
*/
private
void
parseFunctionBody
()
{
...
...
@@ -975,7 +975,7 @@ public class JetParsing extends AbstractJetParsing {
* ;
*
* explicitDelegation
* : userType "by" e
xpression
* : userType "by" e
lement
* ;
*/
private
void
parseDelegationSpecifier
()
{
...
...
@@ -1336,7 +1336,7 @@ public class JetParsing extends AbstractJetParsing {
* ;
*
* functionParameterRest
* : parameter ("=" e
xpression
)?
* : parameter ("=" e
lement
)?
* ;
*/
public
void
parseValueParameterList
(
boolean
isFunctionTypeContents
,
TokenSet
recoverySet
)
{
...
...
@@ -1376,7 +1376,7 @@ public class JetParsing extends AbstractJetParsing {
/*
* functionParameter
* : modifiers ("val" | "var")? parameter ("=" e
xpression
)?
* : modifiers ("val" | "var")? parameter ("=" e
lement
)?
* ;
*/
private
boolean
tryParseValueParameter
()
{
...
...
@@ -1408,7 +1408,7 @@ public class JetParsing extends AbstractJetParsing {
/*
* functionParameterRest
* : parameter ("=" e
xpression
)?
* : parameter ("=" e
lement
)?
* ;
*/
private
boolean
parseFunctionParameterRest
()
{
...
...
idea/src/org/jetbrains/jet/lang/psi/JetContainerNode.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.psi
;
import
com.intellij.lang.ASTNode
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.tree.IElementType
;
import
org.jetbrains.annotations.NotNull
;
/**
...
...
@@ -15,4 +17,9 @@ public class JetContainerNode extends JetElement {
protected
<
T
>
T
findChildByClass
(
Class
<
T
>
aClass
)
{
return
super
.
findChildByClass
(
aClass
);
}
@Override
// for visibility
protected
PsiElement
findChildByType
(
IElementType
type
)
{
return
super
.
findChildByType
(
type
);
}
}
idea/src/org/jetbrains/jet/lang/psi/JetContinueExpression.java
浏览文件 @
eb7db21c
package
org.jetbrains.jet.lang.psi
;
import
com.intellij.lang.ASTNode
;
import
com.intellij.psi.PsiElement
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.lexer.JetTokens
;
/**
* @author max
...
...
@@ -19,9 +16,4 @@ public class JetContinueExpression extends JetLabelQualifiedExpression {
visitor
.
visitContinueExpression
(
this
);
}
@Nullable
public
String
getLabelName
()
{
PsiElement
id
=
findChildByType
(
JetTokens
.
IDENTIFIER
);
return
id
!=
null
?
id
.
getText
()
:
null
;
}
}
idea/src/org/jetbrains/jet/lang/psi/JetLabelQualifiedExpression.java
浏览文件 @
eb7db21c
...
...
@@ -3,7 +3,7 @@ package org.jetbrains.jet.lang.psi;
import
com.intellij.lang.ASTNode
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.jet.
lexer.JetToken
s
;
import
org.jetbrains.jet.
JetNodeType
s
;
/**
* @author abreslav
...
...
@@ -16,7 +16,9 @@ public class JetLabelQualifiedExpression extends JetExpression {
@Nullable
public
JetSimpleNameExpression
getTargetLabel
()
{
return
(
JetSimpleNameExpression
)
findChildByType
(
JetTokens
.
LABELS
);
JetContainerNode
qualifier
=
(
JetContainerNode
)
findChildByType
(
JetNodeTypes
.
LABEL_QUALIFIER
);
if
(
qualifier
==
null
)
return
null
;
return
(
JetSimpleNameExpression
)
qualifier
.
findChildByType
(
JetNodeTypes
.
LABEL_REFERENCE
);
}
@Nullable
@IfNotParsed
...
...
idea/src/org/jetbrains/jet/lang/resolve/BindingTraceContext.java
浏览文件 @
eb7db21c
...
...
@@ -14,6 +14,7 @@ import java.util.Map;
public
class
BindingTraceContext
extends
BindingTrace
implements
BindingContext
{
private
final
Map
<
JetExpression
,
JetType
>
expressionTypes
=
new
HashMap
<
JetExpression
,
JetType
>();
private
final
Map
<
JetReferenceExpression
,
DeclarationDescriptor
>
resolutionResults
=
new
HashMap
<
JetReferenceExpression
,
DeclarationDescriptor
>();
private
final
Map
<
JetReferenceExpression
,
PsiElement
>
labelResolutionResults
=
new
HashMap
<
JetReferenceExpression
,
PsiElement
>();
private
final
Map
<
JetTypeReference
,
JetType
>
types
=
new
HashMap
<
JetTypeReference
,
JetType
>();
private
final
Map
<
DeclarationDescriptor
,
PsiElement
>
descriptorToDeclarations
=
new
HashMap
<
DeclarationDescriptor
,
PsiElement
>();
private
final
Map
<
PsiElement
,
DeclarationDescriptor
>
declarationsToDescriptors
=
new
HashMap
<
PsiElement
,
DeclarationDescriptor
>();
...
...
@@ -31,6 +32,11 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
resolutionResults
.
put
(
expression
,
descriptor
);
}
@Override
public
void
recordLabelResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
PsiElement
element
)
{
labelResolutionResults
.
put
(
expression
,
element
);
}
@Override
public
void
removeReferenceResolution
(
@NotNull
JetReferenceExpression
referenceExpression
)
{
resolutionResults
.
remove
(
referenceExpression
);
...
...
@@ -107,7 +113,7 @@ public class BindingTraceContext extends BindingTrace implements BindingContext
public
PsiElement
resolveToDeclarationPsiElement
(
JetReferenceExpression
referenceExpression
)
{
DeclarationDescriptor
declarationDescriptor
=
resolveReferenceExpression
(
referenceExpression
);
if
(
declarationDescriptor
==
null
)
{
return
null
;
return
labelResolutionResults
.
get
(
referenceExpression
)
;
}
return
descriptorToDeclarations
.
get
(
declarationDescriptor
.
getOriginal
());
}
...
...
idea/src/org/jetbrains/jet/lang/resolve/ClassDescriptorResolver.java
浏览文件 @
eb7db21c
...
...
@@ -177,7 +177,7 @@ public class ClassDescriptorResolver {
}
}
else
{
if
(
bodyExpression
==
null
)
{
semanticServices
.
getErrorHandler
().
genericError
(
function
.
getNode
(),
"This function must either declare a return type or have a body e
xpression
"
);
semanticServices
.
getErrorHandler
().
genericError
(
function
.
getNode
(),
"This function must either declare a return type or have a body e
lement
"
);
returnType
=
ErrorUtils
.
createErrorType
(
"No type, no body"
);
}
else
{
// TODO : Recursion possible
...
...
idea/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java
浏览文件 @
eb7db21c
...
...
@@ -234,7 +234,7 @@ public class TopDownAnalyzer {
if
(
bodyExpression
!=
null
)
{
System
.
out
.
println
(
"-------------"
);
JetControlFlowInstructionsGenerator
instructionsGenerator
=
new
JetControlFlowInstructionsGenerator
();
new
JetControlFlowProcessor
(
semanticServices
,
instructionsGenerator
).
generate
(
function
,
bodyExpression
);
new
JetControlFlowProcessor
(
semanticServices
,
trace
,
instructionsGenerator
).
generate
(
function
,
bodyExpression
);
Pseudocode
pseudocode
=
instructionsGenerator
.
getPseudocode
();
pseudocode
.
postProcess
();
pseudocode
.
dumpInstructions
(
System
.
out
);
...
...
idea/src/org/jetbrains/jet/lang/types/BindingTrace.java
浏览文件 @
eb7db21c
...
...
@@ -18,6 +18,10 @@ public class BindingTrace {
}
public
void
recordLabelResolution
(
@NotNull
JetReferenceExpression
expression
,
@NotNull
PsiElement
element
)
{
}
public
void
recordDeclarationResolution
(
@NotNull
PsiElement
declaration
,
@NotNull
DeclarationDescriptor
descriptor
)
{
}
...
...
idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
浏览文件 @
eb7db21c
...
...
@@ -185,7 +185,7 @@ public class JetTypeInferrer {
@Override
public
void
visitJetElement
(
JetElement
elem
)
{
semanticServices
.
getErrorHandler
().
genericError
(
elem
.
getNode
(),
"Unsupported in call e
xpression
"
);
// TODO : Message
semanticServices
.
getErrorHandler
().
genericError
(
elem
.
getNode
(),
"Unsupported in call e
lement
"
);
// TODO : Message
}
});
return
wrapForTracing
(
result
[
0
],
reference
[
0
],
argumentList
,
true
);
...
...
@@ -894,7 +894,7 @@ public class JetTypeInferrer {
}
else
if
(
selectorExpression
!=
null
)
{
// TODO : not a simple name -> resolve in scope, expect property type or a function type
semanticServices
.
getErrorHandler
().
genericError
(
selectorExpression
.
getNode
(),
"Unsupported selector e
xpression
type: "
+
selectorExpression
);
semanticServices
.
getErrorHandler
().
genericError
(
selectorExpression
.
getNode
(),
"Unsupported selector e
lement
type: "
+
selectorExpression
);
}
return
receiverType
;
}
...
...
@@ -1312,7 +1312,7 @@ public class JetTypeInferrer {
String
counterpartName
=
binaryOperationNames
.
get
(
assignmentOperationCounterparts
.
get
(
operationType
));
getTypeForBinaryCall
(
expression
,
counterpartName
,
scope
,
true
);
}
result
=
null
;
// not an e
xpression
result
=
null
;
// not an e
lement
}
@Override
...
...
@@ -1335,7 +1335,7 @@ public class JetTypeInferrer {
}
}
}
result
=
null
;
// This is not an e
xpression
result
=
null
;
// This is not an e
lement
}
private
void
resolveArrayAccessToLValue
(
JetArrayAccessExpression
arrayAccessExpression
,
JetExpression
rightHandSide
,
JetSimpleNameExpression
operationSign
)
{
...
...
idea/src/org/jetbrains/jet/lexer/_JetLexer.java
浏览文件 @
eb7db21c
...
...
@@ -640,7 +640,7 @@ class _JetLexer implements FlexLexer {
/**
* Returns the text matched by the current regular e
xpression
.
* Returns the text matched by the current regular e
lement
.
*/
public
final
CharSequence
yytext
()
{
return
zzBuffer
.
subSequence
(
zzStartRead
,
zzMarkedPos
);
...
...
@@ -727,7 +727,7 @@ class _JetLexer implements FlexLexer {
/**
* Resumes scanning until the next regular e
xpression
is matched,
* Resumes scanning until the next regular e
lement
is matched,
* the end of input is encountered or an I/O-Error occurs.
*
* @return the next token
...
...
idea/testData/psi/Expressions_ERR.txt
浏览文件 @
eb7db21c
...
...
@@ -30,17 +30,17 @@ JetFile: Expressions_ERR.jet
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('dfsd')
PsiWhiteSpace('\n ')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
PsiElement(RPAR)(')')
PsiElement(SEMICOLON)(';')
PsiElement(SEMICOLON)(';')
PsiElement(SEMICOLON)(';')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
PsiElement(RPAR)(')')
PsiElement(SEMICOLON)(';')
PsiElement(SEMICOLON)(';')
PsiElement(SEMICOLON)(';')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
PsiElement(BAD_CHARACTER)('~')
PsiElement(SEMICOLON)(';')
PsiElement(SEMICOLON)(';')
...
...
@@ -49,10 +49,10 @@ JetFile: Expressions_ERR.jet
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('srgsdfg')
PsiWhiteSpace('\n\n ')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
PsiElement(BAD_CHARACTER)('~')
PsiWhiteSpace('\n\n ')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
\ No newline at end of file
idea/testData/psi/When_ERR.txt
浏览文件 @
eb7db21c
...
...
@@ -60,7 +60,7 @@ JetFile: When_ERR.jet
WHEN_ENTRY
WHEN_CONDITION
PsiElement(in)('in')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
...
...
@@ -71,7 +71,7 @@ JetFile: When_ERR.jet
WHEN_ENTRY
WHEN_CONDITION
PsiElement(NOT_IN)('!in')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
...
...
@@ -81,7 +81,7 @@ JetFile: When_ERR.jet
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiErrorElement:Expecting an e
xpression
, is-condition or in-condition
PsiErrorElement:Expecting an e
lement
, is-condition or in-condition
<empty list>
PsiElement(DOUBLE_ARROW)('=>')
PsiWhiteSpace(' ')
...
...
@@ -90,7 +90,7 @@ JetFile: When_ERR.jet
PsiWhiteSpace('\n ')
WHEN_ENTRY
PsiElement(else)('else')
PsiErrorElement:Expecting 'continue' or '=> e
xpression
'
PsiErrorElement:Expecting 'continue' or '=> e
lement
'
<empty list>
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
...
...
@@ -112,7 +112,7 @@ JetFile: When_ERR.jet
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace('\n ')
WHEN_ENTRY
...
...
@@ -122,59 +122,59 @@ JetFile: When_ERR.jet
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiElement(in)('in')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiElement(NOT_IN)('!in')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiElement(NOT_IN)('!in')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace(' ')
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n ')
WHEN_ENTRY
WHEN_CONDITION
PsiErrorElement:Expecting an e
xpression
, is-condition or in-condition
PsiErrorElement:Expecting an e
lement
, is-condition or in-condition
<empty list>
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace('\n ')
WHEN_ENTRY
PsiElement(else)('else')
PsiErrorElement:Expecting 'continue' or '=> e
xpression
'
PsiErrorElement:Expecting 'continue' or '=> e
lement
'
<empty list>
PsiWhiteSpace('\n ')
WHEN_ENTRY
PsiElement(else)('else')
PsiWhiteSpace(' ')
PsiElement(DOUBLE_ARROW)('=>')
PsiErrorElement:Expecting an e
xpression
PsiErrorElement:Expecting an e
lement
<empty list>
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录