Skip to content

Commit

Permalink
support toplevel value declarations for #37
Browse files Browse the repository at this point in the history
  • Loading branch information
jvasileff committed Oct 16, 2016
1 parent 9ee476d commit 02780ea
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ import com.vasileff.ceylon.dart.compiler.nodeinfo {
objectDefinitionInfo,
valueDefinitionInfo,
valueGetterDefinitionInfo,
callableParameterInfo
callableParameterInfo,
valueDeclarationInfo
}

"For Dart TopLevel declarations."
Expand All @@ -132,7 +133,17 @@ class TopLevelVisitor(CompilationContext ctx)
return;
}

super.visitValueDeclaration(that);
value info = valueDeclarationInfo(that);

"toplevel ValueDeclarations are always late and never transient."
assert (!info.declarationModel.transient);

addAll {
DartTopLevelVariableDeclaration {
generateForValueDeclarationRaw(info, info.declarationModel);
},
*generateForwardingGetterSetter(that)
};
}

shared actual
Expand Down Expand Up @@ -1788,15 +1799,18 @@ class TopLevelVisitor(CompilationContext ctx)
// toplevel interface aliases are not reified
}

[DartFunctionDeclaration*] generateForwardingGetterSetter
(ValueDefinition | ValueGetterDefinition | ObjectDefinition that) {
[DartFunctionDeclaration*] generateForwardingGetterSetter(
ValueDeclaration | ValueDefinition | ValueGetterDefinition |
ObjectDefinition that) {

value info = nodeInfo(that);

value declarationModel =
switch (that)
case (is ValueDefinition)
valueDefinitionInfo(that).declarationModel
case (is ValueDeclaration)
valueDeclarationInfo(that).declarationModel
case (is ValueGetterDefinition)
valueGetterDefinitionInfo(that).declarationModel
case (is ObjectDefinition)
Expand Down

0 comments on commit 02780ea

Please sign in to comment.