public class GenJava_Class_JgenMdl
extends java.lang.Object
#gen(FBlock_JgenMdl, File, String)
is the start function to generate.Modifier and Type | Class and Description |
---|---|
(package private) static class |
GenJava_Class_JgenMdl.ClassComposite
An instance of this presents a variable on class level for a composite instance, used for a submodule.
|
(package private) static class |
GenJava_Class_JgenMdl.ClassVar
An instance of this presents a variable on class level.
|
(package private) static class |
GenJava_Class_JgenMdl.JavaFn
Instance to associate a block function to a Java system function.
|
(package private) static class |
GenJava_Class_JgenMdl.TstepOperations
This class sorts the operations to there step time association.
|
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
bGenJava |
(package private) java.util.Map<java.lang.String,GenJava_Class_JgenMdl.ClassComposite> |
classComposites
All instances which are present as
Callmodule_FBlock_JgenMdl . |
(package private) java.util.Map<java.lang.String,GenJava_Class_JgenMdl.ClassVar> |
classVars
All nodes in the model which should be present as object variables.
|
(package private) GenJava_Statement_JgenMdl |
genStm
Helper class to generate statements, may be removed after TODO
|
(package private) static java.util.Map<java.lang.String,java.lang.String> |
mathConst |
(package private) Module_FBlock_JgenMdl |
moduleBlock |
(package private) ModuleTranslated_JgenMdl |
moduleTransl |
(package private) int |
nrTempVars
Counter for name of tmp variables in this class.
|
(package private) java.util.List<GenJava_Operation_JgenMdl> |
operations
All operations of this class, the update operation too.
|
(package private) GenJavaPrj_JgenMdl |
prj |
(package private) java.util.Map<java.lang.String,java.lang.String> |
sImports |
(package private) static java.util.Map<java.lang.String,GenJava_Class_JgenMdl.JavaFn> |
smlk2JavaFn
The update operation of this class.
|
(package private) java.lang.String |
sNameClass |
private java.util.List<FBlock_JgenMdl> |
statementsInOrder
All FBlock_Mdl which are statements (have a
StatementData_JgenMdl ) sorted in necessary order of operation. |
(package private) java.util.List<FBlock_JgenMdl> |
statementsUnsorted
All FBlock_Mdl which are statements (have a
StatementData_JgenMdl ) sorted in necessary order of operation. |
(package private) java.lang.StringBuilder |
testOut |
(package private) java.util.Map<java.lang.Integer,GenJava_Class_JgenMdl.TstepOperations> |
XXXsteptimes |
Constructor and Description |
---|
GenJava_Class_JgenMdl(Module_FBlock_JgenMdl module,
ModuleTranslated_JgenMdl moduleTransl,
java.lang.String sNameClass,
GenJavaPrj_JgenMdl prj) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addImportPackage(java.lang.String sPkg) |
(package private) GenJava_Class_JgenMdl.ClassVar |
addOrGetClassVar(ConnOut_FBcl outCon,
java.lang.String name,
boolean bScalarAsRefArray)
Adds a class variable which is need in an operation.
|
private void |
assignStatementsToOperations()
Sorts all
statementsInOrder to moduleBlock Module_FBlock_JgenMdl#operBlocks respectively GenJava_Operation_JgenMdl |
(package private) void |
checkAddStateVar(ConnOut_FBcl outCon) |
private void |
findOutconRet()
Sets the
StatementData_JgenMdl.ixOutconRet with the first #conout which is a scalar for all FBlocks. |
private void |
genAtomicOperation(java.lang.Appendable out)
Generates one operation per step time.
|
private void |
genCommentClass(java.lang.Appendable out) |
private void |
genCommentOperationBlockForClass(java.lang.Appendable out,
Operation_FBlock_JgenMdl ob) |
private void |
genJava_createInstanceVar(java.lang.Appendable javaSrc,
GenJava_Class_JgenMdl.ClassVar var,
java.lang.String sIndent,
boolean bOutput,
java.lang.String comment) |
(package private) void |
genJava_useInstanceOrLocalVar(java.lang.Appendable javaSrc,
ConnOut_FBcl con,
Connection_FBcl usingcon,
FBlock_JgenMdl stmBlock)
Checks whether the connecton name is existing as ClassVar and appends the access.
|
(package private) void |
genJava_useRefVar(java.lang.Appendable javaSrc,
java.lang.String nameCon,
ConnOut_FBcl con)
Generates Java code for an operation argument which is an output.
|
(package private) void |
genJava_useVar(java.lang.Appendable javaSrc,
GenJava_Class_JgenMdl.ClassVar classvar,
Connection_FBcl useForConnection,
FBlock_JgenMdl outBlock)
Generates the code to access an existing ClassVar.
|
private void |
genJavaSrc_UpdateOperation(java.lang.Appendable out) |
(package private) void |
genJavaSrc_VectorFrameEnd(java.lang.Appendable out,
int zVectorGen) |
(package private) int |
genJavaSrc_VectorFrameStart(java.lang.Appendable out,
int zVectorNew,
int zVectorGen) |
private void |
genJavaSrc(java.io.File dirOut,
java.lang.String sPackage,
boolean bTopModule) |
private void |
genStatements()
Build statements of blocks which are able to present as one expression and generates the code for it.
|
private void |
genUpdateStatements() |
(package private) java.lang.String |
getOrCreateNameOut(ConnOut_FBcl con)
Returns the name of an Connection.
|
static java.lang.String |
lowerName(java.lang.CharSequence cs) |
private static long |
markPortBits(FBlock_JgenMdl stmBlock,
long mBitOutport,
int recursion) |
static java.lang.CharSequence |
prepareName(java.lang.String name)
Prepares the class name from given module name.
|
(package private) java.lang.String |
setUsedConstIdent(java.lang.String ident,
DataType_FBcl type) |
private static java.util.List<FBlock_JgenMdl> |
sortStatements(java.util.List<FBlock_JgenMdl> unsortedStatemens) |
private static long |
sortStatementsRecursively(FBlock_JgenMdl stmBlock,
java.util.List<FBlock_JgenMdl> sortedStatements,
long mBitOutport,
int recursion) |
static java.lang.String |
sPrepareClassName(Callmodule_FBlock_JgenMdl refLibBlock)
Prepares the class name from given lib block.
|
static java.lang.String |
sPrepareClassName(Callmodule_FBlock_JgenMdl refLibBlock,
DataType_FBcl dataType)
Prepares the class name from given lib block.
|
java.lang.String |
toString() |
void |
translate(java.io.File dirOut,
java.lang.String sPackage,
boolean bTopModule,
int recursion)
Generates all stuff fort this java source files and internal data with given
FBlock_JgenMdl of a Submodule. |
static java.lang.String |
upperName(java.lang.CharSequence cs) |
private void |
writeInfoBlocks() |
final Module_FBlock_JgenMdl moduleBlock
final ModuleTranslated_JgenMdl moduleTransl
final java.lang.String sNameClass
boolean bGenJava
java.util.Map<java.lang.String,GenJava_Class_JgenMdl.ClassVar> classVars
java.util.Map<java.lang.String,GenJava_Class_JgenMdl.ClassComposite> classComposites
Callmodule_FBlock_JgenMdl
.java.util.Map<java.lang.Integer,GenJava_Class_JgenMdl.TstepOperations> XXXsteptimes
final GenJava_Statement_JgenMdl genStm
final java.util.Map<java.lang.String,java.lang.String> sImports
final java.util.List<FBlock_JgenMdl> statementsUnsorted
StatementData_JgenMdl
) sorted in necessary order of operation.private java.util.List<FBlock_JgenMdl> statementsInOrder
StatementData_JgenMdl
) sorted in necessary order of operation.final java.util.List<GenJava_Operation_JgenMdl> operations
static java.util.Map<java.lang.String,GenJava_Class_JgenMdl.JavaFn> smlk2JavaFn
Module_FBlock_JgenMdl#updateBlock
. This is the internal fblock to create the body of the update operation.static java.util.Map<java.lang.String,java.lang.String> mathConst
final GenJavaPrj_JgenMdl prj
int nrTempVars
java.lang.StringBuilder testOut
public GenJava_Class_JgenMdl(Module_FBlock_JgenMdl module, ModuleTranslated_JgenMdl moduleTransl, java.lang.String sNameClass, GenJavaPrj_JgenMdl prj)
module
- prj
- public void translate(java.io.File dirOut, java.lang.String sPackage, boolean bTopModule, int recursion) throws java.io.IOException
FBlock_JgenMdl
of a Submodule.
moduleBlock
.
moduleBlock
Module_FBlock_JgenMdl#operBlocks
and Module_FBlock_JgenMdl#updateBlocks
are set.
dirOut
- The directory where the file.java should be written insPackage
- recursion
- java.io.IOException
private void findOutconRet()
StatementData_JgenMdl.ixOutconRet
with the first #conout
which is a scalar for all FBlocks.
It invokes FBlock_JgenMdl#findOutconRetDetermine_zVectorStm()
, see there.private void genStatements() throws java.io.IOException
FBlock_JgenMdl.stm
is set, then it is a part-Block.
The statements contains the dependency to previous and next statements, see StatementData_JgenMdl.stms_src
and StatementData_JgenMdl.parts_dst
.
The statements are not sorted yet.
All generated statements will be written in the return list.
This list contains the statements which are only necessary for update (build state variables) at its end.
Therewith this statements are processed at last for order.java.io.IOException
private void genUpdateStatements() throws java.io.IOException
java.io.IOException
private static java.util.List<FBlock_JgenMdl> sortStatements(java.util.List<FBlock_JgenMdl> unsortedStatemens)
private static long sortStatementsRecursively(FBlock_JgenMdl stmBlock, java.util.List<FBlock_JgenMdl> sortedStatements, long mBitOutport, int recursion)
private static long markPortBits(FBlock_JgenMdl stmBlock, long mBitOutport, int recursion)
private void assignStatementsToOperations() throws java.io.IOException
statementsInOrder
to moduleBlock
Module_FBlock_JgenMdl#operBlocks
respectively GenJava_Operation_JgenMdl
java.io.IOException
private void writeInfoBlocks() throws java.io.IOException
java.io.IOException
private void genCommentClass(java.lang.Appendable out) throws java.io.IOException
java.io.IOException
private void genCommentOperationBlockForClass(java.lang.Appendable out, Operation_FBlock_JgenMdl ob) throws java.io.IOException
java.io.IOException
void addImportPackage(java.lang.String sPkg)
java.lang.String getOrCreateNameOut(ConnOut_FBcl con)
GenJava_Operation_JgenMdl
.
The name of the variable came from the ConnOut_FBcl#nameConnection()
. That have to be unique (see PrepareFromSlx#prepareModule(org.vishia.jgenMdl.SlxData.Block_SlxData)
.
ConnOut_FBcl#connectToBlock
because it should be known there always.
con
- The ConnOut_FBcl
of the dstBlock of a statement for its output or of the input block.ConnOut_FBcl#nameConnection()
of con too.java.io.IOException
void checkAddStateVar(ConnOut_FBcl outCon)
private void genJava_createInstanceVar(java.lang.Appendable javaSrc, GenJava_Class_JgenMdl.ClassVar var, java.lang.String sIndent, boolean bOutput, java.lang.String comment) throws java.io.IOException
java.io.IOException
GenJava_Class_JgenMdl.ClassVar addOrGetClassVar(ConnOut_FBcl outCon, java.lang.String name, boolean bScalarAsRefArray)
GenJava_Operation_JgenMdl
.outCon
- The ConnOut_FBcl
for which the variable is used.name
- The name of the Connection_FBcl#nameConnection
. A nonamed connection should be named already with tmp_99bScalarAsRefArray
- If the class variable is new allocated, it is designated as reference from beginning.
It means it is never used as non reference. If the ClassVar is found, existing already, its reference state is not changed here, this argument is not used.
The reference state (GenJava_Class_JgenMdl.ClassVar.bScalarAsRefArray
) is changed only if the access to the variable as reference is done.
See #genJava_useRefVar(Appendable, Connection_FBcl)
.void genJava_useInstanceOrLocalVar(java.lang.Appendable javaSrc, ConnOut_FBcl con, Connection_FBcl usingcon, FBlock_JgenMdl stmBlock) throws java.io.IOException
Connection_FBcl#nameConnection
does not exist, only the simple name is added.
That is for connections which are stored in local variables only.
#genJava_useVar(Appendable, ClassVar, FBlock_JgenMdl)
is executed.
javaSrc
- con
- The output connection for the signal.stmBlock
- To add for non-reference usage, see #genJava_useVar(Appendable, ClassVar, FBlock_JgenMdl)
.java.io.IOException
void genJava_useVar(java.lang.Appendable javaSrc, GenJava_Class_JgenMdl.ClassVar classvar, Connection_FBcl useForConnection, FBlock_JgenMdl outBlock) throws java.io.IOException
GenJava_Class_JgenMdl.ClassVar.genJavaCodeNotArray
to correct it if the ClassVar will be become a reference variable later.
javaSrc
- write intoclassvar
- given, not nulloutBlock
- The block where the generated code is stored. It is necessary for non-ref variable which are changed later to ref variable.
It may be null only in the end code generation in GenJava_Operation_JgenMdl#genJava_Operation(Appendable)
.java.io.IOException
void genJava_useRefVar(java.lang.Appendable javaSrc, java.lang.String nameCon, ConnOut_FBcl con) throws java.io.IOException
float[] myVar = new float[1]
.
The reference is the myVar
as array reference. This is not necessary for non-primitive variables.
If the variable is existing as simple variable till now, the existing code is changed to a array variable.
0128javaSrc
- con
- java.io.IOException
java.lang.String setUsedConstIdent(java.lang.String ident, DataType_FBcl type)
private void genJavaSrc(java.io.File dirOut, java.lang.String sPackage, boolean bTopModule) throws java.io.IOException
java.io.IOException
private void genJavaSrc_UpdateOperation(java.lang.Appendable out) throws java.io.IOException
java.io.IOException
int genJavaSrc_VectorFrameStart(java.lang.Appendable out, int zVectorNew, int zVectorGen) throws java.io.IOException
java.io.IOException
void genJavaSrc_VectorFrameEnd(java.lang.Appendable out, int zVectorGen) throws java.io.IOException
java.io.IOException
private void genAtomicOperation(java.lang.Appendable out) throws java.io.IOException
java.io.IOException
public static java.lang.String sPrepareClassName(Callmodule_FBlock_JgenMdl refLibBlock)
name
- The name can contain non-identifier characters such as space or line break.public static java.lang.String sPrepareClassName(Callmodule_FBlock_JgenMdl refLibBlock, DataType_FBcl dataType)
name
- The name can contain non-identifier characters such as space or line break.public static java.lang.CharSequence prepareName(java.lang.String name)
name
- The name can contain non-identifier characters such as space or line break.public static java.lang.String upperName(java.lang.CharSequence cs)
public static java.lang.String lowerName(java.lang.CharSequence cs)
public java.lang.String toString()
toString
in class java.lang.Object