blob: 25aaa9f8fa9823339a200c67adf85ce12a30b23f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package java.lang
import scala.scalajs.js
class Runtime private {
def exit(status: Int): Unit =
halt(status)
//def addShutdownHook(hook: Thread): Unit
//def removeShutdownHook(hook: Thread): Unit
def halt(status: Int): Unit = {
val envInfo = scala.scalajs.runtime.environmentInfo
if (js.typeOf(envInfo.exitFunction) == "function") {
envInfo.exitFunction(status)
throw new IllegalStateException("__ScalaJSEnv.exitFunction returned")
} else {
// We don't have an exit function. Fail
throw new SecurityException("Cannot terminate a JavaScript program. " +
"Define a JavaScript function `__ScalaJSEnv.exitFunction` to " +
"be called on exit.")
}
}
def availableProcessors(): Int = 1
//def freeMemory(): scala.Long
//def totalMemory(): scala.Long
//def maxMemory(): scala.Long
def gc(): Unit = {
// Ignore
}
//def runFinalization(): Unit
//def traceInstructions(on: scala.Boolean): Unit
//def traceMethodCalls(on: scala.Boolean): Unit
//def load(filename: String): Unit
//def loadLibrary(filename: String): Unit
}
object Runtime {
private val currentRuntime = new Runtime
def getRuntime() = currentRuntime
}
|