Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metamodel #226: implement the new Attribute
- Loading branch information
Showing
3 changed files
with
134 additions
and
34 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
runtime/com/redhat/ceylon/compiler/java/runtime/metamodel/AppliedAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.redhat.ceylon.compiler.java.runtime.metamodel; | ||
|
||
import ceylon.language.metamodel.Attribute$impl; | ||
import ceylon.language.metamodel.AttributeType$impl; | ||
import ceylon.language.metamodel.DeclarationType$impl; | ||
import ceylon.language.metamodel.Value; | ||
import ceylon.language.metamodel.declaration.AttributeDeclaration; | ||
|
||
import com.redhat.ceylon.compiler.java.metadata.Ignore; | ||
import com.redhat.ceylon.compiler.java.metadata.TypeInfo; | ||
import com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor; | ||
import com.redhat.ceylon.compiler.typechecker.model.ProducedType; | ||
|
||
public class AppliedAttribute<Container, Type> | ||
extends AppliedMember<Container, ceylon.language.metamodel.Value<? extends Type>> | ||
implements ceylon.language.metamodel.Attribute<Container, Type> { | ||
|
||
private FreeAttribute declaration; | ||
private ProducedType type; | ||
private ceylon.language.metamodel.Type closedType; | ||
|
||
public AppliedAttribute(TypeDescriptor $reifiedType, TypeDescriptor $reifiedKind, | ||
FreeAttribute declaration, ProducedType type) { | ||
super($reifiedType, $reifiedKind); | ||
this.declaration = declaration; | ||
this.type = type; | ||
this.closedType = Metamodel.getAppliedMetamodel(type); | ||
} | ||
|
||
@Override | ||
@Ignore | ||
public AttributeType$impl<Type> $ceylon$language$metamodel$AttributeType$impl() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
@Ignore | ||
public DeclarationType$impl $ceylon$language$metamodel$DeclarationType$impl() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
@Ignore | ||
public Attribute$impl<Container, Type> $ceylon$language$metamodel$Attribute$impl() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
@TypeInfo("ceylon.language.metamodel.declaration::AttributeDeclaration") | ||
public AttributeDeclaration getDeclaration() { | ||
return declaration; | ||
} | ||
|
||
@Override | ||
@TypeInfo("ceylon.language.metamodel::Type") | ||
public ceylon.language.metamodel.Type getType() { | ||
return closedType; | ||
} | ||
|
||
@Override | ||
protected Value<? extends Type> bindTo(Object instance) { | ||
// FIXME: add AttributeDeclaration.isVariable or something | ||
return (((com.redhat.ceylon.compiler.typechecker.model.Value)declaration.declaration).isVariable() | ||
? new AppliedVariable(null, declaration, type, instance) | ||
: new AppliedValue(null, declaration, type, instance)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters