Package sanskrit
Class Interp
java.lang.Object
sanskrit.Interp
The interpreter: runs compiled code on a stack machine. One instance holds
the global variables, the output sink and the limits of one program.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe source of the current time (time.time, datetime.now...).static interfaceReceives what the program prints. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMakes a module importable (import name).Calls a Python callable from the host, with positional arguments and keyword arguments (Python values; kwargs may be null).static CodeCompiles a program.static StringThe __name__ of a function, a builtin function or a method; null for anything else.getGlobalAsString(String name) The value of a global variable converted for display, or null if it is not defined.A builtin module (math, json, or one added byaddModule(sanskrit.PyModule)), or null.longgetSteps()Number of steps (backward jumps and calls) executed so far.static booleanisCallable(Object v) True for what Python's callable() accepts.static booleanTrue for the Python value None.voidCompiles and runs a program in this interpreter's global scope.voidvoidsetClock(Interp.Clock clock) Replaces the clock (the system clock by default), e.g.voidDefines a global variable: a module, or a member of a module such asPyModule.get(java.lang.String).voidsetMaxDepth(int n) voidsetMaxSteps(long n) static Stringstr(v), for the host.
-
Constructor Details
-
Interp
-
-
Method Details
-
addModule
Makes a module importable (import name). Done by the host, before running anything. -
getModule
A builtin module (math, json, or one added byaddModule(sanskrit.PyModule)), or null. -
setGlobal
Defines a global variable: a module, or a member of a module such asPyModule.get(java.lang.String). -
setClock
Replaces the clock (the system clock by default), e.g. by a fixed one for deterministic tests. -
setMaxSteps
public void setMaxSteps(long n) -
setMaxDepth
public void setMaxDepth(int n) -
getSteps
public long getSteps()Number of steps (backward jumps and calls) executed so far. -
compile
Compiles a program. -
run
Compiles and runs a program in this interpreter's global scope. -
run
-
getGlobalAsString
The value of a global variable converted for display, or null if it is not defined. -
callFunction
Calls a Python callable from the host, with positional arguments and keyword arguments (Python values; kwargs may be null). A Python exception is thrown as aPyError; the call counts against the limits. -
isCallable
True for what Python's callable() accepts. -
functionName
The __name__ of a function, a builtin function or a method; null for anything else. -
isNone
True for the Python value None. -
str
str(v), for the host.
-