Skip to content

Commit

Permalink
metamodel #226: fixed more missing type descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Jul 16, 2013
1 parent 0ef6058 commit 31d55a4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
Expand Up @@ -77,7 +77,7 @@ public ceylon.language.metamodel.Type getType() {

@Override
protected Value<? extends Type> bindTo(Object instance) {
return new AppliedValue(null, declaration, type, instance);
return new AppliedValue($reifiedType, declaration, type, instance);
}

@Override
Expand Down
Expand Up @@ -41,7 +41,7 @@ public class AppliedValue<Type>

public AppliedValue(@Ignore TypeDescriptor $reifiedType, FreeAttribute value, ProducedType valueType, Object instance) {
this.type = Metamodel.getAppliedMetamodel(valueType);
this.$reifiedType = Metamodel.getTypeDescriptorForProducedType(valueType);
this.$reifiedType = $reifiedType;
this.declaration = value;

initField(instance, valueType);
Expand Down
Expand Up @@ -61,9 +61,11 @@ public ceylon.language.metamodel.Value<? extends Object> apply() {
public ceylon.language.metamodel.Value<? extends Object> apply(@Name @TypeInfo("ceylon.language::Anything") Object instance) {
// FIXME: validate that instance is null for toplevels and not null for memberss
com.redhat.ceylon.compiler.typechecker.model.Value modelDecl = (com.redhat.ceylon.compiler.typechecker.model.Value)declaration;
// FIXME: this is not valid if the container type has TP
TypeDescriptor reifiedType = Metamodel.getTypeDescriptorForProducedType(modelDecl.getType());
return modelDecl.isVariable()
? new AppliedVariable(null, this, modelDecl.getType(), instance)
: new AppliedValue(null, this, modelDecl.getType(), instance);
? new AppliedVariable(reifiedType, this, modelDecl.getType(), instance)
: new AppliedValue(reifiedType, this, modelDecl.getType(), instance);
}

@Override
Expand Down
Expand Up @@ -31,7 +31,7 @@ protected FreeAttributeWithAppliedValue(@Ignore TypeDescriptor $reifiedType, Typ
super(declaration);
com.redhat.ceylon.compiler.typechecker.model.Value modelDecl = (com.redhat.ceylon.compiler.typechecker.model.Value)declaration;
// FIXME: container?
typeDelegate = new AppliedValue<Type>(null, this, modelDecl.getType(), null);
typeDelegate = new AppliedValue<Type>($reifiedType, this, modelDecl.getType(), null);
}

@Override
Expand Down
Expand Up @@ -147,7 +147,7 @@ protected final void checkInit(){
}

private <Kind> Sequential<? extends Kind> filteredMembers(
TypeDescriptor $reifiedKind,
@Ignore TypeDescriptor $reifiedKind,
Predicates.Predicate predicate) {
if (predicate == Predicates.false_()) {
return (Sequential<? extends Kind>)empty_.$get();
Expand All @@ -163,7 +163,7 @@ private <Kind> Sequential<? extends Kind> filteredMembers(
}

private <Kind> Kind filteredMember(
TypeDescriptor $reifiedKind,
@Ignore TypeDescriptor $reifiedKind,
Predicates.Predicate predicate) {
if (predicate == Predicates.false_()) {
return null;
Expand Down Expand Up @@ -266,7 +266,8 @@ ceylon.language.metamodel.Member<Container, Kind> memberApply(
}

<Type, Kind extends ceylon.language.metamodel.ClassOrInterface<? extends Object>>
ceylon.language.metamodel.Member<Type, Kind> getAppliedClassOrInterface(TypeDescriptor $reifiedType, TypeDescriptor $reifiedKind,
ceylon.language.metamodel.Member<Type, Kind> getAppliedClassOrInterface(@Ignore TypeDescriptor $reifiedType,
@Ignore TypeDescriptor $reifiedKind,
Sequential<? extends ceylon.language.metamodel.Type> types,
AppliedClassOrInterface<Type> container){
List<com.redhat.ceylon.compiler.typechecker.model.ProducedType> producedTypes = Metamodel.getProducedTypes(types);
Expand All @@ -289,19 +290,19 @@ ceylon.language.metamodel.Member<Type, Kind> getAppliedClassOrInterface(TypeDesc
}

FreeFunction findMethod(String name) {
return this.<FreeFunction>findDeclaration(name);
return this.<FreeFunction>findDeclaration(null, name);
}

FreeAttribute findValue(String name) {
return this.<FreeAttribute>findDeclaration(name);
return this.<FreeAttribute>findDeclaration(null, name);
}


FreeClassOrInterface findType(String name) {
return this.<FreeClassOrInterface>findDeclaration(name);
return this.<FreeClassOrInterface>findDeclaration(null, name);
}

<T extends FreeTopLevelOrMemberDeclaration> T findDeclaration(String name) {
<T extends FreeTopLevelOrMemberDeclaration> T findDeclaration(@Ignore TypeDescriptor $reifiedT, String name) {
checkInit();
for(ceylon.language.metamodel.declaration.TopLevelOrMemberDeclaration decl : declarations){
// in theory we can't have several members with the same name so no need to check the type
Expand Down
Expand Up @@ -27,11 +27,14 @@ public class FreeVariableWithAppliedVariable<Type>
implements Variable<Type> {

private AppliedVariable<Type> typeDelegate;
@Ignore
private TypeDescriptor $reifiedType;

protected FreeVariableWithAppliedVariable(com.redhat.ceylon.compiler.typechecker.model.Value declaration) {
protected FreeVariableWithAppliedVariable(@Ignore TypeDescriptor $reifiedType, com.redhat.ceylon.compiler.typechecker.model.Value declaration) {
super(declaration);
this.$reifiedType = $reifiedType;
// FIXME: container?
typeDelegate = new AppliedVariable<Type>(null, this, declaration.getType(), null);
typeDelegate = new AppliedVariable<Type>($reifiedType, this, declaration.getType(), null);
}

@Override
Expand Down Expand Up @@ -92,8 +95,6 @@ public Value<? extends Object> apply(@Name @TypeInfo("ceylon.language::Anything"

@Override
public TypeDescriptor $getType() {
TypeDescriptor.Class type = (TypeDescriptor.Class) typeDelegate.$getType();
TypeDescriptor[] args = type.getTypeArguments();
return TypeDescriptor.klass(FreeVariableWithAppliedVariable.class, args[0]);
return TypeDescriptor.klass(FreeVariableWithAppliedVariable.class, $reifiedType);
}
}
Expand Up @@ -203,7 +203,7 @@ public static com.redhat.ceylon.compiler.java.runtime.metamodel.FreeTopLevelOrMe
TypeDescriptor reifiedType = getTypeDescriptorForProducedType(value.getType());
if(value.isToplevel()){
if(value.isVariable())
ret = new FreeVariableWithAppliedVariable(value);
ret = new FreeVariableWithAppliedVariable(reifiedType, value);
else
ret = new FreeAttributeWithAppliedValue(reifiedType, value);
}else{
Expand Down

0 comments on commit 31d55a4

Please sign in to comment.