|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vishia.java2C.GenerateFile
public class GenerateFile
This class processes the first and second pass of translating Java to C of a java file.
Parsing the content of the java file is done before it processed, see Java2C_Main.
| Field Summary | |
|---|---|
private LocalIdents |
fileLevelIdents
All Type identifier ( ClassData which are visible at file level. |
private java.io.File |
fileStruct
The file descriptor for the structure file. |
private java.util.TreeMap<java.lang.String,java.lang.String> |
imports
|
private java.util.TreeMap<java.lang.String,java.lang.String> |
includes
All include declarations necessary in the C-file of this java file. |
private JavaSources |
javaSources
lines for c file mapping the class content. |
(package private) JavaSrcTreeFile |
javaSrc
|
(package private) java.util.List<ClassData> |
listAllClassesForSecondPath
List of all classes found in this file. |
private java.util.List<ClassData> |
listClassInFile
List of all classes in the file. |
private LocalIdents |
pkgIdents
Copy of the reference from javaSrc. |
private Report |
report
|
(package private) RunRequiredFirstPass_ifc |
runRequiredFirstPass
The interface to call a firstpass run of a needed type. |
(package private) java.lang.String |
sFileNameC
Name without path and extension of the c- and h-file from java file. |
(package private) java.lang.String |
sPkgIdent
Package where the Java file is stored, with / as separators and at end. |
private java.lang.StringBuilder |
uFileCDefinitions
lines for c file mapping the definitions in the C-file before the content of the bodies, see sClassC. |
private java.lang.StringBuilder |
uFileCSecondPath
lines for c file mapping the definitions in the C-file before the content of the bodies, see sClassC. |
private java.lang.StringBuilder |
uFileHDefinitions
lines for c file mapping the definitions in the C-file before the content of the bodies, see sClassC. |
private java.util.Map<java.lang.String,java.lang.Object> |
usedEnhancedRefTypes
Index of all classes from which an enhanced reference is need in this compilation unit. |
private java.util.Map<java.lang.String,java.lang.Object> |
usedMtblRefTypesC
Index of all classes from which an method-table reference is need in this compilation unit. |
private java.util.Map<java.lang.String,java.lang.Object> |
usedMtblRefTypesH
Index of all classes from which an method-table reference is need in the header file. |
| Constructor Summary | |
|---|---|
GenerateFile(JavaSources javaSources,
JavaSrcTreeFile javaSrc,
RunRequiredFirstPass_ifc runRequiredFirstPass,
java.io.File fileStruct,
Report report)
initializes the instances with the given associations. |
|
| Method Summary | |
|---|---|
void |
addEnhancedRefType(java.lang.String sRefType)
If a type is used as enhanced reference in the code of the class, it is noted here. |
void |
addIncludeC(java.lang.String sFileName,
java.lang.String comment)
Adds a type to include the type-correspondent h-file in the c-file. |
void |
addIncludeH(java.lang.String sFileName,
java.lang.String comment)
Adds a type to include the type-correspondent h-file in the h-file. |
void |
addMtblRefType(java.lang.String sRefType,
char intension)
If a type is used as method-table- reference in the code of the class, it is noted here. |
(package private) void |
evaluateImports(ZbnfParseResultItem resultFile)
|
(package private) void |
registerClassInFile(ClassData classData)
|
(package private) void |
runFirstPassFile(ZbnfParseResultItem resultItem,
java.lang.String sPrefixClassCname,
java.lang.String sSuffixClassCname,
java.lang.String sPathOut)
Generates the content of all classes in the h-file with given ZBNF parse result item of the class. |
(package private) void |
runSecondPassFile()
Generates the content of a class in the c-file. |
(package private) void |
stop()
It's a debug helper. |
java.lang.String |
toString()
|
private java.lang.String |
unusedyet_getImport(java.lang.String sType)
|
void |
writeCdefs(java.lang.StringBuilder content)
Adds a text to the C-definition-code |
void |
writeClassC(java.lang.String content)
Adds a text to the C-code |
void |
writeClassC(java.lang.StringBuilder content)
Adds a text to the C-code |
void |
writeClassH(java.lang.String line)
Adds a text to the Headerfile-code |
void |
writeHdefs(java.lang.StringBuilder content)
Adds a text to the H-code |
(package private) static void |
writeStructure(java.io.File fileStructP,
java.lang.String sFilePathNameC,
java.util.List<ClassData> listClassInFile,
java.lang.String sPkgIdent)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private Report report
final java.lang.String sFileNameC
final JavaSrcTreeFile javaSrc
java.lang.String sPkgIdent
/ as separators and at end.
This information is got in #runFirstPass(ZbnfParseResultItem, LocalIdents, String, File)
from the package-declaration in the Java file. The dots . in Java file
are translated to slash / here.
private final java.lang.StringBuilder uFileCDefinitions
sClassC.
private final java.lang.StringBuilder uFileCSecondPath
sClassC.
private final java.lang.StringBuilder uFileHDefinitions
sClassC.
private final JavaSources javaSources
private final LocalIdents pkgIdents
javaSrc.JavaSrcTreeFile.itsPkg.JavaSrcTreePkg.pkgIdents
for faster access.
private final LocalIdents fileLevelIdents
ClassData which are visible at file level. It contains all classes
which are imported in this file. It doesn't contain the package visible identifier, see
private final java.util.Map<java.lang.String,java.lang.Object> usedEnhancedRefTypes
private final java.util.Map<java.lang.String,java.lang.Object> usedMtblRefTypesH
private final java.util.Map<java.lang.String,java.lang.Object> usedMtblRefTypesC
private java.io.File fileStruct
private final java.util.List<ClassData> listClassInFile
final RunRequiredFirstPass_ifc runRequiredFirstPass
private final java.util.TreeMap<java.lang.String,java.lang.String> includes
private final java.util.TreeMap<java.lang.String,java.lang.String> imports
final java.util.List<ClassData> listAllClassesForSecondPath
typedef struct... and plan C-routines.
| Constructor Detail |
|---|
GenerateFile(JavaSources javaSources,
JavaSrcTreeFile javaSrc,
RunRequiredFirstPass_ifc runRequiredFirstPass,
java.io.File fileStruct,
Report report)
| Method Detail |
|---|
public void writeCdefs(java.lang.StringBuilder content)
writeCdefs in interface iWriteContentcontent - the content with the necessary line feeds.public void writeHdefs(java.lang.StringBuilder content)
writeHdefs in interface iWriteContentcontent - the content with the necessary line feeds.public void writeClassC(java.lang.String content)
writeClassC in interface iWriteContentiWriteContent.writeClassC(java.lang.String)public void writeClassC(java.lang.StringBuilder content)
writeClassC in interface iWriteContentiWriteContent.writeClassC(java.lang.StringBuilder)public void writeClassH(java.lang.String line)
writeClassH in interface iWriteContentiWriteContent.writeClassH(java.lang.String)
public void addIncludeC(java.lang.String sFileName,
java.lang.String comment)
addIncludeC in interface iWriteContentsFileName - The file path without .hcomment - a commment written after the include line.
public void addIncludeH(java.lang.String sFileName,
java.lang.String comment)
addIncludeH in interface iWriteContentprivate java.lang.String unusedyet_getImport(java.lang.String sType)
void runFirstPassFile(ZbnfParseResultItem resultItem,
java.lang.String sPrefixClassCname,
java.lang.String sSuffixClassCname,
java.lang.String sPathOut)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
Java2C_Main.
resultItem - The first result item of ZBNF parsing of the whole java-File.pkgIdents - Global map of all classes of the whole translating process.sPathOut - output path for the h- and c-file, with slash on end
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentExceptionvoid registerClassInFile(ClassData classData)
void runSecondPassFile()
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
listAllClassesForSecondPath
is filled while running the first pass and contains all classes found in the java file.
The ZBNF parse result item of each class is stored there.
This routine is called from Java2C_Main.
sClassC.
If all runSecondPass of all found classes are done, the file will be written.
First the necessary includes will be written
in the destination c-file. Therefore the runSecondPass of all classes should be done before.
pkgIdents - Global map of all classes of the whole translating process.
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentExceptionpublic void addEnhancedRefType(java.lang.String sRefType)
sRefType - The referenced type.
public void addMtblRefType(java.lang.String sRefType,
char intension)
sRefType - The referenced type.
static void writeStructure(java.io.File fileStructP,
java.lang.String sFilePathNameC,
java.util.List<ClassData> listClassInFile,
java.lang.String sPkgIdent)
throws java.io.IOException
fileStructP - sFilePathNameC - Path and name for C,without extensionlistClassInFile - sPkgIdent -
java.io.IOException
void evaluateImports(ZbnfParseResultItem resultFile)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
java.io.IOException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseExceptionpublic java.lang.String toString()
toString in class java.lang.Objectvoid stop()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||