diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-10-30 20:25:05 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-10-30 20:25:05 +0000 |
| commit | fee1878340fe2055f9d5b4c52eb2993c06c25f25 (patch) | |
| tree | fb827034b5a4a2174b08803120c295f5affd764f /src/main/java/org/zwobble/couscous/frontends | |
| parent | fd5dde9224680d46dd7081d051f1320194ff59ea (diff) | |
Store inner classes in ScalarType
Diffstat (limited to 'src/main/java/org/zwobble/couscous/frontends')
3 files changed, 8 insertions, 10 deletions
diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaExpressionReader.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaExpressionReader.java index 823310e..747bcac 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaExpressionReader.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaExpressionReader.java @@ -230,7 +230,7 @@ public class JavaExpressionReader { private Receiver toReceiver(IBinding binding) { if (binding instanceof ITypeBinding) { - ScalarType receiver = ScalarType.of(((ITypeBinding) binding).getQualifiedName()); + ScalarType receiver = ScalarType.topLevel(((ITypeBinding) binding).getQualifiedName()); return staticReceiver(receiver); } else if (binding instanceof IVariableBinding) { return instanceReceiver(readVariableBinding((IVariableBinding) binding)); diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java index a047e9e..b0d347b 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java @@ -239,7 +239,7 @@ public class JavaReader { while (type.isAnonymous()) { type = type.getDeclaringClass(); } - return ScalarType.of(erasure(typeOf(type)).getQualifiedName() + "_Anonymous_" + (anonymousClassCount++)); + return ScalarType.topLevel(erasure(typeOf(type)).getQualifiedName() + "_Anonymous_" + (anonymousClassCount++)); } private ITypeBinding findDeclaringClass(ASTNode node) { diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaTypes.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaTypes.java index 5d9eddd..fbd2a3b 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaTypes.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaTypes.java @@ -47,12 +47,10 @@ public class JavaTypes { Identifier declaringScope = getDeclaringScope(typeBinding); return new TypeParameter(declaringScope, typeBinding.getName()); } - // TODO: tidy-up -// ScalarType rawType = outerClass == null -// ? ScalarType.of(typeBinding.getErasure().getQualifiedName()) -// // TODO: test for erasure of inner type name -// : ScalarType.of(erasure(typeOf(outerClass)).getQualifiedName() + "__" + typeBinding.getErasure().getName()); - ScalarType rawType = ScalarType.of(typeBinding.getErasure().getQualifiedName()); + ScalarType rawType = outerClass == null + ? ScalarType.topLevel(typeBinding.getErasure().getQualifiedName()) + // TODO: test for erasure of inner type name + : ScalarType.innerType(erasure(typeOf(outerClass)), typeBinding.getErasure().getName()); if (typeBinding.isParameterizedType()) { List<Type> typeParameters = eagerMap( asList(typeBinding.getTypeArguments()), @@ -141,10 +139,10 @@ public class JavaTypes { } public static Type iterable(Type elementType) { - return parameterizedType(ScalarType.of("java.lang.Iterable"), list(elementType)); + return parameterizedType(ScalarType.topLevel("java.lang.Iterable"), list(elementType)); } - private static final ScalarType RAW_ITERATOR = ScalarType.of("java.util.Iterator"); + private static final ScalarType RAW_ITERATOR = ScalarType.topLevel("java.util.Iterator"); public static final TypeParameter ITERATOR_TYPE_PARAMETER = typeParameter(Identifier.TOP.type(RAW_ITERATOR.getQualifiedName()), "T"); public static Type iterator(Type elementType) { |
