|
|||||||||
| 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.SecondPass
public class SecondPass
This class handle the second pass of the translation.
An instance is built only temporary to run the pass. All Data are stored in the ClassData.
Instances of ClassData will be created while running the first pass, there are stored in
the singleton AllData. Than they are used to run the Second Pass.
| Field Summary | |
|---|---|
(package private) boolean |
bUse_mtthis
Stores the necessity of generating a mtthis reference for the own method table. |
(package private) boolean |
noStacktrace
Stores the necessity of generating a STACKTRC_ENTRY and STACKTRC_LEAVE. |
| Fields inherited from class org.vishia.java2C.GenerateClass |
|---|
classData, fileLevelIdents, log, parentGenerateFile, runRequiredFirstPass, sMethodNameCurrent, writeContent |
| Constructor Summary | |
|---|---|
SecondPass(iWriteContent writeContent,
GenerateFile parentGenerateFile,
LocalIdents fileLevelIdents,
ClassData classData,
RunRequiredFirstPass_ifc runRequiredFirstPass,
Report log)
Initializes an instance to run the second pass of a given class. |
|
| Method Summary | |
|---|---|
(package private) void |
_assert(boolean cond)
|
java.lang.String |
gen_for_statement(ZbnfParseResultItem itemStatement,
int indent,
StatementBlock parentStatementBlock,
FieldData typeReturn)
|
java.lang.String |
gen_statementBlock(ZbnfParseResultItem zbnfStatementBlock,
int indent,
StatementBlock parentBlock,
FieldData typeReturn,
char intension)
Generates C-code from a parsed statement block. |
(package private) void |
runSecondPassClass(ZbnfParseResultItem itemClass,
java.lang.String sOuterClassName)
writes the constructor-, method-, static variable- definition and reflection into the C-File. |
private void |
write_constructorDefinition(ClassData.MethodWithZbnfItem methodDef,
java.lang.String sClassName,
boolean bArgumentSensitive)
writes a constructor definition as C-method into the C-File. |
void |
write_finalizeDefinition(ZbnfParseResultItem zbnfClass,
java.lang.String sClassName,
LocalIdents idents)
|
void |
write_methodDefinition(ClassData.MethodWithZbnfItem methodDef,
java.lang.String sClassName,
LocalIdents parentIdents)
writes a method definition as C-method into the C-File. |
private void |
write_Reflections()
Writes out the reflection inclusively the method table definition. |
| 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 |
|---|
boolean bUse_mtthis
mtthis reference for the own method table.
This variable is set to false on start of any write_methodDefinition(org.vishia.java2C.ClassData.MethodWithZbnfItem, String, LocalIdents)
and set to true if any dynamic call with ythis-reference is generated.
Depending on this, a line to prepare a mtthis variable: The reference to the
own method table, is prepared.
boolean noStacktrace
STACKTRC_ENTRY and STACKTRC_LEAVE.
This variable is set on start of any write_methodDefinition(org.vishia.java2C.ClassData.MethodWithZbnfItem, String, LocalIdents)
depending on the Method.noStacktrace().
| Constructor Detail |
|---|
SecondPass(iWriteContent writeContent,
GenerateFile parentGenerateFile,
LocalIdents fileLevelIdents,
ClassData classData,
RunRequiredFirstPass_ifc runRequiredFirstPass,
Report log)
GenerateClass.
genClass.writeContent - Interface to write the content. Note: The content is not written immediately
in a file, but temporary stored in some StringBuilder. The reason is the order of parts of C-File and H-File.pkgIdents - singleton information of all classes there are knwon yet.classData - The data of this class saves between parsing, first and second pass.
This classData also contain the ZBNF parse result items.runRequiredFirstPass - Interface to cause the parsing and running of a first pass
of a up-to-now unknown class.
This interface is implemented at the main level of the Java2C-translator| Method Detail |
|---|
void runSecondPassClass(ZbnfParseResultItem itemClass,
java.lang.String sOuterClassName)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
#write_constructorDefinition(ZbnfParseResultItem, String)
#write_methodDefinition(ZbnfParseResultItem, String)
itemClass - The class start item of zbnf parse result.sOuterClassName - Name of the environment class not used yet
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentExceptionprivate void write_Reflections()
private void write_constructorDefinition(ClassData.MethodWithZbnfItem methodDef,
java.lang.String sClassName,
boolean bArgumentSensitive)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
iWriteContent.writeClassC(String) is used to do it.
The content isn't written directly in the file, because some include-lines
generated while running any methods and constructors of second pass should be written
before the text of this method.
MemC rawMem as first and ThCxt* _thCxt
as last argument of constructor head.
gen_variableDefinition(ZbnfParseResultItem, LocalIdents, List, char intension)
to generate the arguments of the constructor, in Java2C.zbnf < argumentList>
and < argument>
{ StacktraceJc stacktrace...-expressions.
memset(ythis, 0, sizeof(*ythis)); of the used mem area of the class (C-struct).
Like in Java all class elements of this instance are set to zero in default.
ctorc_ObjectJc(rawMem);
setReflection_ObjectJc(...) to set reflection and jump table infos for the instance.
StatementBlock#gen_value(ZbnfParseResultItem, ClassData[], LocalIdents, char)
to generate the initial value assignment of class variable. The list ClassData.variablesToInit
of the classData is used to get all variables to initialze. That list elements contain
the reference to the parse result item elements of parsed initial values in Java code.
StatementBlock#gen_statementBlock(ZbnfParseResultItem, int, LocalIdents)
is used to generate the statement block of the constructor.
RunRequiredFirstPass_ifc#runRequestedFirstPass(String).
itemConstructor - Parse result of constructorDefinition::=...
If it is null, than this method is used to create a default constructor with all initializations.sClassName - Full Name of the class in C-Style where the constructor is member of.
The class name is used as return type and as C-methodidentifier-postfix.
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
public void write_finalizeDefinition(ZbnfParseResultItem zbnfClass,
java.lang.String sClassName,
LocalIdents idents)
throws java.text.ParseException,
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
public void write_methodDefinition(ClassData.MethodWithZbnfItem methodDef,
java.lang.String sClassName,
LocalIdents parentIdents)
throws java.io.IOException,
java.text.ParseException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
iWriteContent.writeClassC(String) is used to do it.
The content isn't written directly in the file, because some include-lines
generated while running any methods and constructors of second pass should be written
before the text of this method.
Type* ythis as first and ThCxt* _thCxt
as last argument of method head.
gen_variableDefinition(ZbnfParseResultItem, LocalIdents, List, char intension)
to generate the arguments of the constructor, in Java2C.zbnf < argumentList>
and < argument>
{ StacktraceJc stacktrace...-expressions.
StatementBlock#gen_statementBlock(ZbnfParseResultItem, int, LocalIdents)
is used to generate the statement block of the constructor.
RunRequiredFirstPass_ifc#runRequestedFirstPass(String).
parent - Parse result of methodDefinition::=...sClassName - Full Name of the class in C-Style where the method is member of.
The class name is used as ythis-type and as C-method-identifier-postfix.
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
public java.lang.String gen_statementBlock(ZbnfParseResultItem zbnfStatementBlock,
int indent,
StatementBlock parentBlock,
FieldData typeReturn,
char intension)
throws java.text.ParseException,
java.io.FileNotFoundException,
java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
GenerateClass#gen_variableDefinition(ZbnfParseResultItem, LocalIdents, List, char).
It should be done first because in C all variable should be define on the begin of a block.
The variable identifiers and types are stored in a local copy of LocalIdents, which are intialized
with the content of the localIdentsP given as argument, which comes either from the parent block or from the class.
#gen_VariableInitAssignment(ZbnfParseResultItem, int, LocalIdents).
It is separated from the variable definition and it isn't implemented as initializing of variable,
because in Java there are more variants. In C the type name = value; is an initializing of the variable,
but type name; ...; name = value; it is an assignment. It is a fine difficult explainable difference.
The Java2C produce assignments, not initializing.
#gen_statement(ZbnfParseResultItem, int, LocalIdents).
Therefore a separate String variable is used, because MemC-elements, see next:
new-statements, the MemC definitions are generated.
They are named with a incremental number. They are placed after the variable definitions of the block
but before the statements. This is necessary because the MemC memX is an variable also.
activateGarbageCollectorAccess_BlockHeapJc(memX) is generated for all MemC-elements.
The MemC-Elements are countered on level of the statement block, represented by this class.
This is also done in #gen_statement(ZbnfParseResultItem, int, LocalIdents) before a return statement.
It is not done if the last statement was a return.
Thats why it is done with an extra method #gen_ActivateGarbageCollection(int).
zbnfStatementBlock - The ZBNF parse result item which is a < statementBlock>indent - number of indentation in the generated C-code. It is the level of blocks.localIdentsP - The local identifiers of the parent block.intension - Intension of call: 'c'-constructor body, 'm'-method body, 'b'internal block, 'f'-finalize body.
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
public java.lang.String gen_for_statement(ZbnfParseResultItem itemStatement,
int indent,
StatementBlock parentStatementBlock,
FieldData typeReturn)
throws java.text.ParseException,
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.InstantiationExceptionvoid _assert(boolean cond)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||