kawa
Class Shell
java.lang.Object
kawa.Shell
public class Shell
- extends java.lang.Object
Utility functions (static methods) for kawa.repl.
It also contains methods for file loading (source and compiled).
Constructor Summary |
Shell()
|
Method Summary |
static CompiledModule |
checkCompiledZip(java.io.InputStream fs,
Path path,
Environment env,
Language language)
|
static Consumer |
getOutputConsumer(OutPort out)
Return a Consumer that formats using the appropriate format. |
static void |
printError(java.lang.Throwable ex,
SourceMessages messages,
OutPort perr)
|
static boolean |
run(Language language,
Environment env)
|
static boolean |
run(Language language,
Environment env,
InPort inp,
Consumer out,
OutPort perr,
java.net.URL url)
|
static java.lang.Throwable |
run(Language language,
Environment env,
InPort inp,
Consumer out,
OutPort perr,
java.net.URL url,
SourceMessages messages)
|
static java.lang.Throwable |
run(Language language,
Environment env,
InPort inp,
OutPort pout,
OutPort perr,
SourceMessages messages)
|
static boolean |
runFile(java.io.InputStream fs,
Path path,
Environment env,
boolean lineByLine,
int skipLines)
|
static boolean |
runFileOrClass(java.lang.String fname,
boolean lineByLine,
int skipLines)
Run a named source file, compiled .zip, or class. |
static void |
setDefaultFormat(java.lang.String name)
Specify the default output format. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
currentLoadPath
public static java.lang.ThreadLocal currentLoadPath
defaultFormatName
public static java.lang.String defaultFormatName
defaultFormatInfo
public static java.lang.Object[] defaultFormatInfo
defaultFormatMethod
public static java.lang.reflect.Method defaultFormatMethod
Shell
public Shell()
setDefaultFormat
public static void setDefaultFormat(java.lang.String name)
- Specify the default output format.
- Parameters:
name
- The name of the format, as an entry in the formats table.
getOutputConsumer
public static Consumer getOutputConsumer(OutPort out)
- Return a Consumer that formats using the appropriate format.
The format is chosen depending on specified defaults.
- Parameters:
out
- The output where formatted output is sent to.
run
public static boolean run(Language language,
Environment env)
run
public static java.lang.Throwable run(Language language,
Environment env,
InPort inp,
OutPort pout,
OutPort perr,
SourceMessages messages)
run
public static boolean run(Language language,
Environment env,
InPort inp,
Consumer out,
OutPort perr,
java.net.URL url)
run
public static java.lang.Throwable run(Language language,
Environment env,
InPort inp,
Consumer out,
OutPort perr,
java.net.URL url,
SourceMessages messages)
printError
public static void printError(java.lang.Throwable ex,
SourceMessages messages,
OutPort perr)
checkCompiledZip
public static final CompiledModule checkCompiledZip(java.io.InputStream fs,
Path path,
Environment env,
Language language)
throws java.io.IOException
- Throws:
java.io.IOException
runFileOrClass
public static boolean runFileOrClass(java.lang.String fname,
boolean lineByLine,
int skipLines)
- Run a named source file, compiled .zip, or class.
We try in order if
fname
names a compiled zip file,
or names some other file (in which case it is assumed to be source),
or is the name of a class in the classpath.
- Parameters:
lineByLine
- Should we read and evaluate a source file line-by-line
(i.e. read and evaluate each line before reading the next one),
or should be read and compile the whole file as a module before
running it? Only used when parsing a source file.skipLines
- If reading a source file, the number of initial
lines to skip before beginning parsing.
- Returns:
- True on success, false on failure.
runFile
public static final boolean runFile(java.io.InputStream fs,
Path path,
Environment env,
boolean lineByLine,
int skipLines)
throws java.lang.Throwable
- Throws:
java.lang.Throwable