Tests for return types

Transformation for Java boxed types
Lexer fixed for hexadecimal doubles
Longs detected from literals
compareTo with self defined for numbers (working around an unsupported case)
This commit is contained in:
Andrey Breslav
2011-04-07 17:39:40 +04:00
parent 3cc3f374b9
commit f99472e9dd
24 changed files with 394 additions and 167 deletions
+6
View File
@@ -66,6 +66,7 @@ class Number : Hashable {
}
class Double : Number, Comparable<Double> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
@@ -128,6 +129,7 @@ class Double : Number, Comparable<Double> {
class Float : Number, Comparable<Float> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
@@ -191,6 +193,7 @@ class Float : Number, Comparable<Float> {
class Long : Number, Comparable<Long> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
@@ -319,6 +322,7 @@ class Char : Number, Comparable<Char> {
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Char) : Int
fun compareTo(other : Byte) : Int
fun plus(other : Double) : Double
@@ -380,6 +384,7 @@ class Short : Number, Comparable<Short> {
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
@@ -444,6 +449,7 @@ class Byte : Number, Comparable<Byte> {
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Char) : Int
fun compareTo(other : Byte) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
@@ -11,42 +11,44 @@ import org.jetbrains.jet.lang.psi.JetExpression;
*/
public interface JetControlFlowBuilder {
void readNode(@NotNull JetExpression expression);
void readUnit(@NotNull JetExpression expression);
// General label management
@NotNull
Label createUnboundLabel();
void bindLabel(@NotNull Label label);
void bindLabel(@NotNull Label label);
// Jumps
void jump(@NotNull Label label);
void jumpOnFalse(@NotNull Label label);
void jumpOnTrue(@NotNull Label label);
void nondeterministicJump(Label label); // Maybe, jump to label
// Entry/exit points
Label getEntryPoint(@NotNull JetElement labelElement);
Label getExitPoint(@NotNull JetElement labelElement);
Label getExitPoint(@NotNull JetElement labelElement);
// Loops
Label enterLoop(@NotNull JetExpression expression, Label loopExitPoint);
void exitLoop(@NotNull JetExpression expression);
@Nullable
JetElement getCurrentLoop();
// Finally
void enterTryFinally(@NotNull JetBlockExpression expression);
void exitTryFinally();
void exitTryFinally();
// Subroutines
void enterSubroutine(@NotNull JetElement subroutine, boolean isFunctionLiteral);
void exitSubroutine(@NotNull JetElement subroutine, boolean functionLiteral);
@Nullable
JetElement getCurrentSubroutine();
void returnValue(@NotNull JetElement subroutine);
void returnNoValue(@NotNull JetElement expression, @NotNull JetElement subroutine);
void writeNode(@NotNull JetElement assignment, @NotNull JetElement lValue);
@@ -21,6 +21,11 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
builder.readNode(expression);
}
@Override
public void readUnit(@NotNull JetExpression expression) {
builder.readUnit(expression);
}
@Override
@NotNull
public Label createUnboundLabel() {
@@ -40,7 +40,7 @@ public class JetControlFlowProcessor {
boolean functionLiteral = subroutineElement instanceof JetFunctionLiteralExpression;
builder.enterSubroutine(subroutineElement, functionLiteral);
for (JetElement statement : body) {
statement.accept(new CFPVisitor(preferBlocks));
statement.accept(new CFPVisitor(preferBlocks, false));
}
builder.exitSubroutine(subroutineElement, functionLiteral);
}
@@ -89,18 +89,20 @@ public class JetControlFlowProcessor {
private class CFPVisitor extends JetVisitor {
private final boolean preferBlock;
private final boolean inCondition;
private CFPVisitor(boolean preferBlock) {
private CFPVisitor(boolean preferBlock, boolean inCondition) {
this.preferBlock = preferBlock;
this.inCondition = inCondition;
}
private void value(@NotNull JetElement element, boolean preferBlock) {
private void value(@NotNull JetElement element, boolean preferBlock, boolean inCondition) {
CFPVisitor visitor;
if (this.preferBlock == preferBlock) {
if (this.preferBlock == preferBlock && this.inCondition == inCondition) {
visitor = this;
}
else {
visitor = new CFPVisitor(preferBlock);
visitor = new CFPVisitor(preferBlock, inCondition);
}
element.accept(visitor);
exitElement(element);
@@ -110,7 +112,7 @@ public class JetControlFlowProcessor {
public void visitParenthesizedExpression(JetParenthesizedExpression expression) {
JetExpression innerExpression = expression.getExpression();
if (innerExpression != null) {
value(innerExpression, false);
value(innerExpression, false, inCondition);
}
}
@@ -142,7 +144,7 @@ public class JetControlFlowProcessor {
JetExpression deparenthesized = JetPsiUtil.deparenthesize(labeledExpression);
if (deparenthesized != null) {
enterLabeledElement(labelName, deparenthesized);
value(labeledExpression, false);
value(labeledExpression, false, inCondition);
}
}
@@ -151,27 +153,33 @@ public class JetControlFlowProcessor {
IElementType operationType = expression.getOperationReference().getReferencedNameElementType();
JetExpression right = expression.getRight();
if (operationType == JetTokens.ANDAND) {
value(expression.getLeft(), false);
value(expression.getLeft(), false, true);
Label resultLabel = builder.createUnboundLabel();
builder.jumpOnFalse(resultLabel);
if (right != null) {
value(right, false);
value(right, false, true);
}
builder.bindLabel(resultLabel);
if (!inCondition) {
builder.readNode(expression);
}
}
else if (operationType == JetTokens.OROR) {
value(expression.getLeft(), false);
value(expression.getLeft(), false, true);
Label resultLabel = builder.createUnboundLabel();
builder.jumpOnTrue(resultLabel);
if (right != null) {
value(right, false);
value(right, false, true);
}
builder.bindLabel(resultLabel);
if (!inCondition) {
builder.readNode(expression);
}
}
else if (operationType == JetTokens.EQ) {
JetExpression left = expression.getLeft();
if (right != null) {
value(right, false);
value(right, false, false);
}
if (left instanceof JetSimpleNameExpression) {
builder.writeNode(expression, left);
@@ -182,9 +190,9 @@ public class JetControlFlowProcessor {
}
else if (JetTypeInferrer.assignmentOperationNames.containsKey(operationType)) {
JetExpression left = expression.getLeft();
value(left, false);
value(left, false, false);
if (right != null) {
value(right, false);
value(right, false, false);
}
if (left instanceof JetSimpleNameExpression) {
builder.writeNode(expression, left);
@@ -194,11 +202,11 @@ public class JetControlFlowProcessor {
}
}
else {
value(expression.getLeft(), false);
value(expression.getLeft(), false, false);
if (right != null) {
value(right, false);
value(right, false, false);
}
value(expression.getOperationReference(), false);
value(expression.getOperationReference(), false, false);
builder.readNode(expression);
}
}
@@ -218,22 +226,30 @@ public class JetControlFlowProcessor {
@Override
public void visitIfExpression(JetIfExpression expression) {
value(expression.getCondition(), false);
value(expression.getCondition(), false, true);
Label elseLabel = builder.createUnboundLabel();
builder.jumpOnFalse(elseLabel);
JetExpression then = expression.getThen();
if (then != null) {
value(then, true);
JetExpression thenBranch = expression.getThen();
if (thenBranch != null) {
value(thenBranch, true, inCondition);
}
else {
builder.readUnit(expression);
}
Label resultLabel = builder.createUnboundLabel();
builder.jump(resultLabel);
builder.bindLabel(elseLabel);
JetExpression elseBranch = expression.getElse();
if (elseBranch != null) {
value(elseBranch, true);
value(elseBranch, true, inCondition);
}
else {
builder.readUnit(expression);
}
builder.bindLabel(resultLabel);
// builder.readNode(element);
// if (!inCondition) {
// builder.readNode(expression);
// }
}
@Override
@@ -245,13 +261,13 @@ public class JetControlFlowProcessor {
List<JetCatchClause> catchClauses = expression.getCatchClauses();
if (catchClauses.isEmpty()) {
value(expression.getTryBlock(), true);
value(expression.getTryBlock(), true, false);
}
else {
Label catchBlock = builder.createUnboundLabel();
builder.nondeterministicJump(catchBlock);
value(expression.getTryBlock(), true);
value(expression.getTryBlock(), true, false);
Label afterCatches = builder.createUnboundLabel();
builder.jump(afterCatches);
@@ -259,7 +275,7 @@ public class JetControlFlowProcessor {
builder.bindLabel(catchBlock);
for (Iterator<JetCatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
JetCatchClause catchClause = iterator.next();
value(catchClause.getCatchBody(), true);
value(catchClause.getCatchBody(), true, false);
if (iterator.hasNext()) {
builder.nondeterministicJump(afterCatches);
}
@@ -277,9 +293,9 @@ public class JetControlFlowProcessor {
public void visitWhileExpression(JetWhileExpression expression) {
Label loopExitPoint = builder.createUnboundLabel();
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
value(expression.getCondition(), false);
value(expression.getCondition(), false, true);
builder.jumpOnFalse(loopExitPoint);
value(expression.getBody(), true);
value(expression.getBody(), true, false);
builder.jump(loopEntryPoint);
builder.exitLoop(expression);
}
@@ -288,18 +304,18 @@ public class JetControlFlowProcessor {
public void visitDoWhileExpression(JetDoWhileExpression expression) {
Label loopExitPoint = builder.createUnboundLabel();
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
value(expression.getBody(), true);
value(expression.getCondition(), false);
value(expression.getBody(), true, false);
value(expression.getCondition(), false, true);
builder.jumpOnTrue(loopEntryPoint);
builder.exitLoop(expression);
}
@Override
public void visitForExpression(JetForExpression expression) {
value(expression.getLoopRange(), false);
value(expression.getLoopRange(), false, false);
Label loopExitPoint = builder.createUnboundLabel();
Label loopEntryPoint = builder.enterLoop(expression, loopExitPoint);
value(expression.getBody(), true);
value(expression.getBody(), true, false);
builder.nondeterministicJump(loopEntryPoint);
builder.exitLoop(expression);
}
@@ -351,7 +367,7 @@ public class JetControlFlowProcessor {
public void visitReturnExpression(JetReturnExpression expression) {
JetExpression returnedExpression = expression.getReturnedExpression();
if (returnedExpression != null) {
value(returnedExpression, false);
value(returnedExpression, false, false);
}
JetSimpleNameExpression labelElement = expression.getTargetLabel();
JetElement subroutine;
@@ -377,7 +393,7 @@ public class JetControlFlowProcessor {
@Override
public void visitBlockExpression(JetBlockExpression expression) {
for (JetElement statement : expression.getStatements()) {
value(statement, true);
value(statement, true, false);
}
}
@@ -390,7 +406,7 @@ public class JetControlFlowProcessor {
public void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression) {
if (preferBlock && !expression.hasParameterSpecification()) {
for (JetElement statement : expression.getBody()) {
value(statement, true);
value(statement, true, false);
}
}
else {
@@ -400,10 +416,10 @@ public class JetControlFlowProcessor {
@Override
public void visitQualifiedExpression(JetQualifiedExpression expression) {
value(expression.getReceiverExpression(), false);
value(expression.getReceiverExpression(), false, false);
JetExpression selectorExpression = expression.getSelectorExpression();
if (selectorExpression != null) {
value(selectorExpression, false);
value(selectorExpression, false, false);
}
builder.readNode(expression);
}
@@ -411,21 +427,21 @@ public class JetControlFlowProcessor {
@Override
public void visitCallExpression(JetCallExpression expression) {
for (JetTypeProjection typeArgument : expression.getTypeArguments()) {
value(typeArgument, false);
value(typeArgument, false, false);
}
for (JetArgument argument : expression.getValueArguments()) {
JetExpression argumentExpression = argument.getArgumentExpression();
if (argumentExpression != null) {
value(argumentExpression, false);
value(argumentExpression, false, false);
}
}
for (JetExpression functionLiteral : expression.getFunctionLiteralArguments()) {
value(functionLiteral, false);
value(functionLiteral, false, false);
}
value(expression.getCalleeExpression(), false);
value(expression.getCalleeExpression(), false, false);
builder.readNode(expression);
}
@@ -433,7 +449,7 @@ public class JetControlFlowProcessor {
public void visitProperty(JetProperty property) {
JetExpression initializer = property.getInitializer();
if (initializer != null) {
value(initializer, false);
value(initializer, false, false);
builder.writeNode(property, property);
}
}
@@ -441,7 +457,7 @@ public class JetControlFlowProcessor {
@Override
public void visitTupleExpression(JetTupleExpression expression) {
for (JetExpression entry : expression.getEntries()) {
value(entry, false);
value(entry, false, false);
}
builder.readNode(expression);
}
@@ -58,4 +58,8 @@ public class InstructionVisitor {
public void visitWriteValue(WriteValueInstruction writeValueInstruction) {
visitInstructionWithNext(writeValueInstruction);
}
public void visitReadUnitValue(ReadUnitValueInstruction instruction) {
visitInstructionWithNext(instruction);
}
}
@@ -170,6 +170,11 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
add(new ReadValueInstruction(expression));
}
@Override
public void readUnit(@NotNull JetExpression expression) {
add(new ReadUnitValueInstruction(expression));
}
@Override
public void jump(@NotNull Label label) {
add(new UnconditionalJumpInstruction(label));
@@ -0,0 +1,24 @@
package org.jetbrains.jet.lang.cfg.pseudocode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetExpression;
/**
* @author abreslav
*/
public class ReadUnitValueInstruction extends InstructionWithNext {
public ReadUnitValueInstruction(@NotNull JetExpression expression) {
super(expression);
}
@Override
public void accept(InstructionVisitor visitor) {
visitor.visitReadUnitValue(this);
}
@Override
public String toString() {
return "read (Unit)";
}
}
@@ -24,7 +24,12 @@ public class JetConstantExpression extends JetExpression {
if (elementType == JetNodeTypes.INTEGER_CONSTANT) {
if (nodeText.startsWith("0x") || nodeText.startsWith("0X")) {
return Integer.parseInt(nodeText.substring(2), 16);
String hexString = nodeText.substring(2);
long longValue = Long.parseLong(hexString, 16);
if (Integer.MIN_VALUE <= longValue && longValue <= Integer.MAX_VALUE) {
return (int) longValue;
}
return longValue;
}
if (nodeText.startsWith("0b") || nodeText.startsWith("0B")) {
return Integer.parseInt(nodeText.substring(2), 2);
@@ -375,6 +375,11 @@ public class TopDownAnalyzer {
processPreviousInstructions(instruction, returnedExpressions, elementsReturningUnit);
}
@Override
public void visitReadUnitValue(ReadUnitValueInstruction instruction) {
returnedExpressions.add((JetExpression) instruction.getElement());
}
@Override
public void visitInstruction(Instruction instruction) {
if (instruction instanceof JetElementInstruction) {
@@ -17,6 +17,7 @@ public class JavaTypeTransformer {
private final JavaDescriptorResolver resolver;
private final JetStandardLibrary standardLibrary;
private Map<String, JetType> primitiveTypesMap;
private Map<String, JetType> classTypesMap;
public JavaTypeTransformer(JetStandardLibrary standardLibrary, JavaDescriptorResolver resolver) {
this.resolver = resolver;
@@ -33,12 +34,9 @@ public class JavaTypeTransformer {
return ErrorUtils.createErrorType("Unresolved java class: " + classType.getPresentableText());
}
if ("java.lang.Object".equals(psiClass.getQualifiedName())) {
return JetStandardClasses.getNullableAnyType();
}
if ("java.lang.String".equals(psiClass.getQualifiedName())) {
return standardLibrary.getNullableStringType();
JetType jetAnalog = getClassTypesMap().get(psiClass.getQualifiedName());
if (jetAnalog != null) {
return jetAnalog;
}
ClassDescriptor descriptor = resolver.resolveClass(psiClass);
@@ -85,7 +83,32 @@ public class JavaTypeTransformer {
primitiveTypesMap.put("double", standardLibrary.getDoubleType());
primitiveTypesMap.put("boolean", standardLibrary.getBooleanType());
primitiveTypesMap.put("void", JetStandardClasses.getUnitType());
primitiveTypesMap.put("java.lang.Byte", TypeUtils.makeNullable(standardLibrary.getByteType()));
primitiveTypesMap.put("java.lang.Short", TypeUtils.makeNullable(standardLibrary.getShortType()));
primitiveTypesMap.put("java.lang.Character", TypeUtils.makeNullable(standardLibrary.getCharType()));
primitiveTypesMap.put("java.lang.Integer", TypeUtils.makeNullable(standardLibrary.getIntType()));
primitiveTypesMap.put("java.lang.Long", TypeUtils.makeNullable(standardLibrary.getLongType()));
primitiveTypesMap.put("java.lang.Float", TypeUtils.makeNullable(standardLibrary.getFloatType()));
primitiveTypesMap.put("java.lang.Double", TypeUtils.makeNullable(standardLibrary.getDoubleType()));
primitiveTypesMap.put("java.lang.Boolean", TypeUtils.makeNullable(standardLibrary.getBooleanType()));
}
return primitiveTypesMap;
}
public Map<String, JetType> getClassTypesMap() {
if (classTypesMap == null) {
classTypesMap = new HashMap<String, JetType>();
classTypesMap.put("java.lang.Byte", TypeUtils.makeNullable(standardLibrary.getByteType()));
classTypesMap.put("java.lang.Short", TypeUtils.makeNullable(standardLibrary.getShortType()));
classTypesMap.put("java.lang.Character", TypeUtils.makeNullable(standardLibrary.getCharType()));
classTypesMap.put("java.lang.Integer", TypeUtils.makeNullable(standardLibrary.getIntType()));
classTypesMap.put("java.lang.Long", TypeUtils.makeNullable(standardLibrary.getLongType()));
classTypesMap.put("java.lang.Float", TypeUtils.makeNullable(standardLibrary.getFloatType()));
classTypesMap.put("java.lang.Double", TypeUtils.makeNullable(standardLibrary.getDoubleType()));
classTypesMap.put("java.lang.Boolean", TypeUtils.makeNullable(standardLibrary.getBooleanType()));
classTypesMap.put("java.lang.Object", JetStandardClasses.getNullableAnyType());
classTypesMap.put("java.lang.String", standardLibrary.getNullableStringType());
}
return classTypesMap;
}
}
@@ -298,7 +298,12 @@ public class JetTypeInferrer {
}
}
else {
if (element instanceof JetExpression) {
if (element == function) {
JetExpression bodyExpression = function.getBodyExpression();
assert bodyExpression != null;
semanticServices.getErrorHandler().genericError(bodyExpression.getNode(), "This function must return a value of type " + expectedReturnType);
}
else if (element instanceof JetExpression) {
JetExpression expression = (JetExpression) element;
semanticServices.getErrorHandler().typeMismatch(expression, expectedReturnType, actualType);
}
@@ -497,7 +502,13 @@ public class JetTypeInferrer {
IElementType elementType = expression.getNode().getElementType();
JetStandardLibrary standardLibrary = semanticServices.getStandardLibrary();
if (elementType == JetNodeTypes.INTEGER_CONSTANT) {
result = standardLibrary.getIntType();
if (expression.getValue() instanceof Long) {
result = standardLibrary.getLongType();
}
else {
result = standardLibrary.getIntType();
}
// TODO : other ranges
} else if (elementType == JetNodeTypes.LONG_CONSTANT) {
result = standardLibrary.getLongType();
} else if (elementType == JetNodeTypes.FLOAT_CONSTANT) {
@@ -1222,9 +1233,7 @@ public class JetTypeInferrer {
}
private boolean isBoolean(@NotNull JetType type) {
if (type.isNullable()) return false;
TypeConstructor booleanTypeConstructor = semanticServices.getStandardLibrary().getBoolean().getTypeConstructor();
return type.getConstructor().equals(booleanTypeConstructor) || ErrorUtils.isErrorType(type);
return semanticServices.getTypeChecker().isConvertibleTo(type, semanticServices.getStandardLibrary().getBooleanType());
}
@Override
+2 -1
View File
@@ -54,7 +54,8 @@ HEX_FLOAT_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}[Ff]
//HEX_DOUBLE_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}[Dd]?
HEX_DOUBLE_LITERAL={HEX_SIGNIFICAND}{BINARY_EXPONENT}?
BINARY_EXPONENT=[Pp][+-]?{DIGIT}+
HEX_SIGNIFICAND={HEX_INTEGER_LITERAL}|{HEX_INTEGER_LITERAL}\.|0[Xx]{HEX_DIGIT}*\.{HEX_DIGIT}+
HEX_SIGNIFICAND={HEX_INTEGER_LITERAL}|0[Xx]{HEX_DIGIT}*\.{HEX_DIGIT}+
//HEX_SIGNIFICAND={HEX_INTEGER_LITERAL}|{HEX_INTEGER_LITERAL}\.|0[Xx]{HEX_DIGIT}*\.{HEX_DIGIT}+
CHARACTER_LITERAL="'"([^\\\'\n]|{ESCAPE_SEQUENCE})*("'"|\\)?
// TODO: introduce symbols (e.g. 'foo) as another way to write string literals
+99 -100
View File
@@ -1,4 +1,4 @@
/* The following code was generated by JFlex 1.4.3 on 3/16/11 3:06 PM */
/* The following code was generated by JFlex 1.4.3 on 4/7/11 5:16 PM */
/* It's an automatically generated code. Do not modify it. */
package org.jetbrains.jet.lexer;
@@ -13,7 +13,7 @@ import org.jetbrains.jet.lexer.JetTokens;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 3/16/11 3:06 PM from the specification file
* on 4/7/11 5:16 PM from the specification file
* <tt>/Users/abreslav/work/jet/idea/src/org/jetbrains/jet/lexer/Jet.flex</tt>
*/
class _JetLexer implements FlexLexer {
@@ -149,14 +149,13 @@ class _JetLexer implements FlexLexer {
"\1\51\7\3\1\52\1\53\1\54\11\3\1\55\1\56"+
"\1\57\1\0\1\60\1\61\1\62\1\63\1\64\1\65"+
"\1\66\1\67\1\70\1\71\1\72\1\35\1\3\2\0"+
"\1\42\1\73\1\0\1\35\2\0\1\13\1\74\1\3"+
"\1\75\6\3\1\76\6\3\1\77\1\100\4\3\1\101"+
"\1\102\1\103\1\104\1\105\1\106\1\36\1\37\1\0"+
"\2\73\1\35\2\0\1\3\1\107\1\3\1\110\2\3"+
"\1\111\1\112\1\113\5\3\1\114\1\3\1\115\1\42"+
"\2\0\3\3\1\116\1\3\1\117\2\3\1\120\1\121"+
"\1\122\1\74\3\3\1\123\1\124\1\125\5\3\1\126"+
"\1\127\1\130";
"\1\42\1\73\4\0\1\13\1\74\1\3\1\75\6\3"+
"\1\76\6\3\1\77\1\100\4\3\1\101\1\102\1\103"+
"\1\104\1\105\1\106\1\36\1\37\1\0\2\73\1\35"+
"\2\0\1\3\1\107\1\3\1\110\2\3\1\111\1\112"+
"\1\113\5\3\1\114\1\3\1\115\1\42\2\0\3\3"+
"\1\116\1\3\1\117\2\3\1\120\1\121\1\122\1\74"+
"\3\3\1\123\1\124\1\125\5\3\1\126\1\127\1\130";
private static int [] zzUnpackAction() {
int [] result = new int[204];
@@ -355,99 +354,99 @@ class _JetLexer implements FlexLexer {
"\2\163\1\230\1\163\4\0\3\163\1\0\1\163\1\0"+
"\1\163\3\0\30\163\23\0\12\164\1\231\66\164\11\232"+
"\1\233\1\165\66\232\1\0\1\100\12\0\1\100\65\0"+
"\2\234\11\0\1\234\1\0\1\234\1\157\1\234\1\0"+
"\1\170\4\0\1\234\1\0\1\234\1\0\1\170\1\234"+
"\7\0\2\234\7\0\1\234\24\0\1\160\12\0\1\160"+
"\4\0\1\235\36\0\1\235\37\0\1\157\61\0\25\173"+
"\1\236\53\173\1\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\3\4"+
"\1\237\24\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\23\4"+
"\1\240\4\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\3\4"+
"\1\241\24\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\3\4"+
"\1\242\24\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\10\4"+
"\1\243\17\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\4\4"+
"\1\244\23\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\3\4\1\0\1\4\1\0\1\4\3\0\3\4"+
"\1\245\24\4\24\0\2\4\1\0\2\4\1\0\1\4"+
"\4\0\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1\0\1\4\1\0\1\4\3\0\1\304\27\4\24\0"+
"\2\234\11\0\1\234\1\0\1\234\1\157\1\234\6\0"+
"\1\234\1\0\1\234\2\0\1\234\7\0\2\234\7\0"+
"\1\234\24\0\1\160\12\0\1\160\4\0\1\235\36\0"+
"\1\235\37\0\1\157\61\0\25\173\1\236\53\173\1\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\1\4\1\305\26\4\24\0"+
"\1\4\1\0\1\4\3\0\3\4\1\237\24\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\11\4\1\306\16\4\24\0"+
"\1\4\1\0\1\4\3\0\23\4\1\240\4\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\13\4\1\307\14\4\24\0"+
"\1\4\1\0\1\4\3\0\3\4\1\241\24\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\6\4\1\310\21\4\24\0"+
"\1\4\1\0\1\4\3\0\3\4\1\242\24\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\12\4\1\311\15\4\24\0"+
"\1\4\1\0\1\4\3\0\10\4\1\243\17\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\3\4\1\312\24\4\24\0"+
"\1\4\1\0\1\4\3\0\4\4\1\244\23\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\3\4\1\313\24\4\24\0"+
"\1\4\1\0\1\4\3\0\3\4\1\245\24\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\1\314\27\4\23\0";
"\1\4\1\0\1\4\3\0\3\4\1\246\24\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\4\4\1\247\23\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\12\4\1\250\15\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\3\4\1\251\24\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\13\4\1\252\14\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\4\4\1\253\23\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\1\4\1\254\26\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\1\255\27\4\24\0\2\4"+
"\1\0\2\4\1\0\1\4\4\0\3\4\1\0\1\4"+
"\1\0\1\4\3\0\23\4\1\256\4\4\24\0\2\4"+
"\1\0\2\4\1\0\1\4\4\0\3\4\1\0\1\4"+
"\1\0\1\4\3\0\4\4\1\257\23\4\23\0\11\164"+
"\1\260\1\231\66\164\12\232\1\261\66\232\1\0\2\234"+
"\11\0\1\234\1\0\1\234\1\0\1\234\1\0\1\170"+
"\4\0\1\234\1\0\1\234\1\0\1\170\1\234\7\0"+
"\2\234\7\0\1\234\23\0\25\173\1\262\53\173\1\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\4\4\1\263\23\4\24\0"+
"\2\4\1\0\2\4\1\0\1\4\4\0\3\4\1\0"+
"\1\4\1\0\1\4\3\0\1\264\27\4\24\0\2\4"+
"\1\0\2\4\1\0\1\4\4\0\3\4\1\0\1\4"+
"\1\0\1\4\3\0\11\4\1\265\16\4\24\0\2\4"+
"\1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\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\1\4\1\305\26\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\11\4\1\306\16\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\13\4\1\307\14\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\6\4\1\310\21\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\12\4\1\311\15\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\3\4\1\312\24\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\3\4\1\313\24\4\24\0\2\4\1\0\2\4"+
"\1\0\1\4\4\0\3\4\1\0\1\4\1\0\1\4"+
"\3\0\1\314\27\4\23\0";
private static int [] zzUnpackTrans() {
int [] result = new int[8775];
@@ -494,9 +493,9 @@ class _JetLexer implements FlexLexer {
"\1\0\1\11\43\1\1\11\1\1\11\11\1\0\1\1"+
"\1\0\1\1\1\0\1\1\1\0\1\11\2\1\2\11"+
"\4\1\5\11\35\1\1\11\1\0\1\1\12\11\1\1"+
"\1\11\2\0\2\1\1\0\1\1\2\0\1\11\30\1"+
"\6\11\1\0\1\1\1\11\1\1\2\0\21\1\1\11"+
"\2\0\13\1\1\11\16\1";
"\1\11\2\0\2\1\4\0\1\11\30\1\6\11\1\0"+
"\1\1\1\11\1\1\2\0\21\1\1\11\2\0\13\1"+
"\1\11\16\1";
private static int [] zzUnpackAttribute() {
int [] result = new int[204];
@@ -640,7 +639,7 @@ class _JetLexer implements FlexLexer {
/**
* Returns the text matched by the current regular element.
* Returns the text matched by the current regular expression.
*/
public final CharSequence yytext() {
return zzBuffer.subSequence(zzStartRead, zzMarkedPos);
@@ -727,7 +726,7 @@ class _JetLexer implements FlexLexer {
/**
* Resumes scanning until the next regular element is matched,
* Resumes scanning until the next regular expression is matched,
* the end of input is encountered or an I/O-Error occurs.
*
* @return the next token
@@ -31,11 +31,13 @@ l3:
jf(l4)
r(false)
l4:
r(true && false)
w(y)
r(false)
jf(l5)
r(true)
l5:
r(false && true)
w(z)
l1:
<END>
+3 -1
View File
@@ -59,11 +59,13 @@ l0:
jf(l4)
r(true)
l4:
r(a && true)
r(a)
jt(l5)
r(false)
l1:
l5:
r(a || false)
l1:
<END>
l2:
<START>
@@ -54,10 +54,12 @@ l9:
r(11)
jmp(l11)
l10:
read (Unit)
l11:
r(12)
r(a)
jf(l12)
read (Unit)
jmp(l13)
l12:
r(13)
+3 -1
View File
@@ -11,8 +11,9 @@ l6:
r(1)
ret(*)
jmp(l9)
l7:
l8:
read (Unit)
l7:
l9:
<END>
=====================
@@ -62,6 +63,7 @@ l0:
ret(*)
jmp(l3)
l2:
read (Unit)
l3:
r(1)
rf({a =>
@@ -0,0 +1,17 @@
== blockAndAndMismatch ==
fun blockAndAndMismatch() : Boolean {
(return true) || (return false)
}
---------------------
l0:
<START>
r(true)
ret(*)
jt(l2)
r(false)
ret(*)
l2:
r((return true) || (return false))
l1:
<END>
=====================
@@ -0,0 +1,3 @@
fun blockAndAndMismatch() : Boolean {
(return true) || (return false)
}
+71 -1
View File
@@ -9,7 +9,7 @@ fun unitShort() : Unit = ()
fun unitShortConv() : Unit = 1
fun unitShortNull() : Unit = null
<error>fun intEmpty() : Int {}</error>
fun intEmpty() : Int <error>{}</error>
fun intShortInfer() = 1
fun intShort() : Int = 1
fun intBlockInfer() {1}
@@ -18,3 +18,73 @@ fun intBlock() : Int {1}
fun blockReturnUnitMismatch() : Int {<error>return</error>}
fun blockReturnValueTypeMismatch() : Int {return <error>3.4</error>}
fun blockReturnValueTypeMatch() : Int {return 1}
fun blockReturnValueTypeMismatchUnit() : Int {return <error>()</error>}
fun blockAndAndMismatch() : Int {
<error>true && false</error>
}
fun blockAndAndMismatch() : Int {
return <error>true && false</error>
}
fun blockAndAndMismatch() : Int {
<error>(return <error>true</error>) && (return <error>false</error>)</error>
}
/*
fun blockAndAndMismatch() : Int {
true || false
}
fun blockAndAndMismatch() : Int {
return true || false
}
fun blockAndAndMismatch() : Int {
(return true) || (return false)
}
fun blockReturnValueTypeMatch() : Int {
return if (1 > 2) 1.0 else 2.0
}
fun blockReturnValueTypeMatch() : Int {
return if (1 > 2) 1.0
}
fun blockReturnValueTypeMatch() : Int {
return if (1 > 2) else 1.0
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
return 1.0
else return 2.0
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
return 1.0
return 2.0
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
else return 1.0
return 2.0
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
1.0
else 2.0
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
1.0
else 2.0
return 1
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
1.0
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
else 1.0;
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
1
else 1.0
}
*/
+2 -1
View File
@@ -33,7 +33,8 @@ fun a(
a : foo = 10,
a : foo = 10,
a : foo = 10,
a : foo = 10
a : foo = 10,
a : foo = 0xffffffff.lng
) {
return 10
return
+20
View File
@@ -678,6 +678,26 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('10')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('0xffffffff')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('lng')
PsiWhiteSpace('\n')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
+4
View File
@@ -47,3 +47,7 @@ fun <T> t(t : T) : T {
System.out.`java::java.io.PrintStream.print(Int)`print(1)
System.out.`java::java.io.PrintStream.print(Double)`print(1.0)
}
fun typeTransform() {
Integer.getInteger("", 239)`:std::Int`
}
@@ -237,7 +237,7 @@ public class NamespaceGenTest extends LightCodeInsightFixtureTestCase {
}
public void testLongCmp() throws Exception {
loadText("fun foo(a: Long, b: Long): Long = if (a == b) 0xffffffffL else 0L");
loadText("fun foo(a: Long, b: Long): Long = if (a == b) 0xffffffff else 0.lng");
System.out.println(generateToText());
final Method main = generateFunction();
assertEquals(0xffffffffL, main.invoke(null, 1, 1));