From 8a61ff432543a29234193cd1f7c14abd3f3d31a0 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Wed, 2 Nov 2016 11:08:28 +0100 Subject: Move compiler and compiler tests to compiler dir --- .../tools/backend/jvm/CollectEntryPoints.scala | 125 + .../tools/backend/jvm/CollectSuperCalls.scala | 42 + .../tools/backend/jvm/DottyBackendInterface.scala | 1102 ++++++ .../src/dotty/tools/backend/jvm/GenBCode.scala | 433 +++ .../src/dotty/tools/backend/jvm/LabelDefs.scala | 223 ++ .../dotty/tools/backend/jvm/scalaPrimitives.scala | 417 +++ compiler/src/dotty/tools/dotc/Bench.scala | 46 + .../src/dotty/tools/dotc/CompilationUnit.scala | 24 + compiler/src/dotty/tools/dotc/Compiler.scala | 145 + compiler/src/dotty/tools/dotc/Driver.scala | 134 + compiler/src/dotty/tools/dotc/FromTasty.scala | 107 + compiler/src/dotty/tools/dotc/Main.scala | 9 + compiler/src/dotty/tools/dotc/Resident.scala | 58 + compiler/src/dotty/tools/dotc/Run.scala | 138 + .../dotty/tools/dotc/ast/CheckTrees.scala.disabled | 258 ++ compiler/src/dotty/tools/dotc/ast/Desugar.scala | 1089 ++++++ .../src/dotty/tools/dotc/ast/NavigateAST.scala | 82 + .../tools/dotc/ast/PluggableTransformers.scala | 105 + compiler/src/dotty/tools/dotc/ast/Positioned.scala | 213 ++ compiler/src/dotty/tools/dotc/ast/TreeInfo.scala | 733 ++++ .../src/dotty/tools/dotc/ast/TreeTypeMap.scala | 187 + compiler/src/dotty/tools/dotc/ast/Trees.scala | 1295 +++++++ compiler/src/dotty/tools/dotc/ast/tpd.scala | 952 +++++ compiler/src/dotty/tools/dotc/ast/untpd.scala | 562 +++ .../dotty/tools/dotc/config/CompilerCommand.scala | 128 + compiler/src/dotty/tools/dotc/config/Config.scala | 138 + .../src/dotty/tools/dotc/config/JavaPlatform.scala | 70 + .../src/dotty/tools/dotc/config/OutputDirs.scala | 116 + .../src/dotty/tools/dotc/config/PathResolver.scala | 281 ++ .../src/dotty/tools/dotc/config/Platform.scala | 39 + .../src/dotty/tools/dotc/config/Printers.scala | 34 + .../src/dotty/tools/dotc/config/Properties.scala | 165 + .../dotty/tools/dotc/config/ScalaSettings.scala | 267 ++ .../src/dotty/tools/dotc/config/ScalaVersion.scala | 184 + .../src/dotty/tools/dotc/config/Settings.scala | 270 ++ .../tools/dotc/config/WrappedProperties.scala | 34 + .../src/dotty/tools/dotc/core/Annotations.scala | 162 + .../dotty/tools/dotc/core/CheckRealizable.scala | 132 + compiler/src/dotty/tools/dotc/core/Comments.scala | 459 +++ compiler/src/dotty/tools/dotc/core/Constants.scala | 235 ++ .../src/dotty/tools/dotc/core/Constraint.scala | 154 + .../dotty/tools/dotc/core/ConstraintHandling.scala | 458 +++ .../dotty/tools/dotc/core/ConstraintRunInfo.scala | 17 + compiler/src/dotty/tools/dotc/core/Contexts.scala | 709 ++++ .../src/dotty/tools/dotc/core/Decorators.scala | 185 + .../src/dotty/tools/dotc/core/Definitions.scala | 807 ++++ .../dotty/tools/dotc/core/DenotTransformers.scala | 78 + .../src/dotty/tools/dotc/core/Denotations.scala | 1217 ++++++ compiler/src/dotty/tools/dotc/core/Flags.scala | 640 ++++ compiler/src/dotty/tools/dotc/core/Hashable.scala | 103 + compiler/src/dotty/tools/dotc/core/Mode.scala | 89 + compiler/src/dotty/tools/dotc/core/NameOps.scala | 432 +++ compiler/src/dotty/tools/dotc/core/Names.scala | 372 ++ .../dotty/tools/dotc/core/OrderingConstraint.scala | 636 ++++ compiler/src/dotty/tools/dotc/core/Periods.scala | 159 + compiler/src/dotty/tools/dotc/core/Phases.scala | 377 ++ compiler/src/dotty/tools/dotc/core/Scopes.scala | 437 +++ compiler/src/dotty/tools/dotc/core/Signature.scala | 103 + compiler/src/dotty/tools/dotc/core/StdNames.scala | 844 +++++ .../src/dotty/tools/dotc/core/Substituters.scala | 306 ++ .../src/dotty/tools/dotc/core/SymDenotations.scala | 2004 ++++++++++ .../src/dotty/tools/dotc/core/SymbolLoaders.scala | 267 ++ compiler/src/dotty/tools/dotc/core/Symbols.scala | 602 +++ .../dotty/tools/dotc/core/TypeApplications.scala | 688 ++++ .../src/dotty/tools/dotc/core/TypeComparer.scala | 1502 ++++++++ .../src/dotty/tools/dotc/core/TypeErasure.scala | 514 +++ compiler/src/dotty/tools/dotc/core/TypeOps.scala | 554 +++ .../src/dotty/tools/dotc/core/TypeParamInfo.scala | 40 + .../src/dotty/tools/dotc/core/TyperState.scala | 210 ++ compiler/src/dotty/tools/dotc/core/Types.overflow | 66 + compiler/src/dotty/tools/dotc/core/Types.scala | 3865 ++++++++++++++++++++ compiler/src/dotty/tools/dotc/core/Uniques.scala | 128 + .../dotc/core/classfile/AbstractFileReader.scala | 88 + .../tools/dotc/core/classfile/ByteCodecs.scala | 221 ++ .../dotc/core/classfile/ClassfileConstants.scala | 378 ++ .../dotc/core/classfile/ClassfileParser.scala | 1100 ++++++ .../tools/dotc/core/tasty/DottyUnpickler.scala | 53 + .../dotty/tools/dotc/core/tasty/NameBuffer.scala | 101 + .../tools/dotc/core/tasty/PositionPickler.scala | 79 + .../tools/dotc/core/tasty/PositionUnpickler.scala | 39 + .../dotty/tools/dotc/core/tasty/TastyBuffer.scala | 188 + .../dotty/tools/dotc/core/tasty/TastyFormat.scala | 553 +++ .../dotty/tools/dotc/core/tasty/TastyName.scala | 30 + .../dotty/tools/dotc/core/tasty/TastyPickler.scala | 71 + .../dotty/tools/dotc/core/tasty/TastyPrinter.scala | 122 + .../dotty/tools/dotc/core/tasty/TastyReader.scala | 141 + .../tools/dotc/core/tasty/TastyUnpickler.scala | 95 + .../dotty/tools/dotc/core/tasty/TreeBuffer.scala | 188 + .../dotty/tools/dotc/core/tasty/TreePickler.scala | 641 ++++ .../tools/dotc/core/tasty/TreeUnpickler.scala | 1161 ++++++ .../dotc/core/unpickleScala2/PickleBuffer.scala | 299 ++ .../dotc/core/unpickleScala2/Scala2Unpickler.scala | 1260 +++++++ .../dotty/tools/dotc/parsing/CharArrayReader.scala | 132 + .../src/dotty/tools/dotc/parsing/JavaParsers.scala | 898 +++++ .../dotty/tools/dotc/parsing/JavaScanners.scala | 538 +++ .../src/dotty/tools/dotc/parsing/JavaTokens.scala | 92 + .../tools/dotc/parsing/MarkupParserCommon.scala | 257 ++ .../dotty/tools/dotc/parsing/MarkupParsers.scala | 466 +++ .../src/dotty/tools/dotc/parsing/Parsers.scala | 2309 ++++++++++++ .../src/dotty/tools/dotc/parsing/Scanners.scala | 1014 +++++ .../dotty/tools/dotc/parsing/ScriptParsers.scala | 145 + .../tools/dotc/parsing/SymbolicXMLBuilder.scala | 264 ++ compiler/src/dotty/tools/dotc/parsing/Tokens.scala | 238 ++ .../tools/dotc/parsing/TreeBuilder.scala.unused | 535 +++ .../src/dotty/tools/dotc/parsing/Utility.scala | 170 + .../src/dotty/tools/dotc/parsing/package.scala | 33 + .../src/dotty/tools/dotc/printing/Formatting.scala | 258 ++ .../dotty/tools/dotc/printing/Highlighting.scala | 77 + .../dotty/tools/dotc/printing/PlainPrinter.scala | 500 +++ .../src/dotty/tools/dotc/printing/Printer.scala | 105 + .../src/dotty/tools/dotc/printing/Printers.scala | 14 + .../dotty/tools/dotc/printing/RefinedPrinter.scala | 652 ++++ .../src/dotty/tools/dotc/printing/Showable.scala | 34 + .../tools/dotc/printing/SyntaxHighlighting.scala | 304 ++ compiler/src/dotty/tools/dotc/printing/Texts.scala | 168 + .../src/dotty/tools/dotc/printing/package.scala | 17 + .../tools/dotc/repl/AbstractFileClassLoader.scala | 31 + .../src/dotty/tools/dotc/repl/AmmoniteReader.scala | 82 + .../tools/dotc/repl/CompilingInterpreter.scala | 966 +++++ .../src/dotty/tools/dotc/repl/ConsoleWriter.scala | 21 + .../dotty/tools/dotc/repl/InteractiveReader.scala | 20 + .../src/dotty/tools/dotc/repl/Interpreter.scala | 45 + .../dotty/tools/dotc/repl/InterpreterLoop.scala | 210 ++ compiler/src/dotty/tools/dotc/repl/Main.scala | 28 + .../src/dotty/tools/dotc/repl/ManifestInfo.scala | 20 + .../dotty/tools/dotc/repl/NewLinePrintWriter.scala | 11 + compiler/src/dotty/tools/dotc/repl/REPL.scala | 100 + .../src/dotty/tools/dotc/repl/SimpleReader.scala | 24 + .../src/dotty/tools/dotc/repl/ammonite/Ansi.scala | 256 ++ .../dotty/tools/dotc/repl/ammonite/Filter.scala | 61 + .../tools/dotc/repl/ammonite/FilterTools.scala | 80 + .../src/dotty/tools/dotc/repl/ammonite/LICENSE | 25 + .../dotty/tools/dotc/repl/ammonite/Protocol.scala | 30 + .../tools/dotc/repl/ammonite/SpecialKeys.scala | 81 + .../dotty/tools/dotc/repl/ammonite/Terminal.scala | 320 ++ .../src/dotty/tools/dotc/repl/ammonite/Utils.scala | 169 + .../dotc/repl/ammonite/filters/BasicFilters.scala | 163 + .../repl/ammonite/filters/GUILikeFilters.scala | 170 + .../dotc/repl/ammonite/filters/HistoryFilter.scala | 334 ++ .../repl/ammonite/filters/ReadlineFilters.scala | 165 + .../dotc/repl/ammonite/filters/UndoFilter.scala | 157 + .../tools/dotc/reporting/ConsoleReporter.scala | 63 + .../dotc/reporting/HideNonSensicalMessages.scala | 21 + .../tools/dotc/reporting/MessageRendering.scala | 145 + .../src/dotty/tools/dotc/reporting/Reporter.scala | 296 ++ .../dotty/tools/dotc/reporting/StoreReporter.scala | 46 + .../tools/dotc/reporting/ThrowingReporter.scala | 20 + .../dotc/reporting/UniqueMessagePositions.scala | 32 + .../tools/dotc/reporting/diagnostic/Message.scala | 133 + .../reporting/diagnostic/MessageContainer.scala | 74 + .../tools/dotc/reporting/diagnostic/messages.scala | 902 +++++ .../src/dotty/tools/dotc/rewrite/Rewrites.scala | 92 + compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala | 518 +++ .../dotty/tools/dotc/sbt/ExtractDependencies.scala | 268 ++ compiler/src/dotty/tools/dotc/sbt/ShowAPI.scala | 156 + .../src/dotty/tools/dotc/sbt/ThunkHolder.scala | 61 + .../tools/dotc/transform/ArrayConstructors.scala | 59 + .../tools/dotc/transform/AugmentScala2Traits.scala | 101 + .../dotty/tools/dotc/transform/CapturedVars.scala | 149 + .../tools/dotc/transform/CheckReentrant.scala | 95 + .../dotty/tools/dotc/transform/CheckStatic.scala | 96 + .../src/dotty/tools/dotc/transform/ClassOf.scala | 30 + .../tools/dotc/transform/CollectEntryPoints.scala | 116 + .../dotty/tools/dotc/transform/Constructors.scala | 261 ++ .../dotty/tools/dotc/transform/CrossCastAnd.scala | 30 + .../src/dotty/tools/dotc/transform/CtxLazy.scala | 23 + .../transform/DropEmptyCompanions.scala.disabled | 98 + .../dotty/tools/dotc/transform/DropInlined.scala | 15 + .../dotty/tools/dotc/transform/ElimByName.scala | 129 + .../tools/dotc/transform/ElimErasedValueType.scala | 84 + .../dotty/tools/dotc/transform/ElimRepeated.scala | 135 + .../tools/dotc/transform/ElimStaticThis.scala | 40 + .../src/dotty/tools/dotc/transform/Erasure.scala | 664 ++++ .../dotty/tools/dotc/transform/ExpandPrivate.scala | 111 + .../dotty/tools/dotc/transform/ExpandSAMs.scala | 86 + .../dotty/tools/dotc/transform/ExplicitOuter.scala | 362 ++ .../dotty/tools/dotc/transform/ExplicitSelf.scala | 47 + .../tools/dotc/transform/ExtensionMethods.scala | 243 ++ .../tools/dotc/transform/FirstTransform.scala | 193 + .../src/dotty/tools/dotc/transform/Flatten.scala | 47 + .../dotc/transform/FullParameterization.scala | 263 ++ .../dotc/transform/FunctionalInterfaces.scala | 83 + .../src/dotty/tools/dotc/transform/GetClass.scala | 34 + .../src/dotty/tools/dotc/transform/Getters.scala | 76 + .../tools/dotc/transform/InterceptedMethods.scala | 131 + .../dotc/transform/IsInstanceOfEvaluator.scala | 168 + .../dotty/tools/dotc/transform/LambdaLift.scala | 548 +++ .../src/dotty/tools/dotc/transform/LazyVals.scala | 418 +++ .../src/dotty/tools/dotc/transform/LiftTry.scala | 66 + .../dotc/transform/LinkScala2ImplClasses.scala | 62 + .../tools/dotc/transform/Literalize.scala.disabled | 95 + .../tools/dotc/transform/MacroTransform.scala | 70 + .../src/dotty/tools/dotc/transform/Memoize.scala | 129 + .../src/dotty/tools/dotc/transform/Mixin.scala | 257 ++ .../src/dotty/tools/dotc/transform/MixinOps.scala | 68 + .../dotty/tools/dotc/transform/MoveStatics.scala | 77 + .../tools/dotc/transform/NonLocalReturns.scala | 92 + .../tools/dotc/transform/NormalizeFlags.scala | 25 + .../tools/dotc/transform/OverridingPairs.scala | 140 + .../tools/dotc/transform/ParamForwarding.scala | 94 + .../tools/dotc/transform/PatternMatcher.scala | 1989 ++++++++++ .../src/dotty/tools/dotc/transform/Pickler.scala | 108 + .../src/dotty/tools/dotc/transform/PostTyper.scala | 286 ++ .../dotc/transform/PrivateToStatic.scala.disabled | 94 + .../dotty/tools/dotc/transform/ResolveSuper.scala | 115 + .../dotty/tools/dotc/transform/RestoreScopes.scala | 67 + .../dotty/tools/dotc/transform/SelectStatic.scala | 56 + .../dotty/tools/dotc/transform/SeqLiterals.scala | 48 + .../src/dotty/tools/dotc/transform/Splitter.scala | 121 + .../tools/dotc/transform/SuperAccessors.scala | 424 +++ .../src/dotty/tools/dotc/transform/SymUtils.scala | 117 + .../tools/dotc/transform/SyntheticMethods.scala | 198 + .../src/dotty/tools/dotc/transform/TailRec.scala | 384 ++ .../dotty/tools/dotc/transform/TreeChecker.scala | 452 +++ .../tools/dotc/transform/TreeExtractors.scala | 48 + .../src/dotty/tools/dotc/transform/TreeGen.scala | 26 + .../dotty/tools/dotc/transform/TreeTransform.scala | 1221 +++++++ .../tools/dotc/transform/TryCatchPatterns.scala | 99 + .../tools/dotc/transform/TypeTestsCasts.scala | 124 + .../src/dotty/tools/dotc/transform/TypeUtils.scala | 34 + .../tools/dotc/transform/VCElideAllocations.scala | 41 + .../tools/dotc/transform/VCInlineMethods.scala | 104 + .../dotty/tools/dotc/transform/ValueClasses.scala | 56 + .../dotty/tools/dotc/transform/patmat/Space.scala | 615 ++++ .../src/dotty/tools/dotc/typer/Applications.scala | 1351 +++++++ compiler/src/dotty/tools/dotc/typer/Checking.scala | 557 +++ .../src/dotty/tools/dotc/typer/ConstFold.scala | 182 + .../src/dotty/tools/dotc/typer/Docstrings.scala | 56 + compiler/src/dotty/tools/dotc/typer/Dynamic.scala | 104 + .../dotty/tools/dotc/typer/ErrorReporting.scala | 153 + .../src/dotty/tools/dotc/typer/EtaExpansion.scala | 191 + compiler/src/dotty/tools/dotc/typer/FrontEnd.scala | 83 + .../src/dotty/tools/dotc/typer/Implicits.scala | 844 +++++ .../src/dotty/tools/dotc/typer/ImportInfo.scala | 117 + .../src/dotty/tools/dotc/typer/Inferencing.scala | 362 ++ compiler/src/dotty/tools/dotc/typer/Inliner.scala | 539 +++ compiler/src/dotty/tools/dotc/typer/Namer.scala | 1061 ++++++ .../src/dotty/tools/dotc/typer/ProtoTypes.scala | 488 +++ compiler/src/dotty/tools/dotc/typer/ReTyper.scala | 108 + .../src/dotty/tools/dotc/typer/RefChecks.scala | 1526 ++++++++ .../src/dotty/tools/dotc/typer/TypeAssigner.scala | 524 +++ compiler/src/dotty/tools/dotc/typer/Typer.scala | 1952 ++++++++++ .../dotty/tools/dotc/typer/VarianceChecker.scala | 148 + .../src/dotty/tools/dotc/typer/Variances.scala | 116 + .../src/dotty/tools/dotc/util/Attachment.scala | 96 + compiler/src/dotty/tools/dotc/util/Chars.scala | 96 + .../src/dotty/tools/dotc/util/CommentParsing.scala | 239 ++ compiler/src/dotty/tools/dotc/util/DiffUtil.scala | 174 + compiler/src/dotty/tools/dotc/util/DotClass.scala | 12 + .../dotty/tools/dotc/util/FreshNameCreator.scala | 33 + compiler/src/dotty/tools/dotc/util/HashSet.scala | 146 + compiler/src/dotty/tools/dotc/util/LRUCache.scala | 100 + .../dotty/tools/dotc/util/NameTransformer.scala | 163 + compiler/src/dotty/tools/dotc/util/Positions.scala | 173 + compiler/src/dotty/tools/dotc/util/Property.scala | 10 + compiler/src/dotty/tools/dotc/util/Set.scala | 27 + .../src/dotty/tools/dotc/util/ShowPickled.scala | 287 ++ compiler/src/dotty/tools/dotc/util/SimpleMap.scala | 223 ++ .../src/dotty/tools/dotc/util/SixteenNibbles.scala | 28 + .../src/dotty/tools/dotc/util/SourceFile.scala | 145 + .../src/dotty/tools/dotc/util/SourcePosition.scala | 57 + compiler/src/dotty/tools/dotc/util/Stats.scala | 78 + compiler/src/dotty/tools/dotc/util/Util.scala | 32 + compiler/src/dotty/tools/dotc/util/common.scala | 14 + compiler/src/dotty/tools/dotc/util/kwords.sc | 18 + compiler/src/dotty/tools/dotc/util/lrutest.sc | 40 + compiler/src/dotty/tools/io/ClassPath.scala | 421 +++ .../src/dotty/tools/io/DaemonThreadFactory.scala | 16 + compiler/src/dotty/tools/io/Fileish.scala | 34 + compiler/src/dotty/tools/io/Jar.scala | 172 + compiler/src/dotty/tools/io/package.scala | 58 + compiler/src/dotty/tools/package.scala | 24 + .../strawman/collections/CollectionStrawMan1.scala | 405 ++ .../strawman/collections/CollectionStrawMan4.scala | 541 +++ .../strawman/collections/CollectionStrawMan5.scala | 522 +++ .../strawman/collections/CollectionStrawMan6.scala | 1045 ++++++ compiler/test/dotc/build.scala | 40 + compiler/test/dotc/comptest.scala | 24 + compiler/test/dotc/scala-collections.whitelist | 282 ++ compiler/test/dotc/tests.scala | 359 ++ compiler/test/dotty/partest/DPConfig.scala | 40 + compiler/test/dotty/partest/DPConsoleRunner.scala | 356 ++ compiler/test/dotty/partest/DPDirectCompiler.scala | 36 + .../test/dotty/tools/ContextEscapeDetection.java | 36 + .../test/dotty/tools/ContextEscapeDetector.java | 108 + compiler/test/dotty/tools/DottyTest.scala | 73 + compiler/test/dotty/tools/DottyTypeStealer.scala | 32 + compiler/test/dotty/tools/ShowClassTests.scala | 154 + compiler/test/dotty/tools/TypeStealer.scala | 21 + .../dotty/tools/backend/jvm/AsmConverters.scala | 256 ++ .../test/dotty/tools/backend/jvm/AsmNode.scala | 61 + .../tools/backend/jvm/DottyBytecodeTest.scala | 208 ++ .../tools/backend/jvm/DottyBytecodeTests.scala | 188 + .../tools/backend/jvm/InlineBytecodeTests.scala | 32 + compiler/test/dotty/tools/dotc/CompilerTest.scala | 623 ++++ .../test/dotty/tools/dotc/EntryPointsTest.scala | 72 + .../dotty/tools/dotc/InterfaceEntryPointTest.scala | 72 + .../test/dotty/tools/dotc/ast/TreeInfoTest.scala | 30 + .../dotty/tools/dotc/parsing/DeSugarTest.scala | 96 + .../dotty/tools/dotc/parsing/DocstringTest.scala | 34 + .../dotty/tools/dotc/parsing/DocstringTests.scala | 491 +++ .../tools/dotc/parsing/ModifiersParsingTest.scala | 164 + .../test/dotty/tools/dotc/parsing/ParserTest.scala | 44 + .../dotty/tools/dotc/parsing/ScannerTest.scala | 65 + .../dotty/tools/dotc/parsing/desugarPackage.scala | 28 + .../test/dotty/tools/dotc/parsing/parseFile.scala | 13 + .../dotty/tools/dotc/parsing/parsePackage.scala | 83 + .../test/dotty/tools/dotc/parsing/showTree.scala | 26 + compiler/test/dotty/tools/dotc/repl/TestREPL.scala | 66 + .../tools/dotc/reporting/TestMessageLaziness.scala | 37 + .../dotty/tools/dotc/reporting/TestReporter.scala | 52 + .../transform/CreateCompanionObjectsTest.scala | 128 + .../dotty/tools/dotc/transform/LazyValsTest.scala | 361 ++ .../dotc/transform/PostTyperTransformerTest.scala | 132 + .../tools/dotc/transform/TreeTransformerTest.scala | 198 + compiler/test/dotty/tools/showClass.scala | 17 + compiler/test/partest | 4 + compiler/test/worksheets/baseTypetest.sc | 26 + compiler/test/worksheets/denotTest.sc | 55 + compiler/test/worksheets/flagtest.sc | 27 + compiler/test/worksheets/nesting.sc | 31 + compiler/test/worksheets/periodtest.sc | 18 + compiler/test/worksheets/positiontest.sc | 14 + compiler/test/worksheets/sigtest.sc | 34 + compiler/test/worksheets/testnames.sc | 49 + 325 files changed, 86404 insertions(+) create mode 100644 compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala create mode 100644 compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala create mode 100644 compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala create mode 100644 compiler/src/dotty/tools/backend/jvm/GenBCode.scala create mode 100644 compiler/src/dotty/tools/backend/jvm/LabelDefs.scala create mode 100644 compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala create mode 100644 compiler/src/dotty/tools/dotc/Bench.scala create mode 100644 compiler/src/dotty/tools/dotc/CompilationUnit.scala create mode 100644 compiler/src/dotty/tools/dotc/Compiler.scala create mode 100644 compiler/src/dotty/tools/dotc/Driver.scala create mode 100644 compiler/src/dotty/tools/dotc/FromTasty.scala create mode 100644 compiler/src/dotty/tools/dotc/Main.scala create mode 100644 compiler/src/dotty/tools/dotc/Resident.scala create mode 100644 compiler/src/dotty/tools/dotc/Run.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/CheckTrees.scala.disabled create mode 100644 compiler/src/dotty/tools/dotc/ast/Desugar.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/NavigateAST.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/PluggableTransformers.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/Positioned.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/TreeInfo.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/Trees.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/tpd.scala create mode 100644 compiler/src/dotty/tools/dotc/ast/untpd.scala create mode 100644 compiler/src/dotty/tools/dotc/config/CompilerCommand.scala create mode 100644 compiler/src/dotty/tools/dotc/config/Config.scala create mode 100644 compiler/src/dotty/tools/dotc/config/JavaPlatform.scala create mode 100644 compiler/src/dotty/tools/dotc/config/OutputDirs.scala create mode 100644 compiler/src/dotty/tools/dotc/config/PathResolver.scala create mode 100644 compiler/src/dotty/tools/dotc/config/Platform.scala create mode 100644 compiler/src/dotty/tools/dotc/config/Printers.scala create mode 100644 compiler/src/dotty/tools/dotc/config/Properties.scala create mode 100644 compiler/src/dotty/tools/dotc/config/ScalaSettings.scala create mode 100644 compiler/src/dotty/tools/dotc/config/ScalaVersion.scala create mode 100644 compiler/src/dotty/tools/dotc/config/Settings.scala create mode 100644 compiler/src/dotty/tools/dotc/config/WrappedProperties.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Annotations.scala create mode 100644 compiler/src/dotty/tools/dotc/core/CheckRealizable.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Comments.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Constants.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Constraint.scala create mode 100644 compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala create mode 100644 compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Contexts.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Decorators.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Definitions.scala create mode 100644 compiler/src/dotty/tools/dotc/core/DenotTransformers.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Denotations.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Flags.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Hashable.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Mode.scala create mode 100644 compiler/src/dotty/tools/dotc/core/NameOps.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Names.scala create mode 100644 compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Periods.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Phases.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Scopes.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Signature.scala create mode 100644 compiler/src/dotty/tools/dotc/core/StdNames.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Substituters.scala create mode 100644 compiler/src/dotty/tools/dotc/core/SymDenotations.scala create mode 100644 compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Symbols.scala create mode 100644 compiler/src/dotty/tools/dotc/core/TypeApplications.scala create mode 100644 compiler/src/dotty/tools/dotc/core/TypeComparer.scala create mode 100644 compiler/src/dotty/tools/dotc/core/TypeErasure.scala create mode 100644 compiler/src/dotty/tools/dotc/core/TypeOps.scala create mode 100644 compiler/src/dotty/tools/dotc/core/TypeParamInfo.scala create mode 100644 compiler/src/dotty/tools/dotc/core/TyperState.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Types.overflow create mode 100644 compiler/src/dotty/tools/dotc/core/Types.scala create mode 100644 compiler/src/dotty/tools/dotc/core/Uniques.scala create mode 100644 compiler/src/dotty/tools/dotc/core/classfile/AbstractFileReader.scala create mode 100644 compiler/src/dotty/tools/dotc/core/classfile/ByteCodecs.scala create mode 100644 compiler/src/dotty/tools/dotc/core/classfile/ClassfileConstants.scala create mode 100644 compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/PositionUnpickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyName.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala create mode 100644 compiler/src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala create mode 100644 compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/CharArrayReader.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/JavaScanners.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/JavaTokens.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/MarkupParserCommon.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/MarkupParsers.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/Parsers.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/Scanners.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/ScriptParsers.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/Tokens.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/TreeBuilder.scala.unused create mode 100644 compiler/src/dotty/tools/dotc/parsing/Utility.scala create mode 100644 compiler/src/dotty/tools/dotc/parsing/package.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/Formatting.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/Highlighting.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/Printer.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/Printers.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/Showable.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/Texts.scala create mode 100644 compiler/src/dotty/tools/dotc/printing/package.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/AbstractFileClassLoader.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/AmmoniteReader.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/CompilingInterpreter.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ConsoleWriter.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/InteractiveReader.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/Interpreter.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/InterpreterLoop.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/Main.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ManifestInfo.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/NewLinePrintWriter.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/REPL.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/SimpleReader.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/Ansi.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/Filter.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/FilterTools.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/LICENSE create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/Protocol.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/SpecialKeys.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/Terminal.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/Utils.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/filters/BasicFilters.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/filters/GUILikeFilters.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/filters/HistoryFilter.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/filters/ReadlineFilters.scala create mode 100644 compiler/src/dotty/tools/dotc/repl/ammonite/filters/UndoFilter.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/ConsoleReporter.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/Reporter.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/StoreReporter.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/ThrowingReporter.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/diagnostic/Message.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/diagnostic/MessageContainer.scala create mode 100644 compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala create mode 100644 compiler/src/dotty/tools/dotc/rewrite/Rewrites.scala create mode 100644 compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala create mode 100644 compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala create mode 100644 compiler/src/dotty/tools/dotc/sbt/ShowAPI.scala create mode 100644 compiler/src/dotty/tools/dotc/sbt/ThunkHolder.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ArrayConstructors.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/AugmentScala2Traits.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/CapturedVars.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/CheckReentrant.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/CheckStatic.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ClassOf.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/CollectEntryPoints.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Constructors.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/CrossCastAnd.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/CtxLazy.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/DropEmptyCompanions.scala.disabled create mode 100644 compiler/src/dotty/tools/dotc/transform/DropInlined.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ElimByName.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ElimErasedValueType.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ElimStaticThis.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Erasure.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ExpandPrivate.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ExpandSAMs.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ExplicitSelf.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ExtensionMethods.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/FirstTransform.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Flatten.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/FullParameterization.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/GetClass.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Getters.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/InterceptedMethods.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/IsInstanceOfEvaluator.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/LambdaLift.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/LazyVals.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/LiftTry.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/LinkScala2ImplClasses.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Literalize.scala.disabled create mode 100644 compiler/src/dotty/tools/dotc/transform/MacroTransform.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Memoize.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Mixin.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/MixinOps.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/MoveStatics.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/NormalizeFlags.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ParamForwarding.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Pickler.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/PostTyper.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/PrivateToStatic.scala.disabled create mode 100644 compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/RestoreScopes.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/SelectStatic.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/SeqLiterals.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/Splitter.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/SymUtils.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TailRec.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TreeChecker.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TreeExtractors.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TreeGen.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TreeTransform.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TryCatchPatterns.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/TypeUtils.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/VCElideAllocations.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/VCInlineMethods.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/ValueClasses.scala create mode 100644 compiler/src/dotty/tools/dotc/transform/patmat/Space.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Applications.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Checking.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/ConstFold.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Docstrings.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Dynamic.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/FrontEnd.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Implicits.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/ImportInfo.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Inferencing.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Inliner.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Namer.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/ReTyper.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/RefChecks.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Typer.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/VarianceChecker.scala create mode 100644 compiler/src/dotty/tools/dotc/typer/Variances.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Attachment.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Chars.scala create mode 100644 compiler/src/dotty/tools/dotc/util/CommentParsing.scala create mode 100644 compiler/src/dotty/tools/dotc/util/DiffUtil.scala create mode 100644 compiler/src/dotty/tools/dotc/util/DotClass.scala create mode 100644 compiler/src/dotty/tools/dotc/util/FreshNameCreator.scala create mode 100644 compiler/src/dotty/tools/dotc/util/HashSet.scala create mode 100644 compiler/src/dotty/tools/dotc/util/LRUCache.scala create mode 100644 compiler/src/dotty/tools/dotc/util/NameTransformer.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Positions.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Property.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Set.scala create mode 100644 compiler/src/dotty/tools/dotc/util/ShowPickled.scala create mode 100644 compiler/src/dotty/tools/dotc/util/SimpleMap.scala create mode 100644 compiler/src/dotty/tools/dotc/util/SixteenNibbles.scala create mode 100644 compiler/src/dotty/tools/dotc/util/SourceFile.scala create mode 100644 compiler/src/dotty/tools/dotc/util/SourcePosition.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Stats.scala create mode 100644 compiler/src/dotty/tools/dotc/util/Util.scala create mode 100644 compiler/src/dotty/tools/dotc/util/common.scala create mode 100644 compiler/src/dotty/tools/dotc/util/kwords.sc create mode 100644 compiler/src/dotty/tools/dotc/util/lrutest.sc create mode 100644 compiler/src/dotty/tools/io/ClassPath.scala create mode 100644 compiler/src/dotty/tools/io/DaemonThreadFactory.scala create mode 100644 compiler/src/dotty/tools/io/Fileish.scala create mode 100644 compiler/src/dotty/tools/io/Jar.scala create mode 100644 compiler/src/dotty/tools/io/package.scala create mode 100644 compiler/src/dotty/tools/package.scala create mode 100644 compiler/src/strawman/collections/CollectionStrawMan1.scala create mode 100644 compiler/src/strawman/collections/CollectionStrawMan4.scala create mode 100644 compiler/src/strawman/collections/CollectionStrawMan5.scala create mode 100644 compiler/src/strawman/collections/CollectionStrawMan6.scala create mode 100644 compiler/test/dotc/build.scala create mode 100644 compiler/test/dotc/comptest.scala create mode 100644 compiler/test/dotc/scala-collections.whitelist create mode 100644 compiler/test/dotc/tests.scala create mode 100644 compiler/test/dotty/partest/DPConfig.scala create mode 100644 compiler/test/dotty/partest/DPConsoleRunner.scala create mode 100644 compiler/test/dotty/partest/DPDirectCompiler.scala create mode 100644 compiler/test/dotty/tools/ContextEscapeDetection.java create mode 100644 compiler/test/dotty/tools/ContextEscapeDetector.java create mode 100644 compiler/test/dotty/tools/DottyTest.scala create mode 100644 compiler/test/dotty/tools/DottyTypeStealer.scala create mode 100644 compiler/test/dotty/tools/ShowClassTests.scala create mode 100644 compiler/test/dotty/tools/TypeStealer.scala create mode 100644 compiler/test/dotty/tools/backend/jvm/AsmConverters.scala create mode 100644 compiler/test/dotty/tools/backend/jvm/AsmNode.scala create mode 100644 compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala create mode 100644 compiler/test/dotty/tools/backend/jvm/DottyBytecodeTests.scala create mode 100644 compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala create mode 100644 compiler/test/dotty/tools/dotc/CompilerTest.scala create mode 100644 compiler/test/dotty/tools/dotc/EntryPointsTest.scala create mode 100644 compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala create mode 100644 compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/DeSugarTest.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/DocstringTest.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/DocstringTests.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/ParserTest.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/ScannerTest.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/desugarPackage.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/parseFile.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/parsePackage.scala create mode 100644 compiler/test/dotty/tools/dotc/parsing/showTree.scala create mode 100644 compiler/test/dotty/tools/dotc/repl/TestREPL.scala create mode 100644 compiler/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala create mode 100644 compiler/test/dotty/tools/dotc/reporting/TestReporter.scala create mode 100644 compiler/test/dotty/tools/dotc/transform/CreateCompanionObjectsTest.scala create mode 100644 compiler/test/dotty/tools/dotc/transform/LazyValsTest.scala create mode 100644 compiler/test/dotty/tools/dotc/transform/PostTyperTransformerTest.scala create mode 100644 compiler/test/dotty/tools/dotc/transform/TreeTransformerTest.scala create mode 100644 compiler/test/dotty/tools/showClass.scala create mode 100755 compiler/test/partest create mode 100644 compiler/test/worksheets/baseTypetest.sc create mode 100644 compiler/test/worksheets/denotTest.sc create mode 100644 compiler/test/worksheets/flagtest.sc create mode 100644 compiler/test/worksheets/nesting.sc create mode 100644 compiler/test/worksheets/periodtest.sc create mode 100644 compiler/test/worksheets/positiontest.sc create mode 100644 compiler/test/worksheets/sigtest.sc create mode 100644 compiler/test/worksheets/testnames.sc (limited to 'compiler') diff --git a/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala b/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala new file mode 100644 index 000000000..2ee1b6011 --- /dev/null +++ b/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala @@ -0,0 +1,125 @@ +package dotty.tools.backend.jvm + +import dotty.tools.dotc.ast.tpd +import dotty.tools.dotc.core.Contexts.Context +import dotty.tools.dotc.core.Types +import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, TreeTransform, MiniPhase, MiniPhaseTransform} +import dotty.tools.dotc.ast.tpd +import dotty.tools.dotc +import dotty.tools.dotc.backend.jvm.DottyPrimitives +import dotty.tools.dotc.core.Flags.FlagSet +import dotty.tools.dotc.transform.Erasure +import dotty.tools.dotc.transform.SymUtils._ +import java.io.{File => JFile} + +import scala.collection.generic.Clearable +import scala.collection.mutable +import scala.reflect.ClassTag +import scala.reflect.internal.util.WeakHashSet +import scala.reflect.io.{Directory, PlainDirectory, AbstractFile} +import scala.tools.asm.{ClassVisitor, FieldVisitor, MethodVisitor} +import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface} +import dotty.tools.dotc.core._ +import Periods._ +import SymDenotations._ +import Contexts._ +import Types._ +import Symbols._ +import Denotations._ +import Phases._ +import java.lang.AssertionError +import dotty.tools.dotc.util.Positions.Position +import Decorators._ +import tpd._ +import StdNames.nme + +/** + * Created by dark on 26/11/14. + */ +class CollectEntryPoints extends MiniPhaseTransform { + def phaseName: String = "Collect entry points" + + override def transformDefDef(tree: tpd.DefDef)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { + if ((tree.symbol ne NoSymbol) && CollectEntryPoints.isJavaEntryPoint(tree.symbol)) { + ctx.genBCodePhase.asInstanceOf[GenBCode].registerEntryPoint(tree.symbol) + } + tree + } +} + +object CollectEntryPoints{ + def isJavaMainMethod(sym: Symbol)(implicit ctx: Context) = { + (sym.name == nme.main) && (sym.info match { + case r@MethodType(_, List(defn.ArrayOf(t))) => + (t.widenDealias =:= defn.StringType) && ( + r.resultType.widenDealias =:= defn.UnitType) + case _ => false + }) + } + + def isJavaEntryPoint(sym: Symbol)(implicit ctx: Context): Boolean = { + import Types.MethodType + val d = ctx.definitions + val StringType = d.StringType + // The given class has a main method. + def hasJavaMainMethod(sym: Symbol): Boolean = + (toDenot(sym).info member nme.main).alternatives exists(x => isJavaMainMethod(x.symbol)) + + def fail(msg: String, pos: Position = sym.pos) = { + ctx.warning( sym.name + + s" has a main method with parameter type Array[String], but ${toDenot(sym).fullName} will not be a runnable program.\n Reason: $msg", + sourcePos(sym.pos) + // TODO: make this next claim true, if possible + // by generating valid main methods as static in module classes + // not sure what the jvm allows here + // + " You can still run the program by calling it as " + javaName(sym) + " instead." + ) + false + } + def failNoForwarder(msg: String) = { + fail(s"$msg, which means no static forwarder can be generated.\n") + } + val possibles = if (sym.flags is Flags.Module) (toDenot(sym).info nonPrivateMember nme.main).alternatives else Nil + val hasApproximate = possibles exists { m => + m.info match { + case MethodType(_, p :: Nil) => + p.typeSymbol == defn.ArrayClass + case _ => false + } + } + // At this point it's a module with a main-looking method, so either succeed or warn that it isn't. + hasApproximate && { + // Before erasure so we can identify generic mains. + { + // implicit val c = ctx.withPhase(ctx.erasurePhase) + + val companion = sym.asClass.moduleClass + + if (hasJavaMainMethod(companion)) + failNoForwarder("companion contains its own main method") + else if (toDenot(companion).info.member(nme.main) != NoDenotation) + // this is only because forwarders aren't smart enough yet + failNoForwarder("companion contains its own main method (implementation restriction: no main is allowed, regardless of signature)") + else if (companion.flags is Flags.Trait) + failNoForwarder("companion is a trait") + // Now either succeed, or issue some additional warnings for things which look like + // attempts to be java main methods. + else (possibles exists(x=> isJavaMainMethod(x.symbol))) || { + possibles exists { m => + toDenot(m.symbol).info match { + case t: PolyType => + fail("main methods cannot be generic.") + case t@MethodType(paramNames, paramTypes) => + if (t.resultType :: paramTypes exists (_.typeSymbol.isAbstractType)) + fail("main methods cannot refer to type parameters or abstract types.", m.symbol.pos) + else + isJavaMainMethod(m.symbol) || fail("main method must have exact signature (Array[String])Unit", m.symbol.pos) + case tp => + fail(s"don't know what this is: $tp", m.symbol.pos) + } + } + } + } + } + } +} diff --git a/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala b/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala new file mode 100644 index 000000000..8285bfe4b --- /dev/null +++ b/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala @@ -0,0 +1,42 @@ +package dotty.tools.backend.jvm + +import dotty.tools.dotc.ast.tpd +import dotty.tools.dotc.ast.Trees._ +import dotty.tools.dotc.core.Contexts.Context +import dotty.tools.dotc.core.Symbols._ +import dotty.tools.dotc.core.Flags.Trait +import dotty.tools.dotc.transform.TreeTransforms.{MiniPhaseTransform, TransformerInfo} + +/** Collect all super calls to trait members. + * + * For each super reference to trait member, register a call from the current class to the + * owner of the referenced member. + * + * This information is used to know if it is safe to remove a redundant mixin class. + * A redundant mixin class is one that is implemented by another mixin class. As the + * methods in a redundant mixin class could be implemented with a default abstract method, + * the redundant mixin class could be required as a parent by the JVM. + */ +class CollectSuperCalls extends MiniPhaseTransform { + import tpd._ + + def phaseName: String = "collectSuperCalls" + + override def transformSelect(tree: Select)(implicit ctx: Context, info: TransformerInfo): Tree = { + tree.qualifier match { + case sup: Super => + if (tree.symbol.owner.is(Trait)) + registerSuperCall(ctx.owner.enclosingClass.asClass, tree.symbol.owner.asClass) + case _ => + } + tree + } + + private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(implicit ctx: Context) = { + ctx.genBCodePhase match { + case genBCodePhase: GenBCode => + genBCodePhase.registerSuperCall(sym, calls) + case _ => + } + } +} diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala new file mode 100644 index 000000000..a7c449947 --- /dev/null +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -0,0 +1,1102 @@ +package dotty.tools.backend.jvm + +import dotty.tools.dotc.ast.tpd +import dotty.tools.dotc +import dotty.tools.dotc.backend.jvm.DottyPrimitives +import dotty.tools.dotc.core.Flags.FlagSet +import dotty.tools.dotc.transform.Erasure +import dotty.tools.dotc.transform.SymUtils._ +import java.io.{File => JFile} + +import scala.collection.generic.Clearable +import scala.collection.mutable +import scala.reflect.ClassTag +import scala.reflect.internal.util.WeakHashSet +import scala.reflect.io.{AbstractFile, Directory, PlainDirectory} +import scala.tools.asm.{AnnotationVisitor, ClassVisitor, FieldVisitor, MethodVisitor} +import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface} +import dotty.tools.dotc.core._ +import Periods._ +import SymDenotations._ +import Contexts._ +import Types._ +import Symbols._ +import Denotations._ +import Phases._ +import java.lang.AssertionError + +import dotty.tools.dotc.util.{DotClass, Positions} +import Decorators._ +import tpd._ + +import scala.tools.asm +import NameOps._ +import StdNames.nme +import NameOps._ +import dotty.tools.dotc.core +import dotty.tools.dotc.core.Names.TypeName + +import scala.annotation.tailrec + +class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Map[Symbol, Set[ClassSymbol]])(implicit ctx: Context) extends BackendInterface{ + type Symbol = Symbols.Symbol + type Type = Types.Type + type Tree = tpd.Tree + type CompilationUnit = dotc.CompilationUnit + type Constant = Constants.Constant + type Literal = tpd.Literal + type Position = Positions.Position + type Name = Names.Name + type ClassDef = tpd.TypeDef + type TypeDef = tpd.TypeDef + type Apply = tpd.Apply + type TypeApply = tpd.TypeApply + type Try = tpd.Try + type Assign = tpd.Assign + type Ident = tpd.Ident + type If = tpd.If + type ValDef = tpd.ValDef + type Throw = tpd.Apply + type Return = tpd.Return + type Block = tpd.Block + type Typed = tpd.Typed + type Match = tpd.Match + type This = tpd.This + type CaseDef = tpd.CaseDef + type Alternative = tpd.Alternative + type DefDef = tpd.DefDef + type Template = tpd.Template + type Select = tpd.Tree // Actually tpd.Select || tpd.Ident + type Bind = tpd.Bind + type New = tpd.New + type Super = tpd.Super + type Modifiers = Null + type Annotation = Annotations.Annotation + type ArrayValue = tpd.JavaSeqLiteral + type ApplyDynamic = Null + type ModuleDef = Null + type LabelDef = tpd.DefDef + type Closure = tpd.Closure + + val NoSymbol = Symbols.NoSymbol + val NoPosition: Position = Positions.NoPosition + val EmptyTree: Tree = tpd.EmptyTree + + + val UnitTag: ConstantTag = Constants.UnitTag + val IntTag: ConstantTag = Constants.IntTag + val FloatTag: ConstantTag = Constants.FloatTag + val NullTag: ConstantTag = Constants.NullTag + val BooleanTag: ConstantTag = Constants.BooleanTag + val ByteTag: ConstantTag = Constants.ByteTag + val ShortTag: ConstantTag = Constants.ShortTag + val CharTag: ConstantTag = Constants.CharTag + val DoubleTag: ConstantTag = Constants.DoubleTag + val LongTag: ConstantTag = Constants.LongTag + val StringTag: ConstantTag = Constants.StringTag + val ClazzTag: ConstantTag = Constants.ClazzTag + val EnumTag: ConstantTag = Constants.EnumTag + + val nme_This: Name = StdNames.nme.This + val nme_EMPTY_PACKAGE_NAME: Name = StdNames.nme.EMPTY_PACKAGE + val nme_CONSTRUCTOR: Name = StdNames.nme.CONSTRUCTOR + val nme_WILDCARD: Name = StdNames.nme.WILDCARD + val nme_THIS: Name = StdNames.nme.THIS + val nme_PACKAGE: Name = StdNames.nme.PACKAGE + val nme_EQEQ_LOCAL_VAR: Name = StdNames.nme.EQEQ_LOCAL_VAR + + // require LambdaMetafactory: scalac uses getClassIfDefined, but we need those always. + override lazy val LambdaMetaFactory = ctx.requiredClass("java.lang.invoke.LambdaMetafactory") + override lazy val MethodHandle = ctx.requiredClass("java.lang.invoke.MethodHandle") + + val nme_valueOf: Name = StdNames.nme.valueOf + val nme_apply = StdNames.nme.apply + val NothingClass: Symbol = defn.NothingClass + val NullClass: Symbol = defn.NullClass + val ObjectClass: Symbol = defn.ObjectClass + val Object_Type: Type = defn.ObjectType + val Throwable_Type: Type = defn.ThrowableType + val Object_isInstanceOf: Symbol = defn.Any_isInstanceOf + val Object_asInstanceOf: Symbol = defn.Any_asInstanceOf + val Object_equals: Symbol = defn.Any_equals + val ArrayClass: Symbol = defn.ArrayClass + val UnitClass: Symbol = defn.UnitClass + val BooleanClass: Symbol = defn.BooleanClass + val CharClass: Symbol = defn.CharClass + val ShortClass: Symbol = defn.ShortClass + val ClassClass: Symbol = defn.ClassClass + val ByteClass: Symbol = defn.ByteClass + val IntClass: Symbol = defn.IntClass + val LongClass: Symbol = defn.LongClass + val FloatClass: Symbol = defn.FloatClass + val DoubleClass: Symbol = defn.DoubleClass + def isArrayClone(tree: Tree) = tree match { + case Select(qual, StdNames.nme.clone_) if qual.tpe.widen.isInstanceOf[JavaArrayType] => true + case _ => false + } + + val hashMethodSym: Symbol = NoSymbol // used to dispatch ## on primitives to ScalaRuntime.hash. Should be implemented by a miniphase + val externalEqualsNumNum: Symbol = defn.BoxesRunTimeModule.requiredMethod(nme.equalsNumNum) + val externalEqualsNumChar: Symbol = NoSymbol // ctx.requiredMethod(BoxesRunTimeTypeRef, nme.equalsNumChar) // this method is private + val externalEqualsNumObject: Symbol = defn.BoxesRunTimeModule.requiredMethod(nme.equalsNumObject) + val externalEquals: Symbol = defn.BoxesRunTimeClass.info.decl(nme.equals_).suchThat(toDenot(_).info.firstParamTypes.size == 2).symbol + val MaxFunctionArity: Int = Definitions.MaxFunctionArity + val FunctionClass: Array[Symbol] = defn.FunctionClassPerRun() + val AbstractFunctionClass: Array[Symbol] = defn.AbstractFunctionClassPerRun() + val PartialFunctionClass: Symbol = defn.PartialFunctionClass + val AbstractPartialFunctionClass: Symbol = defn.AbstractPartialFunctionClass + val String_valueOf: Symbol = defn.String_valueOf_Object + lazy val Predef_classOf: Symbol = defn.ScalaPredefModule.requiredMethod(nme.classOf) + + lazy val AnnotationRetentionAttr = ctx.requiredClass("java.lang.annotation.Retention") + lazy val AnnotationRetentionSourceAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("SOURCE") + lazy val AnnotationRetentionClassAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("CLASS") + lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("RUNTIME") + lazy val JavaAnnotationClass = ctx.requiredClass("java.lang.annotation.Annotation") + + def boxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses().map{x => // @darkdimius Are you sure this should be a def? + (x, Erasure.Boxing.boxMethod(x.asClass)) + }.toMap + def unboxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses().map(x => (x, Erasure.Boxing.unboxMethod(x.asClass))).toMap + + override def isSyntheticArrayConstructor(s: Symbol) = { + s eq defn.newArrayMethod + } + + def isBox(sym: Symbol): Boolean = Erasure.Boxing.isBox(sym) + def isUnbox(sym: Symbol): Boolean = Erasure.Boxing.isUnbox(sym) + + val primitives: Primitives = new Primitives { + val primitives = new DottyPrimitives(ctx) + def getPrimitive(app: Apply, reciever: Type): Int = primitives.getPrimitive(app, reciever) + + def getPrimitive(sym: Symbol): Int = primitives.getPrimitive(sym) + + def isPrimitive(fun: Tree): Boolean = primitives.isPrimitive(fun) + } + implicit val TypeDefTag: ClassTag[TypeDef] = ClassTag[TypeDef](classOf[TypeDef]) + implicit val ApplyTag: ClassTag[Apply] = ClassTag[Apply](classOf[Apply]) + implicit val SelectTag: ClassTag[Select] = ClassTag[Select](classOf[Select]) + implicit val TypeApplyTag: ClassTag[TypeApply] = ClassTag[TypeApply](classOf[TypeApply]) + implicit val ClassDefTag: ClassTag[ClassDef] = ClassTag[TypeDef](classOf[TypeDef]) + implicit val TryTag: ClassTag[Try] = ClassTag[Try](classOf[Try]) + implicit val AssignTag: ClassTag[Assign] = ClassTag[Assign](classOf[Assign]) + implicit val IdentTag: ClassTag[Ident] = ClassTag[Ident](classOf[Ident]) + implicit val IfTag: ClassTag[If] = ClassTag[If](classOf[If]) + implicit val LabelDefTag: ClassTag[LabelDef] = ClassTag[LabelDef](classOf[LabelDef]) + implicit val ValDefTag: ClassTag[ValDef] = ClassTag[ValDef](classOf[ValDef]) + implicit val ThrowTag: ClassTag[Throw] = ClassTag[Throw](classOf[Throw]) + implicit val ReturnTag: ClassTag[Return] = ClassTag[Return](classOf[Return]) + implicit val LiteralTag: ClassTag[Literal] = ClassTag[Literal](classOf[Literal]) + implicit val BlockTag: ClassTag[Block] = ClassTag[Block](classOf[Block]) + implicit val TypedTag: ClassTag[Typed] = ClassTag[Typed](classOf[Typed]) + implicit val ArrayValueTag: ClassTag[ArrayValue] = ClassTag[ArrayValue](classOf[ArrayValue]) + implicit val MatchTag: ClassTag[Match] = ClassTag[Match](classOf[Match]) + implicit val CaseDefTag: ClassTag[CaseDef] = ClassTag[CaseDef](classOf[CaseDef]) + implicit val ThisTag: ClassTag[This] = ClassTag[This](classOf[This]) + implicit val AlternativeTag: ClassTag[Alternative] = ClassTag[Alternative](classOf[Alternative]) + implicit val DefDefTag: ClassTag[DefDef] = ClassTag[DefDef](classOf[DefDef]) + implicit val ModuleDefTag: ClassTag[ModuleDef] = ClassTag[ModuleDef](classOf[ModuleDef]) + implicit val NameTag: ClassTag[Name] = ClassTag[Name](classOf[Name]) + implicit val TemplateTag: ClassTag[Template] = ClassTag[Template](classOf[Template]) + implicit val BindTag: ClassTag[Bind] = ClassTag[Bind](classOf[Bind]) + implicit val NewTag: ClassTag[New] = ClassTag[New](classOf[New]) + implicit val ApplyDynamicTag: ClassTag[ApplyDynamic] = ClassTag[ApplyDynamic](classOf[ApplyDynamic]) + implicit val SuperTag: ClassTag[Super] = ClassTag[Super](classOf[Super]) + implicit val ConstantClassTag: ClassTag[Constant] = ClassTag[Constant](classOf[Constant]) + implicit val ClosureTag: ClassTag[Closure] = ClassTag[Closure](classOf[Closure]) + + /* dont emit any annotations for now*/ + def isRuntimeVisible(annot: Annotation): Boolean = { + annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr) match { + case Some(retentionAnnot) => + retentionAnnot.tree.find(_.symbol == AnnotationRetentionRuntimeAttr).isDefined + case _ => + // SI-8926: if the annotation class symbol doesn't have a @RetentionPolicy annotation, the + // annotation is emitted with visibility `RUNTIME` + // dotty bug: #389 + true + } + } + + def shouldEmitAnnotation(annot: Annotation): Boolean = { + annot.symbol.isJavaDefined && + retentionPolicyOf(annot) != AnnotationRetentionSourceAttr && + annot.args.isEmpty + } + + private def retentionPolicyOf(annot: Annotation): Symbol = + annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr). + flatMap(_.argument(0).map(_.symbol)).getOrElse(AnnotationRetentionClassAttr) + + private def emitArgument(av: AnnotationVisitor, + name: String, + arg: Tree, bcodeStore: BCodeHelpers)(innerClasesStore: bcodeStore.BCInnerClassGen): Unit = { + (arg: @unchecked) match { + + case Literal(const @ Constant(_)) => + const.tag match { + case BooleanTag | ByteTag | ShortTag | CharTag | IntTag | LongTag | FloatTag | DoubleTag => av.visit(name, const.value) + case StringTag => + assert(const.value != null, const) // TODO this invariant isn't documented in `case class Constant` + av.visit(name, const.stringValue) // `stringValue` special-cases null, but that execution path isn't exercised for a const with StringTag + case ClazzTag => av.visit(name, const.typeValue.toTypeKind(bcodeStore)(innerClasesStore).toASMType) + case EnumTag => + val edesc = innerClasesStore.typeDescriptor(const.tpe.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the enumeration class. + val evalue = const.symbolValue.name.toString // value the actual enumeration value. + av.visitEnum(name, edesc, evalue) + } + case t: TypeApply if (t.fun.symbol == Predef_classOf) => + av.visit(name, t.args.head.tpe.classSymbol.denot.info.toTypeKind(bcodeStore)(innerClasesStore).toASMType) + case t: tpd.Select => + if (t.symbol.denot.is(Flags.Enum)) { + val edesc = innerClasesStore.typeDescriptor(t.tpe.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the enumeration class. + val evalue = t.symbol.name.toString // value the actual enumeration value. + av.visitEnum(name, edesc, evalue) + } else { + assert(toDenot(t.symbol).name.toTermName.defaultGetterIndex >= 0) // this should be default getter. do not emmit. + } + case t: SeqLiteral => + val arrAnnotV: AnnotationVisitor = av.visitArray(name) + for(arg <- t.elems) { emitArgument(arrAnnotV, null, arg, bcodeStore)(innerClasesStore) } + arrAnnotV.visitEnd() + + case Apply(fun, args) if (fun.symbol == defn.ArrayClass.primaryConstructor || + (toDenot(fun.symbol).owner == defn.ArrayClass.linkedClass && fun.symbol.name == nme_apply)) => + val arrAnnotV: AnnotationVisitor = av.visitArray(name) + + var actualArgs = if (fun.tpe.isInstanceOf[ImplicitMethodType]) { + // generic array method, need to get implicit argument out of the way + fun.asInstanceOf[Apply].args + } else args + + val flatArgs = actualArgs.flatMap { + case t: tpd.SeqLiteral => t.elems + case e => List(e) + } + for(arg <- flatArgs) { emitArgument(arrAnnotV, null, arg, bcodeStore)(innerClasesStore) } + arrAnnotV.visitEnd() +/* + case sb @ ScalaSigBytes(bytes) => + // see http://www.scala-lang.org/sid/10 (Storage of pickled Scala signatures in class files) + // also JVMS Sec. 4.7.16.1 The element_value structure and JVMS Sec. 4.4.7 The CONSTANT_Utf8_info Structure. + if (sb.fitsInOneString) { + av.visit(name, BCodeAsmCommon.strEncode(sb)) + } else { + val arrAnnotV: asm.AnnotationVisitor = av.visitArray(name) + for(arg <- BCodeAsmCommon.arrEncode(sb)) { arrAnnotV.visit(name, arg) } + arrAnnotV.visitEnd() + } // for the lazy val in ScalaSigBytes to be GC'ed, the invoker of emitAnnotations() should hold the ScalaSigBytes in a method-local var that doesn't escape. +*/ + case t @ Apply(constr, args) if t.tpe.derivesFrom(JavaAnnotationClass) => + val typ = t.tpe.classSymbol.denot.info + val assocs = assocsFromApply(t) + val desc = innerClasesStore.typeDescriptor(typ.asInstanceOf[bcodeStore.int.Type]) // the class descriptor of the nested annotation class + val nestedVisitor = av.visitAnnotation(name, desc) + emitAssocs(nestedVisitor, assocs, bcodeStore)(innerClasesStore) + } + } + + override def emitAnnotations(cw: asm.ClassVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers) + (innerClasesStore: bcodeStore.BCInnerClassGen) = { + for(annot <- annotations; if shouldEmitAnnotation(annot)) { + val typ = annot.atp + val assocs = annot.assocs + val av = cw.visitAnnotation(innerClasesStore.typeDescriptor(typ.asInstanceOf[bcodeStore.int.Type]), isRuntimeVisible(annot)) + emitAssocs(av, assocs, bcodeStore)(innerClasesStore) + } + } + + private def emitAssocs(av: asm.AnnotationVisitor, assocs: List[(Name, Object)], bcodeStore: BCodeHelpers) + (innerClasesStore: bcodeStore.BCInnerClassGen) = { + for ((name, value) <- assocs) + emitArgument(av, name.toString, value.asInstanceOf[Tree], bcodeStore)(innerClasesStore) + av.visitEnd() + } + + override def emitAnnotations(mw: asm.MethodVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers) + (innerClasesStore: bcodeStore.BCInnerClassGen) = { + for(annot <- annotations; if shouldEmitAnnotation(annot)) { + val typ = annot.atp + val assocs = annot.assocs + val av = mw.visitAnnotation(innerClasesStore.typeDescriptor(typ.asInstanceOf[bcodeStore.int.Type]), isRuntimeVisible(annot)) + emitAssocs(av, assocs, bcodeStore)(innerClasesStore) + } + } + + override def emitAnnotations(fw: asm.FieldVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers) + (innerClasesStore: bcodeStore.BCInnerClassGen) = { + for(annot <- annotations; if shouldEmitAnnotation(annot)) { + val typ = annot.atp + val assocs = annot.assocs + val av = fw.visitAnnotation(innerClasesStore.typeDescriptor(typ.asInstanceOf[bcodeStore.int.Type]), isRuntimeVisible(annot)) + emitAssocs(av, assocs, bcodeStore)(innerClasesStore) + } + } + + override def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[Annotation]], bcodeStore: BCodeHelpers) + (innerClasesStore: bcodeStore.BCInnerClassGen): Unit = { + val annotationss = pannotss map (_ filter shouldEmitAnnotation) + if (annotationss forall (_.isEmpty)) return + for ((annots, idx) <- annotationss.zipWithIndex; + annot <- annots) { + val typ = annot.atp + val assocs = annot.assocs + val pannVisitor: asm.AnnotationVisitor = jmethod.visitParameterAnnotation(idx, innerClasesStore.typeDescriptor(typ.asInstanceOf[bcodeStore.int.Type]), isRuntimeVisible(annot)) + emitAssocs(pannVisitor, assocs, bcodeStore)(innerClasesStore) + } + } + + def getAnnotPickle(jclassName: String, sym: Symbol): Option[Annotation] = None + + + def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname.toTermName) + + def getClassIfDefined(fullname: String): Symbol = NoSymbol // used only for android. todo: implement + + private def erasureString(clazz: Class[_]): String = { + if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]" + else clazz.getName + } + + def requiredClass[T](implicit evidence: ClassTag[T]): Symbol = { + ctx.requiredClass(erasureString(evidence.runtimeClass).toTermName) + } + + def requiredModule[T](implicit evidence: ClassTag[T]): Symbol = { + val moduleName = erasureString(evidence.runtimeClass) + val className = if (moduleName.endsWith("$")) moduleName.dropRight(1) else moduleName + ctx.requiredModule(className.toTermName) + } + + + def debuglog(msg: => String): Unit = ctx.debuglog(msg) + def informProgress(msg: String): Unit = ctx.informProgress(msg) + def log(msg: => String): Unit = ctx.log(msg) + def error(pos: Position, msg: String): Unit = ctx.error(msg, pos) + def warning(pos: Position, msg: String): Unit = ctx.warning(msg, pos) + def abort(msg: String): Nothing = { + ctx.error(msg) + throw new RuntimeException(msg) + } + + def emitAsmp: Option[String] = None + + def shouldEmitJumpAfterLabels = true + + def dumpClasses: Option[String] = + if (ctx.settings.Ydumpclasses.isDefault) None + else Some(ctx.settings.Ydumpclasses.value) + + def mainClass: Option[String] = + if (ctx.settings.mainClass.isDefault) None + else Some(ctx.settings.mainClass.value) + def setMainClass(name: String): Unit = ctx.settings.mainClass.update(name) + + + def noForwarders: Boolean = ctx.settings.noForwarders.value + def debuglevel: Int = 3 // 0 -> no debug info; 1-> filename; 2-> lines; 3-> varnames + def settings_debug: Boolean = ctx.settings.debug.value + def targetPlatform: String = ctx.settings.target.value + + val perRunCaches: Caches = new Caches { + def newAnyRefMap[K <: AnyRef, V](): mutable.AnyRefMap[K, V] = new mutable.AnyRefMap[K, V]() + def newWeakMap[K, V](): mutable.WeakHashMap[K, V] = new mutable.WeakHashMap[K, V]() + def recordCache[T <: Clearable](cache: T): T = cache + def newWeakSet[K <: AnyRef](): WeakHashSet[K] = new WeakHashSet[K]() + def newMap[K, V](): mutable.HashMap[K, V] = new mutable.HashMap[K, V]() + def newSet[K](): mutable.Set[K] = new mutable.HashSet[K] + } + + + + val MODULE_INSTANCE_FIELD: String = nme.MODULE_INSTANCE_FIELD.toString + + def internalNameString(offset: Int, length: Int): String = new String(Names.chrs, offset, length) + + def newTermName(prefix: String): Name = prefix.toTermName + + val Flag_SYNTHETIC: Flags = Flags.Synthetic.bits + val Flag_METHOD: Flags = Flags.Method.bits + val ExcludedForwarderFlags: Flags = { + Flags.Specialized | Flags.Lifted | Flags.Protected | Flags.JavaStatic | + Flags.ExpandedName | Flags.Bridge | Flags.VBridge | Flags.Private | Flags.Macro + }.bits + + + def isQualifierSafeToElide(qual: Tree): Boolean = tpd.isIdempotentExpr(qual) + def desugarIdent(i: Ident): Option[tpd.Select] = { + i.tpe match { + case TermRef(prefix: TermRef, name) => + Some(tpd.ref(prefix).select(i.symbol)) + case TermRef(prefix: ThisType, name) => + Some(tpd.This(prefix.cls).select(i.symbol)) + case TermRef(NoPrefix, name) => + if (i.symbol is Flags.Method) Some(This(i.symbol.topLevelClass).select(i.symbol)) // workaround #342 todo: remove after fixed + else None + case _ => None + } + } + def getLabelDefOwners(tree: Tree): Map[Tree, List[LabelDef]] = { + // for each rhs of a defdef returns LabelDefs inside this DefDef + val res = new collection.mutable.HashMap[Tree, List[LabelDef]]() + + val t = new TreeTraverser { + var outerRhs: Tree = tree + + def traverse(tree: tpd.Tree)(implicit ctx: Context): Unit = tree match { + case t: DefDef => + if (t.symbol is Flags.Label) + res.put(outerRhs, t :: res.getOrElse(outerRhs, Nil)) + else outerRhs = t + traverseChildren(t) + case _ => traverseChildren(tree) + } + } + + t.traverse(tree) + res.toMap + } + + // todo: remove + def isMaybeBoxed(sym: Symbol) = { + (sym == ObjectClass) || + (sym == JavaSerializableClass) || + (sym == defn.ComparableClass) || + (sym derivesFrom BoxedNumberClass) || + (sym derivesFrom BoxedCharacterClass) || + (sym derivesFrom BoxedBooleanClass) + } + + def getSingleOutput: Option[AbstractFile] = None // todo: implement + + + def getGenericSignature(sym: Symbol, owner: Symbol): String = null // todo: implement + + def getStaticForwarderGenericSignature(sym: Symbol, moduleClass: Symbol): String = null // todo: implement + + + def sourceFileFor(cu: CompilationUnit): String = cu.source.file.name + + + + implicit def positionHelper(a: Position): PositionHelper = new PositionHelper { + def isDefined: Boolean = a.exists + def line: Int = sourcePos(a).line + 1 + def finalPosition: Position = a + } + + implicit def constantHelper(a: Constant): ConstantHelper = new ConstantHelper { + def booleanValue: Boolean = a.booleanValue + def longValue: Long = a.longValue + def byteValue: Byte = a.byteValue + def stringValue: String = a.stringValue + def symbolValue: Symbol = a.symbolValue + def floatValue: Float = a.floatValue + def value: Any = a.value + def tag: ConstantTag = a.tag + def typeValue: Type = a.typeValue + def shortValue: Short = a.shortValue + def intValue: Int = a.intValue + def doubleValue: Double = a.doubleValue + def charValue: Char = a.charValue + } + + + implicit def treeHelper(a: Tree): TreeHelper = new TreeHelper { + def symbol: Symbol = a.symbol + + def pos: Position = a.pos + + def isEmpty: Boolean = a.isEmpty + + def tpe: Type = a.tpe + + def exists(pred: (Tree) => Boolean): Boolean = a.find(pred).isDefined + } + + + implicit def annotHelper(a: Annotation): AnnotationHelper = new AnnotationHelper { + def atp: Type = a.tree.tpe + + def assocs: List[(Name, Tree)] = assocsFromApply(a.tree) + + def symbol: Symbol = a.tree.symbol + + def args: List[Tree] = List.empty // those arguments to scala-defined annotations. they are never emmited + } + + def assocsFromApply(tree: Tree) = { + tree match { + case Apply(fun, args) => + fun.tpe.widen match { + case MethodType(names, _) => + names zip args + } + } + } + + + implicit def nameHelper(n: Name): NameHelper = new NameHelper { + def toTypeName: Name = n.toTypeName + def isTypeName: Boolean = n.isTypeName + def toTermName: Name = n.toTermName + def dropModule: Name = n.stripModuleClassSuffix + + def len: Int = n.length + def offset: Int = n.start + def isTermName: Boolean = n.isTermName + def startsWith(s: String): Boolean = n.startsWith(s) + } + + + implicit def symHelper(sym: Symbol): SymbolHelper = new SymbolHelper { + // names + def fullName(sep: Char): String = sym.showFullName + def fullName: String = sym.showFullName + def simpleName: Name = sym.name + def javaSimpleName: Name = toDenot(sym).name // addModuleSuffix(simpleName.dropLocal) + def javaBinaryName: Name = toDenot(sym).fullNameSeparated("/") // addModuleSuffix(fullNameInternal('/')) + def javaClassName: String = toDenot(sym).fullName.toString// addModuleSuffix(fullNameInternal('.')).toString + def name: Name = sym.name + def rawname: Name = sym.name // todo ???? + + // types + def info: Type = toDenot(sym).info + def tpe: Type = toDenot(sym).info // todo whats the differentce between tpe and info? + def thisType: Type = toDenot(sym).thisType + + // tests + def isClass: Boolean = { + sym.isPackageObject || (sym.isClass) + } + def isType: Boolean = sym.isType + def isAnonymousClass: Boolean = toDenot(sym).isAnonymousClass + def isConstructor: Boolean = toDenot(sym).isConstructor + def isAnonymousFunction: Boolean = toDenot(sym).isAnonymousFunction + def isMethod: Boolean = sym is Flags.Method + def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, Flags.Private | Flags.Protected) + def isSynthetic: Boolean = sym is Flags.Synthetic + def isPackageClass: Boolean = sym is Flags.PackageClass + def isModuleClass: Boolean = sym is Flags.ModuleClass + def isModule: Boolean = sym is Flags.Module + def isStrictFP: Boolean = false // todo: implement + def isLabel: Boolean = sym is Flags.Label + def hasPackageFlag: Boolean = sym is Flags.Package + def isImplClass: Boolean = sym is Flags.ImplClass + def isInterface: Boolean = (sym is Flags.PureInterface) || (sym is Flags.Trait) + def hasGetter: Boolean = false // used only for generaration of beaninfo todo: implement + def isGetter: Boolean = toDenot(sym).isGetter + def isSetter: Boolean = toDenot(sym).isSetter + def isGetClass: Boolean = sym eq defn.Any_getClass + def isJavaDefined: Boolean = sym is Flags.JavaDefined + def isJavaDefaultMethod: Boolean = !((sym is Flags.Deferred) || toDenot(sym).isClassConstructor) + def isDeferred: Boolean = sym is Flags.Deferred + def isPrivate: Boolean = sym is Flags.Private + def getsJavaFinalFlag: Boolean = + isFinal && !toDenot(sym).isClassConstructor && !(sym is Flags.Mutable) && !(sym.enclosingClass is Flags.Trait) + + def getsJavaPrivateFlag: Boolean = + isPrivate //|| (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass) + + def isFinal: Boolean = sym is Flags.Final + def isStaticMember: Boolean = (sym ne NoSymbol) && + ((sym is Flags.JavaStatic) || (owner is Flags.ImplClass) || toDenot(sym).hasAnnotation(ctx.definitions.ScalaStaticAnnot)) + // guard against no sumbol cause this code is executed to select which call type(static\dynamic) to use to call array.clone + + def isBottomClass: Boolean = (sym ne defn.NullClass) && (sym ne defn.NothingClass) + def isBridge: Boolean = sym is Flags.Bridge + def isArtifact: Boolean = sym is Flags.Artifact + def hasEnumFlag: Boolean = sym is Flags.Enum + def hasAccessBoundary: Boolean = sym.accessBoundary(defn.RootClass) ne defn.RootClass + def isVarargsMethod: Boolean = sym is Flags.JavaVarargs + def isDeprecated: Boolean = false + def isMutable: Boolean = sym is Flags.Mutable + def hasAbstractFlag: Boolean = + (sym is Flags.Abstract) || (sym is Flags.JavaInterface) || (sym is Flags.Trait) + def hasModuleFlag: Boolean = sym is Flags.Module + def isSynchronized: Boolean = sym is Flags.Synchronized + def isNonBottomSubClass(other: Symbol): Boolean = sym.derivesFrom(other) + def hasAnnotation(ann: Symbol): Boolean = toDenot(sym).hasAnnotation(ann) + def shouldEmitForwarders: Boolean = + (sym is Flags.Module) && !(sym is Flags.ImplClass) && sym.isStatic + def isJavaEntryPoint: Boolean = CollectEntryPoints.isJavaEntryPoint(sym) + + def isClassConstructor: Boolean = toDenot(sym).isClassConstructor + + /** + * True for module classes of modules that are top-level or owned only by objects. Module classes + * for such objects will get a MODULE$ flag and a corresponding static initializer. + */ + def isStaticModuleClass: Boolean = + (sym is Flags.Module) && { + // scalac uses atPickling here + // this would not work if modules are created after pickling + // for example by specialization + val original = toDenot(sym).initial + val validity = original.validFor + val shiftedContext = ctx.withPhase(validity.phaseId) + toDenot(sym)(shiftedContext).isStatic(shiftedContext) + } + + def isStaticConstructor: Boolean = (isStaticMember && isClassConstructor) || (sym.name eq core.Names.STATIC_CONSTRUCTOR) + + + // navigation + def owner: Symbol = toDenot(sym).owner + def rawowner: Symbol = { + originalOwner + } + def originalOwner: Symbol = + // used to populate the EnclosingMethod attribute. + // it is very tricky in presence of classes(and annonymous classes) defined inside supper calls. + if (sym.exists) { + val original = toDenot(sym).initial + val validity = original.validFor + val shiftedContext = ctx.withPhase(validity.phaseId) + val r = toDenot(sym)(shiftedContext).maybeOwner.lexicallyEnclosingClass(shiftedContext) + r + } else NoSymbol + def parentSymbols: List[Symbol] = toDenot(sym).info.parents.map(_.typeSymbol) + def superClass: Symbol = { + val t = toDenot(sym).asClass.superClass + if (t.exists) t + else if (sym is Flags.ModuleClass) { + // workaround #371 + + println(s"Warning: mocking up superclass for $sym") + ObjectClass + } + else t + } + def enclClass: Symbol = toDenot(sym).enclosingClass + def linkedClassOfClass: Symbol = linkedClass + def linkedClass: Symbol = { + toDenot(sym)(ctx).linkedClass(ctx) + } //exitingPickler(sym.linkedClassOfClass) + def companionClass: Symbol = toDenot(sym).companionClass + def companionModule: Symbol = toDenot(sym).companionModule + def companionSymbol: Symbol = if (sym is Flags.Module) companionClass else companionModule + def moduleClass: Symbol = toDenot(sym).moduleClass + def enclosingClassSym: Symbol = { + if (this.isClass) { + val ct = ctx.withPhase(ctx.flattenPhase.prev) + toDenot(sym)(ct).owner.enclosingClass(ct) + } + else sym.enclosingClass(ctx.withPhase(ctx.flattenPhase.prev)) + } //todo is handled specially for JavaDefined symbols in scalac + + + + // members + def primaryConstructor: Symbol = toDenot(sym).primaryConstructor + + /** For currently compiled classes: All locally defined classes including local classes. + * The empty list for classes that are not currently compiled. + */ + def nestedClasses: List[Symbol] = definedClasses(ctx.flattenPhase) + + /** For currently compiled classes: All classes that are declared as members of this class + * (but not inherited ones). The empty list for classes that are not currently compiled. + */ + def memberClasses: List[Symbol] = definedClasses(ctx.lambdaLiftPhase) + + private def definedClasses(phase: Phase) = + if (sym.isDefinedInCurrentRun) + ctx.atPhase(phase) { implicit ctx => + toDenot(sym).info.decls.filter(_.isClass).toList + } + else Nil + + def annotations: List[Annotation] = Nil + def companionModuleMembers: List[Symbol] = { + // phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes, + // not local classes of the companion module (E in the exmaple) that were lifted by lambdalift. + if (linkedClass.isTopLevelModuleClass) /*exitingPickler*/ linkedClass.memberClasses + else Nil + } + def fieldSymbols: List[Symbol] = { + toDenot(sym).info.decls.filter(p => p.isTerm && !p.is(Flags.Method)).toList + } + def methodSymbols: List[Symbol] = + for (f <- toDenot(sym).info.decls.toList if f.isMethod && f.isTerm && !f.isModule) yield f + def serialVUID: Option[Long] = None + + + def freshLocal(cunit: CompilationUnit, name: String, tpe: Type, pos: Position, flags: Flags): Symbol = { + ctx.newSymbol(sym, name.toTermName, FlagSet(flags), tpe, NoSymbol, pos) + } + + def getter(clz: Symbol): Symbol = decorateSymbol(sym).getter + def setter(clz: Symbol): Symbol = decorateSymbol(sym).setter + + def moduleSuffix: String = "" // todo: validate that names already have $ suffix + def outputDirectory: AbstractFile = DottyBackendInterface.this.outputDirectory + def pos: Position = sym.pos + + def throwsAnnotations: List[Symbol] = Nil + + /** + * All interfaces implemented by a class, except for those inherited through the superclass. + * Redundant interfaces are removed unless there is a super call to them. + */ + def superInterfaces: List[Symbol] = { + val directlyInheritedTraits = decorateSymbol(sym).directlyInheritedTraits + val directlyInheritedTraitsSet = directlyInheritedTraits.toSet + val allBaseClasses = directlyInheritedTraits.iterator.flatMap(_.symbol.asClass.baseClasses.drop(1)).toSet + val superCalls = superCallsMap.getOrElse(sym, Set.empty) + val additional = (superCalls -- directlyInheritedTraitsSet).filter(_.is(Flags.Trait)) +// if (additional.nonEmpty) +// println(s"$fullName: adding supertraits $additional") + directlyInheritedTraits.filter(t => !allBaseClasses(t) || superCalls(t)) ++ additional + } + + /** + * True for module classes of package level objects. The backend will generate a mirror class for + * such objects. + */ + def isTopLevelModuleClass: Boolean = sym.isModuleClass && sym.isStatic + + /** + * This is basically a re-implementation of sym.isStaticOwner, but using the originalOwner chain. + * + * The problem is that we are interested in a source-level property. Various phases changed the + * symbol's properties in the meantime, mostly lambdalift modified (destructively) the owner. + * Therefore, `sym.isStatic` is not what we want. For example, in + * object T { def f { object U } } + * the owner of U is T, so UModuleClass.isStatic is true. Phase travel does not help here. + */ + def isOriginallyStaticOwner: Boolean = sym.isStatic + + + def addRemoteRemoteExceptionAnnotation: Unit = () + + def samMethod(): Symbol = + toDenot(sym).info.abstractTermMembers.headOption.getOrElse(toDenot(sym).info.member(nme.apply)).symbol + } + + + implicit def typeHelper(tp: Type): TypeHelper = new TypeHelper { + def member(string: Name): Symbol = tp.member(string.toTermName).symbol + + def isFinalType: Boolean = tp.typeSymbol is Flags.Final //in scalac checks for type parameters. Why? Aren't they gone by backend? + + def underlying: Type = tp match { + case t: TypeProxy => t.underlying + case _ => tp + } + + def paramTypes: List[Type] = tp.firstParamTypes + + def <:<(other: Type): Boolean = tp <:< other + + def memberInfo(s: Symbol): Type = tp.memberInfo(s) + + def decls: List[Symbol] = tp.decls.map(_.symbol).toList + + def members: List[Symbol] = + tp.memberDenots(takeAllFilter, (name, buf) => buf ++= tp.member(name).alternatives).map(_.symbol).toList + + def typeSymbol: Symbol = tp.widenDealias.typeSymbol + + def =:=(other: Type): Boolean = tp =:= other + + def membersBasedOnFlags(excludedFlags: Flags, requiredFlags: Flags): List[Symbol] = + tp.membersBasedOnFlags(FlagSet(requiredFlags), FlagSet(excludedFlags)).map(_.symbol).toList + + def resultType: Type = tp.resultType + + def toTypeKind(ct: BCodeHelpers)(storage: ct.BCInnerClassGen): ct.bTypes.BType = { + import ct.bTypes._ + val defn = ctx.definitions + import coreBTypes._ + import Types._ + /** + * Primitive types are represented as TypeRefs to the class symbol of, for example, scala.Int. + * The `primitiveTypeMap` maps those class symbols to the corresponding PrimitiveBType. + */ + def primitiveOrClassToBType(sym: Symbol): BType = { + assert(sym.isClass, sym) + assert(sym != ArrayClass || isCompilingArray, sym) + primitiveTypeMap.getOrElse(sym.asInstanceOf[ct.bTypes.coreBTypes.bTypes.int.Symbol], + storage.getClassBTypeAndRegisterInnerClass(sym.asInstanceOf[ct.int.Symbol])).asInstanceOf[BType] + } + + /** + * When compiling Array.scala, the type parameter T is not erased and shows up in method + * signatures, e.g. `def apply(i: Int): T`. A TyperRef to T is replaced by ObjectReference. + */ + def nonClassTypeRefToBType(sym: Symbol): ClassBType = { + assert(sym.isType && isCompilingArray, sym) + ObjectReference.asInstanceOf[ct.bTypes.ClassBType] + } + + tp.widenDealias match { + case JavaArrayType(el) =>ArrayBType(el.toTypeKind(ct)(storage)) // Array type such as Array[Int] (kept by erasure) + case t: TypeRef => + t.info match { + + case _ => + if (!t.symbol.isClass) nonClassTypeRefToBType(t.symbol) // See comment on nonClassTypeRefToBType + else primitiveOrClassToBType(t.symbol) // Common reference to a type such as scala.Int or java.lang.String + } + case Types.ClassInfo(_, sym, _, _, _) => primitiveOrClassToBType(sym) // We get here, for example, for genLoadModule, which invokes toTypeKind(moduleClassSymbol.info) + + case t: MethodType => // triggers for LabelDefs + t.resultType.toTypeKind(ct)(storage) + + /* AnnotatedType should (probably) be eliminated by erasure. However we know it happens for + * meta-annotated annotations (@(ann @getter) val x = 0), so we don't emit a warning. + * The type in the AnnotationInfo is an AnnotatedTpe. Tested in jvm/annotations.scala. + */ + case a @ AnnotatedType(t, _) => + debuglog(s"typeKind of annotated type $a") + t.toTypeKind(ct)(storage) + + /* ExistentialType should (probably) be eliminated by erasure. We know they get here for + * classOf constants: + * class C[T] + * class T { final val k = classOf[C[_]] } + */ + /* case e @ ExistentialType(_, t) => + debuglog(s"typeKind of existential type $e") + t.toTypeKind(ctx)(storage)*/ + + /* The cases below should probably never occur. They are kept for now to avoid introducing + * new compiler crashes, but we added a warning. The compiler / library bootstrap and the + * test suite don't produce any warning. + */ + + case tp => + ctx.warning( + s"an unexpected type representation reached the compiler backend while compiling $currentUnit: $tp. " + + "If possible, please file a bug on issues.scala-lang.org.") + + tp match { + case tp: ThisType if tp.cls == ArrayClass => ObjectReference.asInstanceOf[ct.bTypes.ClassBType] // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test + case tp: ThisType => storage.getClassBTypeAndRegisterInnerClass(tp.cls.asInstanceOf[ct.int.Symbol]) + // case t: SingletonType => primitiveOrClassToBType(t.classSymbol) + case t: SingletonType => t.underlying.toTypeKind(ct)(storage) + case t: RefinedType => t.parent.toTypeKind(ct)(storage) //parents.map(_.toTypeKind(ct)(storage).asClassBType).reduceLeft((a, b) => a.jvmWiseLUB(b)) + } + } + } + + def summaryString: String = tp.showSummary + + def params: List[Symbol] = + Nil // backend uses this to emmit annotations on parameter lists of forwarders + // to static methods of companion class + // in Dotty this link does not exists: there is no way to get from method type + // to inner symbols of DefDef + // todo: somehow handle. + + def parents: List[Type] = tp.parents + } + + + + object Assign extends AssignDeconstructor { + def _1: Tree = field.lhs + def _2: Tree = field.rhs + } + + object Select extends SelectDeconstructor { + + var desugared: tpd.Select = null + + override def isEmpty: Boolean = + desugared eq null + + def _1: Tree = desugared.qualifier + + def _2: Name = desugared.name + + override def unapply(s: Select): this.type = { + s match { + case t: tpd.Select => desugared = t + case t: Ident => + desugarIdent(t) match { + case Some(t) => desugared = t + case None => desugared = null + } + case _ => desugared = null + } + + this + } + } + + object Apply extends ApplyDeconstructor { + def _1: Tree = field.fun + def _2: List[Tree] = field.args + } + + object If extends IfDeconstructor { + def _1: Tree = field.cond + def _2: Tree = field.thenp + def _3: Tree = field.elsep + } + + object ValDef extends ValDefDeconstructor { + def _1: Modifiers = null + def _2: Name = field.name + def _3: Tree = field.tpt + def _4: Tree = field.rhs + } + + object ApplyDynamic extends ApplyDynamicDeconstructor { + def _1: Tree = ??? + def _2: List[Tree] = ??? + } + + // todo: this product1s should also eventually become name-based pattn matching + object Literal extends LiteralDeconstructor { + def get = field.const + } + + object Throw extends ThrowDeconstructor { + def get = field.args.head + + override def unapply(s: Throw): DottyBackendInterface.this.Throw.type = { + if (s.fun.symbol eq defn.throwMethod) { + field = s + } else { + field = null + } + this + } + } + + object New extends NewDeconstructor { + def get = field.tpt.tpe + } + + object This extends ThisDeconstructor { + def get = field.qual.name + def apply(s: Symbol): This = tpd.This(s.asClass) + } + + object Return extends ReturnDeconstructor { + def get = field.expr + } + + object Ident extends IdentDeconstructor { + def get = field.name + } + + object Alternative extends AlternativeDeconstructor { + def get = field.trees + } + + object Constant extends ConstantDeconstructor { + def get = field.value + } + object ThrownException extends ThrownException { + def unapply(a: Annotation): Option[Symbol] = None // todo + } + + object Try extends TryDeconstructor { + def _1: Tree = field.expr + def _2: List[Tree] = field.cases + def _3: Tree = field.finalizer + } + + object LabelDef extends LabelDeconstructor { + def _1: Name = field.name + def _2: List[Symbol] = field.vparamss.flatMap(_.map(_.symbol)) + def _3: Tree = field.rhs + + override def unapply(s: LabelDef): DottyBackendInterface.this.LabelDef.type = { + if (s.symbol is Flags.Label) this.field = s + else this.field = null + this + } + } + + object Typed extends TypedDeconstrutor { + def _1: Tree = field.expr + def _2: Tree = field.tpt + } + object Super extends SuperDeconstructor { + def _1: Tree = field.qual + def _2: Name = field.mix.name + } + object ArrayValue extends ArrayValueDeconstructor { + def _1: Type = field.tpe match { + case JavaArrayType(elem) => elem + case _ => + ctx.error(s"JavaSeqArray with type ${field.tpe} reached backend: $field", field.pos) + ErrorType + } + def _2: List[Tree] = field.elems + } + object Match extends MatchDeconstructor { + def _1: Tree = field.selector + def _2: List[Tree] = field.cases + } + object Block extends BlockDeconstructor { + def _1: List[Tree] = field.stats + def _2: Tree = field.expr + } + object TypeApply extends TypeApplyDeconstructor { + def _1: Tree = field.fun + def _2: List[Tree] = field.args + } + object CaseDef extends CaseDeconstructor { + def _1: Tree = field.pat + def _2: Tree = field.guard + def _3: Tree = field.body + } + + object DefDef extends DefDefDeconstructor { + def _1: Modifiers = null + def _2: Name = field.name + def _3: List[TypeDef] = field.tparams + def _4: List[List[ValDef]] = field.vparamss + def _5: Tree = field.tpt + def _6: Tree = field.rhs + } + + object ModuleDef extends ModuleDefDeconstructor { + def _1: Modifiers = ??? + def _2: Name = ??? + def _3: Tree = ??? + } + + object Template extends TemplateDeconstructor { + def _1: List[Tree] = field.parents + def _2: ValDef = field.self + def _3: List[Tree] = field.constr :: field.body + } + + object Bind extends BindDeconstructor { + def _1: Name = field.name + def _2: Tree = field.body + } + + object ClassDef extends ClassDefDeconstructor { + def _1: Modifiers = null + def _2: Name = field.name + def _4: Template = field.rhs.asInstanceOf[Template] + def _3: List[TypeDef] = Nil + } + + object Closure extends ClosureDeconstructor { + def _1 = field.env + def _2 = field.meth + def _3 = { + val t = field.tpt.tpe.typeSymbol + if (t.exists) t + else { + val arity = field.meth.tpe.widenDealias.paramTypes.size - _1.size + val returnsUnit = field.meth.tpe.widenDealias.resultType.classSymbol == UnitClass + if (returnsUnit) + ctx.requiredClass(("scala.compat.java8.JProcedure" + arity).toTermName) + else ctx.requiredClass(("scala.compat.java8.JFunction" + arity).toTermName) + } + } + } + + def currentUnit = ctx.compilationUnit +} diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala new file mode 100644 index 000000000..65dcb6c79 --- /dev/null +++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala @@ -0,0 +1,433 @@ +package dotty.tools.backend.jvm + +import dotty.tools.dotc.CompilationUnit +import dotty.tools.dotc.ast.Trees.{ValDef, PackageDef} +import dotty.tools.dotc.ast.tpd +import dotty.tools.dotc.core.Phases.Phase +import dotty.tools.dotc.core.Names.TypeName + +import scala.collection.mutable +import scala.tools.asm.{CustomAttr, ClassVisitor, MethodVisitor, FieldVisitor} +import scala.tools.nsc.Settings +import scala.tools.nsc.backend.jvm._ +import dotty.tools.dotc +import dotty.tools.dotc.backend.jvm.DottyPrimitives +import dotty.tools.dotc.transform.Erasure + +import dotty.tools.dotc.interfaces +import java.util.Optional + +import scala.reflect.ClassTag +import dotty.tools.dotc.core._ +import Periods._ +import SymDenotations._ +import Contexts._ +import Types._ +import Symbols._ +import Denotations._ +import Phases._ +import java.lang.AssertionError +import java.io.{ File => JFile } +import scala.tools.asm +import scala.tools.asm.tree._ +import dotty.tools.dotc.util.{Positions, DotClass} +import tpd._ +import StdNames._ +import scala.reflect.io.{Directory, PlainDirectory, AbstractFile} + +import scala.tools.nsc.backend.jvm.opt.LocalOpt + +class GenBCode extends Phase { + def phaseName: String = "genBCode" + private val entryPoints = new mutable.HashSet[Symbol]() + def registerEntryPoint(sym: Symbol) = entryPoints += sym + + private val superCallsMap = new mutable.HashMap[Symbol, Set[ClassSymbol]]() + def registerSuperCall(sym: Symbol, calls: ClassSymbol) = { + val old = superCallsMap.getOrElse(sym, Set.empty) + superCallsMap.put(sym, old + calls) + } + + def outputDir(implicit ctx: Context): AbstractFile = + new PlainDirectory(new Directory(new JFile(ctx.settings.d.value))) + + def run(implicit ctx: Context): Unit = { + new GenBCodePipeline(entryPoints.toList, + new DottyBackendInterface(outputDir, superCallsMap.toMap)(ctx))(ctx).run(ctx.compilationUnit.tpdTree) + entryPoints.clear() + } +} + +class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInterface)(implicit val ctx: Context) extends BCodeSyncAndTry{ + + var tree: Tree = _ + + val sourceFile = ctx.compilationUnit.source + + /** Convert a `scala.reflect.io.AbstractFile` into a + * `dotty.tools.dotc.interfaces.AbstractFile`. + */ + private[this] def convertAbstractFile(absfile: scala.reflect.io.AbstractFile): interfaces.AbstractFile = + new interfaces.AbstractFile { + override def name = absfile.name + override def path = absfile.path + override def jfile = Optional.ofNullable(absfile.file) + } + + final class PlainClassBuilder(cunit: CompilationUnit) extends SyncAndTryBuilder(cunit) + + +// class BCodePhase() { + + private var bytecodeWriter : BytecodeWriter = null + private var mirrorCodeGen : JMirrorBuilder = null + private var beanInfoCodeGen : JBeanInfoBuilder = null + + /* ---------------- q1 ---------------- */ + + case class Item1(arrivalPos: Int, cd: TypeDef, cunit: CompilationUnit) { + def isPoison = { arrivalPos == Int.MaxValue } + } + private val poison1 = Item1(Int.MaxValue, null, ctx.compilationUnit) + private val q1 = new java.util.LinkedList[Item1] + + /* ---------------- q2 ---------------- */ + + case class Item2(arrivalPos: Int, + mirror: asm.tree.ClassNode, + plain: asm.tree.ClassNode, + bean: asm.tree.ClassNode, + outFolder: scala.tools.nsc.io.AbstractFile) { + def isPoison = { arrivalPos == Int.MaxValue } + } + + private val poison2 = Item2(Int.MaxValue, null, null, null, null) + private val q2 = new _root_.java.util.LinkedList[Item2] + + /* ---------------- q3 ---------------- */ + + /* + * An item of queue-3 (the last queue before serializing to disk) contains three of these + * (one for each of mirror, plain, and bean classes). + * + * @param jclassName internal name of the class + * @param jclassBytes bytecode emitted for the class SubItem3 represents + */ + case class SubItem3( + jclassName: String, + jclassBytes: Array[Byte] + ) + + case class Item3(arrivalPos: Int, + mirror: SubItem3, + plain: SubItem3, + bean: SubItem3, + outFolder: scala.tools.nsc.io.AbstractFile) { + + def isPoison = { arrivalPos == Int.MaxValue } + } + private val i3comparator = new java.util.Comparator[Item3] { + override def compare(a: Item3, b: Item3) = { + if (a.arrivalPos < b.arrivalPos) -1 + else if (a.arrivalPos == b.arrivalPos) 0 + else 1 + } + } + private val poison3 = Item3(Int.MaxValue, null, null, null, null) + private val q3 = new java.util.PriorityQueue[Item3](1000, i3comparator) + + /* + * Pipeline that takes ClassDefs from queue-1, lowers them into an intermediate form, placing them on queue-2 + */ + class Worker1(needsOutFolder: Boolean) { + + val caseInsensitively = scala.collection.mutable.Map.empty[String, Symbol] + + def run(): Unit = { + while (true) { + val item = q1.poll + if (item.isPoison) { + q2 add poison2 + return + } + else { + try { /*withCurrentUnit(item.cunit)*/(visit(item)) } + catch { + case ex: Throwable => + ex.printStackTrace() + ctx.error(s"Error while emitting ${int.sourceFileFor(item.cunit)}\n${ex.getMessage}") + } + } + } + } + + /* + * Checks for duplicate internal names case-insensitively, + * builds ASM ClassNodes for mirror, plain, and bean classes; + * enqueues them in queue-2. + * + */ + def visit(item: Item1) = { + val Item1(arrivalPos, cd, cunit) = item + val claszSymbol = cd.symbol + + // GenASM checks this before classfiles are emitted, https://github.com/scala/scala/commit/e4d1d930693ac75d8eb64c2c3c69f2fc22bec739 + // todo: add back those checks + /*val lowercaseJavaClassName = claszSymbol.javaClassName.toLowerCase + caseInsensitively.get(lowercaseJavaClassName) match { + case None => + caseInsensitively.put(lowercaseJavaClassName, claszSymbol) + case Some(dupClassSym) => + reporter.warning( + claszSymbol.pos, + s"Class ${claszSymbol.javaClassName} differs only in case from ${dupClassSym.javaClassName}. " + + "Such classes will overwrite one another on case-insensitive filesystems." + ) + }*/ + + // -------------- mirror class, if needed -------------- + val mirrorC = + if (int.symHelper(claszSymbol).isTopLevelModuleClass) { + if (claszSymbol.companionClass == NoSymbol) { + mirrorCodeGen.genMirrorClass(claszSymbol, cunit) + } else { + ctx.log(s"No mirror class for module with linked class: ${claszSymbol.fullName}") + null + } + } else null + + // -------------- "plain" class -------------- + val pcb = new PlainClassBuilder(cunit) + pcb.genPlainClass(cd) + val outF = if (needsOutFolder) getOutFolder(claszSymbol, pcb.thisName) else null; + val plainC = pcb.cnode + + if (claszSymbol.isClass) // @DarkDimius is this test needed here? + for (binary <- ctx.compilationUnit.pickled.get(claszSymbol.asClass)) { + val dataAttr = new CustomAttr(nme.TASTYATTR.toString, binary) + (if (mirrorC ne null) mirrorC else plainC).visitAttribute(dataAttr) + } + + // -------------- bean info class, if needed -------------- + val beanC = + if (claszSymbol hasAnnotation int.BeanInfoAttr) { + beanInfoCodeGen.genBeanInfoClass( + claszSymbol, cunit, + int.symHelper(claszSymbol).fieldSymbols, + int.symHelper(claszSymbol).methodSymbols + ) + } else null + + // ----------- hand over to pipeline-2 + + val item2 = + Item2(arrivalPos, + mirrorC, plainC, beanC, + outF) + + q2 add item2 // at the very end of this method so that no Worker2 thread starts mutating before we're done. + + } // end of method visit(Item1) + + } // end of class BCodePhase.Worker1 + + /* + * Pipeline that takes ClassNodes from queue-2. The unit of work depends on the optimization level: + * + * (a) no optimization involves: + * - converting the plain ClassNode to byte array and placing it on queue-3 + */ + class Worker2 { + lazy val localOpt = new LocalOpt(new Settings()) + + def localOptimizations(classNode: ClassNode): Unit = { + /*BackendStats.timed(BackendStats.methodOptTimer)*/(localOpt.methodOptimizations(classNode)) + } + + def run(): Unit = { + while (true) { + val item = q2.poll + if (item.isPoison) { + q3 add poison3 + return + } + else { + try { + localOptimizations(item.plain) + addToQ3(item) + } catch { + case ex: Throwable => + ex.printStackTrace() + ctx.error(s"Error while emitting ${item.plain.name}\n${ex.getMessage}") + } + } + } + } + + private def addToQ3(item: Item2) = { + + def getByteArray(cn: asm.tree.ClassNode): Array[Byte] = { + val cw = new CClassWriter(extraProc) + cn.accept(cw) + cw.toByteArray + } + + val Item2(arrivalPos, mirror, plain, bean, outFolder) = item + + val mirrorC = if (mirror == null) null else SubItem3(mirror.name, getByteArray(mirror)) + val plainC = SubItem3(plain.name, getByteArray(plain)) + val beanC = if (bean == null) null else SubItem3(bean.name, getByteArray(bean)) + + if (AsmUtils.traceSerializedClassEnabled && plain.name.contains(AsmUtils.traceSerializedClassPattern)) { + if (mirrorC != null) AsmUtils.traceClass(mirrorC.jclassBytes) + AsmUtils.traceClass(plainC.jclassBytes) + if (beanC != null) AsmUtils.traceClass(beanC.jclassBytes) + } + + q3 add Item3(arrivalPos, mirrorC, plainC, beanC, outFolder) + + } + + } // end of class BCodePhase.Worker2 + + var arrivalPos = 0 + + /* + * A run of the BCodePhase phase comprises: + * + * (a) set-up steps (most notably supporting maps in `BCodeTypes`, + * but also "the" writer where class files in byte-array form go) + * + * (b) building of ASM ClassNodes, their optimization and serialization. + * + * (c) tear down (closing the classfile-writer and clearing maps) + * + */ + def run(t: Tree) = { + this.tree = t + + // val bcodeStart = Statistics.startTimer(BackendStats.bcodeTimer) + + // val initStart = Statistics.startTimer(BackendStats.bcodeInitTimer) + arrivalPos = 0 // just in case + // scalaPrimitives.init() + bTypes.intializeCoreBTypes() + // Statistics.stopTimer(BackendStats.bcodeInitTimer, initStart) + + // initBytecodeWriter invokes fullName, thus we have to run it before the typer-dependent thread is activated. + bytecodeWriter = initBytecodeWriter(entryPoints) + mirrorCodeGen = new JMirrorBuilder + beanInfoCodeGen = new JBeanInfoBuilder + + val needsOutfileForSymbol = bytecodeWriter.isInstanceOf[ClassBytecodeWriter] + buildAndSendToDisk(needsOutfileForSymbol) + + // closing output files. + bytecodeWriter.close() + // Statistics.stopTimer(BackendStats.bcodeTimer, bcodeStart) + + if (ctx.compilerCallback != null) + ctx.compilerCallback.onSourceCompiled(sourceFile) + + /* TODO Bytecode can be verified (now that all classfiles have been written to disk) + * + * (1) asm.util.CheckAdapter.verify() + * public static void verify(ClassReader cr, ClassLoader loader, boolean dump, PrintWriter pw) + * passing a custom ClassLoader to verify inter-dependent classes. + * Alternatively, + * - an offline-bytecode verifier could be used (e.g. Maxine brings one as separate tool). + * - -Xverify:all + * + * (2) if requested, check-java-signatures, over and beyond the syntactic checks in `getGenericSignature()` + * + */ + } + + /* + * Sequentially: + * (a) place all ClassDefs in queue-1 + * (b) dequeue one at a time from queue-1, convert it to ASM ClassNode, place in queue-2 + * (c) dequeue one at a time from queue-2, convert it to byte-array, place in queue-3 + * (d) serialize to disk by draining queue-3. + */ + private def buildAndSendToDisk(needsOutFolder: Boolean) = { + + feedPipeline1() + // val genStart = Statistics.startTimer(BackendStats.bcodeGenStat) + (new Worker1(needsOutFolder)).run() + // Statistics.stopTimer(BackendStats.bcodeGenStat, genStart) + + (new Worker2).run() + + // val writeStart = Statistics.startTimer(BackendStats.bcodeWriteTimer) + drainQ3() + // Statistics.stopTimer(BackendStats.bcodeWriteTimer, writeStart) + + } + + /* Feed pipeline-1: place all ClassDefs on q1, recording their arrival position. */ + private def feedPipeline1() = { + def gen(tree: Tree): Unit = { + tree match { + case EmptyTree => () + case PackageDef(_, stats) => stats foreach gen + case ValDef(name, tpt, rhs) => () // module val not emitted + case cd: TypeDef => + q1 add Item1(arrivalPos, cd, int.currentUnit) + arrivalPos += 1 + } + } + gen(tree) + q1 add poison1 + } + + /* Pipeline that writes classfile representations to disk. */ + private def drainQ3() = { + + def sendToDisk(cfr: SubItem3, outFolder: scala.tools.nsc.io.AbstractFile): Unit = { + if (cfr != null){ + val SubItem3(jclassName, jclassBytes) = cfr + try { + val outFile = + if (outFolder == null) null + else getFileForClassfile(outFolder, jclassName, ".class") + bytecodeWriter.writeClass(jclassName, jclassName, jclassBytes, outFile) + + val className = jclassName.replace('/', '.') + if (ctx.compilerCallback != null) + ctx.compilerCallback.onClassGenerated(sourceFile, convertAbstractFile(outFile), className) + if (ctx.sbtCallback != null) + ctx.sbtCallback.generatedClass(sourceFile.jfile.orElse(null), outFile.file, className) + } + catch { + case e: FileConflictException => + ctx.error(s"error writing $jclassName: ${e.getMessage}") + } + } + } + + var moreComing = true + // `expected` denotes the arrivalPos whose Item3 should be serialized next + var expected = 0 + + while (moreComing) { + val incoming = q3.poll + moreComing = !incoming.isPoison + if (moreComing) { + val item = incoming + val outFolder = item.outFolder + sendToDisk(item.mirror, outFolder) + sendToDisk(item.plain, outFolder) + sendToDisk(item.bean, outFolder) + expected += 1 + } + } + + // we're done + assert(q1.isEmpty, s"Some ClassDefs remained in the first queue: $q1") + assert(q2.isEmpty, s"Some classfiles remained in the second queue: $q2") + assert(q3.isEmpty, s"Some classfiles weren't written to disk: $q3") + + } + //} // end of class BCodePhase +} diff --git a/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala b/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala new file mode 100644 index 000000000..371396e36 --- /dev/null +++ b/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala @@ -0,0 +1,223 @@ +package dotty.tools.backend.jvm + +import dotty.tools.dotc.ast.Trees.Thicket +import dotty.tools.dotc.ast.{Trees, tpd} +import dotty.tools.dotc.core.Contexts.Context +import dotty.tools.dotc.core.Types +import dotty.tools.dotc.transform.TreeTransforms.{TransformerInfo, TreeTransform, MiniPhase, MiniPhaseTransform} +import dotty.tools.dotc +import dotty.tools.dotc.backend.jvm.DottyPrimitives +import dotty.tools.dotc.core.Flags.FlagSet +import dotty.tools.dotc.transform.Erasure +import dotty.tools.dotc.transform.SymUtils._ +import java.io.{File => JFile} + +import scala.collection.generic.Clearable +import scala.collection.mutable +import scala.collection.mutable.{ListBuffer, ArrayBuffer} +import scala.reflect.ClassTag +import scala.reflect.internal.util.WeakHashSet +import scala.reflect.io.{Directory, PlainDirectory, AbstractFile} +import scala.tools.asm.{ClassVisitor, FieldVisitor, MethodVisitor} +import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface} +import dotty.tools.dotc.core._ +import Periods._ +import SymDenotations._ +import Contexts._ +import Types._ +import Symbols._ +import Denotations._ +import Phases._ +import java.lang.AssertionError +import dotty.tools.dotc.util.Positions.Position +import Decorators._ +import tpd._ +import Flags._ +import StdNames.nme + +/** + * Verifies that each Label DefDef has only a single address to jump back and + * reorders them such that they are not nested and this address is a fall-through address for JVM + * + * ei such code + * + * + *