Package org.spf4j.zel.vm
Class Program
- java.lang.Object
-
- org.spf4j.zel.vm.Program
-
- All Implemented Interfaces:
Serializable
@Immutable public final class Program extends Object implements Serializable
A ZEL program (function)
This is a Turing machine a Program will always be pretty much an array of operations (instructions).- Version:
- 1.0
- Author:
- zoly
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProgram.ExecutionTypestatic classProgram.Type
-
Method Summary
-
-
-
Method Detail
-
async
public Program async()
-
getGlobalMemoryBuilder
public static MemoryBuilder getGlobalMemoryBuilder()
-
getSource
public String getSource()
-
getName
public String getName()
-
getParameterNames
public String[] getParameterNames()
-
getLocalMemSize
public int getLocalMemSize()
-
getGlobalMem
public Object[] getGlobalMem()
-
equals
@CheckReturnValue public boolean equals(Object obj)
-
hashCode
@CheckReturnValue public int hashCode()
-
hasDeterministicFunctions
public boolean hasDeterministicFunctions()
-
get
@CheckReturnValue public Instruction get(int i)
- Parameters:
i- - inst address.- Returns:
- the instruction.
-
getCode
@CheckReturnValue public Instruction[] getCode()
-
getDebugInfo
@CheckReturnValue public ParsingContext.Location[] getDebugInfo()
-
size
@CheckReturnValue public int size()
-
getExecType
public Program.ExecutionType getExecType()
-
compile
@Nonnull public static Program compile(@Nonnull String zExpr, @Nonnull String... varNames) throws CompileException
- Throws:
CompileException
-
compile
@Nonnull public static Program compile(@Nonnull String source, @Nonnull String name, @Nonnull Reader zExpr, @Nonnull String... varNames) throws CompileException
- Throws:
CompileException
-
compilePredicate
@Nonnull public static <T> ZelPredicate<T> compilePredicate(@Nonnull CharSequence zExpr, @Nonnull String varName) throws CompileException
- Throws:
CompileException
-
compile
public static Program compile(@Nonnull String zExpr, Map<String,Integer> localTable, Object[] globalMem, Map<String,Integer> globalTable, @Nonnull String... varNames) throws CompileException
- Throws:
CompileException
-
compile
public static Program compile(@Nonnull String source, @Nonnull String name, @Nonnull Reader zExpr, Map<String,Integer> localTable, Object[] globalMem, Map<String,Integer> globalTable, @Nonnull String... varNames) throws CompileException
- Throws:
CompileException
-
execute
public Object execute() throws ExecutionException, InterruptedException
-
execute
public Object execute(Object... args) throws ExecutionException, InterruptedException
-
toPredicate
public <T> ZelPredicate<T> toPredicate(String toString)
-
execute
public Object execute(@Nonnull ExecutorService execService, Object... args) throws ExecutionException, InterruptedException
-
executeSingleThreaded
public Object executeSingleThreaded(Object... args) throws ExecutionException, InterruptedException
-
execute
public Object execute(@Nullable VMExecutor execService, @Nullable ProcessIO io, Object... args) throws ExecutionException, InterruptedException
-
execute
public org.spf4j.base.Pair<Object,ExecutionContext> execute(@Nullable VMExecutor execService, @Nullable ProcessIO io, ResultCache resultCache, Object... args) throws ExecutionException, InterruptedException
-
executeSync
public static Object executeSync(@Nonnull ExecutionContext ectx) throws ExecutionException, InterruptedException
-
execute
public static Object execute(@Nonnull ExecutionContext ectx) throws ExecutionException, InterruptedException
-
execute
public Object execute(ProcessIO io, Object... args) throws ExecutionException, InterruptedException
-
main
public static void main(String[] args) throws IOException, InterruptedException
This allows to run ZEL in an interactive mode- Parameters:
args-- Throws:
IOExceptionInterruptedException
-
toAssemblyString
public String toAssemblyString()
-
getType
public Program.Type getType()
- Returns:
- the type
-
contains
public boolean contains(Class<? extends Instruction> instr)
-
-