org.vishia.java2C
Class ClassData

java.lang.Object
  extended by org.vishia.java2C.ClassData
All Implemented Interfaces:
JavaSources.ClassDataOrJavaSrcFile

 class ClassData
extends java.lang.Object
implements JavaSources.ClassDataOrJavaSrcFile

This class represents the content of a java class while Translation. The instance is created and filled while executing the first pass of translation, that is the detecting of the class elements and generating the C-header. It is used for the second pass, the generation of C-file.
Chars are used to identify the kind of a element or type:

Ca class type identifier
Ian interface type identifier
Ba basic scalar type


Nested Class Summary
static class ClassData.CastInfo
          Simple Data class to hold Strings and modes for generation casting.
(package private) static class ClassData.InheritanceInfo
          Holds Informations about superclasses and interfaces.
(package private) static class ClassData.InitInfoVariable
          This class saves the position of zbnfInit in a parse result to the named variable.
(package private) static class ClassData.MethodArg
          unused yet, need?
private static class ClassData.MethodOverrideable
          This class composed the reference of a method and the name of implementation of the method in an inheriting class.
private static class ClassData.MethodOverrideCheck
          Instances of this class are created only temporary while running first pass of this class.
(package private)  class ClassData.MethodWithZbnfItem
           
 
Field Summary
private  boolean basedOnObject
           
 boolean bEmbedded
          Set if instances should only used embedded.
private  boolean bExternal
          True if the class isn't known in Java2C context.
private  boolean bFinalizeNeed
          Set true if any enhanced reference type is need.
private  boolean bInterface
          Set if it is an interface.
private  short bitArrayNeed
          Some bits set if the array form of the type is need anywhere.
private  java.util.TreeMap<java.lang.String,ClassData.CastInfo> castableFromType
          Types from which a cast is possible, and its cast rule.
private  java.util.TreeMap<java.lang.String,ClassData.CastInfo> castableInitializerFromType
          Types from which a cast for initial values is possible, and its cast rule.
private  java.util.TreeMap<java.lang.String,ClassData.CastInfo> castableToType
          Types to which a cast is possible, and its cast rule.
 LocalIdents classLevelIdents
          All known identifiers of this class.
 java.util.List<FieldData> classLevelIdentsOwn
          All identifiers of only this class.
 java.util.Map<java.lang.String,ClassData> classLevelUsageTypes
          All identifiers of only this class.
 FieldData classTypeInfo
          If this or a unnamed instance of the class is used as a reference, this field supplied the necessary instance infos.
 char creationMode
          Mode of anynymous class: C: inner class at class level F: class at file level P: primary class created in CRuntimeJavalike Y: anonymous class b: In a statement block.
(package private)  CCodeData ctorCodeInfo
          This codeinfo is used if a super constructor is called.
 char cVaArgIdent
          Char which identifies a value in a variable argument list.
(package private)  GenerateFile fileContainsClass
          The context of generating the whole file, where the class is defined.
private  boolean hasFields
          true if it has fields.
(package private)  ClassData.InheritanceInfo inheritanceInfo
          Tree of all method tables of interfaces and the superclasses.
private  java.util.List<ClassData> innerClasses
          All inner classes of only this class.
 boolean isAbstract
          Set if it is an abstract class.
 boolean isConstant
          Set if the class or interface has only get-methods, so that it is able to declare as const* in C.
 boolean isFinal
          Set if the class is final.
 boolean isNonStaticInner
          Set if the class is a non-static inner class (only inner classes can be static or non-static).
 boolean isStaticInstanciated
          Set if java2c = staticInstance is found in description of the class.
private  java.util.TreeMap<java.lang.String,java.lang.Object> methods
          Index of all methods with the same number of arguments.
private  java.util.TreeMap<java.lang.String,java.lang.Object> methodsCheckOverriding
          This index is only temporary used while the first pass is running.
private  java.util.TreeMap<java.lang.String,Method> methodsCname
          Index of all methods with its C name.
private  java.util.List<ClassData.MethodOverrideable> methodsOverrideableNew
          This index stores methods, which are designated as override-able, but they are defined in this class, the aren't found in any base class.
(package private)  java.util.Queue<ClassData.MethodWithZbnfItem> methodsWithZbnf
           
private static java.lang.String newLineIndent
          Helper variable to generate indentation, see indent(int)
(package private)  int nrofConstructor
           
(package private)  ClassData outerClazz
          The outer class of this or null.
 java.lang.String sArgSensitiveName
          Short form of type-name for argument sensitive C-routine names.
 java.lang.String sClassNameC
          The full name, like produced in C.
 java.lang.String sClassNameJava
          The full name in java, dot to separate outer.inner class names.
 java.lang.String sClassNameJavaFullqualified
           
 java.lang.String sFileName
          The file were the class is defined in C.
private  java.lang.String sInfo
          Information String given in constructor.
 java.lang.String sPackage
           
 java.lang.String sSourceOfClassData
          The source, from where the ClassData are created.
(package private)  java.util.List<ClassData.InitInfoVariable> staticVariables
          List of all static variables either with initial values or not.
(package private)  CCodeData thisCodeInfo
          This codeinfo is used if a classlevel ident is accessed.
(package private)  CCodeData typeCodeInfo
          This codeinfo contains an cCode == "" and the correct type.
private  java.util.List<ClassData.InitInfoVariable> variablesToInit
          List of parse result items of initial values for variables.
private  ZbnfParseResultItem zbnfClass
          For second pass, the parse result.
private  ZbnfParseResultItem zbnfFinalizeMethod
          For finalize method body, null if no finalize method is defined for java.
 
Constructor Summary
ClassData(java.lang.String sSourceOfClassData, GenerateFile fileContainsClass, java.lang.String sFileName, java.lang.String sPkgJava, java.lang.String sNameJava, java.lang.String sNameCP, java.lang.String sArgSensitiveName, char cVaArgIdent, ClassData outerClassData, ClassData superClassData, ClassData[] ifcClassData, ZbnfParseResultItem zbnfClass, char access, java.lang.String infos, char creationMode)
           
ClassData(java.lang.String sSourceOfClassData, java.lang.String sPkgJava, java.lang.String sNameJava, java.lang.String sNameC, java.lang.String sArgSensitiveName, char cVaArgIdent, java.lang.String sFileName, char access, java.lang.String infos)
           
 
Method Summary
 void addCastFromType(ClassData srcType, java.lang.String cast, java.lang.String modeAccessDstSrc)
          adds a casting possibility from a given type to this.
 void addCastInitializerFromType(ClassData srcType, java.lang.String cast, java.lang.String modeAccessDstSrc)
          adds a casting possibility for initializer.
 void addCastToType(ClassData dstType, java.lang.String cast, java.lang.String modeAccessDstSrc)
          adds a casting possibility to a given type from this.
 void addEnhancedRefType(java.lang.String sRefType)
          If a type is used as enhanced reference in the code of the class, it is noted here and in Java2CMain.
 void addField(java.lang.String sIdent, FieldData identInfo)
           
(package private)  void addInnerClass(ClassData innerClass)
          Adds in inner class to the class.
 void addMethod(Method m)
          Registers a given Method.
 void addMethod(java.lang.String sNameJava, java.lang.String sNameUnambiguous, FieldData returnType, ClassData[] paramsType)
          Adds.
 void addMethod(java.lang.String sNameJava, java.lang.String sNameUnambiguous, int modifier, FieldData returnType)
          Registers a argumentless method if the class is parsed or a standard class is initialized.
 void addMethod(java.lang.String sNameJava, java.lang.String sNameUnambiguous, int modifier, FieldData returnType, ClassData[] paramsType)
          Registers a Method if the class is parsed or a standard class is initialized.
(package private)  Method addMethod(java.lang.String sMethodNameJava, java.lang.String sMethodNameUnambiguous, int modifier, FieldData retType, FieldData[] argTypes)
           
(package private)  Method addMethod(java.lang.String sMethodNameJava, java.lang.String sMethodNameUnambiguous, java.lang.String sImplementationName, int modifier, FieldData retType, FieldData[] argTypes)
          Creates a method and adds it to the lists.
private  void addMethodToList(Method method)
          Adds the method to the lists methods and methodsCname
 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.
private  Method checkParameterMethod(java.lang.Object omethodFound, java.util.List<CCodeData> paramsTypeCheck)
           
private  boolean checkParameterTypesMethod(Method methodTest, FieldData[] paramsType)
           
(package private)  void completeFieldIdentsForInnerClasses()
          Copies all field idents of this class to its non-static inner classes, because the inner classes should know the idents of its outer class.
 void completeInheritanceWithListMethods(java.util.List<java.lang.String> methodNames)
          copies the override-able methods given in param in the inheritance info.
 void completeInheritanceWithOwnMethods()
          copies the new override-able methods of this class in the inheritance info.
(package private)  void completeTypesForInnerClasses()
          Completes the type information of this outer class for all its inner classes.
private  void fillMethodsOverrideable(ClassData.InheritanceInfo inheritanceInfo, java.lang.String sPathToMtbl, java.lang.String sPathToBase)
          Fills the methodsCheckOverriding with the informations given in inheritanceInfo.
 java.lang.String gen_ClassCppDefinitionContent()
          Generates the content of the class definition for C++, to write in the header-file.
private  int gen_MethodCpp(java.lang.StringBuilder u, Method method, int bitZchar)
           
 java.lang.String gen_MethodTableDefinitionContent()
          returns the definition of the methodtable of the class and all superclasses.
private  java.lang.String gen_MethodTableSuperStruct()
          returns the definition of the method-table of a superclass or interface as embedded struct.
(package private)  java.lang.String genMethodTableContent(ClassData.InheritanceInfo inheritanceInfo, java.lang.String sClassName, int indent)
          returns the definition of the methodtable of the class and all superclasses.
(package private)  ZbnfParseResultItem getBodyForFinalize()
          Gets the body for the finalize method.
 ClassData.CastInfo getCastInfoFromType(java.lang.String typeSrc)
          Returns the info how to cast from this type to another.
 ClassData.CastInfo getCastInfoToType(java.lang.String typeSrc)
          Returns the info how to downcast from this type to another.
 ClassData.CastInfo getCastInitializerFromType(java.lang.String typeSrc)
          Returns the info how to downcast from this type to another.
 java.lang.String getClassCtype_s()
          Returns the name of the class used as C-type.
 ClassData getClassData()
          returns the instance because it is.
 java.lang.String getClassIdentName()
          Returns the indentification name of a class.
 java.lang.String getClassNameJava()
          Returns the name of the class used in Java without package information.
 java.lang.String getClassNameJavaFullqualified()
           
 FieldData getFieldIdent(java.lang.String name)
          Test whether the field is known and returns it data.
 ClassData[] getInterfaces()
          Returns all interfaces of immediate level (not interfaces of base classes).
 JavaSrcTreePkg getJavaPkg()
          Implements JavaSources.ClassDataOrJavaSrcFile.getJavaPkg()
 JavaSrcTreeFile getJavaSrc()
          returns null because it is not.
 LocalIdents getLocalIdents(java.lang.String sClassName)
          Returns the identifier of classes or packages, which are available in the implementing package, file or class.
(package private)  Method getMethodPerCname(java.lang.String sNameC)
           
 ClassData getOuterClass()
          Returns the ClassData of outer class or null.
(package private)  ZbnfParseResultItem getParseResult()
           
 ConfigSrcPathPkg_ifc.Set getReplaceCinfo()
          This method returns null because for ready-to-use types this informations are not necessary.
 ClassData getSuperClassData()
          Returns the superclass or null.
 java.lang.String getTypeName()
          Implements JavaSources.ClassDataOrJavaSrcFile.getTypeName()
 java.util.List<ClassData.InitInfoVariable> getVariablesToInit()
           
 boolean hasFields()
           
private  java.lang.String indent(int recursion)
          Generates an indentation, used inside writeStructureClass(BufferedWriter, int)
 boolean isAmbiguousnessMethod(java.lang.String sNameJava)
          tests whether the method is ambiguous.
 boolean isBasedOnObject()
           
 boolean isExternal()
          Returns true if the class isn't known in Java2C context.
 boolean isFinalizeNeed()
          Returns true if the finalize is need but it is not written in Java.
 boolean isInterface()
          Returns true if it is an interface.
(package private)  boolean isneed_Y()
           
(package private)  boolean isneed_YP()
           
 boolean isPrimitiveType()
          Returns true if it is a primitive type without any own elements.
 boolean isString()
          Returns true if the type is 'String'.
 boolean isToTranslate()
          Returns false any time, because all informations are ready to use here.
(package private)  int matchedToTypeSrc(ClassData src)
          Checks whether the src matches to this class with or without type casting.
(package private)  void need_Y()
          Returns true if the ClassData represents an Array type.
(package private)  void need_YP()
           
 void needFinalize()
          Sets the finalize bit.
(package private)  void relinquishParseResult()
          relinquishes the parse result, because it is processed.
 void reportContent(Report console, int reportlevel)
           
 Method searchMethod(java.lang.String sNameJavaP, java.util.List<CCodeData> paramsTypeCheck, boolean strict, java.lang.String[] sPathMtbl)
          Searches a method with the given Java name and all argument types.
(package private)  ClassData.MethodOverrideCheck searchOverrideableMethod(java.lang.String sMethodNameJava, FieldData[] argTypes)
          searches whether a method found in the first pass of a translated class is already declared in an super class or interface of this class.
(package private)  void setBodyForFinalize(ZbnfParseResultItem zbnfFinalizeMethod)
          Sets the body for the finalize method.
 void setClassData(ClassData data)
           
private  void stop()
          Helper method for debugging.
 void testAndSetAmbiguousnessOfMethod(java.lang.String sNameJava)
          Tests whether a method is registered, registers it or set it to ambiguous if it exists already.
 java.lang.String toString()
          Helpfull for debugging in eclipse.
 void writeStructureClass(java.io.BufferedWriter out, int recursion)
          Writes the structure data of the class in file.stc.
 boolean xisObject()
           
 java.lang.String xxxgetRefObjectJc()
          returns a String, which describes the access to the ObjectJc-base, or return null, if the class isn't based on any class.
 boolean xxxisBasedOnObject()
           
 boolean xxxisObject()
           
 java.lang.String xxxtestAndcast(ClassData srcType, java.lang.String value, char intension)
          tests wether a cast is necessary, if it, returns the casted value.
(package private)  java.lang.String xxxwrite_OwnOverrideableMethods()
           
 java.lang.String xxxxxgetRefObjectJc()
          returns a String, which describes the access to the ObjectJc-base, or return null, if the class isn't based on any class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sClassNameC

public final java.lang.String sClassNameC
The full name, like produced in C. If it is an inner class, outer__inner.


sClassNameJava

public final java.lang.String sClassNameJava
The full name in java, dot to separate outer.inner class names.


sArgSensitiveName

public final java.lang.String sArgSensitiveName
Short form of type-name for argument sensitive C-routine names.


sPackage

public final java.lang.String sPackage

sClassNameJavaFullqualified

public final java.lang.String sClassNameJavaFullqualified

cVaArgIdent

public final char cVaArgIdent
Char which identifies a value in a variable argument list. The following chars are used: The upper-case-chars are the same, which are used in Java language to identify Array types returned by java.lang.Class.getName().


sFileName

public final java.lang.String sFileName
The file were the class is defined in C. Without extension .h.


fileContainsClass

final GenerateFile fileContainsClass
The context of generating the whole file, where the class is defined.


sSourceOfClassData

public final java.lang.String sSourceOfClassData
The source, from where the ClassData are created. It is used as a hint in exception message, if any method, field or etc. is missed.


isStaticInstanciated

public final boolean isStaticInstanciated
Set if java2c = staticInstance is found in description of the class. A class is a static instance if the class should not be created dynamically using garbage collection, but only in the construction path of the application. In such classes all final references to final classes (may not be staticInstance itself) are simple pointers in the C Conversion. Otherwise enhanced references are to be used.


sInfo

private final java.lang.String sInfo
Information String given in constructor.


isFinal

public final boolean isFinal
Set if the class is final.


isNonStaticInner

public final boolean isNonStaticInner
Set if the class is a non-static inner class (only inner classes can be static or non-static).


isConstant

public final boolean isConstant
Set if the class or interface has only get-methods, so that it is able to declare as const* in C.


creationMode

public final char creationMode
Mode of anynymous class:


basedOnObject

private final boolean basedOnObject

bEmbedded

public final boolean bEmbedded
Set if instances should only used embedded. It is a property able to set to classes with less elements.


bInterface

private final boolean bInterface
Set if it is an interface.


isAbstract

public final boolean isAbstract
Set if it is an abstract class.


bFinalizeNeed

private boolean bFinalizeNeed
Set true if any enhanced reference type is need.


zbnfClass

private ZbnfParseResultItem zbnfClass
For second pass, the parse result. NOTE: Not final because it should be removed after running second path.


bExternal

private final boolean bExternal
True if the class isn't known in Java2C context. It is a external used class.


zbnfFinalizeMethod

private ZbnfParseResultItem zbnfFinalizeMethod
For finalize method body, null if no finalize method is defined for java.


bitArrayNeed

private short bitArrayNeed
Some bits set if the array form of the type is need anywhere. The bits are coded in the set- and get-methods. See need_Y(), isneed_Y() etc.


classLevelIdents

public final LocalIdents classLevelIdents
All known identifiers of this class. Also fields of the outer classes and base classes. To search any known field identifier in class context, only an access to this instance should be necessary.


classLevelIdentsOwn

public final java.util.List<FieldData> classLevelIdentsOwn
All identifiers of only this class. Used for reflection generation and the stc-File.


innerClasses

private java.util.List<ClassData> innerClasses
All inner classes of only this class. Used for completion of inner classes with outer identifiers.


hasFields

private boolean hasFields
true if it has fields. Used for reflection generation.


classLevelUsageTypes

public final java.util.Map<java.lang.String,ClassData> classLevelUsageTypes
All identifiers of only this class.


castableInitializerFromType

private java.util.TreeMap<java.lang.String,ClassData.CastInfo> castableInitializerFromType
Types from which a cast for initial values is possible, and its cast rule. This list is build using #addCastInitializer(ClassData srcType, String cast) and used in #testAndcast(ClassData srcType, String value, char intension).


castableFromType

private java.util.TreeMap<java.lang.String,ClassData.CastInfo> castableFromType
Types from which a cast is possible, and its cast rule. This list is build using addCastFromType(ClassData srcType, String cast, String modes) and at least used in FieldData#testAndcast(CCodeData). This class provides the info via getCastInfoFromType(String) The key is the C-typename.


castableToType

private java.util.TreeMap<java.lang.String,ClassData.CastInfo> castableToType
Types to which a cast is possible, and its cast rule. This list is build using addCastToType(ClassData srcType, String cast, String modes) and at least used in FieldData#testAndcast(CCodeData). This class provides the info via getCastInfoToType(String) The key is the C-typename.


inheritanceInfo

ClassData.InheritanceInfo inheritanceInfo
Tree of all method tables of interfaces and the superclasses.


methods

private java.util.TreeMap<java.lang.String,java.lang.Object> methods
Index of all methods with the same number of arguments. The key is the java method name, following "#nr", where nr is the number of arguments. The value is either a Method or a List if more as one method with the same number of argumentes exists.


methodsCname

private java.util.TreeMap<java.lang.String,Method> methodsCname
Index of all methods with its C name.


methodsCheckOverriding

private java.util.TreeMap<java.lang.String,java.lang.Object> methodsCheckOverriding
This index is only temporary used while the first pass is running. All override-able methods from base classes and interfaces are referenced here, via the ClassData.InheritanceInfo.methodTable reference and the index in the table. Any occurrence of the same method in nested or parallel interfaces and super classes is registered only one time here. If a method is declared in an interface, and also declared in another parallel interface, than implemented in a super class, it is found here only one time with its unambiguous name (respecting same name but different parameter types). The unambiguous name is the same in all occurrences of the same method.
The key of this Map is the unambiguous name of the method.


methodsOverrideableNew

private java.util.List<ClassData.MethodOverrideable> methodsOverrideableNew
This index stores methods, which are designated as override-able, but they are defined in this class, the aren't found in any base class. The list is used only temporary while running the first pass. After them the content of this list will be stored in inheritanceInfo and there in ClassData.InheritanceInfo.methodTable of the primary level. A list but not an array is used first to add a unknown amount of methods.
The order of methods and hence the order of method in ClassData.InheritanceInfo.methodTable and in the generated method table in C-code is adequate the order of methods in the java source code. The order is important if the compiled C-unit is used as part of library, and using C-units should not be recompiled if inner functionality is changed in the library. The Headerfile contains and shows this order. It is the same problem like virtual methods in C++.


methodsWithZbnf

final java.util.Queue<ClassData.MethodWithZbnfItem> methodsWithZbnf

nrofConstructor

int nrofConstructor

classTypeInfo

public final FieldData classTypeInfo
If this or a unnamed instance of the class is used as a reference, this field supplied the necessary instance infos. It represents the instance as simple forward reference, like this respectively ythis in C.
An Unnamed instance is especially a returned instance reference or a instance per value (StringJc) of a method call.
In opposite: The typeCodeInfo contains a quasi-FieldData for static access.


thisCodeInfo

final CCodeData thisCodeInfo
This codeinfo is used if a classlevel ident is accessed. It is the CcodeData of this.


ctorCodeInfo

final CCodeData ctorCodeInfo
This codeinfo is used if a super constructor is called. It is either a reference to ObjectJc or MemC.


typeCodeInfo

final CCodeData typeCodeInfo
This codeinfo contains an cCode == "" and the correct type. The modeAccess is 'C'. It is used if a static access to a class member is translated. It is used in SecondPass.StatementBlock#gen_reference(String[], ZbnfParseResultItem, LocalIdents, CCodeData, char).


outerClazz

final ClassData outerClazz
The outer class of this or null.


variablesToInit

private final java.util.List<ClassData.InitInfoVariable> variablesToInit
List of parse result items of initial values for variables. Filled in first path, used in second pass.


staticVariables

final java.util.List<ClassData.InitInfoVariable> staticVariables
List of all static variables either with initial values or not. Filled in first path, used in second pass.


newLineIndent

private static final java.lang.String newLineIndent
Helper variable to generate indentation, see indent(int)

See Also:
Constant Field Values
Constructor Detail

ClassData

ClassData(java.lang.String sSourceOfClassData,
          GenerateFile fileContainsClass,
          java.lang.String sFileName,
          java.lang.String sPkgJava,
          java.lang.String sNameJava,
          java.lang.String sNameCP,
          java.lang.String sArgSensitiveName,
          char cVaArgIdent,
          ClassData outerClassData,
          ClassData superClassData,
          ClassData[] ifcClassData,
          ZbnfParseResultItem zbnfClass,
          char access,
          java.lang.String infos,
          char creationMode)
Parameters:
sSourceOfClassData -
fileContainsClass -
sFileName -
sPkgJava -
sNameJava -
sNameCP -
sArgSensitiveName -
cVaArgIdent -
outerClassData -
superClassData -
ifcClassData -
zbnfClass -
infos -
intension - Intension of creation, P: primary (file level), C: inner class, Y: anonymous inner class at class level, m, b etc: anonymous or not at statement block level
fileLevelIdents -

ClassData

ClassData(java.lang.String sSourceOfClassData,
          java.lang.String sPkgJava,
          java.lang.String sNameJava,
          java.lang.String sNameC,
          java.lang.String sArgSensitiveName,
          char cVaArgIdent,
          java.lang.String sFileName,
          char access,
          java.lang.String infos)
Method Detail

getVariablesToInit

public java.util.List<ClassData.InitInfoVariable> getVariablesToInit()

getClassData

public ClassData getClassData()
returns the instance because it is.

Specified by:
getClassData in interface JavaSources.ClassDataOrJavaSrcFile
See Also:
JavaSources.ClassDataOrJavaSrcFile.getClassData()

getJavaSrc

public JavaSrcTreeFile getJavaSrc()
returns null because it is not.

Specified by:
getJavaSrc in interface JavaSources.ClassDataOrJavaSrcFile
See Also:
JavaSources.ClassDataOrJavaSrcFile.getJavaSrc()

setBodyForFinalize

void setBodyForFinalize(ZbnfParseResultItem zbnfFinalizeMethod)
Sets the body for the finalize method.

Parameters:
zbnfFinalizeMethod -

getBodyForFinalize

ZbnfParseResultItem getBodyForFinalize()
Gets the body for the finalize method.

Parameters:
zbnfFinalizeMethod -

need_Y

void need_Y()
Returns true if the ClassData represents an Array type.


isneed_Y

boolean isneed_Y()

need_YP

void need_YP()

isneed_YP

boolean isneed_YP()

addField

public void addField(java.lang.String sIdent,
                     FieldData identInfo)

getFieldIdent

public FieldData getFieldIdent(java.lang.String name)
Test whether the field is known and returns it data.

Parameters:
name - The name of the field. The field can be local or in super scopes.
Returns:
null if the field isn't existing.

hasFields

public boolean hasFields()

addCastInitializerFromType

public void addCastInitializerFromType(ClassData srcType,
                                       java.lang.String cast,
                                       java.lang.String modeAccessDstSrc)
adds a casting possibility for initializer.

Parameters:
srcType - The src type for which the cast is valid.
cast - String in form "pre?post". To implement the cast the pre and post part will wrap the value.

addCastFromType

public void addCastFromType(ClassData srcType,
                            java.lang.String cast,
                            java.lang.String modeAccessDstSrc)
adds a casting possibility from a given type to this. This is used for special cases. The cast from a base class to all its derived class is not registered here. It needs instead a cast at programming level in Java.

Parameters:
srcType - Type from which the cast is possible
cast - String in form "pre?post". To implement the cast the pre and post part will wrap the value.
modeAccessDstSrc - first and second char is modeAccessDst and modeAccessSrc, typically "**" if both are pointers or "%%" if both are primitives. Only in special cases the modeAccess is differently

addCastToType

public void addCastToType(ClassData dstType,
                          java.lang.String cast,
                          java.lang.String modeAccessDstSrc)
adds a casting possibility to a given type from this. This is the typically cause for downcast form a derived class to its super class.

Parameters:
dstType - Type to which the cast is possible
cast - String in form "pre?post". To implement the cast the pre and post part will wrap the value.
modeAccessDstSrc - first and second char is modeAccessDst and modeAccessSrc, typically "**" if both are pointers or "%%" if both are primitives. Only in special cases the modeAccess is differently

xxxtestAndcast

public java.lang.String xxxtestAndcast(ClassData srcType,
                                       java.lang.String value,
                                       char intension)
tests wether a cast is necessary, if it, returns the casted value. This is checked to srcType. If srcType is the same as this, no cast occurs, the value is returned direct. If srcType is a derivateable type of this, the cast is set with #addCast(ClassData, String). That is used to produce the casted return value.

Parameters:
srcType - The type of the value
value - The value string.
intension - 'i' init-value may be in {...}
Returns:
The value itself if no cast is necessary

addMethod

public void addMethod(java.lang.String sNameJava,
                      java.lang.String sNameUnambiguous,
                      int modifier,
                      FieldData returnType,
                      ClassData[] paramsType)
Registers a Method if the class is parsed or a standard class is initialized. Inside addMethod(String, String, int, org.vishia.java2C.FieldData, org.vishia.java2C.FieldData[]) is called with classTypeInfo.

Parameters:
sNameJava - Name of the method in Java
sCName - Name of the method to translate in C. If more than 1 method with the same sNameJava is given, the sCName should be unambiguous.
modifier - Ones of ClassData.Method#modeStatic, ClassData.Method#modeNoThCxt
returnType - The type of return. It isn't a Classdata, but a IdentInfo, because some additional properties like return by value or reference should be present.
paramsType - Array of all argument types. They are given in form of pure types, because they are taken with standard conventions: simple pointers or simple primitive types.

addMethod

public void addMethod(java.lang.String sNameJava,
                      java.lang.String sNameUnambiguous,
                      FieldData returnType,
                      ClassData[] paramsType)
Adds. @deprecated, use addMethod(String, String, int, FieldData, ClassData[])

Parameters:
sNameJava -
sCName -
returnType -
paramsType -

addMethod

public void addMethod(java.lang.String sNameJava,
                      java.lang.String sNameUnambiguous,
                      int modifier,
                      FieldData returnType)
Registers a argumentless method if the class is parsed or a standard class is initialized.

Parameters:
sNameJava -
sCName -
modifier -
returnType -

addMethod

final Method addMethod(java.lang.String sMethodNameJava,
                       java.lang.String sMethodNameUnambiguous,
                       int modifier,
                       FieldData retType,
                       FieldData[] argTypes)

addMethod

final Method addMethod(java.lang.String sMethodNameJava,
                       java.lang.String sMethodNameUnambiguous,
                       java.lang.String sImplementationName,
                       int modifier,
                       FieldData retType,
                       FieldData[] argTypes)
Creates a method and adds it to the lists. Test whether this method is already defined in a superclass or interface and overrides it. The name of the override-able method in ClassData.InheritanceInfo.methodTable (aggregation inheritanceInfo) is changed to the name of this method for all overridden methods. It is possible that more as one overridden method is found, if the same method is defined in an interface, in more as one parallel inherited interfaces or in more as one nested interfaces or super-classes.

Parameters:
sMethodNameJava - given method-name in Java or ctorO or ctorM
sMethodNameUnambiguous - The java name plus argument type designations if the method is ambiguous.
argTypes - Array of all argument types with there type modifier.
modifier - Contains bits ClassData.Method#modeStatic, ClassData.Method#modeNoThCxt or ClassData.Method#modeOverrideable.
If the method is able to override, its unambiguous name is saved in methodsOverrideableNew of this ClassData. The keyname is ... TODO. The method name is also saved in ClassData.InheritanceInfo.methodTable. This information is used primary to write out the method table. The names are copied and changed in an inherited class.
retType - The type of return. It isn't a Classdata, but a IdentInfo, because some additional properties like return by value or reference should be present.
Returns:
The created and registered instance of method.

addMethodToList

private void addMethodToList(Method method)
Adds the method to the lists methods and methodsCname

Parameters:
method -

searchOverrideableMethod

ClassData.MethodOverrideCheck searchOverrideableMethod(java.lang.String sMethodNameJava,
                                                       FieldData[] argTypes)
searches whether a method found in the first pass of a translated class is already declared in an super class or interface of this class. If the method is found more as one time in parallel interfaces, there is noted only one time. But the occurrence is stored in the returned instance.

Parameters:
sMethodNameJava - The method name in Java
argTypes - arg types of the found method.
Returns:
null if the method isn't declared already, elsewhere the override-able method description.

addMethod

public void addMethod(Method m)
Registers a given Method. This routine is used if a file.stc is parsed.

Parameters:
m - The Method data.

addEnhancedRefType

public void addEnhancedRefType(java.lang.String sRefType)
If a type is used as enhanced reference in the code of the class, it is noted here and in Java2CMain. The information will be used to define the enhanced references in the Headerfile, it is also transformed to the stc file. (?)

Parameters:
sRefType - The referenced type.

addInnerClass

void addInnerClass(ClassData innerClass)
Adds in inner class to the class.

Parameters:
innerClass -

completeFieldIdentsForInnerClasses

void completeFieldIdentsForInnerClasses()
Copies all field idents of this class to its non-static inner classes, because the inner classes should know the idents of its outer class.


completeTypesForInnerClasses

void completeTypesForInnerClasses()
Completes the type information of this outer class for all its inner classes. This routine is called after GenerateFile.runFirstPassFile(ZbnfParseResultItem, String, String, String) of this class is finished. Then all types of this class, they are the inner classes, are gathered. All inner classes have to know all the other inner classes too, the inner classes should be known together. Additional the inner classes should know its outer one as type too.

This routine is called recursively for all its own inner classes too.


needFinalize

public void needFinalize()
Sets the finalize bit. This method is called if any condition is met which requires the generation of a finalize method. It is, if the class contains enhanced references or if a finalize method is given in Java code.


addMtblRefType

public 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. The information will be used to define the enhanced references in the Headerfile, it is also transformed to the stc file. (?)

Parameters:
sRefType - The referenced type.

testAndSetAmbiguousnessOfMethod

public void testAndSetAmbiguousnessOfMethod(java.lang.String sNameJava)
Tests whether a method is registered, registers it or set it to ambiguous if it exists already. This routine is called processing the first pass of translation. It creates an entry with key sNameJava + "?" to check ambiguously. In the second pass the methods are registered with full informations.

Parameters:
sNameJava - The method name.

isAmbiguousnessMethod

public boolean isAmbiguousnessMethod(java.lang.String sNameJava)
tests whether the method is ambiguous. The method have to be exist.

Parameters:
sNameJava -
Returns:
true if more as one method with the same Java name exists.

checkParameterTypesMethod

private boolean checkParameterTypesMethod(Method methodTest,
                                          FieldData[] paramsType)

getMethodPerCname

Method getMethodPerCname(java.lang.String sNameC)

searchMethod

public Method searchMethod(java.lang.String sNameJavaP,
                           java.util.List<CCodeData> paramsTypeCheck,
                           boolean strict,
                           java.lang.String[] sPathMtbl)
Searches a method with the given Java name and all argument types.

Parameters:
sNameJavaP - The name in Java.
paramsTypeCheck - All argument types. It is tested whether the argument types are able to cast to the matching types.
strict - true then the method is not created if if isn't found. It should be found.
sPathMtbl - Starting with "", a seach in a super-class adds the path.
Returns:
The appropriate method or null if no method matches.

checkParameterMethod

private Method checkParameterMethod(java.lang.Object omethodFound,
                                    java.util.List<CCodeData> paramsTypeCheck)

getClassCtype_s

public java.lang.String getClassCtype_s()
Returns the name of the class used as C-type. If it is an generated class, that type names have an extension _s. The type name without this extension is useable, if a C++-wrapper-class of that type is desired.


getClassNameJava

public java.lang.String getClassNameJava()
Returns the name of the class used in Java without package information.


getClassIdentName

public java.lang.String getClassIdentName()
Returns the indentification name of a class. If the class is generated from java2c, it is the name without the _s or _i on end. The identification is used as postfix of the static visible class elements. But the struct type have the additional postfix _s or _i to to distinguish between its possible C++-class.


getClassNameJavaFullqualified

public java.lang.String getClassNameJavaFullqualified()

isPrimitiveType

public boolean isPrimitiveType()
Returns true if it is a primitive type without any own elements. It is, if the element classLevelIdents is null.


isString

public boolean isString()
Returns true if the type is 'String'.


xxxisObject

public boolean xxxisObject()

xisObject

public boolean xisObject()

isInterface

public boolean isInterface()
Returns true if it is an interface.


isFinalizeNeed

public boolean isFinalizeNeed()
Returns true if the finalize is need but it is not written in Java.


getSuperClassData

public ClassData getSuperClassData()
Returns the superclass or null.


getOuterClass

public ClassData getOuterClass()
Returns the ClassData of outer class or null.


getInterfaces

public ClassData[] getInterfaces()
Returns all interfaces of immediate level (not interfaces of base classes).

Returns:
The interfaces are provided in an array.

xxxgetRefObjectJc

public java.lang.String xxxgetRefObjectJc()
returns a String, which describes the access to the ObjectJc-base, or return null, if the class isn't based on any class. It assumes, all superclasses should have the name "super", the ObjectJc-superclass should have the name "object". At ex. returns "object"

Returns:

xxxxxgetRefObjectJc

public java.lang.String xxxxxgetRefObjectJc()
returns a String, which describes the access to the ObjectJc-base, or return null, if the class isn't based on any class. It assumes, all superclasses should have the name "super", the ObjectJc-superclass should have the name "object". At ex. returns "object"

Returns:

isBasedOnObject

public boolean isBasedOnObject()

xxxisBasedOnObject

public boolean xxxisBasedOnObject()

isExternal

public boolean isExternal()
Returns true if the class isn't known in Java2C context. It is a external used class.


getCastInfoFromType

public ClassData.CastInfo getCastInfoFromType(java.lang.String typeSrc)
Returns the info how to cast from this type to another.

Parameters:
typeSrc - Name of the source type.
Returns:
CastInfo contains pre- and suffix C-Code and the modeAccess.

getCastInfoToType

public ClassData.CastInfo getCastInfoToType(java.lang.String typeSrc)
Returns the info how to downcast from this type to another.

Parameters:
typeSrc - Name of the source type.
Returns:
CastInfo contains pre- and suffix C-Code and the modeAccess.

getCastInitializerFromType

public ClassData.CastInfo getCastInitializerFromType(java.lang.String typeSrc)
Returns the info how to downcast from this type to another.

Parameters:
typeSrc - Name of the source type.
Returns:
CastInfo contains pre- and suffix C-Code and the modeAccess.

matchedToTypeSrc

int matchedToTypeSrc(ClassData src)
Checks whether the src matches to this class with or without type casting.

Parameters:
src - The type to compare
Returns:
the score. 0: doesn't match 1 .. 4 see ClassData.CastInfo.kCastAble.

getParseResult

ZbnfParseResultItem getParseResult()

relinquishParseResult

void relinquishParseResult()
relinquishes the parse result, because it is processed. It should not consumed memory.


indent

private java.lang.String indent(int recursion)
Generates an indentation, used inside writeStructureClass(BufferedWriter, int)

Parameters:
recursion - nesting level
Returns:
A newline char and the appropritate number of spaces for indentation.

reportContent

public void reportContent(Report console,
                          int reportlevel)

gen_MethodTableDefinitionContent

public java.lang.String gen_MethodTableDefinitionContent()
returns the definition of the methodtable of the class and all superclasses.


gen_ClassCppDefinitionContent

public java.lang.String gen_ClassCppDefinitionContent()
Generates the content of the class definition for C++, to write in the header-file.

Returns:

gen_MethodCpp

private int gen_MethodCpp(java.lang.StringBuilder u,
                          Method method,
                          int bitZchar)

genMethodTableContent

java.lang.String genMethodTableContent(ClassData.InheritanceInfo inheritanceInfo,
                                       java.lang.String sClassName,
                                       int indent)
returns the definition of the methodtable of the class and all superclasses.

Parameters:
classDataP -
Returns:

xxxwrite_OwnOverrideableMethods

java.lang.String xxxwrite_OwnOverrideableMethods()

fillMethodsOverrideable

private void fillMethodsOverrideable(ClassData.InheritanceInfo inheritanceInfo,
                                     java.lang.String sPathToMtbl,
                                     java.lang.String sPathToBase)
Fills the methodsCheckOverriding with the informations given in inheritanceInfo. This routine is called only after inheritanceInfo is initalized in the constructor of this. In the picture ...TODO

Parameters:
inheritanceInfo - of the adequate level, this routine is called recursively for all supers and interfaces.

completeInheritanceWithOwnMethods

public void completeInheritanceWithOwnMethods()
copies the new override-able methods of this class in the inheritance info. The methods were captured in methodsOverrideableNew. It will be written to inheritanceInfo.ClassData.InheritanceInfo.methodTable. The order of the given is important for method table Mtbl in C
The methodsOverrideableNew and the methodsCheckOverriding were cleared (set to null) because its content isn't necessary for translation the other classes.


completeInheritanceWithListMethods

public void completeInheritanceWithListMethods(java.util.List<java.lang.String> methodNames)
copies the override-able methods given in param in the inheritance info. It will be written to inheritanceInfo.ClassData.InheritanceInfo.methodTable.
The methodsOverrideableNew and the methodsCheckOverriding were cleared (set to null) because its content isn't necessary for translation the other classes.

Parameters:
methodNames - List of names with that methods, which are to write in the Inheritanceinfo. The order is important for method table Mtbl in C

gen_MethodTableSuperStruct

private java.lang.String gen_MethodTableSuperStruct()
returns the definition of the method-table of a superclass or interface as embedded struct.


toString

public java.lang.String toString()
Helpfull for debugging in eclipse. The infos from Object.toString() is given too.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getLocalIdents

public LocalIdents getLocalIdents(java.lang.String sClassName)
Description copied from interface: JavaSources.ClassDataOrJavaSrcFile
Returns the identifier of classes or packages, which are available in the implementing package, file or class.

Specified by:
getLocalIdents in interface JavaSources.ClassDataOrJavaSrcFile
Parameters:
sClassName - Name of the element. Especially if it is a JavaSrcTreeFile, it may be the name of the public class or another class in the file.
Returns:
Especially list of all types in the element. If it is a package, the types may be the files in the package or sub-packages.

getJavaPkg

public JavaSrcTreePkg getJavaPkg()
Implements JavaSources.ClassDataOrJavaSrcFile.getJavaPkg()

Specified by:
getJavaPkg in interface JavaSources.ClassDataOrJavaSrcFile

getTypeName

public java.lang.String getTypeName()
Implements JavaSources.ClassDataOrJavaSrcFile.getTypeName()

Specified by:
getTypeName in interface JavaSources.ClassDataOrJavaSrcFile

getReplaceCinfo

public ConfigSrcPathPkg_ifc.Set getReplaceCinfo()
This method returns null because for ready-to-use types this informations are not necessary.

Specified by:
getReplaceCinfo in interface JavaSources.ClassDataOrJavaSrcFile
Returns:
null if there are not such informations. That is especially for super-paths.
See Also:
JavaSources.ClassDataOrJavaSrcFile.getReplaceCinfo()

isToTranslate

public boolean isToTranslate()
Returns false any time, because all informations are ready to use here.

Specified by:
isToTranslate in interface JavaSources.ClassDataOrJavaSrcFile
Returns:
false if always the stc-File is to be read, or it is a ClassData.
See Also:
JavaSources.ClassDataOrJavaSrcFile.isToTranslate()

writeStructureClass

public void writeStructureClass(java.io.BufferedWriter out,
                                int recursion)
                         throws java.io.IOException
Writes the structure data of the class in file.stc.

Parameters:
out - destination
recursion - nesting level
Throws:
java.io.IOException

setClassData

public void setClassData(ClassData data)
Specified by:
setClassData in interface JavaSources.ClassDataOrJavaSrcFile

stop

private void stop()
Helper method for debugging.