edu.vub.at
Class IAT

java.lang.Object
  extended byedu.vub.at.IAT

public final class IAT
extends java.lang.Object

IAT is the main entry point for the 'iat' Interactive AmbientTalk shell. usage: iat [options] [file] [arguments] Environment variables used by iat: AT_HOME: path to the AmbientTalk home directory (for native libraries) AT_OBJECTPATH: default objectpath to use (is prefixed by '.' and suffixed by AT_HOME by the interpreter) Command Line Options: -i, --init init-file: specifies which file to load as the preamble of the language (the content of this file is evaluated in the context of the global lexical root) -o, --objectpath objectpath: specifies the object-path, a list of directories separated by ';' which contain the necessary libraries -e, --eval codestring: evaluates the given codestring and ignores the filename -p, --print print value of last evaluated expression, then quit instead of entering REPL -h, --help display help, then quit -v, --version display version information, then quit -q, --quiet quiet mode - don't print welcome message or any prompts Program arguments: an optional filename and optional arguments to the script Program behaviour: iat evaluates the code in the argument file, if one is given, then enters a read-eval-print loop (unless -p was specified, in which case it prints out the last evaluated expression and quits) During execution of the iat program, the AmbientTalk Lexical root contains an object called 'system'. For more information about this object, see the OBJSystem class:

Author:
tvcutsem
See Also:
edu.vub.at.natives.OBJSystem

Field Summary
static java.lang.String[] _ARGUMENTS_ARG_
           
private static java.lang.String _ENV_AT_HOME_
           
private static java.lang.String _ENV_AT_OBJECTPATH_
           
static java.lang.String _EVAL_ARG_
           
private static ELActor _evaluator
           
private static java.lang.String _EXEC_NAME_
           
static java.lang.String _FILE_ARG_
           
static boolean _HELP_ARG_
           
protected static java.util.Properties _IAT_PROPS_
           
static java.lang.String _INIT_ARG_
           
private static java.lang.String _INPUT_PROMPT_
           
static java.lang.String _OBJECTPATH_ARG_
           
private static java.lang.String _OUTPUT_PROMPT_
           
static boolean _PRINT_ARG_
           
static boolean _QUIET_ARG_
           
static boolean _VERSION_ARG_
           
 
Constructor Summary
IAT()
           
 
Method Summary
private static void abort(java.lang.String message)
           
static void boot()
          Performs the main boot sequence of the AmbientTalk VM and environment: 1) Create a virtual machine using the correct object path and actor initialisation 2) Create a new actor which knows how to interface with IAT (it knows execute: and the system object) 3) Create a barrier which allows synchronizing between an actor and the REPL 4) Ensure the barrier is informed of results by registering it as an observer 5) Send the main code specified by the user to be executed by the actor.
private static SAFLobby computeObjectPath(java.lang.String objectPath)
           
private static SAFWorkingDirectory computeWorkingDirectory()
           
private static void handleATException(InterpreterException e)
           
private static void handleParseError(XParseError e)
           
private static java.lang.String initObjectPathString()
          Initializes the lobby namespace with a slot for each directory in the object path.
private static java.lang.String loadMainCode()
          Load the code in the main argument file or the code specified using the -e option.
static void main(java.lang.String[] args)
          Startup sequence: I) parse command-line arguments, extract properties II) check for simple -help or -version arguments III) Boot sequence: 1) initialize the lobby using the object path (-o or default) 2) add system object to the global lexical scope 3) evaluate init file (-i or default) in context of the global scope 4) if -e was specified, then evaluate the given code in a 'main' namespace else if a filename was specified then load the file and evaluate it within its 'main' namespace else skip 5) if -p was specified, then print value of last evaluation quit else IV) enter REPL: 1) print input prompt (unless -q) 2) read input 3) parse input 4) eval input in the 'main' namespace 5) print output prompt (unless -q) 6) print value of last evaluation
private static void parseAndSend(java.lang.String code, java.lang.String inFile)
           
private static void parseArguments(java.lang.String[] args)
           
private static ATAbstractGrammar parseInitFile()
           
private static void printObjectPath()
           
private static void printToConsole(java.lang.String txt)
           
private static void printVersion()
           
private static void processInformativeArguments()
           
private static void readEvalPrintLoop()
          Reads a single line of input, and schedules it for evaluation.
private static java.lang.String readFromConsole()
           
private static void warn(java.lang.String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_EXEC_NAME_

private static final java.lang.String _EXEC_NAME_
See Also:
Constant Field Values

_ENV_AT_OBJECTPATH_

private static final java.lang.String _ENV_AT_OBJECTPATH_
See Also:
Constant Field Values

_ENV_AT_HOME_

private static final java.lang.String _ENV_AT_HOME_
See Also:
Constant Field Values

_IAT_PROPS_

protected static final java.util.Properties _IAT_PROPS_

_INPUT_PROMPT_

private static java.lang.String _INPUT_PROMPT_

_OUTPUT_PROMPT_

private static java.lang.String _OUTPUT_PROMPT_

_FILE_ARG_

public static java.lang.String _FILE_ARG_

_ARGUMENTS_ARG_

public static java.lang.String[] _ARGUMENTS_ARG_

_INIT_ARG_

public static java.lang.String _INIT_ARG_

_OBJECTPATH_ARG_

public static java.lang.String _OBJECTPATH_ARG_

_EVAL_ARG_

public static java.lang.String _EVAL_ARG_

_PRINT_ARG_

public static boolean _PRINT_ARG_

_HELP_ARG_

public static boolean _HELP_ARG_

_VERSION_ARG_

public static boolean _VERSION_ARG_

_QUIET_ARG_

public static boolean _QUIET_ARG_

_evaluator

private static ELActor _evaluator
Constructor Detail

IAT

public IAT()
Method Detail

parseArguments

private static void parseArguments(java.lang.String[] args)

processInformativeArguments

private static void processInformativeArguments()

initObjectPathString

private static java.lang.String initObjectPathString()
Initializes the lobby namespace with a slot for each directory in the object path. The slot name corresponds to the last name of the directory. The slot value corresponds to a namespace object initialized with the directory. If the user did not specify an objectpath, the default is .:$AT_OBJECTPATH:$AT_HOME


computeObjectPath

private static final SAFLobby computeObjectPath(java.lang.String objectPath)

computeWorkingDirectory

private static final SAFWorkingDirectory computeWorkingDirectory()

parseInitFile

private static ATAbstractGrammar parseInitFile()
                                        throws InterpreterException
Throws:
InterpreterException

loadMainCode

private static java.lang.String loadMainCode()
Load the code in the main argument file or the code specified using the -e option. As a side-effect, sets the _globalContext variable to the correct global context to be used subsequently in the REPL.

Returns:
the result of evaluating the main initialization file or the -e option; null if no main file or -e option were specified.

readEvalPrintLoop

private static void readEvalPrintLoop()
Reads a single line of input, and schedules it for evaluation. The result will be printed as a result of proceed, which is invoked by the IATSynchronizer. The continual reading is ensured as that method in its turn calls readEvalPrintLoop


boot

public static void boot()
Performs the main boot sequence of the AmbientTalk VM and environment: 1) Create a virtual machine using the correct object path and actor initialisation 2) Create a new actor which knows how to interface with IAT (it knows execute: and the system object) 3) Create a barrier which allows synchronizing between an actor and the REPL 4) Ensure the barrier is informed of results by registering it as an observer 5) Send the main code specified by the user to be executed by the actor. An important side-effect of calling boot is that the variable _evaluator will point to a newly create actor serving as iat's global evaluation context.

Returns:
the result of evaluating the main file or -e code; nil if none of both was specified

main

public static void main(java.lang.String[] args)
Startup sequence: I) parse command-line arguments, extract properties II) check for simple -help or -version arguments III) Boot sequence: 1) initialize the lobby using the object path (-o or default) 2) add system object to the global lexical scope 3) evaluate init file (-i or default) in context of the global scope 4) if -e was specified, then evaluate the given code in a 'main' namespace else if a filename was specified then load the file and evaluate it within its 'main' namespace else skip 5) if -p was specified, then print value of last evaluation quit else IV) enter REPL: 1) print input prompt (unless -q) 2) read input 3) parse input 4) eval input in the 'main' namespace 5) print output prompt (unless -q) 6) print value of last evaluation

Parameters:
args - arguments passed to the JVM, which should all be interpreted as arguments to 'iat'

printObjectPath

private static void printObjectPath()

parseAndSend

private static void parseAndSend(java.lang.String code,
                                 java.lang.String inFile)

handleParseError

private static void handleParseError(XParseError e)

handleATException

private static void handleATException(InterpreterException e)

readFromConsole

private static java.lang.String readFromConsole()
                                         throws java.io.IOException
Throws:
java.io.IOException

printToConsole

private static void printToConsole(java.lang.String txt)

abort

private static void abort(java.lang.String message)

warn

private static void warn(java.lang.String message)

printVersion

private static void printVersion()