coins.driver
Class CompileThread

java.lang.Object
  extended byjava.lang.Thread
      extended bycoins.driver.CompileThread
All Implemented Interfaces:
java.lang.Runnable

public class CompileThread
extends java.lang.Thread

A compiler thread.
COINS Compiler Driver API executes compile steps of one compile unit by one thread. If the option -conis:compile-paralle is specified, all the threads are concurrently executed.
The compiler modules executed in the thread can get the thread object by a method Thread.currentThread(), whose return value can be narrowed to this class.
Some services are provided by the thread object:


Nested Class Summary
(package private)  class CompileThread.Assembler
           
(package private)  class CompileThread.Compiler
           
(package private)  class CompileThread.Linker
           
(package private)  class CompileThread.PassGroup
           
(package private)  class CompileThread.Preprocessor
           
 
Field Summary
(package private)  StopWatch fClock
           
(package private)  CompilerImplementation fImplementation
           
(package private)  IoRoot fIoRoot
           
(package private)  boolean fIsLinkerThread
           
(package private)  java.lang.String fSourceFileName
           
(package private)  CompileSpecification fSpec
           
(package private)  CompileStatus fStatus
           
(package private)  TemporaryFileManager fTemporaryFileManager
           
(package private)  java.util.Map fThreadLocalVariables
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
(package private) CompileThread(java.lang.String pSourceFileName, CompileSpecification pSpec, TemporaryFileManager pTemporaryFileManager, CompilerImplementation pImplementation, CompileStatus pStatus, boolean pIsLinkerThread)
           
 
Method Summary
 java.io.File createTemporaryFile()
          Returns a File object representing a newly created temporary file.
 long elapsedTime()
          Returns an elapsed mili-seconds since this thread was started.
 int getExitStatus()
          Gets the current value of the exit status.
 IoRoot getIoRoot()
          Gets an IoRoot object.
 java.lang.Object getThreadLocalVariableValue(java.lang.String varName)
          Gets the value of a thread local variable.
 boolean isDefinedThreadLocalVariable(java.lang.String varName)
          Tests if a thread local variable is defined or not.
 java.lang.Object removeThreadLocalVariable(java.lang.String varName)
          Removes a thread local variable.
 void run()
           
 void setABEND()
          Sets a value representing `abnormal end' to the exit status.
 void setExitStatus(int s)
          Sets a value to the exit status of this compilation.
 java.lang.Object setThreadLocalVariableValue(java.lang.String varName, java.lang.Object value)
          Sets a value to a thread local variable.
 void storeToFile(java.io.InputStream in, java.io.File dest)
          Reads data from an InputStream and stores them to a file.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fSourceFileName

java.lang.String fSourceFileName

fIsLinkerThread

boolean fIsLinkerThread

fTemporaryFileManager

TemporaryFileManager fTemporaryFileManager

fImplementation

CompilerImplementation fImplementation

fSpec

CompileSpecification fSpec

fIoRoot

IoRoot fIoRoot

fStatus

CompileStatus fStatus

fThreadLocalVariables

java.util.Map fThreadLocalVariables

fClock

StopWatch fClock
Constructor Detail

CompileThread

CompileThread(java.lang.String pSourceFileName,
              CompileSpecification pSpec,
              TemporaryFileManager pTemporaryFileManager,
              CompilerImplementation pImplementation,
              CompileStatus pStatus,
              boolean pIsLinkerThread)
Method Detail

getIoRoot

public IoRoot getIoRoot()
Gets an IoRoot object.

Returns:
the IoRoot object.

getExitStatus

public int getExitStatus()
Gets the current value of the exit status.

Returns:
the exit status value.

setABEND

public void setABEND()
Sets a value representing `abnormal end' to the exit status.


setExitStatus

public void setExitStatus(int s)
Sets a value to the exit status of this compilation.

Parameters:
s - the status value

isDefinedThreadLocalVariable

public boolean isDefinedThreadLocalVariable(java.lang.String varName)
Tests if a thread local variable is defined or not.

Parameters:
varName - the name of the variable
Returns:
true if the variable has been defined, false otherwise.

getThreadLocalVariableValue

public java.lang.Object getThreadLocalVariableValue(java.lang.String varName)
Gets the value of a thread local variable.

Parameters:
varName - the name of the variable.
Returns:
the value of the variable if it has been defined, null otherwise.

setThreadLocalVariableValue

public java.lang.Object setThreadLocalVariableValue(java.lang.String varName,
                                                    java.lang.Object value)
Sets a value to a thread local variable. If the variable is has not been defined yet, the variable is newly defined and the value is set.

Parameters:
varName - the name of the variable
Returns:
the old value of the variable if it has been defined, null otherwise.

removeThreadLocalVariable

public java.lang.Object removeThreadLocalVariable(java.lang.String varName)
Removes a thread local variable.

Parameters:
varName - the name of the variable
Returns:
the value of the variable if it has been defined, null otherwise.

elapsedTime

public long elapsedTime()
Returns an elapsed mili-seconds since this thread was started.

Returns:
elapsed time.

createTemporaryFile

public java.io.File createTemporaryFile()
                                 throws java.io.IOException
Returns a File object representing a newly created temporary file. The file is removed when the compiler exited.

Returns:
a File object representing a temporary file.
Throws:
java.io.IOException - if temporary file creation fails.

storeToFile

public void storeToFile(java.io.InputStream in,
                        java.io.File dest)
                 throws java.io.IOException
Reads data from an InputStream and stores them to a file.

Parameters:
in - the source InputStream
dest - the destination File
Throws:
java.io.IOException - if storing data to a file fails

run

public void run()