CharSequence added in to stdlib
This commit is contained in:
@@ -38,6 +38,7 @@ public class JetTypeMapper {
|
||||
public static final Type JL_NUMBER_TYPE = Type.getObjectType("java/lang/Number");
|
||||
public static final Type JL_STRING_BUILDER = Type.getObjectType("java/lang/StringBuilder");
|
||||
public static final Type JL_STRING_TYPE = Type.getObjectType("java/lang/String");
|
||||
public static final Type JL_CHAR_SEQUENCE_TYPE = Type.getObjectType("java/lang/CharSequence");
|
||||
private static final Type JL_COMPARABLE_TYPE = Type.getObjectType("java/lang/Comparable");
|
||||
|
||||
public static final Type ARRAY_GENERIC_TYPE = Type.getType(Object[].class);
|
||||
@@ -142,8 +143,6 @@ public class JetTypeMapper {
|
||||
return mapType(jetType, OwnerKind.IMPLEMENTATION, signatureVisitor);
|
||||
}
|
||||
|
||||
private HashMap<DeclarationDescriptor,Map<DeclarationDescriptor,String>> naming = new HashMap<DeclarationDescriptor, Map<DeclarationDescriptor, String>>();
|
||||
|
||||
private String getStableNameForObject(JetObjectDeclaration object, DeclarationDescriptor descriptor) {
|
||||
String local = getLocalNameForObject(object);
|
||||
if (local == null) return null;
|
||||
@@ -781,6 +780,8 @@ public class JetTypeMapper {
|
||||
|
||||
knowTypes.put(standardLibrary.getStringType(),JL_STRING_TYPE);
|
||||
knowTypes.put(standardLibrary.getNullableStringType(),JL_STRING_TYPE);
|
||||
knowTypes.put(standardLibrary.getCharSequenceType(),JL_CHAR_SEQUENCE_TYPE);
|
||||
knowTypes.put(standardLibrary.getNullableCharSequenceType(),JL_CHAR_SEQUENCE_TYPE);
|
||||
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
PrimitiveType primitiveType = jvmPrimitiveType.getPrimitiveType();
|
||||
|
||||
@@ -88,7 +88,7 @@ public class IntrinsicMethods {
|
||||
declareIntrinsicFunction("Boolean", "not", 0, new Not());
|
||||
|
||||
declareIntrinsicFunction("String", "plus", 1, new Concat());
|
||||
declareIntrinsicFunction("String", "get", 1, new StringGetChar());
|
||||
declareIntrinsicFunction("CharSequence", "get", 1, new StringGetChar());
|
||||
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("toString"), 0, new ToString());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("equals"), 1, EQUALS);
|
||||
@@ -114,7 +114,7 @@ public class IntrinsicMethods {
|
||||
// declareIntrinsicFunction("Any", "equals", 1, new Equals());
|
||||
//
|
||||
declareIntrinsicStringMethods();
|
||||
declareIntrinsicProperty("String", "length", new StringLength());
|
||||
declareIntrinsicProperty("CharSequence", "length", new StringLength());
|
||||
|
||||
declareArrayMethods();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class StringGetChar implements IntrinsicMethod {
|
||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||
if(arguments != null)
|
||||
codegen.gen(arguments.get(0)).put(Type.INT_TYPE, v);
|
||||
v.invokevirtual("java/lang/String", "charAt", "(I)C");
|
||||
v.invokeinterface("java/lang/CharSequence", "charAt", "(I)C");
|
||||
return StackValue.onStack(Type.CHAR_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class StringLength implements IntrinsicMethod {
|
||||
@Override
|
||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||
v.invokevirtual("java/lang/String", "length", "()I");
|
||||
v.invokeinterface("java/lang/CharSequence", "length", "()I");
|
||||
return StackValue.onStack(Type.INT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user