1 /*
2  * sys-emu - A system emulator for tutorials
3  * Copyright (C) 2018 - 2019 osdevelopment-info
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18 
19 package info.osdevelopment.sysemu.processor
20 
21 import java.util.ServiceLoader
22 
23 import scala.jdk.CollectionConverters._
24 
25 object ProcessorDescriptor {
26 
27   def loadProcessors(): Iterable[ProcessorDescriptor] = {
28     ServiceLoader.load(classOf[ProcessorDescriptor]).asScala
29   }
30 
31   def loadProcessor(name: String): Option[ProcessorDescriptor] = {
32     ServiceLoader.load(classOf[ProcessorDescriptor]).asScala.find(_.name == name)
33   }
34 
35 }
36 
37 /**
38   * <p>An abstract description of a processor usable in a system. This descriptor only contains the very basic data of
39   * the processor and offers a possibility to create a processor to be added to a system.</p>
40   * <p>This class is used to find automatically new processor descriptions via a ServiceLoader.</p>
41   * @param name the name of the processor (e.g. "8086" or "68000").
42   * @param maxMemory the maximum memory that this processor can access.
43   * @param romName the proposed resource name for a ROM to be used by the processor.
44   */
45 abstract class ProcessorDescriptor (val name: String,
46                                     val maxMemory: Long,
47                                     val romName: String) {
48 
49   def createProcessor: Processor
50 
51 }
Line Stmt Id Pos Tree Symbol Code
28 324 982 - 1038 Select scala.collection.convert.AsScalaExtensions.IterableHasAsScala.asScala scala.jdk.CollectionConverters.IterableHasAsScala[info.osdevelopment.sysemu.processor.ProcessorDescriptor](java.util.ServiceLoader.load[info.osdevelopment.sysemu.processor.ProcessorDescriptor](classOf[info.osdevelopment.sysemu.processor.ProcessorDescriptor])).asScala
28 323 982 - 1030 Apply java.util.ServiceLoader.load java.util.ServiceLoader.load[info.osdevelopment.sysemu.processor.ProcessorDescriptor](classOf[info.osdevelopment.sysemu.processor.ProcessorDescriptor])
32 325 1115 - 1163 Apply java.util.ServiceLoader.load java.util.ServiceLoader.load[info.osdevelopment.sysemu.processor.ProcessorDescriptor](classOf[info.osdevelopment.sysemu.processor.ProcessorDescriptor])
32 327 1115 - 1192 Apply scala.collection.IterableOnceOps.find scala.jdk.CollectionConverters.IterableHasAsScala[info.osdevelopment.sysemu.processor.ProcessorDescriptor](java.util.ServiceLoader.load[info.osdevelopment.sysemu.processor.ProcessorDescriptor](classOf[info.osdevelopment.sysemu.processor.ProcessorDescriptor])).asScala.find(((x$1: info.osdevelopment.sysemu.processor.ProcessorDescriptor) => x$1.name.==(name)))
32 326 1177 - 1191 Apply java.lang.Object.== x$1.name.==(name)