
org.jetbrains.kotlinx.jupyter.repl.impl.executionStack.kt Maven / Gradle / Ivy
package org.jetbrains.kotlinx.jupyter.repl.impl
import org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinition
// Immutable interface representing stack frame
interface ExecutionStackFrame {
val previous: ExecutionStackFrame?
val libraries: List
}
// Mutable stack frame. Mutation is only available for this specific frame
class MutableExecutionStackFrame(
override val previous: ExecutionStackFrame? = null,
) : ExecutionStackFrame {
override val libraries = mutableListOf()
}
fun ExecutionStackFrame?.traverseStack() = generateSequence(this) { it.previous }
fun ExecutionStackFrame?.push() = MutableExecutionStackFrame(this)
val ExecutionStackFrame?.libraryOptions: Map get() {
return buildMap {
traverseStack().forEach { frame ->
frame.libraries.forEach { library ->
library.options.entries.forEach { (key, value) ->
put(key, value)
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy