public class Runtime
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
emptyString
The empty polymorphic value of type StringJ a
|
private static int |
exitCode
set this if you need a different exit code
|
static java.lang.ThreadLocal<java.io.PrintWriter> |
stderr
Provide UTF-8 encoded standard printer for stderr with autoflush
|
static java.lang.ThreadLocal<java.io.BufferedReader> |
stdin
Provide UTF-8 decoded standard input Reader
|
static java.lang.ThreadLocal<java.io.PrintWriter> |
stdout
Provide UTF-8 encoded standard printer for stdout with automatic line flushing
|
static java.util.Random |
stdRandom
GLobal Random generator
|
Constructor and Description |
---|
Runtime() |
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
arrayThaw(T[] a)
Thaw a readonly array by cloning it
|
static <A> java.lang.Class<A> |
classForName(java.lang.String x)
Implementation for frege.prelude.PreludeBase.Class.forName
|
static int |
constructor(java.lang.Object v) |
static int |
constructor(Value v)
Implementation for
pure native constructor frege.runtime.Runtime.constructor :: a -> Int |
static <T extends java.io.Serializable> |
copySerializable(T o)
This is used to copy a mutable value.
|
static void |
exit() |
static <A> java.lang.Class<A> |
getClass(A o)
Implementation for frege.prelude.PreludeBase.getClass
|
static <T> T |
identity(T x)
Identity function for reference types
(Can be used to pseudo thaw/freeze a value)
|
static java.lang.Object |
itemAt(java.lang.String value,
int offset)
Cheat with phantom types.
|
static java.lang.String |
quoteChr(char c)
Utility method used by
Char.show to quote a character. |
static java.lang.String |
quoteStr(java.lang.String a)
Utility method used by
String.show to quote a string. |
static java.lang.Integer |
runMain(java.lang.Object arg)
Run a IO action as main program.
|
static void |
setExitCode(int a) |
public static final java.util.Random stdRandom
public static java.lang.ThreadLocal<java.io.PrintWriter> stdout
Must be thread local so that it works in the online REPL, for instance.
public static java.lang.ThreadLocal<java.io.PrintWriter> stderr
Must be thread local so that it works in the online REPL, for instance.
public static java.lang.ThreadLocal<java.io.BufferedReader> stdin
public static final java.lang.String emptyString
The empty polymorphic value of type StringJ a
Referenced in frege.prelude.List.ListLike_StringJ
private static volatile int exitCode
public static final int constructor(Value v)
pure native constructor frege.runtime.Runtime.constructor :: a -> Int
public static final int constructor(java.lang.Object v)
public static final <A> java.lang.Class<A> getClass(A o)
public static final <A> java.lang.Class<A> classForName(java.lang.String x) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static final java.lang.String quoteStr(java.lang.String a)
Utility method used by String.show
to quote a string.
public static final java.lang.String quoteChr(char c)
Utility method used by Char.show
to quote a character.
public static final <T extends java.io.Serializable> T copySerializable(T o)
This is used to copy a mutable value.
The returned value is of same type, but is considered immutable.
Suitable for instances of classes that do not implement Cloneable
,
but do implement Serializable
.
o
- the value to copypublic static final <T> T identity(T x)
public static final <T> T[] arrayThaw(T[] a)
public static final java.lang.Object itemAt(java.lang.String value, int offset)
Cheat with phantom types.
This method is announced with type String a -> Int -> a but it always returns a char.
This is fine as long as nobody is able to actually create a
value with type, say String Int.
This could be done only with another malicious native function, though.
public static java.lang.Integer runMain(java.lang.Object arg)
Run a IO action as main program.
* Called from the java main method of a frege program.
This converts the argument String array to a list and passes this to
the compiled frege main function, if it is a function.
The result is an IO action of type
IO a to which then IO.performUnsafe is applied.
The resulting Lambda
then actually executes the frege code
when evaluated.
public static final void exit()
public static final void setExitCode(int a)