coins.driver
Class CoinsOptions

java.lang.Object
  extended bycoins.driver.CoinsOptions

public class CoinsOptions
extends java.lang.Object

An abstraction of COINS options at a command line.
Standard COINS options (which means the options that affects driver API objects) are listed below:

More than one COINS options can be specifed by delimiting them by `,'s, e.g. -coins:debug,trace=Driver.8/2,suffix=/tmp/mysuffixes.
Although standard COINS options have an constant representation in this class, users can define and use any option and argument of it.


Field Summary
static java.lang.String DEBUG
          The option string to tell that the compiler is under debugging.
static java.lang.String DEFAULT_LIBDIR
          The default library directory path when a directory `coins' doesn't exist at a user home directory.
static java.lang.String DEFAULT_LIBDIR_NAME_AT_HOME
          The default library directory name at a user home directory.
static java.lang.String DEFAULT_PROPERTY_FILENAME
          The default property file name.
protected  java.lang.String fArgumentString
           
static java.lang.String LIBDIR
          The "library directory" option string.
static java.lang.String PRESERVE_FILES
          The option string to preserve temporary files.
static java.lang.String PROPERTY_FILE
          The "property file path" option string.
static java.lang.String SUFFIX_FILE_PATH
          The "suffix database file path" option string.
static java.lang.String SUFFIX_OPTION
          The "suffix option" option string.
static java.lang.String TRACE
          The "trace" option string.
 
Constructor Summary
CoinsOptions(java.lang.String argumentString)
          Constructs a CoinsOptions object from an argument string of a -coins option.
 
Method Summary
 java.lang.String getArg(java.lang.String pOption)
          Returns the argument of an option in this COINS option.
 java.io.File getLibDir()
          Returns library directory path.
 java.util.Set getOptionKeys()
           
 boolean isSet(java.lang.String pOption)
          Tests if an option is set or not in this COINS option.
 java.util.Map parseArgument(java.lang.String pArgument, char pCategoryDelimiter, char pValueDelimiter)
          parseArgument Get option categories doing division of pArgument by pCategoryDelimiter and then record option items and corresponding option values doing division of each option category by pValueDelimiter.
 void readPropertyFile(Warning pWarning)
          Reads a property file if it exists and merges its contents to the option table when they don't exist.
 void set(java.lang.String pOption)
          Sets a COINS option without argument.
 void set(java.lang.String pOption, java.lang.String pArg)
          Sets a COINS option with an argument.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_LIBDIR_NAME_AT_HOME

public static final java.lang.String DEFAULT_LIBDIR_NAME_AT_HOME
The default library directory name at a user home directory.

See Also:
Constant Field Values

DEFAULT_LIBDIR

public static final java.lang.String DEFAULT_LIBDIR
The default library directory path when a directory `coins' doesn't exist at a user home directory.

See Also:
Constant Field Values

DEFAULT_PROPERTY_FILENAME

public static final java.lang.String DEFAULT_PROPERTY_FILENAME
The default property file name.

See Also:
Constant Field Values

DEBUG

public static final java.lang.String DEBUG
The option string to tell that the compiler is under debugging.

See Also:
Constant Field Values

PRESERVE_FILES

public static final java.lang.String PRESERVE_FILES
The option string to preserve temporary files.

See Also:
Constant Field Values

LIBDIR

public static final java.lang.String LIBDIR
The "library directory" option string.

See Also:
Constant Field Values

PROPERTY_FILE

public static final java.lang.String PROPERTY_FILE
The "property file path" option string.

See Also:
Constant Field Values

SUFFIX_FILE_PATH

public static final java.lang.String SUFFIX_FILE_PATH
The "suffix database file path" option string.

See Also:
Constant Field Values

SUFFIX_OPTION

public static final java.lang.String SUFFIX_OPTION
The "suffix option" option string.

See Also:
Constant Field Values

TRACE

public static final java.lang.String TRACE
The "trace" option string.

See Also:
Constant Field Values

fArgumentString

protected java.lang.String fArgumentString
Constructor Detail

CoinsOptions

public CoinsOptions(java.lang.String argumentString)
Constructs a CoinsOptions object from an argument string of a -coins option. Argument string is a comma separated option list excluding the leading -coins:.

Parameters:
argumentString - an argument string.
Method Detail

readPropertyFile

public void readPropertyFile(Warning pWarning)
Reads a property file if it exists and merges its contents to the option table when they don't exist.

Parameters:
pWarning - warning message controler.

isSet

public boolean isSet(java.lang.String pOption)
Tests if an option is set or not in this COINS option.

Parameters:
pOption - the option string (left side of a delimiting equal sign).
Returns:
true if the option is set, false otherwise.

getArg

public java.lang.String getArg(java.lang.String pOption)
Returns the argument of an option in this COINS option. When the option is not set, a null is returned. When the option is set but no argument is specified (i.e., no delimiting equal sign exists or no string exists at right side of delimiting equal sign), a "" is returned.

Parameters:
pOption - the option string (left side of a delimitin equal sign).
Returns:
the argument of option or null.

set

public void set(java.lang.String pOption)
Sets a COINS option without argument.

Parameters:
pOption - an option to be set.

set

public void set(java.lang.String pOption,
                java.lang.String pArg)
Sets a COINS option with an argument.

Parameters:
pOption - an option to be set.
pArg - an argument of the option.

getLibDir

public java.io.File getLibDir()
Returns library directory path. It is searched from the following sources in this order:
  1. COINS options
  2. property file (specified by "property=path" way)
  3. default value (i.e., ".");

Returns:
library directory path.

toString

public java.lang.String toString()

parseArgument

public java.util.Map parseArgument(java.lang.String pArgument,
                                   char pCategoryDelimiter,
                                   char pValueDelimiter)
parseArgument Get option categories doing division of pArgument by pCategoryDelimiter and then record option items and corresponding option values doing division of each option category by pValueDelimiter. The return value also contains the list of option categories which can be get by get("item_key_list"). The list is ordered in the same sequence as given in pArgument. Example For compiler option -coins:hirOpt=loopexp.4/cpf/pre,trace=HIR.1 by coding CoinsOptions lOptions = ioRoot.getCompileSpecification().getCoinsOptions(); lOption will represent information specified by hirOpt=loopexp.4/cpf/pre,trace=HIR.1 and by coding String lOptArg = lOptions.getArg("hirOpt"); lOptArg will represent "loopexp.4/cpf/pre,trace=HIR.1" and by coding Map lHirOptionItems = parseArgument(lOptArg, '/', '.'); lHirOptionImems will contain key-value correspondence { ("loopexp", "4"), ("cpf", ""), ("pre", ""), ("item_key_list", ("loopexp", "cpf", "pre")) } The coding of this method is similar to parseArgument of Trace class.

Parameters:
pArgument - is a character string showing options.
Returns:
the Map showing option item and option value correspondence.

getOptionKeys

public java.util.Set getOptionKeys()