remove JetStandardLibrary dependency from jvm backend
This commit is contained in:
@@ -28,31 +28,29 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
public class AnalyzeExhaust {
|
||||
@NotNull
|
||||
private final BindingContext bindingContext;
|
||||
private final JetStandardLibrary standardLibrary;
|
||||
private final Throwable error;
|
||||
|
||||
@Nullable
|
||||
private final BodiesResolveContext bodiesResolveContext;
|
||||
|
||||
private AnalyzeExhaust(@NotNull BindingContext bindingContext,
|
||||
@Nullable JetStandardLibrary standardLibrary, @Nullable BodiesResolveContext bodiesResolveContext, @Nullable Throwable error) {
|
||||
@Nullable BodiesResolveContext bodiesResolveContext, @Nullable Throwable error) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.standardLibrary = standardLibrary;
|
||||
this.error = error;
|
||||
this.bodiesResolveContext = bodiesResolveContext;
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust success(@NotNull BindingContext bindingContext, @NotNull JetStandardLibrary standardLibrary) {
|
||||
return new AnalyzeExhaust(bindingContext, standardLibrary, null, null);
|
||||
public static AnalyzeExhaust success(@NotNull BindingContext bindingContext) {
|
||||
return new AnalyzeExhaust(bindingContext, null, null);
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust success(@NotNull BindingContext bindingContext, @NotNull JetStandardLibrary standardLibrary,
|
||||
BodiesResolveContext bodiesResolveContext) {
|
||||
return new AnalyzeExhaust(bindingContext, standardLibrary, bodiesResolveContext, null);
|
||||
public static AnalyzeExhaust success(@NotNull BindingContext bindingContext,
|
||||
BodiesResolveContext bodiesResolveContext) {
|
||||
return new AnalyzeExhaust(bindingContext, bodiesResolveContext, null);
|
||||
}
|
||||
|
||||
public static AnalyzeExhaust error(@NotNull BindingContext bindingContext, @NotNull Throwable error) {
|
||||
return new AnalyzeExhaust(bindingContext, null, null, error);
|
||||
return new AnalyzeExhaust(bindingContext, null, error);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -65,11 +63,6 @@ public class AnalyzeExhaust {
|
||||
return bindingContext;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetStandardLibrary getStandardLibrary() {
|
||||
return standardLibrary;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.BodiesResolveContext;
|
||||
import org.jetbrains.jet.lang.resolve.ObservableBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -51,7 +50,7 @@ public class AnalyzerFacadeForEverything {
|
||||
|
||||
try {
|
||||
injector.getBodyResolver().resolveBodies(bodiesResolveContext);
|
||||
return AnalyzeExhaust.success(traceContext.getBindingContext(), JetStandardLibrary.getInstance());
|
||||
return AnalyzeExhaust.success(traceContext.getBindingContext());
|
||||
} finally {
|
||||
injector.destroy();
|
||||
}
|
||||
|
||||
@@ -502,11 +502,13 @@ public class JetStandardLibrary {
|
||||
return volatileType;
|
||||
}
|
||||
|
||||
public final boolean isVolatile(PropertyDescriptor descriptor) {
|
||||
public static boolean isVolatile(PropertyDescriptor descriptor) {
|
||||
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
||||
if (annotations != null) {
|
||||
for(AnnotationDescriptor d: annotations) {
|
||||
if (d.getType().equals(getVolatileType())) { return true; }
|
||||
if (JetStandardLibraryNames.VOLATILE.is(d.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.types.lang;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ref.ClassName;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class JetStandardLibraryNames {
|
||||
|
||||
@NotNull
|
||||
private static ClassName classIn(@NotNull String name, int typeParameterCount) {
|
||||
return new ClassName(
|
||||
JetStandardClasses.STANDARD_CLASSES_FQNAME.child(Name.identifier(name)),
|
||||
typeParameterCount);
|
||||
}
|
||||
|
||||
public static final ClassName ARRAY = classIn("Array", 1);
|
||||
public static final ClassName VOLATILE = classIn("volatile", 0);
|
||||
public static final ClassName INT = PrimitiveType.INT.getClassName();
|
||||
public static final ClassName COMPARABLE = classIn("Comparable", 1);
|
||||
public static final ClassName NOTHING = classIn("Nothing", 0);
|
||||
public static final ClassName STRING = classIn("String", 0);
|
||||
public static final ClassName CHAR_SEQUENCE = classIn("CharSequence", 0);
|
||||
public static final ClassName NUMBER = classIn("Number", 0);
|
||||
public static final ClassName THROWABLE = classIn("Throwable", 0);
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.types.lang;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.ref.ClassName;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
@@ -36,10 +37,14 @@ public enum PrimitiveType {
|
||||
|
||||
private final Name typeName;
|
||||
private final Name arrayTypeName;
|
||||
private final ClassName className;
|
||||
private final ClassName arrayClassName;
|
||||
|
||||
private PrimitiveType(String typeName) {
|
||||
this.typeName = Name.identifier(typeName);
|
||||
this.arrayTypeName = Name.identifier(typeName + "Array");
|
||||
this.className = new ClassName(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.typeName), 0);
|
||||
this.arrayClassName = new ClassName(JetStandardClasses.STANDARD_CLASSES_FQNAME.child(this.arrayTypeName), 0);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -51,4 +56,14 @@ public enum PrimitiveType {
|
||||
public Name getArrayTypeName() {
|
||||
return arrayTypeName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassName getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassName getArrayClassName() {
|
||||
return arrayClassName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.types.ref;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*
|
||||
* @see JetTypeName
|
||||
*/
|
||||
public final class ClassName {
|
||||
|
||||
@NotNull
|
||||
private final FqName fqName;
|
||||
private final int typeParameterCount;
|
||||
|
||||
public ClassName(@NotNull FqName fqName, int typeParameterCount) {
|
||||
this.fqName = fqName;
|
||||
this.typeParameterCount = typeParameterCount;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FqName getFqName() {
|
||||
return fqName;
|
||||
}
|
||||
|
||||
public int getTypeParameterCount() {
|
||||
return typeParameterCount;
|
||||
}
|
||||
|
||||
|
||||
public boolean is(@NotNull ClassDescriptor clazz) {
|
||||
return DescriptorUtils.getFQName(clazz).equalsTo(fqName);
|
||||
}
|
||||
|
||||
public boolean is(@NotNull JetType type) {
|
||||
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
|
||||
return classifier instanceof ClassDescriptor && is((ClassDescriptor) classifier);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fqName + "<" + typeParameterCount + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ClassName className = (ClassName) o;
|
||||
|
||||
if (typeParameterCount != className.typeParameterCount) return false;
|
||||
if (!fqName.equals(className.fqName)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = fqName.hashCode();
|
||||
result = 31 * result + typeParameterCount;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*
|
||||
* @see ClassName
|
||||
*/
|
||||
public class JetTypeName {
|
||||
// generic types one day
|
||||
|
||||
Reference in New Issue
Block a user