org.vishia.java2C
Class StatementBlock

java.lang.Object
  extended by org.vishia.java2C.StatementBlock

public class StatementBlock
extends java.lang.Object

This class generates all statements in one block. It is instanciated temporary for any statement block.


Field Summary
 int blockNestingCnt
          The deepness of block nesting.
private  GenerateClass genClass
           
private  int indent
          Indentation of the block.
 boolean lastWasReturn
          Saves, whether the last generated statement is a return.
 LocalIdents localIdents
          The identifiers valid at this block level.
private  java.util.List<FieldData> mtblVariables
          If any dynamic call occurs in this statement block without local knowledge of the correct interface type, a helpness variable is created.
private  boolean needPtrStringBuilderInThCxt
           
private  int nrofMTBRef
          Counter for "_mtbl8_9" of this block.
private  int nrofNew
          The number of call of new in this blockStatment.
private  int nrofPersistentStrings
           
private  int nrofStringBufForConcat
          Counter for "_temp" + nrofStringBufForConcat of this block.
private  int nrofTempRefForConcat
          Counter for "_temp" + nrofTempRefForConcat of this block.
(package private)  StatementBlock parent
          The parent statement block.
private  SecondPass secondpass
           
private  java.util.LinkedList<java.lang.Integer> sizesStringBufferConcat
           
private  int sizeStringBuilderInStack
          If set >0, a StringBuilderJc-instance with this direct buffer size should be generate in this block-level.
private  java.util.LinkedList<FieldData> tempRef
           
 
Constructor Summary
StatementBlock(GenerateClass genClass, LocalIdents parentLocalIdents, boolean bClassLevel, int indent)
           
StatementBlock(StatementBlock parent)
           
 
Method Summary
(package private)  java.util.List<CCodeData> gatherActParams(ZbnfParseResultItem zbnfMethod, ZbnfParseResultItem zbnfDescription, java.lang.String sMethodNameJava)
           
 java.lang.String gen_ActivateGarbageCollection(int indent, boolean bRet, CCodeData cCodeReturn)
          generates the statement for activateGarbageCollectorAccess_BlockHeapJc().
(package private)  java.lang.String gen_AssignCheckCast(CCodeData leftVariable, java.lang.String sAssignOperatorC, CCodeData value)
          Generates the assignment with check of necessity of cast.
 java.lang.String gen_assignment(ZbnfParseResultItem zbnfAssignment, ZbnfParseResultItem zbnfDescription, int indent, LocalIdents localIdents, char intension)
          generates an assignment-statement from given parse result item < statement>.
(package private)  java.lang.String gen_assignValue(CCodeData leftVariable, java.lang.String sAssignOperatorC, ClassData[] typeValue, ZbnfParseResultItem zbnfValue, ZbnfParseResultItem zbnfDescription, int indent, LocalIdents localIdents, char intension)
           
(package private)  CCodeData gen_ConcatenatedStrings(java.lang.String sFirstString, ClassData firstType, char firstModeAccess, java.util.Iterator<ZbnfParseResultItem> iterZbnf, ZbnfParseResultItem zbnfDescription, java.lang.String sStringBuilderToUse, LocalIdents localIdents, char xxxintension)
          This routine generates an concatenated String.
(package private)  CCodeData gen_InternalMethodCall(ZbnfParseResultItem zbnfMethod, ZbnfParseResultItem zbnfDescription, java.lang.String sMethodNameJava, ClassData declaringClass, CCodeData envInstance, java.lang.String sNewObject)
          generates either a new or a simple method call.
 java.lang.String gen_newArray(ZbnfParseResultItem zbnfNewArray, ClassData[] retTypeValue, LocalIdents idents, FieldData variable)
          generates the expression for a new Type[...] expression.
 java.lang.String gen_newObj()
          Returns a new identifier for a newObject.
private  CCodeData gen_newObject(ZbnfParseResultItem zbnfNewObject, CCodeData referenceP)
          generates the expression for a new Type(...) expression.
(package private)  java.lang.String gen_NewObjReferences(int indent)
          Generates all variables which are used for newObject (new operator).
(package private)  java.lang.String gen_persistringVarDefinitions(int indent)
          Generates all StringJc-variables which are used to build persistent Strings.
 java.lang.String gen_persistringVariable()
          Returns a new identifier for a persistent String.
(package private)  CCodeData gen_reference(java.lang.String[] concatenatedReference, ZbnfParseResultItem zbnfReferenceP, ZbnfParseResultItem zbnfDescription, LocalIdents localIdentsParent, CCodeData envClassCode, char intension)
          generates an reference to a variable or method call from parse result < reference>.
private  java.lang.String gen_returnStatement(ZbnfParseResultItem itemStatement, ZbnfParseResultItem zbnfDescription, FieldData typeReturn)
          generates a return statement.
private  CCodeData gen_simpleMethodCall(ZbnfParseResultItem zbnfMethod, ZbnfParseResultItem zbnfDescription, CCodeData envInstance, LocalIdents localIdents, boolean maybeNonPersistent, char intension)
          generates a simple method call.
 CCodeData gen_simpleValue(ZbnfParseResultItem zbnfItem, ZbnfParseResultItem zbnfDescription, LocalIdents localIdents, boolean maybeNonPersistent, char intension, boolean bRefNeed)
          generates the code for ZBNF-< simpleValue>.
(package private)  java.lang.String gen_StackSize(ZbnfParseResultItem zbnfDescription)
           
 java.lang.String gen_statement(ZbnfParseResultItem parent, int indent, LocalIdents localIdents, FieldData typeReturn, char intension)
          generates a statement from given parse result item < statement>.
 java.lang.String gen_StringAssignment(int indent, CCodeData leftValue, java.lang.String sAssignOperatorC, ZbnfParseResultItem zbnfValue, ZbnfParseResultItem zbnfDescription, LocalIdents localIdents, char intension)
          Generates an assignment to a String.
(package private)  java.lang.String gen_synchronizedBlock(ZbnfParseResultItem zbnfSync, FieldData typeReturn, int indent)
           
(package private)  java.lang.String gen_TempRefs(int indent)
          Generates all variables which are used for temporary references for concatenation-disentangle.
 java.lang.String gen_tempString()
          Counts the #nrof and returns the name of a reference for new Objects.
(package private)  java.lang.String gen_TempStringBufferReferences(int indent)
          Generates all variables which are used for new statements.
 java.lang.String gen_throwNew(ZbnfParseResultItem zbnfThrowNew, ZbnfParseResultItem zbnfDescription, LocalIdents localIdents, FieldData typeReturn)
          generates the expression for a .
 java.lang.String gen_try_statement(ZbnfParseResultItem zbnfThrowNew, int indent, LocalIdents localIdents)
          generates the expression for a < try_Statment> .
 CCodeData gen_value(ZbnfParseResultItem parent, ZbnfParseResultItem zbnfDescription, boolean maybeNonPersistent, char intension)
          generates the expression to get a value.
 java.lang.String gen_value(ZbnfParseResultItem parent, ZbnfParseResultItem zbnfDescription, ClassData[] retType, LocalIdents localIdents, boolean maybeNonPersistent, char intension)
           
 CCodeData gen_variableAccess(ZbnfParseResultItem itemVariable, ZbnfParseResultItem zbnfDescription, LocalIdents localIdents, char intension, CCodeData cCodeReferenceInput)
          generates an access to a value in a variable or a using of a variable as left value.
(package private)  java.lang.String gen_VariableDefWithSimpleInitValue(FieldData variable, ZbnfParseResultItem zbnfInitAssignment)
          Generates the definition of variable with its initialization.
 java.lang.String gen_VariableInitAssignment(ZbnfParseResultItem zbnfVariableDefinition, int indent)
          generates the initial assignments to variables.
(package private)  java.lang.String genInitEmbeddedInstance(ZbnfParseResultItem zbnfNewObject, ZbnfParseResultItem zbnfDescription, FieldData fieldInfo, java.lang.String sCCodeInstance, int indent)
           
private  java.lang.String genTemp_mtblRef(FieldData typeMtb, CCodeData ref)
          Generates a new identifier for a _mtbl8_9-variable and fills it with the given value.
(package private)  void stop()
           
private  java.lang.String tempRefForConcat(FieldData src)
          Generates a new identifier for a _temp8_9-variable and fills it with the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

genClass

private final GenerateClass genClass

secondpass

private final SecondPass secondpass

nrofNew

private int nrofNew
The number of call of new in this blockStatment. The call of new is counted, generates some special statements in C.


nrofPersistentStrings

private int nrofPersistentStrings

tempRef

private java.util.LinkedList<FieldData> tempRef

nrofTempRefForConcat

private int nrofTempRefForConcat
Counter for "_temp" + nrofTempRefForConcat of this block.


nrofStringBufForConcat

private int nrofStringBufForConcat
Counter for "_temp" + nrofStringBufForConcat of this block.


nrofMTBRef

private int nrofMTBRef
Counter for "_mtbl8_9" of this block.


sizeStringBuilderInStack

private int sizeStringBuilderInStack
If set >0, a StringBuilderJc-instance with this direct buffer size should be generate in this block-level.


needPtrStringBuilderInThCxt

private boolean needPtrStringBuilderInThCxt

sizesStringBufferConcat

private java.util.LinkedList<java.lang.Integer> sizesStringBufferConcat

indent

private final int indent
Indentation of the block. It is valid for the statements. The opened and close curly bracket have indent-1.


blockNestingCnt

public final int blockNestingCnt
The deepness of block nesting.


lastWasReturn

public boolean lastWasReturn
Saves, whether the last generated statement is a return. If it is not so, some instructions at end of block have to be done.


localIdents

public LocalIdents localIdents
The identifiers valid at this block level. Note: The definition is not final because at first the LocalIdents of the level above are referenced here. Only if any variable or type defined in this block, an own instance is created and the reference is replaced.


mtblVariables

private java.util.List<FieldData> mtblVariables
If any dynamic call occurs in this statement block without local knowledge of the correct interface type, a helpness variable is created. This list contains all of it.


parent

final StatementBlock parent
The parent statement block. It is necessary at ex. for gen_ActivateGarbageCollection() called at return statement.

Constructor Detail

StatementBlock

StatementBlock(StatementBlock parent)

StatementBlock

StatementBlock(GenerateClass genClass,
               LocalIdents parentLocalIdents,
               boolean bClassLevel,
               int indent)
Method Detail

gen_newObj

public java.lang.String gen_newObj()
Returns a new identifier for a newObject. Counts the nrofNew thereby.


gen_NewObjReferences

java.lang.String gen_NewObjReferences(int indent)
Generates all variables which are used for newObject (new operator).

Parameters:
indent - indentation.
Returns:
String with C-Code

gen_persistringVariable

public java.lang.String gen_persistringVariable()
Returns a new identifier for a persistent String. Counts the nrofPersistentStrings thereby.


gen_persistringVarDefinitions

java.lang.String gen_persistringVarDefinitions(int indent)
Generates all StringJc-variables which are used to build persistent Strings.

Parameters:
indent - indentation.
Returns:
String with C-Code

gen_tempString

public java.lang.String gen_tempString()
Counts the #nrof and returns the name of a reference for new Objects.


gen_TempStringBufferReferences

java.lang.String gen_TempStringBufferReferences(int indent)
Generates all variables which are used for new statements.

Parameters:
indent - indentation.
Returns:
String with C-Code

tempRefForConcat

private final java.lang.String tempRefForConcat(FieldData src)
Generates a new identifier for a _temp8_9-variable and fills it with the given value.

Parameters:
src - the type which should stores in the ref
modeDef - 'n':_new8_9 created '&':_mtb8_9 else:_temp8_9
Returns:

genTemp_mtblRef

private final java.lang.String genTemp_mtblRef(FieldData typeMtb,
                                               CCodeData ref)
Generates a new identifier for a _mtbl8_9-variable and fills it with the given value.

Parameters:
ref - the value which should stores in the ref
Returns:

gen_TempRefs

java.lang.String gen_TempRefs(int indent)
Generates all variables which are used for temporary references for concatenation-disentangle.

Parameters:
indent - indentation.
Returns:
String with C-Code

gen_ActivateGarbageCollection

public java.lang.String gen_ActivateGarbageCollection(int indent,
                                                      boolean bRet,
                                                      CCodeData cCodeReturn)
generates the statement for activateGarbageCollectorAccess_BlockHeapJc(). This is placed on end of a statement block or before an return-statement, if inside new-statements are generated.

Parameters:
indent - number of indentations. 2 spaces per indentation are produced.
Returns:
The statement as string with indentation +1, but without newline.

gen_statement

public java.lang.String gen_statement(ZbnfParseResultItem parent,
                                      int indent,
                                      LocalIdents localIdents,
                                      FieldData typeReturn,
                                      char intension)
                               throws java.text.ParseException,
                                      java.io.FileNotFoundException,
                                      java.lang.IllegalArgumentException,
                                      java.io.IOException,
                                      java.lang.IllegalAccessException,
                                      java.lang.InstantiationException
generates a statement from given parse result item < statement>. It may be a simple call, an assignment, an if-statement and so on or a < statementBlock>

Parameters:
parent - The ZBNF parse result item which is a < statement>
indent - Number of nesting level of the block to generate indentations of a line.
localIdents - The indentation of the block: TODO use it as class element.
typeReturn - The return type of the superior method if it contains a return statement.
intension - Intension of call: 'c'-constructor body, 'm'-method body, 'b'-internal block, 'z'-part of if, while etc., 'f'-finalize body.
Returns:
The statement in C stated without indentation and ended without newline, but with the end-semicolon. If the statement occupies more as one line, the indentation is generated correctly using the indent argument.
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_returnStatement

private java.lang.String gen_returnStatement(ZbnfParseResultItem itemStatement,
                                             ZbnfParseResultItem zbnfDescription,
                                             FieldData typeReturn)
                                      throws java.io.FileNotFoundException,
                                             java.lang.IllegalArgumentException,
                                             java.text.ParseException,
                                             java.io.IOException,
                                             java.lang.IllegalAccessException,
                                             java.lang.InstantiationException
generates a return statement.

Parameters:
itemStatement -
zbnfDescription -
typeReturn -
Returns:
Throws:
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.text.ParseException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

gen_synchronizedBlock

java.lang.String gen_synchronizedBlock(ZbnfParseResultItem zbnfSync,
                                       FieldData typeReturn,
                                       int indent)
                                 throws java.io.FileNotFoundException,
                                        java.lang.IllegalArgumentException,
                                        java.text.ParseException,
                                        java.io.IOException,
                                        java.lang.IllegalAccessException,
                                        java.lang.InstantiationException
Throws:
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.text.ParseException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

genInitEmbeddedInstance

java.lang.String genInitEmbeddedInstance(ZbnfParseResultItem zbnfNewObject,
                                         ZbnfParseResultItem zbnfDescription,
                                         FieldData fieldInfo,
                                         java.lang.String sCCodeInstance,
                                         int indent)
                                   throws java.text.ParseException,
                                          java.io.FileNotFoundException,
                                          java.lang.IllegalArgumentException,
                                          java.io.IOException,
                                          java.lang.IllegalAccessException,
                                          java.lang.InstantiationException
Throws:
java.text.ParseException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

gen_assignment

public java.lang.String gen_assignment(ZbnfParseResultItem zbnfAssignment,
                                       ZbnfParseResultItem zbnfDescription,
                                       int indent,
                                       LocalIdents localIdents,
                                       char intension)
                                throws java.text.ParseException,
                                       java.io.FileNotFoundException,
                                       java.lang.IllegalArgumentException,
                                       java.io.IOException,
                                       java.lang.IllegalAccessException,
                                       java.lang.InstantiationException
generates an assignment-statement from given parse result item < statement>. The < assignment> consist of a < ?leftValue>, an < assignOperator> and a < value>.
The < leftValue> is translated via call of gen_variable(ZbnfParseResultItem, LocalIdents , char intension, LocalIdents.IdentInfos[] retIdentInfo) with intension='='. The argument retIdentInfo is a call by returned reference. The returned object contains informations about the kind of the left-value variable, especially if it is an enhanced reference.
The value is translated via call of gen_value(ZbnfParseResultItem, LocalIdents, char intension) with intension='e'.
If the left value is an enhanced reference, a call of clearBackRefJc(variable) is produced before the new reference is set to it, and setBackRefJc(variable) after it is set. This subroutines implement the necessities of Garbage Collection for that enhanced references.

Parameters:
zbnfAssignment - The ZBNF parse result item which is a < assignment>
indent - Number of nesting level of the block to generate indentations of a line.
localIdents - The indentation of the block: TODO use it as class element.
intension - Intension of call: 'c'-constructor body, 'm'-method body, 'b'-internal block, 'z'-part of if, while etc., 'f'-finalize body.
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_assignValue

java.lang.String gen_assignValue(CCodeData leftVariable,
                                 java.lang.String sAssignOperatorC,
                                 ClassData[] typeValue,
                                 ZbnfParseResultItem zbnfValue,
                                 ZbnfParseResultItem zbnfDescription,
                                 int indent,
                                 LocalIdents localIdents,
                                 char intension)
                           throws java.io.FileNotFoundException,
                                  java.lang.IllegalArgumentException,
                                  java.text.ParseException,
                                  java.io.IOException,
                                  java.lang.IllegalAccessException,
                                  java.lang.InstantiationException
Parameters:
leftVariable -
sAssignOperatorC -
typeValue -
zbnfValue -
zbnfDescription -
indent -
localIdents -
intension -
Returns:
Throws:
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.text.ParseException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

gen_AssignCheckCast

java.lang.String gen_AssignCheckCast(CCodeData leftVariable,
                                     java.lang.String sAssignOperatorC,
                                     CCodeData value)
Generates the assignment with check of necessity of cast.

Parameters:
leftVariable - The destination variable with name, type etc.
sAssignOperatorC - The operator, mostly "=", maybe "+=" etc.
value - The right value with name, type etc.
Returns:
The assignment code in C

gen_StringAssignment

public java.lang.String gen_StringAssignment(int indent,
                                             CCodeData leftValue,
                                             java.lang.String sAssignOperatorC,
                                             ZbnfParseResultItem zbnfValue,
                                             ZbnfParseResultItem zbnfDescription,
                                             LocalIdents localIdents,
                                             char intension)
                                      throws java.text.ParseException,
                                             java.io.FileNotFoundException,
                                             java.lang.IllegalArgumentException,
                                             java.io.IOException,
                                             java.lang.IllegalAccessException,
                                             java.lang.InstantiationException
Generates an assignment to a String.

Parameters:
indent -
sVariableC -
typeLeftValue -
sAssignOperatorC -
sValueC -
typeValue -
intension - Intension of call: 'c'-constructor body, 'm'-method body, 'b'-internal block, 'z'-part of if, while etc., 'f'-finalize body.
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_variableAccess

public CCodeData gen_variableAccess(ZbnfParseResultItem itemVariable,
                                    ZbnfParseResultItem zbnfDescription,
                                    LocalIdents localIdents,
                                    char intension,
                                    CCodeData cCodeReferenceInput)
                             throws java.text.ParseException,
                                    java.io.FileNotFoundException,
                                    java.lang.IllegalArgumentException,
                                    java.io.IOException,
                                    java.lang.IllegalAccessException,
                                    java.lang.InstantiationException
generates an access to a value in a variable or a using of a variable as left value. The variable may be referenced. It means, it is a variable in the referenced object.
If no reference is given, it may be either it a local variable or a class variable. With help of the argument localIdents the variable can be found in the context.
If it is a referenced variable, the identifier info of the referencing object is used, The reference is build correctly either with -> or ., depended on the reference kind. It may be an embedded struct. The LocalIdents of the referencing object are used to desire it.
If the variable is an enhanced reference and the intension is ones of "Rrmex", the code REFJc(variable) is generated to get the stored reference as value. REFJc(variable) is a Macro to get the reference pointer inside an enhanced referende. Especially if it is left value, the code of enhanced reference itself is generated.
A variable may have a pre- or post- increment or -decrement like --x or y++.

Parameters:
itemVariable - The ZBNF parse result item of the < ?variable>-semantic. It is a part of a simpleValue-syntax-prescript.
localIdents - The Identifier info of the environment.
intension - Info about the location respectively cause to call this method. e-expression R-first reference r-nested reference =:leftvalue ...
retIdentInfo - information about the variable in its context.
Returns:
generated String of variable access for the C-code
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_reference

CCodeData gen_reference(java.lang.String[] concatenatedReference,
                        ZbnfParseResultItem zbnfReferenceP,
                        ZbnfParseResultItem zbnfDescription,
                        LocalIdents localIdentsParent,
                        CCodeData envClassCode,
                        char intension)
                  throws java.text.ParseException,
                         java.io.FileNotFoundException,
                         java.lang.IllegalArgumentException,
                         java.io.IOException,
                         java.lang.IllegalAccessException,
                         java.lang.InstantiationException
generates an reference to a variable or method call from parse result < reference>. A reference can be referenced again, writing at ex.myRef.itsRef. or myRef.method().itsRef.. In Java2C.zbnf the references are understand syntactically as repetition. Therefore here all references are concatenated. The following separator . or -> is determined always from type of the reference before. The type-info of the last reference is returned in retInfo.

Parameters:
concatedReference - Part of reference, which are build with concatenated methods in Java. In the result it is to be write as a expression separated with comma.
zbnfReferences - The ZBNF parse result item of the < reference>.
localIdents - The Identifier info of the environment.
intension - Info about the location respectively cause to call this method. e-expression R-first reference r-nested reference =:leftvalue ...
retIdentInfo - information about the last reference type.
Returns:
String representing the reference in C.
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_value

public java.lang.String gen_value(ZbnfParseResultItem parent,
                                  ZbnfParseResultItem zbnfDescription,
                                  ClassData[] retType,
                                  LocalIdents localIdents,
                                  boolean maybeNonPersistent,
                                  char intension)
                           throws java.text.ParseException,
                                  java.io.FileNotFoundException,
                                  java.lang.IllegalArgumentException,
                                  java.io.IOException,
                                  java.lang.IllegalAccessException,
                                  java.lang.InstantiationException
Throws:
java.text.ParseException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

gen_value

public CCodeData gen_value(ZbnfParseResultItem parent,
                           ZbnfParseResultItem zbnfDescription,
                           boolean maybeNonPersistent,
                           char intension)
                    throws java.text.ParseException,
                           java.io.FileNotFoundException,
                           java.lang.IllegalArgumentException,
                           java.io.IOException,
                           java.lang.IllegalAccessException,
                           java.lang.InstantiationException
generates the expression to get a value. From syntax item <...?value>. In the syntax of < value> it is a repetion of { [|< unaryOperator>] < simpleValue?> ? < binaryOperator> }. Therefore #gen_simpleValue(ZbnfParseResultItem, LocalIdents, char) is called inside. All components of the < value> are processed in one while-loop because it is stored one after another. That includes also the [< ?conditional>... construct in which is this method is called recursively.
The priority of operators is checked in the Java context. The input to the Java2C-translator should be a well compiled java source code. Therefore it needn't considered here.

Parameters:
parent - The parse result item which has the semantic <...?value>.
intension - intension of generating:
  • 'e'-value in an expression, enhanced references are taken with .ref
  • 'l'-left value,
  • 'a'-argument
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
java.lang.InstantiationException

gen_ConcatenatedStrings

CCodeData gen_ConcatenatedStrings(java.lang.String sFirstString,
                                  ClassData firstType,
                                  char firstModeAccess,
                                  java.util.Iterator<ZbnfParseResultItem> iterZbnf,
                                  ZbnfParseResultItem zbnfDescription,
                                  java.lang.String sStringBuilderToUse,
                                  LocalIdents localIdents,
                                  char xxxintension)
                            throws java.text.ParseException,
                                   java.io.FileNotFoundException,
                                   java.lang.IllegalArgumentException,
                                   java.io.IOException,
                                   java.lang.IllegalAccessException,
                                   java.lang.InstantiationException
This routine generates an concatenated String.

Parameters:
sFirstString - The first part of String expression found in gen_Value before calling this routine.
firstType - The associated type to the sFirstString
firstModeAccess -
iterZbnf - iterator through parse result.
zbnfDescription - description parse result of the whole expression (statement)
sStringBuilderTmp - A given temporary StringBuilder to use.
localIdents -
creationMode -
Returns:
Throws:
java.text.ParseException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

gen_simpleValue

public CCodeData gen_simpleValue(ZbnfParseResultItem zbnfItem,
                                 ZbnfParseResultItem zbnfDescription,
                                 LocalIdents localIdents,
                                 boolean maybeNonPersistent,
                                 char intension,
                                 boolean bRefNeed)
                          throws java.text.ParseException,
                                 java.io.FileNotFoundException,
                                 java.lang.IllegalArgumentException,
                                 java.io.IOException,
                                 java.lang.IllegalAccessException,
                                 java.lang.InstantiationException
generates the code for ZBNF-< simpleValue>. A simpleValue is a value without operators, a non calculated value, in opposite to a < value>. But a simpleValue may be an expression accessing a referenced value. Examples are: var, this.var, super.var, ref.var, "xyz", method(a.b), "xyz".indexof(cc), method().val

Parameters:
zbnfItem - One of the alternatives in simpleValue::=...
localIdents - of the environment
intension - calling intension.
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_simpleMethodCall

private CCodeData gen_simpleMethodCall(ZbnfParseResultItem zbnfMethod,
                                       ZbnfParseResultItem zbnfDescription,
                                       CCodeData envInstance,
                                       LocalIdents localIdents,
                                       boolean maybeNonPersistent,
                                       char intension)
                                throws java.text.ParseException,
                                       java.io.FileNotFoundException,
                                       java.lang.IllegalArgumentException,
                                       java.io.IOException,
                                       java.lang.IllegalAccessException,
                                       java.lang.InstantiationException
generates a simple method call. It includes the evaluation of actual parameters using #gen_value(ZbnfParseResultItem, ClassData[], LocalIdents, char). The method-name is built with the Java-method-name, following by the class name as postfix. In C all methods should have a unique name.
If it is a class method, the reference of the class is generated as the first argument. Depended on the kind of the class reference, a &(ref) is generated if it is an embedded reference.

Parameters:
parent -
sInstanceRef - The generated C-Code for the reference to the methods class-instance. It is the output from #gen_reference(String[], ZbnfParseResultItem, LocalIdents, char, org.vishia.java2C.FieldData[]) For static methods this parameter is null. If it is a constructor call, this is either the reference to the outer class or null.
envInstanceInfo - The type-info of the class from which the method is member of.
localIdents - The local identifier of this statement block level used for parameter values.
maybeNonPersist - The result is accepted as non-persistent too.
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
java.lang.InstantiationException

gen_InternalMethodCall

CCodeData gen_InternalMethodCall(ZbnfParseResultItem zbnfMethod,
                                 ZbnfParseResultItem zbnfDescription,
                                 java.lang.String sMethodNameJava,
                                 ClassData declaringClass,
                                 CCodeData envInstance,
                                 java.lang.String sNewObject)
                           throws java.text.ParseException,
                                  java.io.FileNotFoundException,
                                  java.lang.IllegalArgumentException,
                                  java.io.IOException,
                                  java.lang.IllegalAccessException,
                                  java.lang.InstantiationException
generates either a new or a simple method call. It includes the evaluation of actual parameters using #gen_value(ZbnfParseResultItem, ClassData[], LocalIdents, char). The method-name is built with the Java-method-name, following by the class name as postfix. In C all methods should have a unique name.
If it is a class method, the reference of the class is generated as the first argument. Depended on the kind of the class reference, a &(ref) is generated if it is an embedded reference. TODO

Parameters:
zbnfMethod - Zbnf parse result item from simpleMethodCall::= or newObject::= or [ super ...], may be null if a default constructor is called.
sMethodNameJava - The methodname from Java
declaringClass - The class where the method should be member of. Mostly it is the ClassData of the envInstance: CCodeData.identInfo and there FieldData.typeClazz, but if the super class is accessed, it is the super class of them.
envInstance - Type and name of the reference to the instance, from which the method is called. It is the output from #gen_reference(String[], ZbnfParseResultItem, LocalIdents, char, org.vishia.java2C.FieldData[]) For static methods this parameter is null.
If it is a constructor call, this is either the reference to the outer class: The constructor respectively new(...) is a method of the outer class: outer.new(...) Or null it should be null: The constructor respectively new(...) of not-inner classes is a static method.
sNewObject - If it is a constructor call, the generated C-Code for access the new Object, else null. it is used as second argument of ctor(...) respectively first argument of ctor(...) if envInstance == null.
localIdents - The local identifier of this statement block level used for parameter values.
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
java.lang.InstantiationException

gatherActParams

java.util.List<CCodeData> gatherActParams(ZbnfParseResultItem zbnfMethod,
                                          ZbnfParseResultItem zbnfDescription,
                                          java.lang.String sMethodNameJava)
                                    throws java.io.FileNotFoundException,
                                           java.lang.IllegalArgumentException,
                                           java.text.ParseException,
                                           java.io.IOException,
                                           java.lang.IllegalAccessException,
                                           java.lang.InstantiationException
Parameters:
zbnfMethod -
zbnfDescription -
Throws:
java.lang.IllegalAccessException
java.io.IOException
java.text.ParseException
java.lang.IllegalArgumentException
java.io.FileNotFoundException
java.lang.InstantiationException

gen_StackSize

java.lang.String gen_StackSize(ZbnfParseResultItem zbnfDescription)
                         throws java.io.FileNotFoundException,
                                java.lang.IllegalArgumentException,
                                java.io.IOException,
                                java.lang.IllegalAccessException,
                                java.lang.InstantiationException,
                                java.text.ParseException
Throws:
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.text.ParseException

gen_newObject

private CCodeData gen_newObject(ZbnfParseResultItem zbnfNewObject,
                                CCodeData referenceP)
                         throws java.text.ParseException,
                                java.io.FileNotFoundException,
                                java.lang.IllegalArgumentException,
                                java.io.IOException,
                                java.lang.IllegalAccessException,
                                java.lang.InstantiationException
generates the expression for a new Type(...) expression. For a new Object, a MemC-instance is necessary. It will be generated in #gen_statementBlock(ZbnfParseResultItem, int, LocalIdents). The variable nrofNew is used and incremented for that.

Parameters:
zbnfNewObject - The zbnf parse result item of the < newObject>
reference - A reference before .new, used for inner non-static classes, or null for static or first-level classes.
idents - The identifier of the environment.
Returns:
generated C-code.
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_newArray

public java.lang.String gen_newArray(ZbnfParseResultItem zbnfNewArray,
                                     ClassData[] retTypeValue,
                                     LocalIdents idents,
                                     FieldData variable)
                              throws java.text.ParseException,
                                     java.io.FileNotFoundException,
                                     java.lang.IllegalArgumentException,
                                     java.io.IOException,
                                     java.lang.IllegalAccessException,
                                     java.lang.InstantiationException
generates the expression for a new Type[...] expression. For a new Object, a Object-instance is necessary. It will be generated using gen_newObj(). The variable nrofNew is used and incremented for that.
If a variable is given, and it is an embedded instance, no new Object is allocated, but the constructor for the given embedded instance is called.

Parameters:
zbnfNewArray - The zbnf parse result item of the < newObject>
idents - The identifier of the environment.
variable - The variable to assign to, or null
Returns:
generated C-code.
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_try_statement

public java.lang.String gen_try_statement(ZbnfParseResultItem zbnfThrowNew,
                                          int indent,
                                          LocalIdents localIdents)
                                   throws java.text.ParseException,
                                          java.io.FileNotFoundException,
                                          java.lang.IllegalArgumentException,
                                          java.io.IOException,
                                          java.lang.IllegalAccessException,
                                          java.lang.InstantiationException
generates the expression for a < try_Statment> .

Parameters:
zbnfThrowNew -
localIdents -
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_throwNew

public java.lang.String gen_throwNew(ZbnfParseResultItem zbnfThrowNew,
                                     ZbnfParseResultItem zbnfDescription,
                                     LocalIdents localIdents,
                                     FieldData typeReturn)
                              throws java.text.ParseException,
                                     java.io.FileNotFoundException,
                                     java.lang.IllegalArgumentException,
                                     java.io.IOException,
                                     java.lang.IllegalAccessException,
                                     java.lang.InstantiationException
generates the expression for a .

Parameters:
zbnfThrowNew -
localIdents -
Returns:
Throws:
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_VariableInitAssignment

public java.lang.String gen_VariableInitAssignment(ZbnfParseResultItem zbnfVariableDefinition,
                                                   int indent)
                                            throws java.text.ParseException,
                                                   java.io.FileNotFoundException,
                                                   java.lang.IllegalArgumentException,
                                                   java.io.IOException,
                                                   java.lang.IllegalAccessException,
                                                   java.lang.InstantiationException
generates the initial assignments to variables. Called only inside a #gen_statementBlock(ZbnfParseResultItem , int, StatementBlock, ClassData, char)

Parameters:
zbnfVariableDefinition - Item of < variableDefinition>
Throws:
java.io.IOException
java.text.ParseException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.io.IOException
java.lang.IllegalArgumentException
java.io.FileNotFoundException

gen_VariableDefWithSimpleInitValue

java.lang.String gen_VariableDefWithSimpleInitValue(FieldData variable,
                                                    ZbnfParseResultItem zbnfInitAssignment)
                                              throws java.text.ParseException,
                                                     java.io.FileNotFoundException,
                                                     java.lang.IllegalArgumentException,
                                                     java.io.IOException,
                                                     java.lang.IllegalAccessException,
                                                     java.lang.InstantiationException
Generates the definition of variable with its initialization. It is able to use first for static variable, it is not able to use for complexly initilizations, which depends from pre-calculated values. TODO: To sophisticate something obout the sources of the value, it should be returned whether the value is only build with constants, or with some variables. It should be returned from gen_value. Than here only a constant value may be considered. It is necessary for C static variable, but also for immediately initializiation of variable. If any dynamically values are used, the initialization don't may execute here. This routine should return null.

Parameters:
variable -
zbnfInitAssignment -
Returns:
Throws:
java.text.ParseException
java.io.FileNotFoundException
java.lang.IllegalArgumentException
java.io.IOException
java.lang.IllegalAccessException
java.lang.InstantiationException

stop

void stop()