|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vishia.java2C.GenerateClass
org.vishia.java2C.FirstPass
public class FirstPass
This class processes the first pass of translating Java to C of a detect class in a java file.
Parsing the content of the java file is done before, see GenerateFile.
In the first pass all declared elements of a class are captured and store in the ClassData.
| Field Summary | |
|---|---|
(package private) boolean |
bDontWriteCtor
|
private java.util.List<FirstPass> |
innerClasses
|
private ZbnfParseResultItem |
zbnfClass
|
| Fields inherited from class org.vishia.java2C.GenerateClass |
|---|
classData, fileLevelIdents, log, parentGenerateFile, runRequiredFirstPass, sMethodNameCurrent, writeContent |
| Constructor Summary | |
|---|---|
FirstPass(iWriteContent writeContent,
GenerateFile parentGenerateFile,
LocalIdents fileLevelIdents,
RunRequiredFirstPass_ifc runRequiredFirstPass,
Report log)
initializes the instances with the given associations. |
|
| Method Summary | |
|---|---|
(package private) ClassData |
buildType(java.lang.StringBuilder uResult,
java.lang.String sourceOfClassDataP,
GenerateFile fileContainsClass,
java.lang.String sFileNameC,
java.lang.String sPkgIdent,
java.lang.String sPrefixClassCname,
java.lang.String sSuffixClassCname,
ZbnfParseResultItem zbnfClass,
boolean bDontWriteCtor,
java.lang.String sOuterClassName,
ClassData outerClassData,
java.util.List<ClassData> listAllClassesForSecondPath,
boolean bInterface,
ClassData classBase,
char intension)
|
(package private) java.lang.String |
gen_methodArguments(ZbnfParseResultItem zbnfMethod,
LocalIdents localIdents,
char intension,
java.lang.String[] retArgSensitiveName,
java.util.List<FieldData> retArgTypes)
Generates the formal argument list of a method used both by generating method declaration or method definition. |
(package private) Method |
gen_methodHeadAndRegisterMethod(ZbnfParseResultItem zbnfMethod,
int modeCtor,
ClassData classOfMethod,
java.lang.String sMethodNameJava,
FieldData typeReturn,
FieldData[] argTypes,
boolean bArgumentSensitive)
Generates a method head with syntax methodDefinition::= from given ZBNF parse result item
and registers the method in the classData. |
(package private) void |
runFirstPass2(java.lang.StringBuilder uResult)
Generates the content of a class in the h-file with given ZBNF parse result item of the class. |
private void |
write_ClassCpp(java.lang.StringBuilder uHeader)
|
private void |
write_HeaderContent(java.lang.StringBuilder uHeader,
GenerateFile fileContainsClass,
ZbnfParseResultItem zbnfClass,
boolean bDontWriteCtor,
java.lang.String XXXsClassNameC,
ClassData superClazz,
ClassData[] ifcClassData)
Write out the header part of the class. |
(package private) void |
write_Interface(ZbnfParseResultItem itemClass,
java.lang.String sOuterClassName,
ClassData outerClassData,
java.lang.StringBuilder uHeader)
Generates the content of an interface in c- and h-file. |
void |
write_methodDeclaration(ZbnfParseResultItem zbnfMethod,
java.lang.String sClassName,
LocalIdents localIdents,
java.lang.StringBuilder uHeader)
writes a method-forward-declaration in Headerfile and registers the method to generate definition. |
private void |
write_Mtbl(java.lang.StringBuilder uHeader)
|
private void |
writeCtor(ZbnfParseResultItem zbnfClass,
ClassData outerClass,
java.lang.StringBuilder uHeader)
|
private ClassData[] |
zbnfResultInterfaces(ZbnfParseResultItem zbnfClass,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdentsIfcType,
ClassData firstInterface)
Gets the interfaces from ZBNF parse result item. |
(package private) ClassData |
zbnfResultSuperclass(ZbnfParseResultItem zbnfClass,
ZbnfParseResultItem zbnfDescription,
ClassData outerClassData)
Gets the superClass from ZBNF parse result item. |
| Methods inherited from class org.vishia.java2C.GenerateClass |
|---|
createFieldDataNewObject, createFieldInfo, gen_AnonymousClass, gen_variableDefinition, genConstantValue, genIndent, get_shortDescription, getDimensionsArray, getType, getTypeInfoArray, getTypeInfoSimple, setStop, stop, stopCond, write_Description |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.List<FirstPass> innerClasses
private ZbnfParseResultItem zbnfClass
boolean bDontWriteCtor
| Constructor Detail |
|---|
FirstPass(iWriteContent writeContent,
GenerateFile parentGenerateFile,
LocalIdents fileLevelIdents,
RunRequiredFirstPass_ifc runRequiredFirstPass,
Report log)
| Method Detail |
|---|
ClassData buildType(java.lang.StringBuilder uResult,
java.lang.String sourceOfClassDataP,
GenerateFile fileContainsClass,
java.lang.String sFileNameC,
java.lang.String sPkgIdent,
java.lang.String sPrefixClassCname,
java.lang.String sSuffixClassCname,
ZbnfParseResultItem zbnfClass,
boolean bDontWriteCtor,
java.lang.String sOuterClassName,
ClassData outerClassData,
java.util.List<ClassData> listAllClassesForSecondPath,
boolean bInterface,
ClassData classBase,
char intension)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
uResult - sourceOfClassDataP - fileContainsClass - sFileNameC - sPkgIdent - sPrefixClassCname - sSuffixClassCname - zbnfClass - bDontWriteCtor - sOuterClassName - outerClassData - listAllClassesForSecondPath - bInterface - classBase - intension - C: inner class, P: file-level (primary) class, Y: class level anonymous,
other: anonymous inner class at statement block level
java.io.IOException
java.text.ParseException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.InstantiationException
void runFirstPass2(java.lang.StringBuilder uResult)
throws java.lang.IllegalArgumentException,
java.io.IOException,
java.text.ParseException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
GenerateFile.
ClassData#listVariablesToInit.
This action is done inside the called routine GenerateClass#gen_variableDefinition(ZbnfParseResultItem, LocalIdents, List, char, ClassData[]).
#write_methodDeclaration(ZbnfParseResultItem, String, LocalIdents).
uResult -
java.lang.IllegalArgumentException
java.io.IOException
java.text.ParseException
java.lang.IllegalAccessException
java.lang.InstantiationException
ClassData zbnfResultSuperclass(ZbnfParseResultItem zbnfClass,
ZbnfParseResultItem zbnfDescription,
ClassData outerClassData)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
zbnfClass - The parse result item of classDefinition::=...zbnfDescription - The parse result item of < description>... test_description::=
inside the classDefinition::=...outerClassData - a given outerclass
Java2C_Main.CRuntimeJavalikeClassData#clazzObjectJc
if no superclass is given in Java-code (no extends ...).
It is null if the description contains @java2c=noObject. and no other superclass is given.
java.io.FileNotFoundException - The Superclass may be translated yet nested, it may be cause some errors.
java.lang.IllegalArgumentException - Errors see #runFirstPassClass(GenerateFile, String, String, String, String, ZbnfParseResultItem, String, ClassData, List, boolean, LocalIdents).
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseException
private ClassData[] zbnfResultInterfaces(ZbnfParseResultItem zbnfClass,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdentsIfcType,
ClassData firstInterface)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
zbnfClass - The parse result item of classDefinition::=...zbnfDescription - The parse result item of < description>... test_description::=
inside the classDefinition::=...outerClassData - a given outerclasssFirstInterface - name of the interface for anonymous classes
java.io.FileNotFoundException - The Superclass may be translated yet nested, it may be cause some errors.
java.lang.IllegalArgumentException - Errors see #runFirstPassClass(GenerateFile, String, String, String, String, ZbnfParseResultItem, String, ClassData, List, boolean, LocalIdents).
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseException
private void write_HeaderContent(java.lang.StringBuilder uHeader,
GenerateFile fileContainsClass,
ZbnfParseResultItem zbnfClass,
boolean bDontWriteCtor,
java.lang.String XXXsClassNameC,
ClassData superClazz,
ClassData[] ifcClassData)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.text.ParseException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
/*@CLASS_C NAME @@@@@@@@@@@@@@@@@@@@@* /
typedef struct NAME_t
{ union base_{ ObjectJc object; SUPER super; IFC IFC; } base
VARIABLETYPE VARIABLENAME;
} NAME_s;
typedef struct NAME_Y_t { ObjectArrayJc head; " + NAME + "_s data[50]; } NAME_Y;");
extern struct ClassJc_t const reflection_NAME_s;
extern STATICVARIABLEDEF NAME;
...etc TODO
uHeader - The buffer for output.fileContainsClass - The calling instance.zbnfClass - The parse result item of the class definition.bDontWriteCtor - if it is an interface or anonymous class.sClassNameC - The name, it is dissolved already from zbnfClasssuperClazz - The superclass or ObjectJc or nullifcClassData - null or interfaces
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.text.ParseException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
private void writeCtor(ZbnfParseResultItem zbnfClass,
ClassData outerClass,
java.lang.StringBuilder uHeader)
throws java.lang.IllegalArgumentException,
java.io.IOException,
java.text.ParseException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
zbnfClass - outerClass - uHeader -
java.lang.IllegalArgumentException
java.io.IOException
java.text.ParseException
java.lang.IllegalAccessException
java.lang.InstantiationExceptionprivate void write_Mtbl(java.lang.StringBuilder uHeader)
private void write_ClassCpp(java.lang.StringBuilder uHeader)
void write_Interface(ZbnfParseResultItem itemClass,
java.lang.String sOuterClassName,
ClassData outerClassData,
java.lang.StringBuilder uHeader)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.io.IOException
java.text.ParseException
public void write_methodDeclaration(ZbnfParseResultItem zbnfMethod,
java.lang.String sClassName,
LocalIdents localIdents,
java.lang.StringBuilder uHeader)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
zbnfMethod - with syntax methodDefinition::=.
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
Method gen_methodHeadAndRegisterMethod(ZbnfParseResultItem zbnfMethod,
int modeCtor,
ClassData classOfMethod,
java.lang.String sMethodNameJava,
FieldData typeReturn,
FieldData[] argTypes,
boolean bArgumentSensitive)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
methodDefinition::= from given ZBNF parse result item
and registers the method in the classData. The ambiguousness of the method should be tested before this call,
but the unambiguous method name for C is built here: Methods with equal names but different parameter types
are different methods.
zbnfMethod - Zbnf item defined in <methodDefinition>
or <constructorDefinition>. The head hasn't an own zbnf-result item.
The following contained elements are tested:
<description>, calling GenerateClass.get_shortDescription(ZbnfParseResultItem)
<static> defined in Modifier::=>
<argumentList>, calling gen_methodArguments(ZbnfParseResultItem, LocalIdents, char, String[], List)
ctor - '.' if it isn't a ctor, 'C'-static ctor of class 'n'-ctor of non-static inner class. 'y'-ctor of anonymous classclassOfMethod - environment class, for non-static constructors the outer class.sMethodNameJava - Name of the method, "ctorO" if a constructor from given ObjectJc should be generated.typeReturn - Type of the method, get outside because this routine is also used to generate constructors.
On constructor generation this argument should be equal the environment class type.bArgumentSensitive - true than more as one method with the same Java-name exists.
It is tested before calling ClassData.isAmbiguousnessMethod(String).
The C-name of the method is built regarding the type of the arguments.
Method.sMethodFormalListDefiniton
promoted in Method.gen_MethodForwardDeclaration() and
Method.gen_MethodHeadDefinition().
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.String gen_methodArguments(ZbnfParseResultItem zbnfMethod,
LocalIdents localIdents,
char intension,
java.lang.String[] retArgSensitiveName,
java.util.List<FieldData> retArgTypes)
throws java.text.ParseException,
java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
zbnfMethod - Zbnf item defined in argumentList::=>....localIdents - The known identificators of the calling environment, the type identificators are used especially.
This parameter is used calling #gen_variableDefinition(ZbnfParseResultItem, LocalIdents, List, char intension, ClassData[])
inside with the parameters of the head. If the intension=='a' (Method definition in C-File),the parameter-variables are added to the localIdents.intension - Intension of call: 'A'-declaration in h-File, 'a'-definition in c-file, passing on gen_variableDefinition().retArgSensitiveName - [0] is filled with the short name of arg types if not null.retArgTypes - The list is filled with the detect argument types, used for argument sensitive method call.
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||