Refactoring of JetTypeInfo / BindingContext. Loop data flow analysis corrected.

Now BindingContext includes expression type info instead of jump out possible, data flow info and expression type.
getType() was added into BindingContext, getType() and recordType() were added into BindingTrace.
JetTypeInfo now includes also jump possible flag and jump point data flow info.
Old TypeInfoWithJumpInfo deleted.
TypeInfoFactory introduced to create JetTypeInfo instances.
A pack of extra tests for break / continue in loops added.
This commit is contained in:
Mikhail Glukhikh
2015-04-20 16:12:49 +03:00
parent 14b92404cd
commit 27625b04e1
113 changed files with 908 additions and 550 deletions
@@ -350,7 +350,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
assert right != null;
JetType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right);
JetType leftType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.EXPRESSION_TYPE, expression.getLeft());
JetType leftType = BindingContextUtils.getNotNullType(context.bindingContext(), expression.getLeft());
if (TypeUtils.isNullableType(rightType) || !TypeUtils.isNullableType(leftType)) {
return jsExpression.source(expression);
}
@@ -89,7 +89,7 @@ public final class StringTemplateTranslator extends AbstractTranslator {
return;
}
JetType type = context().bindingContext().get(BindingContext.EXPRESSION_TYPE, entryExpression);
JetType type = context().bindingContext().getType(entryExpression);
if (type == null || type.isMarkedNullable()) {
append(TopLevelFIF.TO_STRING.apply((JsExpression) null, Collections.singletonList(translatedExpression), context()));
}
@@ -55,7 +55,7 @@ public final class UnaryOperationTranslator {
IElementType operationToken = expression.getOperationReference().getReferencedNameElementType();
if (operationToken == JetTokens.EXCLEXCL) {
JetExpression baseExpression = getBaseExpression(expression);
JetType type = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.EXPRESSION_TYPE, baseExpression);
JetType type = BindingContextUtils.getNotNullType(context.bindingContext(), baseExpression);
JsExpression translatedExpression = translateAsExpression(baseExpression, context);
return type.isMarkedNullable() ? sure(translatedExpression, context) : translatedExpression;
}
@@ -160,7 +160,7 @@ public final class BindingUtils {
public static Object getCompileTimeValue(@NotNull BindingContext context, @NotNull JetExpression expression, @NotNull CompileTimeConstant<?> constant) {
if (constant != null) {
if (constant instanceof IntegerValueTypeConstant) {
JetType expectedType = context.get(BindingContext.EXPRESSION_TYPE, expression);
JetType expectedType = context.getType(expression);
return ((IntegerValueTypeConstant) constant).getValue(expectedType == null ? TypeUtils.NO_EXPECTED_TYPE : expectedType);
}
return constant.getValue();
@@ -210,7 +210,7 @@ public final class BindingUtils {
@NotNull
public static JetType getTypeForExpression(@NotNull BindingContext context,
@NotNull JetExpression expression) {
return BindingContextUtils.getNotNull(context, BindingContext.EXPRESSION_TYPE, expression);
return BindingContextUtils.getNotNullType(context, expression);
}
@NotNull
@@ -162,7 +162,7 @@ public final class JsDescriptorUtils {
@Nullable
public static Name getNameIfStandardType(@NotNull JetExpression expression, @NotNull TranslationContext context) {
JetType type = context.bindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
JetType type = context.bindingContext().getType(expression);
return type != null ? DescriptorUtilsPackage.getNameIfStandardType(type) : null;
}