Name class

In the most places in frontend identifier is stored in Name class, was in String.
Name has two advantages over String:
* validation: you cannot accidentally create identifier with dot, for example
* readability: if you see String, you don't now whether it is
  identifier, fq name, jvm class name or something else

Name's disadvantage is (small) performance overhead. We have no value types in JVM.
This commit is contained in:
Stepan Koltsov
2012-05-23 02:52:32 +04:00
parent c15ff2dee0
commit 33a59ff5fe
152 changed files with 962 additions and 726 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ import org.jetbrains.jet.j2k.ast.Class;
import org.jetbrains.jet.j2k.ast.Enum;
import org.jetbrains.jet.j2k.util.AstUtil;
import org.jetbrains.jet.j2k.visitors.*;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import java.util.*;
@@ -781,7 +782,7 @@ public class Converter {
@NotNull
private static String getPrimitiveTypeConversion(@NotNull String type) {
Map<String, String> conversions = new HashMap<String, String>();
Map<String, Name> conversions = new HashMap<String, Name>();
conversions.put("byte", BYTE);
conversions.put("short", SHORT);
conversions.put("int", INT);
@@ -62,7 +62,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements J2KVisitor {
final IdentifierImpl identifier = new IdentifierImpl(name);
if (name.equals("void")) {
myResult = new PrimitiveType(new IdentifierImpl(JetStandardClasses.UNIT_ALIAS));
myResult = new PrimitiveType(new IdentifierImpl(JetStandardClasses.UNIT_ALIAS.getName()));
}
else if (Node.PRIMITIVE_TYPES.contains(name)) {
myResult = new PrimitiveType(new IdentifierImpl(AstUtil.upperFirstCharacter(name)));