coins.driver
Class CommandLine

java.lang.Object
  extended bycoins.driver.CommandLine
All Implemented Interfaces:
CompileSpecification, java.io.Serializable

public class CommandLine
extends java.lang.Object
implements CompileSpecification, java.io.Serializable

Abstraction of a COINS compiler command line.
This class is used when the compiler is invoked from command line. A COINS compiler command line is in the form:

java driver [{option | file }] ...
`option' is a string starting with a `-'. As for compile options, see CompileSpecification in more detail.

See Also:
CompileSpecification, Serialized Form

Field Summary
static java.lang.String COINS_DEFAULT_TARGET_CONVENTION
           
static java.lang.String COINS_DEFAULT_TARGET_NAME
           
static java.lang.String COINS_TARGET_CONVENTION_OPTION
           
static java.lang.String COINS_TARGET_NAME_OPTION
           
static java.lang.String COINS_TARGET_OPTION
           
 
Fields inherited from interface coins.driver.CompileSpecification
ARCHIVE_TO_LINK, ASSEMBLE_ONLY, COINS, COMPILE_ONLY, DEFINE_MACRO, DYNAMIC_LINKAGE, HELP, INCLUDE_PATH, INHIBIT_NUMBER_LINE, LINK_PATH, OPTIMIZE_LEVEL, OUTPUT_FILE, PERFORMANCE_MONITOR, PIPE, PREPROCESS_ONLY, PRESERVE_COMMENTS, PRESERVE_SYMBOLS, STATIC_LINKAGE, TARGET_ARCHITECTURE, UNDEFINE_MACRO, VERBOSE, WARNING_CATEGORY
 
Constructor Summary
CommandLine()
          Constructs a CommandLine object representing an empty command line string.
CommandLine(java.lang.String[] args)
          Constructs a CommandLine object representing a command line string.
 
Method Summary
 java.util.Map commandLineOptions()
           
 java.lang.Object getArg(java.lang.String option)
          Returns an argument of an option in this command line.
 java.util.List getAssemblerOptions()
          Returns a List of Strings containing all assembler options specified in this command line.
 CoinsOptions getCoinsOptions()
          Returns an CoinsOptions object which represents -coins options included in this command line.
 java.util.List getCompilerOptions()
          Returns a List of Strings containing all compiler options specified in this command line.
 java.util.List getLinkerOptions()
          Returns a List of Strings containing all linker options specified in this command line.
 java.util.List getPreprocessorOptions()
          Returns a List of Strings containing all preprocessor options specified in this command line.
 java.util.List getSourceFiles()
          Return a List of source file names listed in this command line.
 Trace getTrace()
          Returns a Trace object which filters trace messages in a manner specified in this command line.
 Warning getWarning()
          Returns a Warning object which filters warning messages in a manner specified in this command line.
 boolean isAssemblerOption(java.lang.String arg)
          Tests if the argument string is one of assembler options.
 boolean isCompilerOption(java.lang.String arg)
          Tests if the argument string is one of compiler options.
 boolean isLinkerOption(java.lang.String arg)
          Tests if the argument string is one of linker options.
 boolean isPreprocessorOption(java.lang.String arg)
          Tests if the argument string is one of preprocessor options.
 boolean isSet(java.lang.String option)
          Tests if an option is set or not in this command line.
 void setObjectFile(java.lang.String sourceFile, java.lang.String objectFile)
          Registers a file as an object file of a specified source file.
 void showHelp(java.io.PrintStream out, CompilerImplementation driver)
          Shows help messages.
 java.lang.String toString()
          Returns a String representation of this command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COINS_TARGET_OPTION

public static final java.lang.String COINS_TARGET_OPTION
See Also:
Constant Field Values

COINS_DEFAULT_TARGET_NAME

public static final java.lang.String COINS_DEFAULT_TARGET_NAME
See Also:
Constant Field Values

COINS_TARGET_NAME_OPTION

public static final java.lang.String COINS_TARGET_NAME_OPTION
See Also:
Constant Field Values

COINS_TARGET_CONVENTION_OPTION

public static final java.lang.String COINS_TARGET_CONVENTION_OPTION
See Also:
Constant Field Values

COINS_DEFAULT_TARGET_CONVENTION

public static final java.lang.String COINS_DEFAULT_TARGET_CONVENTION
See Also:
Constant Field Values
Constructor Detail

CommandLine

public CommandLine()
Constructs a CommandLine object representing an empty command line string.


CommandLine

public CommandLine(java.lang.String[] args)
            throws java.text.ParseException
Constructs a CommandLine object representing a command line string.

Parameters:
args - The command line string.
Throws:
java.text.ParseException - error(s) in the command line.
Method Detail

showHelp

public void showHelp(java.io.PrintStream out,
                     CompilerImplementation driver)
Shows help messages.

Specified by:
showHelp in interface CompileSpecification
Parameters:
out - A PrintStream to which the help messages are written.
driver - A driver object which has the method `main'.

getCoinsOptions

public CoinsOptions getCoinsOptions()
Returns an CoinsOptions object which represents -coins options included in this command line.

Specified by:
getCoinsOptions in interface CompileSpecification
Returns:
a CoinsOptions object.

setObjectFile

public void setObjectFile(java.lang.String sourceFile,
                          java.lang.String objectFile)
Registers a file as an object file of a specified source file. Without calling this method, getLinkerOptions cannot return a correct command line arguments.

Specified by:
setObjectFile in interface CompileSpecification
Parameters:
sourceFile - the source file name
objectFile - the object file name

getTrace

public Trace getTrace()
Returns a Trace object which filters trace messages in a manner specified in this command line.

Specified by:
getTrace in interface CompileSpecification
Returns:
a Trace object.

getWarning

public Warning getWarning()
Returns a Warning object which filters warning messages in a manner specified in this command line.

Specified by:
getWarning in interface CompileSpecification
Returns:
a Warning object.

isSet

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

Specified by:
isSet in interface CompileSpecification
Parameters:
option - the option string, including leading `-'.
Returns:
true if the option is set, false otherwise.

getArg

public java.lang.Object getArg(java.lang.String option)
Returns an argument of an option in this command line. When the option is not set, a null is returned. The argument is a String for -o, a List of Strings for -D, -I, -L, -O, -U, -W and -l.

Specified by:
getArg in interface CompileSpecification
Parameters:
option - the option string, including leading `-'.
Returns:
the argument of option.

getSourceFiles

public java.util.List getSourceFiles()
Return a List of source file names listed in this command line.

Specified by:
getSourceFiles in interface CompileSpecification
Returns:
the List of source files names.

toString

public java.lang.String toString()
Returns a String representation of this command line.

Returns:
the String representation of this command line.

isPreprocessorOption

public boolean isPreprocessorOption(java.lang.String arg)
Tests if the argument string is one of preprocessor options. The argument string should start with `-' to be judged as a preprocessor option.

Specified by:
isPreprocessorOption in interface CompileSpecification
Parameters:
arg - the argument string
Returns:
true if `arg' is one of the preprocessor options; false otherwise.

getPreprocessorOptions

public java.util.List getPreprocessorOptions()
Returns a List of Strings containing all preprocessor options specified in this command line.

Specified by:
getPreprocessorOptions in interface CompileSpecification
Returns:
preprocessor options

isCompilerOption

public boolean isCompilerOption(java.lang.String arg)
Tests if the argument string is one of compiler options. The argument string should start with `-' to be judged as a compiler option.

Specified by:
isCompilerOption in interface CompileSpecification
Parameters:
arg - the argument string
Returns:
true if `arg' is one of the compiler options; false otherwise.

getCompilerOptions

public java.util.List getCompilerOptions()
Returns a List of Strings containing all compiler options specified in this command line.

Specified by:
getCompilerOptions in interface CompileSpecification
Returns:
compiler options

isAssemblerOption

public boolean isAssemblerOption(java.lang.String arg)
Tests if the argument string is one of assembler options. The argument string should start with `-' to be judged as a assembler option.

Specified by:
isAssemblerOption in interface CompileSpecification
Parameters:
arg - the argument string
Returns:
true if `arg' is one of the assembler options; false otherwise.

getAssemblerOptions

public java.util.List getAssemblerOptions()
Returns a List of Strings containing all assembler options specified in this command line.

Specified by:
getAssemblerOptions in interface CompileSpecification
Returns:
assembler options

isLinkerOption

public boolean isLinkerOption(java.lang.String arg)
Tests if the argument string is one of linker options. The argument string should start with `-' to be judged as a linker option.

Specified by:
isLinkerOption in interface CompileSpecification
Parameters:
arg - the argument string
Returns:
true if `arg' is one of the linker options; false otherwise.

getLinkerOptions

public java.util.List getLinkerOptions()
Returns a List of Strings containing all linker options specified in this command line.

Specified by:
getLinkerOptions in interface CompileSpecification
Returns:
linker options

commandLineOptions

public java.util.Map commandLineOptions()