├── .github └── FUNDING.yml ├── compiler ├── src │ ├── main │ │ ├── resources │ │ │ └── brokenPlugins.txt │ │ └── kotlin │ │ │ └── org │ │ │ └── dotlin │ │ │ └── compiler │ │ │ ├── dart │ │ │ ├── ast │ │ │ │ ├── README.md │ │ │ │ ├── expression │ │ │ │ │ ├── literal │ │ │ │ │ │ ├── DartStringLiteral.kt │ │ │ │ │ │ ├── DartLiteral.kt │ │ │ │ │ │ ├── DartSingleStringLiteral.kt │ │ │ │ │ │ ├── DartTypedLiteral.kt │ │ │ │ │ │ ├── DartNullLiteral.kt │ │ │ │ │ │ ├── DartDoubleLiteral.kt │ │ │ │ │ │ ├── DartTypeLiteral.kt │ │ │ │ │ │ ├── DartSimpleStringLiteral.kt │ │ │ │ │ │ ├── DartBooleanLiteral.kt │ │ │ │ │ │ └── DartIntegerLiteral.kt │ │ │ │ │ ├── DartPossiblyNullAwareExpression.kt │ │ │ │ │ ├── DartExpression.kt │ │ │ │ │ ├── DartCode.kt │ │ │ │ │ ├── DartSuperExpression.kt │ │ │ │ │ ├── DartThisExpression.kt │ │ │ │ │ ├── DartThrowExpression.kt │ │ │ │ │ ├── invocation │ │ │ │ │ │ ├── DartFunctionExpressionInvocation.kt │ │ │ │ │ │ └── DartInvocationExpression.kt │ │ │ │ │ ├── DartIndexExpression.kt │ │ │ │ │ ├── DartParenthesizedExpression.kt │ │ │ │ │ ├── DartNamedExpression.kt │ │ │ │ │ ├── DartAsExpression.kt │ │ │ │ │ ├── DartIsExpression.kt │ │ │ │ │ ├── DartConditionalExpression.kt │ │ │ │ │ ├── DartArgumentList.kt │ │ │ │ │ ├── DartPropertyAccessExpression.kt │ │ │ │ │ ├── DartAssignmentExpression.kt │ │ │ │ │ └── DartInstanceCreationExpression.kt │ │ │ │ ├── statement │ │ │ │ │ ├── DartStatement.kt │ │ │ │ │ ├── DartBreakStatement.kt │ │ │ │ │ ├── DartContinueStatement.kt │ │ │ │ │ ├── DartReturnStatement.kt │ │ │ │ │ ├── DartBlock.kt │ │ │ │ │ ├── DartExpressionStatement.kt │ │ │ │ │ ├── DartIfStatement.kt │ │ │ │ │ ├── declaration │ │ │ │ │ │ └── DartVariableDeclarationStatement.kt │ │ │ │ │ └── trycatch │ │ │ │ │ │ └── DartTryStatement.kt │ │ │ │ ├── parameter │ │ │ │ │ ├── DartFormalParameter.kt │ │ │ │ │ └── DartNormalFormalParameter.kt │ │ │ │ ├── collection │ │ │ │ │ ├── DartCollectionElement.kt │ │ │ │ │ └── DartCollectionElementList.kt │ │ │ │ ├── directive │ │ │ │ │ ├── DartDirective.kt │ │ │ │ │ └── DartUriBasedDirective.kt │ │ │ │ ├── declaration │ │ │ │ │ ├── DartDeclaration.kt │ │ │ │ │ ├── classlike │ │ │ │ │ │ ├── member │ │ │ │ │ │ │ ├── DartClassMember.kt │ │ │ │ │ │ │ └── constructor │ │ │ │ │ │ ├── DartExtendsClause.kt │ │ │ │ │ │ ├── DartWithClause.kt │ │ │ │ │ │ └── DartImplementsClause.kt │ │ │ │ │ └── function │ │ │ │ │ │ └── body │ │ │ │ │ │ ├── DartFunctionBody.kt │ │ │ │ │ │ ├── DartEmptyFunctionBody.kt │ │ │ │ │ │ ├── DartBlockFunctionBody.kt │ │ │ │ │ │ └── DartExpressionFunctionBody.kt │ │ │ │ ├── compilationunit │ │ │ │ │ ├── DartCompilationUnitMember.kt │ │ │ │ │ ├── DartNamedCompilationUnitMember.kt │ │ │ │ │ └── DartCompilationUnit.kt │ │ │ │ ├── annotation │ │ │ │ │ └── DartAnnotatedNode.kt │ │ │ │ ├── DartAstNode.kt │ │ │ │ ├── DartLabel.kt │ │ │ │ ├── typealias │ │ │ │ │ └── DartTypeAlias.kt │ │ │ │ └── type │ │ │ │ │ ├── DartTypeArgumentList.kt │ │ │ │ │ ├── parameter │ │ │ │ │ ├── DartTypeParameterList.kt │ │ │ │ │ └── DartTypeParameter.kt │ │ │ │ │ └── DartNamedType.kt │ │ │ └── element │ │ │ │ ├── README.md │ │ │ │ └── GenerateProtoSchema.kt │ │ │ ├── backend │ │ │ ├── steps │ │ │ │ ├── src2ir │ │ │ │ │ ├── analyze │ │ │ │ │ │ ├── checkers │ │ │ │ │ │ │ ├── file │ │ │ │ │ │ │ │ ├── SourceFileChecker.kt │ │ │ │ │ │ │ │ └── DartDuplicateImportChecker.kt │ │ │ │ │ │ │ ├── type │ │ │ │ │ │ │ │ ├── CharTypeChecker.kt │ │ │ │ │ │ │ │ └── FloatTypeChecker.kt │ │ │ │ │ │ │ └── call │ │ │ │ │ │ │ │ ├── SpecialInheritanceConstructorCallChecker.kt │ │ │ │ │ │ │ │ └── KotlinIteratorMethodCallChecker.kt │ │ │ │ │ │ ├── suppress │ │ │ │ │ │ │ ├── TypeErasureSuppressor.kt │ │ │ │ │ │ │ ├── InlineSuppressor.kt │ │ │ │ │ │ │ ├── KotlinIteratorSuppressor.kt │ │ │ │ │ │ │ ├── LateInitSuppressor.kt │ │ │ │ │ │ │ ├── ThrowSuppressor.kt │ │ │ │ │ │ │ ├── AbstractFactoryConstructorCallSuppressor.kt │ │ │ │ │ │ │ ├── DartDiagnosticSuppressor.kt │ │ │ │ │ │ │ └── SpecialInheritanceSuppressor.kt │ │ │ │ │ │ └── ir │ │ │ │ │ │ │ └── CheckerUtils.kt │ │ │ │ │ ├── DartPlatform.kt │ │ │ │ │ └── DotlinSymbolTable.kt │ │ │ │ ├── ir2ast │ │ │ │ │ ├── transformer │ │ │ │ │ │ └── util │ │ │ │ │ │ │ └── DartConstructorUtils.kt │ │ │ │ │ └── lower │ │ │ │ │ │ └── lowerings │ │ │ │ │ │ ├── SingleExpressionBlocksLowering.kt │ │ │ │ │ │ └── NestedClassLowering.kt │ │ │ │ └── ast2dart │ │ │ │ │ ├── DartAstToDartSource.kt │ │ │ │ │ └── transformer │ │ │ │ │ ├── DartCollectionElementTransformer.kt │ │ │ │ │ └── DartMiscTransformer.kt │ │ │ ├── descriptors │ │ │ │ ├── ScopeUtils.kt │ │ │ │ ├── Utils.kt │ │ │ │ ├── DartInteropDescriptor.kt │ │ │ │ └── DartDescriptor.kt │ │ │ ├── util │ │ │ │ ├── PathUtils.kt │ │ │ │ ├── DotlinUtils.kt │ │ │ │ ├── SystemUtils.kt │ │ │ │ ├── ImportUtils.kt │ │ │ │ ├── ConstructorUtils.kt │ │ │ │ ├── ExternalUtils.kt │ │ │ │ ├── PropertyUtils.kt │ │ │ │ ├── DartIrUtils.kt │ │ │ │ └── ObjectUtils.kt │ │ │ └── bin │ │ │ │ └── Dart.kt │ │ │ ├── Main.kt │ │ │ ├── DiagnosticsUtils.kt │ │ │ └── cli │ │ │ └── command │ │ │ └── Compile.kt │ └── test │ │ └── kotlin │ │ ├── Util.kt │ │ ├── compile │ │ ├── klib │ │ │ └── StandardLibrary.kt │ │ └── dialect │ │ │ ├── TypeAlias.kt │ │ │ ├── Type.kt │ │ │ └── Primitives.kt │ │ ├── FunctionDisplayNameGenerator.kt │ │ └── analysis │ │ └── dialect │ │ └── TypeErasure.kt ├── gradle.properties ├── settings.gradle.kts ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore └── build.gradle.kts ├── docs └── assets │ └── dotlin.png ├── packages ├── dotlin_generator │ ├── CHANGELOG.md │ ├── .gitignore │ ├── README.md │ ├── lib │ │ └── src │ │ │ ├── generated │ │ │ ├── elements.pbserver.dart │ │ │ └── elements.pbenum.dart │ │ │ ├── dart_package.dart │ │ │ └── serialize │ │ │ └── util.dart │ ├── pubspec.yaml │ ├── bin │ │ └── generate.dart │ ├── build.yaml │ └── analysis_options.yaml └── dotlin │ ├── .gitignore │ ├── pubspec.yaml │ └── lib │ └── src │ ├── kotlin │ ├── native │ │ ├── comparable_ext.dart │ │ ├── Annotation.kt │ │ ├── Nothing.kt │ │ ├── Comparable.kt │ │ ├── Lazy.kt │ │ └── String.kt │ ├── unused │ │ ├── Throwable.kt │ │ ├── Char.kt │ │ ├── ProgressionIterators.kt │ │ ├── Error.kt │ │ ├── Progressions.kt │ │ ├── Iterators.kt │ │ ├── Ranges.kt │ │ └── Primitives.kt │ ├── reflect │ │ ├── KFunction.kt │ │ ├── KClassifier.kt │ │ ├── typeOf.kt │ │ ├── KCallable.kt │ │ └── KVariance.kt │ ├── Function.kt │ ├── Unit.kt │ ├── util │ │ └── Lateinit.kt │ ├── collections │ │ └── SetFactories.kt │ ├── Library.kt │ ├── ranges │ │ ├── ProgressionIterators.kt │ │ └── Range.kt │ └── internal │ │ └── InternalAnnotations.kt │ ├── dotlin │ ├── intrinsics │ │ ├── Internal.kt │ │ ├── Errors.kt │ │ ├── Dynamic.kt │ │ ├── SpecialInheritance.kt │ │ ├── Jump.kt │ │ └── CollectionMarkers.kt │ └── collections │ │ └── IterableExt.kt │ └── dart │ ├── core │ ├── Identical.kt │ └── Duration.kt │ └── typed_data │ ├── Endian.kt │ └── TypedData.kt └── DCO /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: wilkomanger 2 | -------------------------------------------------------------------------------- /compiler/src/main/resources/brokenPlugins.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compiler/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | -------------------------------------------------------------------------------- /compiler/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "compiler" -------------------------------------------------------------------------------- /docs/assets/dotlin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotlin-org/dotlin/HEAD/docs/assets/dotlin.png -------------------------------------------------------------------------------- /packages/dotlin_generator/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | - Publish. 4 | 5 | ## 0.0.2 6 | 7 | - Update LICENSE 8 | -------------------------------------------------------------------------------- /compiler/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotlin-org/dotlin/HEAD/compiler/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /packages/dotlin_generator/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub. 2 | .dart_tool/ 3 | .packages 4 | pubspec.lock 5 | 6 | # Conventional directory for build output. 7 | build/ 8 | 9 | .dotlin/ 10 | 11 | # IntelliJ 12 | .idea/ 13 | -------------------------------------------------------------------------------- /packages/dotlin_generator/README.md: -------------------------------------------------------------------------------- 1 | # Dotlin 2 | 3 | This is a tool used in [Dotlin](https://dotlin.org), the Kotlin to Dart compiler. 4 | 5 | This tool generates protobuf Dart elements, which Dotlin then uses to make it possible to call Dart code in Kotlin. -------------------------------------------------------------------------------- /compiler/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /packages/dotlin/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub. 2 | .dart_tool/ 3 | .packages 4 | pubspec.lock 5 | 6 | # Conventional directory for build output. 7 | build/ 8 | 9 | # Dotlin 10 | *.dt.g.dart 11 | .dotlin/ 12 | 13 | # IntelliJ 14 | .idea/ 15 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/README.md: -------------------------------------------------------------------------------- 1 | # Dart AST 2 | 3 | The Dart AST (Abstract Syntax Tree) classes are inspired by the 4 | [`ast` library in Dart's `analyzer`](https://pub.dev/documentation/analyzer/latest/dart_ast_ast/dart_ast_ast-library.html) 5 | package. -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/element/README.md: -------------------------------------------------------------------------------- 1 | # Dart AST 2 | 3 | The Dart Element classes are inspired by the 4 | [`element` library in Dart's `analyzer`](https://pub.dev/documentation/analyzer/latest/dart_element_element/dart_element_element-library.html) 5 | package. -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/checkers/file/SourceFileChecker.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.checkers.file 2 | 3 | import org.jetbrains.kotlin.psi.KtFile 4 | 5 | interface SourceFileChecker { 6 | fun check(file: KtFile) 7 | } -------------------------------------------------------------------------------- /packages/dotlin/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: dotlin 2 | description: The Dotlin standard library. 3 | version: 0.0.1 4 | homepage: dotlin.org 5 | 6 | environment: 7 | sdk: '>=2.18.2 <3.0.0' 8 | 9 | dependencies: 10 | meta: ^1.9.0 11 | 12 | dev_dependencies: 13 | dotlin_generator: 14 | path: ../dotlin_generator -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/native/comparable_ext.dart: -------------------------------------------------------------------------------- 1 | extension ComparableOperators on Comparable { 2 | bool operator <(T other) => this.compareTo(other) < 0; 3 | 4 | bool operator >(T other) => this.compareTo(other) > 0; 5 | 6 | bool operator <=(T other) => this.compareTo(other) <= 0; 7 | 8 | bool operator >=(T other) => this.compareTo(other) >= 0; 9 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/TypeErasureSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.jetbrains.kotlin.diagnostics.Diagnostic 4 | import org.jetbrains.kotlin.diagnostics.Errors 5 | 6 | object TypeErasureSuppressor : SubSuppressor { 7 | override fun Diagnostic.isSuppressed(): Boolean { 8 | return factory == Errors.CANNOT_CHECK_FOR_ERASED 9 | } 10 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/descriptors/ScopeUtils.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.descriptors 2 | 3 | import org.jetbrains.kotlin.resolve.scopes.MemberScope 4 | import org.jetbrains.kotlin.utils.Printer 5 | 6 | context(MemberScope) 7 | fun Printer.printScope() { 8 | println(this::class.simpleName + "{") 9 | pushIndent() 10 | 11 | getContributedDescriptors().forEach { 12 | println(it) 13 | } 14 | 15 | popIndent() 16 | println("}") 17 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/lib/src/generated/elements.pbserver.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: elements.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,deprecated_member_use_from_same_package,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | export 'elements.pb.dart'; 9 | 10 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/InlineSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.jetbrains.kotlin.diagnostics.Diagnostic 4 | import org.jetbrains.kotlin.diagnostics.Errors 5 | 6 | object InlineSuppressor : SubSuppressor { 7 | override fun Diagnostic.isSuppressed(): Boolean { 8 | // We don't need `noinline`. 9 | return factory == Errors.USAGE_IS_NOT_INLINABLE || factory == Errors.NOTHING_TO_INLINE 10 | } 11 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: dotlin_generator 2 | description: Generates ProtoBuf Dart elements for use in the Dotlin compiler. 3 | version: 0.0.2 4 | homepage: https://dotlin.org 5 | repository: https://github.com/dotlin-org/dotlin 6 | 7 | environment: 8 | sdk: '>=2.18.2 <3.0.0' 9 | 10 | executables: 11 | generate: generate 12 | 13 | dependencies: 14 | analyzer: ^5.2.0 15 | path: ^1.8.2 16 | package_config: ^2.1.0 17 | dartx: ^1.1.0 18 | protobuf: ^2.1.0 19 | fixnum: ^1.0.1 20 | 21 | dev_dependencies: 22 | lints: ^2.0.0 23 | test: ^1.16.0 24 | build_runner: ^2.1.0 25 | protoc_builder: ^0.3.0 26 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/descriptors/Utils.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.descriptors 2 | 3 | import org.dotlin.compiler.backend.descriptors.annotation.DartInteropAnnotationClassDescriptor 4 | import org.dotlin.compiler.dart.element.DartElement 5 | import org.jetbrains.kotlin.descriptors.DeclarationDescriptor 6 | 7 | val DeclarationDescriptor.dartElement: DartElement? 8 | get() = when (this) { 9 | is DartDescriptor -> element 10 | is DartInteropAnnotationClassDescriptor<*> -> from.element 11 | else -> null 12 | } 13 | 14 | @Suppress("UNCHECKED_CAST") 15 | fun DeclarationDescriptor.dartElementAs(): E? = dartElement as? E -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/KotlinIteratorSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.jetbrains.kotlin.diagnostics.Diagnostic 4 | import org.jetbrains.kotlin.diagnostics.Errors.* 5 | 6 | object KotlinIteratorSuppressor : SubSuppressor { 7 | override fun Diagnostic.isSuppressed(): Boolean { 8 | return factory in listOf( 9 | HAS_NEXT_MISSING, 10 | HAS_NEXT_FUNCTION_TYPE_MISMATCH, 11 | HAS_NEXT_FUNCTION_NONE_APPLICABLE, 12 | HAS_NEXT_FUNCTION_AMBIGUITY, 13 | NEXT_MISSING, 14 | NEXT_NONE_APPLICABLE, 15 | NEXT_AMBIGUITY 16 | ) 17 | } 18 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/intrinsics/Internal.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dotlin.intrinsics 18 | 19 | internal annotation class DotlinExternal -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Throwable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | internal open class Throwable 21 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/intrinsics/Errors.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dotlin.intrinsics 18 | 19 | // TODO: Kotlin-only internal (@DartPublic) 20 | 21 | internal class NoWhenBranchMatchedError : Error() -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Char.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | internal external abstract class Char private constructor() : Comparable 21 | 22 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/LateInitSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.jetbrains.kotlin.diagnostics.Diagnostic 4 | import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters1 5 | import org.jetbrains.kotlin.diagnostics.Errors 6 | 7 | object LateInitSuppressor : SubSuppressor { 8 | override fun Diagnostic.isSuppressed(): Boolean { 9 | if (factory != Errors.INAPPLICABLE_LATEINIT_MODIFIER || this !is DiagnosticWithParameters1<*, *>) { 10 | return false 11 | } 12 | 13 | val message = a as? String ?: return false 14 | 15 | return message.endsWith("nullable types") || 16 | message.endsWith("primitive types") || 17 | message.endsWith("nullable upper bound") 18 | } 19 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/bin/generate.dart: -------------------------------------------------------------------------------- 1 | import 'package:dotlin_generator/src/dart_package.dart'; 2 | import 'package:dotlin_generator/src/resolve_package_dependencies.dart'; 3 | import 'package:dotlin_generator/src/write_dlibs.dart'; 4 | import 'package:package_config/package_config.dart'; 5 | 6 | PackageConfig get pkgConfig => throw UnsupportedError("asd"); 7 | 8 | void main(List arguments) async { 9 | final resolvedPackages = await resolvePackages(_packagesFromArgs(arguments)); 10 | await writeDlibs(resolvedPackages); 11 | } 12 | 13 | List _packagesFromArgs(List arguments) { 14 | final packages = []; 15 | for (var i = 0; i < arguments.length; i += 2) { 16 | packages.add( 17 | DartPackage( 18 | path: arguments[i], 19 | packagePath: arguments[i + 1], 20 | ), 21 | ); 22 | } 23 | return packages; 24 | } 25 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dart/core/Identical.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:DartLibrary("dart:core") 18 | 19 | package dart.core 20 | 21 | /** 22 | * Check whether two references are to the same object. 23 | */ 24 | external fun identical(a: Any?, b: Any?): Boolean -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/ProgressionIterators.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.ranges 19 | 20 | private external interface CharProgressionIterator 21 | private external interface LongProgressionIterator -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/reflect/KFunction.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2018 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.reflect 19 | 20 | /** 21 | * Represents a function with introspection capabilities. 22 | */ 23 | interface KFunction : KCallable, Function -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Error.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * An exception is thrown to indicate that a method body remains to be implemented. 22 | */ 23 | private class NotImplementedError : Error() -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/checkers/type/CharTypeChecker.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.checkers.type 2 | 3 | import org.dotlin.compiler.backend.steps.src2ir.analyze.ir.ErrorsDart 4 | import org.jetbrains.kotlin.psi.KtExpression 5 | import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker 6 | import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext 7 | import org.jetbrains.kotlin.types.KotlinType 8 | import org.jetbrains.kotlin.types.typeUtil.isChar 9 | 10 | object CharTypeChecker : AdditionalTypeChecker { 11 | override fun checkType( 12 | expression: KtExpression, 13 | expressionType: KotlinType, 14 | expressionTypeWithSmartCast: KotlinType, 15 | c: ResolutionContext<*> 16 | ) { 17 | if (expressionType.isChar()) { 18 | c.trace.report(ErrorsDart.CHAR_REFERENCE.on(expression)) 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/checkers/type/FloatTypeChecker.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.checkers.type 2 | 3 | import org.dotlin.compiler.backend.steps.src2ir.analyze.ir.ErrorsDart 4 | import org.jetbrains.kotlin.psi.KtExpression 5 | import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker 6 | import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext 7 | import org.jetbrains.kotlin.types.KotlinType 8 | import org.jetbrains.kotlin.types.typeUtil.isFloat 9 | 10 | object FloatTypeChecker : AdditionalTypeChecker { 11 | override fun checkType( 12 | expression: KtExpression, 13 | expressionType: KotlinType, 14 | expressionTypeWithSmartCast: KotlinType, 15 | c: ResolutionContext<*> 16 | ) { 17 | if (expressionType.isFloat()) { 18 | c.trace.report(ErrorsDart.FLOAT_REFERENCE.on(expression)) 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/reflect/KClassifier.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2019 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.reflect 19 | 20 | /** 21 | * A classifier is either a class or a type parameter. 22 | * 23 | * @see [KClass] 24 | * @see [KTypeParameter] 25 | */ 26 | @SinceKotlin("1.1") 27 | interface KClassifier -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/Function.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * Represents a value of a functional type, such as a lambda, an anonymous function or a function reference. 22 | * 23 | * @param R return type of the function. 24 | */ 25 | interface Function 26 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartStringLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | interface DartStringLiteral : DartLiteral -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/intrinsics/Dynamic.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dotlin.intrinsics 18 | 19 | /** 20 | * Used to make type aliases to `dynamic`, since Kotlin doesn't support type aliases to `dynamic` 21 | * directly. 22 | */ 23 | // TODO: Error if used by non-stdlib (?) 24 | // TODO: Error if used outside of typealias 25 | external class Dynamic private constructor() -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/Unit.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * The type with only one value: the `Unit` object. 22 | * 23 | * This type corresponds to the `void` type in Dart, iff used as a return type or type argument. 24 | */ 25 | object Unit { 26 | override fun toString() = "kotlin.Unit" 27 | } 28 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/Main.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | @file:JvmName("Dotlin") 21 | 22 | package org.dotlin.compiler 23 | 24 | import org.dotlin.compiler.cli.command.Compile 25 | 26 | fun main(args: Array) = Compile().main(args) -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | 24 | interface DartStatement : DartAstNode -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/element/GenerateProtoSchema.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.element 21 | 22 | import org.dotlin.compiler.backend.bin.DotlinGenerator 23 | 24 | fun main() = DotlinGenerator.generateSchema() -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/parameter/DartFormalParameter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.parameter 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | 24 | interface DartFormalParameter : DartAstNode -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/native/Annotation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2018 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * Base interface implicitly implemented by all annotation interfaces. 22 | * See [Kotlin language documentation](https://kotlinlang.org/docs/reference/annotations.html) for more information 23 | * on annotations. 24 | */ 25 | interface Annotation 26 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/collection/DartCollectionElement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.collection 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | 24 | interface DartCollectionElement : DartAstNode -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/reflect/typeOf.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2019 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.reflect 19 | 20 | /** 21 | * Returns a runtime representation of the given reified type [T] as an instance of [KType]. 22 | */ 23 | /*inline*/ fun kTypeOf(): KType = 24 | throw UnsupportedError("This function is implemented as an intrinsic on all supported platforms.") 25 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/directive/DartDirective.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.directive 21 | 22 | import org.dotlin.compiler.dart.ast.annotation.DartAnnotatedNode 23 | 24 | interface DartDirective : DartAnnotatedNode -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartPossiblyNullAwareExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | interface DartPossiblyNullAwareExpression : DartExpression { 23 | val isNullAware: Boolean 24 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/collections/IterableExt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | @file:DartExtensionName("IterableExt") 18 | 19 | package dotlin 20 | 21 | inline fun Iterable.toMutableList(): MutableList = toList(growable = true) as MutableList 22 | inline fun Iterable.toArray(): Array = toList(growable = false) as Array 23 | inline fun Iterable.toFixedSizeList(): FixedSizeList = toArray() -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/DartDeclaration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration 21 | 22 | import org.dotlin.compiler.dart.ast.annotation.DartAnnotatedNode 23 | 24 | interface DartDeclaration : DartAnnotatedNode -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.expression.DartExpression 23 | 24 | interface DartLiteral : DartExpression -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.collection.DartCollectionElement 23 | 24 | interface DartExpression : DartCollectionElement -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/PathUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import java.nio.file.Path 23 | 24 | fun Path.toPosixString() = when { 25 | onWindows() -> toString().replace('\\', '/') 26 | else -> toString() 27 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/util/Lateinit.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. 3 | * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. 4 | */ 5 | 6 | package kotlin 7 | 8 | import kotlin.internal.AccessibleLateinitPropertyLiteral 9 | import kotlin.reflect.KProperty0 10 | 11 | /** 12 | * Returns `true` if this lateinit property has been assigned a value, and `false` otherwise. 13 | * 14 | * This will call the getter of the property. If the getter is resource-intensive, consider 15 | * checking whether the property is initialized in different way. 16 | */ 17 | @SinceKotlin("1.2") 18 | /*inline*/ val @receiver:AccessibleLateinitPropertyLiteral KProperty0<*>.isInitialized: Boolean 19 | get() { 20 | try { 21 | get() 22 | } catch (e: Error) { 23 | if (e.runtimeType.hashCode() == 425871248) { 24 | return false 25 | } 26 | } 27 | 28 | return true 29 | } 30 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/compilationunit/DartCompilationUnitMember.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.compilationunit 21 | 22 | import org.dotlin.compiler.dart.ast.declaration.DartDeclaration 23 | 24 | interface DartCompilationUnitMember : DartDeclaration -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/classlike/member/DartClassMember.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.classlike.member 21 | 22 | import org.dotlin.compiler.dart.ast.declaration.DartDeclaration 23 | 24 | interface DartClassMember : DartDeclaration -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartSingleStringLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | interface DartSingleStringLiteral : DartStringLiteral { 23 | val isRaw: Boolean 24 | val isTripleQuoted: Boolean 25 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/intrinsics/SpecialInheritance.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dotlin.intrinsics 18 | 19 | annotation class SpecialInheritance 20 | 21 | /** 22 | * This annotation is used on super types in the output IR, because it's information normally not 23 | * present in the IR. 24 | */ 25 | internal annotation class SpecialInheritedType( 26 | val kind: String /* "SuperTypeKind.Interface.Implicit" | "SuperTypeKind.Mixin" */ 27 | ) -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/classlike/member/constructor/DartConstructorInitializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.classlike.member.constructor 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | 24 | interface DartConstructorInitializer : DartAstNode -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/directive/DartUriBasedDirective.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.directive 21 | 22 | import org.dotlin.compiler.dart.ast.expression.literal.DartStringLiteral 23 | 24 | interface DartUriBasedDirective : DartDirective { 25 | val uri: DartStringLiteral 26 | } -------------------------------------------------------------------------------- /compiler/src/test/kotlin/Util.kt: -------------------------------------------------------------------------------- 1 | import kotlin.io.path.Path 2 | 3 | /* 4 | * Copyright 2021-2022 Wilko Manger 5 | * 6 | * This file is part of Dotlin. 7 | * 8 | * Dotlin is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Dotlin is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with Dotlin. If not, see . 20 | */ 21 | 22 | /** 23 | * Used to reference the `_$DefaultValue` Dart type in multiline 24 | * code strings. Note that you have to add the `_` prefix yourself. 25 | */ 26 | const val DefaultValue = "\$DefaultValue" 27 | 28 | val stdlibPath = Path("../packages/dotlin") -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/intrinsics/Jump.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dotlin.intrinsics 18 | 19 | // TODO: Kotlin-only internal (@DartPublic) 20 | 21 | internal sealed interface `$Jump` { 22 | val target: Int 23 | } 24 | 25 | internal class `$Return` const constructor(val value: T, override val target: Int) : `$Jump` 26 | internal class `$Break` const constructor(override val target: Int) : `$Jump` 27 | internal class `$Continue` const constructor(override val target: Int) : `$Jump` -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/descriptors/DartInteropDescriptor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.descriptors 21 | 22 | /** 23 | * Marker interface for Dart descriptors that were not originated from loaded Dart source, but 24 | * created by Dotlin for Kotlin interoperability. 25 | */ 26 | interface DartInteropDescriptor -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/annotation/DartAnnotatedNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.annotation 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | 24 | interface DartAnnotatedNode : DartAstNode { 25 | val annotations: List 26 | val documentationComment: String? 27 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dart/core/Duration.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dart.core 18 | 19 | // Stub: Rest will be generated later by dtgen. 20 | 21 | @DartLibrary("dart:core") 22 | external class Duration const constructor( 23 | days: Int = 0, 24 | hours: Int = 0, 25 | minutes: Int = 0, 26 | seconds: Int = 0, 27 | milliseconds: Int = 0, 28 | microseconds: Int = 0 29 | ) : Comparable { 30 | override fun compareTo(other: Duration): Int = definedExternally 31 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Progressions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.ranges 19 | 20 | import kotlin.internal.getProgressionLastElement 21 | 22 | /** 23 | * A progression of values of type `Char`. 24 | */ 25 | internal external interface CharProgression : Iterable(Interface) 26 | 27 | /** 28 | * A progression of values of type `Long`. 29 | */ 30 | internal external interface LongProgression : Iterable(Interface) 31 | 32 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Iterators.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.collections 19 | 20 | private external interface ByteIterator 21 | private external interface CharIterator 22 | private external interface ShortIterator 23 | private external interface IntIterator 24 | private external interface LongIterator 25 | private external interface FloatIterator 26 | private external interface DoubleIterator 27 | private external interface BooleanIterator -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/function/body/DartFunctionBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.function.body 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | 24 | interface DartFunctionBody : DartAstNode { 25 | val isAsync: Boolean 26 | val isGenerator: Boolean 27 | } 28 | 29 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartTypedLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.type.DartTypeArgumentList 23 | 24 | interface DartTypedLiteral : DartLiteral { 25 | val isConst: Boolean 26 | val typeArguments: DartTypeArgumentList 27 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/native/Nothing.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * Nothing has no instances. You can use Nothing to represent "a value that never exists": for example, 22 | * if a function has the return type of Nothing, it means that it never returns (always throws an exception). 23 | * 24 | * Corresponds to `Never` in Dart. 25 | */ 26 | @DartLibrary("dart:core") 27 | @DartName("Never") 28 | external class Nothing private constructor() 29 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/ThrowSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.jetbrains.kotlin.builtins.KotlinBuiltIns 4 | import org.jetbrains.kotlin.diagnostics.Diagnostic 5 | import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters2 6 | import org.jetbrains.kotlin.diagnostics.Errors 7 | import org.jetbrains.kotlin.types.SimpleType 8 | 9 | object ThrowSuppressor : SubSuppressor { 10 | // Suppress Throwable expected error, we can throw anything (except null). 11 | override fun Diagnostic.isSuppressed(): Boolean { 12 | val isConstant = factory == Errors.CONSTANT_EXPECTED_TYPE_MISMATCH 13 | if ((factory != Errors.TYPE_MISMATCH && !isConstant) || 14 | this !is DiagnosticWithParameters2<*, *, *> 15 | ) { 16 | return false 17 | } 18 | 19 | val expectedType = when { 20 | isConstant -> b as? SimpleType ?: return false 21 | else -> a as? SimpleType ?: return false 22 | } 23 | 24 | return KotlinBuiltIns.isThrowableOrNullableThrowable(expectedType) 25 | } 26 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/AbstractFactoryConstructorCallSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.dotlin.compiler.backend.descriptors.dartElementAs 4 | import org.dotlin.compiler.dart.element.DartConstructorElement 5 | import org.jetbrains.kotlin.diagnostics.Diagnostic 6 | import org.jetbrains.kotlin.diagnostics.Errors.CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS 7 | import org.jetbrains.kotlin.psi.KtElement 8 | import org.jetbrains.kotlin.resolve.BindingTraceContext 9 | import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall 10 | 11 | class AbstractFactoryConstructorCallSuppressor(private val trace: BindingTraceContext) : SubSuppressor { 12 | override fun Diagnostic.isSuppressed(): Boolean { 13 | if (factory != CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS) return false 14 | 15 | val constructorCall = (this.psiElement as KtElement).getResolvedCall(trace.bindingContext) ?: return false 16 | val constructor = constructorCall.candidateDescriptor 17 | 18 | return constructor.dartElementAs()?.isFactory == true 19 | } 20 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/build.yaml: -------------------------------------------------------------------------------- 1 | targets: 2 | $default: 3 | sources: 4 | - $package$ 5 | - lib/$lib$ 6 | - proto/** 7 | builders: 8 | protoc_builder: 9 | options: 10 | # The version of the Protobuf compiler to use. 11 | # (Default: "3.19.1", make sure to use quotation marks) 12 | protobuf_version: "3.19.1" 13 | # The version of the Dart protoc_plugin package to use. 14 | # (Default: "20.0.1", make sure to use quotation marks) 15 | protoc_plugin_version: "20.0.1" 16 | # Directory which is treated as the root of all Protobuf files. 17 | # (Default: "proto/") 18 | root_dir: "proto/" 19 | # Include paths given to the Protobuf compiler during compilation. 20 | # (Default: ["proto/"]) 21 | proto_paths: 22 | - "proto/" 23 | # The root directory for generated Dart output files. 24 | # (Default: "lib/src/proto") 25 | out_dir: "lib/src/generated" 26 | # Enable the gRPC flag for the Dart protoc plugin to generate `.pbgrpc.dart` files. 27 | # (Default: false) 28 | grpc: false -------------------------------------------------------------------------------- /packages/dotlin_generator/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Ranges.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | @file:Suppress("EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE", "MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED") 19 | 20 | package kotlin.ranges 21 | 22 | /** 23 | * A range of values of type `Char`. 24 | */ 25 | internal external interface CharRange : CharProgression, ClosedRange 26 | 27 | /** 28 | * A range of values of type `Long`. 29 | */ 30 | internal external interface LongRange : LongProgression, ClosedRange -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/ir2ast/transformer/util/DartConstructorUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.ir2ast.transformer.util 21 | 22 | import org.dotlin.compiler.backend.steps.ir2ast.ir.IrDotlinDeclarationOrigin 23 | import org.jetbrains.kotlin.ir.declarations.IrConstructor 24 | 25 | val IrConstructor.isDartFactory: Boolean 26 | get() = origin == IrDotlinDeclarationOrigin.FACTORY -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/DartPlatform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.src2ir 21 | 22 | import org.jetbrains.kotlin.platform.SimplePlatform 23 | import org.jetbrains.kotlin.platform.TargetPlatform 24 | 25 | object DartPlatform : TargetPlatform(setOf(Simple)) { 26 | object Simple : SimplePlatform("Dart") { 27 | override val oldFashionedDescription = "Dart" 28 | } 29 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/lib/src/dart_package.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin Generator. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | import 'package:path/path.dart' as p; 21 | 22 | class DartPackage { 23 | final String path; 24 | 25 | /// Most of the time `lib/`. 26 | final String packagePath; 27 | 28 | DartPackage({required this.path, required this.packagePath}); 29 | 30 | late final String dotlinPath = p.join(path, '.dotlin'); 31 | 32 | late final String dlibPath = p.join(dotlinPath, 'dlib'); 33 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dotlin/intrinsics/CollectionMarkers.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dotlin.intrinsics 18 | 19 | // Markers used in instanceof checks as an optimization to prevent unncessary calls to `isGrowable` etc. 20 | 21 | // TODO: @DartPublic 22 | 23 | internal interface ImmutableListMarker 24 | internal interface WriteableListMarker 25 | internal interface MutableListMarker 26 | internal interface FixedSizeListMarker 27 | 28 | internal interface ImmutableSetMarker 29 | internal interface MutableSetMarker 30 | 31 | internal interface ImmutableMapMarker 32 | internal interface MutableMapMarker -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/DartAstNode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast 21 | 22 | interface DartAstNode { 23 | fun accept(visitor: DartAstNodeVisitor, data: D): R 24 | 25 | fun acceptChildren(visitor: DartAstNodeVisitor, data: D) 26 | } 27 | 28 | fun Collection.accept(visitor: DartAstNodeVisitor, data: C) = 29 | map { it.accept(visitor, data) } -------------------------------------------------------------------------------- /compiler/src/test/kotlin/compile/klib/StandardLibrary.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package compile.klib 21 | 22 | import BaseTest 23 | import assertCanCompileProject 24 | import org.junit.jupiter.api.DisplayName 25 | import org.junit.jupiter.api.Test 26 | import stdlibPath 27 | 28 | @DisplayName("Compile: Klib: Standard Library") 29 | class StandardLibrary : BaseTest { 30 | @Test 31 | fun `compile stdlib`() = assertCanCompileProject { 32 | path = stdlibPath 33 | } 34 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/compilationunit/DartNamedCompilationUnitMember.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.compilationunit 21 | 22 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 23 | 24 | interface DartNamedCompilationUnitMember : DartCompilationUnitMember { 25 | val name: DartSimpleIdentifier 26 | } 27 | 28 | val DartNamedCompilationUnitMember.isPrivate: Boolean 29 | get() = name.isPrivate 30 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dart/typed_data/Endian.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dart.typed_data 18 | 19 | /** 20 | * Describes endianness to be used when accessing or updating a 21 | * sequence of bytes. 22 | */ 23 | external interface Endian { 24 | companion object { 25 | // TODO: const 26 | @DartName("big") 27 | external val BIG: Endian = definedExternally 28 | 29 | // TODO: const 30 | @DartName("little") 31 | external val LITTLE: Endian = definedExternally 32 | 33 | // TODO: const 34 | @DartName("host") 35 | external val HOST: Endian = definedExternally 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartCode.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | @JvmInline 25 | value class DartCode(val value: String) : DartExpression { 26 | override fun accept(visitor: DartAstNodeVisitor, data: C) = visitor.visitCode(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartBreakStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | object DartBreakStatement : DartStatement { 25 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 26 | visitor.visitBreakStatement(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartSuperExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | object DartSuperExpression : DartExpression { 25 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 26 | visitor.visitSuperExpression(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartThisExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | object DartThisExpression : DartExpression { 25 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 26 | visitor.visitThisExpression(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartContinueStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | object DartContinueStatement : DartStatement { 25 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 26 | visitor.visitContinueStatement(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartNullLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | object DartNullLiteral : DartLiteral { 25 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 26 | visitor.visitNullLiteral(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/DartLabel.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast 21 | 22 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 23 | 24 | @JvmInline 25 | value class DartLabel(val value: DartSimpleIdentifier) : DartAstNode { 26 | override fun accept(visitor: DartAstNodeVisitor, data: C) = visitor.visitLabel(this, data) 27 | 28 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/DotlinUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import org.dotlin.compiler.backend.dotlin 23 | import org.jetbrains.kotlin.ir.types.IrType 24 | import org.jetbrains.kotlin.ir.types.classFqName 25 | 26 | fun IrType.isDotlinReturn(): Boolean = classFqName == dotlin.intrinsics.`$Return` 27 | 28 | fun IrType.isDotlinLoopJump(): Boolean = with(dotlin.intrinsics) { 29 | classFqName.let { it == `$Continue` || it == `$Break` } 30 | } 31 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/dart/typed_data/TypedData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package dart.typed_data 18 | 19 | /** 20 | * A typed view of a sequence of bytes. 21 | */ 22 | external interface TypedData { 23 | /** 24 | * Returns the number of bytes in the representation of each element in this 25 | * array. 26 | */ 27 | val elementSizeInBytes: Int 28 | 29 | /** 30 | * Returns the offset in bytes into the underlying byte buffer of this view. 31 | */ 32 | val offsetInBytes: Int 33 | 34 | /** 35 | * Returns the length of this view, in bytes. 36 | */ 37 | val lengthInBytes: Int 38 | 39 | // TODO: buffer 40 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/native/Comparable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2015 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * Classes which inherit from this interface have a defined total ordering between their instances. 22 | */ 23 | @DartLibrary("dart:core") 24 | external interface Comparable { 25 | /** 26 | * Compares this object with the specified object for order. Returns zero if this object is equal 27 | * to the specified [other] object, a negative number if it's less than [other], or a positive number 28 | * if it's greater than [other]. 29 | */ 30 | operator fun compareTo(other: T): Int 31 | } 32 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/native/Lazy.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package kotlin 18 | 19 | import kotlin.reflect.KProperty 20 | 21 | /** 22 | * To create a lazily initialized variable or property, use [lazy]. 23 | */ 24 | external interface Lazy { 25 | operator fun getValue(thisRef: Any?, property: KProperty<*>): T 26 | } 27 | 28 | /** 29 | * Lazily initializes a variable or property with the given [initializer]. 30 | * 31 | * In Dart, the variable or property will be compiled as `late`. The [Lazy] 32 | * delegate is not used. 33 | */ 34 | // TODO: Error if using as anything but a property delegate 35 | external fun lazy(initializer: () -> T): Lazy -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/SystemUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import java.nio.file.Path 23 | import kotlin.io.path.Path 24 | 25 | fun onWindows(): Boolean = System.getProperty("os.name").startsWith("Windows") 26 | 27 | val homePathString: String? 28 | get() = System.getProperty("user.home") ?: System.getenv("HOME") 29 | 30 | val homePath: Path? 31 | get() = homePathString?.let { Path(it) } 32 | 33 | fun envPath(key: String) = System.getenv(key)?.let { Path(it) } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/parameter/DartNormalFormalParameter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.parameter 21 | 22 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 23 | 24 | interface DartNormalFormalParameter : DartFormalParameter { 25 | /** 26 | * Is null when it's part of a function type. 27 | */ 28 | val identifier: DartSimpleIdentifier? 29 | 30 | val isCovariant: Boolean 31 | val isConst: Boolean 32 | val isFinal: Boolean 33 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/typealias/DartTypeAlias.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.`typealias` 21 | 22 | import org.dotlin.compiler.dart.ast.compilationunit.DartNamedCompilationUnitMember 23 | import org.dotlin.compiler.dart.ast.type.DartTypeAnnotation 24 | import org.dotlin.compiler.dart.ast.type.parameter.DartTypeParameterList 25 | 26 | sealed interface DartTypeAlias : DartNamedCompilationUnitMember { 27 | val typeParameters: DartTypeParameterList 28 | val aliased: DartTypeAnnotation 29 | } -------------------------------------------------------------------------------- /compiler/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | 3 | *.iml 4 | *.ipr 5 | 6 | # File-based project format 7 | *.iws 8 | 9 | out/ 10 | 11 | # mpeltonen/sbt-idea plugin 12 | .idea_modules/ 13 | 14 | # JIRA plugin 15 | atlassian-ide-plugin.xml 16 | 17 | # Cursive Clojure plugin 18 | .idea/replstate.xml 19 | 20 | # Crashlytics plugin (for Android Studio and IntelliJ) 21 | com_crashlytics_export_strings.xml 22 | crashlytics.properties 23 | crashlytics-build.properties 24 | fabric.properties 25 | 26 | # Editor-based Rest Client 27 | .idea/httpRequests 28 | 29 | # Android studio 3.1+ serialized cache file 30 | .idea/caches/build_file_checksums.ser 31 | 32 | ## Java 33 | 34 | # Compiled class file 35 | *.class 36 | 37 | # Log file 38 | *.log 39 | 40 | # BlueJ files 41 | *.ctxt 42 | 43 | # Mobile Tools for Java (J2ME) 44 | .mtj.tmp/ 45 | 46 | # Package Files # 47 | *.jar 48 | *.war 49 | *.nar 50 | *.ear 51 | *.zip 52 | *.tar.gz 53 | *.rar 54 | 55 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 56 | hs_err_pid* 57 | 58 | ## Gradle 59 | 60 | .gradle 61 | **/build/ 62 | !src/**/build/ 63 | 64 | # Ignore Gradle GUI config 65 | gradle-app.setting 66 | 67 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 68 | !gradle-wrapper.jar 69 | 70 | # Cache of project 71 | .gradletasknamecache 72 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/ast2dart/DartAstToDartSource.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.ast2dart 21 | 22 | import org.dotlin.compiler.backend.steps.ast2dart.transformer.accept 23 | import org.dotlin.compiler.dart.ast.compilationunit.DartCompilationUnit 24 | import java.nio.file.Path 25 | 26 | fun dartAstToDartSource(units: Map): Map { 27 | val context = DartGenerationContext() 28 | 29 | return units.mapValues { (_, unit) -> unit.accept(context) } 30 | } 31 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/ir/CheckerUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.src2ir.analyze.ir 21 | 22 | import org.dotlin.compiler.backend.util.getFqName 23 | import org.jetbrains.kotlin.name.FqName 24 | import org.jetbrains.kotlin.psi.KtAnnotated 25 | import org.jetbrains.kotlin.resolve.BindingContext 26 | 27 | // TODO: context(IrContext) 28 | fun KtAnnotated.getAnnotation(fqName: FqName, bindingContext: BindingContext) = 29 | annotationEntries.firstOrNull { entry -> entry.getFqName(bindingContext) == fqName } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/DartDiagnosticSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.dotlin.compiler.backend.steps.src2ir.markSuppressed 4 | import org.jetbrains.kotlin.diagnostics.Diagnostic 5 | import org.jetbrains.kotlin.resolve.BindingTraceContext 6 | import org.jetbrains.kotlin.resolve.diagnostics.DiagnosticSuppressor 7 | 8 | class DartDiagnosticSuppressor( 9 | private val trace: BindingTraceContext, 10 | ) : DiagnosticSuppressor { 11 | private val subSuppressors = listOf( 12 | NumberPrimitiveSuppressor, 13 | ThrowSuppressor, 14 | SpecialInheritanceSuppressor(trace), 15 | ConstSuppressor(trace), 16 | TypeErasureSuppressor, 17 | LateInitSuppressor, 18 | KotlinIteratorSuppressor, 19 | InlineSuppressor, 20 | AbstractFactoryConstructorCallSuppressor(trace), 21 | ) 22 | 23 | override fun isSuppressed(diagnostic: Diagnostic): Boolean = diagnostic.let { 24 | return subSuppressors.any { with(it) { diagnostic.isSuppressed() } }.also { isSuppressed -> 25 | if (isSuppressed) { 26 | trace.markSuppressed(diagnostic) 27 | } 28 | } 29 | } 30 | } 31 | 32 | interface SubSuppressor { 33 | fun Diagnostic.isSuppressed(): Boolean 34 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/collections/SetFactories.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.collections 19 | 20 | /** 21 | * Returns a new immutable set with the given elements. Elements of the set are 22 | * iterated in the order they were specified. 23 | */ 24 | external const inline fun setOf(vararg elements: T): ImmutableSet 25 | 26 | /** 27 | * Returns an empty immutable set. 28 | */ 29 | external const inline fun emptySet(): ImmutableSet 30 | 31 | /** 32 | * Returns a new [MutableSet] with the given elements. Elements of the set are 33 | * iterated in the order they were specified. 34 | */ 35 | external inline fun mutableSetOf(vararg elements: T): MutableSet -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/DotlinSymbolTable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.src2ir 21 | 22 | import org.jetbrains.kotlin.ir.declarations.IrFactory 23 | import org.jetbrains.kotlin.ir.util.IdSignatureComposer 24 | import org.jetbrains.kotlin.ir.util.NameProvider 25 | import org.jetbrains.kotlin.ir.util.SymbolTable 26 | 27 | class DotlinSymbolTable( 28 | signaturer: IdSignatureComposer, 29 | irFactory: IrFactory, 30 | nameProvider: NameProvider = NameProvider.DEFAULT 31 | ) : SymbolTable(signaturer, irFactory, nameProvider) { 32 | 33 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/unused/Primitives.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | @file:Suppress( 19 | "NON_ABSTRACT_FUNCTION_WITH_NO_BODY", 20 | "MUST_BE_INITIALIZED_OR_BE_ABSTRACT", 21 | "UNUSED_PARAMETER", 22 | "DIVISION_BY_ZERO", 23 | "INAPPLICABLE_OPERATOR_MODIFIER" 24 | ) 25 | 26 | package kotlin 27 | 28 | @DartLibrary("dart:core") 29 | @DartName("int") 30 | internal external abstract class Byte private constructor() : Number() 31 | 32 | @DartLibrary("dart:core") 33 | @DartName("int") 34 | internal external abstract class Short private constructor() : Number() 35 | 36 | @DartLibrary("dart:core") 37 | @DartName("double") 38 | internal external abstract class Float private constructor() : Number() -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/ast2dart/transformer/DartCollectionElementTransformer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.ast2dart.transformer 21 | 22 | import org.dotlin.compiler.backend.steps.ast2dart.DartGenerationContext 23 | import org.dotlin.compiler.dart.ast.collection.DartCollectionElementList 24 | 25 | object DartCollectionElementTransformer : DartAstNodeTransformer() { 26 | override fun DartGenerationContext.visitCollectionElementList(collectionElementList: DartCollectionElementList) = 27 | collectionElementList.accept(separator = ", ") 28 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/checkers/file/DartDuplicateImportChecker.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.checkers.file 2 | 3 | import org.dotlin.compiler.backend.steps.src2ir.analyze.ir.ErrorsDart.DUPLICATE_IMPORT 4 | import org.dotlin.compiler.backend.util.descriptor 5 | import org.jetbrains.kotlin.psi.KtFile 6 | import org.jetbrains.kotlin.resolve.BindingTrace 7 | 8 | /** 9 | * Checks whether the same Dart declarations are imported through multiple imports. This can happen if for example 10 | * a class is imported through a Dart `export` directive and also imported through the file it was declared in. 11 | */ 12 | class DartDuplicateImportChecker(private val trace: BindingTrace) : SourceFileChecker { 13 | override fun check(file: KtFile) { 14 | val descriptorsByImports = file.importDirectives.associateWith { 15 | it.descriptor(trace.bindingContext) 16 | } 17 | 18 | for ((import, descriptor) in descriptorsByImports) { 19 | if (descriptor == null) continue 20 | 21 | val otherImport = descriptorsByImports.entries 22 | .firstOrNull { (i, d) -> i != import && d == descriptor } 23 | ?.key 24 | ?: continue 25 | 26 | trace.report(DUPLICATE_IMPORT.on(import, descriptor, otherImport)) 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartThrowExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | data class DartThrowExpression( 25 | val expression: DartExpression, 26 | ) : DartExpression { 27 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 28 | visitor.visitThrowExpression(this, data) 29 | 30 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 31 | expression.accept(visitor, data) 32 | } 33 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartDoubleLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | @JvmInline 25 | value class DartDoubleLiteral(val value: Double) : DartLiteral { 26 | constructor(value: Float) : this(value.toDouble()) 27 | 28 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 29 | visitor.visitDoubleLiteral(this, data) 30 | 31 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 32 | } -------------------------------------------------------------------------------- /compiler/src/test/kotlin/FunctionDisplayNameGenerator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | import org.junit.jupiter.api.DisplayNameGenerator 21 | import java.lang.reflect.Method 22 | 23 | class FunctionDisplayNameGenerator : DisplayNameGenerator { 24 | override fun generateDisplayNameForClass(testClass: Class<*>?) = testClass?.simpleName ?: "null" 25 | 26 | override fun generateDisplayNameForNestedClass(nestedClass: Class<*>?) = nestedClass?.simpleName ?: "null" 27 | 28 | override fun generateDisplayNameForMethod(testClass: Class<*>?, testMethod: Method?) = 29 | testMethod?.name?.replace(Regex("""\(\($"""), "") 30 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/ImportUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import org.jetbrains.kotlin.backend.jvm.ir.getKtFile 23 | import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName 24 | import org.jetbrains.kotlin.ir.declarations.IrFile 25 | import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable 26 | 27 | fun IrDeclarationWithName.importAliasIn(file: IrFile): String? { 28 | val ktFile = file.getKtFile() ?: return null 29 | val fqName = fqNameWhenAvailable ?: return null 30 | 31 | return ktFile.findAliasByFqName(fqName)?.name 32 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartTypeLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.type.DartTypeAnnotation 24 | 25 | @JvmInline 26 | value class DartTypeLiteral(val type: DartTypeAnnotation) : DartLiteral { 27 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 28 | visitor.visitTypeLiteral(this, data) 29 | 30 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 31 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/lib/src/serialize/util.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin Generator. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | import 'package:analyzer/dart/element/element.dart'; 21 | import 'package:protobuf/protobuf.dart'; 22 | 23 | B polymorphicOf( 24 | B Function({required String type, required List value}) constructor, 25 | GeneratedMessage element, 26 | ) { 27 | return constructor( 28 | type: 'org.dotlin.compiler.dart.element.${element.runtimeType}', 29 | value: element.writeToBuffer(), 30 | ); 31 | } 32 | 33 | extension EncodedElementLocation on Element { 34 | String get encodedLocation => location!.encoding; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/ConstructorUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import org.dotlin.compiler.backend.dotlin 23 | import org.jetbrains.kotlin.ir.expressions.IrConstructorCall 24 | import org.jetbrains.kotlin.ir.expressions.IrEnumConstructorCall 25 | import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression 26 | 27 | fun IrFunctionAccessExpression.isDartConstructorCall(): Boolean { 28 | if (this is IrConstructorCall || this is IrEnumConstructorCall) return true 29 | 30 | return symbol.owner.hasAnnotation(dotlin.DartConstructor) 31 | } 32 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/reflect/KCallable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2018 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.reflect 19 | 20 | /** 21 | * Represents a callable entity, such as a function or a property. 22 | * 23 | * @param R return type of the callable. 24 | */ 25 | interface KCallable { 26 | /** 27 | * The name of this callable as it was declared in the source code. 28 | * If the callable has no name, a special invented name is created. 29 | * Nameless callables include: 30 | * - constructors have the name "", 31 | * - property accessors: the getter for a property named "foo" will have the name "", 32 | * the setter, similarly, will have the name "". 33 | */ 34 | val name: String 35 | } 36 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/function/body/DartEmptyFunctionBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.function.body 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | data class DartEmptyFunctionBody( 25 | override val isAsync: Boolean = false, 26 | override val isGenerator: Boolean = false, 27 | ) : DartFunctionBody { 28 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 29 | visitor.visitEmptyFunctionBody(this, data) 30 | 31 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 32 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/Library.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * Returns a string representation of the object. Can be called with a null receiver, in which case 22 | * it returns the string "null". 23 | */ 24 | @DartExtensionName("SafeToString") 25 | @DartName("safeToString") 26 | fun Any?.toString(): String { 27 | if (this == null) return "null" 28 | return toString() 29 | } 30 | 31 | /** 32 | * Concatenates this string with the string representation of the given [other] object. If either the receiver 33 | * or the [other] object are null, they are represented as the string "null". 34 | */ 35 | @DartExtensionName("SafeStringPlus") 36 | operator fun String?.plus(other: Any?): String = toString() + other.toString() -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/DiagnosticsUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler 21 | 22 | import org.jetbrains.kotlin.diagnostics.Diagnostic 23 | import org.jetbrains.kotlin.diagnostics.Severity 24 | 25 | val Iterable.warnings 26 | get() = filter { it.severity == Severity.WARNING } 27 | 28 | val Iterable.errors 29 | get() = filter { it.severity == Severity.ERROR } 30 | 31 | val Iterable.hasWarnings 32 | get() = warnings.isNotEmpty() 33 | 34 | val Iterable.hasErrors 35 | get() = errors.isNotEmpty() 36 | 37 | val Iterable.factories 38 | get() = map { it.factory } -------------------------------------------------------------------------------- /compiler/src/test/kotlin/analysis/dialect/TypeErasure.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package analysis.dialect 21 | 22 | import BaseTest 23 | import assertCompilesWithWarning 24 | import org.dotlin.compiler.backend.steps.src2ir.analyze.ir.ErrorsDart 25 | import org.junit.jupiter.api.DisplayName 26 | import org.junit.jupiter.api.Test 27 | 28 | @DisplayName("Analysis: Dialect: Type Erasure") 29 | class TypeErasure : BaseTest { 30 | @Test 31 | fun `warning if using reified`() = assertCompilesWithWarning(ErrorsDart.UNNECESSARY_REIFIED) { 32 | kotlin( 33 | """ 34 | inline fun test() {} 35 | """ 36 | ) 37 | } 38 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/invocation/DartFunctionExpressionInvocation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.invocation 21 | 22 | import org.dotlin.compiler.dart.ast.expression.DartArgumentList 23 | import org.dotlin.compiler.dart.ast.expression.DartExpression 24 | import org.dotlin.compiler.dart.ast.type.DartTypeArgumentList 25 | 26 | data class DartFunctionExpressionInvocation( 27 | override val function: DartExpression, 28 | override val arguments: DartArgumentList = DartArgumentList(), 29 | override val typeArguments: DartTypeArgumentList = DartTypeArgumentList(), 30 | ) : DartInvocationExpression -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartIndexExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | data class DartIndexExpression( 25 | val target: DartExpression, 26 | val index: DartExpression 27 | ) : DartExpression { 28 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 29 | visitor.visitIndexExpression(this, data) 30 | 31 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 32 | target.accept(visitor, data) 33 | index.accept(visitor, data) 34 | } 35 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartSimpleStringLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | data class DartSimpleStringLiteral( 25 | val value: String, 26 | override val isRaw: Boolean = false, 27 | override val isTripleQuoted: Boolean = false, 28 | ) : DartSingleStringLiteral { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 30 | visitor.visitSimpleStringLiteral(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 33 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartReturnStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.DartExpression 24 | 25 | data class DartReturnStatement( 26 | val expression: DartExpression?, 27 | ) : DartStatement { 28 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 29 | visitor.visitReturnStatement(this, data) 30 | 31 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 32 | expression?.accept(visitor, data) 33 | } 34 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartBooleanLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | @JvmInline 25 | value class DartBooleanLiteral(val value: Boolean) : DartLiteral { 26 | companion object { 27 | val TRUE = DartBooleanLiteral(true) 28 | val FALSE = DartBooleanLiteral(false) 29 | } 30 | 31 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 32 | visitor.visitBooleanLiteral(this, data) 33 | 34 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 35 | } -------------------------------------------------------------------------------- /compiler/src/test/kotlin/compile/dialect/TypeAlias.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package compile.dialect 21 | 22 | import BaseTest 23 | import assertCompile 24 | import org.junit.jupiter.api.DisplayName 25 | import org.junit.jupiter.api.Test 26 | 27 | @DisplayName("Compile: Dialect: Type Alias") 28 | class TypeAlias : BaseTest { 29 | @Test 30 | fun `type alias to dynamic`() = assertCompile { 31 | kotlin( 32 | """ 33 | import dotlin.intrinsics.Dynamic 34 | 35 | typealias MyDynamic = Dynamic 36 | """ 37 | ) 38 | 39 | dart( 40 | """ 41 | typedef MyDynamic = dynamic; 42 | """ 43 | ) 44 | } 45 | } -------------------------------------------------------------------------------- /DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this 7 | license document, but changing it is not allowed. 8 | 9 | 10 | Developer's Certificate of Origin 1.1 11 | 12 | By making a contribution to this project, I certify that: 13 | 14 | (a) The contribution was created in whole or in part by me and I 15 | have the right to submit it under the open source license 16 | indicated in the file; or 17 | 18 | (b) The contribution is based upon previous work that, to the best 19 | of my knowledge, is covered under an appropriate open source 20 | license and I have the right under that license to submit that 21 | work with modifications, whether created in whole or in part 22 | by me, under the same open source license (unless I am 23 | permitted to submit under a different license), as indicated 24 | in the file; or 25 | 26 | (c) The contribution was provided directly to me by some other 27 | person who certified (a), (b) or (c) and I have not modified 28 | it. 29 | 30 | (d) I understand and agree that this project and the contribution 31 | are public and that a record of the contribution (including all 32 | personal information I submit with it, including my sign-off) is 33 | maintained indefinitely and may be redistributed consistent with 34 | this project or the open source license(s) involved. -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartParenthesizedExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | data class DartParenthesizedExpression( 25 | val expression: DartExpression, 26 | ) : DartExpression { 27 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 28 | visitor.visitParenthesizedExpression(this, data) 29 | 30 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 31 | expression.accept(visitor, data) 32 | } 33 | } 34 | 35 | fun DartExpression.parenthesize() = DartParenthesizedExpression(this) -------------------------------------------------------------------------------- /compiler/src/test/kotlin/compile/dialect/Type.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package compile.dialect 21 | 22 | import BaseTest 23 | import assertCompile 24 | import org.junit.jupiter.api.DisplayName 25 | import org.junit.jupiter.api.Test 26 | 27 | @DisplayName("Compile: Dialect: Type") 28 | class Type : BaseTest { 29 | @Test 30 | fun typeOf() = assertCompile { 31 | kotlin( 32 | """ 33 | fun main() { 34 | val myType = typeOf() 35 | } 36 | """ 37 | ) 38 | 39 | dart( 40 | """ 41 | void main() { 42 | final Type myType = String; 43 | } 44 | """ 45 | ) 46 | } 47 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/classlike/DartExtendsClause.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.classlike 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.type.DartNamedType 25 | 26 | data class DartExtendsClause( 27 | val type: DartNamedType, 28 | ) : DartAstNode { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 30 | visitor.visitExtendsClause(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 33 | type.accept(visitor, data) 34 | } 35 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/literal/DartIntegerLiteral.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.literal 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | @JvmInline 25 | value class DartIntegerLiteral(val value: Long) : DartLiteral { 26 | constructor(value: Byte) : this(value.toLong()) 27 | constructor(value: Short) : this(value.toLong()) 28 | constructor(value: Int) : this(value.toLong()) 29 | 30 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 31 | visitor.visitIntegerLiteral(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) {} 34 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartNamedExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.DartLabel 24 | 25 | data class DartNamedExpression( 26 | val label: DartLabel, 27 | val expression: DartExpression, 28 | ) : DartExpression { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 30 | visitor.visitNamedExpression(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 33 | label.accept(visitor, data) 34 | expression.accept(visitor, data) 35 | } 36 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/checkers/call/SpecialInheritanceConstructorCallChecker.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.checkers.call 2 | 3 | import com.intellij.psi.PsiElement 4 | import org.dotlin.compiler.backend.steps.src2ir.analyze.ir.ErrorsDart 5 | import org.dotlin.compiler.backend.util.isSpecialInheritanceMarker 6 | import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor 7 | import org.jetbrains.kotlin.psi.KtExpression 8 | import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry 9 | import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker 10 | import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext 11 | import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall 12 | 13 | object SpecialInheritanceConstructorCallChecker : CallChecker { 14 | override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { 15 | val descriptor = resolvedCall.resultingDescriptor 16 | if (descriptor !is ClassConstructorDescriptor) return 17 | 18 | // Should be a constructor with a single parameter with the marker type. 19 | descriptor.valueParameters.singleOrNull{ it.type.isSpecialInheritanceMarker() } ?: return 20 | 21 | // As as super type is the right usage, return. 22 | if (reportOn.parent is KtSuperTypeCallEntry) return 23 | 24 | context.trace.report(ErrorsDart.SPECIAL_INHERITANCE_CONSTRUCTOR_MISUSE.on(reportOn as KtExpression)) 25 | } 26 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartAsExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.type.DartTypeAnnotation 24 | 25 | data class DartAsExpression( 26 | val expression: DartExpression, 27 | val type: DartTypeAnnotation, 28 | ) : DartExpression { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 30 | visitor.visitAsExpression(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 33 | expression.accept(visitor, data) 34 | type.accept(visitor, data) 35 | } 36 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartBlock.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.accept 24 | 25 | 26 | class DartBlock( 27 | val statements: List = listOf() 28 | ) : DartStatement { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = visitor.visitBlock(this, data) 30 | 31 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 32 | statements.accept(visitor, data) 33 | } 34 | } 35 | 36 | fun DartStatement.wrapInBlock(): DartBlock = if (this is DartBlock) this else DartBlock(statements = listOf(this)) -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/ExternalUtils.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.util 2 | 3 | import org.dotlin.compiler.backend.dotlin 4 | import org.jetbrains.kotlin.backend.jvm.ir.psiElement 5 | import org.jetbrains.kotlin.ir.declarations.IrClass 6 | import org.jetbrains.kotlin.ir.declarations.IrDeclaration 7 | import org.jetbrains.kotlin.ir.util.isEffectivelyExternal 8 | import org.jetbrains.kotlin.ir.util.parentClassOrNull 9 | import org.jetbrains.kotlin.lexer.KtTokens 10 | import org.jetbrains.kotlin.psi.KtDeclaration 11 | 12 | /** 13 | * True if this declaration has the `external` keyword in front of it in the source, or 14 | * if it's annotated with `@DotlinExternal`. 15 | */ 16 | val IrDeclaration.isExplicitlyExternal: Boolean 17 | get() = hasAnnotation(dotlin.intrinsics.DotlinExternal) || 18 | (psiElement as? KtDeclaration)?.hasModifier(KtTokens.EXTERNAL_KEYWORD) == true 19 | 20 | /** 21 | * Whether this declaration is external by Dotlin standards. This means that companion objects are only 22 | * considered external if they explicitly had the `external` keyword in front of them. 23 | */ 24 | val IrDeclaration.isDotlinExternal: Boolean 25 | get() = when { 26 | this is IrClass && isCompanion -> isExplicitlyExternal 27 | parentClassOrNull is IrClass && parentClassOrNull?.isCompanion == true -> { 28 | isExplicitlyExternal || parentClassOrNull?.isExplicitlyExternal == true 29 | } 30 | else -> isEffectivelyExternal() 31 | } 32 | 33 | -------------------------------------------------------------------------------- /compiler/src/test/kotlin/compile/dialect/Primitives.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package compile.dialect 21 | 22 | import BaseTest 23 | import assertCompile 24 | import org.junit.jupiter.api.DisplayName 25 | import org.junit.jupiter.api.Test 26 | 27 | @DisplayName("Compile: Dialect: Primitives") 28 | class Primitives : BaseTest { 29 | @Test 30 | fun `using Long literal on Int`() = assertCompile { 31 | kotlin( 32 | """ 33 | fun main() { 34 | val x: Int = 9223372036854775807 35 | } 36 | """ 37 | ) 38 | 39 | dart( 40 | """ 41 | void main() { 42 | final int x = 9223372036854775807; 43 | } 44 | """ 45 | ) 46 | } 47 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/classlike/DartWithClause.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.classlike 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | import org.dotlin.compiler.dart.ast.type.DartNamedType 26 | 27 | data class DartWithClause( 28 | val mixins: List, 29 | ) : DartAstNode { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitWithClause(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | mixins.accept(visitor, data) 35 | } 36 | } -------------------------------------------------------------------------------- /packages/dotlin_generator/lib/src/generated/elements.pbenum.dart: -------------------------------------------------------------------------------- 1 | /// 2 | // Generated code. Do not modify. 3 | // source: elements.proto 4 | // 5 | // @dart = 2.12 6 | // ignore_for_file: annotate_overrides,camel_case_types,constant_identifier_names,directives_ordering,library_prefixes,non_constant_identifier_names,prefer_final_fields,return_of_invalid_type,unnecessary_const,unnecessary_import,unnecessary_this,unused_import,unused_shown_name 7 | 8 | // ignore_for_file: UNDEFINED_SHOWN_NAME 9 | import 'dart:core' as $core; 10 | import 'package:protobuf/protobuf.dart' as $pb; 11 | 12 | class DartNullabilitySuffix extends $pb.ProtobufEnum { 13 | static const DartNullabilitySuffix QUESTION_MARK = DartNullabilitySuffix._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'QUESTION_MARK'); 14 | static const DartNullabilitySuffix STAR = DartNullabilitySuffix._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STAR'); 15 | static const DartNullabilitySuffix NONE = DartNullabilitySuffix._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'NONE'); 16 | 17 | static const $core.List values = [ 18 | QUESTION_MARK, 19 | STAR, 20 | NONE, 21 | ]; 22 | 23 | static final $core.Map<$core.int, DartNullabilitySuffix> _byValue = $pb.ProtobufEnum.initByValue(values); 24 | static DartNullabilitySuffix? valueOf($core.int value) => _byValue[value]; 25 | 26 | const DartNullabilitySuffix._($core.int v, $core.String n) : super(v, n); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/checkers/call/KotlinIteratorMethodCallChecker.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.checkers.call 2 | 3 | import com.intellij.psi.PsiElement 4 | import org.dotlin.compiler.backend.steps.src2ir.analyze.ir.ErrorsDart 5 | import org.dotlin.compiler.backend.steps.src2ir.isIteratorMethod 6 | import org.jetbrains.kotlin.descriptors.FunctionDescriptor 7 | import org.jetbrains.kotlin.psi.KtCallExpression 8 | import org.jetbrains.kotlin.psi.KtExpression 9 | import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker 10 | import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext 11 | import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall 12 | import org.jetbrains.kotlin.resolve.descriptorUtil.firstOverridden 13 | 14 | object KotlinIteratorMethodCallChecker : CallChecker { 15 | override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { 16 | val descriptor = resolvedCall.resultingDescriptor 17 | // If it's not a call expression in the source, it's used in a loop. In that case we don't 18 | // want to report the diagnostic. 19 | if (descriptor !is FunctionDescriptor || reportOn.parent !is KtCallExpression) return 20 | 21 | val iteratorMethod = descriptor.firstOverridden { it.isIteratorMethod() } 22 | 23 | if (iteratorMethod != null) { 24 | context.trace.report(ErrorsDart.KOTLIN_ITERATOR_METHOD_USAGE.on(reportOn as KtExpression)) 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartIsExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.type.DartTypeAnnotation 24 | 25 | data class DartIsExpression( 26 | val expression: DartExpression, 27 | val type: DartTypeAnnotation, 28 | val isNegated: Boolean = false 29 | ) : DartExpression { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 31 | visitor.visitIsExpression(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | expression.accept(visitor, data) 35 | type.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/PropertyUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import org.dotlin.compiler.backend.hasDartGetterAnnotation 23 | import org.dotlin.compiler.backend.steps.ir2ast.ir.hasImplicitGetter 24 | import org.dotlin.compiler.backend.steps.ir2ast.ir.hasImplicitSetter 25 | import org.jetbrains.kotlin.ir.declarations.IrFunction 26 | import org.jetbrains.kotlin.ir.declarations.IrProperty 27 | import org.jetbrains.kotlin.ir.util.isGetter 28 | import org.jetbrains.kotlin.ir.util.isSetter 29 | 30 | val IrProperty.isSimple: Boolean 31 | get() = hasImplicitGetter && (!isVar || hasImplicitSetter) 32 | 33 | fun IrFunction.isDartGetter() = isGetter || hasDartGetterAnnotation() 34 | fun IrFunction.isDartSetter() = isSetter -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/collection/DartCollectionElementList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.collection 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | 26 | data class DartCollectionElementList( 27 | private val elements: List = listOf(), 28 | ) : DartAstNode, List by elements { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 30 | visitor.visitCollectionElementList(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 33 | elements.accept(visitor, data) 34 | } 35 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/classlike/DartImplementsClause.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.classlike 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | import org.dotlin.compiler.dart.ast.type.DartNamedType 26 | 27 | data class DartImplementsClause( 28 | val interfaces: List, 29 | ) : DartAstNode { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitImplementsClause(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | interfaces.accept(visitor, data) 35 | } 36 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartExpressionStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.DartExpression 24 | 25 | data class DartExpressionStatement( 26 | val expression: DartExpression, 27 | ) : DartStatement { 28 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 29 | visitor.visitExpressionStatement(this, data) 30 | 31 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 32 | expression.accept(visitor, data) 33 | } 34 | } 35 | 36 | fun DartExpression.asStatement(): DartExpressionStatement = DartExpressionStatement(this@asStatement) -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/ranges/ProgressionIterators.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2021 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.ranges 19 | 20 | /** 21 | * An iterator over a progression of values of type `Int`. 22 | * @property step the number by which the value is incremented on each step. 23 | */ 24 | // TODO: Add behavior test 25 | internal class IntProgressionIterator(private val first: Int, private val last: Int, val step: Int) : Iterator { 26 | private var hasNext: Boolean = if (step > 0) first <= last else first >= last 27 | 28 | override fun moveNext(): Boolean { 29 | _current = when (val current = _current) { 30 | null -> first 31 | last -> return false 32 | else -> current + step 33 | } 34 | 35 | return true 36 | } 37 | 38 | private var _current: Int? = null 39 | 40 | override val current: Int 41 | get() = _current!! 42 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/function/body/DartBlockFunctionBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.function.body 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.statement.DartBlock 24 | 25 | class DartBlockFunctionBody( 26 | val block: DartBlock = DartBlock(), 27 | override val isAsync: Boolean = false, 28 | override val isGenerator: Boolean = false, 29 | ) : DartFunctionBody { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitBlockFunctionBody(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | block.accept(visitor, data) 35 | } 36 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartConditionalExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | data class DartConditionalExpression( 25 | val condition: DartExpression, 26 | val thenExpression: DartExpression, 27 | val elseExpression: DartExpression 28 | ) : DartExpression { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 30 | visitor.visitConditionalExpression(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 33 | condition.accept(visitor, data) 34 | thenExpression.accept(visitor, data) 35 | elseExpression.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/function/body/DartExpressionFunctionBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.function.body 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.DartExpression 24 | 25 | class DartExpressionFunctionBody( 26 | val expression: DartExpression, 27 | override val isAsync: Boolean = false, 28 | override val isGenerator: Boolean = false, 29 | ) : DartFunctionBody { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitExpressionFunctionBody(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | expression.accept(visitor, data) 35 | } 36 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartArgumentList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | 26 | data class DartArgumentList( 27 | private val arguments: List = listOf(), 28 | ) : DartAstNode, List by arguments { 29 | constructor(vararg arguments: DartExpression) : this(arguments.toList()) 30 | 31 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 32 | visitor.visitArgumentList(this, data) 33 | 34 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 35 | arguments.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/DartIrUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | @file:OptIn(ObsoleteDescriptorBasedAPI::class) 21 | 22 | package org.dotlin.compiler.backend.util 23 | 24 | import org.dotlin.compiler.backend.descriptors.DartDescriptor 25 | import org.dotlin.compiler.backend.descriptors.dartElementAs 26 | import org.dotlin.compiler.dart.element.DartDeclarationElement 27 | import org.dotlin.compiler.dart.element.DartElement 28 | import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI 29 | import org.jetbrains.kotlin.ir.declarations.IrDeclaration 30 | 31 | val IrDeclaration.isDartDeclaration 32 | get() = descriptor is DartDescriptor 33 | 34 | val IrDeclaration.dartElement: DartDeclarationElement? 35 | get() = descriptor.dartElementAs() 36 | 37 | fun IrDeclaration.dartElementAs(): E? = descriptor.dartElementAs() -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/DartIfStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.DartExpression 24 | 25 | data class DartIfStatement( 26 | val condition: DartExpression, 27 | val thenStatement: DartStatement, 28 | val elseStatement: DartStatement? = null 29 | ) : DartStatement { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitIfStatement(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | condition.accept(visitor, data) 35 | thenStatement.accept(visitor, data) 36 | elseStatement?.accept(visitor, data) 37 | } 38 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/type/DartTypeArgumentList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.type 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | 26 | data class DartTypeArgumentList( 27 | private val arguments: List = listOf(), 28 | ) : DartAstNode, List by arguments { 29 | constructor(vararg arguments: DartTypeAnnotation) : this(arguments.toList()) 30 | 31 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 32 | visitor.visitTypeArgumentList(this, data) 33 | 34 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 35 | arguments.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartPropertyAccessExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 24 | 25 | data class DartPropertyAccessExpression( 26 | val target: DartExpression, 27 | val propertyName: DartSimpleIdentifier, 28 | override val isNullAware: Boolean, 29 | ) : DartPossiblyNullAwareExpression { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitPropertyAccess(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | target.accept(visitor, data) 35 | propertyName.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/src2ir/analyze/suppress/SpecialInheritanceSuppressor.kt: -------------------------------------------------------------------------------- 1 | package org.dotlin.compiler.backend.steps.src2ir.analyze.suppress 2 | 3 | import org.dotlin.compiler.backend.util.isImplicitInterfaceConstructorCall 4 | import org.dotlin.compiler.backend.util.isSpecialInheritanceConstructorCall 5 | import org.jetbrains.kotlin.diagnostics.Diagnostic 6 | import org.jetbrains.kotlin.diagnostics.Errors 7 | import org.jetbrains.kotlin.resolve.BindingTraceContext 8 | 9 | class SpecialInheritanceSuppressor( 10 | private val trace: BindingTraceContext, 11 | ) : SubSuppressor { 12 | override fun Diagnostic.isSuppressed() = 13 | isManySuperTypesError() || isInterfaceWithSuperClassError() || isInterfacesCannotInitializeSuperTypesError() 14 | 15 | private fun Diagnostic.isManySuperTypesError(): Boolean { 16 | if (factory != Errors.MANY_CLASSES_IN_SUPERTYPE_LIST) return false 17 | 18 | return psiElement.isSpecialInheritanceConstructorCall(trace.bindingContext) 19 | } 20 | 21 | private fun Diagnostic.isInterfaceWithSuperClassError(): Boolean { 22 | if (factory != Errors.INTERFACE_WITH_SUPERCLASS) return false 23 | 24 | return psiElement.isImplicitInterfaceConstructorCall(trace.bindingContext) 25 | } 26 | 27 | private fun Diagnostic.isInterfacesCannotInitializeSuperTypesError(): Boolean { 28 | if (factory != Errors.SUPERTYPE_INITIALIZED_IN_INTERFACE) return false 29 | 30 | return psiElement.parent?.children?.get(0)?.children?.get(0) 31 | ?.isImplicitInterfaceConstructorCall(trace.bindingContext) == true 32 | } 33 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/ir2ast/lower/lowerings/SingleExpressionBlocksLowering.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.ir2ast.lower.lowerings 21 | 22 | import org.dotlin.compiler.backend.steps.ir2ast.lower.* 23 | import org.jetbrains.kotlin.ir.expressions.IrBlock 24 | import org.jetbrains.kotlin.ir.expressions.IrExpression 25 | 26 | 27 | @Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") 28 | class SingleExpressionBlocksLowering(override val context: DotlinLoweringContext) : IrExpressionLowering { 29 | override fun DotlinLoweringContext.transform(expression: IrExpression): Transformation? { 30 | if (expression !is IrBlock || expression.statements.singleOrNull() !is IrExpression) return noChange() 31 | 32 | return replaceWith(expression.statements.single() as IrExpression) 33 | } 34 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/type/parameter/DartTypeParameterList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.type.parameter 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | 26 | class DartTypeParameterList( 27 | private val parameters: List = mutableListOf(), 28 | ) : DartAstNode, List by parameters { 29 | constructor(vararg parameters: DartTypeParameter) : this(parameters.toList()) 30 | 31 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 32 | visitor.visitTypeParameterList(this, data) 33 | 34 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 35 | parameters.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/descriptors/DartDescriptor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.descriptors 21 | 22 | import org.dotlin.compiler.backend.DartPackage 23 | import org.dotlin.compiler.backend.steps.src2ir.DartElementLocator 24 | import org.dotlin.compiler.dart.element.DartElement 25 | import org.jetbrains.kotlin.descriptors.ModuleDescriptor 26 | import org.jetbrains.kotlin.storage.StorageManager 27 | 28 | interface DartDescriptor { 29 | val element: DartElement 30 | val context: DartDescriptorContext 31 | 32 | val module: ModuleDescriptor 33 | get() = context.module 34 | 35 | val pkg: DartPackage 36 | get() = context.pkg 37 | 38 | val elementLocator: DartElementLocator 39 | get() = context.elementLocator 40 | 41 | val storageManager: StorageManager 42 | get() = context.storageManager 43 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/type/parameter/DartTypeParameter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.type.parameter 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 25 | import org.dotlin.compiler.dart.ast.type.DartTypeAnnotation 26 | 27 | data class DartTypeParameter( 28 | val name: DartSimpleIdentifier, 29 | val bound: DartTypeAnnotation? = null 30 | ) : DartAstNode { 31 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 32 | visitor.visitTypeParameter(this, data) 33 | 34 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 35 | name.accept(visitor, data) 36 | bound?.accept(visitor, data) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/cli/command/Compile.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.cli.command 21 | 22 | import com.github.ajalt.clikt.core.CliktCommand 23 | import com.github.ajalt.clikt.parameters.options.flag 24 | import com.github.ajalt.clikt.parameters.options.help 25 | import com.github.ajalt.clikt.parameters.options.option 26 | import org.dotlin.compiler.KotlinToDartCompiler 27 | import kotlin.io.path.Path 28 | 29 | class Compile : CliktCommand(name = "dotlin") { 30 | private val format: Boolean by option() 31 | .help("Whether to format the output Dart code using dart format") 32 | .flag("--no-format", default = false) 33 | 34 | override fun run() { 35 | // TODO: Support compiling non-project Dart files and STDIN 36 | 37 | KotlinToDartCompiler.compile( 38 | Path(""), 39 | format, 40 | ) 41 | } 42 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/compilationunit/DartCompilationUnit.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.compilationunit 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNode 23 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 24 | import org.dotlin.compiler.dart.ast.accept 25 | import org.dotlin.compiler.dart.ast.directive.DartDirective 26 | 27 | data class DartCompilationUnit( 28 | val directives: List = listOf(), 29 | val declarations: List = listOf() 30 | ) : DartAstNode { 31 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 32 | visitor.visitCompilationUnit(this, data) 33 | 34 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 35 | directives.accept(visitor, data) 36 | declarations.accept(visitor, data) 37 | } 38 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/internal/InternalAnnotations.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.internal 19 | 20 | /** 21 | * Specifies that the corresponding type parameter is not used for unsafe operations such as casts or 'is' checks 22 | * That means it's completely safe to use generic types as argument for such parameter. 23 | */ 24 | @Target(AnnotationTarget.TYPE_PARAMETER) 25 | @Retention(AnnotationRetention.SOURCE) 26 | internal annotation class PureReifiable 27 | 28 | /** 29 | * Specifies that the corresponding built-in method exists depending on platform. 30 | * Current implementation for JVM looks whether method with same JVM descriptor exists in the module JDK. 31 | * For example MutableMap.remove(K, V) available only if corresponding 32 | * method 'java/util/Map.remove(Ljava/lang/Object;Ljava/lang/Object;)Z' is defined in JDK (i.e. for major versions >= 8) 33 | */ 34 | @Target(AnnotationTarget.FUNCTION) 35 | @Retention(AnnotationRetention.SOURCE) 36 | internal annotation class PlatformDependent 37 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/type/DartNamedType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.type 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.identifier.DartIdentifier 24 | 25 | data class DartNamedType( 26 | val name: DartIdentifier, 27 | val typeArguments: DartTypeArgumentList = DartTypeArgumentList(), 28 | override val isNullable: Boolean = false, 29 | val isDeferred: Boolean = false, 30 | ) : DartTypeAnnotation { 31 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = visitor.visitNamedType(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | name.accept(visitor, data) 35 | typeArguments.accept(visitor, data) 36 | } 37 | } 38 | 39 | fun DartNamedType.toNullable() = copy(isNullable = true) -------------------------------------------------------------------------------- /compiler/build.gradle.kts: -------------------------------------------------------------------------------- 1 | 2 | import org.gradle.api.JavaVersion.VERSION_17 3 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 4 | 5 | plugins { 6 | kotlin("jvm") version "1.7.21" 7 | kotlin("plugin.serialization") version "1.7.21" 8 | application 9 | } 10 | 11 | group = "org.dotlin.compiler" 12 | version = "0.0.1" 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | 18 | sourceSets.main { 19 | java.srcDirs("src/main/kotlin") 20 | } 21 | 22 | dependencies { 23 | testImplementation(kotlin("test-junit5")) 24 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0") 25 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0") 26 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") 27 | implementation("org.jetbrains.kotlin:kotlin-compiler:1.7.21") 28 | implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") 29 | implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.4.1") 30 | implementation("io.ktor:ktor-client-core:2.2.1") 31 | implementation("io.ktor:ktor-client-cio:2.2.1") 32 | implementation("com.charleskorn.kaml:kaml:0.49.0") 33 | implementation("com.github.ajalt.clikt:clikt:3.5.0") 34 | } 35 | 36 | tasks.test { 37 | useJUnitPlatform() 38 | } 39 | 40 | java { 41 | sourceCompatibility = VERSION_17 42 | targetCompatibility = VERSION_17 43 | } 44 | 45 | tasks.withType { 46 | kotlinOptions { 47 | jvmTarget = "17" 48 | freeCompilerArgs = listOf("-Xinline-classes", "-Xcontext-receivers") 49 | } 50 | } 51 | 52 | application { 53 | mainClass.set("org.dotlin.compiler.Dotlin") 54 | applicationName = "dotlin" 55 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/declaration/DartVariableDeclarationStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement.declaration 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.declaration.variable.DartVariableDeclarationList 24 | import org.dotlin.compiler.dart.ast.statement.DartStatement 25 | 26 | data class DartVariableDeclarationStatement( 27 | val variables: DartVariableDeclarationList, 28 | ) : DartStatement { 29 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 30 | visitor.visitVariableDeclarationStatement(this, data) 31 | 32 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 33 | variables.accept(visitor, data) 34 | } 35 | } 36 | 37 | fun DartVariableDeclarationList.asStatement() = DartVariableDeclarationStatement(this) -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/reflect/KVariance.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2019 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.reflect 19 | 20 | /** 21 | * Represents variance applied to a type parameter on the declaration site (*declaration-site variance*), 22 | * or to a type in a projection (*use-site variance*). 23 | * 24 | * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#variance) 25 | * for more information. 26 | * 27 | * @see [KTypeParameter.variance] 28 | * @see [KTypeProjection] 29 | */ 30 | @SinceKotlin("1.1") 31 | enum class KVariance { 32 | /** 33 | * The affected type parameter or type is *invariant*, which means it has no variance applied to it. 34 | */ 35 | INVARIANT, 36 | 37 | /** 38 | * The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code. 39 | */ 40 | IN, 41 | 42 | /** 43 | * The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code. 44 | */ 45 | OUT, 46 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/ir2ast/lower/lowerings/NestedClassLowering.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.ir2ast.lower.lowerings 21 | 22 | import org.dotlin.compiler.backend.steps.ir2ast.lower.* 23 | import org.jetbrains.kotlin.ir.declarations.IrClass 24 | import org.jetbrains.kotlin.ir.declarations.IrDeclaration 25 | import org.jetbrains.kotlin.ir.util.file 26 | 27 | class NestedClassLowering(override val context: DotlinLoweringContext) : IrDeclarationLowering { 28 | override fun DotlinLoweringContext.transform(declaration: IrDeclaration): Transformations { 29 | if (declaration !is IrClass || declaration.parent !is IrClass || declaration.isInner) return noChange() 30 | 31 | // We don't use addChild on purpose: We want to keep parent information. 32 | declaration.file.declarations.add(declaration) 33 | 34 | return just { remove() } 35 | } 36 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartAssignmentExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | 24 | 25 | data class DartAssignmentExpression( 26 | val left: DartExpression, 27 | val operator: DartAssignmentOperator = DartAssignmentOperator.ASSIGN, 28 | val right: DartExpression, 29 | ) : DartExpression { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C) = 31 | visitor.visitAssignmentExpression(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | left.accept(visitor, data) 35 | right.accept(visitor, data) 36 | } 37 | } 38 | 39 | enum class DartAssignmentOperator { 40 | ASSIGN, 41 | NULL_SHORTED, 42 | ADD, 43 | SUBTRACT, 44 | MULTIPLY, 45 | DIVIDE, 46 | INTEGER_DIVIDE 47 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/declaration/classlike/member/constructor/DartConstructorFieldInitializer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.declaration.classlike.member.constructor 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.DartExpression 24 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 25 | 26 | data class DartConstructorFieldInitializer( 27 | val fieldName: DartSimpleIdentifier, 28 | val expression: DartExpression, 29 | ) : DartConstructorInitializer { 30 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 31 | visitor.visitConstructorFieldInitializer(this, data) 32 | 33 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 34 | fieldName.accept(visitor, data) 35 | expression.accept(visitor, data) 36 | } 37 | } -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/native/String.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin 19 | 20 | /** 21 | * The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are 22 | * implemented as instances of this class. 23 | */ 24 | @DartLibrary("dart:core") 25 | external class String : Comparable { 26 | companion object 27 | 28 | /** 29 | * Returns a string obtained by concatenating this string with the string representation of the given [other] object. 30 | */ 31 | operator fun plus(other: Any?): String 32 | 33 | val length: Int 34 | 35 | /** 36 | * Returns the character of this string at the specified [index]. 37 | * 38 | * If the [index] is out of bounds of this string, throws an [IndexOutOfBoundsException] except in Kotlin/JS 39 | * where the behavior is unspecified. 40 | */ 41 | fun get(index: Int): String 42 | 43 | fun subSequence(startIndex: Int, endIndex: Int): String 44 | 45 | override fun compareTo(other: String): Int 46 | } 47 | -------------------------------------------------------------------------------- /packages/dotlin/lib/src/kotlin/ranges/Range.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2019 JetBrains s.r.o. 3 | * Copyright 2021-2022 Wilko Manger 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package kotlin.ranges 19 | 20 | /** 21 | * Represents a range of values (for example, numbers or characters). 22 | * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/ranges.html) for more information. 23 | */ 24 | interface ClosedRange> { 25 | /** 26 | * The minimum value in the range. 27 | */ 28 | val start: T 29 | 30 | /** 31 | * The maximum value in the range (inclusive). 32 | */ 33 | val endInclusive: T 34 | 35 | /** 36 | * Checks whether the specified [value] belongs to the range. 37 | */ 38 | @DartName("has") // We change the name in Dart to prevent a clash in IntProgression. 39 | operator fun contains(value: T): Boolean = value >= start && value <= endInclusive 40 | 41 | /** 42 | * Checks whether the range is empty. 43 | * 44 | * The range is empty if its start value is greater than the end value. 45 | */ 46 | fun isEmpty(): Boolean = start > endInclusive 47 | } 48 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/statement/trycatch/DartTryStatement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.statement.trycatch 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.accept 24 | import org.dotlin.compiler.dart.ast.statement.DartBlock 25 | import org.dotlin.compiler.dart.ast.statement.DartStatement 26 | 27 | data class DartTryStatement( 28 | val body: DartBlock, 29 | val catchClauses: List = emptyList(), 30 | val finallyBlock: DartBlock? = null 31 | ) : DartStatement { 32 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 33 | visitor.visitTryStatement(this, data) 34 | 35 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 36 | body.accept(visitor, data) 37 | catchClauses.accept(visitor, data) 38 | finallyBlock?.accept(visitor, data) 39 | } 40 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/bin/Dart.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | @file:Suppress("ClassName") 21 | 22 | package org.dotlin.compiler.backend.bin 23 | 24 | import org.dotlin.compiler.backend.util.runCommand 25 | import java.nio.file.Path 26 | import kotlin.io.path.absolutePathString 27 | 28 | object dart { 29 | object pub { 30 | suspend fun get(workingDirectory: Path? = null) = 31 | runCommand("dart", "pub", "get", workingDirectory = workingDirectory) 32 | } 33 | 34 | suspend fun run(executable: String, vararg args: String, workingDirectory: Path? = null) = runCommand( 35 | "dart", "run", executable, *args, 36 | workingDirectory = workingDirectory 37 | ) 38 | 39 | suspend fun analyze(workingDirectory: Path? = null) = 40 | runCommand("dart", "analyze", workingDirectory = workingDirectory) 41 | 42 | suspend fun format(projectPath: Path) = runCommand("dart", "format", projectPath.absolutePathString()) 43 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/steps/ast2dart/transformer/DartMiscTransformer.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.steps.ast2dart.transformer 21 | 22 | import org.dotlin.compiler.backend.steps.ast2dart.DartGenerationContext 23 | import org.dotlin.compiler.dart.ast.DartLabel 24 | import org.dotlin.compiler.dart.ast.annotation.DartAnnotation 25 | 26 | object DartMiscTransformer : DartAstNodeTransformer() { 27 | override fun DartGenerationContext.visitLabel(label: DartLabel) = "${label.acceptChild { value }}: " 28 | 29 | override fun DartGenerationContext.visitAnnotation(annotation: DartAnnotation) = annotation.run { 30 | val name = acceptChild { name } 31 | val constructorName = acceptChild(prefix = ".") { constructorName } 32 | val typeArguments = acceptChild { typeArguments } 33 | val arguments = acceptChild { arguments } 34 | 35 | "@$name$constructorName$typeArguments$arguments" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/backend/util/ObjectUtils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.backend.util 21 | 22 | import org.dotlin.compiler.backend.steps.ir2ast.ir.isDartStatic 23 | import org.dotlin.compiler.backend.steps.ir2ast.ir.isFakeOverride 24 | import org.dotlin.compiler.backend.steps.ir2ast.ir.isStatic 25 | import org.jetbrains.kotlin.ir.declarations.* 26 | import org.jetbrains.kotlin.ir.util.isMethodOfAny 27 | import org.jetbrains.kotlin.ir.util.isObject 28 | import org.jetbrains.kotlin.ir.util.parentClassOrNull 29 | 30 | val IrDeclaration.hasObjectParentAndStaticCounterpart 31 | get() = (this is IrProperty || (this is IrField && !isStatic) || (this is IrSimpleFunction && !isStatic)) && 32 | this !is IrConstructor && 33 | !isFakeOverride() && 34 | origin != IrDeclarationOrigin.FIELD_FOR_OBJECT_INSTANCE && 35 | parentClassOrNull?.isObject == true && 36 | !isDartStatic && 37 | !(this is IrSimpleFunction && isMethodOfAny()) -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/invocation/DartInvocationExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression.invocation 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.DartArgumentList 24 | import org.dotlin.compiler.dart.ast.expression.DartExpression 25 | import org.dotlin.compiler.dart.ast.type.DartTypeArgumentList 26 | 27 | interface DartInvocationExpression : DartExpression { 28 | val function: DartExpression 29 | val arguments: DartArgumentList 30 | val typeArguments: DartTypeArgumentList 31 | 32 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 33 | visitor.visitInvocationExpression(this, data) 34 | 35 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 36 | function.accept(visitor, data) 37 | arguments.accept(visitor, data) 38 | typeArguments.accept(visitor, data) 39 | } 40 | } -------------------------------------------------------------------------------- /compiler/src/main/kotlin/org/dotlin/compiler/dart/ast/expression/DartInstanceCreationExpression.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-2022 Wilko Manger 3 | * 4 | * This file is part of Dotlin. 5 | * 6 | * Dotlin is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Dotlin is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with Dotlin. If not, see . 18 | */ 19 | 20 | package org.dotlin.compiler.dart.ast.expression 21 | 22 | import org.dotlin.compiler.dart.ast.DartAstNodeVisitor 23 | import org.dotlin.compiler.dart.ast.expression.identifier.DartSimpleIdentifier 24 | import org.dotlin.compiler.dart.ast.type.DartNamedType 25 | 26 | data class DartInstanceCreationExpression( 27 | val type: DartNamedType, 28 | val isConst: Boolean = false, 29 | val constructorName: DartSimpleIdentifier? = null, 30 | val arguments: DartArgumentList = DartArgumentList(), 31 | ) : DartExpression { 32 | override fun accept(visitor: DartAstNodeVisitor, data: C): R = 33 | visitor.visitInstanceCreationExpression(this, data) 34 | 35 | override fun acceptChildren(visitor: DartAstNodeVisitor, data: D) { 36 | type.accept(visitor, data) 37 | constructorName?.accept(visitor, data) 38 | arguments.accept(visitor, data) 39 | } 40 | } --------------------------------------------------------------------------------