From 02780eae21df4bb981b03318d151c8053412e70f Mon Sep 17 00:00:00 2001 From: John Vasileff Date: Sun, 16 Oct 2016 12:21:50 -0400 Subject: [PATCH] support toplevel value declarations for #37 --- .../dart/compiler/core/TopLevelVisitor.ceylon | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ceylon-dart-compiler/source/com/vasileff/ceylon/dart/compiler/core/TopLevelVisitor.ceylon b/ceylon-dart-compiler/source/com/vasileff/ceylon/dart/compiler/core/TopLevelVisitor.ceylon index 3095841d..548eaf66 100644 --- a/ceylon-dart-compiler/source/com/vasileff/ceylon/dart/compiler/core/TopLevelVisitor.ceylon +++ b/ceylon-dart-compiler/source/com/vasileff/ceylon/dart/compiler/core/TopLevelVisitor.ceylon @@ -110,7 +110,8 @@ import com.vasileff.ceylon.dart.compiler.nodeinfo { objectDefinitionInfo, valueDefinitionInfo, valueGetterDefinitionInfo, - callableParameterInfo + callableParameterInfo, + valueDeclarationInfo } "For Dart TopLevel declarations." @@ -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 @@ -1788,8 +1799,9 @@ 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); @@ -1797,6 +1809,8 @@ class TopLevelVisitor(CompilationContext ctx) switch (that) case (is ValueDefinition) valueDefinitionInfo(that).declarationModel + case (is ValueDeclaration) + valueDeclarationInfo(that).declarationModel case (is ValueGetterDefinition) valueGetterDefinitionInfo(that).declarationModel case (is ObjectDefinition)