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:
@@ -135,13 +135,6 @@ public final class TipsManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (descriptor instanceof NamespaceDescriptor) {
|
||||
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) descriptor;
|
||||
if (namespaceDescriptor.getName().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.objectweb.asm.*;
|
||||
|
||||
@@ -101,8 +102,8 @@ public abstract class AnnotationCodegen {
|
||||
continue;
|
||||
}
|
||||
|
||||
String keyName = entry.getKey().getName();
|
||||
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName);
|
||||
Name keyName = entry.getKey().getName();
|
||||
genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ public abstract class AnnotationCodegen {
|
||||
if(call != null) {
|
||||
if(call.getResultingDescriptor() instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor descriptor = (PropertyDescriptor)call.getResultingDescriptor();
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName());
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName().getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -154,7 +155,7 @@ public abstract class AnnotationCodegen {
|
||||
String value = null;
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
value = (String) annotation.getValueArguments().get(0).getValue();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
@@ -74,7 +75,7 @@ public class ClosureAnnotator {
|
||||
funDescriptor,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
// TODO: internal name used as identifier
|
||||
name.getInternalName()); // TODO:
|
||||
Name.identifier(name.getInternalName())); // TODO:
|
||||
classDescriptor.initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
@@ -126,8 +127,7 @@ public class ClosureAnnotator {
|
||||
}
|
||||
|
||||
public boolean hasThis0(ClassDescriptor classDescriptor) {
|
||||
if(DescriptorUtils.isClassObject(classDescriptor))
|
||||
return false;
|
||||
if (DescriptorUtils.isClassObject(classDescriptor)) { return false; }
|
||||
|
||||
ClassDescriptor other = enclosing.get(classDescriptor);
|
||||
return other != null;
|
||||
@@ -208,11 +208,10 @@ public class ClosureAnnotator {
|
||||
recordEnclosing(classDescriptor);
|
||||
classStack.push(classDescriptor);
|
||||
String base = nameStack.peek();
|
||||
if(classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName() : base + '/' + classDescriptor.getName());
|
||||
if (classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName().getName() : base + '/' + classDescriptor.getName());
|
||||
}
|
||||
else
|
||||
nameStack.push(base + '$' + classDescriptor.getName());
|
||||
else { nameStack.push(base + '$' + classDescriptor.getName()); }
|
||||
super.visitObjectDeclaration(declaration);
|
||||
nameStack.pop();
|
||||
classStack.pop();
|
||||
@@ -227,11 +226,10 @@ public class ClosureAnnotator {
|
||||
recordEnclosing(classDescriptor);
|
||||
classStack.push(classDescriptor);
|
||||
String base = nameStack.peek();
|
||||
if(classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName() : base + '/' + classDescriptor.getName());
|
||||
if (classDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
nameStack.push(base.isEmpty() ? classDescriptor.getName().getName() : base + '/' + classDescriptor.getName());
|
||||
}
|
||||
else
|
||||
nameStack.push(base + '$' + classDescriptor.getName());
|
||||
else { nameStack.push(base + '$' + classDescriptor.getName()); }
|
||||
super.visitClass(klass);
|
||||
nameStack.pop();
|
||||
classStack.pop();
|
||||
@@ -298,10 +296,8 @@ public class ClosureAnnotator {
|
||||
}
|
||||
else if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
String peek = nameStack.peek();
|
||||
if(peek.isEmpty())
|
||||
peek = "namespace";
|
||||
else
|
||||
peek = peek + "/namespace";
|
||||
if (peek.isEmpty()) { peek = "namespace"; }
|
||||
else { peek = peek + "/namespace"; }
|
||||
nameStack.push(peek + '$' + function.getName());
|
||||
super.visitNamedFunction(function);
|
||||
nameStack.pop();
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -99,7 +100,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
||||
}
|
||||
|
||||
public JvmMethodSignature invokeSignature(FunctionDescriptor fd) {
|
||||
return state.getInjector().getJetTypeMapper().mapSignature("invoke", fd);
|
||||
return state.getInjector().getJetTypeMapper().mapSignature(Name.identifier("invoke"), fd);
|
||||
}
|
||||
|
||||
public GeneratedAnonymousClassDescriptor gen(JetExpression fun) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
@@ -97,8 +98,7 @@ public abstract class CodegenContext {
|
||||
}
|
||||
|
||||
protected StackValue getOuterExpression(@Nullable StackValue prefix) {
|
||||
if(outerExpression == null)
|
||||
throw new UnsupportedOperationException();
|
||||
if (outerExpression == null) { throw new UnsupportedOperationException(); }
|
||||
|
||||
outerWasUsed = outerExpression.type;
|
||||
return prefix != null ? StackValue.composed(prefix, outerExpression) : outerExpression;
|
||||
@@ -173,8 +173,7 @@ public abstract class CodegenContext {
|
||||
final ObjectOrClosureCodegen top = closure;
|
||||
if (top != null) {
|
||||
final StackValue answer = top.lookupInContext(d, result);
|
||||
if (answer != null)
|
||||
return result == null ? answer : StackValue.composed(result, answer);
|
||||
if (answer != null) { return result == null ? answer : StackValue.composed(result, answer); }
|
||||
|
||||
StackValue outer = getOuterExpression(null);
|
||||
result = result == null ? outer : StackValue.composed(result, outer);
|
||||
@@ -185,15 +184,13 @@ public abstract class CodegenContext {
|
||||
|
||||
public Type enclosingClassType(JetTypeMapper typeMapper) {
|
||||
CodegenContext cur = getParentContext();
|
||||
while(cur != null && !(cur.getContextDescriptor() instanceof ClassDescriptor))
|
||||
cur = cur.getParentContext();
|
||||
while (cur != null && !(cur.getContextDescriptor() instanceof ClassDescriptor)) { cur = cur.getParentContext(); }
|
||||
|
||||
return cur == null ? null : typeMapper.mapType(((ClassDescriptor) cur.getContextDescriptor()).getDefaultType(), MapTypeMode.IMPL);
|
||||
}
|
||||
|
||||
public int getTypeInfoConstantIndex(JetType type) {
|
||||
if(parentContext != STATIC)
|
||||
return parentContext.getTypeInfoConstantIndex(type);
|
||||
if (parentContext != STATIC) { return parentContext.getTypeInfoConstantIndex(type); }
|
||||
|
||||
if(typeInfoConstants == null) {
|
||||
typeInfoConstants = new LinkedHashMap<JetType, Integer>();
|
||||
@@ -215,13 +212,12 @@ public abstract class CodegenContext {
|
||||
}
|
||||
descriptor = descriptor.getOriginal();
|
||||
DeclarationDescriptor accessor = accessors.get(descriptor);
|
||||
if(accessor != null)
|
||||
return accessor;
|
||||
if (accessor != null) { return accessor; }
|
||||
|
||||
if(descriptor instanceof SimpleFunctionDescriptor) {
|
||||
SimpleFunctionDescriptorImpl myAccessor = new SimpleFunctionDescriptorImpl(contextType,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
descriptor.getName() + "$bridge$" + accessors.size(),
|
||||
Name.identifier(descriptor.getName() + "$bridge$" + accessors.size()), // TODO: evil
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
FunctionDescriptor fd = (SimpleFunctionDescriptor) descriptor;
|
||||
myAccessor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
@@ -242,7 +238,7 @@ public abstract class CodegenContext {
|
||||
pd.getVisibility(),
|
||||
pd.isVar(),
|
||||
pd.isObjectDeclaration(),
|
||||
pd.getName() + "$bridge$" + accessors.size(),
|
||||
Name.identifier(pd.getName() + "$bridge$" + accessors.size()), // TODO: evil
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class CodegenUtil {
|
||||
SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl(
|
||||
fd.getExpectedThisObject().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity),
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
"invoke",
|
||||
Name.identifier("invoke"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
|
||||
invokeDescriptor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
|
||||
@@ -1010,7 +1010,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if(classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
ClassDescriptor containing = (ClassDescriptor) classDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||
Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE);
|
||||
StackValue.field(type, type.getInternalName(), classDescriptor.getName(), true).put(TYPE_OBJECT, v);
|
||||
StackValue.field(type, type.getInternalName(), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v);
|
||||
|
||||
// todo: for now we don't generate classes for enum entries, so we need this hack
|
||||
type = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
@@ -1148,7 +1148,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
isInterface = CodegenUtil.isInterface(containingDeclaration);
|
||||
}
|
||||
|
||||
v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor());
|
||||
v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName().getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor());
|
||||
StackValue.onStack(asmType(functionDescriptor.getReturnType())).coerce(type, v);
|
||||
}
|
||||
|
||||
@@ -1238,7 +1238,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
ownerParam = callableMethod.getDefaultImplParam();
|
||||
}
|
||||
|
||||
return StackValue.property(propertyDescriptor.getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
|
||||
return StackValue.property(propertyDescriptor.getName().getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1951,7 +1951,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
String className = descriptor.getName();
|
||||
String className = descriptor.getName().getName();
|
||||
return className.equals("Int") || className.equals("Long") || className.equals("Short") ||
|
||||
className.equals("Byte") || className.equals("Char") || className.equals("Float") ||
|
||||
className.equals("Double");
|
||||
@@ -1961,7 +1961,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (!(descriptor instanceof ClassDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
String className = descriptor.getName();
|
||||
String className = descriptor.getName().getName();
|
||||
return className.equals(name);
|
||||
}
|
||||
|
||||
@@ -2113,7 +2113,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
else {
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
if (isNumberPrimitive(cls) || !(op.getName().equals("inc") || op.getName().equals("dec")) ) {
|
||||
if (isNumberPrimitive(cls) || !(op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) ) {
|
||||
return invokeOperation(expression, (FunctionDescriptor) op, (CallableMethod) callable);
|
||||
}
|
||||
else {
|
||||
@@ -2165,14 +2165,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (op instanceof FunctionDescriptor) {
|
||||
final Type asmType = expressionType(expression);
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
if (op.getName().equals("inc") || op.getName().equals("dec")) {
|
||||
if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) {
|
||||
if (isNumberPrimitive(cls)) {
|
||||
receiver.put(receiver.type, v);
|
||||
JetExpression operand = expression.getBaseExpression();
|
||||
if (operand instanceof JetReferenceExpression) {
|
||||
final int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0 && isIntPrimitive(asmType)) {
|
||||
int increment = op.getName().equals("inc") ? 1 : -1;
|
||||
int increment = op.getName().getName().equals("inc") ? 1 : -1;
|
||||
return StackValue.postIncrement(index, increment);
|
||||
}
|
||||
}
|
||||
@@ -2230,7 +2230,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
|
||||
int increment = op.getName().equals("inc") ? 1 : -1;
|
||||
int increment = op.getName().getName().equals("inc") ? 1 : -1;
|
||||
if (operand instanceof JetReferenceExpression) {
|
||||
final int index = indexOfLocal((JetReferenceExpression) operand);
|
||||
if (index >= 0 && isIntPrimitive(asmType)) {
|
||||
|
||||
@@ -159,7 +159,7 @@ public class FunctionCodegen {
|
||||
for(int i = 0; i != paramDescrs.size(); ++i) {
|
||||
JetValueParameterAnnotationWriter av = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, i + start);
|
||||
ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i);
|
||||
av.writeName(parameterDescriptor.getName());
|
||||
av.writeName(parameterDescriptor.getName().getName());
|
||||
av.writeHasDefaultValue(parameterDescriptor.declaresDefaultValue());
|
||||
av.writeNullable(parameterDescriptor.getType().isNullable());
|
||||
if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) {
|
||||
@@ -261,7 +261,7 @@ public class FunctionCodegen {
|
||||
for (ValueParameterDescriptor parameter : paramDescrs) {
|
||||
Type type = state.getInjector().getJetTypeMapper().mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
// TODO: specify signature
|
||||
mv.visitLocalVariable(parameter.getName(), type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||
mv.visitLocalVariable(parameter.getName().getName(), type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||
k += type.getSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
// TODO: cache internal names
|
||||
String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String innerClassInternalName = typeMapper.mapType(innerClass.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName(), innerClassAccess);
|
||||
v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName().getName(), innerClassAccess);
|
||||
}
|
||||
|
||||
if (descriptor.getClassObjectDescriptor() != null) {
|
||||
@@ -298,7 +298,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Method originalMethod = typeMapper.mapSignature(original.getName(), original).getAsmMethod();
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
|
||||
MethodVisitor mv = v.newMethod(null, ACC_PUBLIC| ACC_BRIDGE| ACC_FINAL, bridge.getName(), method.getDescriptor(), null, null);
|
||||
MethodVisitor mv = v.newMethod(null, ACC_PUBLIC| ACC_BRIDGE| ACC_FINAL, bridge.getName().getName(), method.getDescriptor(), null, null);
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
||||
StubCodegen.generateStubCode(mv);
|
||||
}
|
||||
@@ -340,7 +340,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||
if(original.getVisibility() == Visibilities.PRIVATE)
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName(), originalMethod.getReturnType().getDescriptor());
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getReturnType().getDescriptor());
|
||||
else
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
@@ -373,7 +373,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
reg += argType.getSize();
|
||||
}
|
||||
if(original.getVisibility() == Visibilities.PRIVATE && original.getModality() == Modality.FINAL)
|
||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||
else
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
@@ -484,7 +484,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if(closure != null) {
|
||||
if(closure.captureThis != null) {
|
||||
if(!hasThis0)
|
||||
consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName()), "", JvmMethodParameterKind.THIS0));
|
||||
consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName().getName()), "", JvmMethodParameterKind.THIS0));
|
||||
insert++;
|
||||
}
|
||||
else {
|
||||
@@ -553,7 +553,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
for (ValueParameterDescriptor valueParameter : constructorDescriptor.getValueParameters()) {
|
||||
JetValueParameterAnnotationWriter jetValueParameterAnnotation = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, i);
|
||||
jetValueParameterAnnotation.writeName(valueParameter.getName());
|
||||
jetValueParameterAnnotation.writeName(valueParameter.getName().getName());
|
||||
jetValueParameterAnnotation.writeHasDefaultValue(valueParameter.declaresDefaultValue());
|
||||
jetValueParameterAnnotation.writeType(constructorMethod.getKotlinParameterType(i));
|
||||
jetValueParameterAnnotation.visitEnd();
|
||||
@@ -689,7 +689,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type type = typeMapper.mapType(descriptor.getType(), MapTypeMode.VALUE);
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getIndex(descriptor), type);
|
||||
iv.putfield(classname, descriptor.getName(), type.getDescriptor());
|
||||
iv.putfield(classname, descriptor.getName().getName(), type.getDescriptor());
|
||||
}
|
||||
curParam++;
|
||||
}
|
||||
@@ -954,7 +954,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
codegen.gen(initializer, type);
|
||||
// @todo write directly to the field. Fix test excloset.jet::test6
|
||||
String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
StackValue.property(propertyDescriptor.getName(), owner, owner,
|
||||
StackValue.property(propertyDescriptor.getName().getName(), owner, owner,
|
||||
typeMapper.mapType(propertyDescriptor.getType(), MapTypeMode.VALUE), false, false, false, null, null, 0).store(iv);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -222,10 +223,6 @@ public class JetTypeMapper {
|
||||
r.append("$");
|
||||
}
|
||||
}
|
||||
if (ns.getName().length() == 0) {
|
||||
throw new IllegalStateException(
|
||||
"name must not be empty at this point when generating for " + namespace);
|
||||
}
|
||||
r.append(ns.getName());
|
||||
}
|
||||
|
||||
@@ -316,14 +313,17 @@ public class JetTypeMapper {
|
||||
}
|
||||
|
||||
DeclarationDescriptor container = descriptor.getContainingDeclaration();
|
||||
String name = descriptor.getName();
|
||||
Name name = descriptor.getName();
|
||||
if(JetPsiUtil.NO_NAME_PROVIDED.equals(name)) {
|
||||
return closureAnnotator
|
||||
.classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor))
|
||||
.getInternalName();
|
||||
}
|
||||
if(name.contains("/"))
|
||||
return name;
|
||||
|
||||
// This is the worst code in the project
|
||||
if(name.getName().contains("/"))
|
||||
return name.getName();
|
||||
|
||||
if (container != null) {
|
||||
String baseName = getFQName(container);
|
||||
if (!baseName.isEmpty()) {
|
||||
@@ -331,7 +331,7 @@ public class JetTypeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
return name.getName();
|
||||
}
|
||||
|
||||
private static ClassDescriptor getContainingClass(DeclarationDescriptor descriptor) {
|
||||
@@ -667,7 +667,7 @@ public class JetTypeMapper {
|
||||
mapReturnType(f.getReturnType(), signatureVisitor);
|
||||
signatureVisitor.writeReturnTypeEnd();
|
||||
}
|
||||
return signatureVisitor.makeJvmMethodSignature(f.getName());
|
||||
return signatureVisitor.makeJvmMethodSignature(f.getName().getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ public class JetTypeMapper {
|
||||
}
|
||||
|
||||
private void writeFormalTypeParameter(TypeParameterDescriptor typeParameterDescriptor, BothSignatureWriter signatureVisitor) {
|
||||
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName(), typeParameterDescriptor.getVariance(), typeParameterDescriptor.isReified());
|
||||
signatureVisitor.writeFormalTypeParameter(typeParameterDescriptor.getName().getName(), typeParameterDescriptor.getVariance(), typeParameterDescriptor.isReified());
|
||||
|
||||
classBound:
|
||||
{
|
||||
@@ -725,7 +725,7 @@ public class JetTypeMapper {
|
||||
|
||||
}
|
||||
|
||||
public JvmMethodSignature mapSignature(String name, FunctionDescriptor f) {
|
||||
public JvmMethodSignature mapSignature(Name name, FunctionDescriptor f) {
|
||||
final ReceiverDescriptor receiver = f.getReceiverParameter();
|
||||
|
||||
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, false);
|
||||
@@ -752,7 +752,7 @@ public class JetTypeMapper {
|
||||
mapReturnType(f.getReturnType(), signatureWriter);
|
||||
signatureWriter.writeReturnTypeEnd();
|
||||
|
||||
return signatureWriter.makeJvmMethodSignature(name);
|
||||
return signatureWriter.makeJvmMethodSignature(name.getName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -206,7 +207,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
else {
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.GETSTATIC : Opcodes.GETFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName(),
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
iv.areturn(type);
|
||||
@@ -296,7 +297,7 @@ public class PropertyCodegen {
|
||||
else {
|
||||
iv.load(paramCode, type);
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName(),
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -307,12 +308,12 @@ public class PropertyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getterName(String propertyName) {
|
||||
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName);
|
||||
public static String getterName(Name propertyName) {
|
||||
return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
|
||||
}
|
||||
|
||||
public static String setterName(String propertyName) {
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName);
|
||||
public static String setterName(Name propertyName) {
|
||||
return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.getName());
|
||||
}
|
||||
|
||||
public void genDelegate(PropertyDescriptor declaration, PropertyDescriptor overriddenDescriptor, StackValue field) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.psi.search.ProjectScope;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
@@ -54,8 +55,8 @@ public class IntrinsicMethods {
|
||||
private static final IntrinsicMethod INC = new Increment(1);
|
||||
private static final IntrinsicMethod DEC = new Increment(-1);
|
||||
|
||||
private static final List<String> PRIMITIVE_TYPES = ImmutableList.of("Boolean", "Byte", "Char", "Short", "Int", "Float", "Long", "Double");
|
||||
private static final List<String> PRIMITIVE_NUMBER_TYPES = ImmutableList.of("Byte", "Char", "Short", "Int", "Float", "Long", "Double");
|
||||
private static final List<Name> PRIMITIVE_TYPES = ImmutableList.of(Name.identifier("Boolean"), Name.identifier("Byte"), Name.identifier("Char"), Name.identifier("Short"), Name.identifier("Int"), Name.identifier("Float"), Name.identifier("Long"), Name.identifier("Double"));
|
||||
private static final List<Name> PRIMITIVE_NUMBER_TYPES = ImmutableList.of(Name.identifier("Byte"), Name.identifier("Char"), Name.identifier("Short"), Name.identifier("Int"), Name.identifier("Float"), Name.identifier("Long"), Name.identifier("Double"));
|
||||
public static final IntrinsicMethod ARRAY_SIZE = new ArraySize();
|
||||
public static final IntrinsicMethod ARRAY_INDICES = new ArrayIndices();
|
||||
public static final Equals EQUALS = new Equals();
|
||||
@@ -91,69 +92,69 @@ public class IntrinsicMethods {
|
||||
namedMethods.put(KOTLIN_JAVA_CLASS_PROPERTY, new JavaClassProperty());
|
||||
namedMethods.put(KOTLIN_ARRAYS_ARRAY, new JavaClassArray());
|
||||
|
||||
List<String> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
|
||||
for (String method : primitiveCastMethods) {
|
||||
declareIntrinsicFunction("Number", method, 0, NUMBER_CAST, true);
|
||||
for (String type : PRIMITIVE_NUMBER_TYPES) {
|
||||
ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
|
||||
for (Name method : primitiveCastMethods) {
|
||||
declareIntrinsicFunction(Name.identifier("Number"), method, 0, NUMBER_CAST, true);
|
||||
for (Name type : PRIMITIVE_NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type, method, 0, NUMBER_CAST, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (String type : PRIMITIVE_NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type, "plus", 0, UNARY_PLUS, false);
|
||||
declareIntrinsicFunction(type, "minus", 0, UNARY_MINUS, false);
|
||||
declareIntrinsicFunction(type, "inv", 0, INV, false);
|
||||
declareIntrinsicFunction(type, "rangeTo", 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, "upto", 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, "downto", 1, DOWN_TO, false);
|
||||
declareIntrinsicFunction(type, "inc", 0, INC, false);
|
||||
declareIntrinsicFunction(type, "dec", 0, DEC, false);
|
||||
for (Name type : PRIMITIVE_NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type, Name.identifier("plus"), 0, UNARY_PLUS, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("minus"), 0, UNARY_MINUS, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("inv"), 0, INV, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("rangeTo"), 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("upto"), 1, UP_TO, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("downto"), 1, DOWN_TO, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("inc"), 0, INC, false);
|
||||
declareIntrinsicFunction(type, Name.identifier("dec"), 0, DEC, false);
|
||||
}
|
||||
|
||||
declareBinaryOp("plus", Opcodes.IADD);
|
||||
declareBinaryOp("minus", Opcodes.ISUB);
|
||||
declareBinaryOp("times", Opcodes.IMUL);
|
||||
declareBinaryOp("div", Opcodes.IDIV);
|
||||
declareBinaryOp("mod", Opcodes.IREM);
|
||||
declareBinaryOp("shl", Opcodes.ISHL);
|
||||
declareBinaryOp("shr", Opcodes.ISHR);
|
||||
declareBinaryOp("ushr", Opcodes.IUSHR);
|
||||
declareBinaryOp("and", Opcodes.IAND);
|
||||
declareBinaryOp("or", Opcodes.IOR);
|
||||
declareBinaryOp("xor", Opcodes.IXOR);
|
||||
declareBinaryOp(Name.identifier("plus"), Opcodes.IADD);
|
||||
declareBinaryOp(Name.identifier("minus"), Opcodes.ISUB);
|
||||
declareBinaryOp(Name.identifier("times"), Opcodes.IMUL);
|
||||
declareBinaryOp(Name.identifier("div"), Opcodes.IDIV);
|
||||
declareBinaryOp(Name.identifier("mod"), Opcodes.IREM);
|
||||
declareBinaryOp(Name.identifier("shl"), Opcodes.ISHL);
|
||||
declareBinaryOp(Name.identifier("shr"), Opcodes.ISHR);
|
||||
declareBinaryOp(Name.identifier("ushr"), Opcodes.IUSHR);
|
||||
declareBinaryOp(Name.identifier("and"), Opcodes.IAND);
|
||||
declareBinaryOp(Name.identifier("or"), Opcodes.IOR);
|
||||
declareBinaryOp(Name.identifier("xor"), Opcodes.IXOR);
|
||||
|
||||
declareIntrinsicFunction("Boolean", "not", 0, new Not(), true);
|
||||
declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("not"), 0, new Not(), true);
|
||||
|
||||
declareIntrinsicFunction("String", "plus", 1, new Concat(), true);
|
||||
declareIntrinsicFunction("CharSequence", "get", 1, new StringGetChar(), true);
|
||||
declareIntrinsicFunction("String", "get", 1, new StringGetChar(), true);
|
||||
declareIntrinsicFunction(Name.identifier("String"), Name.identifier("plus"), 1, new Concat(), true);
|
||||
declareIntrinsicFunction(Name.identifier("CharSequence"), Name.identifier("get"), 1, new StringGetChar(), true);
|
||||
declareIntrinsicFunction(Name.identifier("String"), Name.identifier("get"), 1, new StringGetChar(), true);
|
||||
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("toString"), 0, new ToString());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("equals"), 1, EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("identityEquals"), 1, IDENTITY_EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("plus"), 1, STRING_PLUS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("arrayOfNulls"), 1, new NewArray());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("sure"), 0, new Sure());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("synchronized"), 2, new StupidSync());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("iterator"), 0, new IteratorIterator());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("toString")), 0, new ToString());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("equals")), 1, EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("identityEquals")), 1, IDENTITY_EQUALS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("plus")), 1, STRING_PLUS);
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("arrayOfNulls")), 1, new NewArray());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("sure")), 0, new Sure());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("synchronized")), 2, new StupidSync());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions(Name.identifier("iterator")), 0, new IteratorIterator());
|
||||
|
||||
declareIntrinsicFunction("ByteIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("ShortIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("IntIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("LongIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("CharIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("BooleanIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("FloatIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction("DoubleIterator", "next", 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("ByteIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("ShortIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("IntIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("LongIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("CharIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("BooleanIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("FloatIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
declareIntrinsicFunction(Name.identifier("DoubleIterator"), Name.identifier("next"), 0, ITERATOR_NEXT, false);
|
||||
|
||||
for (String type : PRIMITIVE_TYPES) {
|
||||
declareIntrinsicFunction(type, "compareTo", 1, new CompareTo(), false);
|
||||
for (Name type : PRIMITIVE_TYPES) {
|
||||
declareIntrinsicFunction(type, Name.identifier("compareTo"), 1, new CompareTo(), false);
|
||||
}
|
||||
// declareIntrinsicFunction("Any", "equals", 1, new Equals());
|
||||
//
|
||||
declareIntrinsicStringMethods();
|
||||
declareIntrinsicProperty("CharSequence", "length", new StringLength());
|
||||
declareIntrinsicProperty("String", "length", new StringLength());
|
||||
declareIntrinsicProperty(Name.identifier("CharSequence"), Name.identifier("length"), new StringLength());
|
||||
declareIntrinsicProperty(Name.identifier("String"), Name.identifier("length"), new StringLength());
|
||||
|
||||
declareArrayMethods();
|
||||
}
|
||||
@@ -164,24 +165,24 @@ public class IntrinsicMethods {
|
||||
declareArrayMethodsForPrimitive(jvmPrimitiveType);
|
||||
}
|
||||
|
||||
declareIntrinsicProperty("Array", "size", ARRAY_SIZE);
|
||||
declareIntrinsicProperty("Array", "indices", ARRAY_INDICES);
|
||||
declareIntrinsicFunction("Array", "set", 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction("Array", "get", 1, ARRAY_GET, true);
|
||||
declareIntrinsicProperty(Name.identifier("Array"), Name.identifier("size"), ARRAY_SIZE);
|
||||
declareIntrinsicProperty(Name.identifier("Array"), Name.identifier("indices"), ARRAY_INDICES);
|
||||
declareIntrinsicFunction(Name.identifier("Array"), Name.identifier("set"), 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction(Name.identifier("Array"), Name.identifier("get"), 1, ARRAY_GET, true);
|
||||
declareIterator(myStdLib.getArray());
|
||||
}
|
||||
|
||||
private void declareArrayMethodsForPrimitive(JvmPrimitiveType jvmPrimitiveType) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), "size", ARRAY_SIZE);
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), "indices", ARRAY_INDICES);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), "set", 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), "get", 1, ARRAY_GET, true);
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), Name.identifier("size"), ARRAY_SIZE);
|
||||
declareIntrinsicProperty(primitiveType.getArrayTypeName(), Name.identifier("indices"), ARRAY_INDICES);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), Name.identifier("set"), 2, ARRAY_SET, true);
|
||||
declareIntrinsicFunction(primitiveType.getArrayTypeName(), Name.identifier("get"), 1, ARRAY_GET, true);
|
||||
declareIterator(myStdLib.getPrimitiveArrayClassDescriptor(primitiveType));
|
||||
}
|
||||
|
||||
private void declareIterator(ClassDescriptor classDescriptor) {
|
||||
declareOverload(classDescriptor.getDefaultType().getMemberScope().getFunctions("iterator"), 0, ARRAY_ITERATOR);
|
||||
declareOverload(classDescriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("iterator")), 0, ARRAY_ITERATOR);
|
||||
}
|
||||
|
||||
private void declareIntrinsicStringMethods() {
|
||||
@@ -200,7 +201,7 @@ public class IntrinsicMethods {
|
||||
if (stringMember instanceof SimpleFunctionDescriptor) {
|
||||
final SimpleFunctionDescriptor stringMethod = (SimpleFunctionDescriptor) stringMember;
|
||||
final PsiMethod[] methods = stringPsiClass != null?
|
||||
stringPsiClass.findMethodsByName(stringMember.getName(), false) : new PsiMethod[]{};
|
||||
stringPsiClass.findMethodsByName(stringMember.getName().getName(), false) : new PsiMethod[]{};
|
||||
for (PsiMethod method : methods) {
|
||||
if (method.getParameterList().getParametersCount() == stringMethod.getValueParameters().size()) {
|
||||
myMethods.put(stringMethod, new PsiMethodCall(stringMethod));
|
||||
@@ -210,14 +211,14 @@ public class IntrinsicMethods {
|
||||
}
|
||||
}
|
||||
|
||||
private void declareBinaryOp(String methodName, int opcode) {
|
||||
private void declareBinaryOp(Name methodName, int opcode) {
|
||||
BinaryOp op = new BinaryOp(opcode);
|
||||
for (String type : PRIMITIVE_TYPES) {
|
||||
for (Name type : PRIMITIVE_TYPES) {
|
||||
declareIntrinsicFunction(type, methodName, 1, op, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void declareIntrinsicProperty(String className, String methodName, IntrinsicMethod implementation) {
|
||||
private void declareIntrinsicProperty(Name className, Name methodName, IntrinsicMethod implementation) {
|
||||
final JetScope numberScope = getClassMemberScope(className);
|
||||
Set<VariableDescriptor> properties = numberScope.getProperties(methodName);
|
||||
assert properties.size() == 1;
|
||||
@@ -225,7 +226,7 @@ public class IntrinsicMethods {
|
||||
myMethods.put(property.getOriginal(), implementation);
|
||||
}
|
||||
|
||||
private void declareIntrinsicFunction(String className, String functionName, int arity, IntrinsicMethod implementation, boolean original) {
|
||||
private void declareIntrinsicFunction(Name className, Name functionName, int arity, IntrinsicMethod implementation, boolean original) {
|
||||
JetScope memberScope = getClassMemberScope(className);
|
||||
final Set<FunctionDescriptor> group = memberScope.getFunctions(functionName);
|
||||
for (FunctionDescriptor descriptor : group) {
|
||||
@@ -243,7 +244,7 @@ public class IntrinsicMethods {
|
||||
}
|
||||
}
|
||||
|
||||
private JetScope getClassMemberScope(String className) {
|
||||
private JetScope getClassMemberScope(Name className) {
|
||||
final ClassDescriptor descriptor = (ClassDescriptor) myStdLib.getLibraryScope().getClassifier(className);
|
||||
final List<TypeParameterDescriptor> typeParameterDescriptors = descriptor.getTypeConstructor().getParameters();
|
||||
List<TypeProjection> typeParameters = new ArrayList<TypeProjection>();
|
||||
@@ -257,11 +258,10 @@ public class IntrinsicMethods {
|
||||
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
String value = (String) annotation.getValueArguments().get(0).getValue();
|
||||
IntrinsicMethod intrinsicMethod = namedMethods.get(value);
|
||||
if(intrinsicMethod != null)
|
||||
return intrinsicMethod;
|
||||
if (intrinsicMethod != null) { return intrinsicMethod; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,11 +274,10 @@ public class IntrinsicMethods {
|
||||
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
|
||||
if (annotations != null) {
|
||||
for (AnnotationDescriptor annotation : annotations) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName())) {
|
||||
if("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().getName())) {
|
||||
String value = (String) annotation.getValueArguments().get(0).getValue();
|
||||
intrinsicMethod = namedMethods.get(value);
|
||||
if(intrinsicMethod != null)
|
||||
break;
|
||||
if (intrinsicMethod != null) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetSignatureUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureAdapter;
|
||||
import org.jetbrains.jet.rt.signature.JetSignatureReader;
|
||||
@@ -264,9 +265,9 @@ public class BothSignatureWriter {
|
||||
pop();
|
||||
}
|
||||
|
||||
public void writeTypeVariable(final String name, boolean nullable, Type asmType) {
|
||||
signatureVisitor().visitTypeVariable(name);
|
||||
jetSignatureWriter.visitTypeVariable(name, nullable);
|
||||
public void writeTypeVariable(final Name name, boolean nullable, Type asmType) {
|
||||
signatureVisitor().visitTypeVariable(name.getName());
|
||||
jetSignatureWriter.visitTypeVariable(name.getName(), nullable);
|
||||
generic = true;
|
||||
writeAsmType0(asmType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user