|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vishia.java2C.GenerateClass
class GenerateClass
This is the superclass for FirstPass and SecondPass.
It contains commonly methods used in both passes and commonly data for both passes.
This class isn't store as instance between both passes, elsewhere the ClassData to store are stored
in the instance of ClassData, all the ClassData are contained in a list
inside AllClassData.
The attributes of this class are copied from the Java2C_Main in construction
and there are forgotten after running the pass.
| Field Summary | |
|---|---|
protected ClassData |
classData
The data of this class for first and second path. |
protected LocalIdents |
fileLevelIdents
A TreeMap of all classData sorted by classname to find all other classData. |
protected Report |
log
|
protected GenerateFile |
parentGenerateFile
|
(package private) RunRequiredFirstPass_ifc |
runRequiredFirstPass
The interface to call a firstpass run of a needed type. |
protected java.lang.String |
sMethodNameCurrent
The C-name of the current translated method, used for _Stacktrace and alloc_s_BlockHeapJc. |
private static java.lang.String |
sNewLine
String to generate newline and indent. |
private boolean |
stopCond
|
protected iWriteContent |
writeContent
A writer to file. |
| Constructor Summary | |
|---|---|
protected |
GenerateClass(iWriteContent writeContent,
GenerateFile parentGenerateFile,
LocalIdents fileLevelIdents,
RunRequiredFirstPass_ifc runRequiredFirstPass,
Report log)
constructs the class. |
| Method Summary | |
|---|---|
(package private) FieldData |
createFieldDataNewObject(ZbnfParseResultItem zbnfNewObject,
ZbnfParseResultItem zbnfDescription,
LocalIdents typeIdentsForNew,
LocalIdents localIdentsP,
StatementBlock blockEnvironment,
java.lang.String sNameField,
ClassData declaringClass,
char intension,
char accessModeP,
char staticMode,
boolean isFinal)
Creates FieldData for a new Type(...) |
FieldData |
createFieldInfo(ZbnfParseResultItem zbnfVariable,
ZbnfParseResultItem zbnfType,
ZbnfParseResultItem zbnfDescription,
ZbnfParseResultItem zbnfNewObject,
LocalIdents localIdentsP,
StatementBlock blockEnvironment,
ClassData declaringClass,
char intension,
char definitionCondition)
Prepare the type properties from a given ZBNF type::= or adequate info. |
ClassData |
gen_AnonymousClass(ZbnfParseResultItem zbnfNewObject,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdents,
StatementBlock blockEnvironment,
java.lang.String sNameField,
char intension,
GenerateFile fileContainsClass)
Generate an anonymous class, in Java: new Type(..){...} |
protected CCodeData |
gen_variableDefinition(ZbnfParseResultItem zbnfVariableDefinition,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdents,
StatementBlock blockEnvironment,
java.util.List<ClassData.InitInfoVariable> listVariablesToInit,
char intension)
Generates a variable definition with syntax of < variableDefinition>, register the variable in the LocalIdents of the class or block and registers in the list of variables to init or static variables. |
protected CCodeData |
genConstantValue(ZbnfParseResultItem item)
generates constants values from parse result of the syntaxterm simpleValue. |
static java.lang.String |
genIndent(int indent)
generates a String with the correct indentation. |
(package private) java.lang.String |
get_shortDescription(ZbnfParseResultItem zbnfDescription)
Prepares the description from the < description>parse result item. |
int |
getDimensionsArray(ZbnfParseResultItem zbnfType)
Gets the info whether the type is an array type written like ident[][]. |
protected ClassData |
getType(ZbnfParseResultItem zbnfType,
LocalIdents localIdentsP)
Provides the ClassData for the given type. |
(package private) FieldData |
getTypeInfoArray(ZbnfParseResultItem zbnfVariable,
ZbnfParseResultItem zbnfType,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdentsP,
java.lang.String sNameField,
ClassData declaringClass,
char intension,
char accessMode,
ClassData typeClass,
char staticMode,
int dimensionArray)
|
(package private) FieldData |
getTypeInfoSimple(ZbnfParseResultItem zbnfVariable,
ZbnfParseResultItem zbnfType,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdentsP,
java.lang.String sNameField,
ClassData declaringClass,
char intension,
char accessMode,
ClassData typeClass,
ClassData instanceClass,
char staticMode,
ZbnfParseResultItem itemNewObject)
|
protected void |
setStop()
|
protected void |
stop()
It's a debug helper. |
protected void |
stopCond()
|
protected void |
write_Description(ZbnfParseResultItem item,
java.lang.StringBuilder uHeader)
writes the parsed description in the H-File. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Report log
private static final java.lang.String sNewLine
protected iWriteContent writeContent
protected final LocalIdents fileLevelIdents
protected final GenerateFile parentGenerateFile
protected ClassData classData
protected java.lang.String sMethodNameCurrent
SecondPass#write_methodDefinition(ZbnfParseResultItem, String, LocalIdents).
final RunRequiredFirstPass_ifc runRequiredFirstPass
private boolean stopCond
| Constructor Detail |
|---|
protected GenerateClass(iWriteContent writeContent,
GenerateFile parentGenerateFile,
LocalIdents fileLevelIdents,
RunRequiredFirstPass_ifc runRequiredFirstPass,
Report log)
writeContent - The writer to the C- and H-File.fileLevelIdents - List of all known Classes while translation Java2CrunRequiredFirstPass - Reference to run the first pass of a required class.
If in the first or second pass any ClassData from another class are
necessary but there was not found in pkgIdents, the first pass of this
required class will called recursively while processing the pass of this class.| Method Detail |
|---|
protected void write_Description(ZbnfParseResultItem item,
java.lang.StringBuilder uHeader)
throws java.io.IOException
item - description::= test_description::=
java.io.IOException
protected CCodeData gen_variableDefinition(ZbnfParseResultItem zbnfVariableDefinition,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdents,
StatementBlock blockEnvironment,
java.util.List<ClassData.InitInfoVariable> listVariablesToInit,
char intension)
throws java.text.ParseException,
java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
argumentList::=... are translated with this method.
It is the same syntax.
LocalIdents are given per reference, it is either the instance of this classData
or the instance of the block-statement.
classData.ClassData.staticVariables. Static variables are only able at class level.
Static variables may have an initialization or not.
FieldData#gen_VariableDefinition() is called inside. The properties of the variable are stored
in its FieldData, which are created here from the ZBNF parse results.
So the C-code-String of variable definition is able to prepare only with knowledge of the FieldData.
final static variable with a immediate simple assignment like
final static int name = 5;, a #define name_Classname 5 is produced.
final Type ... = new Type(...), an embedded struct is defined in C.
That's correct, because a final reference can't be changed and the reference type is equal the
instanciated type. Embedded struct constructs are opportune in C to optimize access and
memory layout of the data.
struct Type_t* ...
or with using an enhanced reference like Type_REF .... All enhanced references
are defined together in 1 headerfile In form
typedef struct NAMEREF_t { ObjectRefValuesJc refbase; struct NAME_t* ref; } NAMEREF;
, see referenceNeeded() and Java2C_Main.writeFileRef().
zbnfVariableDefinition - from parsers result.zbnfDescription - The description to the variable. If the variable is a method argument,
than this description is gotten as a part of the method description after tag param.
The description may contain java2c-tags. The following tags are respected:
zeroTermString
zeroTermStringTODO
zeroTermString
zeroTermString
zeroTermString
zeroTermString
zeroTermString
zeroTermString
zeroTermString
zeroTermString
zeroTermString
localIdents - The environment identifiers. Register the variable there, get types from them.listVariablesToInit - The initialization of variables is stored in this list.
The initializations should be done in C not by the variables declaration
but in another part of code. For class variables that is the constructor(s).
Therefore this parameter should be the ClassData.variablesToInit of this.
But if this routine is called inside a statement block, an extra List instance
for the block should given locally.intension - intension of calling
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
public ClassData gen_AnonymousClass(ZbnfParseResultItem zbnfNewObject,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdents,
StatementBlock blockEnvironment,
java.lang.String sNameField,
char intension,
GenerateFile fileContainsClass)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
new Type(..){...}.
FirstPass#runFirstPassClass(StringBuilder, GenerateFile, String, String, String, String, ZbnfParseResultItem, boolean, String, ClassData, List, boolean, ClassData).
FirstPass#writeCtor(...)
SecondPass.runSecondPassClass(ZbnfParseResultItem, String) is called.
The content of this second-pass is written using TODO before the running second-pass.
zbnfNewObject - The parse result from newObject::=...zbnfNewObject - zbnfDescription - localIdents - The idents of the context, either classLevelIdents if intensio TODO always classLevelIdents.blockEnvironment - sNameField - The name of the field which is initialized with new Type(..){...}
to build the name of the inner class, TODO name of routine.intension - 'b' if called in an statement block, otherwise: at class level.fileContainsClass -
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseExceptionjava.lang.String get_shortDescription(ZbnfParseResultItem zbnfDescription)
parent - The item
protected CCodeData genConstantValue(ZbnfParseResultItem item)
#define NAME VALUE expression in C where a
final static int NAME = VALUE; is given in Java.
item - The part of a simpleValue what is
[ <""?simpleStringLiteral> | <''?simpleCharLiteral> | 0x<#x?hexNumber> | - 0x<#x?hexNumberNegative> | <#-?intNumber>[?\.] | <#f?floatNumber>F | <#f?doubleNumber> ]
public static java.lang.String genIndent(int indent)
indent - nr of indentation, as counter for nesting
protected ClassData getType(ZbnfParseResultItem zbnfType,
LocalIdents localIdentsP)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
ClassData for the given type. The type is given in form of a parse result item
with semantic
type::= [ [List|LinkedList|ArrayList|Iterator|Class][ \<. Especially because the possibility of\>] | [Map|TreeMap|ArrayList|Iterator|Class][ \< \>\< \>] | ] [{ \[ \]}].
<envIdent?typeIdent> the requested type
may be a type inside another class (an inner class, Outerclass.Innerclass),
so this class should be provided before, and the type should be searched there.
ClassData with the given key are found,
starting in the LocalIdents of the current context, further searching in the
Java2C_Main#userTypes and the Java2C_Main.standardClassData,
if necessary searched as inner type. It are one or some simple accesses to the appropriate
LocalIdents.
<envIdent?typeIdent>)
isn't found, it is possible that this type isn't translated yet, but it is a part of the
users type.java sources to translate. In this case a type.java-file
should be part of input files, given with cmd line arguments -i:FILE or
inside the -if:INPFILE. Therefore
RunRequiredFirstPass_ifc#runRequestedFirstPass(String type) is called.
This routine either processes the parsing and first pass of translation for that file,
or it parses the appropriate type.stc File and provides therewith
the ClassData. The parsing is a deep recursively process, because other types
are need too. This routine is called than recursively.
type.java-File in the Java sources exists. In both cases
a new ClassData with attribute "external" is created.
ClassData-instance is returned.
zbnfType - The zbnf-component with syntax type::=....localIdents - The idents of this level.
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
java.text.ParseExceptionpublic int getDimensionsArray(ZbnfParseResultItem zbnfType)
ident[][].
zbnfType - The ZBNF parse result for a type.
[] isn't found (parse result typeArray isn't present,
>0 if it is a array type.
public FieldData createFieldInfo(ZbnfParseResultItem zbnfVariable,
ZbnfParseResultItem zbnfType,
ZbnfParseResultItem zbnfDescription,
ZbnfParseResultItem zbnfNewObject,
LocalIdents localIdentsP,
StatementBlock blockEnvironment,
ClassData declaringClass,
char intension,
char definitionCondition)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.text.ParseException
type::= or adequate info.
The type properties are stored in a new FieldData, but without field name.
The type properties includes array designation and some Java2CTag.
zbnfVariable - It may be null, if only the type informations should be kept.
The ZBNF result which presents a variable definition.
Some informations about the type of variable are contained in that level of parse result,
like new Array[length], final, a static initialization etc.zbnfType - The ZBNF result which presents type::=
or nonArrayType::= or typeIdent::=zbnfDescription - The ZBNF result which presents the description part to the type.
If it is a variable definition, it is the description to the them.
But if it is a argument or return type of a method, it is that part of the description
of the method, which describes the param or return.
It may contain a <$?Java2CTag> to the type element.
This param may be null, if no description of them is available.zbnfNewObject - maybe given, to create a stack or embedded instance.localIdentsP - The local visible identifiers.intension -
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException - from called getType(ZbnfParseResultItem, LocalIdents).
java.text.ParseException
FieldData getTypeInfoSimple(ZbnfParseResultItem zbnfVariable,
ZbnfParseResultItem zbnfType,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdentsP,
java.lang.String sNameField,
ClassData declaringClass,
char intension,
char accessMode,
ClassData typeClass,
ClassData instanceClass,
char staticMode,
ZbnfParseResultItem itemNewObject)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseException
FieldData createFieldDataNewObject(ZbnfParseResultItem zbnfNewObject,
ZbnfParseResultItem zbnfDescription,
LocalIdents typeIdentsForNew,
LocalIdents localIdentsP,
StatementBlock blockEnvironment,
java.lang.String sNameField,
ClassData declaringClass,
char intension,
char accessModeP,
char staticMode,
boolean isFinal)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
zbnfNewObject - The parse result from expression newObject::=.zbnfDescription - The description to the variabletypeIdentsForNew - localIdentsP - The environment for parameters. -not for the new Object.sNameField - name of variabledeclaringClass - The class where the FieldData should be associated to.
May be null for statementblock-fields or new in Expression.intension - accessModeP - staticMode - isFinal -
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseException
FieldData getTypeInfoArray(ZbnfParseResultItem zbnfVariable,
ZbnfParseResultItem zbnfType,
ZbnfParseResultItem zbnfDescription,
LocalIdents localIdentsP,
java.lang.String sNameField,
ClassData declaringClass,
char intension,
char accessMode,
ClassData typeClass,
char staticMode,
int dimensionArray)
throws java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.text.ParseException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseExceptionprotected void stop()
protected void setStop()
protected void stopCond()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||