Renamed Name.getName() and FqName.getFqName() to asString()

This commit is contained in:
Evgeny Gerashchenko
2013-05-21 17:56:04 +04:00
parent de6d5a4a96
commit 43b9a9d434
140 changed files with 294 additions and 304 deletions
@@ -115,7 +115,7 @@ public abstract class AnnotationCodegen {
}
Name keyName = entry.getKey().getName();
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName());
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.asString());
}
}
@@ -152,7 +152,7 @@ public abstract class AnnotationCodegen {
if (call != null) {
if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
PropertyDescriptor descriptor = (PropertyDescriptor) call.getResultingDescriptor();
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().getName());
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().asString());
return;
}
}
@@ -168,7 +168,7 @@ public abstract class AnnotationCodegen {
if (annotations != null) {
for (AnnotationDescriptor annotation : annotations) {
//noinspection ConstantConditions
if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) {
value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
break;
}
@@ -505,7 +505,7 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.load(index, asmType);
v.visitLdcInsn(descriptor.getName().getName());
v.visitLdcInsn(descriptor.getName().asString());
v.invokestatic("jet/runtime/Intrinsics", "checkParameterIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V");
}
}
@@ -546,8 +546,8 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.dup();
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().getName());
v.visitLdcInsn(descriptor.getName().getName());
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().asString());
v.visitLdcInsn(descriptor.getName().asString());
v.invokestatic("jet/runtime/Intrinsics", assertMethodToCall, "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V");
}
}
@@ -178,7 +178,7 @@ public class ClosureCodegen extends GenerationStateAware {
return;
}
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE, interfaceFunction.getName().getName(),
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE, interfaceFunction.getName().asString(),
bridge.getDescriptor(), null, ArrayUtil.EMPTY_STRING_ARRAY);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
@@ -203,7 +203,7 @@ public class ClosureCodegen extends GenerationStateAware {
count++;
}
iv.invokevirtual(name.getInternalName(), interfaceFunction.getName().getName(), delegate.getDescriptor());
iv.invokevirtual(name.getInternalName(), interfaceFunction.getName().asString(), delegate.getDescriptor());
StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), iv);
iv.areturn(bridge.getReturnType());
@@ -268,11 +268,11 @@ public class ClosureCodegen extends GenerationStateAware {
Type type = sharedVarType != null
? sharedVarType
: typeMapper.mapType((VariableDescriptor) descriptor);
args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().getName()));
args.add(FieldInfo.createForHiddenField(ownerType, type, "$" + descriptor.getName().asString()));
}
else if (isLocalNamedFun(descriptor)) {
JvmClassName className = classNameForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
args.add(FieldInfo.createForHiddenField(ownerType, className.getAsmType(), "$" + descriptor.getName().getName()));
args.add(FieldInfo.createForHiddenField(ownerType, className.getAsmType(), "$" + descriptor.getName().asString()));
}
else if (descriptor instanceof FunctionDescriptor) {
assert captureReceiver != null;
@@ -560,7 +560,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public void run() {
myFrameMap.leave(parameterDescriptor);
v.visitLocalVariable(parameterDescriptor.getName().getName(),
v.visitLocalVariable(parameterDescriptor.getName().asString(),
asmTypeForParameter.getDescriptor(), null,
bodyStart, bodyEnd,
loopParameterVar);
@@ -601,7 +601,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public void run() {
myFrameMap.leave(componentDescriptor);
v.visitLocalVariable(componentDescriptor.getName().getName(),
v.visitLocalVariable(componentDescriptor.getName().asString(),
componentAsmType.getDescriptor(), null,
bodyStart, bodyEnd,
componentVarIndex);
@@ -1414,7 +1414,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.store(index, OBJECT_TYPE);
}
}
v.visitLocalVariable(variableDescriptor.getName().getName(), type.getDescriptor(), null, scopeStart, blockEnd,
v.visitLocalVariable(variableDescriptor.getName().asString(), type.getDescriptor(), null, scopeStart, blockEnd,
index);
return null;
}
@@ -1628,7 +1628,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
ClassDescriptor containing = (ClassDescriptor) variableDescriptor.getContainingDeclaration().getContainingDeclaration();
assert containing != null;
Type type = typeMapper.mapType(containing);
return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().getName(), true);
return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().asString(), true);
}
else {
return StackValue.singleton(objectClassDescriptor, typeMapper);
@@ -2924,7 +2924,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
else {
DeclarationDescriptor cls = op.getContainingDeclaration();
CallableMethod callableMethod = (CallableMethod) callable;
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().getName().equals("inc") || op.getName().getName().equals("dec"))) {
if (isPrimitiveNumberClassDescriptor(cls) || !(op.getName().asString().equals("inc") || op.getName().asString().equals("dec"))) {
return invokeOperation(expression, (FunctionDescriptor) op, callableMethod);
}
else {
@@ -2981,14 +2981,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (op instanceof FunctionDescriptor) {
Type asmType = expressionType(expression);
DeclarationDescriptor cls = op.getContainingDeclaration();
if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) {
if (op.getName().asString().equals("inc") || op.getName().asString().equals("dec")) {
if (isPrimitiveNumberClassDescriptor(cls)) {
receiver.put(receiver.type, v);
JetExpression operand = expression.getBaseExpression();
if (operand instanceof JetReferenceExpression) {
int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) {
int increment = op.getName().getName().equals("inc") ? 1 : -1;
int increment = op.getName().asString().equals("inc") ? 1 : -1;
return StackValue.postIncrement(index, increment);
}
}
@@ -3053,7 +3053,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
int increment = op.getName().getName().equals("inc") ? 1 : -1;
int increment = op.getName().asString().equals("inc") ? 1 : -1;
if (operand instanceof JetReferenceExpression) {
int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) {
@@ -41,7 +41,7 @@ public class FieldInfo {
Type ownerType = typeMapper.mapType(ownerDescriptor.getDefaultType());
String fieldName = kind == ClassKind.ENUM_ENTRY
? fieldClassDescriptor.getName().getName()
? fieldClassDescriptor.getName().asString()
: fieldClassDescriptor.getKind() == ClassKind.CLASS_OBJECT ? JvmAbi.CLASS_OBJECT_FIELD : JvmAbi.INSTANCE_FIELD;
return new FieldInfo(ownerType, fieldType, fieldName, true);
}
@@ -200,7 +200,7 @@ public class FunctionCodegen extends GenerationStateAware {
List<ValueParameterDescriptor> parameters = functionDescriptor.getValueParameters();
List<String> result = new ArrayList<String>(parameters.size());
for (ValueParameterDescriptor parameter : parameters) {
result.add(parameter.getName().getName());
result.add(parameter.getName().asString());
}
return result;
}
@@ -244,7 +244,7 @@ public class FunctionCodegen extends GenerationStateAware {
if (kind == JvmMethodParameterKind.VALUE) {
ValueParameterDescriptor parameter = valueParameters.next();
Label divideLabel = labelsForSharedVars.get(parameter.getName());
parameterName = parameter.getName().getName();
parameterName = parameter.getName().asString();
if (divideLabel != null) {
mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, shift);
@@ -377,7 +377,7 @@ public class FunctionCodegen extends GenerationStateAware {
ValueParameterDescriptor parameterDescriptor = null;
if (kind == JvmMethodParameterKind.VALUE) {
parameterDescriptor = valueParameters.next();
parameterName = parameterDescriptor.getName().getName();
parameterName = parameterDescriptor.getName().asString();
} else if (kind == JvmMethodParameterKind.ENUM_NAME || kind == JvmMethodParameterKind.ENUM_ORDINAL) {
//we shouldn't generate annotations for invisible in runtime parameters otherwise we get bad RuntimeInvisibleParameterAnnotations error in javac
continue;
@@ -297,7 +297,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
innerClassInternalName = outerClassInternalName + JvmAbi.CLASS_OBJECT_SUFFIX;
}
else {
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().getName();
innerName = innerClass.getName().isSpecial() ? null : innerClass.getName().asString();
innerClassInternalName = getInternalNameForImpl(innerClass);
}
@@ -620,11 +620,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean first = true;
for (PropertyDescriptor propertyDescriptor : properties) {
if (first) {
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().getName()+"=");
iv.aconst(descriptor.getName() + "(" + propertyDescriptor.getName().asString()+"=");
first = false;
}
else {
iv.aconst(", " + propertyDescriptor.getName().getName()+"=");
iv.aconst(", " + propertyDescriptor.getName().asString()+"=");
}
genInvokeAppendMethod(iv, JAVA_STRING_TYPE);
@@ -821,7 +821,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type[] argTypes = method.getArgumentTypes();
String owner = typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION, isCallInsideSameModuleAsDeclared(original, context)).getInternalName();
MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().getName(),
MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().asString(),
method.getDescriptor(), null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
@@ -1015,7 +1015,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(descriptor);
iv.load(0, classAsmType);
iv.load(codegen.myFrameMap.getIndex(descriptor), type);
iv.putfield(classAsmType.getInternalName(), descriptor.getName().getName(), type.getDescriptor());
iv.putfield(classAsmType.getInternalName(), descriptor.getName().asString(), type.getDescriptor());
}
curParam++;
}
@@ -1097,7 +1097,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
// final property with backing field
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname,
propertyDescriptor.getName().getName(), false);
propertyDescriptor.getName().asString(), false);
}
else {
iv.load(0, classType);
@@ -148,7 +148,7 @@ public class PropertyCodegen extends GenerationStateAware {
modifiers |= ACC_VOLATILE;
}
Type type = typeMapper.mapType(propertyDescriptor);
return v.newField(p, modifiers, propertyDescriptor.getName().getName(), type.getDescriptor(), null, value);
return v.newField(p, modifiers, propertyDescriptor.getName().asString(), type.getDescriptor(), null, value);
}
private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) {
@@ -248,7 +248,7 @@ public class PropertyCodegen extends GenerationStateAware {
iv.visitFieldInsn(
kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
propertyDescriptor.getName().getName(),
propertyDescriptor.getName().asString(),
type.getDescriptor());
iv.areturn(type);
}
@@ -265,7 +265,7 @@ public class PropertyCodegen extends GenerationStateAware {
iv.load(paramCode, type);
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD,
typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
propertyDescriptor.getName().getName(),
propertyDescriptor.getName().asString(),
type.getDescriptor());
iv.visitInsn(RETURN);
@@ -336,11 +336,11 @@ public class PropertyCodegen extends GenerationStateAware {
}
public static String getterName(Name propertyName) {
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
public static String setterName(Name propertyName) {
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString());
}
public void genDelegate(PropertyDescriptor delegate, PropertyDescriptor overridden, StackValue field) {
@@ -112,7 +112,7 @@ public class RangeCodegenUtil {
}
public static boolean isOptimizableRangeTo(CallableDescriptor rangeTo) {
if ("rangeTo".equals(rangeTo.getName().getName())) {
if ("rangeTo".equals(rangeTo.getName().asString())) {
if (isPrimitiveNumberClassDescriptor(rangeTo.getContainingDeclaration())) {
return true;
}
@@ -913,7 +913,7 @@ public abstract class StackValue {
}
private String getPropertyName() {
return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().getName();
return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().asString();
}
}
@@ -227,7 +227,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
private String getName(ClassDescriptor classDescriptor) {
String base = peekFromStack(nameStack);
return DescriptorUtils.isTopLevelDeclaration(classDescriptor) ? base.isEmpty() ? classDescriptor.getName()
.getName() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
.asString() : base + '/' + classDescriptor.getName() : base + '$' + classDescriptor.getName();
}
@Override
@@ -350,7 +350,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
String peek = peekFromStack(nameStack);
String name = descriptor.getName().getName();
String name = descriptor.getName().asString();
if (containingDeclaration instanceof ClassDescriptor) {
return peek + '$' + name;
}
@@ -116,7 +116,7 @@ public final class PsiCodegenPredictor {
if (declaration instanceof JetNamedFunction) {
if (parentDeclaration == null) {
JvmClassName packageClass = addPackageClass(parentClassName);
return JvmClassName.byInternalName(packageClass.getInternalName() + "$" + name.getName());
return JvmClassName.byInternalName(packageClass.getInternalName() + "$" + name.asString());
}
if (!(parentDeclaration instanceof JetClass || parentDeclaration instanceof JetObjectDeclaration)) {
@@ -128,16 +128,16 @@ public final class PsiCodegenPredictor {
// NOTE: looks like a bug - for class in getter of top level property class name will be $propertyName$ClassName but not
// namespace$propertyName$ClassName
if (declaration instanceof JetProperty) {
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.getName());
return JvmClassName.byInternalName(parentClassName.getInternalName() + "$" + name.asString());
}
if (fqName.isRoot()) {
return JvmClassName.byInternalName(name.getName());
return JvmClassName.byInternalName(name.asString());
}
return JvmClassName.byInternalName(parentDeclaration == null ?
parentClassName.getInternalName() + "/" + name.getName() :
parentClassName.getInternalName() + "$" + name.getName());
parentClassName.getInternalName() + "/" + name.asString() :
parentClassName.getInternalName() + "$" + name.asString());
}
return null;
@@ -241,7 +241,7 @@ public class IntrinsicMethods {
for (AnnotationDescriptor annotation : annotations) {
ClassifierDescriptor classifierDescriptor = annotation.getType().getConstructor().getDeclarationDescriptor();
assert classifierDescriptor != null;
if ("Intrinsic".equals(classifierDescriptor.getName().getName())) {
if ("Intrinsic".equals(classifierDescriptor.getName().asString())) {
String value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
intrinsicMethod = namedMethods.get(value);
if (intrinsicMethod != null) {
@@ -51,7 +51,7 @@ public class StaticField implements IntrinsicMethod {
StackValue receiver,
@NotNull GenerationState state
) {
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.getName(), expectedType.getDescriptor());
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.asString(), expectedType.getDescriptor());
return StackValue.onStack(expectedType);
}
}
@@ -272,8 +272,8 @@ public class BothSignatureWriter {
}
public void writeTypeVariable(Name name, boolean nullable, Type asmType) {
signatureVisitor().visitTypeVariable(name.getName());
jetSignatureWriter.visitTypeVariable(name.getName(), nullable);
signatureVisitor().visitTypeVariable(name.asString());
jetSignatureWriter.visitTypeVariable(name.asString(), nullable);
generic = true;
writeAsmType0(asmType);
}
@@ -578,7 +578,7 @@ public class JetTypeMapper extends BindingTraceAware {
@NotNull
public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, boolean needGenericSignature, @NotNull OwnerKind kind) {
String name = f.getName().getName();
String name = f.getName().asString();
if (f instanceof PropertyAccessorDescriptor) {
boolean isGetter = f instanceof PropertyGetterDescriptor;
name = getPropertyAccessorName(((PropertyAccessorDescriptor) f).getCorrespondingProperty(), isGetter);
@@ -588,7 +588,7 @@ public class JetTypeMapper extends BindingTraceAware {
@NotNull
public JvmMethodSignature mapSignature(@NotNull Name functionName, @NotNull FunctionDescriptor f) {
return mapSignature(functionName.getName(), f, false, OwnerKind.IMPLEMENTATION);
return mapSignature(functionName.asString(), f, false, OwnerKind.IMPLEMENTATION);
}
@NotNull
@@ -675,7 +675,7 @@ public class JetTypeMapper extends BindingTraceAware {
}
private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) {
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(),
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().asString(), typeParameterDescriptor.getVariance(),
typeParameterDescriptor.isReified());
classBound:
@@ -730,7 +730,7 @@ public class JetTypeMapper extends BindingTraceAware {
DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration();
boolean isAnnotation = parentDescriptor instanceof ClassDescriptor &&
((ClassDescriptor) parentDescriptor).getKind() == ClassKind.ANNOTATION_CLASS;
return isAnnotation ? descriptor.getName().getName() :
return isAnnotation ? descriptor.getName().asString() :
isGetter ? PropertyCodegen.getterName(descriptor.getName()) : PropertyCodegen.setterName(descriptor.getName());
}