public class RtflRuntime
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
class |
RtflRuntime.GarbageCollector
Garbage collector daemon for local values no longer in use
|
static class |
RtflRuntime.LocalVar |
static class |
RtflRuntime.RtflMetadata
Utility class to store Rtfl compiled file metadata
|
| Constructor and Description |
|---|
RtflRuntime()
Instantiates a new Rtfl runtime
|
| Modifier and Type | Method and Description |
|---|---|
RtflRuntime |
closeTerminal()
Closes terminal input
|
RtflType |
execute(RtflInstruction[] instructions)
Executes Rtfl instructions at the top scope
|
RtflType |
execute(RtflInstruction[] instructions,
Scope scope)
Executes Rtfl instructions
|
RtflType |
execute(RtflInstruction[] instructions,
Scope scope,
boolean disownAll)
Executes Rtfl instructions
|
RtflType |
execute(java.lang.String code)
Executes a String of Rtfl code
|
RtflType |
execute(java.lang.String code,
Scope scope)
Executes a String of Rtfl code
|
RtflRuntime |
executeAsync(RtflInstruction[] instructions,
Scope scope)
Executes Rtfl instructions asynchronously
|
RtflType |
executeFile(java.io.File file)
Executes an Rtfl file (script or bytecode) at top level
|
RtflType |
executeFile(java.io.File file,
Scope scope)
Executes an Rtfl file (script or bytecode)
|
RtflRuntime |
exposeMethod(java.lang.Object object,
java.lang.String name,
java.lang.Class<?>[] parameters)
Exposes a Java method to this runtime as an Rtfl function
|
RtflRuntime |
exposeMethodAs(java.lang.Object object,
java.lang.String name,
java.lang.Class<?>[] parameters,
java.lang.String importName)
Exposes a Java method to this runtime as an Rtfl function
|
RtflRuntime |
exposeStaticMethod(java.lang.Class<?> clazz,
java.lang.String name,
java.lang.Class<?>[] parameters)
Exposes a static Java method to this runtime as an Rtfl function
|
RtflRuntime |
exposeStaticMethodAs(java.lang.Class<?> clazz,
java.lang.String name,
java.lang.Class<?>[] parameters,
java.lang.String importName)
Exposes a static Java method to this runtime as an Rtfl function
|
java.util.concurrent.ConcurrentHashMap<java.lang.String,RtflFunction> |
functions()
Returns all currently loaded functions
|
RtflRuntime.GarbageCollector |
garbageCollector()
Returns this runtime's garbage collector daemon
|
java.util.concurrent.ConcurrentHashMap<java.lang.String,RtflType> |
globalVarables()
Returns all global variables
|
RtflRuntime |
importJavaInterop()
Imports all Java interop functions into this Runtime
|
RtflRuntime |
importStandard()
Imports all Rtfl standard functions into this Runtime
|
static boolean |
isCompiledScript(java.io.InputStream in)
Returns whether the stream provided contains the four byte signature for compiled Rtfl files.
|
java.util.concurrent.ConcurrentHashMap<java.lang.Integer,RtflRuntime.LocalVar> |
localVariables()
Returns all local variables.
|
int |
newId()
Generates a new unique integer ID
|
RtflRuntime |
openTerminal()
Opens terminal input
|
static RtflRuntime.RtflMetadata |
readCompiledMetadata(java.io.InputStream in)
Returns the metadata of a compiled Rtfl file.
|
java.lang.String |
readTerminal()
Reads a line from the terminal if terminal input is open
|
boolean |
terminalOpen()
Returns if terminal input is open
|
public static boolean isCompiledScript(java.io.InputStream in)
throws java.io.IOException
in - The InputStream to readjava.io.IOException - If reading from the stream failspublic static RtflRuntime.RtflMetadata readCompiledMetadata(java.io.InputStream in) throws java.io.IOException
in - The InputStream from which to read metadatajava.io.IOException - If reading from the stream failspublic RtflRuntime openTerminal()
public RtflRuntime closeTerminal() throws RuntimeException
RuntimeException - If closing terminal input failspublic boolean terminalOpen()
public java.lang.String readTerminal()
throws RuntimeException
RuntimeException - If reading the input failspublic RtflType execute(RtflInstruction[] instructions) throws RuntimeException
instructions - The instructions to executeRuntimeException - If there is an error while executing instructionspublic RtflType execute(RtflInstruction[] instructions, Scope scope) throws RuntimeException
instructions - The instructions to executescope - The scope in which to run the instructionsRuntimeException - If there is an error while executing instructionspublic RtflType execute(java.lang.String code) throws RuntimeException, java.io.IOException, ProducerException
code - The Rtfl code to executeRuntimeException - If there is an error while executing instructionsjava.io.IOException - If reading the code String failsProducerException - If parsing/reading the instructions failspublic RtflType execute(java.lang.String code, Scope scope) throws RuntimeException, java.io.IOException, ProducerException
code - The Rtfl code to executescope - The scope in which to run the codeRuntimeException - If there is an error while executing instructionsjava.io.IOException - If reading the code String failsProducerException - If parsing/reading the instructions failspublic RtflRuntime executeAsync(RtflInstruction[] instructions, Scope scope)
instructions - The instructions to executescope - The scope in which to run the instructionspublic RtflType executeFile(java.io.File file) throws java.io.IOException, RuntimeException, ProducerException
file - The file to executejava.io.IOException - If reading the file failsRuntimeException - If executing the file failsProducerException - If parsing/reading the file failspublic RtflType executeFile(java.io.File file, Scope scope) throws java.io.IOException, RuntimeException, ProducerException
file - The file to executescope - The scope in which to execute te filejava.io.IOException - If reading the file failsRuntimeException - If executing the file failsProducerException - If parsing/reading the file failspublic RtflType execute(RtflInstruction[] instructions, Scope scope, boolean disownAll) throws RuntimeException
instructions - The instructions to executescope - The scope in which to run the instructionsdisownAll - Whether to delete all local variables after execution (should only be used on top-level execution)RuntimeException - If there is an error while executing instructionspublic java.util.concurrent.ConcurrentHashMap<java.lang.String,RtflFunction> functions()
public java.util.concurrent.ConcurrentHashMap<java.lang.String,RtflType> globalVarables()
public java.util.concurrent.ConcurrentHashMap<java.lang.Integer,RtflRuntime.LocalVar> localVariables()
public RtflRuntime.GarbageCollector garbageCollector()
public RtflRuntime importStandard()
public RtflRuntime importJavaInterop()
public RtflRuntime exposeMethodAs(java.lang.Object object, java.lang.String name, java.lang.Class<?>[] parameters, java.lang.String importName) throws java.lang.NoSuchMethodException, java.lang.SecurityException
object - The object containing the methodname - The name of the methodparameters - The method's parameter typesimportName - What the new function should be namedjava.lang.NoSuchMethodException - If the specified method (and its specified parameters) does not existjava.lang.SecurityException - If the method cannot be accessedpublic RtflRuntime exposeMethod(java.lang.Object object, java.lang.String name, java.lang.Class<?>[] parameters) throws java.lang.NoSuchMethodException, java.lang.SecurityException
object - The object containing the methodname - The name of the methodparameters - The method's parameter typesjava.lang.NoSuchMethodException - If the specified method (and its specified parameters) does not existjava.lang.SecurityException - If the method cannot be accessedpublic RtflRuntime exposeStaticMethodAs(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>[] parameters, java.lang.String importName) throws java.lang.NoSuchMethodException, java.lang.SecurityException
clazz - The class containing the static methodname - The name of the methodparameters - The method's parameter typesimportName - What the new function should be namedjava.lang.NoSuchMethodException - If the specified method (and its specified parameters) does not existjava.lang.SecurityException - If the method cannot be accessedpublic RtflRuntime exposeStaticMethod(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>[] parameters) throws java.lang.NoSuchMethodException, java.lang.SecurityException
clazz - The class containing the static methodname - The name of the methodparameters - The method's parameter typesjava.lang.NoSuchMethodException - If the specified method (and its specified parameters) does not existjava.lang.SecurityException - If the method cannot be accessedpublic int newId()