public class WriterCodegen
extends java.lang.Object
#readTpl(Class, String).
Depending of the data structure different otx scripts are called.
With the otx scripts the adaption to any target language can be done, and also to any desired style.
The otx scripts are able to give from outside. The adaption can be done without changing the Java sources
and also without study the Java sources.
#writeCode(File, File, String, Module_FBcl, LogMessage).
This operation writes all defined output files.
General the script for the whole output file for a target language starts with:| Modifier and Type | Class and Description |
|---|---|
protected static class |
WriterCodegen.CondNode
Contains data saved in a stack for next sibling node after a condition node.
|
private static class |
WriterCodegen.LogLevel
Store info to log level in the stack
stackLogEntries |
static class |
WriterCodegen.MdlData |
static class |
WriterCodegen.OtxWorkData
This class holds data for one generation of code related to one otx script for a whole file.
|
(package private) static class |
WriterCodegen.XXXECondCode |
| Modifier and Type | Field and Description |
|---|---|
private AliasImport_FBcl |
aliasImport |
boolean |
bVerboseCode |
java.util.Map<java.lang.String,java.lang.String> |
cmprOp
Map operators of OFB (compatible IEC61499) to target language C/++, Java
Note due IEC61499 '=' is equal and '<>' is not equal from graphic
|
java.util.Map<java.lang.String,java.lang.String> |
cmprOpReverse
Note '>' is translated to '<=' etc. because the relation is to the input,
but the operator is written left side, regarded als compare between left and this value.
|
(package private) java.util.Map<java.lang.String,java.lang.Object> |
idxConstData
This map can be filled by the script especially with String-String associations.
|
(package private) java.util.Map<java.lang.String,java.lang.String> |
idxImportImpl |
(package private) java.util.TreeMap<java.lang.String,OutTextPreparer> |
idxOtx
Index with all scripts to write, filled after creation of this class calling
#readTpl(Class, String). |
(package private) java.util.Map<java.lang.String,OutTextPreparer.DataTextPreparer> |
idxOtxdata |
static java.util.List<Din_FBcl> |
iterDinEmpty
Is used for the first evChain entry, it has the module din.
|
static float |
kNoLimit |
private LogMessage |
logPrc |
private java.lang.StringBuilder |
logPrcBuffer |
private Module_FBcl |
mdl |
java.util.Map<java.lang.String,java.lang.String> |
numOp |
java.util.Map<java.lang.String,java.lang.String> |
numOpFirst |
private java.io.OutputStream |
oLogPrc |
(package private) OutTextPreparer |
otx_callFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_castValExprLim_SFd |
(package private) OutTextPreparer |
otx_ctorFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_ctorObjFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_defineLocalVar_FBexpr
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_evMdlOutEnd
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_evMdlOutStart
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_exprAccessElement
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_exprCondBitsIf
Called if a condition bit change is found.
|
(package private) OutTextPreparer |
otx_exprCondIf
Called if an event output true is found.
|
(package private) OutTextPreparer |
otx_exprTerm
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_initFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setMdlOutArrayCpy
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setMdlOutArrayExpr
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setMdlOutScalar
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setMdlOutStructCpy
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setVar_DoutFBarray2Din
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setVar_FBexpr
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setVarArrayElem
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setVarStruct
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setVarX_Array
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otx_setVarX_Elem
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otxAccessFBdout
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otxEvChainExprSetvar
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer). |
(package private) OutTextPreparer |
otxExprCondBitsEndif
Called if a condition bit change is found.
|
(package private) OutTextPreparer |
otxExprElse
Called if an event output true is found.
|
(package private) OutTextPreparer |
otxExprEndif
Called if the chain of an event output true is finished,
means the next event given before executing the "true" is found, or on end of all events.
|
(package private) OutTextPreparer |
otxExprEv_OFB_Variable
Called if an event output true is found.
|
(package private) OutTextPreparer |
otxExprIf
Called if an event output true is found.
|
(package private) Prj_FBcl |
prj |
(package private) java.lang.String |
sDbgFBexpr |
(package private) java.lang.String |
sDbgFBexprEvin |
private java.lang.String |
sLineIndent |
java.lang.String |
sNewlineIndent |
private java.util.Stack<WriterCodegen.LogLevel> |
stackLogEntries
The position in the current StringBuilder for output on call of
#writeLogPrcEntry(StringBuilder, String, Object...) |
(package private) java.lang.String |
testData |
java.util.Map<java.lang.String,java.lang.String> |
unaryOp |
static java.lang.String |
version
Version, history and license.
|
private java.io.Writer |
wrLogPrc |
(package private) OutTextPreparer |
XXXotx_exprSetCond
Called if an event output true is found.
|
| Constructor and Description |
|---|
WriterCodegen(Prj_FBcl prj) |
| Modifier and Type | Method and Description |
|---|---|
void |
addImportToPrj(java.lang.String sNameModule,
java.lang.String sKind,
java.lang.String sImportPath)
Adds the own header of the module to the project wide alias-header-
Prj_FBcl.codegenTypeReplace
So that usage of this Module FBtype imports the header. |
private void |
callFBoper(FBexpr_FBcl fbx,
long[] condBits,
Dout_FBcl dout,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst wrCt)
Generates the code for a called operation of an FBexpr as FBoper if it contains a
FBexpr_FBcl.getFunction(). |
private void |
callOtx(OutTextPreparer otx,
OutTextPreparer.WriteDst out,
OutTextPreparer.DataTextPreparer args)
Call the otx script with log entries.
|
private static boolean |
checkConnUse(PinConnect_FBcl connSrc,
long mEvinMdlMask,
int ixFBlock,
java.lang.String sVariant)
Deprecated.
use
#iterConnSrcConditional(Din_FBcl, long[]) |
boolean |
checkSetLocalVariable(java.lang.String name,
WriterCodegen.OtxWorkData wd) |
void |
debug(java.lang.Object val1)
It can be used to set a debug stop point in an otx script.
|
void |
debug4(java.lang.Object val1,
java.lang.Object val2,
java.lang.Object val3,
java.lang.Object val4)
It can be used to set a debug stop point in an otx script.
|
void |
doInsert(WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst OUT) |
DinExpr_FBcl.DTypeDesignation |
dTypeDsgn(java.lang.String sSAT,
DinExpr_FBcl xin,
DinExpr_FBcl x1)
Wrapper arround
DinExpr_FBcl.dTypeDsgn(String, DinExpr_FBcl) with log entries. |
void |
genCastAccess(Dinout_FBcl dinout,
DType_FBcl dtDst,
DType_FBcl dtSrc,
boolean bCast,
java.lang.String sSAT,
float maxArg,
float minArg,
boolean bCastConstArg,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst wrCt,
java.lang.CharSequence sExprIn)
Generates the cast and bit shift surround an value expression given as string from generation of this value or a constant.
|
java.lang.String |
genConstantValue(Din_FBcl din,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Generates the const value string with given
Din_FBcl.sConstant
and also given Din_FBcl.dTypeCastInp as detected type of the constant,
tuned to the Dinout_FBcl.dTypeDecl(), the type of the pin itself. |
java.lang.String |
genDinAccess(Din_FBcl din,
PinConnect_FBcl conn,
long[] condBits,
java.lang.String sVariant,
java.lang.String ref,
int ixFBlock,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Compatible form see
#genDinAccessLimit(Din_FBcl, PinConnect_FBcl, long[], String, String, int, String, float, float, OtxWorkData, StringBuilder)
especially used in otx script, where limitation is not a topic. |
void |
genDinAccessConnLimit(Din_FBcl dinDst,
PinConnect_FBcl connSrc,
java.lang.String cacc,
int ixFBlock,
long[] condBits,
java.lang.String ref,
float max,
float min,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Generates the code for a given
Din_FBcl for a given connection PinConnect_FBcl |
java.lang.String |
genDinAccessLimit(Din_FBcl din,
PinConnect_FBcl conn,
long[] condBits,
java.lang.String sVariant,
java.lang.String ref,
int ixFBlock,
java.lang.String cacc,
float max,
float min,
boolean bOnlyOne,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Generates the access String for an input of any FBlock.
|
void |
genDinConnAcc(Din_FBcl din,
PinConnect_FBcl conn,
java.lang.String cacc,
int ixFBlock,
long[] condBits,
int[] ixFBArg,
java.lang.String ref,
java.lang.String sSat,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Generates the code for one connected Dout for
Din_FBcl, also for DinExpr_FBcl
or also for the const value of Din_FBcl.sConstant if given. |
java.lang.String |
genEventOperBody(EvtreeNode_FBcl rootNode,
Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
java.lang.String |
genEventOperHeader(Evout_FBcl evinMdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
private void |
genExprIn(DinExpr_FBcl din,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String sOperatorLeftArg,
java.lang.String sOperator,
java.lang.String sUnaryOp,
java.lang.String ref,
int ix,
java.lang.String caccArg,
float max,
float min,
boolean bOnlyOne,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out,
int recursion)
Generate the code of an expression input regarding constant values and K parts.
|
private void |
genExprInConn(Dout_FBcl doutSrc,
DinExpr_FBcl din,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String sOperatorLeft,
java.lang.String sOperator,
java.lang.String sUnaryOp,
java.lang.String ref,
java.lang.String caccArg,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out,
int recursion)
Generates the expression term part for one given connection from its Dout to one Dinexpr.
|
private void |
genExprOut(Dout_FBcl doutExpr,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out,
int recursion)
Generates the term due to the given expression.
|
void |
genExprSetVar(java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
java.lang.String var,
DoutExpr_FBcl doutExpr,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst sb)
Called from otx.
|
private void |
genExprTerm(OutTextPreparer.WriteDst out,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
int recursion)
Generates an expression determined by its inputs with its operators and K inputs.
|
private void |
genExprTermCmpr(OutTextPreparer.WriteDst OUT,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
java.lang.Iterable<DinExpr_FBcl> dinValues,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
int recursion) |
java.lang.String |
genInlineGetOper(Din_FBcl doutMdl,
Evin_FBcl evoutMdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
java.lang.String |
genRefIn(PinRef_FBcl din,
long[] condBits,
java.lang.String ref,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out,
int recursion)
Generates the access String for a reference of a FBlock for direct connected port output.
|
java.lang.String |
genValueDin(Din_FBcl din,
long[] condBits,
java.lang.String ref,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd)
Generates the access String for an input of a FBlock maybe through some combinatoric expressions.
|
void |
genValueDout(java.lang.Iterable<FBlock_FBcl> iterFBsrc,
Dout_FBcl dout,
long[] condBits,
java.lang.String ref,
int[] ixFB,
int[] ixDout,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out,
int recursion)
Generates the access String to data from the given output pin of any
FBlock_FBcl, also an FBexpr_FBcl or a Variable after expression. |
void |
genVarExpr(Dout_FBcl doutVar,
Dout_FBcl doutExpr,
FBlock_FBcl fb,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst sb)
Called in otx (VarX_OFB) to set the variable after expression or access.
|
void |
genVariableDef(Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Generates a proper code for variable definitions (usual in header file) for all variables on output on expressions.
|
(package private) OutTextPreparer.DataTextPreparer |
getCreateOtxData(OutTextPreparer otx,
WriterCodegen.OtxWorkData wd)
Gets the proper instance of DataTextPreparer to run
OutTextPreparer#exec(Appendable, org.vishia.util.OutTextPreparer.DataTextPreparer)
running repeatedly in the same thread. |
void |
insertPoint(WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst OUT) |
static java.lang.Iterable<java.lang.Integer> |
iterBits(long[] bitArray) |
java.lang.Iterable<PinConnect_FBcl> |
iterConnSrcConditional(Din_FBcl din,
long[] condBits,
java.lang.String sVariant,
int ixFBlock,
WriterCodegen.OtxWorkData wd)
Wrapper around
Din_FBcl.iterConnSrcConditional(long[], long, String, int)
for code generation with argument wd instead 'mEvinMdlMask'. |
java.lang.Iterable<java.lang.String> |
iterImportHeader(WriterCodegen.OtxWorkData wd,
java.lang.String sKind)
Offers an
Iterable for all import or header files. |
java.lang.Iterable<java.lang.String> |
iterImportImpl()
TODO should be organized similar as
iterImportHeader(OtxWorkData, String) |
java.lang.StringBuilder |
newStringBuilder() |
void |
parseScripts(LogMessage log)
Translates the script to otx, second pass of translation
It translates
idxOtx and set otx_callFB_evin. |
private void |
prc_DefineLocalVar(Evin_FBcl evinDst,
Dinout_FBcl varExpr,
java.util.List<Dout_FBcl> listVarOut,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Defines local variables used for FBexpr and FBlock as return and reference variables.
|
private void |
prc_setVar_DoutFBarray2Din(Dout_FBcl doutSrc,
Din_FBcl dinDst,
long[] condBitsSrc,
Evin_FBcl evinDst,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
private void |
prc_setVar_FBexpr(FBexpr_FBcl fbx,
Evout_FBcl evSrc,
Evin_FBcl evinDst,
Dout_FBcl doutExpr,
Dinout_FBcl varExpr,
java.util.List<Dout_FBcl> listVarOut,
long[] condBits,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
Generates code to set the variable(s) after expression.
|
void |
prcEvchainOperation(EvtreeNode_FBcl nodeRoot,
Evout_FBcl evStartArg,
Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out)
This operation follows the
EvtreeNode_FBcl from evStart to generate the code for this event as operation. |
private void |
prcEvinFBexpr(Evout_FBcl evSrc,
Evin_FBcl evinDst,
long[] condBits,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst wrCt)
Process the next FBlock as FBexpr.
|
private void |
prcEvinFBlock(Evout_FBcl evinMdl,
Evout_FBcl evoutSrc,
Evin_FBcl evinDst,
long[] condBitsSrc,
java.lang.String sVariant,
WriterCodegen.OtxWorkData wd,
Module_FBcl mdl,
OutTextPreparer.WriteDst out)
Processes one evin to one FBlock.
|
private void |
prcEvNode(Evout_FBcl evinMdl,
EvtreeNode_FBcl evNode,
long[] condBitsSrc,
EvtreeNode_FBcl.IteratorEvoutTree iterTree,
Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out,
int recursion)
Generates the code due to one
EvtreeNode_FBcl called in #prcEvchainOperation(EvtreeNode_FBcl, Evout_FBcl, Module_FBcl, OtxWorkData, Appendable)
following the event node chain. |
private void |
prcEvNodesBranch(Evout_FBcl evinMdl,
EvtreeNode_FBcl evNode,
Evout_FBcl evoutSrc,
Evin_FBcl XXXevin,
long[][] condBits,
int ixCond,
WriterCodegen.OtxWorkData wd,
Module_FBcl mdl,
OutTextPreparer.WriteDst out,
int recursion) |
private void |
prepareExprTextGiven(OutTextPreparer.WriteDst out,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
java.lang.String sFn,
WriterCodegen.OtxWorkData wd)
Prepares any expression which is given in sFn.
|
void |
readTpl(java.lang.Class<?> classInJar,
java.lang.String pathTpl,
LogMessage log)
Reads the script file in the first pass
It fills
idxOtx with empty instances of otx. |
void |
stateDefinitionHeader(Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
void |
stateDefinitionHeader1(Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
void |
stateDefinitionVars(Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
void |
stateDefinitionVars1(Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst out) |
private boolean |
testCondition(Din_FBcl din,
long[] condBits)
Test whether the given condition is met on any of the source pins if more connections are given.
|
private boolean |
testCondition(Dout_FBcl doutSrc,
long[] condBits)
Test whether the condition is true for the given source pin.
|
void |
testOtx(java.lang.Object... val) |
void |
testOtxCond(java.lang.String valTest,
java.lang.String sTest,
java.lang.Object... val) |
java.lang.CharSequence |
testPins(FBlock_FBcl fb) |
private java.lang.String |
translateOperatorToTargetLang(char dType,
java.lang.String sGraphicOperator,
java.util.Map<java.lang.String,java.lang.String> idxTrl,
java.lang.String sDefault)
check whether graphic operator with specific type should be translated.
|
private void |
writeCode(java.io.File dirout,
java.io.File dirCmp,
java.lang.String sMdlName,
FBlock_FBcl fbCalling,
Module_FBcl mdl,
LogMessage log) |
void |
writeCodeMain(Module_FBcl mdl) |
java.lang.String |
writeLogOtx(WriterCodegen.OtxWorkData wd,
java.lang.String sId,
java.lang.Object... args) |
private void |
writeLogPrcEnd(OutTextPreparer.WriteDst out,
java.lang.CharSequence textArg,
java.lang.Object... args)
Must be called as closing to
#writeLogPrcEntry(StringBuilder, String, Object...). |
private void |
writeLogPrcEntry(OutTextPreparer.WriteDst out,
java.lang.String text,
java.lang.Object... args) |
private void |
writeLogPrcEntry(java.lang.String sIdLog,
OutTextPreparer.WriteDst out,
java.lang.String text,
java.lang.Object... args)
Writes a log entry for code generation.
|
public static final java.lang.String version
public static final float kNoLimit
public static final java.util.List<Din_FBcl> iterDinEmpty
public final java.util.Map<java.lang.String,java.lang.String> cmprOpReverse
public final java.util.Map<java.lang.String,java.lang.String> cmprOp
public final java.util.Map<java.lang.String,java.lang.String> numOp
public final java.util.Map<java.lang.String,java.lang.String> numOpFirst
public final java.util.Map<java.lang.String,java.lang.String> unaryOp
final java.lang.String sDbgFBexpr
final java.lang.String sDbgFBexprEvin
final Prj_FBcl prj
private java.lang.StringBuilder logPrcBuffer
private java.io.OutputStream oLogPrc
private java.io.Writer wrLogPrc
private LogMessage logPrc
private java.lang.String sLineIndent
private java.util.Stack<WriterCodegen.LogLevel> stackLogEntries
#writeLogPrcEntry(StringBuilder, String, Object...)
to output the text progress in #writeLogPrcEnd(StringBuilder, String, Object...).public boolean bVerboseCode
public java.lang.String sNewlineIndent
final java.util.TreeMap<java.lang.String,OutTextPreparer> idxOtx
#readTpl(Class, String).
The content comes from the script as argument pathTpl.final java.util.Map<java.lang.String,OutTextPreparer.DataTextPreparer> idxOtxdata
final java.util.Map<java.lang.String,java.lang.String> idxImportImpl
private AliasImport_FBcl aliasImport
final java.util.Map<java.lang.String,java.lang.Object> idxConstData
OutTextPreparer otx_callFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_ctorFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_ctorObjFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_initFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otxEvChainExprSetvar
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_exprTerm
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_exprAccessElement
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setVar_FBexpr
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_defineLocalVar_FBexpr
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setVar_DoutFBarray2Din
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_evMdlOutStart
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_evMdlOutEnd
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setMdlOutScalar
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setMdlOutArrayCpy
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setMdlOutArrayExpr
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setMdlOutStructCpy
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otxAccessFBdout
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setVarStruct
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setVarArrayElem
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setVarX_Array
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otx_setVarX_Elem
#prcEvChain(Evin_FBcl, Integer, Writer).OutTextPreparer otxExprEv_OFB_Variable
#prcEvchainOperation(Evout_FBcl, Module_FBcl, Appendable)OutTextPreparer otxExprIf
#prcEvchainOperation(Evout_FBcl, Module_FBcl, Appendable)OutTextPreparer XXXotx_exprSetCond
OutTextPreparer otx_exprCondIf
OutTextPreparer otxExprElse
OutTextPreparer otx_exprCondBitsIf
OutTextPreparer otxExprCondBitsEndif
OutTextPreparer otxExprEndif
#prcEvchainOperation(Evout_FBcl, Module_FBcl, Appendable)OutTextPreparer otx_castValExprLim_SFd
private Module_FBcl mdl
java.lang.String testData
public WriterCodegen(Prj_FBcl prj)
public void debug(java.lang.Object val1)
<:exec:debug(val)>public void debug4(java.lang.Object val1,
java.lang.Object val2,
java.lang.Object val3,
java.lang.Object val4)
<:exec:debug(val, val, val, val)>public void testOtx(java.lang.Object... val)
public void testOtxCond(java.lang.String valTest,
java.lang.String sTest,
java.lang.Object... val)
public static java.lang.Iterable<java.lang.Integer> iterBits(long[] bitArray)
public void readTpl(java.lang.Class<?> classInJar,
java.lang.String pathTpl,
LogMessage log)
idxOtx with empty instances of otx.classInJar - given then read from jar-File, null: read as filepathTpl - relative path to classInJar or path in file systemjava.io.IOExceptionjava.text.ParseExceptionpublic void parseScripts(LogMessage log)
idxOtx and set otx_callFB_evin.java.text.ParseExceptionpublic void writeCodeMain(Module_FBcl mdl)
private void writeCode(java.io.File dirout,
java.io.File dirCmp,
java.lang.String sMdlName,
FBlock_FBcl fbCalling,
Module_FBcl mdl,
LogMessage log)
dirout - output directory for the generated filedirCmp - directory where the same files are existing from generation before, to comparesMdlName - fbCalling - The FBlock from which the module generation is called.
It can contain actual DType_FBcl referenced via FBlock_FBcl.dTypes.
This FBlock should reference the module which should be generated,
via FBlock_FBcl.fbt and then FBtype_FBcl.mdl.log - public java.lang.Iterable<java.lang.String> iterImportHeader(WriterCodegen.OtxWorkData wd, java.lang.String sKind)
Iterable for all import or header files.
The container for the Iterable is build on demand.
It iterates over all Module_FBcl.iterFBlock(),
detects their FBlock_FBcl.typeName() regarding also dedication of non dedicated FBtype,
and looks for the header in aliasImport.wd - working datasKind - kind of import or headerpublic java.lang.Iterable<java.lang.String> iterImportImpl()
iterImportHeader(OtxWorkData, String)public void addImportToPrj(java.lang.String sNameModule,
java.lang.String sKind,
java.lang.String sImportPath)
Prj_FBcl.codegenTypeReplace
So that usage of this Module FBtype imports the header.sNameModule - identifier of the FBtype is the name of the module.sKind - kind of header for key in AliasImport_FBcl.Elem#importsTypesImportPath - The path as should be used in relation with the sKind.public void insertPoint(WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst OUT) throws java.io.IOException
java.io.IOExceptionpublic void doInsert(WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst OUT)
public boolean checkSetLocalVariable(java.lang.String name,
WriterCodegen.OtxWorkData wd)
OutTextPreparer.DataTextPreparer getCreateOtxData(OutTextPreparer otx,
WriterCodegen.OtxWorkData wd)
OutTextPreparer#exec(Appendable, org.vishia.util.OutTextPreparer.DataTextPreparer)
running repeatedly in the same thread.
Hint: For more as one thread use different instances. Use the threadId also as key.otx - public java.lang.CharSequence testPins(FBlock_FBcl fb)
public void genVariableDef(Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
FBlock_FBcl.kind() is == FBlock_FBcl.Blocktype#VarAfterExpr
and then calls the otx script with the type name of the FBlock_FBcl.typeName() following by "_h".
<otx: VarZ_OFB_h ... or <otx: VarV_OFB_h ... or <otx: VarL_OFB_h ...
whereby 'VarL_OFB' is a local variable, should not create a variable definition here, but can be used as comment docu line.
mdl - Module's dataout - to write the source codejava.io.IOExceptionpublic void prcEvchainOperation(EvtreeNode_FBcl nodeRoot, Evout_FBcl evStartArg, Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
EvtreeNode_FBcl from evStart to generate the code for this event as operation.
This routine should be called inside the otx script for the implementation code.evStart - The event which is the start event of the operation.mdl - The module dataout - Output. It is anytime a StringBuilder, needs insertion points.java.io.IOExceptionprivate void prcEvNode(Evout_FBcl evinMdl, EvtreeNode_FBcl evNode, long[] condBitsSrc, EvtreeNode_FBcl.IteratorEvoutTree iterTree, Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out, int recursion) throws java.io.IOException
EvtreeNode_FBcl called in #prcEvchainOperation(EvtreeNode_FBcl, Evout_FBcl, Module_FBcl, OtxWorkData, Appendable)
following the event node chain.
This follows the connection between two FBlocks or the module's evinMdl and evoutMdl.evinMdl - The modules evin or the evin on start of this event chainevNode - the TreeNode with the evin to the FBlockcondBitsSrc - null or maybe given bits for conditions, which are checked with input data.iterTree - The iterator where the evNode is gotten from. Used to continue on sibling etc. if conditions givenmdl - The modulewd - out - recursion - java.io.IOExceptionprivate void prcEvNodesBranch(Evout_FBcl evinMdl, EvtreeNode_FBcl evNode, Evout_FBcl evoutSrc, Evin_FBcl XXXevin, long[][] condBits, int ixCond, WriterCodegen.OtxWorkData wd, Module_FBcl mdl, OutTextPreparer.WriteDst out, int recursion) throws java.io.IOException
java.io.IOExceptionprivate void prcEvinFBlock(Evout_FBcl evinMdl, Evout_FBcl evoutSrc, Evin_FBcl evinDst, long[] condBitsSrc, java.lang.String sVariant, WriterCodegen.OtxWorkData wd, Module_FBcl mdl, OutTextPreparer.WriteDst out) throws java.io.IOException
#prcEvchainOperation(Evout_FBcl, Module_FBcl, OtxWorkData, StringBuilder)
for each event from the queue.
It calls one of the described processing in the given order of the following list:
FBlock_FBcl of the 'evinDst' is an array of FBlocks calling FBlock_FBcl.sizeArray().
FBlock_FBcl.sizeArray() should not play a role. It is ignored for FBexpr.
FBlock_FBcl.typeName() is existing.
Means, specific FBtype_FBcl can have there own source code generation script.
The script is called with the arguments:
FBlock_FBcl itself due to evin.fb
Din_FBcl, the first din if given, or null if the fb has not an input. This helps on some simple FBlocks to access
Dout_FBcl, the first output if given, or null if the fb has not an output. This helps on some simple FBlocks to access
DoutType_FBcl, This helps on some simple FBlocks to access
Evin_FBcl the evinDst as argument of this operation, it is the original given evin from the event queue
Evout_FBcl the evSrc as argument of this operation, it is the source of the evin usable for comments in source code.
FBlock_FBcl.kind() == FBlock_FBcl.Blocktype#VarAfterExpr and the update pin is reached,
in that kind point above <otx: VarZ_OFB_upd... is called for update source code.
with the arguments shown in the point before.
FBaccess_FBcl then #prcEvinFBaccess(Evout_FBcl, Evin_FBcl, List, Map, Appendable) is called,
see there.
Module_FBcl.idxFBlockTEST, then normally no code generation should be done for it in this operation.
But on option -verbodeCode the <otx: infoFBtest ... is called to get an info about this FBlock as part of the event queue.
PinKind_FBcl.isModulePin())
then <otx: evChainMdlOut... is called with the arguments
Evin_FBcl.iterAssocDin() all inputs to this event.
<otx: callFB_evin:... is searched and should be found.
This found otx is called with the same arguments as <otx: evChainMdlOut..., iterDin, evout and evin.
Module_FBcl.idxFBlockTEST) evout are not considerate.
FBlock_FBcl.iterEvout(Evin_FBcl) is called to get the correspond evout,
and they are put in the queue calling #addEventNextAll(List, Evin_FBcl, Appendable)
to generate the code for this FBlocks afterwards in the event order.
The event order is firstly regard immediately following events, later parallel events.
This is done by "last in first out" organization of the queue.
evoutSrc - The source of this evin, only used for commentevinDst - the evin to processqueueEvSrc - queue to add following evout of the FBlock.idxEvStartChainCodegen - Hash Map stores the already used events for codeGen to prevent twice or circular code generation,
may be caused only by an software errormdl - The module's dataout - output for source codejava.io.IOExceptionprivate void prcEvinFBexpr(Evout_FBcl evSrc, Evin_FBcl evinDst, long[] condBits, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst wrCt) throws java.io.IOException
#prcEvinFBlock(Evout_FBcl, Evout_FBcl, Evin_FBcl, long[], String, OtxWorkData, Module_FBcl, Appendable)
only if FBexpr_FBcl.cAccess() is '$' or '='.
It is FBexpr_FBcl.cAccess which is also given the first character in din[0]
able to see in FBcl presentation as constant initializer of 'expr'.
If it is not so, the expression is generated as inline access, done backward from inputs,
which calls #genExprTerm(StringBuilder, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, int)
maybe with the correct component on complex or comprehensive types.
<otx: setVar_FBexpr....
Evout_FBcl only for comment
Evin_FBcl of the FBexpr
FBexpr_FBcl the FBexpr itself
FBexpr_FBcl#getOperation()
PinKind_FBcl.Dout
FBlock_FBcl the FBlock of the variable after the dout which is type of DoutExpr_FBcl.
It is null if the expression has not a connection on its DoutExpr_FBcl.
Note: All other outputs of the expression are only Dout_FBcl.
DoutExpr_FBcl
evSrc - the evout before this FBlock, only for commentevinDst - the relevant prep evin of the FBlockqueueEvSrc - queue to add new driven eventsidxEvStartChainCodegen - Hash Map stores the already used events for codeGen to prevent twice or circular code generation,
may be caused only by an software errorwr - outputjava.io.IOExceptionprivate void prc_DefineLocalVar(Evin_FBcl evinDst, Dinout_FBcl varExpr, java.util.List<Dout_FBcl> listVarOut, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
otx_defineLocalVar_FBexpr.evinDst - Only for comment in code.varExpr - It is possible that DoutMdl will be applied, hence Din_FBcl should be admissible.listVarOut - list of reference variableswd - out - java.io.IOExceptionprivate void prc_setVar_FBexpr(FBexpr_FBcl fbx, Evout_FBcl evSrc, Evin_FBcl evinDst, Dout_FBcl doutExpr, Dinout_FBcl varExpr, java.util.List<Dout_FBcl> listVarOut, long[] condBits, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
otx_defineLocalVar_FBexpr, otx_setVar_FBexpr .
This is an expression marked with FBexpr_FBcl.cAccess == one of "$=".
The proper expression is detect in EvoutTreePrc_FBcl.
This operation is called from #prcEvinFBexpr(Evout_FBcl, Evin_FBcl, long[], OtxWorkData, Appendable)
and from #prcEvinFBlock(Evout_FBcl, Evout_FBcl, Evin_FBcl, long[], String, OtxWorkData, Module_FBcl, Appendable).
#genExprOut(Dout_FBcl, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, StringBuilder, int)
For debug set a breakpoint there.fbx - evSrc - evinDst - doutExpr - The output of the expression itself, it is usual avarExpr - The variable after the expression. It can be either a module's output, which is an Din_FBcl,
an referenced input of a FbLock,
or also the variable after expression given as Dout_FBcl.listVarOut - a list of variable which are used in the expression and which should be defined as stack local variable.condBits - to access inputs, the condition from the evSrcwd - out - java.io.IOExceptionprivate void prc_setVar_DoutFBarray2Din(Dout_FBcl doutSrc, Din_FBcl dinDst, long[] condBitsSrc, Evin_FBcl evinDst, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionprivate void callFBoper(FBexpr_FBcl fbx, long[] condBits, Dout_FBcl dout, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst wrCt) throws java.io.IOException
FBexpr_FBcl.getFunction().
Dout_FBcl of the expression.
Note: Intrinsically this operation should be hold in the EvinType_FBcl pin
but this is not possible because the expression is not determined by the type.
Or think about, a special type is created for a specific expression since 2024-07-26 also because different data types.
FBlock_FBcl.reference pin, then it is the reference to the associated FBlock
where this operation is a member of. Hence the operation of the type is called, with the reference as this pointer.
fbx - The FBoperdout - presents the value of the expression, all other outputs are call by value arguments.wr - to write the code.java.io.IOExceptionpublic java.lang.String genInlineGetOper(Din_FBcl doutMdl, Evin_FBcl evoutMdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String genEventOperHeader(Evout_FBcl evinMdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String genEventOperBody(EvtreeNode_FBcl rootNode, Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String genValueDin(Din_FBcl din, long[] condBits, java.lang.String ref, java.lang.String cacc, WriterCodegen.OtxWorkData wd) throws java.io.IOException
<:set:dinVar=genValueDin(fbx.din[1],'', 0)>
This example shows set a access variable string with generated access code to use it to set the components of the variable.
Also it is called inside #prepareExprTextGiven(Appendable, FBexpr_FBcl, String) to replace the X1.. variables with the code on inputs.
Hence the content is not immediately written for the code generation, instead it is prepared in a StringBuilder
and returned as String to use.
It calls #genValueDout(Dout_FBcl, String, Appendable, int) with this StringBuilder if the input has a connection to an output.
Non connected input constant values are immediately returned.din - The data input which is connected to any output or it has a Din_FBcl.sConstantcacc - access to an element of an input variable, for example ".re" or "[1]"ref - reference to the module data, it is often "thiz" inside the module, or a specific reference variablejava.io.IOExceptionpublic java.lang.String genConstantValue(Din_FBcl din, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
Din_FBcl.sConstant
and also given Din_FBcl.dTypeCastInp as detected type of the constant,
tuned to the Dinout_FBcl.dTypeDecl(), the type of the pin itself.
DTypeBase_FBcl.typeChar stored in Dinout_FBcl.dTypeDecl()
and 'C' stands for the given DType of the constant typeChar stored in Din_FBcl.dTypeCastInp.
For example 'otx:castValue_FD' presents a float constant, in C/++ with following f.
"3.14" given in graphic will be presented by "3.14f" in the generated code.
DTypeBase_FBcl.zBitFrac.
Then it converts for example for Pin Dtype "S.8" (short, 8 bits fractional)
a constant 1.25 via '(int16)( (1L<<8) * 1.25f)' to a value 0x0140.din - The input which may have a Din_FBcl.sConstant. If not, nothing is done.wd - Working datasb - If given then write the text in this StringBuilder, and return null.java.io.IOExceptionpublic java.lang.String genDinAccessLimit(Din_FBcl din, PinConnect_FBcl conn, long[] condBits, java.lang.String sVariant, java.lang.String ref, int ixFBlock, java.lang.String cacc, float max, float min, boolean bOnlyOne, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
DinExpr_FBcl, this is an input of an FBexpr_FBcl,
then #genExprIn(DinExpr_FBcl, FBexpr_FBcl, String, String, Appendable, int) is called.
This regards also the K.. input of an expression.
Dout_FBcl as source for the input.
If yes, It is also a type cast and an access to a struct or array element can be contained in the input string.
This is regarded here.
Then with the doutSrc #genValueDout(Dout_FBcl, String, String, Appendable, int) is called.
Din_FBcl.getConstant()
then this constant value is used for the generated code for this input.
For that #genConstantValue(Din_FBcl, OtxWorkData, StringBuilder) is called
which adapts the given constant String to the necessary target language presentation.
for example to create "3.14f" in C/++ code as float designation if "3.14" is given.
#genValueDout(Dout_FBcl, String, int) from the connected source or taks the Din_FBcl.sConstantdin - The data input which is delivered from any output or it has a Din_FBcl.sConstantconn - null or the specific connection from din. Then conn: PinConnect_FBcl.pinDst should == din.condBits - sVariant - ref - reference to the module data for the source of din, it is often "thiz" inside the module, or a specific reference variableixFBlock - -1 or the index of a FBlock from a for loop counted till FBlock_FBcl.sizeArray(int)cacc - access to an element of an input variable, for example ".re" or "[1]"wd - out - the buffer to write the generated source codejava.io.IOExceptionpublic java.lang.String genDinAccess(Din_FBcl din, PinConnect_FBcl conn, long[] condBits, java.lang.String sVariant, java.lang.String ref, int ixFBlock, java.lang.String cacc, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
#genDinAccessLimit(Din_FBcl, PinConnect_FBcl, long[], String, String, int, String, float, float, OtxWorkData, StringBuilder)
especially used in otx script, where limitation is not a topic.java.io.IOExceptionprivate static boolean checkConnUse(PinConnect_FBcl connSrc, long mEvinMdlMask, int ixFBlock, java.lang.String sVariant)
#iterConnSrcConditional(Din_FBcl, long[])PinConnect_FBcl on a din should be used
for this source code expression.connSrc - the given connectionixFBlock - >=0 then the dinAccess is in a for-loop of indexed accesses.
Then the PinConnect_FBcl.sElemDst should contain [ix] with the same ix value then ixFBlock.
Then it is used.sVariant - if given !=null then the PinConnect_FBcl#sVariant should be the same.
The sVariant comes from arguments.public void genDinAccessConnLimit(Din_FBcl dinDst, PinConnect_FBcl connSrc, java.lang.String cacc, int ixFBlock, long[] condBits, java.lang.String ref, float max, float min, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
Din_FBcl for a given connection PinConnect_FBcldinDst - It is the same as connSrc: PinConnect_FBcl.pinDstconnSrc - the given connection between dout and dincacc - access string to theixFBlock - -1 or the index of a FBlock from a for loop counted till FBlock_FBcl.sizeArray(int)condBits - the condition bits necessary for backward selection of dout for inline expressionsref - wd - Write dataout - The output where to write the code.java.io.IOExceptionpublic java.lang.String genRefIn(PinRef_FBcl din, long[] condBits, java.lang.String ref, java.lang.String cacc, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out, int recursion)
#genValueDout(Dout_FBcl, String, int) from the connected source,
that is a PinPort_FBcl returnd by PinRef_FBcl.getConnPort()
or takes the Din_FBcl.sConstantdin - The data input which is delivered from any output or it has a Din_FBcl.sConstantcacc - access to an element of an input variable, for example ".re" or "[1]"ref - reference to the module data, it is often "thiz" inside the module, or a specific reference variablerecursion - public void genValueDout(java.lang.Iterable<FBlock_FBcl> iterFBsrc, Dout_FBcl dout, long[] condBits, java.lang.String ref, int[] ixFB, int[] ixDout, java.lang.String cacc, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out, int recursion) throws java.io.IOException
FBlock_FBcl, also an FBexpr_FBcl or a Variable after expression.
VarL_OFB_acc etc.
to access the output of variables as output of an expression.
DoutExpr_FBcl,
then #genExprOut(Dout_FBcl, FBexpr_FBcl, String, String, HashMap, Appendable, int) is called
which regards all possibilies of expressions in the graphic.
<otx: doutAccessThis ... is called, else <otx: doutAccessThis ... ,
with the following arguments:
FBlock_FBcl from dout.fb
FBlock_FBcl.typeName()
dout - The data output which delivers a valuecondBits - ref - reference to the module data, it is often "thiz" inside the module, or a specific reference variableixFB - null or possible index to the FBlock instanceixDout - null or possible index to the element of the out variable.cacc - access to an element of an input variable, for example ".re" or "[1]"wd - out - StringBuilder to write inrecursion - java.io.IOExceptionpublic void genVarExpr(Dout_FBcl doutVar, Dout_FBcl doutExpr, FBlock_FBcl fb, long[] condBits, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst sb) throws java.io.IOException
doutExpr - fb - condBits - ref - ix - cacc - wd - sb - recursion - java.io.IOExceptionprivate void genExprOut(Dout_FBcl doutExpr, java.lang.String selDinElemDst, FBexpr_FBcl fbx, long[] condBits, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out, int recursion) throws java.io.IOException
FBexpr_FBcl#getOperation() or FBexpr_FBcl.cOp what is done:
FBexpr_FBcl.cOpTextExpr The expression has an expression text given in the FBexpr shape.
This is handled by the specific #prepareExprTextGiven(Appendable, FBexpr_FBcl, String, String).
DoutExpr_FBcl (from the ofpExprOut pin style in odg diagram).
In this case param doutExpr may be null if the ofpExprOut is not connected.
This is detected by a before called #setVar_FBexpr(FBexpr_FBcl, Evout_FBcl, Evin_FBcl, Evout_FBcl, Appendable)
to define expression output variables.
In this case either for the given FBexpr_FBcl.getFunction() a specific otx script is found, then it is executed with the arguments:
String, the name in FBexpr_FBcl#getOperation() till the opened '('.
FBexpr_FBcl the expression
#callFBoper(FBexpr_FBcl, Dout_FBcl, Appendable) is executed.
#genExprTerm(StringBuilder, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, int).
The doutExpr should be given, not null.
doutExpr - It is the dout connected to either any input or to the variable which presents this output in the graphic.
It can be null if one of the FBlock_FBcl.dout is type of DoutExpr_FBcl but has no connection,
or it is null if all FBlock_FBcl.dout has variables on its outputs,
hence the type of FBlock_FBcl.dout is only Dout_FBcl, and not DoutExpr_FBcl.
This is detected by the before called #setVar_FBexpr(FBexpr_FBcl, Evout_FBcl, Evin_FBcl, Evout_FBcl, Appendable)selDinElemDst - to select DinExpr due to PinConnect_FBcl#elemDstix - if >=0 then doutExpr is an array, which is evaluated in the otx script. This is the index while evaluation.
It is used also as index for inputs with the same array properties.fbx - The expressionref - reference to the module data, it is often "thiz" inside the module, or a specific reference variablecacc - optional an access string added to any data inputout - output buffer.java.io.IOExceptionpublic void genExprSetVar(java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
java.lang.String var,
DoutExpr_FBcl doutExpr,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
OutTextPreparer.WriteDst sb)
throws java.io.IOException
#genExprOut(Dout_FBcl, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, StringBuilder, int).
selDinElemDst - fbx - var - doutExpr - condBits - ref - ix - cacc - wd - sb - java.io.IOExceptionprivate void genExprTerm(OutTextPreparer.WriteDst out,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
int recursion)
throws java.io.IOException
out - the output, usual a StringBuilderfbx - the FBexpr itselfref - reference to the module data, it is often "thiz" inside the module, or a specific reference variablecacc - additional access String to access each the same sub element (".re", ".im", "[ix]")recursion - java.io.IOExceptionprivate java.lang.String translateOperatorToTargetLang(char dType,
java.lang.String sGraphicOperator,
java.util.Map<java.lang.String,java.lang.String> idxTrl,
java.lang.String sDefault)
dType - The data type chactersGraphicOperator - given operator in graphicidxTrl - translator map. key may be dType + sGraphicOperator or only sGraphicOperatorprivate void genExprTermCmpr(OutTextPreparer.WriteDst OUT,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
java.lang.Iterable<DinExpr_FBcl> dinValues,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
int recursion)
throws java.io.IOException
java.io.IOExceptionprivate void genExprIn(DinExpr_FBcl din, FBexpr_FBcl fbx, long[] condBits, java.lang.String sOperatorLeftArg, java.lang.String sOperator, java.lang.String sUnaryOp, java.lang.String ref, int ix, java.lang.String caccArg, float max, float min, boolean bOnlyOne, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out, int recursion) throws java.io.IOException
din - One of the expression inputfbx - of this FBexprcondBits - sOperatorLeftArg - sOperator - sUnaryOp - ref - reference to the module data, it is often "thiz" inside the module, or a specific reference variableix - -1 or >=0 if the expression is used as array expression.caccArg - possible access to component of variablesmax - if not Float.NaN then use as limitation for the input.min - if not Float.NaN then use as limitation for the input.bOnlyOne - true then this is the only one input, used for input limitation.wd - out - outputrecursion - java.io.IOExceptionpublic void genDinConnAcc(Din_FBcl din, PinConnect_FBcl conn, java.lang.String cacc, int ixFBlock, long[] condBits, int[] ixFBArg, java.lang.String ref, java.lang.String sSat, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
Din_FBcl, also for DinExpr_FBcl
or also for the const value of Din_FBcl.sConstant if given.
This is the most frequently used operation called in otx to write the Din target code.din - Din which is the input pin to generate target codeconn - maybe null only if Din_FBcl.sConstant is set, else the PinConnect_FBcl to usecacc - "" or a specific access String to an element of the delivered target code from the source.
It is used for specific otx scripts, especially provide ".re" and ".im" to access a complex value source.
Note that also the 'conn' can contain a PinConnect_FBcl.sElemSrc for the same effect. But different reason.ixFBlock - -1 or the index of the FBlock in SlidescondBits - null or condition bitsixFB - ref - access in target code to data, 'thiz'sSat - "" or String to create saturation macros.wd - WriterCodegen.OtxWorkDataout - output StringBuilderjava.io.IOExceptionprivate void genExprInConn(Dout_FBcl doutSrc, DinExpr_FBcl din, FBexpr_FBcl fbx, long[] condBits, java.lang.String sOperatorLeft, java.lang.String sOperator, java.lang.String sUnaryOp, java.lang.String ref, java.lang.String caccArg, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out, int recursion) throws java.io.IOException
doutSrc - The found dout of the PinConnect_FBcl.pinSrcdin - The din of the expressionfbx - the FBexpr_FBcl, it is same is din.fbcondBits - for conditional connectionsOperatorLeft - sOperator - sUnaryOp - ref - caccArg - max - If Float.NaN then no limitation, elsewhere either overflow prevention or input limitation.min - If given (!= Float.isNaN(), then max should be given and this is the minimal value.
If max is given but min is NaN, then min is the negate max.bOnlyOne - true then this is the only one input, used for input limitation.wd - out - recursion - java.io.IOExceptionprivate void prepareExprTextGiven(OutTextPreparer.WriteDst out,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
java.lang.String sFn,
WriterCodegen.OtxWorkData wd)
throws java.io.IOException
#genValueDin(Din_FBcl, String) is called
which may invoke (depending on the input delivering FBlock) a proper otx Script.fbx - The FBexpr using its FBlock_FBcl.dinref - reference to the module data, it is often "thiz" inside the module, or a specific reference variablesFn - the given function from FBexpr_FBcl.sFnjava.io.IOExceptionpublic void stateDefinitionVars(Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic void stateDefinitionVars1(Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic void stateDefinitionHeader(Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic void stateDefinitionHeader1(Module_FBcl mdl, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst out) throws java.io.IOException
java.io.IOExceptionpublic void genCastAccess(Dinout_FBcl dinout, DType_FBcl dtDst, DType_FBcl dtSrc, boolean bCast, java.lang.String sSAT, float maxArg, float minArg, boolean bCastConstArg, WriterCodegen.OtxWorkData wd, OutTextPreparer.WriteDst wrCt, java.lang.CharSequence sExprIn) throws java.io.IOException
dinout - regarded Din_FBcl or Dout_FBcl, this is especially to set debug breaks, not used for algorithm. Can be null.dtDst - dtSrc - bCast - true then a cast is definitely set.sSAT - "" or null, then no saturation, if given, in some cases this string is used to name macros for saturation.maxArg - Given for float inputs which should be cast to integer with fractional bits.minArg - adequate maxArg. If the value is Float.NaN or kNoLimit then the limitation is defined by the number of pre-fractional bits possible.bCastConst - The sExprIn is expected as const literal.wd - Working datasb - Output Buffer to writesExprIn - The value expression which should be casted.java.io.IOExceptionpublic DinExpr_FBcl.DTypeDesignation dTypeDsgn(java.lang.String sSAT, DinExpr_FBcl xin, DinExpr_FBcl x1)
DinExpr_FBcl.dTypeDsgn(String, DinExpr_FBcl) with log entries.sSAT - xin - x1 - public java.lang.Iterable<PinConnect_FBcl> iterConnSrcConditional(Din_FBcl din, long[] condBits, java.lang.String sVariant, int ixFBlock, WriterCodegen.OtxWorkData wd)
Din_FBcl.iterConnSrcConditional(long[], long, String, int)
for code generation with argument wd instead 'mEvinMdlMask'.
The checkConnUse(PinConnect_FBcl, long, int, String) algorithm is here contained.din - Din_FBcl which's Pin_FBcl.connectSrc should be testedcondBits - null or condition bits in connection.sVariant - Designation on DoutMdl pins which should be used.ixFBlock - -1 or index for slicing or FB array access.wd - WriterCodegen.OtxWorkData.mEventOperation is used to select only proper inputsList contains the appropriate connections.private void callOtx(OutTextPreparer otx,
OutTextPreparer.WriteDst out,
OutTextPreparer.DataTextPreparer args)
throws java.io.IOException
otx - wr - args - java.io.IOExceptionpublic java.lang.String writeLogOtx(WriterCodegen.OtxWorkData wd, java.lang.String sId, java.lang.Object... args)
private void writeLogPrcEntry(OutTextPreparer.WriteDst out,
java.lang.String text,
java.lang.Object... args)
private void writeLogPrcEntry(java.lang.String sIdLog,
OutTextPreparer.WriteDst out,
java.lang.String text,
java.lang.Object... args)
logPrcBuffersb - null or the current output for generated code, same as in #writeLogPrcEnd(StringBuilder, String, Object...)
to detect what was writtentext - maybe formatted text to output, should contain the name of the operation which is executed yet,
and important argument names.args - arguments to text.private void writeLogPrcEnd(OutTextPreparer.WriteDst out,
java.lang.CharSequence textArg,
java.lang.Object... args)
#writeLogPrcEntry(StringBuilder, String, Object...).
elsewhere the stack stackLogEntries is wrong.sb - null or the current output for generated code, same as in #writeLogPrcEntry(StringBuilder, String, Object...)
to detect what was writtentext - null or an maybe formatted text to outputargs - arguments to text.private boolean testCondition(Din_FBcl din, long[] condBits)
testCondition(Dout_FBcl, long[]) for all sources.din - may have connections or notcondBits - maybe nullprivate boolean testCondition(Dout_FBcl doutSrc, long[] condBits)
Evinout_FBcl.condBits.
Calls Evinout_FBcl.getConditionBits() to check
and calls Bitfield#checkOrConditionMet(long[][], long[]) to test the condition.doutSrc - the dout where the condition should met.condBits - maybe nullpublic java.lang.StringBuilder newStringBuilder()