null checks added
This commit is contained in:
@@ -241,7 +241,10 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitIfExpression(JetIfExpression expression) {
|
public void visitIfExpression(JetIfExpression expression) {
|
||||||
value(expression.getCondition(), false, true);
|
JetExpression condition = expression.getCondition();
|
||||||
|
if (condition != null) {
|
||||||
|
value(condition, false, true);
|
||||||
|
}
|
||||||
Label elseLabel = builder.createUnboundLabel();
|
Label elseLabel = builder.createUnboundLabel();
|
||||||
builder.jumpOnFalse(elseLabel);
|
builder.jumpOnFalse(elseLabel);
|
||||||
JetExpression thenBranch = expression.getThen();
|
JetExpression thenBranch = expression.getThen();
|
||||||
@@ -290,7 +293,10 @@ public class JetControlFlowProcessor {
|
|||||||
builder.bindLabel(catchBlock);
|
builder.bindLabel(catchBlock);
|
||||||
for (Iterator<JetCatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
|
for (Iterator<JetCatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
|
||||||
JetCatchClause catchClause = iterator.next();
|
JetCatchClause catchClause = iterator.next();
|
||||||
value(catchClause.getCatchBody(), true, false);
|
JetExpression catchBody = catchClause.getCatchBody();
|
||||||
|
if (catchBody != null) {
|
||||||
|
value(catchBody, true, false);
|
||||||
|
}
|
||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
builder.nondeterministicJump(afterCatches);
|
builder.nondeterministicJump(afterCatches);
|
||||||
}
|
}
|
||||||
@@ -308,9 +314,15 @@ public class JetControlFlowProcessor {
|
|||||||
public void visitWhileExpression(JetWhileExpression expression) {
|
public void visitWhileExpression(JetWhileExpression expression) {
|
||||||
Label loopExitPoint = builder.createUnboundLabel();
|
Label loopExitPoint = builder.createUnboundLabel();
|
||||||
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
|
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
|
||||||
value(expression.getCondition(), false, true);
|
JetExpression condition = expression.getCondition();
|
||||||
|
if (condition != null) {
|
||||||
|
value(condition, false, true);
|
||||||
|
}
|
||||||
builder.jumpOnFalse(loopExitPoint);
|
builder.jumpOnFalse(loopExitPoint);
|
||||||
value(expression.getBody(), true, false);
|
JetExpression body = expression.getBody();
|
||||||
|
if (body != null) {
|
||||||
|
value(body, true, false);
|
||||||
|
}
|
||||||
builder.jump(loopEntryPoint);
|
builder.jump(loopEntryPoint);
|
||||||
builder.exitLoop(expression);
|
builder.exitLoop(expression);
|
||||||
}
|
}
|
||||||
@@ -319,8 +331,14 @@ public class JetControlFlowProcessor {
|
|||||||
public void visitDoWhileExpression(JetDoWhileExpression expression) {
|
public void visitDoWhileExpression(JetDoWhileExpression expression) {
|
||||||
Label loopExitPoint = builder.createUnboundLabel();
|
Label loopExitPoint = builder.createUnboundLabel();
|
||||||
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
|
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
|
||||||
value(expression.getBody(), true, false);
|
JetExpression body = expression.getBody();
|
||||||
value(expression.getCondition(), false, true);
|
if (body != null) {
|
||||||
|
value(body, true, false);
|
||||||
|
}
|
||||||
|
JetExpression condition = expression.getCondition();
|
||||||
|
if (condition != null) {
|
||||||
|
value(condition, false, true);
|
||||||
|
}
|
||||||
builder.jumpOnTrue(loopEntryPoint);
|
builder.jumpOnTrue(loopEntryPoint);
|
||||||
builder.exitLoop(expression);
|
builder.exitLoop(expression);
|
||||||
}
|
}
|
||||||
@@ -330,7 +348,10 @@ public class JetControlFlowProcessor {
|
|||||||
value(expression.getLoopRange(), false, false);
|
value(expression.getLoopRange(), false, false);
|
||||||
Label loopExitPoint = builder.createUnboundLabel();
|
Label loopExitPoint = builder.createUnboundLabel();
|
||||||
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
|
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
|
||||||
value(expression.getBody(), true, false);
|
JetExpression body = expression.getBody();
|
||||||
|
if (body != null) {
|
||||||
|
value(body, true, false);
|
||||||
|
}
|
||||||
builder.nondeterministicJump(loopEntryPoint);
|
builder.nondeterministicJump(loopEntryPoint);
|
||||||
builder.exitLoop(expression);
|
builder.exitLoop(expression);
|
||||||
}
|
}
|
||||||
@@ -414,7 +435,10 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitFunction(JetFunction function) {
|
public void visitFunction(JetFunction function) {
|
||||||
generate(function, function.getBodyExpression());
|
JetExpression bodyExpression = function.getBodyExpression();
|
||||||
|
if (bodyExpression != null) {
|
||||||
|
generate(function, bodyExpression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -479,11 +503,12 @@ public class JetControlFlowProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression) {
|
public void visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression) {
|
||||||
if (expression.getOperationSign().getReferencedNameElementType() == JetTokens.COLON) {
|
IElementType operationType = expression.getOperationSign().getReferencedNameElementType();
|
||||||
|
if (operationType == JetTokens.COLON || operationType == JetTokens.AS_KEYWORD || operationType == JetTokens.AS_SAFE) {
|
||||||
value(expression.getLeft(), false, false);
|
value(expression.getLeft(), false, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
visitJetElement(expression); // TODO
|
visitJetElement(expression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,5 +522,4 @@ public class JetControlFlowProcessor {
|
|||||||
builder.unsupported(elem);
|
builder.unsupported(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
-1
@@ -17,7 +17,6 @@ import java.util.*;
|
|||||||
public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAdapter {
|
public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAdapter {
|
||||||
|
|
||||||
private final Stack<BlockInfo> loopInfo = new Stack<BlockInfo>();
|
private final Stack<BlockInfo> loopInfo = new Stack<BlockInfo>();
|
||||||
// private final Stack<BlockInfo> subroutineInfo = new Stack<BlockInfo>();
|
|
||||||
private final Map<JetElement, BlockInfo> elementToBlockInfo = new HashMap<JetElement, BlockInfo>();
|
private final Map<JetElement, BlockInfo> elementToBlockInfo = new HashMap<JetElement, BlockInfo>();
|
||||||
private int labelCount = 0;
|
private int labelCount = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user