Useless class IndexedSymbolTable removed
This commit is contained in:
committed by
Alexander Udalov
parent
fd3f2d93be
commit
e960247936
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.descriptors.serialization;
|
||||
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class IndexedSymbolTable<T> {
|
||||
@Nullable
|
||||
private final IndexedSymbolTable<? extends T> parent;
|
||||
private final TIntObjectHashMap<T> symbols = new TIntObjectHashMap<T>();
|
||||
|
||||
public IndexedSymbolTable(@Nullable IndexedSymbolTable<? extends T> parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void registerSymbol(int id, @NotNull T symbol) {
|
||||
symbols.put(id, symbol);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getSymbol(int id) {
|
||||
T symbol = symbols.get(id);
|
||||
if (symbol == null && parent != null) {
|
||||
return parent.getSymbol(id);
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
|
||||
}
|
||||
+13
-7
@@ -36,12 +36,16 @@ import java.util.List;
|
||||
public class TypeDeserializer {
|
||||
private final NameResolver nameResolver;
|
||||
private final ClassResolver classResolver;
|
||||
private final IndexedSymbolTable<TypeParameterDescriptor> typeParameterDescriptors;
|
||||
private final TypeDeserializer parent;
|
||||
private final TIntObjectHashMap<TypeParameterDescriptor> typeParameterDescriptors = new TIntObjectHashMap<TypeParameterDescriptor>();
|
||||
private final TIntObjectHashMap<ClassDescriptor> classDescriptors = new TIntObjectHashMap<ClassDescriptor>();
|
||||
|
||||
private final String debugName;
|
||||
|
||||
public TypeDeserializer(@NotNull TypeDeserializer parent, @NotNull String debugName) {
|
||||
public TypeDeserializer(
|
||||
@NotNull TypeDeserializer parent,
|
||||
@NotNull String debugName
|
||||
) {
|
||||
this(parent, parent.nameResolver, parent.classResolver, debugName);
|
||||
}
|
||||
|
||||
@@ -50,9 +54,8 @@ public class TypeDeserializer {
|
||||
@NotNull NameResolver nameResolver,
|
||||
@NotNull ClassResolver classResolver,
|
||||
@NotNull String debugName
|
||||
) {
|
||||
IndexedSymbolTable<TypeParameterDescriptor> parentTypeParameters = parent == null ? null : parent.typeParameterDescriptors;
|
||||
this.typeParameterDescriptors = new IndexedSymbolTable<TypeParameterDescriptor>(parentTypeParameters);
|
||||
) {
|
||||
this.parent = parent;
|
||||
this.nameResolver = nameResolver;
|
||||
this.classResolver = classResolver;
|
||||
this.debugName = debugName + (parent == null ? "" : ". Child of " + parent.debugName);
|
||||
@@ -64,7 +67,7 @@ public class TypeDeserializer {
|
||||
}
|
||||
|
||||
public void registerTypeParameter(int id, TypeParameterDescriptor typeParameter) {
|
||||
typeParameterDescriptors.registerSymbol(id, typeParameter);
|
||||
typeParameterDescriptors.put(id, typeParameter);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -102,7 +105,10 @@ public class TypeDeserializer {
|
||||
|
||||
return classDescriptor.getTypeConstructor();
|
||||
case TYPE_PARAMETER:
|
||||
TypeParameterDescriptor descriptor = typeParameterDescriptors.getSymbol(proto.getId());
|
||||
TypeParameterDescriptor descriptor = typeParameterDescriptors.get(proto.getId());
|
||||
if (descriptor == null && parent != null) {
|
||||
descriptor = parent.typeParameterDescriptors.get(proto.getId());
|
||||
}
|
||||
if (descriptor == null) return null;
|
||||
|
||||
return descriptor.getTypeConstructor();
|
||||
|
||||
Reference in New Issue
Block a user