Merge remote-tracking branch 'origin/master'

This commit is contained in:
svtk
2011-12-26 18:37:27 +04:00
467 changed files with 5068 additions and 2902 deletions
+1 -1
View File
@@ -11,8 +11,8 @@
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" />
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" />
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" />
<module fileurl="file://$PROJECT_DIR$/shift/shift.iml" filepath="$PROJECT_DIR$/shift/shift.iml" />
<module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" />
<module fileurl="file://$PROJECT_DIR$/testlib/testlib.iml" filepath="$PROJECT_DIR$/testlib/testlib.iml" />
</modules>
</component>
</project>
+3 -3
View File
@@ -42,11 +42,11 @@
</java>
</target>
<target name="jarRT" depends="compileStdlib">
<target name="jarRT" depends="compile">
<jar destfile="${output}/kotlin-runtime.jar">
<fileset dir="${output}/classes/runtime"/>
<fileset dir="${output}/classes/stdlib"/>
<fileset dir="${basedir}/stdlib/ktSrc"/>
<!--<fileset dir="${output}/classes/stdlib"/>-->
<fileset dir="${basedir}" includes="stdlib/ktSrc/**/*"/>
</jar>
</target>
@@ -3,13 +3,11 @@ package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.types.JetType;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter;
import org.objectweb.asm.commons.Method;
import java.util.List;
@@ -87,7 +85,8 @@ public class CallableMethod implements Callable {
else {
if(getInvokeOpcode() != Opcodes.INVOKESTATIC)
desc = desc.replace("(", "(L" + getOwner() + ";");
v.visitMethodInsn(Opcodes.INVOKESTATIC, getInvokeOpcode() == Opcodes.INVOKEINTERFACE ? getOwner() + "$$TImpl" : getOwner(), getSignature().getAsmMethod().getName() + "$default", desc);
v.visitMethodInsn(Opcodes.INVOKESTATIC, getInvokeOpcode() == Opcodes.INVOKEINTERFACE ? getOwner() + JvmAbi.TRAIT_IMPL_SUFFIX
: getOwner(), getSignature().getAsmMethod().getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc);
}
}
@@ -48,8 +48,6 @@ public abstract class ClassBodyCodegen {
generateSyntheticParts(accessors);
generateStaticInitializer();
v.done();
}
protected abstract void generateDeclaration();
@@ -26,6 +26,12 @@ public class ClassCodegen {
}
final CodegenContext contextForInners = context.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state.getTypeMapper());
if (!classBuilder.generateCode()) {
// Outer class implementation must happen prior inner classes so we get proper scoping tree in JetLightClass's delegate
generateImplementation(context, aClass, OwnerKind.IMPLEMENTATION, contextForInners.accessors, classBuilder);
}
for (JetDeclaration declaration : aClass.getDeclarations()) {
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
generate(contextForInners, (JetClass) declaration);
@@ -35,7 +41,11 @@ public class ClassCodegen {
}
}
generateImplementation(context, aClass, OwnerKind.IMPLEMENTATION, contextForInners.accessors, classBuilder);
if (classBuilder.generateCode()) {
generateImplementation(context, aClass, OwnerKind.IMPLEMENTATION, contextForInners.accessors, classBuilder);
}
classBuilder.done();
}
private void generateImplementation(CodegenContext context, JetClassOrObject aClass, OwnerKind kind, HashMap<DeclarationDescriptor, DeclarationDescriptor> accessors, ClassBuilder classBuilder) {
@@ -46,6 +56,7 @@ public class ClassCodegen {
if(aClass instanceof JetClass && ((JetClass)aClass).isTrait()) {
ClassBuilder traitBuilder = state.forTraitImplementation(descriptor);
new TraitImplBodyCodegen(aClass, context.intoClass(descriptor, OwnerKind.TRAIT_IMPL, state.getTypeMapper()), traitBuilder, state).generate(null);
traitBuilder.done();
}
}
}
@@ -2410,13 +2410,19 @@ If finally block is present, its last expression is the value of try expression.
return generateTuplePatternMatch((JetTuplePattern) pattern, negated, expressionToMatch, nextEntry);
}
else if (pattern instanceof JetExpressionPattern) {
final Type subjectType = expressionToMatch.type;
expressionToMatch.dupReceiver(v);
expressionToMatch.put(subjectType, v);
JetExpression condExpression = ((JetExpressionPattern) pattern).getExpression();
Type condType = isNumberPrimitive(subjectType) ? expressionType(condExpression) : TYPE_OBJECT;
gen(condExpression, condType);
return generateEqualsForExpressionsOnStack(JetTokens.EQEQ, subjectType, condType, false, false);
if(expressionToMatch != null) {
final Type subjectType = expressionToMatch.type;
expressionToMatch.dupReceiver(v);
expressionToMatch.put(subjectType, v);
JetExpression condExpression = ((JetExpressionPattern) pattern).getExpression();
Type condType = isNumberPrimitive(subjectType) ? expressionType(condExpression) : TYPE_OBJECT;
gen(condExpression, condType);
return generateEqualsForExpressionsOnStack(JetTokens.EQEQ, subjectType, condType, false, false);
}
else {
JetExpression condExpression = ((JetExpressionPattern) pattern).getExpression();
return gen(condExpression);
}
}
else if (pattern instanceof JetWildcardPattern) {
return StackValue.constant(!negated, Type.BOOLEAN_TYPE);
@@ -2665,9 +2671,11 @@ If finally block is present, its last expression is the value of try expression.
JetExpression expr = expression.getSubjectExpression();
final Type subjectType = expressionType(expr);
final Type resultType = expressionType(expression);
final int subjectLocal = myFrameMap.enterTemp(subjectType.getSize());
gen(expr, subjectType);
v.store(subjectLocal, subjectType);
final int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType.getSize()) : -1;
if(subjectLocal != -1) {
gen(expr, subjectType);
v.store(subjectLocal, subjectType);
}
Label end = new Label();
boolean hasElse = false;
@@ -2736,7 +2744,7 @@ If finally block is present, its last expression is the value of try expression.
JetWhenConditionIsPattern patternCondition = (JetWhenConditionIsPattern) condition;
JetPattern pattern = patternCondition.getPattern();
conditionValue = generatePatternMatch(pattern, patternCondition.isNegated(),
StackValue.local(subjectLocal, subjectType), nextEntry);
subjectLocal == -1 ? null : StackValue.local(subjectLocal, subjectType), nextEntry);
}
else {
throw new UnsupportedOperationException("unsupported kind of when condition");
@@ -6,7 +6,8 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.StdlibNames;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Label;
@@ -68,6 +69,10 @@ public class FunctionCodegen {
{
flags |= ACC_VARARGS;
}
if (functionDescriptor.getModality() == Modality.FINAL) {
flags |= ACC_FINAL;
}
OwnerKind kind = context.getContextKind();
@@ -88,48 +93,48 @@ public class FunctionCodegen {
if(kind != OwnerKind.TRAIT_IMPL) {
AnnotationVisitor av = mv.visitAnnotation(JetTypeMapper.JET_METHOD_TYPE.getDescriptor(), true);
if(functionDescriptor.getReturnType().isNullable()) {
av.visit(StdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD, true);
av.visit(JvmStdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD, true);
}
if (jvmSignature.getKotlinReturnType() != null) {
av.visit(StdlibNames.JET_METHOD_RETURN_TYPE_FIELD, jvmSignature.getKotlinReturnType());
av.visit(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD, jvmSignature.getKotlinReturnType());
}
if (jvmSignature.getKotlinTypeParameter() != null) {
av.visit(StdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, jvmSignature.getKotlinTypeParameter());
av.visit(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, jvmSignature.getKotlinTypeParameter());
}
av.visitEnd();
}
if(kind == OwnerKind.TRAIT_IMPL) {
AnnotationVisitor av = mv.visitParameterAnnotation(start++, StdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
av.visit(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$self");
AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$self");
av.visitEnd();
}
if(receiverParameter.exists()) {
AnnotationVisitor av = mv.visitParameterAnnotation(start++, StdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
av.visit(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$receiver");
AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$receiver");
if(receiverParameter.getType().isNullable()) {
av.visit(StdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true);
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true);
}
av.visit(StdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD, true);
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD, true);
av.visitEnd();
}
for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
AnnotationVisitor av = mv.visitParameterAnnotation(start++, StdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true);
av.visit(StdlibNames.JET_TYPE_PARAMETER_NAME_FIELD, typeParameterDescriptor.getName());
AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true);
av.visit(JvmStdlibNames.JET_TYPE_PARAMETER_NAME_FIELD, typeParameterDescriptor.getName());
av.visitEnd();
}
for(int i = 0; i != paramDescrs.size(); ++i) {
AnnotationVisitor av = mv.visitParameterAnnotation(i + start, StdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
AnnotationVisitor av = mv.visitParameterAnnotation(i + start, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true);
ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i);
av.visit(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, parameterDescriptor.getName());
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, parameterDescriptor.getName());
if(parameterDescriptor.hasDefaultValue()) {
av.visit(StdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true);
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true);
}
if(parameterDescriptor.getOutType().isNullable()) {
av.visit(StdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true);
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true);
}
if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) {
av.visit(StdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD, jvmSignature.getKotlinParameterTypes().get(i));
av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD, jvmSignature.getKotlinParameterTypes().get(i + start));
}
av.visitEnd();
}
@@ -300,7 +305,7 @@ public class FunctionCodegen {
boolean isConstructor = "<init>".equals(jvmSignature.getName());
if(!isStatic && !isConstructor)
descriptor = descriptor.replace("(","(L" + ownerInternalName + ";");
final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC), isConstructor ? "<init>" : jvmSignature.getName() + "$default", descriptor, null, null);
final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC), isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, descriptor, null, null);
InstructionAdapter iv = new InstructionAdapter(mv);
if (v.generateCode()) {
mv.visitCode();
@@ -6,8 +6,8 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.OverridingUtil;
import org.jetbrains.jet.lang.resolve.java.StdlibNames;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeProjection;
import org.jetbrains.jet.lexer.JetTokens;
@@ -47,19 +47,41 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean isAbstract = false;
boolean isInterface = false;
boolean isFinal = false;
boolean isStatic = false;
if(myClass instanceof JetClass) {
if(((JetClass) myClass).hasModifier(JetTokens.ABSTRACT_KEYWORD))
JetClass jetClass = (JetClass) myClass;
if (jetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD))
isAbstract = true;
if(((JetClass) myClass).isTrait()) {
if (jetClass.isTrait()) {
isAbstract = true;
isInterface = true;
}
if (!jetClass.hasModifier(JetTokens.OPEN_KEYWORD) && !isAbstract) {
isFinal = true;
}
}
else if (myClass.getParent() instanceof JetClassObject) {
isStatic = true;
}
int access = 0;
access |= Opcodes.ACC_PUBLIC;
if (isAbstract) {
access |= Opcodes.ACC_ABSTRACT;
}
if (isInterface) {
access |= Opcodes.ACC_INTERFACE; // ACC_SUPER
}
if (isFinal) {
access |= Opcodes.ACC_FINAL;
}
if (isStatic) {
access |= Opcodes.ACC_STATIC;
}
v.defineClass(myClass, Opcodes.V1_6,
Opcodes.ACC_PUBLIC | (isAbstract ? Opcodes.ACC_ABSTRACT : 0) | (isInterface
? Opcodes.ACC_INTERFACE
: 0/*Opcodes.ACC_SUPER*/),
access,
signature.getName(),
signature.getJavaGenericSignature(),
signature.getSuperclassName(),
@@ -67,17 +89,27 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
);
v.visitSource(myClass.getContainingFile().getName(), null);
if(descriptor.getContainingDeclaration() instanceof ClassDescriptor) {
v.visitOuterClass(typeMapper.mapType(((ClassDescriptor) descriptor.getContainingDeclaration()).getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), null, null);
ClassDescriptor container = getContainingClassDescriptor(descriptor);
if(container != null) {
v.visitOuterClass(typeMapper.mapType(container.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), null, null);
}
if(myClass instanceof JetClass && signature.getKotlinGenericSignature() != null) {
AnnotationVisitor annotationVisitor = v.newAnnotation(myClass, StdlibNames.JET_CLASS.getDescriptor(), true);
annotationVisitor.visit(StdlibNames.JET_CLASS_SIGNATURE, signature.getKotlinGenericSignature());
AnnotationVisitor annotationVisitor = v.newAnnotation(myClass, JvmStdlibNames.JET_CLASS.getDescriptor(), true);
annotationVisitor.visit(JvmStdlibNames.JET_CLASS_SIGNATURE, signature.getKotlinGenericSignature());
annotationVisitor.visitEnd();
}
}
private static ClassDescriptor getContainingClassDescriptor(ClassDescriptor decl) {
DeclarationDescriptor container = decl.getContainingDeclaration();
while (container != null && !(container instanceof NamespaceDescriptor)) {
if (container instanceof ClassDescriptor) return (ClassDescriptor) container;
container = container.getContainingDeclaration();
}
return null;
}
private JvmClassSignature signature() {
List<String> superInterfaces;
@@ -106,7 +138,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
{ // superinterfaces
superInterfacesLinkedHashSet.add(StdlibNames.JET_OBJECT.getInternalName());
superInterfacesLinkedHashSet.add(JvmStdlibNames.JET_OBJECT.getInternalName());
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
@@ -1,5 +1,6 @@
package org.jetbrains.jet.codegen;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import jet.JetObject;
import jet.typeinfo.TypeInfo;
@@ -12,6 +13,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lexer.JetTokens;
@@ -180,7 +182,29 @@ public class JetTypeMapper {
}
private HashMap<DeclarationDescriptor,Map<DeclarationDescriptor,String>> naming = new HashMap<DeclarationDescriptor, Map<DeclarationDescriptor, String>>();
private String getStableNameForObject(JetObjectDeclaration object, DeclarationDescriptor descriptor) {
String local = getLocalNameForObject(object);
if (local == null) return null;
DeclarationDescriptor containingClass = getContainingClass(descriptor);
if (containingClass != null) {
return getFQName(containingClass) + "$" + local;
}
else {
return getFQName(getContainingNamespace(descriptor)) + "/" + local;
}
}
public static String getLocalNameForObject(JetObjectDeclaration object) {
PsiElement parent = object.getParent();
if (parent instanceof JetClassObject) {
return "ClassObject$";
}
return null;
}
public String getFQName(DeclarationDescriptor descriptor) {
descriptor = descriptor.getOriginal();
@@ -200,7 +224,17 @@ public class JetTypeMapper {
name = map.get(descriptor);
if(name == null) {
name = getFQName(container) + "$" + (map.size()+1);
PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
if (declaration instanceof JetObjectDeclaration) {
String stable = getStableNameForObject((JetObjectDeclaration) declaration, descriptor);
if (stable != null) {
name = stable;
}
}
if (name == null) {
name = getFQName(container) + "$" + (map.size()+1);
}
map.put(descriptor, name);
}
return name;
@@ -222,7 +256,19 @@ public class JetTypeMapper {
return name;
}
private static ClassDescriptor getContainingClass(DeclarationDescriptor descriptor) {
DeclarationDescriptor parent = descriptor.getContainingDeclaration();
if (parent == null || parent instanceof ClassDescriptor) return (ClassDescriptor) parent;
return getContainingClass(parent);
}
private static NamespaceDescriptor getContainingNamespace(DeclarationDescriptor descriptor) {
DeclarationDescriptor parent = descriptor.getContainingDeclaration();
if (parent == null || parent instanceof NamespaceDescriptor) return (NamespaceDescriptor) parent;
return getContainingNamespace(parent);
}
@NotNull public Type mapType(final JetType jetType) {
return mapType(jetType, (BothSignatureWriter) null);
}
@@ -280,7 +326,7 @@ public class JetTypeMapper {
if (descriptor instanceof ClassDescriptor) {
String name = getFQName(descriptor);
Type asmType = Type.getObjectType(name + (kind == OwnerKind.TRAIT_IMPL ? "$$TImpl" : ""));
Type asmType = Type.getObjectType(name + (kind == OwnerKind.TRAIT_IMPL ? JvmAbi.TRAIT_IMPL_SUFFIX : ""));
if (signatureVisitor != null) {
signatureVisitor.writeClassBegin(asmType.getInternalName(), jetType.isNullable());
@@ -738,6 +784,8 @@ public class JetTypeMapper {
}
private void initKnownTypeNames() {
knowTypeNames.put(JetStandardClasses.getAnyType(), "ANY_TYPE_INFO");
knowTypeNames.put(JetStandardClasses.getNullableAnyType(), "NULLABLE_ANY_TYPE_INFO");
knowTypeNames.put(standardLibrary.getIntType(), "INT_TYPE_INFO");
knowTypeNames.put(standardLibrary.getNullableIntType(), "NULLABLE_INT_TYPE_INFO");
knowTypeNames.put(standardLibrary.getLongType(), "LONG_TYPE_INFO");
@@ -6,6 +6,7 @@ import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lexer.JetTokens;
@@ -754,7 +755,7 @@ public abstract class StackValue {
@Override
public void put(Type type, InstructionAdapter v) {
if(isSuper && isInterface) {
v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + "$$TImpl", getter.getName(), getter.getDescriptor().replace("(","(L" + owner + ";"));
v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + JvmAbi.TRAIT_IMPL_SUFFIX, getter.getName(), getter.getDescriptor().replace("(","(L" + owner + ";"));
}
else {
if (getter == null) {
@@ -770,7 +771,7 @@ public abstract class StackValue {
@Override
public void store(InstructionAdapter v) {
if(isSuper && isInterface) {
v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + "$$TImpl", setter.getName(), setter.getDescriptor().replace("(","(L" + owner + ";"));
v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + JvmAbi.TRAIT_IMPL_SUFFIX, setter.getName(), setter.getDescriptor().replace("(","(L" + owner + ";"));
}
else {
if (setter == null) {
@@ -7,6 +7,9 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.Processor;
import jet.ExtensionFunction0;
import jet.ExtensionFunction10;
import jet.Function1;
import jet.modules.IModuleBuilder;
import jet.modules.IModuleSetBuilder;
import org.jetbrains.annotations.Nullable;
@@ -18,6 +21,7 @@ import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.plugin.JetMainDetector;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
@@ -123,6 +127,11 @@ public class CompileEnvironment {
if (rtJar.exists()) {
return rtJar;
}
File classesJar = new File(new File(javaHome).getParentFile().getAbsolutePath(), "Classes/classes.jar");
if (classesJar.exists()) {
return classesJar;
}
return null;
}
@@ -193,17 +202,19 @@ public class CompileEnvironment {
final IModuleSetBuilder moduleSetBuilder = (IModuleSetBuilder) moduleSetBuilderClass.newInstance();
Class namespaceClass = loader.loadClass("namespace");
final Method[] methods = namespaceClass.getMethods();
final Field[] fields = namespaceClass.getDeclaredFields();
boolean modulesDefined = false;
for (Method method : methods) {
if (method.getName().equals("defineModules")) {
method.invoke(null, moduleSetBuilder);
for (Field field : fields) {
if (field.getName().equals("modules")) {
field.setAccessible(true);
ExtensionFunction0 defineMudules = (ExtensionFunction0) field.get(null);
defineMudules.invoke(moduleSetBuilder);
modulesDefined = true;
break;
}
}
if (!modulesDefined) {
throw new CompileEnvironmentException("Module script " + moduleFile + " must define a defineModules() method");
throw new CompileEnvironmentException("Module script " + moduleFile + " must define a modules() property");
}
return moduleSetBuilder;
} catch (Exception e) {
@@ -37,6 +37,9 @@ public class CompileSession {
}
public void addSources(String path) {
if(path == null)
return;
VirtualFile vFile = myEnvironment.getLocalFileSystem().findFileByPath(path);
if (vFile == null) {
myErrors.add("File/directory not found: " + path);
@@ -68,15 +71,15 @@ public class CompileSession {
public void addSources(VirtualFile vFile) {
if (vFile.isDirectory()) {
for (VirtualFile virtualFile : vFile.getChildren()) {
if (virtualFile.getFileType() == JetFileType.INSTANCE) {
addSources(virtualFile);
}
addSources(virtualFile);
}
}
else {
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile);
if (psiFile instanceof JetFile) {
mySourceFileNamespaces.add(((JetFile) psiFile).getRootNamespace());
if (vFile.getFileType() == JetFileType.INSTANCE) {
PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile);
if (psiFile instanceof JetFile) {
mySourceFileNamespaces.add(((JetFile) psiFile).getRootNamespace());
}
}
}
}
@@ -121,8 +124,9 @@ public class CompileSession {
else {
final File runtimeJarPath = CompileEnvironment.getRuntimeJarPath();
if (runtimeJarPath != null && runtimeJarPath.exists()) {
// todo
throw new UnsupportedOperationException("Loading of stdlib sources from jar");
VirtualFile runtimeJar = myEnvironment.getLocalFileSystem().findFileByPath(runtimeJarPath.getAbsolutePath());
VirtualFile jarRoot = myEnvironment.getJarFileSystem().findFileByPath(runtimeJar.getPath() + "!/stdlib/ktSrc");
addSources(jarRoot);
}
else {
return false;
@@ -0,0 +1,134 @@
package org.jetbrains.jet.compiler;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.psi.JetQualifiedExpression;
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintResolutionListener;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl;
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemSolution;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeUtils;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.NamespaceType;
import org.jetbrains.jet.lang.types.Variance;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintType.RECEIVER;
/**
* @author Nikolay Krasko
*/
public final class TipsManager {
private TipsManager() {
}
@NotNull
public static Collection<DeclarationDescriptor> getReferenceVariants(JetSimpleNameExpression expression, BindingContext context) {
PsiElement parent = expression.getParent();
if (parent instanceof JetQualifiedExpression) {
JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) parent;
JetExpression receiverExpression = qualifiedExpression.getReceiverExpression();
final JetType expressionType = context.get(BindingContext.EXPRESSION_TYPE, receiverExpression);
final JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, receiverExpression);
if (expressionType != null && resolutionScope != null) {
return includeExternalCallableExtensions(
expressionType.getMemberScope().getAllDescriptors(),
resolutionScope, new ExpressionReceiver(receiverExpression, expressionType));
}
}
else {
JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
if (resolutionScope != null) {
return excludeNotCallableExtensions(resolutionScope.getAllDescriptors(), resolutionScope);
}
}
return Collections.emptyList();
}
private static Collection<DeclarationDescriptor> excludeNotCallableExtensions(
@NotNull Collection<DeclarationDescriptor> descriptors, @NotNull final JetScope scope
) {
final Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors);
descriptorsSet.removeAll(
Collections2.filter(JetScopeUtils.getAllExtensions(scope), new Predicate<CallableDescriptor>() {
@Override
public boolean apply(CallableDescriptor callableDescriptor) {
return !checkReceiverResolution(scope.getImplicitReceiver(), callableDescriptor);
}
}));
return Lists.newArrayList(descriptorsSet);
}
private static Collection<DeclarationDescriptor> includeExternalCallableExtensions(
@NotNull Collection<DeclarationDescriptor> descriptors,
@NotNull final JetScope externalScope,
@NotNull final ReceiverDescriptor receiverDescriptor
) {
// It's impossible to add extension function for namespace
if (receiverDescriptor.getType() instanceof NamespaceType) {
return descriptors;
}
Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors);
descriptorsSet.addAll(
Collections2.filter(JetScopeUtils.getAllExtensions(externalScope),
new Predicate<CallableDescriptor>() {
@Override
public boolean apply(CallableDescriptor callableDescriptor) {
return checkReceiverResolution(receiverDescriptor, callableDescriptor);
}
}));
return descriptorsSet;
}
/*
* Checks if receiver declaration could be resolved to call expected receiver.
*/
private static boolean checkReceiverResolution (
@NotNull ReceiverDescriptor expectedReceiver,
@NotNull CallableDescriptor receiverArgument
) {
ConstraintSystem constraintSystem = new ConstraintSystemImpl(ConstraintResolutionListener.DO_NOTHING);
for (TypeParameterDescriptor typeParameterDescriptor : receiverArgument.getTypeParameters()) {
constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT);
}
ReceiverDescriptor receiverParameter = receiverArgument.getReceiverParameter();
if (expectedReceiver.exists() && receiverParameter.exists()) {
constraintSystem.addSubtypingConstraint(
RECEIVER.assertSubtyping(expectedReceiver.getType(), receiverParameter.getType()));
}
else if (expectedReceiver.exists() || receiverParameter.exists()) {
// Only one of receivers exist
return false;
}
ConstraintSystemSolution solution = constraintSystem.solve();
return solution.getStatus().isSuccessful();
}
}
@@ -104,7 +104,10 @@ public class JavaClassMembersScope implements JetScope {
for (PsiClass innerClass : psiClass.getAllInnerClasses()) {
if (name.equals(innerClass.getName())) {
if (innerClass.hasModifierProperty(PsiModifier.STATIC) != staticMembers) return null;
return semanticServices.getDescriptorResolver().resolveClass(innerClass);
ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver().resolveClass(innerClass);
if (classDescriptor != null) {
return classDescriptor;
}
}
}
return null;
@@ -9,7 +9,6 @@ import com.intellij.psi.*;
import com.intellij.psi.search.DelegatingGlobalSearchScope;
import com.intellij.psi.search.GlobalSearchScope;
import jet.typeinfo.TypeInfoVariance;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -107,9 +106,14 @@ public class JavaDescriptorResolver {
this.semanticServices = semanticServices;
}
@NotNull
@Nullable
public ClassDescriptor resolveClass(@NotNull PsiClass psiClass) {
String qualifiedName = psiClass.getQualifiedName();
if (qualifiedName.endsWith(JvmAbi.TRAIT_IMPL_SUFFIX)) {
// TODO: only if -$$TImpl class is created by Kotlin
return null;
}
// First, let's check that this is a real Java class, not a Java's view on a Kotlin class:
ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName);
@@ -128,6 +132,12 @@ public class JavaDescriptorResolver {
@Nullable
public ClassDescriptor resolveClass(@NotNull String qualifiedName) {
if (qualifiedName.endsWith(JvmAbi.TRAIT_IMPL_SUFFIX)) {
// TODO: only if -$$TImpl class is created by Kotlin
return null;
}
// First, let's check that this is a real Java class, not a Java's view on a Kotlin class:
ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName);
if (kotlinClassDescriptor != null) {
@@ -234,8 +244,8 @@ public class JavaDescriptorResolver {
private List<TypeParameterDescriptor> resolveClassTypeParameters(PsiClass psiClass, JavaClassDescriptor classDescriptor) {
for (PsiAnnotation annotation : psiClass.getModifierList().getAnnotations()) {
if (annotation.getQualifiedName().equals(StdlibNames.JET_CLASS.getFqName())) {
PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_CLASS_SIGNATURE);
if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_CLASS.getFqName())) {
PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_CLASS_SIGNATURE);
if (attributeValue != null) {
String typeParametersString = (String) attributeValue.getValue();
if (typeParametersString != null) {
@@ -608,18 +618,19 @@ public class JavaDescriptorResolver {
String typeFromAnnotation = null;
boolean receiver = false;
boolean hasDefaultValue = false;
// TODO: must be very slow, make it lazy?
String name = parameter.getName() != null ? parameter.getName() : "p" + i;
for (PsiAnnotation annotation : parameter.getModifierList().getAnnotations()) {
if (annotation.getQualifiedName().equals(StdlibNames.JET_VALUE_PARAMETER.getFqName())) {
PsiLiteralExpression nameExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD);
if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_VALUE_PARAMETER.getFqName())) {
PsiLiteralExpression nameExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD);
if (nameExpression != null) {
name = (String) nameExpression.getValue();
}
PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD);
PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD);
if (nullableExpression != null) {
nullable = (Boolean) nullableExpression.getValue();
} else {
@@ -628,25 +639,30 @@ public class JavaDescriptorResolver {
changeNullable = true;
}
PsiLiteralExpression signatureExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD);
PsiLiteralExpression signatureExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD);
if (signatureExpression != null) {
typeFromAnnotation = (String) signatureExpression.getValue();
}
PsiLiteralExpression receiverExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD);
PsiLiteralExpression receiverExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD);
if (receiverExpression != null) {
receiver = true;
receiver = (Boolean) receiverExpression.getValue();
}
PsiLiteralExpression hasDefaultValueExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD);
if (hasDefaultValueExpression != null) {
hasDefaultValue = (Boolean) hasDefaultValueExpression.getValue();
}
} else if (annotation.getQualifiedName().equals(StdlibNames.JET_TYPE_PARAMETER.getFqName())) {
} else if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_TYPE_PARAMETER.getFqName())) {
return JvmMethodParameterMeaning.typeInfo(new Object());
}
}
JetType outType;
if (typeFromAnnotation != null) {
if (typeFromAnnotation != null && typeFromAnnotation.length() > 0) {
outType = semanticServices.getTypeTransformer().transformToType(typeFromAnnotation);
} else {
outType = semanticServices.getTypeTransformer().transformToType(psiType);
@@ -661,7 +677,7 @@ public class JavaDescriptorResolver {
name,
null, // TODO : review
changeNullable ? TypeUtils.makeNullableAsSpecified(outType, nullable) : outType,
false,
hasDefaultValue,
varargElementType
));
}
@@ -748,6 +764,9 @@ public class JavaDescriptorResolver {
return functionDescriptor;
}
DeclarationDescriptor classDescriptor = method.hasModifierProperty(PsiModifier.STATIC) ? resolveNamespace(method.getContainingClass()) : resolveClass(method.getContainingClass());
if (classDescriptor == null) {
return null;
}
PsiParameter[] parameters = method.getParameterList().getParameters();
FunctionDescriptorImpl functionDescriptorImpl = new FunctionDescriptorImpl(
owner,
@@ -776,8 +795,8 @@ public class JavaDescriptorResolver {
private List<TypeParameterDescriptor> resolveMethodTypeParameters(PsiMethod method, FunctionDescriptorImpl functionDescriptorImpl) {
for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) {
if (annotation.getQualifiedName().equals(StdlibNames.JET_METHOD.getFqName())) {
PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD);
if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_METHOD.getFqName())) {
PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD);
if (attributeValue != null) {
String typeParametersString = (String) attributeValue.getValue();
if (typeParametersString != null) {
@@ -822,8 +841,8 @@ public class JavaDescriptorResolver {
String returnTypeFromAnnotation = null;
for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) {
if (annotation.getQualifiedName().equals(StdlibNames.JET_METHOD.getFqName())) {
PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD);
if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_METHOD.getFqName())) {
PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD);
if (nullableExpression != null) {
nullable = (Boolean) nullableExpression.getValue();
} else {
@@ -832,14 +851,14 @@ public class JavaDescriptorResolver {
changeNullable = true;
}
PsiLiteralExpression returnTypeExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_METHOD_RETURN_TYPE_FIELD);
PsiLiteralExpression returnTypeExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD);
if (returnTypeExpression != null) {
returnTypeFromAnnotation = (String) returnTypeExpression.getValue();
}
}
}
JetType transformedType;
if (returnTypeFromAnnotation != null) {
if (returnTypeFromAnnotation != null && returnTypeFromAnnotation.length() > 0) {
transformedType = semanticServices.getTypeTransformer().transformToType(returnTypeFromAnnotation);
} else {
transformedType = semanticServices.getTypeTransformer().transformToType(returnType);
@@ -94,7 +94,10 @@ public class JavaPackageScope extends JetScopeImpl {
}
if (psiClass.hasModifierProperty(PsiModifier.PUBLIC)) {
allDescriptors.add(descriptorResolver.resolveClass(psiClass));
ClassDescriptor classDescriptor = descriptorResolver.resolveClass(psiClass);
if (classDescriptor != null) {
allDescriptors.add(classDescriptor);
}
}
}
}
@@ -94,6 +94,9 @@ public class JavaTypeTransformer {
}
ClassDescriptor descriptor = resolver.resolveClass(psiClass);
if (descriptor == null) {
return ErrorUtils.createErrorType("Unresolve java class: " + classType.getPresentableText());
}
List<TypeProjection> arguments = Lists.newArrayList();
if (classType.isRaw()) {
@@ -1,17 +1,18 @@
package org.jetbrains.jet.lang.resolve.java;
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.rt.signature.JetSignatureVisitor;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetStandardClasses;
import org.jetbrains.jet.lang.types.JetStandardLibrary;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.JetTypeImpl;
import org.jetbrains.jet.lang.types.TypeProjection;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.Variance;
import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter;
import org.jetbrains.jet.rt.signature.JetSignatureVisitor;
import java.util.ArrayList;
import java.util.Collections;
@@ -119,6 +120,23 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd
};
}
@Override
public JetSignatureVisitor visitArrayType(final boolean nullable) {
return new JetTypeJetSignatureReader(javaDescriptorResolver, jetStandardLibrary) {
@Override
protected void done(@NotNull JetType jetType) {
JetType arrayType = TypeUtils.makeNullableAsSpecified(jetStandardLibrary.getArrayType(jetType), nullable);
JetTypeJetSignatureReader.this.done(arrayType);
}
};
}
@Override
public void visitTypeVariable(String name, boolean nullable) {
// TODO: need a way to get type TypeParameterDescriptor by name
throw new IllegalStateException();
}
@Override
public void visitEnd() {
JetType jetType = new JetTypeImpl(
@@ -0,0 +1,9 @@
package org.jetbrains.jet.lang.resolve.java;
/**
* @author Stepan Koltsov
*/
public class JvmAbi {
public static final String TRAIT_IMPL_SUFFIX = "$$TImpl";
public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default";
}
@@ -5,7 +5,7 @@ import org.objectweb.asm.Type;
/**
* @author Stepan Koltsov
*/
public class StdlibNames {
public class JvmStdlibNames {
public static final JvmClassName JET_VALUE_PARAMETER = new JvmClassName("jet.typeinfo.JetValueParameter");
@@ -36,6 +36,6 @@ public class StdlibNames {
public static final JvmClassName JET_OBJECT = new JvmClassName("jet.JetObject");
private StdlibNames() {
private JvmStdlibNames() {
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
namespace jet
package jet
namespace typeinfo {
package typeinfo {
class TypeInfo<out T> {
fun isSubtypeOf(other : TypeInfo<*>) : Boolean
fun isInstance(obj : Any?) : Boolean
@@ -10,7 +10,7 @@ namespace typeinfo {
fun typeinfo<T>(expression : T) : TypeInfo<T>
}
namespace io {
package io {
fun print(message : Any?)
fun print(message : Int)
fun print(message : Long)
@@ -34,7 +34,7 @@ namespace io {
fun readLine() : String?
}
fun <R> Any.synchronized(block : fun() : R) : R
fun <R> Any.synchronized(block : () -> R) : R
fun Any?.identityEquals(other : Any?) : Boolean // = this === other
@@ -139,7 +139,7 @@ trait CharIterable : Iterable<Char> {
fun Array<T>(val size : Int) : Array<T?>
class Array<T>(val size : Int, init : fun(Int) : T) {
class Array<T>(val size : Int, init : (Int) -> T) {
fun get(index : Int) : T
fun set(index : Int, value : T) : Unit
@@ -2,6 +2,7 @@ package org.jetbrains.jet;
import com.intellij.core.JavaCoreEnvironment;
import com.intellij.lang.java.JavaParserDefinition;
import com.intellij.mock.MockApplication;
import com.intellij.openapi.Disposable;
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
import org.jetbrains.jet.plugin.JetFileType;
@@ -19,4 +20,8 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
registerParserDefinition(new JavaParserDefinition());
registerParserDefinition(new JetParserDefinition());
}
public MockApplication getApplication() {
return myApplication;
}
}
@@ -18,7 +18,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
*/
public class JetExpressionParsing extends AbstractJetParsing {
private static final TokenSet WHEN_CONDITION_RECOVERY_SET = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD);
private static final TokenSet WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD, DOUBLE_ARROW, DOT);
private static final TokenSet WHEN_CONDITION_RECOVERY_SET_WITH_ARROW = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD, ARROW, DOT);
private static final ImmutableMap<String, JetToken> KEYWORD_TEXTS = tokenSetToMap(KEYWORDS);
@@ -38,8 +38,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
CONTINUE_KEYWORD, OBJECT_KEYWORD, IF_KEYWORD, TRY_KEYWORD, ELSE_KEYWORD, WHILE_KEYWORD, DO_KEYWORD,
WHEN_KEYWORD, RBRACKET, RBRACE, RPAR, PLUSPLUS, MINUSMINUS, MUL, PLUS, MINUS, EXCL, DIV, PERC, LTEQ,
// TODO GTEQ, foo<bar, baz>=x
EQEQEQ, ARROW, DOUBLE_ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS,
SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, NOT_IN, NOT_IS, HASH,
EQEQEQ, ARROW, ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS,
SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, NOT_IN, NOT_IS, //HASH,
COLON
);
@@ -49,6 +49,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
// Atomic
LPAR, // parenthesized
HASH, // Tuple
// literal constant
TRUE_KEYWORD, FALSE_KEYWORD,
@@ -100,13 +101,14 @@ public class JetExpressionParsing extends AbstractJetParsing {
);
/*package*/ static final TokenSet EXPRESSION_FOLLOW = TokenSet.create(
SEMICOLON, DOUBLE_ARROW, COMMA, RBRACE, RPAR, RBRACKET
SEMICOLON, ARROW, COMMA, RBRACE, RPAR, RBRACKET
);
@SuppressWarnings({"UnusedDeclaration"})
private enum Precedence {
POSTFIX(PLUSPLUS, MINUSMINUS,
HASH, DOT, SAFE_ACCESS, QUEST), // typeArguments? valueArguments : typeArguments : arrayAccess
// HASH,
DOT, SAFE_ACCESS, QUEST), // typeArguments? valueArguments : typeArguments : arrayAccess
PREFIX(MINUS, PLUS, MINUSMINUS, PLUSPLUS, EXCL, LABEL_IDENTIFIER, AT, ATAT) { // attributes
@@ -150,7 +152,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
EQUALITY(EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ),
CONJUNCTION(ANDAND),
DISJUNCTION(OROR),
ARROW(JetTokens.ARROW),
// ARROW(JetTokens.ARROW),
ASSIGNMENT(EQ, PLUSEQ, MINUSEQ, MULTEQ, DIVEQ, PERCEQ),
;
@@ -374,13 +376,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
expression.done(PREDICATE_EXPRESSION);
}
else if (at(HASH)) {
advance(); // HASH
expect(IDENTIFIER, "Expecting property or function name");
expression.done(HASH_QUALIFIED_EXPRESSION);
}
// else if (at(HASH)) {
// advance(); // HASH
//
// expect(IDENTIFIER, "Expecting property or function name");
//
// expression.done(HASH_QUALIFIED_EXPRESSION);
// }
else if (atSet(Precedence.POSTFIX.getOperations())) {
parseOperationReference();
expression.done(POSTFIX_EXPRESSION);
@@ -502,7 +504,10 @@ public class JetExpressionParsing extends AbstractJetParsing {
// System.out.println("atom at " + myBuilder.getTokenText());
if (at(LPAR)) {
parseParenthesizedExpressionOrTuple();
parseParenthesizedExpression();
}
else if (at(HASH)) {
parseTupleExpression();
}
else if (at(NAMESPACE_KEYWORD)) {
parseOneTokenExpression(ROOT_NAMESPACE);
@@ -756,13 +761,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (at(ELSE_KEYWORD)) {
advance(); // ELSE_KEYWORD
if (!at(DOUBLE_ARROW)) {
errorUntil("Expecting '=>'", TokenSet.create(DOUBLE_ARROW,
if (!at(ARROW)) {
errorUntil("Expecting '=>'", TokenSet.create(ARROW,
RBRACE, EOL_OR_SEMICOLON));
}
if (at(DOUBLE_ARROW)) {
advance(); // DOUBLE_ARROW
if (at(ARROW)) {
advance(); // ARROW
if (atSet(WHEN_CONDITION_RECOVERY_SET)) {
error("Expecting an element");
@@ -790,7 +795,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (!at(COMMA)) break;
advance(); // COMMA
}
expect(DOUBLE_ARROW, "Expecting '=>' or 'when'", WHEN_CONDITION_RECOVERY_SET);
expect(ARROW, "Expecting '->' or 'when'", WHEN_CONDITION_RECOVERY_SET);
if (atSet(WHEN_CONDITION_RECOVERY_SET)) {
error("Expecting an element");
} else {
@@ -815,7 +820,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
mark.done(OPERATION_REFERENCE);
if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) {
if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_ARROW)) {
error("Expecting an element");
} else {
parseExpression();
@@ -824,7 +829,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
} else if (at(IS_KEYWORD) || at(NOT_IS)) {
advance(); // IS_KEYWORD or NOT_IS
if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) {
if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_ARROW)) {
error("Expecting a type or a decomposer pattern");
} else {
parsePattern();
@@ -832,7 +837,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
condition.done(WHEN_CONDITION_IS_PATTERN);
} else {
PsiBuilder.Marker expressionPattern = mark();
if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) {
if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_ARROW)) {
error("Expecting an expression, is-condition or in-condition");
} else {
parseExpression();
@@ -863,9 +868,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (at(NAMESPACE_KEYWORD) || at(IDENTIFIER) || at(FUN_KEYWORD) || at(THIS_KEYWORD)) {
PsiBuilder.Marker rollbackMarker = mark();
parseBinaryExpression(Precedence.ELVIS);
if (at(AT)) {
if (at(HASH)) {
rollbackMarker.drop();
advance(); // AT
PsiBuilder.Marker list = mark();
parseTuplePattern(DECOMPOSER_ARGUMENT);
list.done(DECOMPOSER_ARGUMENT_LIST);
@@ -877,9 +881,9 @@ public class JetExpressionParsing extends AbstractJetParsing {
rollbackMarker = mark();
myJetParsing.parseTypeRef();
if (at(AT)) {
errorAndAdvance("'@' is allowed only after a decomposer element, not after a type");
}
// if (at(AT)) {
// errorAndAdvance("'@' is allowed only after a decomposer element, not after a type");
// }
if (myBuilder.getCurrentOffset() < expressionEndOffset) {
rollbackMarker.rollbackTo();
parseBinaryExpression(Precedence.ELVIS);
@@ -889,7 +893,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
pattern.done(TYPE_PATTERN);
}
}
} else if (at(LPAR)) {
} else if (at(HASH)) {
parseTuplePattern(TUPLE_PATTERN_ENTRY);
pattern.done(TUPLE_PATTERN);
}
@@ -905,20 +909,21 @@ public class JetExpressionParsing extends AbstractJetParsing {
} else if (parseLiteralConstant()) {
pattern.done(EXPRESSION_PATTERN);
} else {
errorUntil("Pattern expected", TokenSet.create(RBRACE, DOUBLE_ARROW));
errorUntil("Pattern expected", TokenSet.create(RBRACE, ARROW));
pattern.drop();
}
}
/*
* tuplePattern
* : "(" ((SimpleName "=")? pattern){","}? ")"
* : "#" "(" ((SimpleName "=")? pattern){","}? ")"
* ;
*/
private void parseTuplePattern(JetNodeType entryType) {
myBuilder.disableNewlines();
expect(LPAR, "Expecting '('", getDecomposerExpressionFollow());
expect(HASH, "Expecting a tuple pattern of the form '#(...)'", getDecomposerExpressionFollow());
expect(LPAR, "Expecting a tuple pattern of the form '#(...)'", getDecomposerExpressionFollow());
if (!at(RPAR)) {
while (true) {
@@ -1059,8 +1064,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
/*
* functionLiteral // one can use "it" as a parameter name
* : "{" expressions "}"
* : "{" (modifiers SimpleName){","} "=>" statements "}"
* : "{" (type ".")? "(" (modifiers SimpleName (":" type)?){","} ")" (":" type)? "=>" expressions "}"
* : "{" (modifiers SimpleName){","} "->" statements "}"
* : "{" (type ".")? "(" (modifiers SimpleName (":" type)?){","} ")" (":" type)? "->" expressions "}"
* ;
*/
private void parseFunctionLiteral() {
@@ -1077,83 +1082,112 @@ public class JetExpressionParsing extends AbstractJetParsing {
myBuilder.enableNewlines();
advance(); // LBRACE
int doubleArrowPos = matchTokenStreamPredicate(new FirstBefore(new At(DOUBLE_ARROW), new At(RBRACE)) {
@Override
public boolean isTopLevel(int openAngleBrackets, int openBrackets, int openBraces, int openParentheses) {
return openBraces == 0;
boolean paramsFound = false;
if (at(ARROW)) {
// { -> ...}
advance(); // ARROW
mark().done(VALUE_PARAMETER_LIST);
paramsFound = true;
}
else if (at(LPAR)) {
// Look for ARROW after matching RPAR
// {(a, b) -> ...}
{
PsiBuilder.Marker rollbackMarker = mark();
parseFunctionLiteralParametersAndType();
paramsFound = rollbackOrDropAt(rollbackMarker, ARROW);
}
});
boolean doubleArrowPresent = doubleArrowPos >= 0;
if (doubleArrowPresent) {
boolean dontExpectParameters = false;
int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtOffset(doubleArrowPos)));
if (lastDot >= 0) { // There is a receiver type
createTruncatedBuilder(lastDot).parseTypeRef();
expect(DOT, "Expecting '.'");
if (!at(LPAR)) {
int firstLParPos = matchTokenStreamPredicate(new FirstBefore(new At(LPAR), new AtOffset(doubleArrowPos)));
if (firstLParPos >= 0) {
errorUntilOffset("Expecting '('", firstLParPos);
} else {
errorUntilOffset("To specify a receiver type, use the full notation: {ReceiverType.(parameters) [: ReturnType] => ...}",
doubleArrowPos);
dontExpectParameters = true;
if (!paramsFound) {
// If not found, try a typeRef DOT and then LPAR .. RPAR ARROW
// {((A) -> B).(x) -> ... }
PsiBuilder.Marker rollbackMarker = mark();
int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtSet(ARROW, RPAR)));
if (lastDot >= 0) {
createTruncatedBuilder(lastDot).parseTypeRef();
if (at(DOT)) {
advance(); // DOT
parseFunctionLiteralParametersAndType();
}
}
paramsFound = rollbackOrDropAt(rollbackMarker, ARROW);
}
if (at(LPAR)) {
parseFunctionLiteralParameterList();
if (at(COLON)) {
advance(); // COLON
if (at(DOUBLE_ARROW)) {
error("Expecting a type");
}
else {
myJetParsing.parseTypeRef();
}
}
}
else if (!dontExpectParameters) {
PsiBuilder.Marker parameterList = mark();
while (!eof()) {
PsiBuilder.Marker parameter = mark();
int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos)));
createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false);
expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(DOUBLE_ARROW));
parameter.done(VALUE_PARAMETER);
if (at(COLON)) {
errorUntilOffset("To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...}", doubleArrowPos);
}
else if (at(DOUBLE_ARROW)) {
break;
}
else if (!at(COMMA)) {
errorUntilOffset("Expecting '=>' or ','", doubleArrowPos);
}
else {
advance(); // COMMA
}
}
parameterList.done(VALUE_PARAMETER_LIST);
}
expectNoAdvance(DOUBLE_ARROW, "Expecting '=>'");
}
else {
if (at(IDENTIFIER)) {
// Try to parse a simple name list followed by an ARROW
// {a -> ...}
// {a, b -> ...}
PsiBuilder.Marker rollbackMarker = mark();
parseFunctionLiteralShorthandParameterList();
parseOptionalFunctionLiteralType();
paramsFound = rollbackOrDropAt(rollbackMarker, ARROW);
}
if (!paramsFound && atSet(JetParsing.TYPE_REF_FIRST)) {
// Try to parse a type DOT valueParameterList ARROW
// {A.(b) -> ...}
PsiBuilder.Marker rollbackMarker = mark();
int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtSet(ARROW, RBRACE)));
if (lastDot >= 0) { // There is a receiver type
createTruncatedBuilder(lastDot).parseTypeRef();
}
if (at(DOT)) {
advance(); // DOT
parseFunctionLiteralParametersAndType();
paramsFound = rollbackOrDropAt(rollbackMarker, ARROW);
}
else {
rollbackMarker.rollbackTo();
}
}
// int doubleArrowPos = matchTokenStreamPredicate(new FirstBefore(new At(ARROW), new At(RBRACE)) {
// @Override
// public boolean isTopLevel(int openAngleBrackets, int openBrackets, int openBraces, int openParentheses) {
// return openBraces == 0;
// }
// });
//
// boolean doubleArrowPresent = doubleArrowPos >= 0;
// if (doubleArrowPresent) {
// boolean dontExpectParameters = false;
//
// int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtOffset(doubleArrowPos)));
// if (lastDot >= 0) { // There is a receiver type
// createTruncatedBuilder(lastDot).parseTypeRef();
//
// expect(DOT, "Expecting '.'");
//
// if (!at(LPAR)) {
// int firstLParPos = matchTokenStreamPredicate(new FirstBefore(new At(LPAR), new AtOffset(doubleArrowPos)));
//
// if (firstLParPos >= 0) {
// errorUntilOffset("Expecting '('", firstLParPos);
// } else {
// errorUntilOffset("To specify a receiver type, use the full notation: {ReceiverType.(parameters) [: ReturnType] => ...}",
// doubleArrowPos);
// dontExpectParameters = true;
// }
// }
//
// }
//
// if (at(LPAR)) {
// parseFunctionLiteralParametersAndType();
// }
// else if (!dontExpectParameters) {
// parseFunctionLiteralShorthandParameterList();
// }
//
// expectNoAdvance(ARROW, "Expecting '=>'");
// }
}
if (!paramsFound) {
if (preferBlock) {
literal.drop();
parseStatements();
@@ -1175,12 +1209,80 @@ public class JetExpressionParsing extends AbstractJetParsing {
literalExpression.done(FUNCTION_LITERAL_EXPRESSION);
}
private boolean rollbackOrDropAt(PsiBuilder.Marker rollbackMarker, IElementType dropAt) {
if (at(dropAt)) {
advance(); // dropAt
rollbackMarker.drop();
return true;
}
rollbackMarker.rollbackTo();
return false;
}
/*
* SimpleName{,}
*/
private void parseFunctionLiteralShorthandParameterList() {
PsiBuilder.Marker parameterList = mark();
while (!eof()) {
PsiBuilder.Marker parameter = mark();
// int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos)));
// createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false);
expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(ARROW));
parameter.done(VALUE_PARAMETER);
if (at(COLON)) {
PsiBuilder.Marker errorMarker = mark();
advance(); // COLON
myJetParsing.parseTypeRef();
errorMarker.error("To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...}");
}
else if (at(ARROW)) {
break;
}
else if (at(COMMA)) {
advance(); // COMMA
}
else {
error("Expecting '->' or ','");
break;
}
}
parameterList.done(VALUE_PARAMETER_LIST);
}
private void parseFunctionLiteralParametersAndType() {
parseFunctionLiteralParameterList();
parseOptionalFunctionLiteralType();
}
/*
* (":" type)?
*/
private void parseOptionalFunctionLiteralType() {
if (at(COLON)) {
advance(); // COLON
if (at(ARROW)) {
error("Expecting a type");
}
else {
myJetParsing.parseTypeRef();
}
}
}
/*
* "(" (modifiers SimpleName (":" type)?){","} ")"
*/
private void parseFunctionLiteralParameterList() {
PsiBuilder.Marker list = mark();
expect(LPAR, "Expecting a parameter list in parentheses (...)", TokenSet.create(DOUBLE_ARROW, COLON));
expect(LPAR, "Expecting a parameter list in parentheses (...)", TokenSet.create(ARROW, COLON));
myBuilder.disableNewlines();
@@ -1189,7 +1291,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (at(COMMA)) errorAndAdvance("Expecting a parameter declaration");
PsiBuilder.Marker parameter = mark();
int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtSet(COMMA, RPAR, COLON, DOUBLE_ARROW)));
int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtSet(COMMA, RPAR, COLON, ARROW)));
createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false);
expect(IDENTIFIER, "Expecting parameter declaration");
@@ -1211,7 +1313,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
myBuilder.restoreNewlinesState();
expect(RPAR, "Expecting ')", TokenSet.create(DOUBLE_ARROW, COLON));
expect(RPAR, "Expecting ')", TokenSet.create(ARROW, COLON));
list.done(VALUE_PARAMETER_LIST);
}
@@ -1567,29 +1669,43 @@ public class JetExpressionParsing extends AbstractJetParsing {
}
/*
* tupleLiteral // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an element in parentheses
* // to put a tuple, write write ((e))
* : "(" ((SimpleName "=")? element){","} ")"
* ;
*
* element
* : "(" element ")"
* ;
*
* TODO: duplication with valueArguments (but for the error messages)
* "(" expression ")"
*/
private void parseParenthesizedExpressionOrTuple() {
private void parseParenthesizedExpression() {
assert _at(LPAR);
PsiBuilder.Marker mark = mark();
myBuilder.disableNewlines();
advance(); // LPAR
boolean tuple = false;
if (at(RPAR)) {
error("Expecting an expression");
}
else {
parseExpression();
}
expect(RPAR, "Expecting ')'");
myBuilder.restoreNewlinesState();
mark.done(PARENTHESIZED);
}
/*
* tupleLiteral
* : "#" "(" (((SimpleName "=")? expression){","})? ")"
* ;
*/
private void parseTupleExpression() {
assert _at(HASH);
PsiBuilder.Marker mark = mark();
advance(); // HASH
advance(); // LPAR
myBuilder.disableNewlines();
if (!at(RPAR)) {
while (true) {
while (at(COMMA)) {
tuple = true;
errorAndAdvance("Expecting a tuple entry (element)");
}
@@ -1597,7 +1713,6 @@ public class JetExpressionParsing extends AbstractJetParsing {
PsiBuilder.Marker entry = mark();
advance(); // IDENTIFIER
advance(); // EQ
tuple = true;
parseExpression();
entry.done(LABELED_TUPLE_ENTRY);
} else {
@@ -1606,21 +1721,18 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (!at(COMMA)) break;
advance(); // COMMA
tuple = true;
if (at(RPAR)) {
error("Expecting a tuple entry (element)");
break;
}
}
} else {
tuple = true;
}
}
expect(RPAR, "Expecting ')'");
myBuilder.restoreNewlinesState();
mark.done(tuple ? TUPLE : PARENTHESIZED);
mark.done(TUPLE);
}
/*
@@ -37,7 +37,7 @@ public class JetParsing extends AbstractJetParsing {
private static final TokenSet TYPE_PARAMETER_GT_RECOVERY_SET = TokenSet.create(WHERE_KEYWORD, LPAR, COLON, LBRACE, GT);
private static final TokenSet PARAMETER_NAME_RECOVERY_SET = TokenSet.create(COLON, EQ, COMMA, RPAR);
private static final TokenSet NAMESPACE_NAME_RECOVERY_SET = TokenSet.create(DOT, EOL_OR_SEMICOLON);
/*package*/ static final TokenSet TYPE_REF_FIRST = TokenSet.create(LBRACKET, IDENTIFIER, FUN_KEYWORD, LPAR, CAPITALIZED_THIS_KEYWORD);
/*package*/ static final TokenSet TYPE_REF_FIRST = TokenSet.create(LBRACKET, IDENTIFIER, FUN_KEYWORD, LPAR, CAPITALIZED_THIS_KEYWORD, HASH);
private static final TokenSet RECEIVER_TYPE_TERMINATORS = TokenSet.create(DOT, SAFE_ACCESS);
public static JetParsing createForTopLevel(SemanticWhitespaceAwarePsiBuilder builder) {
@@ -826,12 +826,12 @@ public class JetParsing extends AbstractJetParsing {
boolean typeParametersDeclared = at(LT) ? parseTypeParameterList(TokenSet.create(IDENTIFIER, EQ, COLON, SEMICOLON)) : false;
TokenSet propertyNameFollow = TokenSet.create(COLON, EQ, LBRACE, SEMICOLON);
TokenSet propertyNameFollow = TokenSet.create(COLON, EQ, LBRACE, SEMICOLON, VAL_KEYWORD, VAR_KEYWORD, FUN_KEYWORD, CLASS_KEYWORD);
myBuilder.disableJoiningComplexTokens();
// TODO: extract constant
int lastDot = matchTokenStreamPredicate(new FirstBefore(
int lastDot = matchTokenStreamPredicate(new LastBefore(
new AtSet(DOT, SAFE_ACCESS),
new AbstractTokenStreamPredicate() {
@Override
@@ -847,7 +847,7 @@ public class JetParsing extends AbstractJetParsing {
parseReceiverType("property", propertyNameFollow, lastDot);
myBuilder.enableJoiningComplexTokens();
myBuilder.restoreJoiningComplexTokensState();
if (at(COLON)) {
advance(); // COLON
@@ -985,7 +985,7 @@ public class JetParsing extends AbstractJetParsing {
myBuilder.disableJoiningComplexTokens();
int lastDot = findLastBefore(RECEIVER_TYPE_TERMINATORS, TokenSet.create(LPAR), true);
parseReceiverType("function", TokenSet.create(LT, LPAR, COLON, EQ), lastDot);
myBuilder.enableJoiningComplexTokens();
myBuilder.restoreJoiningComplexTokensState();
TokenSet valueParametersFollow = TokenSet.create(COLON, EQ, LBRACE, SEMICOLON, RPAR);
@@ -1281,17 +1281,54 @@ public class JetParsing extends AbstractJetParsing {
* : typeDescriptor "?"
*/
public void parseTypeRef() {
PsiBuilder.Marker typeRefMarker = parseTypeRefContents();
typeRefMarker.done(TYPE_REFERENCE);
}
private PsiBuilder.Marker parseTypeRefContents() {
// Disabling token merge is required for cases like
// Int?.(Foo) -> Bar
// we don't support this case now
// myBuilder.disableJoiningComplexTokens();
PsiBuilder.Marker typeRefMarker = mark();
parseAnnotations(false);
if (at(IDENTIFIER) || at(NAMESPACE_KEYWORD)) {
parseUserType();
}
else if (at(FUN_KEYWORD)) {
parseFunctionType();
else if (at(HASH)) {
parseTupleType();
}
else if (at(LPAR)) {
parseTupleType();
PsiBuilder.Marker functionOrParenthesizedType = mark();
// This may be a function parameter list or just a prenthesized type
advance(); // LPAR
parseTypeRefContents().drop(); // parenthesized types, no reference element around it is needed
if (at(RPAR)) {
advance(); // RPAR
if (at(ARROW)) {
// It's a function type with one parameter specified
// (A) -> B
functionOrParenthesizedType.rollbackTo();
parseFunctionType();
}
else {
// It's a parenthesized type
// (A)
functionOrParenthesizedType.drop();
}
}
else {
// This must be a function type
// (A, B) -> C
// or
// (a : A) -> C
functionOrParenthesizedType.rollbackTo();
parseFunctionType();
}
}
else if (at(CAPITALIZED_THIS_KEYWORD)) {
parseSelfType();
@@ -1299,7 +1336,7 @@ public class JetParsing extends AbstractJetParsing {
else {
errorWithRecovery("Type expected",
TokenSet.orSet(TOPLEVEL_OBJECT_FIRST,
TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON)));
TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON)));
}
while (at(QUEST)) {
@@ -1310,20 +1347,29 @@ public class JetParsing extends AbstractJetParsing {
typeRefMarker = precede;
}
typeRefMarker.done(TYPE_REFERENCE);
}
/*
* selfType
* : "This"
* ;
*/
private void parseSelfType() {
assert _at(CAPITALIZED_THIS_KEYWORD);
if (at(DOT)) {
// This is a receiver for a function type
// A.(B) -> C
// ^
PsiBuilder.Marker type = mark();
advance(); // CAPITALIZED_THIS_KEYWORD
type.done(SELF_TYPE);
PsiBuilder.Marker precede = typeRefMarker.precede();
typeRefMarker.done(TYPE_REFERENCE);
advance(); // DOT
if (at(LPAR)) {
parseFunctionTypeContents().drop();
}
else {
error("Expecting function type");
}
typeRefMarker = precede.precede();
precede.done(FUNCTION_TYPE);
}
// myBuilder.restoreJoiningComplexTokensState();
return typeRefMarker;
}
/*
@@ -1341,13 +1387,18 @@ public class JetParsing extends AbstractJetParsing {
PsiBuilder.Marker reference = mark();
while (true) {
expect(IDENTIFIER, "Type name expected", TokenSet.orSet(JetExpressionParsing.EXPRESSION_FIRST, JetExpressionParsing.EXPRESSION_FOLLOW));
expect(IDENTIFIER, "Expecting type name", TokenSet.orSet(JetExpressionParsing.EXPRESSION_FIRST, JetExpressionParsing.EXPRESSION_FOLLOW));
reference.done(REFERENCE_EXPRESSION);
parseTypeArgumentList(-1);
if (!at(DOT)) {
break;
}
if (lookahead(1) == LPAR) {
// This may be a receiver for a function type
// Int.(Int) -> Int
break;
}
PsiBuilder.Marker precede = userType.precede();
userType.done(USER_TYPE);
@@ -1360,6 +1411,19 @@ public class JetParsing extends AbstractJetParsing {
userType.done(USER_TYPE);
}
/*
* selfType
* : "This"
* ;
*/
private void parseSelfType() {
assert _at(CAPITALIZED_THIS_KEYWORD);
PsiBuilder.Marker type = mark();
advance(); // CAPITALIZED_THIS_KEYWORD
type.done(SELF_TYPE);
}
/*
* (optionalProjection type){","}
*/
@@ -1410,18 +1474,18 @@ public class JetParsing extends AbstractJetParsing {
/*
* tupleType
* : "(" type{","}? ")"
* : "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility
* : "#" "(" type{","}? ")"
* : "#" "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility
* ;
*/
private void parseTupleType() {
// TODO : prohibit (a)
assert _at(LPAR);
assert _at(HASH);
PsiBuilder.Marker tuple = mark();
myBuilder.disableNewlines();
advance(); // LPAR
advance(); // HASH
expect(LPAR, "Expecting a tuple type in the form of '#(...)");
if (!at(RPAR)) {
while (true) {
@@ -1456,32 +1520,38 @@ public class JetParsing extends AbstractJetParsing {
/*
* functionType
* : "fun" (type ".")? "(" (parameter | modifiers type){","} ")" (":" type)? // Unit by default
* : (type ".")? "(" (parameter | modifiers type){","} ")" "->" type?
* ;
*/
private void parseFunctionType() {
assert _at(FUN_KEYWORD);
parseFunctionTypeContents().done(FUNCTION_TYPE);
}
private PsiBuilder.Marker parseFunctionTypeContents() {
// assert _at(LPAR) : tt();
if (!_at(LPAR))
System.out.println(myBuilder.getTokenText());
PsiBuilder.Marker functionType = mark();
advance(); // FUN_KEYWORD
int lastLPar = findLastBefore(TokenSet.create(LPAR), TokenSet.create(COLON), false);
if (lastLPar >= 0 && lastLPar > myBuilder.getCurrentOffset()) {
// TODO : -1 is a hack?
createTruncatedBuilder(lastLPar - 1).parseTypeRef();
advance(); // DOT
}
// advance(); // LPAR
//
// int lastLPar = findLastBefore(TokenSet.create(LPAR), TokenSet.create(COLON), false);
// if (lastLPar >= 0 && lastLPar > myBuilder.getCurrentOffset()) {
// TODO : -1 is a hack?
// createTruncatedBuilder(lastLPar - 1).parseTypeRef();
// advance(); // DOT
// }
parseValueParameterList(true, TokenSet.EMPTY);
if (at(COLON)) {
advance(); // COLON // expect(COLON, "Expecting ':' followed by a return type", TYPE_REF_FIRST);
// if (at(COLON)) {
// advance(); // COLON // expect(COLON, "Expecting ':' followed by a return type", TYPE_REF_FIRST);
parseTypeRef();
}
expect(ARROW, "Expecting '->' to specify return type of a function type", TYPE_REF_FIRST);
parseTypeRef();
// }
functionType.done(FUNCTION_TYPE);
return functionType;//.done(FUNCTION_TYPE);
}
/*
@@ -13,6 +13,7 @@ public interface SemanticWhitespaceAwarePsiBuilder extends PsiBuilder {
void enableNewlines();
void restoreNewlinesState();
void restoreJoiningComplexTokensState();
void enableJoiningComplexTokens();
void disableJoiningComplexTokens();
}
@@ -35,6 +35,11 @@ public class SemanticWhitespaceAwarePsiBuilderAdapter extends PsiBuilderAdapter
myBuilder.restoreNewlinesState();
}
@Override
public void restoreJoiningComplexTokensState() {
myBuilder.restoreJoiningComplexTokensState();
}
@Override
public void enableJoiningComplexTokens() {
myBuilder.enableJoiningComplexTokens();
@@ -16,11 +16,15 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
* @author abreslav
*/
public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder {
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS);
private final Stack<Boolean> joinComplexTokens = new Stack<Boolean>();
private final Stack<Boolean> newlinesEnabled = new Stack<Boolean>();
public SemanticWhitespaceAwarePsiBuilderImpl(final PsiBuilder delegate) {
super(delegate);
newlinesEnabled.push(true);
joinComplexTokens.push(true);
}
@Override
@@ -75,22 +79,28 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
newlinesEnabled.pop();
}
private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS);
private boolean joinComplexTokens = true;
private boolean joinComplexTokens() {
return joinComplexTokens.peek();
}
@Override
public void restoreJoiningComplexTokensState() {
joinComplexTokens.pop();
}
@Override
public void enableJoiningComplexTokens() {
joinComplexTokens = true;
joinComplexTokens.push(true);
}
@Override
public void disableJoiningComplexTokens() {
joinComplexTokens = false;
joinComplexTokens.push(false);
}
@Override
public IElementType getTokenType() {
if (!joinComplexTokens) return super.getTokenType();
if (!joinComplexTokens()) return super.getTokenType();
return getJoinedTokenType(super.getTokenType(), 1);
}
@@ -105,7 +115,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
@Override
public void advanceLexer() {
if (!joinComplexTokens) {
if (!joinComplexTokens()) {
super.advanceLexer();
return;
}
@@ -123,7 +133,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
@Override
public String getTokenText() {
if (!joinComplexTokens) return super.getTokenText();
if (!joinComplexTokens()) return super.getTokenText();
IElementType tokenType = getTokenType();
if (complexTokens.contains(tokenType)) {
if (tokenType == ELVIS) return "?:";
@@ -134,7 +144,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
@Override
public IElementType lookAhead(int steps) {
if (!joinComplexTokens) return super.lookAhead(steps);
if (!joinComplexTokens()) return super.lookAhead(steps);
if (complexTokens.contains(getTokenType())) {
return super.lookAhead(steps + 1);
@@ -30,7 +30,7 @@ public class JetFunctionLiteral extends JetFunction {
}
public boolean hasParameterSpecification() {
return findChildByType(JetTokens.DOUBLE_ARROW) != null;
return findChildByType(JetTokens.ARROW) != null;
}
@Override
@@ -51,6 +51,6 @@ public class JetFunctionLiteral extends JetFunction {
@Nullable
public ASTNode getArrowNode() {
return getNode().findChildByType(JetTokens.DOUBLE_ARROW);
return getNode().findChildByType(JetTokens.ARROW);
}
}
@@ -7,6 +7,7 @@ import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.jet.lexer.JetToken;
import org.jetbrains.jet.lexer.JetTokens;
import java.util.ArrayList;
@@ -17,6 +18,9 @@ import java.util.List;
* @author max
*/
public class JetFunctionType extends JetTypeElement {
public static final JetToken RETURN_TYPE_SEPARATOR = JetTokens.ARROW;
public JetFunctionType(@NotNull ASTNode node) {
super(node);
}
@@ -65,7 +69,7 @@ public class JetFunctionType extends JetTypeElement {
PsiElement child = getFirstChild();
while (child != null) {
IElementType tt = child.getNode().getElementType();
if (tt == JetTokens.LPAR || tt == JetTokens.COLON) break;
if (tt == JetTokens.LPAR || tt == RETURN_TYPE_SEPARATOR) break;
if (child instanceof JetTypeReference) {
return (JetTypeReference) child;
}
@@ -81,7 +85,7 @@ public class JetFunctionType extends JetTypeElement {
PsiElement child = getFirstChild();
while (child != null) {
IElementType tt = child.getNode().getElementType();
if (tt == JetTokens.COLON) {
if (tt == RETURN_TYPE_SEPARATOR) {
colonPassed = true;
}
if (colonPassed && child instanceof JetTypeReference) {
@@ -19,6 +19,7 @@ import java.util.Collections;
import java.util.List;
import static org.jetbrains.jet.lang.diagnostics.Errors.UNRESOLVED_REFERENCE;
import static org.jetbrains.jet.lang.diagnostics.Errors.UNSUPPORTED;
import static org.jetbrains.jet.lang.diagnostics.Errors.WRONG_NUMBER_OF_TYPE_ARGUMENTS;
import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
@@ -173,13 +174,17 @@ public class TypeResolver {
@Override
public void visitJetElement(JetElement element) {
throw new IllegalArgumentException("Unsupported type: " + element);
trace.report(UNSUPPORTED.on(element, "Self-types are not supported yet"));
// throw new IllegalArgumentException("Unsupported type: " + element);
}
});
}
if (result[0] == null) {
return ErrorUtils.createErrorType(typeElement == null ? "No type element" : typeElement.getText());
}
if (nullable) {
return TypeUtils.makeNullable(result[0]);
}
return result[0];
}
@@ -161,8 +161,8 @@ LONG_TEMPLATE_ENTRY_END=\}
// TODO: Decide what to do with """ ... """"
{RAW_STRING_LITERAL} { return JetTokens.RAW_STRING_LITERAL; }
"namespace" { return JetTokens.NAMESPACE_KEYWORD ;}
"continue" { return JetTokens.CONTINUE_KEYWORD ;}
"package" { return JetTokens.NAMESPACE_KEYWORD ;}
"return" { return JetTokens.RETURN_KEYWORD ;}
"object" { return JetTokens.OBJECT_KEYWORD ;}
"while" { return JetTokens.WHILE_KEYWORD ;}
@@ -170,12 +170,14 @@ public interface JetTokens {
TokenSet STRINGS = TokenSet.create(CHARACTER_LITERAL, REGULAR_STRING_PART, RAW_STRING_LITERAL);
TokenSet OPERATIONS = TokenSet.create(AS_KEYWORD, AS_SAFE, IS_KEYWORD, IN_KEYWORD, DOT, PLUSPLUS, MINUSMINUS, MUL, PLUS,
MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR,
MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR,
SAFE_ACCESS, ELVIS,
// MAP, FILTER,
QUEST, COLON,
RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
NOT_IN, NOT_IS, HASH, IDENTIFIER, LABEL_IDENTIFIER, ATAT, AT);
NOT_IN, NOT_IS,
// HASH,
IDENTIFIER, LABEL_IDENTIFIER, ATAT, AT);
TokenSet AUGMENTED_ASSIGNMENTS = TokenSet.create(PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ);
}
@@ -1,4 +1,4 @@
/* The following code was generated by JFlex 1.4.3 on 12/15/11 8:19 PM */
/* The following code was generated by JFlex 1.4.3 on 12/25/11 2:36 PM */
package org.jetbrains.jet.lexer;
@@ -13,8 +13,8 @@ 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 12/15/11 8:19 PM from the specification file
* <tt>/Users/abreslav/work/jet-clean/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex</tt>
* on 12/25/11 2:36 PM from the specification file
* <tt>/Users/abreslav/work/jet/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex</tt>
*/
class _JetLexer implements FlexLexer {
/** initial size of the lookahead buffer */
@@ -44,10 +44,10 @@ class _JetLexer implements FlexLexer {
"\1\10\1\67\1\65\1\23\1\72\1\73\1\13\1\62\1\76\1\21"+
"\1\17\1\12\1\14\11\1\1\74\1\75\1\63\1\60\1\64\1\61"+
"\1\11\1\2\1\16\2\2\1\20\1\2\11\4\1\22\3\4\1\54"+
"\3\4\1\15\2\4\1\70\1\24\1\71\1\0\1\4\1\6\1\36"+
"\1\45\1\42\1\56\1\40\1\52\1\4\1\32\1\33\1\46\1\51"+
"\1\50\1\37\1\35\1\43\1\41\1\4\1\44\1\34\1\31\1\26"+
"\1\55\1\47\1\15\1\53\1\4\1\27\1\66\1\30\54\0\1\4"+
"\3\4\1\15\2\4\1\70\1\24\1\71\1\0\1\4\1\6\1\42"+
"\1\46\1\35\1\56\1\40\1\52\1\44\1\32\1\33\1\47\1\43"+
"\1\51\1\4\1\37\1\36\1\41\1\4\1\45\1\34\1\31\1\26"+
"\1\55\1\50\1\15\1\53\1\4\1\27\1\66\1\30\54\0\1\4"+
"\12\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0\u013f\4"+
"\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\213\0\1\4"+
"\13\0\1\4\1\0\3\4\1\0\1\4\1\0\24\4\1\0\54\4"+
@@ -121,27 +121,27 @@ class _JetLexer implements FlexLexer {
private static final String ZZ_ACTION_PACKED_0 =
"\4\0\1\1\1\2\1\3\1\4\2\1\1\5\1\6"+
"\1\7\1\2\1\10\1\11\1\12\1\13\1\14\1\15"+
"\17\3\1\16\1\17\1\20\1\21\1\22\1\23\2\1"+
"\20\3\1\16\1\17\1\20\1\21\1\22\1\23\2\1"+
"\1\24\1\25\1\26\1\27\1\30\1\31\1\32\1\33"+
"\1\34\1\35\1\36\1\35\1\0\1\37\1\40\1\0"+
"\1\40\1\41\1\42\1\0\1\43\1\0\1\44\1\0"+
"\1\45\1\0\1\46\1\47\1\50\1\51\1\52\1\43"+
"\2\2\1\43\1\53\1\54\1\55\1\56\2\12\1\0"+
"\3\3\1\57\1\60\1\61\3\3\1\62\14\3\1\63"+
"\3\3\1\57\1\60\1\61\7\3\1\62\10\3\1\63"+
"\1\0\1\64\1\65\1\66\1\67\1\70\1\71\1\72"+
"\1\73\1\74\1\75\1\76\1\0\1\77\2\100\1\0"+
"\1\40\1\101\1\43\1\3\2\0\1\50\1\102\4\0"+
"\1\103\4\3\1\104\4\3\1\105\10\3\1\106\1\3"+
"\1\107\1\3\1\110\1\111\1\112\1\113\1\114\1\115"+
"\2\0\2\40\1\44\1\45\1\0\2\102\1\43\2\0"+
"\1\116\1\3\1\117\1\3\1\120\1\3\1\121\1\3"+
"\1\122\6\3\1\123\1\3\1\124\1\125\1\76\1\0"+
"\1\126\1\50\2\0\1\127\1\130\1\131\2\3\1\132"+
"\2\3\1\133\1\134\1\135\1\0\1\103\2\3\1\136"+
"\1\137\3\3\1\140\1\141";
"\1\103\4\3\1\104\10\3\1\105\4\3\1\106\1\107"+
"\2\3\1\110\1\111\1\112\1\113\1\114\1\115\2\0"+
"\2\40\1\44\1\45\1\0\2\102\1\43\2\0\1\116"+
"\1\3\1\117\1\3\1\120\4\3\1\121\1\122\4\3"+
"\1\123\1\3\1\124\1\125\1\76\1\0\1\126\1\50"+
"\2\0\1\127\1\130\1\131\1\3\1\132\3\3\1\133"+
"\1\134\1\135\1\0\1\103\1\3\1\136\1\3\1\137"+
"\1\3\1\140\1\141";
private static int [] zzUnpackAction() {
int [] result = new int[225];
int [] result = new int[224];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -170,34 +170,33 @@ class _JetLexer implements FlexLexer {
"\0\u0200\0\u0240\0\u0280\0\u02c0\0\u0300\0\u0340\0\u0380\0\u03c0"+
"\0\u0400\0\u0440\0\u0100\0\u0100\0\u0480\0\u04c0\0\u0500\0\u0540"+
"\0\u0580\0\u05c0\0\u0600\0\u0640\0\u0680\0\u06c0\0\u0700\0\u0740"+
"\0\u0780\0\u07c0\0\u0800\0\u0840\0\u0880\0\u0100\0\u08c0\0\u0900"+
"\0\u0940\0\u0980\0\u09c0\0\u0a00\0\u0100\0\u0100\0\u0100\0\u0100"+
"\0\u0100\0\u0100\0\u0100\0\u0100\0\u0a40\0\u0100\0\u0a80\0\u0ac0"+
"\0\u0100\0\u0b00\0\u0b40\0\u0b80\0\u0100\0\u0100\0\u0bc0\0\u0c00"+
"\0\u0c40\0\u0c80\0\u0cc0\0\u0d00\0\u0d40\0\u0100\0\u0d80\0\u0dc0"+
"\0\u0100\0\u0100\0\u0e00\0\u0e40\0\u0e80\0\u0ec0\0\u0100\0\u0100"+
"\0\u0100\0\u0100\0\u0100\0\u0f00\0\u0f40\0\u0f80\0\u0fc0\0\u1000"+
"\0\u0180\0\u0180\0\u0180\0\u1040\0\u1080\0\u10c0\0\u1100\0\u1140"+
"\0\u0780\0\u07c0\0\u0800\0\u0840\0\u0880\0\u08c0\0\u0100\0\u0900"+
"\0\u0940\0\u0980\0\u09c0\0\u0a00\0\u0a40\0\u0100\0\u0100\0\u0100"+
"\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0a80\0\u0100\0\u0ac0"+
"\0\u0b00\0\u0100\0\u0b40\0\u0b80\0\u0bc0\0\u0100\0\u0100\0\u0c00"+
"\0\u0c40\0\u0c80\0\u0cc0\0\u0d00\0\u0d40\0\u0d80\0\u0100\0\u0dc0"+
"\0\u0e00\0\u0100\0\u0100\0\u0e40\0\u0e80\0\u0ec0\0\u0f00\0\u0100"+
"\0\u0100\0\u0100\0\u0100\0\u0100\0\u0f40\0\u0f80\0\u0fc0\0\u1000"+
"\0\u1040\0\u0180\0\u0180\0\u0180\0\u1080\0\u10c0\0\u1100\0\u1140"+
"\0\u1180\0\u11c0\0\u1200\0\u1240\0\u1280\0\u12c0\0\u1300\0\u1340"+
"\0\u1380\0\u13c0\0\u1400\0\u0180\0\u1440\0\u1480\0\u14c0\0\u0100"+
"\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u1500"+
"\0\u1540\0\u0100\0\u0100\0\u1580\0\u15c0\0\u1600\0\u0100\0\u1640"+
"\0\u0100\0\u1680\0\u16c0\0\u1700\0\u1740\0\u1780\0\u17c0\0\u1800"+
"\0\u1840\0\u1880\0\u18c0\0\u1900\0\u1940\0\u1980\0\u0180\0\u19c0"+
"\0\u1a00\0\u1a40\0\u1a80\0\u0100\0\u1ac0\0\u1b00\0\u1b40\0\u1b80"+
"\0\u1bc0\0\u1c00\0\u1c40\0\u1c80\0\u0180\0\u1cc0\0\u0180\0\u1d00"+
"\0\u0180\0\u0180\0\u1d40\0\u1d40\0\u0100\0\u0100\0\u1d80\0\u1dc0"+
"\0\u0100\0\u1e00\0\u0100\0\u0100\0\u1e40\0\u1e80\0\u0100\0\u1ec0"+
"\0\u1640\0\u1f00\0\u0180\0\u1f40\0\u0180\0\u1f80\0\u0180\0\u1fc0"+
"\0\u0180\0\u2000\0\u0180\0\u2040\0\u2080\0\u20c0\0\u2100\0\u2140"+
"\0\u2180\0\u0180\0\u21c0\0\u0180\0\u0100\0\u0100\0\u2200\0\u0b00"+
"\0\u0100\0\u2240\0\u2280\0\u0180\0\u0180\0\u0180\0\u22c0\0\u2300"+
"\0\u0180\0\u2340\0\u2380\0\u0180\0\u0180\0\u0180\0\u23c0\0\u0100"+
"\0\u2400\0\u2440\0\u0180\0\u0180\0\u2480\0\u24c0\0\u2500\0\u0180"+
"\0\u0180";
"\0\u1380\0\u13c0\0\u1400\0\u1440\0\u0180\0\u1480\0\u14c0\0\u1500"+
"\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100"+
"\0\u1540\0\u1580\0\u0100\0\u0100\0\u15c0\0\u1600\0\u1640\0\u0100"+
"\0\u1680\0\u0100\0\u16c0\0\u1700\0\u1740\0\u1780\0\u17c0\0\u1800"+
"\0\u1840\0\u1880\0\u18c0\0\u1900\0\u1940\0\u1980\0\u19c0\0\u0180"+
"\0\u1a00\0\u1a40\0\u1a80\0\u1ac0\0\u1b00\0\u1b40\0\u1b80\0\u1bc0"+
"\0\u0100\0\u1c00\0\u1c40\0\u1c80\0\u1cc0\0\u0180\0\u0180\0\u1d00"+
"\0\u1d40\0\u0180\0\u0180\0\u1d80\0\u1d80\0\u0100\0\u0100\0\u1dc0"+
"\0\u1e00\0\u0100\0\u1e40\0\u0100\0\u0100\0\u1e80\0\u1ec0\0\u0100"+
"\0\u1f00\0\u1680\0\u1f40\0\u0180\0\u1f80\0\u0180\0\u1fc0\0\u0180"+
"\0\u2000\0\u2040\0\u2080\0\u20c0\0\u0180\0\u0180\0\u2100\0\u2140"+
"\0\u2180\0\u21c0\0\u0180\0\u2200\0\u0180\0\u0100\0\u0100\0\u2240"+
"\0\u0b40\0\u0100\0\u2280\0\u22c0\0\u0180\0\u0180\0\u0180\0\u2300"+
"\0\u0180\0\u2340\0\u2380\0\u23c0\0\u0180\0\u0180\0\u0180\0\u2400"+
"\0\u0100\0\u2440\0\u0180\0\u2480\0\u0180\0\u24c0\0\u0180\0\u0180";
private static int [] zzUnpackRowMap() {
int [] result = new int[225];
int [] result = new int[224];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -223,241 +222,239 @@ class _JetLexer implements FlexLexer {
"\1\5\1\6\1\7\1\10\1\7\1\5\1\11\1\10"+
"\1\12\1\13\1\14\1\15\1\16\2\7\1\17\1\7"+
"\1\20\1\7\1\21\1\5\1\22\1\7\1\23\1\24"+
"\1\25\1\7\1\26\1\27\1\30\1\31\1\7\1\32"+
"\1\7\1\33\1\34\1\35\1\36\1\7\1\37\2\7"+
"\1\40\1\7\1\41\1\42\1\43\1\44\1\45\1\46"+
"\1\47\1\50\1\51\1\52\1\53\1\54\1\55\1\56"+
"\1\57\1\60\1\61\1\62\1\63\1\64\7\65\1\66"+
"\1\67\13\65\1\70\1\71\52\65\2\0\1\72\1\0"+
"\1\72\1\0\1\73\6\0\2\72\1\0\1\72\1\0"+
"\1\72\3\0\1\72\2\0\1\74\25\72\21\0\1\5"+
"\1\25\1\7\1\26\1\27\1\30\1\31\1\32\1\33"+
"\1\34\1\35\2\7\1\36\1\37\1\7\1\40\1\7"+
"\1\41\1\7\1\42\1\43\1\44\1\45\1\46\1\47"+
"\1\50\1\51\1\52\1\53\1\54\1\55\1\56\1\57"+
"\1\60\1\61\1\62\1\63\1\64\1\65\7\66\1\67"+
"\1\70\13\66\1\71\1\72\52\66\2\0\1\73\1\0"+
"\1\73\1\0\1\74\6\0\2\73\1\0\1\73\1\0"+
"\1\73\3\0\1\73\2\0\1\75\25\73\21\0\1\5"+
"\1\6\1\7\1\10\1\7\1\5\1\11\1\10\1\12"+
"\1\13\1\14\1\15\1\16\2\7\1\17\1\7\1\20"+
"\1\7\1\21\1\5\1\22\1\7\1\75\1\76\1\25"+
"\1\7\1\26\1\27\1\30\1\31\1\7\1\32\1\7"+
"\1\33\1\34\1\35\1\36\1\7\1\37\2\7\1\40"+
"\1\7\1\41\1\42\1\43\1\44\1\45\1\46\1\47"+
"\1\50\1\51\1\52\1\53\1\54\1\55\1\56\1\57"+
"\1\60\1\61\1\62\1\63\1\64\101\0\1\6\12\0"+
"\1\6\2\0\1\77\1\100\17\0\1\100\40\0\2\7"+
"\1\7\1\21\1\5\1\22\1\7\1\76\1\77\1\25"+
"\1\7\1\26\1\27\1\30\1\31\1\32\1\33\1\34"+
"\1\35\2\7\1\36\1\37\1\7\1\40\1\7\1\41"+
"\1\7\1\42\1\43\1\44\1\45\1\46\1\47\1\50"+
"\1\51\1\52\1\53\1\54\1\55\1\56\1\57\1\60"+
"\1\61\1\62\1\63\1\64\1\65\101\0\1\6\12\0"+
"\1\6\2\0\1\100\1\101\17\0\1\101\40\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\26\7\24\0\1\10\3\0\1\10"+
"\70\0\6\101\2\0\70\101\2\0\1\102\1\0\1\102"+
"\1\0\1\103\6\0\2\102\1\0\1\102\1\0\1\102"+
"\3\0\1\102\2\0\26\102\23\0\1\104\1\0\1\104"+
"\1\0\1\105\2\0\1\106\3\0\2\104\1\0\1\104"+
"\1\0\1\104\3\0\1\104\2\0\26\104\33\0\1\107"+
"\1\110\44\0\1\111\77\0\1\112\20\0\1\113\12\0"+
"\1\113\1\114\1\115\1\77\1\100\17\0\1\100\4\0"+
"\1\115\33\0\1\116\12\0\1\116\2\0\1\117\101\0"+
"\1\120\36\0\1\121\3\0\1\122\13\0\7\21\1\0"+
"\13\21\1\123\1\124\53\21\25\0\1\125\53\0\2\7"+
"\70\0\6\102\2\0\70\102\2\0\1\103\1\0\1\103"+
"\1\0\1\104\6\0\2\103\1\0\1\103\1\0\1\103"+
"\3\0\1\103\2\0\26\103\23\0\1\105\1\0\1\105"+
"\1\0\1\106\2\0\1\107\3\0\2\105\1\0\1\105"+
"\1\0\1\105\3\0\1\105\2\0\26\105\33\0\1\110"+
"\1\111\44\0\1\112\77\0\1\113\20\0\1\114\12\0"+
"\1\114\1\115\1\116\1\100\1\101\17\0\1\101\5\0"+
"\1\116\32\0\1\117\12\0\1\117\2\0\1\120\101\0"+
"\1\121\36\0\1\122\3\0\1\123\13\0\7\21\1\0"+
"\13\21\1\124\1\125\53\21\25\0\1\126\53\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\1\7\1\126\11\7\1\127\6\7"+
"\1\130\3\7\22\0\2\7\1\0\2\7\6\0\3\7"+
"\3\0\1\7\2\0\1\7\1\127\12\7\1\130\5\7"+
"\1\131\3\7\22\0\2\7\1\0\2\7\6\0\3\7"+
"\1\0\1\7\1\0\1\7\3\0\1\7\2\0\3\7"+
"\1\131\1\132\14\7\1\133\4\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\134\2\0\26\7\22\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\135\2\0"+
"\5\7\1\136\20\7\22\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+
"\3\7\1\137\22\7\22\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+
"\17\7\1\140\6\7\22\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+
"\12\7\1\141\4\7\1\142\6\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\7\2\0\14\7\1\143\11\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\7\2\0\7\7\1\144\16\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\7\2\0\13\7\1\145\12\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\7\2\0\1\7\1\146\24\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\147\2\0\5\7\1\150\4\7\1\151\13\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\1\7\1\152\24\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\5\7\1\153\20\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\12\7\1\154\13\7\54\0"+
"\1\155\24\0\1\156\77\0\1\157\3\0\1\160\73\0"+
"\1\161\1\0\1\162\75\0\1\163\77\0\1\164\104\0"+
"\1\165\100\0\1\166\71\0\1\167\17\0\7\65\2\0"+
"\13\65\2\0\52\65\2\0\1\170\1\0\1\170\1\0"+
"\1\171\6\0\2\170\1\0\1\170\1\0\1\170\3\0"+
"\1\170\1\172\1\0\26\170\21\0\7\173\1\0\16\173"+
"\1\174\51\173\1\0\2\72\1\0\2\72\6\0\3\72"+
"\1\0\1\72\1\0\1\72\3\0\1\72\2\0\26\72"+
"\21\0\6\175\2\0\70\175\1\0\2\72\1\0\2\72"+
"\6\0\3\72\1\0\1\72\1\0\1\72\3\0\1\72"+
"\2\0\1\72\1\176\24\72\22\0\1\116\12\0\1\116"+
"\2\0\1\177\61\0\1\200\12\0\1\200\4\0\1\200"+
"\40\0\1\200\15\0\6\101\1\201\1\0\70\101\1\0"+
"\2\102\1\0\2\102\6\0\3\102\1\0\1\102\1\0"+
"\1\102\3\0\1\102\2\0\26\102\21\0\6\202\2\0"+
"\70\202\1\0\2\104\1\0\2\104\6\0\3\104\1\0"+
"\1\104\1\0\1\104\3\0\1\104\2\0\26\104\21\0"+
"\6\203\2\0\70\203\7\107\1\0\70\107\13\204\1\205"+
"\64\204\1\0\1\113\12\0\1\113\2\0\1\206\1\100"+
"\17\0\1\100\40\0\2\114\11\0\1\114\1\0\1\114"+
"\1\207\1\114\1\0\1\210\13\0\1\114\1\0\1\114"+
"\1\210\1\114\2\0\1\114\4\0\1\114\3\0\1\114"+
"\22\0\1\115\12\0\1\115\2\0\1\211\61\0\1\116"+
"\12\0\1\116\3\0\1\100\17\0\1\100\37\0\7\21"+
"\1\0\70\21\25\0\1\212\53\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\2\7\1\213\10\7\1\214\12\7\22\0\2\7"+
"\1\132\2\7\1\133\12\7\1\134\4\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\215\2\0\5\7\1\216\14\7\1\217\3\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\10\7\1\220\15\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\10\7\1\221\15\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\17\7\1\222\6\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\6\7\1\223\17\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\26\7\2\0\1\224"+
"\17\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\3\7\1\225\22\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\4\7\1\226\21\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\5\7\1\227\20\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\15\7\1\230\10\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\1\231\25\7\22\0"+
"\3\0\1\135\2\0\26\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\5\7\1\136\12\7\1\137\5\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\15\7\1\140\10\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\141\2\0\26\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\20\7\1\142\5\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\11\7\1\143\14\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\3\7\1\144\22\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\7\7\1\145\16\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\14\7\1\146\11\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\1\7\1\147\24\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\150"+
"\2\0\5\7\1\151\3\7\1\152\14\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\1\7\1\153\24\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\11\7\1\154\14\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\5\7\1\155\20\7\54\0\1\156"+
"\24\0\1\157\77\0\1\160\3\0\1\161\73\0\1\162"+
"\1\0\1\163\75\0\1\164\77\0\1\165\104\0\1\166"+
"\100\0\1\167\71\0\1\170\17\0\7\66\2\0\13\66"+
"\2\0\52\66\2\0\1\171\1\0\1\171\1\0\1\172"+
"\6\0\2\171\1\0\1\171\1\0\1\171\3\0\1\171"+
"\1\173\1\0\26\171\21\0\7\174\1\0\16\174\1\175"+
"\51\174\1\0\2\73\1\0\2\73\6\0\3\73\1\0"+
"\1\73\1\0\1\73\3\0\1\73\2\0\26\73\21\0"+
"\6\176\2\0\70\176\1\0\2\73\1\0\2\73\6\0"+
"\3\73\1\0\1\73\1\0\1\73\3\0\1\73\2\0"+
"\1\73\1\177\24\73\22\0\1\117\12\0\1\117\2\0"+
"\1\200\61\0\1\201\12\0\1\201\4\0\1\201\40\0"+
"\1\201\15\0\6\102\1\202\1\0\70\102\1\0\2\103"+
"\1\0\2\103\6\0\3\103\1\0\1\103\1\0\1\103"+
"\3\0\1\103\2\0\26\103\21\0\6\203\2\0\70\203"+
"\1\0\2\105\1\0\2\105\6\0\3\105\1\0\1\105"+
"\1\0\1\105\3\0\1\105\2\0\26\105\21\0\6\204"+
"\2\0\70\204\7\110\1\0\70\110\13\205\1\206\64\205"+
"\1\0\1\114\12\0\1\114\2\0\1\207\1\101\17\0"+
"\1\101\40\0\2\115\11\0\1\115\1\0\1\115\1\210"+
"\1\115\1\0\1\211\12\0\1\115\2\0\1\115\1\211"+
"\1\115\3\0\1\115\3\0\1\115\3\0\1\115\22\0"+
"\1\116\12\0\1\116\2\0\1\212\61\0\1\117\12\0"+
"\1\117\3\0\1\101\17\0\1\101\37\0\7\21\1\0"+
"\70\21\25\0\1\213\53\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+
"\2\7\1\214\11\7\1\215\11\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\216\2\0\11\7\1\217\10\7\1\220\3\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\232\16\7\22\0"+
"\1\7\3\0\1\7\2\0\10\7\1\221\15\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\2\7\1\233\4\7\1\234"+
"\16\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\4\7\1\235"+
"\21\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\17\7\1\236"+
"\6\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\13\7\1\237"+
"\12\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\2\7\1\240"+
"\23\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\13\7\1\241"+
"\3\7\1\242\6\7\55\0\1\243\1\244\122\0\1\245"+
"\77\0\1\246\20\0\2\170\1\0\2\170\6\0\3\170"+
"\1\0\1\170\1\0\1\170\3\0\1\170\2\0\26\170"+
"\21\0\6\247\2\0\70\247\1\0\2\250\11\0\1\250"+
"\1\0\1\250\1\0\1\250\15\0\1\250\1\0\1\250"+
"\1\0\1\250\2\0\1\250\4\0\1\250\3\0\1\250"+
"\21\0\6\175\1\251\1\0\70\175\1\0\2\72\1\0"+
"\2\72\6\0\3\72\1\0\1\72\1\0\1\72\3\0"+
"\1\72\2\0\2\72\1\252\23\72\22\0\1\200\12\0"+
"\1\200\63\0\6\202\1\253\1\0\70\202\6\203\1\254"+
"\1\0\70\203\13\204\1\255\64\204\12\256\1\257\1\205"+
"\64\256\1\0\1\116\12\0\1\116\64\0\2\260\11\0"+
"\1\260\1\0\1\260\1\177\1\260\15\0\1\260\1\0"+
"\1\260\1\0\1\260\2\0\1\260\4\0\1\260\3\0"+
"\1\260\22\0\1\200\12\0\1\200\4\0\1\261\40\0"+
"\1\261\34\0\1\177\60\0\25\212\1\262\52\212\1\0"+
"\1\7\3\0\1\7\2\0\10\7\1\222\15\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\3\7\1\263\22\7\22\0"+
"\1\7\3\0\1\7\2\0\6\7\1\223\17\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\12\7\1\264\13\7\22\0"+
"\1\7\3\0\1\7\2\0\11\7\1\224\14\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\265\16\7\22\0"+
"\1\7\3\0\1\7\2\0\16\7\1\225\7\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\2\7\1\266\23\7\22\0"+
"\1\7\3\0\1\7\2\0\20\7\1\226\5\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\267\16\7\22\0"+
"\1\7\3\0\1\7\2\0\3\7\1\227\22\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\4\7\1\230\21\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\26\7\2\0\1\231\17\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\1\232\25\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\7\7\1\233\16\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\2\7\1\234\4\7\1\235\16\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\6\7\1\236\17\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\14\7\1\237\11\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\20\7\1\240\5\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\2\7\1\241\23\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\14\7\1\242\3\7"+
"\1\243\5\7\55\0\1\244\2\0\1\245\120\0\1\246"+
"\77\0\1\247\20\0\2\171\1\0\2\171\6\0\3\171"+
"\1\0\1\171\1\0\1\171\3\0\1\171\2\0\26\171"+
"\21\0\6\250\2\0\70\250\1\0\2\251\11\0\1\251"+
"\1\0\1\251\1\0\1\251\14\0\1\251\2\0\1\251"+
"\1\0\1\251\3\0\1\251\3\0\1\251\3\0\1\251"+
"\21\0\6\176\1\252\1\0\70\176\1\0\2\73\1\0"+
"\2\73\6\0\3\73\1\0\1\73\1\0\1\73\3\0"+
"\1\73\2\0\2\73\1\253\23\73\22\0\1\201\12\0"+
"\1\201\63\0\6\203\1\254\1\0\70\203\6\204\1\255"+
"\1\0\70\204\13\205\1\256\64\205\12\257\1\260\1\206"+
"\64\257\1\0\1\117\12\0\1\117\64\0\2\261\11\0"+
"\1\261\1\0\1\261\1\200\1\261\14\0\1\261\2\0"+
"\1\261\1\0\1\261\3\0\1\261\3\0\1\261\3\0"+
"\1\261\22\0\1\201\12\0\1\201\4\0\1\262\40\0"+
"\1\262\34\0\1\200\60\0\25\213\1\263\52\213\1\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\3\7\1\264\22\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\5\7\1\265\20\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\266\16\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\2\7\1\267\23\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\270\16\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\17\7\1\271\6\7\22\0"+
"\1\7\3\0\1\7\2\0\7\7\1\271\16\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\272\16\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\7\7\1\273\16\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\1\274\25\7\22\0\2\7"+
"\1\7\3\0\1\7\2\0\1\272\25\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\3\7\1\275\22\7\22\0\2\7"+
"\3\0\1\7\2\0\3\7\1\273\22\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\7\7\1\274\16\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\20\7\1\275\5\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\7\2\0\7\7\1\276\16\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\277\2\0\26\7\22\0\2\7\1\0\2\7"+
"\3\0\1\7\2\0\12\7\1\277\13\7\22\0\2\7"+
"\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+
"\3\0\1\300\2\0\26\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\5\7\1\300\20\7\22\0\2\7\1\0\2\7"+
"\2\0\11\7\1\301\14\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\17\7\1\301\6\7\22\0\2\7\1\0\2\7"+
"\2\0\20\7\1\302\5\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\4\7\1\302\21\7\22\0\2\7\1\0\2\7"+
"\2\0\6\7\1\303\17\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\3\7\1\303\22\7\22\0\2\7\1\0\2\7"+
"\2\0\3\7\1\304\22\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\3\7\1\304\22\7\22\0\2\305\1\0\2\305"+
"\6\0\3\305\1\0\1\305\1\0\1\305\3\0\1\305"+
"\2\0\26\305\21\0\6\247\1\306\1\0\70\247\1\0"+
"\2\307\11\0\1\307\1\0\1\307\1\0\1\307\15\0"+
"\1\307\1\0\1\307\1\0\1\307\2\0\1\307\4\0"+
"\1\307\3\0\1\307\22\0\2\72\1\0\2\72\6\0"+
"\3\72\1\0\1\72\1\0\1\72\3\0\1\72\2\0"+
"\3\72\1\310\22\72\21\0\12\204\1\311\1\255\64\204"+
"\13\256\1\312\64\256\1\0\2\260\11\0\1\260\1\0"+
"\1\260\1\0\1\260\1\0\1\210\13\0\1\260\1\0"+
"\1\260\1\210\1\260\2\0\1\260\4\0\1\260\3\0"+
"\1\260\21\0\25\212\1\313\52\212\1\0\2\7\1\0"+
"\2\0\3\7\1\305\22\7\22\0\2\306\1\0\2\306"+
"\6\0\3\306\1\0\1\306\1\0\1\306\3\0\1\306"+
"\2\0\26\306\21\0\6\250\1\307\1\0\70\250\1\0"+
"\2\310\11\0\1\310\1\0\1\310\1\0\1\310\14\0"+
"\1\310\2\0\1\310\1\0\1\310\3\0\1\310\3\0"+
"\1\310\3\0\1\310\22\0\2\73\1\0\2\73\6\0"+
"\3\73\1\0\1\73\1\0\1\73\3\0\1\73\2\0"+
"\3\73\1\311\22\73\21\0\12\205\1\312\1\256\64\205"+
"\13\257\1\313\64\257\1\0\2\261\11\0\1\261\1\0"+
"\1\261\1\0\1\261\1\0\1\211\12\0\1\261\2\0"+
"\1\261\1\211\1\261\3\0\1\261\3\0\1\261\3\0"+
"\1\261\21\0\25\213\1\314\52\213\1\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\7\2\0\16\7\1\314\7\7\22\0\2\7\1\0"+
"\1\7\2\0\17\7\1\315\6\7\22\0\2\7\1\0"+
"\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+
"\1\7\2\0\1\315\25\7\22\0\2\7\1\0\2\7"+
"\1\7\2\0\1\316\25\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\13\7\1\316\12\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\3\7\1\317\22\7\22\0\2\7\1\0\2\7"+
"\2\0\14\7\1\317\11\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\2\7\1\320\23\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\3\7\1\321\22\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\11\7\1\322\14\7\22\0\2\7\1\0\2\7"+
"\2\0\4\7\1\322\21\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\13\7\1\323\12\7\22\0\2\7\1\0\2\7"+
"\2\0\11\7\1\323\14\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\20\7\1\324\5\7\22\0\2\7\1\0\2\7"+
"\2\0\14\7\1\324\11\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\7\7\1\325\16\7\22\0\2\7\1\0\2\7"+
"\2\0\12\7\1\325\13\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\7\7\1\326\16\7\22\0\2\327\11\0\1\327"+
"\1\0\1\327\1\0\1\327\15\0\1\327\1\0\1\327"+
"\1\0\1\327\2\0\1\327\4\0\1\327\3\0\1\327"+
"\21\0\12\256\1\257\1\312\64\256\25\212\1\330\52\212"+
"\2\0\7\7\1\326\16\7\22\0\2\7\1\0\2\7"+
"\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+
"\2\0\7\7\1\327\16\7\22\0\2\330\11\0\1\330"+
"\1\0\1\330\1\0\1\330\14\0\1\330\2\0\1\330"+
"\1\0\1\330\3\0\1\330\3\0\1\330\3\0\1\330"+
"\21\0\12\257\1\260\1\313\64\257\25\213\1\331\52\213"+
"\1\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\10\7\1\331\15\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\4\7\1\332\21\7"+
"\1\0\1\7\3\0\1\7\2\0\6\7\1\332\17\7"+
"\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+
"\1\0\1\7\3\0\1\7\2\0\1\333\25\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\4\7\1\334\21\7\22\0"+
"\2\173\11\0\1\173\1\0\1\173\1\0\1\173\15\0"+
"\1\173\1\0\1\173\1\0\1\173\2\0\1\173\4\0"+
"\1\173\3\0\1\173\22\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+
"\5\7\1\335\20\7\22\0\2\7\1\0\2\7\6\0"+
"\1\7\3\0\1\7\2\0\13\7\1\334\12\7\22\0"+
"\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+
"\1\7\3\0\1\7\2\0\6\7\1\335\17\7\22\0"+
"\2\174\11\0\1\174\1\0\1\174\1\0\1\174\14\0"+
"\1\174\2\0\1\174\1\0\1\174\3\0\1\174\3\0"+
"\1\174\3\0\1\174\22\0\2\7\1\0\2\7\6\0"+
"\3\7\1\0\1\7\1\0\1\7\3\0\1\336\2\0"+
"\26\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\11\7\1\337"+
"\14\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\340"+
"\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\337"+
"\16\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+
"\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\341"+
"\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\340"+
"\16\7\21\0";
private static int [] zzUnpackTrans() {
int [] result = new int[9536];
int [] result = new int[9472];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -498,18 +495,18 @@ class _JetLexer implements FlexLexer {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\4\0\1\11\15\1\2\11\21\1\1\11\6\1\10\11"+
"\4\0\1\11\15\1\2\11\22\1\1\11\6\1\10\11"+
"\1\1\1\11\1\1\1\0\1\11\1\1\1\0\1\1"+
"\2\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\1\1\1\0\27\1"+
"\1\0\2\1\10\11\1\1\1\0\2\11\1\1\1\0"+
"\1\1\1\11\1\1\1\11\2\0\2\1\4\0\12\1"+
"\1\11\20\1\2\11\2\0\1\11\1\1\2\11\1\0"+
"\1\1\1\11\1\1\1\11\2\0\2\1\4\0\16\1"+
"\1\11\14\1\2\11\2\0\1\11\1\1\2\11\1\0"+
"\1\1\1\11\1\1\2\0\22\1\2\11\1\0\1\1"+
"\1\11\2\0\13\1\1\0\1\11\11\1";
"\1\11\2\0\13\1\1\0\1\11\7\1";
private static int [] zzUnpackAttribute() {
int [] result = new int[225];
int [] result = new int[224];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -1025,7 +1022,7 @@ class _JetLexer implements FlexLexer {
{ return JetTokens.MINUSMINUS;
}
case 142: break;
case 96:
case 97:
{ return JetTokens.CONTINUE_KEYWORD ;
}
case 143: break;
@@ -1077,7 +1074,7 @@ class _JetLexer implements FlexLexer {
{ return TokenType.BAD_CHARACTER;
}
case 155: break;
case 97:
case 96:
{ return JetTokens.NAMESPACE_KEYWORD ;
}
case 156: break;
+8 -8
View File
@@ -121,17 +121,17 @@ sink:
<SINK> NEXT:[] PREV:[<END>]
=====================
== flfun ==
fun flfun(f : fun () : Any) : Unit {}
fun flfun(f : () -> Any) : Unit {}
---------------------
l0:
<START> NEXT:[v(f : fun () : Any)] PREV:[]
v(f : fun () : Any) NEXT:[w(f)] PREV:[<START>]
w(f) NEXT:[read (Unit)] PREV:[v(f : fun () : Any)]
read (Unit) NEXT:[<END>] PREV:[w(f)]
<START> NEXT:[v(f : () -> Any)] PREV:[]
v(f : () -> Any) NEXT:[w(f)] PREV:[<START>]
w(f) NEXT:[read (Unit)] PREV:[v(f : () -> Any)]
read (Unit) NEXT:[<END>] PREV:[w(f)]
l1:
<END> NEXT:[<SINK>] PREV:[read (Unit)]
<END> NEXT:[<SINK>] PREV:[read (Unit)]
error:
<ERROR> NEXT:[] PREV:[]
<ERROR> NEXT:[] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<END>]
<SINK> NEXT:[] PREV:[<END>]
=====================
+1 -1
View File
@@ -20,4 +20,4 @@ fun foo(a : Boolean, b : Int) : Unit {}
fun genfun<T>() : Unit {}
fun flfun(f : fun () : Any) : Unit {}
fun flfun(f : () -> Any) : Unit {}
+1 -1
View File
@@ -1,4 +1,4 @@
namespace foo;
package foo;
fun main(args : Array<String>) {
@@ -1,7 +1,7 @@
fun box() : String {
return apply( "OK", {(arg: String) => arg } )
return apply( "OK", {(arg: String) -> arg } )
}
fun apply(arg : String, f : fun (p:String) : String) : String {
fun apply(arg : String, f : (p:String) -> String) : String {
return f(arg)
}
@@ -1,7 +1,7 @@
fun box() : String {
return if (apply( 5, {(arg: Int) => arg + 13 } ) == 18) "OK" else "fail"
return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail"
}
fun apply(arg : Int, f : fun (p:Int) : Int) : Int {
fun apply(arg : Int, f : (p:Int) -> Int) : Int {
return f(arg)
}
@@ -3,6 +3,6 @@ fun box() : String {
return if (sum(200, { val ff = {cl}; ff() }) == 239) "OK" else "FAIL"
}
fun sum(arg:Int, f : fun () : Int) : Int {
fun sum(arg:Int, f : () -> Int) : Int {
return arg + f()
}
@@ -3,6 +3,6 @@ fun box() : String {
return if (sum(200, { val m = { val r = { cl }; r() }; m() }) == 239) "OK" else "FAIL"
}
fun sum(arg:Int, f : fun () : Int) : Int {
fun sum(arg:Int, f : () -> Int) : Int {
return arg + f()
}
@@ -1,10 +1,10 @@
class Point(val x:Int, val y:Int) {
fun mul() : fun (scalar:Int):Point {
return { (scalar:Int):Point => Point(x * scalar, y * scalar) }
fun mul() : (scalar:Int)->Point {
return { (scalar:Int):Point -> Point(x * scalar, y * scalar) }
}
}
val m = Point(2, 3).mul() : fun (scalar:Int):Point
val m = Point(2, 3).mul() : (scalar:Int)->Point
fun box() : String {
val answer = m(5)
@@ -1,13 +1,13 @@
class Point(val x : Int, val y : Int)
fun box() : String {
val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point =>
val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point ->
Point(x * scalar, y * scalar)
})
return if (answer.x == 6 && answer.y == 10) "OK" else "FAIL"
}
fun apply(arg:Point, f : fun Point.(scalar : Int) : Point) : Point {
fun apply(arg:Point, f : Point.(scalar : Int) -> Point) : Point {
return arg.f(2)
}
@@ -2,6 +2,6 @@ fun box() : String {
return invoker( {"OK"} )
}
fun invoker(gen : fun () : String) : String {
fun invoker(gen : () -> String) : String {
return gen()
}
@@ -2,6 +2,6 @@ fun box() : String {
return if (int_invoker( { 7 } ) == 7) "OK" else "fail"
}
fun int_invoker(gen : fun () : Int) : Int {
fun int_invoker(gen : () -> Int) : Int {
return gen()
}
@@ -1,7 +1,7 @@
import java.util.concurrent.*
import java.util.concurrent.atomic.*
fun thread(block: fun():Unit ) {
fun thread(block: ()->Unit ) {
val thread = object: Thread() {
override fun run() {
block()
@@ -1,6 +1,6 @@
import java.util.*
fun <T> ArrayList<T>.findAll(predicate: fun (T) : Boolean): ArrayList<T> {
fun <T> ArrayList<T>.findAll(predicate: (T) -> Boolean): ArrayList<T> {
val result = ArrayList<T>()
for(val t in this) {
if (predicate(t)) result.add(t)
@@ -16,6 +16,6 @@ fun box(): String {
list.add("Moscow")
list.add("Munich")
val m: ArrayList<String> = list.findAll<String>({(name: String) => name.startsWith("M")})
val m: ArrayList<String> = list.findAll<String>({(name: String) -> name.startsWith("M")})
return if (m.size() == 2) "OK" else "fail"
}
@@ -2,7 +2,7 @@ fun <T> T.mustBe(t : T) {
assert("$this must be $t") {this == t}
}
inline fun assert(message : String, condition : fun() : Boolean) {
inline fun assert(message : String, condition : () -> Boolean) {
if (!condition())
throw AssertionError(message)
}
@@ -3,7 +3,7 @@ class Request(val path: String) {
}
class Handler() {
fun Int.times(op: fun(): Unit) {
fun Int.times(op: ()-> Unit) {
for(i in 0..this)
op()
}
@@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char {
fun foo(expr: StringBuilder): Int {
val c = expr.takeFirst()
when(c) {
0.chr => throw Exception("zero")
else => throw Exception("nonzero" + c)
0.chr -> throw Exception("zero")
else -> throw Exception("nonzero" + c)
}
}
@@ -5,7 +5,7 @@ fun reformat(
divideByCamelHumps : Boolean = true,
wordSeparator : String = " "
) =
(normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator)
#(normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator)
trait A {
fun bar2(arg: Int = 239) : Int
@@ -38,7 +38,7 @@ class C() : B() {
fun <T> T.toPrefixedString(prefix: String = "", suffix: String="") = prefix + (this as java.lang.Object).toString() + suffix
fun box() : String {
val expected = (true, true, true, " ")
val expected = #(true, true, true, " ")
if("mama".toPrefixedString(suffix="321", prefix="papa") != "papamama321") return "fail"
if("mama".toPrefixedString(prefix="papa") != "papamama") return "fail"
@@ -1,24 +1,24 @@
fun Any.foo1() : fun(): String {
fun Any.foo1() : ()-> String {
return { "239" + this }
}
fun Int.foo2() : fun(i : Int) : Int {
return { x => x + this }
fun Int.foo2() : (i : Int) -> Int {
return { x -> x + this }
}
fun fooT1<T>(t : T) = { t.toString() }
fun fooT2<T>(t: T) = { (x:T) => t.toString() + x.toString() }
fun fooT2<T>(t: T) = { (x:T) -> t.toString() + x.toString() }
fun box() : String {
if( (10.foo1())() != "23910") return "foo1 fail"
if( (10.foo2())(1) != 11 ) return "foo2 fail"
if(1.{Int.() => this + 1}() != 2) return "test 3 failed";
if(1.{Int.() -> this + 1}() != 2) return "test 3 failed";
if( {1}() != 1) return "test 4 failed";
if( {(x : Int) => x}(1) != 1) return "test 5 failed";
if( 1.{Int.(x : Int) => x + this}(1) != 2) return "test 6 failed";
if( 1.({Int.() => this})() != 1) return "test 7 failed";
if( {(x : Int) -> x}(1) != 1) return "test 5 failed";
if( 1.{Int.(x : Int) -> x + this}(1) != 2) return "test 6 failed";
if( 1.({Int.() -> this})() != 1) return "test 7 failed";
if( (fooT1<String>("mama"))() != "mama") return "test 8 failed";
if( (fooT2<String>("mama"))("papa") != "mamapapa") return "test 9 failed";
return "OK"
@@ -1,6 +1,6 @@
fun loop(var times : Int) {
while(times > 0) {
val u : fun(value : Int) : Unit = {
val u : (value : Int) -> Unit = {
System.out?.println(it)
}
u(times--)
@@ -1,5 +1,5 @@
class X<T> () {
fun getTypeChecker() = { (a : Any) => a is T }
fun getTypeChecker() = { (a : Any) -> a is T }
}
fun box() : String {
@@ -1,4 +1,4 @@
namespace Foo {
package Foo {
fun bar() = 610
}
@@ -1,4 +1,4 @@
fun isZero(x: Int) = when(x) {
0 => true
else => false
0 -> true
else -> false
}
@@ -1,3 +1,3 @@
fun isZero(x: Int) = when(x) {
0 => true
0 -> true
}
@@ -1,7 +1,7 @@
fun typeName(a: Any?) : String {
return when(a) {
is java.util.ArrayList<*> => "array list"
else => "no idea"
is java.util.ArrayList<*> -> "array list"
else -> "no idea"
}
}
@@ -1,4 +1,4 @@
fun isString(x: Any) = when(x) {
is String => "string"
else => "something"
is String -> "string"
else -> "something"
}
@@ -3,9 +3,9 @@ fun isDigit(a: Int) : String {
aa.add(239)
return when(a) {
in aa => "array list"
in 0..9 => "digit"
!in 0..100 => "not small"
else => "something"
in aa -> "array list"
in 0..9 -> "digit"
!in 0..100 -> "not small"
else -> "something"
}
}
@@ -1,4 +1,4 @@
fun isDigit(a: Char) = when(a) {
in '0'..'9' => "digit"
else => "something"
in '0'..'9' -> "digit"
else -> "something"
}
@@ -1,11 +1,11 @@
fun main(args: Array<String>?) {
val y: Unit = () //do not compile
val y: Unit = #() //do not compile
A<Unit>() //do not compile
C<Unit>(()) //do not compile
C<Unit>(#()) //do not compile
//do not compile
System.out?.println(fff<Unit>(())) //do not compile
System.out?.println(fff<Unit>(#())) //do not compile
System.out?.println(id<Unit>(y)) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit => }))) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit -> }))) //do not compile
}
class A<T>()
@@ -17,13 +17,13 @@ fun <T> fff(x: T) : T { return x }
fun <T> id(value: T): T = value
fun foreach(array: Array<Int>?, action: fun(Int): Unit) {
fun foreach(array: Array<Int>?, action: (Int)-> Unit) {
for (el in array) {
action(el) //exception through compilation (see below)
}
}
fun almostFilter(array: Array<Int>, action: fun(Int): Int) {
fun almostFilter(array: Array<Int>, action: (Int)-> Int) {
for (el in array) {
action(el)
}
@@ -34,8 +34,8 @@ fun box() : String {
a[0] = 0
a[1] = 1
a[2] = 2
foreach(a, { (el : Int) : Unit => System.out?.println(el) })
almostFilter(a, { (el : Int) : Int => el })
foreach(a, { (el : Int) : Unit -> System.out?.println(el) })
almostFilter(a, { (el : Int) : Int -> el })
main(null)
return "OK"
}
@@ -1,4 +1,4 @@
namespace x
package x
class Outer() {
class object {
@@ -1,4 +1,4 @@
namespace test
package test
class List<T>(len: Int) {
val a : Array<T?> = Array<T?>(len)
@@ -1,12 +1,12 @@
import java.util.ArrayList
fun launch(f : fun() : Unit) {
fun launch(f : () -> Unit) {
f()
}
fun box(): String {
val list = ArrayList<Int>()
val foo : fun() : Unit = {
val foo : () -> Unit = {
list.add(2) //first exception
}
foo()
@@ -27,7 +27,7 @@ fun t1() : Boolean {
x = x + "45" + y
x = x.substring(3)
x += "aaa"
()
#()
}
foo()
@@ -43,7 +43,7 @@ fun t2() : Boolean {
x = x + 5 + y
x += 5
x++
()
#()
}
foo()
x -= 55
@@ -55,7 +55,7 @@ fun t3() : Boolean {
var x = true
val foo = {
x = false
()
#()
}
foo()
return !x
@@ -67,7 +67,7 @@ fun t4() : Boolean {
val foo = {
x = x + 200.flt + y
x += 18
()
#()
}
foo()
System.out?.println(x)
@@ -80,7 +80,7 @@ fun t5() : Boolean {
val foo = {
x = x + 200.dbl + y
x -= 22
()
#()
}
foo()
System.out?.println(x)
@@ -94,7 +94,7 @@ fun t6() : Boolean {
x = (x + 20.byt + y).byt
x += 2
x--
()
#()
}
foo()
System.out?.println(x)
@@ -105,7 +105,7 @@ fun t7() : Boolean {
var x : Char = 'a'
val foo = {
x = 'b'
()
#()
}
foo()
System.out?.println(x)
@@ -117,10 +117,10 @@ fun t8() : Boolean {
val foo = {
val bar = {
x = 30.sht
()
#()
}
bar()
()
#()
}
foo()
return x == 30.sht
@@ -1,6 +1,6 @@
fun Any.with(operation : fun Any.() : Any) = operation().toString()
fun Any.with(operation : Any.() -> Any) = operation().toString()
val f = { (a : Int) :Unit => }
val f = { (a : Int) :Unit -> }
fun box () : String {
return if(20.with {
@@ -1,4 +1,4 @@
namespace mult_constructors_3_bug
package mult_constructors_3_bug
public open class Identifier() {
private var myNullable : Boolean = true
@@ -1,4 +1,4 @@
namespace one_extends_base
package one_extends_base
open class Base<T>(name : T?) {
var myName : T?
@@ -1,4 +1,4 @@
namespace mask
package mask
import std.io.*
import java.io.*
@@ -52,7 +52,7 @@ class Luhny() {
fun check() {
if (digits.size() < 14) return
print("check")
val sum = digits.sum { i, d =>
val sum = digits.sum { i, d ->
// println("$i -> $d")
if (i % 2 == digits.size()) {
val f = d * 2 / 10
@@ -94,12 +94,12 @@ class Luhny() {
}
}
fun <T> T.pr(f : fun(T) : Unit) : T {
fun <T> T.pr(f : (T) -> Unit) : T {
f(this)
return this
}
fun LinkedList<Int>.sum(f : fun(Int, Int ): Int): Int {
fun LinkedList<Int>.sum(f : (Int, Int )-> Int): Int {
var sum = 0
for (i in 1..size()) {
val j = size() - i
@@ -120,7 +120,7 @@ fun LinkedList<Int>.sum(f : fun(Int, Int ): Int): Int {
fun Char.isDigit() = Character.isDigit(this)
fun Reader.forEachChar(body : fun(Char) : Unit) {
fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
@@ -1,4 +1,4 @@
namespace mask
package mask
import std.io.*
import java.io.*
@@ -46,7 +46,7 @@ class Luhny() {
private fun check() {
val size = digits.size()
if (size < 14) return
val sum = digits.sum {i, d =>
val sum = digits.sum {i, d ->
if (i % 2 == size % 2) double(d) else d
}
// var sum = 0
@@ -89,7 +89,7 @@ class Luhny() {
fun Char.isDigit() = Character.isDigit(this)
fun java.lang.Iterable<Int>.sum(f : fun(index : Int, value : Int) : Int) : Int {
fun java.lang.Iterable<Int>.sum(f : (index : Int, value : Int) -> Int) : Int {
var sum = 0
var i = 0
for (d in this) {
@@ -99,7 +99,7 @@ fun java.lang.Iterable<Int>.sum(f : fun(index : Int, value : Int) : Int) : Int {
return sum
}
fun Reader.forEachChar(body : fun(Char) : Unit) {
fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
@@ -1,4 +1,4 @@
namespace mask
package mask
import std.io.*
import java.io.*
@@ -50,7 +50,7 @@ class Luhny() {
fun check() {
if (digits.size() < 14) return
val sum = digits.sum { i, d =>
val sum = digits.sum { i, d ->
if (i % 2 != 0)
d * 2 / 10 + d * 2 % 10
else d
@@ -85,7 +85,7 @@ class Luhny() {
}
}
fun LinkedList<Int>.sum(f : fun(Int, Int) : Int) : Int {
fun LinkedList<Int>.sum(f : (Int, Int) -> Int) : Int {
var sum = 0
var i = 0
for (d in backwards()) {
@@ -136,7 +136,7 @@ fun Char.isDigit() = Character.isDigit(this)
// fun clear() {}
//}
fun Reader.forEachChar(body : fun(Char) : Unit) {
fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
@@ -1,4 +1,4 @@
namespace while_bug_1
package while_bug_1
import java.io.*
@@ -1,4 +1,4 @@
namespace whats.the.difference
package whats.the.difference
import java.util.HashSet
@@ -1,4 +1,4 @@
namespace array_test
package array_test
fun box() : String {
var array : IntArray? = IntArray(10)
@@ -1,4 +1,4 @@
namespace name
package name
class Test() {
var i = 5
@@ -1,4 +1,4 @@
namespace demo
package demo
public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
{
@@ -1,8 +1,8 @@
fun escapeChar(c : Char) : String? = when (c) {
'\\' => "\\\\"
'\n' => "\\n"
'"' => "\\\""
else => String.valueOf(c)
'\\' -> "\\\\"
'\n' -> "\\n"
'"' -> "\\\""
else -> String.valueOf(c)
}
fun String.escape(i : Int = 0, result : String = "") : String =
@@ -1,4 +1,4 @@
namespace org2
package org2
enum class Test {
A
@@ -1,6 +1,6 @@
class List<T>(val head: T, val tail: List<T>? = null)
fun <T> List<T>.mapHead(f: fun(T): T): List<T> = List<T>(f(head), null)
fun <T> List<T>.mapHead(f: (T)-> T): List<T> = List<T>(f(head), null)
fun box() : String {
val a: Int = List<Int>(1).mapHead{it * 2}.head
@@ -1,4 +1,4 @@
namespace demo_range
package demo_range
fun Int?.rangeTo(other : Int?) : IntRange = this.sure().rangeTo(other.sure())
@@ -1,4 +1,4 @@
namespace bitwise_demo
package bitwise_demo
fun Long?.shl(bits : Int?) : Long = this.sure().shl(bits.sure())
@@ -1,4 +1,4 @@
namespace demo_range
package demo_range
fun Int?.plus() : Int = this.sure().plus()
fun Int?.dec() : Int = this.sure().dec()
@@ -1,4 +1,4 @@
namespace demo_long
package demo_long
fun Long?.inv() : Long = this.sure().inv()
@@ -1,10 +1,10 @@
namespace w_range
package w_range
fun box() : String {
var i = 0
when (i) {
1 => i--
else => { i = 2 }
1 -> i--
else -> { i = 2 }
}
System.out?.println(i)
return "OK"
@@ -1,18 +1,18 @@
namespace demo2
package demo2
fun print(o : Any?) {}
fun test(i : Int) {
var monthString : String? = "<empty>"
when (i) {
1 => {
1 -> {
print(1)
print(2)
print(3)
print(4)
print(5)
}
else => {
else -> {
monthString = "Invalid month"
}
}
@@ -1,18 +1,18 @@
namespace demo2
package demo2
fun print(o : Any?) {}
fun test(i : Int) {
var monthString : String? = "<empty>"
when (i) {
1 => {
1 -> {
print(1)
print(2)
print(3)
print(4)
print(5)
}
else => {
else -> {
monthString = "Invalid month"
}
}
@@ -1,7 +1,7 @@
class A() {
var x : Int = 0
var z = { () =>
var z = { () ->
x++
}
}
@@ -1,4 +1,4 @@
namespace foo
package foo
import java.util.*;
@@ -1,4 +1,4 @@
namespace demo
package demo
fun box() : String {
var res : Boolean = true
@@ -0,0 +1,7 @@
package container_test
class Container<T>(var t : T) {
fun getT() : T = t
}
fun box() = Container<String>("OK").getT()
@@ -0,0 +1,5 @@
fun box() = when {
1 > 2 -> "false"
1 >= 1 -> "OK"
else -> "else"
}
+1 -1
View File
@@ -36,7 +36,7 @@ trait WriteOnlyArray<in T> : ISized {
}
}
class MutableArray<T>(length: Int, init : fun(Int) : T) : ReadOnlyArray<T>, WriteOnlyArray<T> {
class MutableArray<T>(length: Int, init : (Int) -> T) : ReadOnlyArray<T>, WriteOnlyArray<T> {
private val array = Array<T>(length, init)
override fun get(index : Int) : T = array[index]
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Smoke
package Smoke
import std.io.*
+4 -6
View File
@@ -1,8 +1,6 @@
import kotlin.modules.ModuleSetBuilder
import kotlin.modules.*
fun ModuleSetBuilder.defineModules() {
module("smoke") {
source files "Smoke.kt"
jar name System.getProperty("java.io.tmpdir") + "/smoke.jar"
}
val modules = module("smoke") {
source files "Smoke.kt"
jar name System.getProperty("java.io.tmpdir") + "/smoke.jar"
}
@@ -2,7 +2,7 @@ fun foo(u : Unit) : Int = 1
fun test() : Int {
foo(1)
val a : fun() : Unit = {
val a : () -> Unit = {
foo(1)
}
return 1 - "1"
@@ -1,6 +1,6 @@
// +JDK
namespace abstract
package abstract
class MyClass() {
//properties
@@ -180,7 +180,7 @@ enum class MyEnum() {
abstract enum class MyAbstractEnum() {}
namespace MyNamespace {
package MyNamespace {
//properties
val <!MUST_BE_INITIALIZED!>a<!>: Int
val a1: Int = 1
@@ -1,10 +1,10 @@
fun text() {
"direct:a" to "mock:a"
"direct:a" on {it.body == "<hello/>"} to "mock:a"
"direct:a" on {it => it.body == "<hello/>"} to "mock:a"
"direct:a" on {it -> it.body == "<hello/>"} to "mock:a"
bar <!TYPE_MISMATCH!>{1}<!>
bar <!TYPE_MISMATCH!>{<!UNRESOLVED_REFERENCE!>it<!> + 1}<!>
bar {it, it1 => it}
bar {it, it1 -> it}
bar1 {1}
bar1 {it + 1}
@@ -12,18 +12,18 @@ fun text() {
bar2 <!TYPE_MISMATCH!>{<!TYPE_MISMATCH!><!>}<!>
bar2 {1}
bar2 {<!UNRESOLVED_REFERENCE!>it<!>}
bar2 <!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>it<!> => it}<!>
bar2 <!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>it<!> -> it}<!>
}
fun bar(<!UNUSED_PARAMETER!>f<!> : fun (Int, Int) : Int) {}
fun bar1(<!UNUSED_PARAMETER!>f<!> : fun (Int) : Int) {}
fun bar2(<!UNUSED_PARAMETER!>f<!> : fun () : Int) {}
fun bar(<!UNUSED_PARAMETER!>f<!> : (Int, Int) -> Int) {}
fun bar1(<!UNUSED_PARAMETER!>f<!> : (Int) -> Int) {}
fun bar2(<!UNUSED_PARAMETER!>f<!> : () -> Int) {}
fun String.to(<!UNUSED_PARAMETER!>dest<!> : String) {
}
fun String.on(<!UNUSED_PARAMETER!>predicate<!> : fun (s : URI) : Boolean) : URI {
fun String.on(<!UNUSED_PARAMETER!>predicate<!> : (s : URI) -> Boolean) : URI {
return URI(this)
}
@@ -1,6 +1,6 @@
namespace example;
package example;
namespace ns {
package ns {
val y : Any? = 2
}
@@ -2,7 +2,7 @@ fun foo(<!UNUSED_PARAMETER!>u<!> : Unit) : Int = 1
fun test() : Int {
foo(<!TYPE_MISMATCH!>1<!>)
val <!UNUSED_VARIABLE!>a<!> : fun() : Unit = {
val <!UNUSED_VARIABLE!>a<!> : () -> Unit = {
foo(<!TYPE_MISMATCH!>1<!>)
}
return 1 <!NONE_APPLICABLE!>-<!> "1"
@@ -1,4 +1,4 @@
namespace boundsWithSubstitutors {
package boundsWithSubstitutors {
open class A<T>
class B<X : A<X>>()
@@ -18,10 +18,10 @@ namespace boundsWithSubstitutors {
open class A {}
open class B<T : A>()
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : (B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>)>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> #(B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>)>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
abstract val x : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : B<<!UPPER_BOUND_VIOLATED!>Any<!>>
abstract val x : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> B<<!UPPER_BOUND_VIOLATED!>Any<!>>
}

Some files were not shown because too many files have changed in this diff Show More