coins.lir2c
Class LirToC

java.lang.Object
  extended bycoins.lir2c.LirToC

public class LirToC
extends java.lang.Object

LirToC: convert LIR into C code. It is called from coins.driver.Driver.


Field Summary
 Module compileUnit
          Module to convert
 java.io.OutputStreamWriter out
          Output Stream Writer
 java.io.PrintWriter stdout
          print writer to output C code
 
Constructor Summary
LirToC(Module cU, java.io.OutputStreamWriter fout)
          Constructor (with args)
LirToC(Module cU, java.lang.String dstName)
          Constructor (with args)
 
Method Summary
(package private)  java.util.HashMap getArgMap(Function func)
          getArgMap: this method gets the declaration arguments in the Function.
 java.lang.String getEpilogue(Function func)
          getEpilogue: this method gets the epilogue of the function.
static java.lang.String getInitializer(Data data)
           
(package private)  java.util.HashMap getIsFuncOrDataMap(Module cU)
          getIsFuncOrDataMap: this method gets the Function-or-Data Map in the Module object.
(package private)  java.util.HashMap getIsStaticMap(SymTab gmap)
          getIsStaticMap: this method gets the IsStatic Map in the global symbol table.
 java.lang.String getPrologue(Function func)
          getPrologue: this method gets the prologue of the function.
 void invoke()
          the main routine of convertion.
 void invoke2(Function func)
          invoke2: invoke2 method converts the Function object to the C code.
 void recurLirNode(LirNode root, java.io.PrintWriter stdout)
          revurLirNode: the experimental method that traverse LirNodes recursively.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stdout

public java.io.PrintWriter stdout
print writer to output C code


out

public java.io.OutputStreamWriter out
Output Stream Writer


compileUnit

public Module compileUnit
Module to convert

Constructor Detail

LirToC

public LirToC(Module cU,
              java.lang.String dstName)
       throws java.io.IOException
Constructor (with args)

Parameters:
cU - The module to convert.
dstName - The filename for the output(C code).

LirToC

public LirToC(Module cU,
              java.io.OutputStreamWriter fout)
       throws java.io.IOException
Constructor (with args)

Parameters:
cU - The module to convert.
fout - The OutputStreamWriter for the output(C code).
Method Detail

invoke

public void invoke()
the main routine of convertion.


invoke2

public void invoke2(Function func)
invoke2: invoke2 method converts the Function object to the C code. it is called from coins.k3.lir2c.LirToC@invoke.

Parameters:
func - the function to convert.

recurLirNode

public void recurLirNode(LirNode root,
                         java.io.PrintWriter stdout)
revurLirNode: the experimental method that traverse LirNodes recursively. no need to call this method in coins.k3.lir2c.LirToC@invoke2.

Parameters:
root - the root node of the LirNodes.
stdout - the print writer to output(C code).

getEpilogue

public java.lang.String getEpilogue(Function func)
getEpilogue: this method gets the epilogue of the function.

Parameters:
func - The function to get the epilogue.
Returns:
The string of C code that for Epilogue.

getPrologue

public java.lang.String getPrologue(Function func)
getPrologue: this method gets the prologue of the function.

Parameters:
func - The function to get the prologue.
Returns:
The string of C code that for Prologue.

getArgMap

java.util.HashMap getArgMap(Function func)
getArgMap: this method gets the declaration arguments in the Function. for example: func(int a, int b){} will get the hash entries ("int a","-none-") ("int b","-none-")

Parameters:
func - The function to get argument map.
Returns:
The HashMap that contains declaration arguments.

getIsStaticMap

java.util.HashMap getIsStaticMap(SymTab gmap)
getIsStaticMap: this method gets the IsStatic Map in the global symbol table.

Parameters:
gmap - the global symbol table.
Returns:
The HashMap that contains static values.

getIsFuncOrDataMap

java.util.HashMap getIsFuncOrDataMap(Module cU)
getIsFuncOrDataMap: this method gets the Function-or-Data Map in the Module object.

Parameters:
cU - the Module to get HashMap entry.
Returns:
The HashMap that contains the names of value that is Function or Data.

getInitializer

public static java.lang.String getInitializer(Data data)