Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe
Class FrontEndTool

    java.lang.Object
      javafe.Tool
          javafe.FrontEndTool

Direct Known Subclasses:
  CopyLoaded, SrcTool

public abstract class FrontEndTool
extends Tool

`FrontEndTool` is an abstract class for tools that use our Java front end.

It handles parsing the standard options for setting up the front end and initializing the front end using those options. At the end of a run, it prints a count of how many cautions, warnings, and errors occurred (cf. `ErrorSet`). It also handles catching `FatalError`s (see `ErrorSet.fatal`). The remaining processing, if any, is front-end-tool specific.

Field Summary
`protected java.lang.String` | `compositeClassPath`
`protected java.lang.String` | `compositeSourcePath` Setup: initialize the front end using the standard front-end-tool option variables (`Options.userPath`, `Options.sysPath`).

Fields inherited from class javafe.Tool
`badUsageExitCode, errorExitCode, okExitCode, options, outOfMemoryExitCode`

Constructor Summary
`FrontEndTool()`

Method Summary
`void` | `clear(boolean complete)` Called to clear any static initializations, so that the parser can be called multiple times within one process.
`abstract void` | `frontEndToolProcessing(java.util.ArrayList args)` Perform any front-end-tool-specific processing.
`int` | `handleOptions(java.lang.String[] args)` Parses the options into a new instance of an `Options` subclass.
`static void` | `main(java.lang.String[] args)` Start up an instance of this tool using command-line arguments `args`.
`Options` | `makeOptions()` Called to create a new `Options` object.
`PragmaParser` | `makePragmaParser()` Called to obtain the pragma parser to be used for parsing input files.
`PrettyPrint` | `makePrettyPrint()` Called to obtain the pretty printer to set `PrettyPrint.inst` to.
`StandardTypeReader` | `makeStandardTypeReader(java.lang.String path, java.lang.String sourcePath, PragmaParser P)` Called to obtain the `StandardTypeReader` to be used for locating and reading in types.
`TypeCheck` | `makeTypeCheck()` Called to obtain an instance of the `TypeCheck` class (or a subclass thereof) to be used for typechecking.
`void` | `processOptions(java.lang.String[] args)` Processes the options into the current Options instance as contained in the options field.
`int` | `run(java.lang.String[] args)` A tool's main entry point, which should be overridden in derived classes to do the work of the tool.
`void` | `setup()`
`void` | `setupPaths()`

Methods inherited from class javafe.Tool
`badOptionUsage, currentTime, name, spaceUsed, timeUsed, usage`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### compositeSourcePath

    protected java.lang.String compositeSourcePath

  Setup: initialize the front end using the standard front-end-tool option variables (`Options.userPath`, `Options.sysPath`).

  This can be done only once. The standard front-end-tool option variables have no effect after this point. May exit with an error (via `ErrorSet.fatal(String)`).

  Ensures `OutsideEnv` has been properly initialized (except if an error occurs).

  Also initializes `PrettyPrint.inst` and `TypeCheck.inst` to their default front end values.

### compositeClassPath

    protected java.lang.String compositeClassPath

Constructor Detail

### FrontEndTool

    public FrontEndTool()

Method Detail

### setupPaths

    public void setupPaths()

### setup

    public void setup()

### clear

    public void clear(boolean complete)

  Called to clear any static initializations, so that the parser can be called multiple times within one process. Called as part of construction of a new Main.

### makeStandardTypeReader

    public StandardTypeReader makeStandardTypeReader(java.lang.String path,
                                                     java.lang.String sourcePath,
                                                     PragmaParser P)

  Called to obtain the `StandardTypeReader` to be used for locating and reading in types.

### makePragmaParser

    public PragmaParser makePragmaParser()

  Called to obtain the pragma parser to be used for parsing input files. If `null` is returned, then no pragma parsing is done. (By default, returns `null`).

### makeOptions

    public Options makeOptions()

  Called to create a new `Options` object.

### processOptions

    public void processOptions(java.lang.String[] args)
                        throws UsageError

  Processes the options into the current Options instance as contained in the options field.

  Parameters:
    `args` - The command-line arguments to process
  Throws:
    `UsageError` - if the sequence of command-line arguments is invalid

### makePrettyPrint

    public PrettyPrint makePrettyPrint()

  Called to obtain the pretty printer to set `PrettyPrint.inst` to. May not return `null`. By default, returns `StandardPrettyPrint`.

### makeTypeCheck

    public TypeCheck makeTypeCheck()

  Called to obtain an instance of the `TypeCheck` class (or a subclass thereof) to be used for typechecking. May not return `null`. By default, returns `TypeCheck`.

### main

    public static void main(java.lang.String[] args)

  Start up an instance of this tool using command-line arguments `args`.

  Note: this code needs to be copied verbatim to each subclass of `Tool` except with the name of the actual subclass inserted after the new operator and the comment characters (//) removed.

  (This needs to be done because static methods cannot be inherited.)

### handleOptions

    public int handleOptions(java.lang.String[] args)

  Parses the options into a new instance of an `Options` subclass. The new instance is assigned to the options field. If the argument is null, the tool is initialized with the existing options (the options field is unchanged). The tool is then initialized (by calling setup) with the designated options.

  Parameters:
    `args` - Either null or an array of arguments used to initialize the Options structure
  Returns:
    Returns -1 if arguments were parsed satisfactorily, otherwise returns the exit code with which to terminate the program

### run

    public final int run(java.lang.String[] args)

  A tool's main entry point, which should be overridden in derived classes to do the work of the tool.

  Specified by:
    `run` in class `Tool`
  Parameters:
    `args` - The command-line arguments the program was invoked with
  Returns:
    The exit code for the program, with 0 indicating success
  See Also:
    `Tool.run(java.lang.String[])`

### frontEndToolProcessing

    public abstract void frontEndToolProcessing(java.util.ArrayList args)

  Perform any front-end-tool-specific processing.

  The remaining arguments are `args[offset]`, `args[offset+1]`, ...

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage