initial commit: overall class structure and small maven-compatible tornadofx app
This commit is contained in:
96
.gitignore
vendored
Normal file
96
.gitignore
vendored
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### Maven template
|
||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
|
||||||
|
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
|
||||||
|
!/.mvn/wrapper/maven-wrapper.jar
|
||||||
|
### Kotlin template
|
||||||
|
# Compiled class file
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-debug/
|
||||||
|
cmake-build-release/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
### Java template
|
||||||
|
# Compiled class file
|
||||||
|
# Log file
|
||||||
|
# BlueJ files
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
# Package Files #
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
18
.idea/compiler.xml
generated
Normal file
18
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="befunge" />
|
||||||
|
<module name="ide" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="befunge" target="1.5" />
|
||||||
|
<module name="ide" target="1.5" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/cssdialects.xml
generated
Normal file
6
.idea/cssdialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CssDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/ide/src/main/resources/befide/ide/style.css" dialect="CLASSIC" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/encodings.xml
generated
Normal file
7
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/befunge" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/ide" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/kotlinc.xml
generated
Normal file
6
.idea/kotlinc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Kotlin2JvmCompilerArguments">
|
||||||
|
<option name="jvmTarget" value="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
14
.idea/misc.xml
generated
Normal file
14
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/befunge/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/ide/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
.idea/modules.xml
generated
Normal file
10
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/befunge/befunge.iml" filepath="$PROJECT_DIR$/befunge/befunge.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/ide/ide.iml" filepath="$PROJECT_DIR$/ide/ide.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/kotlin-befide.iml" filepath="$PROJECT_DIR$/kotlin-befide.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# befide
|
||||||
|
|
||||||
|
Befunge Interpreter and IDE implemented in Kotlin with TornadoFX
|
||||||
43
befunge/befunge.iml
Normal file
43
befunge/befunge.iml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
|
||||||
|
<compilerSettings />
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="jvmTarget" value="1.8" />
|
||||||
|
<option name="languageVersion" value="1.3" />
|
||||||
|
<option name="apiVersion" value="1.3" />
|
||||||
|
<option name="pluginOptions">
|
||||||
|
<array />
|
||||||
|
</option>
|
||||||
|
<option name="pluginClasspaths">
|
||||||
|
<array />
|
||||||
|
</option>
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../ide/src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<content url="file://$MODULE_DIR$/../ide/src/main/resources" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-junit:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-common:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
71
befunge/pom.xml
Normal file
71
befunge/pom.xml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>befide</groupId>
|
||||||
|
<artifactId>befunge</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>befide befunge</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<kotlin.version>1.3.0</kotlin.version>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
|
<!--<testSourceDirectory>src/test/kotlin</testSourceDirectory>-->
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
26
befunge/src/main/kotlin/befide/befunge/b93/B93Funge.kt
Normal file
26
befunge/src/main/kotlin/befide/befunge/b93/B93Funge.kt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package befide.befunge.b93
|
||||||
|
|
||||||
|
import befide.befunge.core.*
|
||||||
|
import befide.befunge.state.*
|
||||||
|
|
||||||
|
class B93Funge : Funge {
|
||||||
|
override val width = 80
|
||||||
|
override val height = 25
|
||||||
|
|
||||||
|
override fun get(vec: Vec): Value {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun set(vec: Vec, value: Value) {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun nextVec(vec: Vec, delta: Vec): Vec {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setString(data: String) {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
29
befunge/src/main/kotlin/befide/befunge/b93/B93Interpreter.kt
Normal file
29
befunge/src/main/kotlin/befide/befunge/b93/B93Interpreter.kt
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package befide.befunge.b93
|
||||||
|
|
||||||
|
import befide.befunge.core.Interpreter
|
||||||
|
import befide.befunge.events.Event
|
||||||
|
import befide.befunge.events.FungeEvent
|
||||||
|
import befide.befunge.events.IpEvent
|
||||||
|
import befide.befunge.events.StackEvent
|
||||||
|
import befide.befunge.state.IpMode
|
||||||
|
import befide.befunge.state.Value
|
||||||
|
import befide.befunge.state.Vec
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class B93Interpreter : Interpreter {
|
||||||
|
override val funge = B93Funge()
|
||||||
|
override val stack = Stack<Value>()
|
||||||
|
override val ip = B93Pointer(Vec(0, 0), Vec(1, 0), IpMode.Normal)
|
||||||
|
|
||||||
|
override val fungeChanged: Event<FungeEvent> = Event()
|
||||||
|
override val stackChanged: Event<StackEvent> = Event()
|
||||||
|
override val ipChanged: Event<IpEvent> = Event()
|
||||||
|
|
||||||
|
override fun step(): Boolean {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun reset() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
7
befunge/src/main/kotlin/befide/befunge/b93/B93Pointer.kt
Normal file
7
befunge/src/main/kotlin/befide/befunge/b93/B93Pointer.kt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package befide.befunge.b93
|
||||||
|
|
||||||
|
import befide.befunge.core.Pointer
|
||||||
|
import befide.befunge.state.IpMode
|
||||||
|
import befide.befunge.state.Vec
|
||||||
|
|
||||||
|
data class B93Pointer(override val pos: Vec, override val delta: Vec, override val mode: IpMode) : Pointer
|
||||||
33
befunge/src/main/kotlin/befide/befunge/core/Funge.kt
Normal file
33
befunge/src/main/kotlin/befide/befunge/core/Funge.kt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package befide.befunge.core
|
||||||
|
|
||||||
|
import befide.befunge.events.Event
|
||||||
|
import befide.befunge.events.FungeEvent
|
||||||
|
import befide.befunge.state.Value
|
||||||
|
import befide.befunge.state.Vec
|
||||||
|
|
||||||
|
interface Funge {
|
||||||
|
val width: Int
|
||||||
|
val height: Int
|
||||||
|
|
||||||
|
operator fun get(vec: Vec): Value
|
||||||
|
operator fun set(vec: Vec, value: Value)
|
||||||
|
|
||||||
|
fun nextVec(vec: Vec, delta: Vec): Vec
|
||||||
|
|
||||||
|
fun setString(data: String)
|
||||||
|
|
||||||
|
fun nextVecs(vec: Vec, delta: Vec): Iterable<Vec> {
|
||||||
|
return generateSequence(vec) {
|
||||||
|
nextVec(it, delta)
|
||||||
|
}.asIterable()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setMany(vec: Vec, delta: Vec, data: List<Value>) {
|
||||||
|
for ((e, v) in data.zip(nextVecs(vec, delta)))
|
||||||
|
set(v, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getMany(vec: Vec, delta: Vec, count: Int): Iterable<Value> {
|
||||||
|
return nextVecs(vec, delta).take(count).map(this::get).asIterable()
|
||||||
|
}
|
||||||
|
}
|
||||||
22
befunge/src/main/kotlin/befide/befunge/core/Interpreter.kt
Normal file
22
befunge/src/main/kotlin/befide/befunge/core/Interpreter.kt
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package befide.befunge.core
|
||||||
|
|
||||||
|
import befide.befunge.events.Event
|
||||||
|
import befide.befunge.events.FungeEvent
|
||||||
|
import befide.befunge.events.IpEvent
|
||||||
|
import befide.befunge.events.StackEvent
|
||||||
|
import befide.befunge.state.Value
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
interface Interpreter {
|
||||||
|
val funge: Funge
|
||||||
|
val stack: Stack<Value>
|
||||||
|
val ip: Pointer
|
||||||
|
|
||||||
|
val fungeChanged: Event<FungeEvent>
|
||||||
|
val stackChanged: Event<StackEvent>
|
||||||
|
val ipChanged: Event<IpEvent>
|
||||||
|
|
||||||
|
fun step(): Boolean
|
||||||
|
fun reset()
|
||||||
|
}
|
||||||
|
|
||||||
12
befunge/src/main/kotlin/befide/befunge/core/Pointer.kt
Normal file
12
befunge/src/main/kotlin/befide/befunge/core/Pointer.kt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package befide.befunge.core
|
||||||
|
|
||||||
|
import befide.befunge.events.Event
|
||||||
|
import befide.befunge.events.IpEvent
|
||||||
|
import befide.befunge.state.IpMode
|
||||||
|
import befide.befunge.state.Vec
|
||||||
|
|
||||||
|
interface Pointer {
|
||||||
|
val pos: Vec
|
||||||
|
val delta: Vec
|
||||||
|
val mode: IpMode
|
||||||
|
}
|
||||||
57
befunge/src/main/kotlin/befide/befunge/events/Event.kt
Normal file
57
befunge/src/main/kotlin/befide/befunge/events/Event.kt
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package befide.befunge.events
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source is pulled unmodified from https://github.com/notiocide/kotlin-events, under the MIT licence
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.function.Consumer
|
||||||
|
|
||||||
|
typealias Handler<EventType> = Consumer<EventType>
|
||||||
|
|
||||||
|
internal operator fun <T> Handler<T>.invoke(t: T) = accept(t)
|
||||||
|
|
||||||
|
class Event<T> : Iterable<MutableMap.MutableEntry<String, Handler<T>>> {
|
||||||
|
|
||||||
|
private val list = LinkedHashMap<String, Handler<T>>()
|
||||||
|
|
||||||
|
var nextUnnamedIndex = 0L
|
||||||
|
private set
|
||||||
|
|
||||||
|
val size: Int @JvmName("size") get() = list.size
|
||||||
|
val listeners: MutableCollection<MutableMap.MutableEntry<String, Handler<T>>> get() = list.entries
|
||||||
|
|
||||||
|
fun clear() = list.clear()
|
||||||
|
|
||||||
|
override operator fun iterator() = list.iterator()
|
||||||
|
|
||||||
|
@JvmName("add")
|
||||||
|
operator fun plusAssign(handler: Handler<T>) {
|
||||||
|
list.put("${nextUnnamedIndex++}", handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmName("put")
|
||||||
|
operator fun set(name: String, handler: Handler<T>) {
|
||||||
|
list.put(name, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmName("add")
|
||||||
|
inline operator fun plusAssign(crossinline handler: (T) -> Unit) {
|
||||||
|
this += Handler { handler(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmName("put")
|
||||||
|
inline operator fun set(name: String, crossinline handler: (T) -> Unit) {
|
||||||
|
this[name] = Handler { handler(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmName("remove")
|
||||||
|
operator fun minusAssign(name: String) {
|
||||||
|
list.remove(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmName("handle")
|
||||||
|
operator fun invoke(data: T) {
|
||||||
|
for ((_, value) in this) value(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package befide.befunge.events
|
||||||
|
|
||||||
|
import befide.befunge.state.Value
|
||||||
|
import befide.befunge.state.Vec
|
||||||
|
|
||||||
|
data class FungeEvent(val vec: Vec, val from: Value, val to: Value)
|
||||||
5
befunge/src/main/kotlin/befide/befunge/events/IpEvent.kt
Normal file
5
befunge/src/main/kotlin/befide/befunge/events/IpEvent.kt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package befide.befunge.events
|
||||||
|
|
||||||
|
import befide.befunge.core.Pointer
|
||||||
|
|
||||||
|
data class IpEvent(val from: Pointer, val to: Pointer)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package befide.befunge.events
|
||||||
|
|
||||||
|
enum class StackAction {
|
||||||
|
Push,
|
||||||
|
Pop,
|
||||||
|
Clear
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package befide.befunge.events
|
||||||
|
|
||||||
|
import befide.befunge.state.Value
|
||||||
|
|
||||||
|
data class StackEvent(val op: StackAction, val values: List<Value>)
|
||||||
7
befunge/src/main/kotlin/befide/befunge/state/IpMode.kt
Normal file
7
befunge/src/main/kotlin/befide/befunge/state/IpMode.kt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package befide.befunge.state
|
||||||
|
|
||||||
|
enum class IpMode {
|
||||||
|
Normal,
|
||||||
|
String,
|
||||||
|
Char
|
||||||
|
}
|
||||||
7
befunge/src/main/kotlin/befide/befunge/state/Value.kt
Normal file
7
befunge/src/main/kotlin/befide/befunge/state/Value.kt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package befide.befunge.state
|
||||||
|
|
||||||
|
data class Value(val value: Int) {
|
||||||
|
constructor(value: Char) : this(value.toInt())
|
||||||
|
|
||||||
|
val asChar: Char? = if (value in (32..126)) value.toChar() else null
|
||||||
|
}
|
||||||
6
befunge/src/main/kotlin/befide/befunge/state/Vec.kt
Normal file
6
befunge/src/main/kotlin/befide/befunge/state/Vec.kt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package befide.befunge.state
|
||||||
|
|
||||||
|
data class Vec(val x: Int, val y: Int) {
|
||||||
|
operator fun plus(other: Vec) = Vec(x + other.x, y + other.y)
|
||||||
|
operator fun times(c: Int) = Vec(x * c, y * c)
|
||||||
|
}
|
||||||
50
ide/ide.iml
Normal file
50
ide/ide.iml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="kotlin-language" name="Kotlin">
|
||||||
|
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
|
||||||
|
<compilerSettings />
|
||||||
|
<compilerArguments>
|
||||||
|
<option name="jvmTarget" value="1.8" />
|
||||||
|
<option name="languageVersion" value="1.3" />
|
||||||
|
<option name="apiVersion" value="1.2" />
|
||||||
|
<option name="pluginOptions">
|
||||||
|
<array />
|
||||||
|
</option>
|
||||||
|
<option name="pluginClasspaths">
|
||||||
|
<array />
|
||||||
|
</option>
|
||||||
|
</compilerArguments>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="no.tornado:tornadofx:1.7.17" level="project" />
|
||||||
|
<orderEntry type="module" module-name="befunge" />
|
||||||
|
<orderEntry type="library" name="Maven: no.tornado:tornadofx:1.7.17" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.glassfish:javax.json:1.1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: javax.json:javax.json-api:1.1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.60" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.60" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-reflect:1.2.60" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-junit:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-annotations-common:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-common:1.3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
87
ide/pom.xml
Normal file
87
ide/pom.xml
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>befide</groupId>
|
||||||
|
<artifactId>ide</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>befide ide</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<kotlin.version>1.3.0</kotlin.version>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- befide.befunge module -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>befide</groupId>
|
||||||
|
<artifactId>befunge</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- tornadofx -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>no.tornado</groupId>
|
||||||
|
<artifactId>tornadofx</artifactId>
|
||||||
|
<version>1.7.17</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- kotlin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
|
<!--<testSourceDirectory>src/test/kotlin</testSourceDirectory>-->
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
46
ide/src/main/kotlin/befide/ide/Sample.kt
Normal file
46
ide/src/main/kotlin/befide/ide/Sample.kt
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package befide.ide
|
||||||
|
|
||||||
|
import befide.befunge.b93.B93Interpreter
|
||||||
|
import befide.befunge.core.Interpreter
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty
|
||||||
|
import javafx.scene.Parent
|
||||||
|
import javafx.scene.control.Label
|
||||||
|
import tornadofx.*
|
||||||
|
|
||||||
|
class SampleView : View() {
|
||||||
|
private val controller: SampleController by inject()
|
||||||
|
|
||||||
|
override val root: Parent by fxml()
|
||||||
|
|
||||||
|
private val width: Label by fxid()
|
||||||
|
private val height: Label by fxid()
|
||||||
|
|
||||||
|
init {
|
||||||
|
importStylesheet(resources["style.css"])
|
||||||
|
|
||||||
|
width.bind(controller.width)
|
||||||
|
height.bind(controller.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SampleController : Controller() {
|
||||||
|
private val bf: Interpreter = B93Interpreter()
|
||||||
|
|
||||||
|
val width = SimpleIntegerProperty()
|
||||||
|
val height = SimpleIntegerProperty()
|
||||||
|
|
||||||
|
init {
|
||||||
|
bf.fungeChanged += { updateFungeLabels() }
|
||||||
|
|
||||||
|
updateFungeLabels()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateFungeLabels() {
|
||||||
|
width.set(bf.funge.width)
|
||||||
|
height.set(bf.funge.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SampleApp : App() {
|
||||||
|
override val primaryView = SampleView::class
|
||||||
|
}
|
||||||
16
ide/src/main/resources/befide/ide/SampleView.fxml
Normal file
16
ide/src/main/resources/befide/ide/SampleView.fxml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<GridPane alignment="CENTER" minHeight="-Infinity" minWidth="-Infinity" prefHeight="200.0" prefWidth="300.0"
|
||||||
|
xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<Label text="Width: " styleClass="lbl"
|
||||||
|
fx:id="widthLabel"/>
|
||||||
|
<Label text="Height: " styleClass="lbl"
|
||||||
|
fx:id="heightLabel" GridPane.rowIndex="1"/>
|
||||||
|
<Label text="{width}" styleClass="val"
|
||||||
|
fx:id="width" GridPane.columnIndex="1"/>
|
||||||
|
<Label text="{height}" styleClass="val"
|
||||||
|
fx:id="height" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
|
</GridPane>
|
||||||
16
ide/src/main/resources/befide/ide/style.css
Normal file
16
ide/src/main/resources/befide/ide/style.css
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
.lbl {
|
||||||
|
-fx-text-fill: maroon;
|
||||||
|
}
|
||||||
|
|
||||||
|
.val {
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#heightLabel {
|
||||||
|
-fx-font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
GridPane {
|
||||||
|
-fx-font-size: 20px;
|
||||||
|
-fx-font-family: Consolas, monospace;
|
||||||
|
}
|
||||||
9
kotlin-befide.iml
Normal file
9
kotlin-befide.iml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
Reference in New Issue
Block a user