From 6819ca70bd8e7fb00ea900348a76cd16e6599b10 Mon Sep 17 00:00:00 2001 From: George Mamais Date: Sun, 7 Jul 2024 23:13:12 +0300 Subject: [PATCH] ICD improvements --- BackendAst/DAstACN.fs | 687 +++++++++++++++++------------- BackendAst/DAstConstruction.fs | 8 +- BackendAst/DAstUtilFunctions.fs | 30 +- FrontEndAst/AcnCreateFromAntlr.fs | 1 - FrontEndAst/DAst.fs | 40 +- 5 files changed, 431 insertions(+), 335 deletions(-) diff --git a/BackendAst/DAstACN.fs b/BackendAst/DAstACN.fs index 9175b94df..09b6d17f6 100644 --- a/BackendAst/DAstACN.fs +++ b/BackendAst/DAstACN.fs @@ -114,7 +114,7 @@ let handleSavePosition (funcBody: FuncBody) Some {bodyResult with funcBody = funcBodyStr} | None -> let funcBodyStr = savePositionStatement - Some {funcBody = funcBodyStr; errCodes =[]; localVariables = []; bValIsUnReferenced= true; bBsIsUnReferenced=false; resultExpr = None; typeEncodingKind = None} + Some {funcBody = funcBodyStr; errCodes =[]; localVariables = []; bValIsUnReferenced= true; bBsIsUnReferenced=false; resultExpr = None; typeEncodingKind = None; icdResult = None } newContent, ns1a newFuncBody @@ -150,7 +150,7 @@ let handleAlignmentForAsn1Types (r:Asn1AcnAst.AstRoot) Some {bodyResult with funcBody = funcBodyStr} | None -> let funcBodyStr = alignToNext "" alStr nAlignmentVal nestingScope.acnOffset (nestingScope.acnOuterMaxSize - nestingScope.acnOffset) (nestingScope.nestingLevel - 1I) nestingScope.nestingIx nestingScope.acnRelativeOffset codec - Some {funcBody = funcBodyStr; errCodes =[errCode]; localVariables = []; bValIsUnReferenced= true; bBsIsUnReferenced=false; resultExpr = None; typeEncodingKind = None} + Some {funcBody = funcBodyStr; errCodes =[errCode]; localVariables = []; bValIsUnReferenced= true; bBsIsUnReferenced=false; resultExpr = None; typeEncodingKind = None; icdResult=None} newContent, ns1a newFuncBody @@ -176,20 +176,26 @@ let handleAlignmentForAcnTypes (r:Asn1AcnAst.AstRoot) Some {bodyResult with funcBody = funcBodyStr} | None -> let funcBodyStr = alignToNext "" alStr nAlignmentVal nestingScope.acnOffset (nestingScope.acnOuterMaxSize - nestingScope.acnOffset) (nestingScope.nestingLevel - 1I) nestingScope.nestingIx nestingScope.acnRelativeOffset codec - Some {funcBody = funcBodyStr; errCodes =[]; localVariables = []; bValIsUnReferenced= true; bBsIsUnReferenced=false; resultExpr = None; typeEncodingKind = None} + Some {funcBody = funcBodyStr; errCodes =[]; localVariables = []; bValIsUnReferenced= true; bBsIsUnReferenced=false; resultExpr = None; typeEncodingKind = None; icdResult= None} newContent newFuncBody -type IcdArgAux = { - canBeEmbedded : bool - baseAsn1Kind : string - rowsFunc : string->string->string list ->IcdRow list - commentsForTas : string list - scope : string - name : string option -} -let createIcdAux (r:Asn1AcnAst.AstRoot) (id:ReferenceToType) (icdAux:IcdArgAux) hash (td:FE_TypeDefinition) (typeDefinition:TypeDefinitionOrReference) nMinBytesInACN nMaxBytesInACN= - let typeAss = +let md5 = System.Security.Cryptography.MD5.Create() + +let createIcdTas (r:Asn1AcnAst.AstRoot) (id:ReferenceToType) (icdAux:IcdArgAux) (td:FE_TypeDefinition) (typeDefinition:TypeDefinitionOrReference) nMinBytesInACN nMaxBytesInACN= + let calcIcdTypeAssHash (t1:IcdTypeAss) = + let rec calcIcdTypeAssHash_aux (t1:IcdTypeAss) = + let rws = + t1.rows |> + Seq.map(fun r -> sprintf "%A%A%A%A%A%A%A%A%A%A" r.idxOffset r.fieldName r.comments r.sPresent r.sType r.sConstraint r.minLengthInBits r.maxLengthInBits r.sUnits r.rowType) |> + Seq.StrJoin "" + let aa = sprintf"%A%A%A%A%A%A%A%A%A" t1.acnLink t1.asn1Link t1.name t1.kind t1.comments t1.minLengthInBytes t1.maxLengthInBytes (rws) ("") + let bytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes aa) + Convert.ToHexString bytes + calcIcdTypeAssHash_aux t1 + + let icdRows, compositeChildren = icdAux.rowsFunc "" "" []; + let icdTas = { IcdTypeAss.linkId = id tasInfo = id.tasInfo @@ -200,6 +206,8 @@ let createIcdAux (r:Asn1AcnAst.AstRoot) (id:ReferenceToType) (icdAux:IcdArgAux) | Some n -> n | None -> td.asn1Name kind = icdAux.baseAsn1Kind; + canBeEmbedded = icdAux.canBeEmbedded + createRowsFunc = icdAux.rowsFunc comments = let asn1Comments = match id.tasInfo with @@ -212,26 +220,15 @@ let createIcdAux (r:Asn1AcnAst.AstRoot) (id:ReferenceToType) (icdAux:IcdArgAux) | None -> [] | Some ts -> ts.Comments |> Seq.toList asn1Comments@icdAux.commentsForTas - rows = icdAux.rowsFunc "" "" []; + rows = icdRows + compositeChildren = compositeChildren minLengthInBytes = nMinBytesInACN; maxLengthInBytes = nMaxBytesInACN - hash = hash + hash = "" // will be calculated later } - {IcdAux.canBeEmbedded = icdAux.canBeEmbedded; createRowsFunc= icdAux.rowsFunc; typeAss=typeAss} - -let md5 = System.Security.Cryptography.MD5.Create() + let icdHash = calcIcdTypeAssHash icdTas + {icdTas with hash = icdHash} -let calcIcdTypeAssHash (codec:CommonTypes.Codec) bPrint (t1:IcdTypeAss) = - let rec calcIcdTypeAssHash_aux (t1:IcdTypeAss) = - let rws = - t1.rows |> - Seq.map(fun r -> sprintf "%A%A%A%A%A%A%A%A%A%A" r.idxOffset r.fieldName r.comments r.sPresent r.sType r.sConstraint r.minLengthInBits r.maxLengthInBits r.sUnits r.rowType) |> - Seq.StrJoin "" - let aa = sprintf"%A%A%A%A%A%A%A%A%A" t1.acnLink t1.asn1Link t1.name t1.kind t1.comments t1.minLengthInBytes t1.maxLengthInBytes (rws) ("") - let bytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes aa) - Convert.ToHexString bytes - - calcIcdTypeAssHash_aux t1 let adaptArgument = DAstUPer.adaptArgument let adaptArgumentValue = DAstUPer.adaptArgumentValue @@ -246,7 +243,6 @@ let private createAcnFunction (r: Asn1AcnAst.AstRoot) (isValidFunc: IsValidFunction option) (funcBody: FuncBody) isTestVaseValid - (icdAux: IcdArgAux) (soSparkAnnotations: string option) (funcDefAnnots: string list) (us: State) = @@ -284,20 +280,29 @@ let private createAcnFunction (r: Asn1AcnAst.AstRoot) let sStar = lm.lg.getStar p.arg let isValidFuncName = match isValidFunc with None -> None | Some f -> f.funcName let sInitialExp = "" - let func, funcDef,ns2 = + let func, funcDef,icdResult, ns2 = match funcNameAndtasInfo with - | None -> None, None, ns + | None -> + let precondAnnots = lm.lg.generatePrecond ACN t + let postcondAnnots = lm.lg.generatePostcond ACN funcNameBase p t codec + let content, ns1a = funcBody ns errCode [] (NestingScope.init t.acnMaxSizeInBits t.uperMaxSizeInBits) p + let icdResult = + match content with + | None -> None + | Some bodyResult -> bodyResult.icdResult + + None, None, icdResult, ns1a | Some funcName -> let precondAnnots = lm.lg.generatePrecond ACN t let postcondAnnots = lm.lg.generatePostcond ACN funcNameBase p t codec let content, ns1a = funcBody ns errCode [] (NestingScope.init t.acnMaxSizeInBits t.uperMaxSizeInBits) p - let bodyResult_funcBody, errCodes, bodyResult_localVariables, bBsIsUnreferenced, bVarNameIsUnreferenced = + let bodyResult_funcBody, errCodes, bodyResult_localVariables, bBsIsUnreferenced, bVarNameIsUnreferenced, icdResult = match content with | None -> let emptyStatement = lm.lg.emptyStatement - emptyStatement, [], [], true, isValidFuncName.IsNone + emptyStatement, [], [], true, isValidFuncName.IsNone, None | Some bodyResult -> - bodyResult.funcBody, bodyResult.errCodes, bodyResult.localVariables, bodyResult.bBsIsUnReferenced, bodyResult.bValIsUnReferenced + bodyResult.funcBody, bodyResult.errCodes, bodyResult.localVariables, bodyResult.bBsIsUnReferenced, bodyResult.bValIsUnReferenced, bodyResult.icdResult let handleAcnParameter (p:AcnGenericTypes.AcnParameter) = let intType = lm.typeDef.Declare_Integer () @@ -324,21 +329,18 @@ let private createAcnFunction (r: Asn1AcnAst.AstRoot) let errCodStr = errCodes |> List.map(fun x -> EmitTypeAssignment_def_err_code x.errCodeName (BigInteger x.errCodeValue) x.comment) |> List.distinct let funcDef = Some(EmitTypeAssignment_primitive_def varName sStar funcName (typeDefinition.longTypedefName2 lm.lg.hasModules) errCodStr (t.acnMaxSizeInBits = 0I) nMaxBytesInACN ( t.acnMaxSizeInBits) prms soSparkAnnotations codec) - func, funcDef,ns1a + func, funcDef,icdResult, ns1a let icdAux, ns3 = - match codec with - | Encode -> - let tr = createIcdAux r t.id icdAux "" td typeDefinition nMinBytesInACN nMaxBytesInACN - let icdHash = calcIcdTypeAssHash codec true tr.typeAss - let trTypeAssWithHash = {tr.typeAss with hash = icdHash} - let tr = {tr with typeAss = trTypeAssWithHash} + match icdResult with + | Some icdAux -> + let icdTas = createIcdTas r t.id icdAux td typeDefinition nMinBytesInACN nMaxBytesInACN let ns3 = - match ns2.icdHashes.TryFind icdHash with - | None -> {ns2 with icdHashes = ns2.icdHashes.Add(icdHash, [tr.typeAss])} - | Some exList -> {ns2 with icdHashes = ns2.icdHashes.Add(icdHash, tr.typeAss::exList)} - Some tr, ns3 - | Decode -> None, ns2 + match ns2.icdHashes.TryFind icdTas.hash with + | None -> {ns2 with icdHashes = ns2.icdHashes.Add(icdTas.hash, [icdTas])} + | Some exList -> {ns2 with icdHashes = ns2.icdHashes.Add(icdTas.hash, icdTas::exList)} + Some icdTas, ns3 + | None -> None, ns2 let ret = { AcnFunction.funcName = funcNameAndtasInfo @@ -347,7 +349,7 @@ let private createAcnFunction (r: Asn1AcnAst.AstRoot) funcBody = (fun us acnArgs p -> funcBody us errCode acnArgs p ) funcBodyAsSeqComp = funcBodyAsSeqComp isTestVaseValid = isTestVaseValid - icd = icdAux + icdTas = icdAux } ret, ns3 @@ -360,6 +362,10 @@ let private createAcnIntegerFunctionInternal (r:Asn1AcnAst.AstRoot) (intClass:Asn1AcnAst.IntegerClass) (acnEncodingClass: IntEncodingClass) (uperfuncBody : ErrorCode -> NestingScope -> CallerScope -> (UPERFuncBodyResult option)) + (sAsn1Constraints:string option) + acnMinSizeInBits + acnMaxSizeInBits + unitsOfMeasure (soMF:string option, soMFM:string option): AcnIntegerFuncBody = let PositiveInteger_ConstSize_8 = lm.acn.PositiveInteger_ConstSize_8 let PositiveInteger_ConstSize_big_endian_16 = lm.acn.PositiveInteger_ConstSize_big_endian_16 @@ -479,7 +485,11 @@ let private createAcnIntegerFunctionInternal (r:Asn1AcnAst.AstRoot) match funcBodyContent with | None -> None | Some (funcBodyContent,errCodes, bValIsUnReferenced, bBsIsUnReferenced, typeEncodingKind ) -> - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= bValIsUnReferenced; bBsIsUnReferenced=bBsIsUnReferenced; resultExpr = resultExpr; typeEncodingKind = typeEncodingKind}) + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType "INTEGER"); sConstraint=sAsn1Constraints; minLengthInBits = acnMinSizeInBits ;maxLengthInBits=acnMaxSizeInBits;sUnits=unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = "INTEGER"; rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= bValIsUnReferenced; bBsIsUnReferenced=bBsIsUnReferenced; resultExpr = resultExpr; typeEncodingKind = typeEncodingKind; icdResult=Some icd}) funcBody let getMappingFunctionModule (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (soMapFuncName:string option) = @@ -508,11 +518,21 @@ let createAcnIntegerFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:C | None -> getMappingFunctionModule r lm soMapFunc, soMapFunc | Some soMapFunMod -> Some soMapFunMod.Value, soMapFunc | None -> None, None - let funcBody = createAcnIntegerFunctionInternal r lm codec t.uperRange t.intClass t.acnEncodingClass uperFuncBody (soMapFunc, soMapFunMod) + + let sAsn1Constraints = None + let unitsOfMeasure = None + + let funcBody = createAcnIntegerFunctionInternal r lm codec t.uperRange t.intClass t.acnEncodingClass uperFuncBody sAsn1Constraints t.acnMinSizeInBits t.acnMaxSizeInBits unitsOfMeasure (soMapFunc, soMapFunMod) (funcBody errCode), ns let createIntegerFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.Integer) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (uperFunc: UPerFunction) (us:State) = + let sAsn1Constraints = + let sTmpCons = o.AllCons |> List.map (DastValidate2.printRangeConAsAsn1 (fun z -> z.ToString())) |> Seq.StrJoin "" + match sTmpCons.Trim() with + | "" -> None + | _ -> Some sTmpCons + let soMapFunMod, soMapFunc = match o.acnProperties.mappingFunction with | Some (MappingFunction (soMapFunMod, mapFncName)) -> @@ -521,19 +541,11 @@ let createIntegerFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Comm | None -> getMappingFunctionModule r lm soMapFunc, soMapFunc | Some soMapFunMod -> Some soMapFunMod.Value, soMapFunc | None -> None, None - let funcBody = createAcnIntegerFunctionInternal r lm codec o.uperRange o.intClass o.acnEncodingClass uperFunc.funcBody_e (soMapFunc, soMapFunMod) + let funcBody = createAcnIntegerFunctionInternal r lm codec o.uperRange o.intClass o.acnEncodingClass uperFunc.funcBody_e sAsn1Constraints t.acnMinSizeInBits t.acnMaxSizeInBits t.unitsOfMeasure (soMapFunc, soMapFunMod) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let sAsn1Constraints = - let sTmpCons = o.AllCons |> List.map (DastValidate2.printRangeConAsAsn1 (fun z -> z.ToString())) |> Seq.StrJoin "" - match sTmpCons.Trim() with - | "" -> None - | _ -> Some sTmpCons - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=sAsn1Constraints; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us let createAcnChildIcdFunction (ch:AcnChild) = let icd fieldName comments = @@ -547,7 +559,21 @@ let createAcnChildIcdFunction (ch:AcnChild) = {IcdRow.fieldName = fieldName; comments = comments; sPresent="always";sType=(IcdPlainType sType); sConstraint=None; minLengthInBits = minSize ;maxLengthInBits=maxSize;sUnits=None; rowType = IcdRowType.FieldRow; idxOffset = None} icd -let createEnumCommon (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (typeId : ReferenceToType) (o:Asn1AcnAst.Enumerated) (defOrRef:TypeDefinitionOrReference ) (typeDefinitionName:string) = +let enumComment stgFileName (o:Asn1AcnAst.Enumerated) = + let EmitItem (n:Asn1AcnAst.NamedItem) = + let comment = n.Comments |> Seq.StrJoin "\n" + match comment.Trim() with + | "" -> icd_uper.EmitEnumItem stgFileName n.Name.Value n.definitionValue + | _ -> icd_uper.EmitEnumItemWithComment stgFileName n.Name.Value n.definitionValue comment + let itemsHtml = + o.items |> + List.filter(fun z -> + let v = z.Name.Value + Asn1Fold.isValidValueGeneric o.AllCons (=) v ) |> + List.map EmitItem + icd_uper.EmitEnumInternalContents stgFileName itemsHtml + +let createEnumCommon (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (typeId : ReferenceToType) (o:Asn1AcnAst.Enumerated) (defOrRef:TypeDefinitionOrReference ) (typeDefinitionName:string) (icdStgFileName:string) sAsn1Constraints acnMinSizeInBits acnMaxSizeInBits unitsOfMeasure = let EnumeratedEncValues = lm.acn.EnumeratedEncValues let Enumerated_item = lm.acn.Enumerated_item let IntFullyConstraintPos = lm.uper.IntFullyConstraintPos @@ -585,7 +611,7 @@ let createEnumCommon (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTyp | None -> None let funcBody = IntFullyConstraintPos (castPp word_size_in_bits) min max nbits sSsuffix errCode.errCodeName rangeAssert codec Some({UPERFuncBodyResult.funcBody = funcBody; errCodes = [errCode]; localVariables= []; bValIsUnReferenced=false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (Asn1IntegerEncodingType (Some (FullyConstrainedPositive (min, max))))}) - createAcnIntegerFunctionInternal r lm codec (Concrete (min,max)) intTypeClass o.acnEncodingClass uperInt (None, None) + createAcnIntegerFunctionInternal r lm codec (Concrete (min,max)) intTypeClass o.acnEncodingClass uperInt sAsn1Constraints acnMinSizeInBits acnMaxSizeInBits unitsOfMeasure (None, None) let funcBodyContent = match intFuncBody errCode acnArgs nestingScope pVal with | None -> None @@ -610,41 +636,28 @@ let createEnumCommon (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTyp match funcBodyContent with | None -> None | Some (funcBodyContent, resultExpr, errCodes, localVariables, typeEncodingKind) -> - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind}) + let icdFnc fieldName sPresent (comments:string list) = + let newComments = comments@[enumComment icdStgFileName o] + [{IcdRow.fieldName = fieldName; comments = newComments; sPresent=sPresent;sType=(IcdPlainType "ENUMERATED"); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = "ENUMERATED"; rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None;} + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind; icdResult=Some icd}) funcBody -let enumComment stgFileName (o:Asn1AcnAst.Enumerated) = - let EmitItem (n:Asn1AcnAst.NamedItem) = - let comment = n.Comments |> Seq.StrJoin "\n" - match comment.Trim() with - | "" -> icd_uper.EmitEnumItem stgFileName n.Name.Value n.definitionValue - | _ -> icd_uper.EmitEnumItemWithComment stgFileName n.Name.Value n.definitionValue comment - let itemsHtml = - o.items |> - List.filter(fun z -> - let v = z.Name.Value - Asn1Fold.isValidValueGeneric o.AllCons (=) v ) |> - List.map EmitItem - icd_uper.EmitEnumInternalContents stgFileName itemsHtml let createEnumeratedFunction (r:Asn1AcnAst.AstRoot) (icdStgFileName:string) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.Enumerated) (defOrRef:TypeDefinitionOrReference) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (uperFunc: UPerFunction) (us:State) = let typeDefinitionName = defOrRef.longTypedefName2 lm.lg.hasModules //getTypeDefinitionName t.id.tasInfo typeDefinition - let funcBody = createEnumCommon r lm codec t.id o defOrRef typeDefinitionName + let funcBody = createEnumCommon r lm codec t.id o defOrRef typeDefinitionName icdStgFileName None t.acnMinSizeInBits t.acnMaxSizeInBits t.unitsOfMeasure let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent (comments:string list) = - let newComments = comments@[enumComment icdStgFileName o] - [{IcdRow.fieldName = fieldName; comments = newComments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None;} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us -let createAcnEnumeratedFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (typeId : ReferenceToType) (t:Asn1AcnAst.AcnReferenceToEnumerated) (defOrRef:TypeDefinitionOrReference) (us:State) = +let createAcnEnumeratedFunction (r:Asn1AcnAst.AstRoot) (icdStgFileName:string) (lm:LanguageMacros) (codec:CommonTypes.Codec) (typeId : ReferenceToType) (t:Asn1AcnAst.AcnReferenceToEnumerated) (defOrRef:TypeDefinitionOrReference) (us:State) = let errCodeName = ToC ("ERR_ACN" + (codec.suffix.ToUpper()) + "_" + ((typeId.AcnAbsPath |> Seq.skip 1 |> Seq.StrJoin("-")).Replace("#","elm"))) let errCode, ns = getNextValidErrorCode us errCodeName None let td = lm.lg.getTypeDefinition (t.getType r).FT_TypeDefinition let typeDefinitionName = td.typeName - let funcBody = createEnumCommon r lm codec typeId t.enumerated defOrRef typeDefinitionName + let funcBody = createEnumCommon r lm codec typeId t.enumerated defOrRef typeDefinitionName icdStgFileName None t.enumerated.acnMinSizeInBits t.enumerated.acnMaxSizeInBits None (funcBody errCode), ns let createRealFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.Real) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (uperFunc: UPerFunction) (us:State) = @@ -673,16 +686,18 @@ let createRealFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonT | Real_uPER -> uperFunc.funcBody_e errCode nestingScope p |> Option.map(fun x -> x.funcBody, x.errCodes, x.typeEncodingKind) match funcBodyContent with | None -> None - | Some (funcBodyContent,errCodes, typeEncodingKind) -> Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind}) + | Some (funcBodyContent,errCodes, typeEncodingKind) -> + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind; icdResult=Some icd}) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} let annots = match ST.lang with | Scala -> ["extern"] | _ -> [] - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations annots us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations annots us let createObjectIdentifierFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.ObjectIdentifier) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (uperFunc: UPerFunction) (us:State) = @@ -691,12 +706,13 @@ let createObjectIdentifierFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (c uperFunc.funcBody_e errCode nestingScope p |> Option.map(fun x -> x.funcBody, x.errCodes, x.resultExpr, x.typeEncodingKind) match funcBodyContent with | None -> None - | Some (funcBodyContent,errCodes, resultExpr, typeEncodingKind) -> Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind}) + | Some (funcBodyContent,errCodes, resultExpr, typeEncodingKind) -> + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind; icdResult = Some icd}) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us let createTimeTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.TimeType) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (uperFunc: UPerFunction) (us:State) = @@ -705,12 +721,13 @@ let createTimeTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Com uperFunc.funcBody_e errCode nestingScope p |> Option.map(fun x -> x.funcBody, x.errCodes, x.resultExpr, x.typeEncodingKind) match funcBodyContent with | None -> None - | Some (funcBodyContent,errCodes, resultExpr, typeEncodingKind) -> Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind}) + | Some (funcBodyContent,errCodes, resultExpr, typeEncodingKind) -> + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None;} + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind; icdResult = Some icd}) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None;} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us let nestChildItems (lm:LanguageMacros) (codec:CommonTypes.Codec) children = @@ -726,7 +743,12 @@ let createAcnBooleanFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:C let Boolean = lm.uper.Boolean let funcBodyContent = Boolean pp errCode.errCodeName codec - Some {AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnBooleanEncodingType None)} + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType "BOOLEAN"); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = "BOOLEAN"; rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + + Some {AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnBooleanEncodingType None); icdResult = Some icd} (funcBody errCode), ns let createBooleanFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.Boolean) (typeDefinition:TypeDefinitionOrReference) (baseTypeUperFunc : AcnFunction option) (isValidFunc: IsValidFunction option) (us:State) = @@ -765,13 +787,13 @@ let createBooleanFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Comm let arrFalseValueAsByteArray = bitStringValueToByteArray fvPatten let nSize = trPattern.Value.Length BooleanTrueFalse pvalue ptr (BigInteger nSize) arrTrueValueAsByteArray arrFalseValueAsByteArray arrTrueBits arrFalseBits errCode.errCodeName codec, resultExpr + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - {AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnBooleanEncodingType o.acnProperties.encodingPattern)} + {AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnBooleanEncodingType o.acnProperties.encodingPattern); icdResult = Some icd} let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> Some (funcBody e acnArgs nestingScope p), us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> Some (funcBody e acnArgs nestingScope p), us) (fun atc -> true) soSparkAnnotations [] us @@ -798,7 +820,10 @@ let createAcnNullTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec: let arrsBits = bitStringPattern.ToCharArray() |> Seq.mapi(fun i x -> ((i+1).ToString()) + "=>" + if x='0' then "0" else "1") |> Seq.toList arrsBits,arrBytes,(BigInteger bitStringPattern.Length) let ret = nullType pp arrBytes nBitsSize arrsBits errCode.errCodeName o.acnProperties.savePosition codec - Some ({AcnFuncBodyResult.funcBody = ret; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnNullEncodingType (Some encPattern))}) + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType "NULL"); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = "NULL"; rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + Some ({AcnFuncBodyResult.funcBody = ret; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnNullEncodingType (Some encPattern)); icdResult = Some icd}) (funcBody errCode), ns let createNullTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.NullType) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (us:State) = @@ -811,7 +836,7 @@ let createNullTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Com match codec, lm.lg.decodingKind with | Decode, Copy -> // Copy-decoding backend expect all values to be declared even if they are "dummies" - Some ({AcnFuncBodyResult.funcBody = lm.acn.Null_declare pp; errCodes = []; localVariables = []; bValIsUnReferenced=false; bBsIsUnReferenced=false; resultExpr=Some pp; typeEncodingKind = Some (AcnNullEncodingType None)}) + Some ({AcnFuncBodyResult.funcBody = lm.acn.Null_declare pp; errCodes = []; localVariables = []; bValIsUnReferenced=false; bBsIsUnReferenced=false; resultExpr=Some pp; typeEncodingKind = Some (AcnNullEncodingType None); icdResult=None}) | _ -> None | Some encPattern -> let arrsBits, arrBytes, nBitsSize = @@ -826,12 +851,13 @@ let createNullTypeFunction (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (codec:Com let arrsBits = bitStringPattern.ToCharArray() |> Seq.mapi(fun i x -> ((i+1).ToString()) + "=>" + if x='0' then "0" else "1") |> Seq.toList arrsBits,arrBytes,(BigInteger bitStringPattern.Length) let ret = nullType pp arrBytes nBitsSize arrsBits errCode.errCodeName o.acnProperties.savePosition codec - Some ({AcnFuncBodyResult.funcBody = ret; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= lm.lg.acn.null_valIsUnReferenced; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnNullEncodingType (Some encPattern))}) + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + Some ({AcnFuncBodyResult.funcBody = ret; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= lm.lg.acn.null_valIsUnReferenced; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnNullEncodingType (Some encPattern)); icdResult = Some icd}) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us let getExternalField0 (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) asn1TypeIdWithDependency func1 = @@ -941,12 +967,12 @@ let createStringFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFiel match funcBodyContent with | None -> None, ns | Some (funcBodyContent,errCodes, localVars) -> - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVars; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnStringEncodingType o.acnEncodingClass)}), ns + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVars; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnStringEncodingType o.acnEncodingClass); icdResult = Some icd} ), ns let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p us) (fun atc -> true) soSparkAnnotations [] us let createAcnStringFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (lm:LanguageMacros) (codec:CommonTypes.Codec) (typeId : ReferenceToType) (t:Asn1AcnAst.AcnReferenceToIA5String) (us:State) = @@ -1064,7 +1090,10 @@ let createAcnStringFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF match funcBodyContent with | None -> None | Some (funcBodyContent,errCodes, lvs) -> - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCode::errCodes |> List.distinct ; localVariables = lvs; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnStringEncodingType o.acnEncodingClass)}) + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType "IA5String"); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = "IA5String"; rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCode::errCodes |> List.distinct ; localVariables = lvs; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnStringEncodingType o.acnEncodingClass); icdResult = Some icd}) (funcBody errCode), ns @@ -1129,12 +1158,13 @@ let createOctetStringFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInserte match funcBodyContent with | None -> None | Some (funcBodyContent,errCodes, localVariables) -> - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnOctetStringEncodingType o.acnEncodingClass)}) + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (AcnOctetStringEncodingType o.acnEncodingClass); icdResult = Some icd}) let soSparkAnnotations = Some (sparkAnnotations lm td codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us let createBitStringFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.BitString) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (uperFunc: UPerFunction) (us:State) = let nAlignSize = 0I; let bitString_FixSize = lm.uper.bitString_FixSize @@ -1177,12 +1207,13 @@ let createBitStringFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF match funcBodyContent with | None -> None | Some (funcBodyContent,errCodes, localVariables) -> - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (AcnBitStringEncodingType o.acnEncodingClass)}) + let icdFnc fieldName sPresent comments = + [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], [] + let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (AcnBitStringEncodingType o.acnEncodingClass); icdResult = Some icd}) let soSparkAnnotations = Some(sparkAnnotations lm td codec) - let icdFnc fieldName sPresent comments = - [{IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=(IcdPlainType (getASN1Name t)); sConstraint=None; minLengthInBits = o.acnMinSizeInBits ;maxLengthInBits=o.acnMaxSizeInBits;sUnits=t.unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}] - let icd = {IcdArgAux.canBeEmbedded = true; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.SequenceOf) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (child:Asn1Type) (us:State) = let oct_sqf_null_terminated = lm.acn.oct_sqf_null_terminated @@ -1204,6 +1235,40 @@ let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInserted let nAlignSize = 0I; let nIntItemMaxSize = child.acnMaxSizeInBits let td = typeDefinition.longTypedefName2 lm.lg.hasModules + + let icdFnc fieldName sPresent comments = + let lengthRow, terminationPattern = + match o.acnEncodingClass with + | SZ_EC_LENGTH_EMBEDDED _ -> + let nSizeInBits = GetNumberOfBitsForNonNegativeInteger ( (o.maxSize.acn - o.minSize.acn)) + [{IcdRow.fieldName = "Length"; comments = [$"The number of items"]; sPresent="always";sType=IcdPlainType "INTEGER"; sConstraint=None; minLengthInBits = nSizeInBits ;maxLengthInBits=nSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = Some 1}], [] + | SZ_EC_FIXED_SIZE + | SZ_EC_ExternalField _ -> [], [] + | SZ_EC_TerminationPattern bitPattern -> + let nSizeInBits = bitPattern.Value.Length.AsBigInt + [], [{IcdRow.fieldName = "Length"; comments = [$"Termination pattern {bitPattern.Value}"]; sPresent="always";sType=IcdPlainType "INTEGER"; sConstraint=None; minLengthInBits = nSizeInBits ;maxLengthInBits=nSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = Some (int (o.maxSize.acn+1I))}] + match child.icdTas with + | Some childIcdTas -> + match childIcdTas.canBeEmbedded with + | true -> + let chRows = (childIcdTas.createRowsFunc "Item #1" "always" [] |> fst) |> List.map(fun r -> {r with idxOffset = Some (lengthRow.Length + 1)}) + let lastChRows = chRows |> List.map(fun r -> {r with fieldName = $"Item #{o.maxSize.acn}"; idxOffset = Some ((int o.maxSize.acn)+lengthRow.Length)}) + lengthRow@chRows@[THREE_DOTS]@lastChRows@terminationPattern, [] + | false -> + let sType = TypeHash childIcdTas.hash + let a1 = {IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=sType; sConstraint=None; minLengthInBits = t.acnMinSizeInBits; maxLengthInBits=t.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = Some (lengthRow.Length + 1)} + let a2 = {a1 with idxOffset = Some ((int o.maxSize.acn)+lengthRow.Length)} + [a1;THREE_DOTS;a2], [childIcdTas] + | None -> lengthRow@terminationPattern, [] + let sExtraComment = + match o.acnEncodingClass with + | Asn1AcnAst.SZ_EC_FIXED_SIZE -> $"Length is fixed to {o.maxSize.acn} elements (no length determinant is needed)." + | Asn1AcnAst.SZ_EC_LENGTH_EMBEDDED _ -> if o.maxSize.acn <2I then "The array contains a single element." else "" + | Asn1AcnAst.SZ_EC_ExternalField relPath -> $"Length is determined by the external field: %s{relPath.AsString}" + | Asn1AcnAst.SZ_EC_TerminationPattern bitPattern -> $"Length is determined by the stop marker '%s{bitPattern.Value}'" + let icd = {IcdArgAux.canBeEmbedded = false; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[sExtraComment]; scope="type"; name= None} + + let funcBody (us:State) (errCode:ErrorCode) (acnArgs: (AcnGenericTypes.RelativePath*AcnGenericTypes.AcnParameter) list) (nestingScope: NestingScope) (p:CallerScope) = let pp, resultExpr = joinedOrAsIdentifier lm codec p // `childInitExpr` is used to initialize the array of elements in which we will write their decoded values @@ -1261,7 +1326,7 @@ let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInserted | true -> None | false -> let funcBody = varSize pp access td i "" o.minSize.acn o.maxSize.acn nSizeInBits child.acnMinSizeInBits nIntItemMaxSize 0I childInitExpr errCode.errCodeName absOffset remBits lvl ix offset introSnap preSerde postSerde postInc invariant codec - Some ({AcnFuncBodyResult.funcBody = funcBody; errCodes = [errCode]; localVariables = lv@nStringLength; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=None}) + Some ({AcnFuncBodyResult.funcBody = funcBody; errCodes = [errCode]; localVariables = lv@nStringLength; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=None; icdResult = Some icd}) | Some internalItem -> let childErrCodes = internalItem.errCodes @@ -1270,7 +1335,7 @@ let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInserted | true -> fixedSize pp td i internalItem.funcBody o.minSize.acn child.acnMinSizeInBits nIntItemMaxSize 0I childInitExpr codec, nStringLength | false -> varSize pp access td i internalItem.funcBody o.minSize.acn o.maxSize.acn nSizeInBits child.acnMinSizeInBits nIntItemMaxSize 0I childInitExpr errCode.errCodeName absOffset remBits lvl ix offset introSnap preSerde postSerde postInc invariant codec, nStringLength let typeEncodingKind = internalItem.typeEncodingKind |> Option.map (fun tpe -> TypeEncodingKind.SequenceOfEncodingType (tpe, o.acnEncodingClass)) - Some ({AcnFuncBodyResult.funcBody = ret; errCodes = errCode::childErrCodes; localVariables = lv@(internalItem.localVariables@localVariables); bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind}) + Some ({AcnFuncBodyResult.funcBody = ret; errCodes = errCode::childErrCodes; localVariables = lv@(internalItem.localVariables@localVariables); bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind; icdResult = Some icd}) | SZ_EC_ExternalField _ -> match internalItem with @@ -1298,7 +1363,7 @@ let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInserted | true -> oct_sqf_external_field_fix_size td pp access i internalItemBody (if o.minSize.acn=0I then None else Some o.minSize.acn) o.maxSize.acn extField unsigned nAlignSize errCode.errCodeName o.child.acnMinSizeInBits o.child.acnMaxSizeInBits childInitExpr introSnap preSerde postSerde postInc invariant codec | false -> external_field td pp access i internalItemBody (if o.minSize.acn=0I then None else Some o.minSize.acn) o.maxSize.acn extField unsigned nAlignSize errCode.errCodeName o.child.acnMinSizeInBits o.child.acnMaxSizeInBits childInitExpr introSnap preSerde postSerde postInc invariant codec let typeEncodingKind = internalItem.typeEncodingKind |> Option.map (fun tpe -> TypeEncodingKind.SequenceOfEncodingType (tpe, o.acnEncodingClass)) - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCode::childErrCodes; localVariables = lv@localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind}) + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCode::childErrCodes; localVariables = lv@localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=typeEncodingKind; icdResult = Some icd}) | SZ_EC_TerminationPattern bitPattern -> match internalItem with | None -> None @@ -1325,45 +1390,11 @@ let createSequenceOfFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInserted | _ -> [] let typeEncodingKind = internalItem.typeEncodingKind |> Option.map (fun tpe -> TypeEncodingKind.SequenceOfEncodingType (tpe, o.acnEncodingClass)) - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCode::childErrCodes; localVariables = lv2@lv@localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=None; typeEncodingKind=typeEncodingKind}) + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCode::childErrCodes; localVariables = lv2@lv@localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=None; typeEncodingKind=typeEncodingKind; icdResult = Some icd}) ret,ns let soSparkAnnotations = Some(sparkAnnotations lm td codec) - let icdFnc fieldName sPresent comments = - let x = child.icdFunction - - let lengthRow, terminationPattern = - match o.acnEncodingClass with - | SZ_EC_LENGTH_EMBEDDED _ -> - let nSizeInBits = GetNumberOfBitsForNonNegativeInteger ( (o.maxSize.acn - o.minSize.acn)) - [{IcdRow.fieldName = "Length"; comments = [$"The number of items"]; sPresent="always";sType=IcdPlainType "INTEGER"; sConstraint=None; minLengthInBits = nSizeInBits ;maxLengthInBits=nSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = Some 1}], [] - | SZ_EC_FIXED_SIZE - | SZ_EC_ExternalField _ -> [], [] - | SZ_EC_TerminationPattern bitPattern -> - let nSizeInBits = bitPattern.Value.Length.AsBigInt - [], [{IcdRow.fieldName = "Length"; comments = [$"Termination pattern {bitPattern.Value}"]; sPresent="always";sType=IcdPlainType "INTEGER"; sConstraint=None; minLengthInBits = nSizeInBits ;maxLengthInBits=nSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = Some (int (o.maxSize.acn+1I))}] - match x.canBeEmbedded with - | true -> - let chRows = (x.createRowsFunc "Item #1" "always" []) |> List.map(fun r -> {r with idxOffset = Some (lengthRow.Length + 1)}) - let lastChRows = chRows |> List.map(fun r -> {r with fieldName = $"Item #{o.maxSize.acn}"; idxOffset = Some ((int o.maxSize.acn)+lengthRow.Length)}) - lengthRow@chRows@[THREE_DOTS]@lastChRows@terminationPattern - | false -> - let sType = TypeHash x.typeAss.hash - let a1 = {IcdRow.fieldName = fieldName; comments = comments; sPresent=sPresent;sType=sType; sConstraint=None; minLengthInBits = t.acnMinSizeInBits; maxLengthInBits=t.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = Some (lengthRow.Length + 1)} - let a2 = {a1 with idxOffset = Some ((int o.maxSize.acn)+lengthRow.Length)} - [a1;THREE_DOTS;a2] - - let sExtraComment = - match o.acnEncodingClass with - | Asn1AcnAst.SZ_EC_FIXED_SIZE -> $"Length is fixed to {o.maxSize.acn} elements (no length determinant is needed)." - | Asn1AcnAst.SZ_EC_LENGTH_EMBEDDED _ -> if o.maxSize.acn <2I then "The array contains a single element." else "" - | Asn1AcnAst.SZ_EC_ExternalField relPath -> $"Length is determined by the external field: %s{relPath.AsString}" - | Asn1AcnAst.SZ_EC_TerminationPattern bitPattern -> $"Length is determined by the stop marker '%s{bitPattern.Value}'" - - - - let icd = {IcdArgAux.canBeEmbedded = false; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[sExtraComment]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc funcBody (fun atc -> true) icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc funcBody (fun atc -> true) soSparkAnnotations [] us let initExpr (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (m:Asn1AcnAst.Asn1Module) (t: Asn1AcnAst.AcnInsertedType): string = match t with @@ -1396,8 +1427,8 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn | Some prmUpdateStatement -> let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = prmUpdateStatement.updateAcnChildFnc child nestingScope vTarget pSrcRoot - - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=prmUpdateStatement.errCodes; testCaseFnc = prmUpdateStatement.testCaseFnc; localVariables=[]}), ns1 + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=prmUpdateStatement.errCodes; testCaseFnc = prmUpdateStatement.testCaseFnc; localVariables=[]}), ns1 | AcnDepSizeDeterminant (minSize, maxSize, szAcnProp) -> let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = let v = lm.lg.getValue vTarget.arg @@ -1417,7 +1448,8 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn let testCaseFnc (atc:AutomaticTestCase) : TestCaseValue option = atc.testCaseTypeIDsMap.TryFind d.asn1Type - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=[]; testCaseFnc=testCaseFnc; localVariables=[]}), us + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=[]; testCaseFnc=testCaseFnc; localVariables=[]}), us | AcnDepSizeDeterminant_bit_oct_str_contain o -> let baseTypeDefinitionName = match lm.lg.hasModules with @@ -1458,8 +1490,8 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn let testCaseFnc (atc:AutomaticTestCase) : TestCaseValue option = atc.testCaseTypeIDsMap.TryFind d.asn1Type let localVars = lm.lg.acn.getAcnDepSizeDeterminantLocVars sReqBytesForUperEncoding - - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=errCodes0; testCaseFnc=testCaseFnc; localVariables= localVariables0@localVars}), ns + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=errCodes0; testCaseFnc=testCaseFnc; localVariables= localVariables0@localVars}), ns | AcnDepIA5StringSizeDeterminant (minSize, maxSize, szAcnProp) -> let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = @@ -1471,7 +1503,8 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn | _ -> checkAccessPath checkPath updateStatement v (initExpr r lm m child.Type) let testCaseFnc (atc:AutomaticTestCase) : TestCaseValue option = atc.testCaseTypeIDsMap.TryFind d.asn1Type - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=[]; testCaseFnc=testCaseFnc; localVariables=[]}), us + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=[]; testCaseFnc=testCaseFnc; localVariables=[]}), us | AcnDepPresenceBool -> let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = let v = lm.lg.getValue vTarget.arg @@ -1487,8 +1520,12 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn match atc.testCaseTypeIDsMap.TryFind(d.asn1Type) with | Some _ -> Some TcvComponentPresent | None -> Some TcvComponentAbsent - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=[]; testCaseFnc=testCaseFnc; localVariables=[]}), us + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=[]; testCaseFnc=testCaseFnc; localVariables=[]}), us | AcnDepPresence (relPath, chc) -> + let icdComments = + let aaa = sprintf "Used as a presence determinant for %s " (chc.typeDef[C].asn1Name) + [aaa] let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = let v = lm.lg.getValue vTarget.arg let choicePath, checkPath = getAccessFromScopeNodeList d.asn1Type false lm pSrcRoot @@ -1521,7 +1558,7 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn match updateValues with | v1::[] -> Some v1 | _ -> None - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=[] ; testCaseFnc=testCaseFnc; localVariables=[]}), us + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=[] ; testCaseFnc=testCaseFnc; localVariables=[]}), us | AcnDepPresenceStr (relPath, chc, str) -> let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = let v = lm.lg.getValue vTarget.arg @@ -1554,7 +1591,8 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn match updateValues with | v1::[] -> Some v1 | _ -> None - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=[]; testCaseFnc = testCaseFnc; localVariables=[]}), us + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=[]; testCaseFnc = testCaseFnc; localVariables=[]}), us | AcnDepChoiceDeterminant (enm, chc, isOptional) -> let updateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = let v = lm.lg.getValue vTarget.arg @@ -1580,7 +1618,8 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn | _ -> checkAccessPath checkPath updateStatement2 v (initExpr r lm m child.Type) let testCaseFnc (atc:AutomaticTestCase) : TestCaseValue option = atc.testCaseTypeIDsMap.TryFind d.asn1Type - Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; errCodes=[] ; testCaseFnc=testCaseFnc; localVariables=[]}), us + let icdComments = [] + Some ({AcnChildUpdateResult.updateAcnChildFnc = updateFunc; icdComments=icdComments; errCodes=[] ; testCaseFnc=testCaseFnc; localVariables=[]}), us and getUpdateFunctionUsedInEncoding (r: Asn1AcnAst.AstRoot) (deps: Asn1AcnAst.AcnInsertedFieldDependencies) (lm: LanguageMacros) (m: Asn1AcnAst.Asn1Module) (acnChildOrAcnParameterId) (us:State) : (AcnChildUpdateResult option*State)= let multiAcnUpdate = lm.acn.MultiAcnUpdate @@ -1616,6 +1655,7 @@ and getUpdateFunctionUsedInEncoding (r: Asn1AcnAst.AstRoot) (deps: Asn1AcnAst.Ac updates@[f1], nns) ([],us) let restErrCodes = localUpdateFuns |> List.choose id |> List.collect(fun z -> z.errCodes) let restLocalVariables = localUpdateFuns |> List.choose id |> List.collect(fun z -> z.localVariables) + let icdComments = localUpdateFuns |> List.choose id |> List.collect(fun z -> z.icdComments) let multiUpdateFunc (child: AcnChild) (nestingScope: NestingScope) (vTarget : CallerScope) (pSrcRoot : CallerScope) = let v = lm.lg.getValue vTarget.arg let arrsLocalUpdateStatements = @@ -1670,7 +1710,7 @@ and getUpdateFunctionUsedInEncoding (r: Asn1AcnAst.AstRoot) (deps: Asn1AcnAst.Ac | true -> None | false -> Some u1 - let ret = Some(({AcnChildUpdateResult.updateAcnChildFnc = multiUpdateFunc; errCodes=errCode::restErrCodes ; testCaseFnc = testCaseFnc; localVariables = restLocalVariables})) + let ret = Some(({AcnChildUpdateResult.updateAcnChildFnc = multiUpdateFunc; icdComments=icdComments; errCodes=errCode::restErrCodes ; testCaseFnc = testCaseFnc; localVariables = restLocalVariables})) ret, ns type private AcnSequenceStatement = @@ -1691,6 +1731,7 @@ type private SequenceChildStmt = { body: string option lvs: LocalVariable list errCodes: ErrorCode list + icdComments : string list } type private SequenceChildState = { us: State @@ -1704,6 +1745,7 @@ type private SequenceChildResult = { existVar: string option props: SequenceChildProps typeKindEncoding: TypeEncodingKind option + icdComments : string list } with member this.joinedBodies (lm:LanguageMacros) (codec:CommonTypes.Codec): string option = this.stmts |> List.choose (fun s -> s.body) |> nestChildItems lm codec @@ -1794,6 +1836,59 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi let acnChildren = children |> List.choose(fun x -> match x with AcnChild z -> Some z | Asn1Child _ -> None) let asn1Children = children |> List.choose(fun x -> match x with Asn1Child z -> Some z | AcnChild _ -> None) + let sPresenceBitIndexMap = + asn1Children |> + List.filter(fun c -> match c.Optionality with Some(Optional _) -> true | _ -> false) |> + List.mapi (fun i c -> (c.Name.Value, i)) |> + Map.ofList + let uperPresenceMask = + match sPresenceBitIndexMap.IsEmpty with + | true -> [] + | false -> + [{IcdRow.fieldName = "Presence Mask"; comments = [$"Presence bit mask"]; sPresent="always";sType=IcdPlainType "bit mask"; sConstraint=None; minLengthInBits = sPresenceBitIndexMap.Count.AsBigInt ;maxLengthInBits=sPresenceBitIndexMap.Count.AsBigInt;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}] + let icdFnc fieldName sPresent comments = + let chRows0, compositeChildren0 = + children |> + List.map(fun c -> + match c with + | Asn1Child c -> + let optionality = + match c.Optionality with + | None -> "always" + | Some(AlwaysAbsent ) -> "never" + | Some(AlwaysPresent) -> "always" + | Some(Optional opt) -> + match opt.acnPresentWhen with + | None -> $"when bit %d{sPresenceBitIndexMap[c.Name.Value]} is set in the uPER bit mask" + | Some(PresenceWhenBool relPath) -> $"when %s{relPath.AsString} is true" + | Some(PresenceWhenBoolExpression acnExp) -> + let dummyScope = {CallerScope.modName = ""; arg = Selection.valueEmptyPath "dummy"} + let retExp = acnExpressionToBackendExpression o dummyScope acnExp + $"when %s{retExp}" + let comments = c.Comments |> Seq.toList + let childIcdTas = c.Type.icdTas + //let isRef = match c.Type.Kind with ReferenceType _ -> true | _ -> false + match c.Type.icdTas with + | Some childIcdTas -> + match childIcdTas.canBeEmbedded with + | true -> + let chRows, _ = childIcdTas.createRowsFunc c.Name.Value optionality comments + chRows, [] + | false -> + let sType = TypeHash childIcdTas.hash + [{IcdRow.fieldName = c.Name.Value; comments = comments; sPresent=optionality;sType=sType; sConstraint=None; minLengthInBits = c.Type.acnMinSizeInBits; maxLengthInBits=c.Type.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}], [childIcdTas] + | None -> + [], [] + | AcnChild c -> + let icdRow = createAcnChildIcdFunction c c.Name.Value (c.Comments |> Seq.toList) + [icdRow], []) |> + List.unzip + let chRows = chRows0 |> List.collect id + let compositeChildren = compositeChildren0 |> List.collect id + uperPresenceMask@chRows |> List.mapi(fun i r -> {r with idxOffset = Some (i+1)}), compositeChildren + let icd = {IcdArgAux.canBeEmbedded = false; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} + + let funcBody (us:State) (errCode:ErrorCode) (acnArgs: (AcnGenericTypes.RelativePath*AcnGenericTypes.AcnParameter) list) (nestingScope: NestingScope) (p:CallerScope) = let acnlocalVariablesCh = acnChildren |> @@ -1930,7 +2025,7 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi let body = sequence_presence_optChild_pres_acn_expression (p.arg.joined lm.lg) (lm.lg.getAccess p.arg) childName retExp existVar errCode.errCodeName codec Some body, lv, [errCode], existVar, ns1a | _ -> None, [], [], None, ns1 - {acnStatement=AcnPresenceStatement; body=acnPresenceStatement; lvs=lvs; errCodes=errCodes}, existVar, ns1b + {acnStatement=AcnPresenceStatement; body=acnPresenceStatement; lvs=lvs; errCodes=errCodes; icdComments=[]}, existVar, ns1b let childEncDecStatement, childResultExpr, childTpeKind, ns3 = match childContentResult with @@ -1943,7 +2038,7 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi match child.Optionality with | Some Asn1AcnAst.AlwaysPresent -> let childBody = Some(sequence_always_present_child (p.arg.joined lm.lg) (lm.lg.getAccess p.arg) childName None childResultExpr soSaveBitStrmPosStatement codec) - Some {acnStatement=Asn1ChildEncodeStatement; body=childBody; lvs=[]; errCodes=[]}, childResultExpr, None, ns2 + Some {acnStatement=Asn1ChildEncodeStatement; body=childBody; lvs=[]; errCodes=[];icdComments=[]}, childResultExpr, None, ns2 | _ -> None, childResultExpr, None, ns2 | Some childContent -> let childBody, chLocalVars = @@ -1960,14 +2055,16 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi | Some v -> let defInit= child.Type.initFunction.initByAsn1Value childP (mapValue v).kind Some(sequence_default_child pp (lm.lg.getAccess p.arg) childName childContent.funcBody defInit existVar childContent.resultExpr childTypeDef soSaveBitStrmPosStatement codec), childContent.localVariables - Some {acnStatement=Asn1ChildEncodeStatement; body=childBody; lvs=chLocalVars; errCodes=childContent.errCodes}, childContent.resultExpr, childContent.typeEncodingKind, ns2 + let fff = childContent.localVariables + Some {acnStatement=Asn1ChildEncodeStatement; body=childBody; lvs=chLocalVars; errCodes=childContent.errCodes;icdComments=[]}, childContent.resultExpr, childContent.typeEncodingKind, ns2 let stmts = [present_when_statements]@(childEncDecStatement |> Option.toList) + let icdComments = stmts |> List.collect(fun z -> z.icdComments) let tpeKind = if child.Optionality.IsSome then childTpeKind |> Option.map OptionEncodingType else childTpeKind let typeInfo = {uperMaxSizeBits=child.uperMaxSizeInBits; acnMaxSizeBits=child.acnMaxSizeInBits; typeKind=tpeKind} let props = {sel=Some (childSel.joined lm.lg); uperMaxOffset=s.uperAccBits; acnMaxOffset=s.acnAccBits; typeInfo=typeInfo} - let res = {stmts=stmts; resultExpr=childResultExpr; existVar=existVar; props=props; typeKindEncoding=tpeKind} + let res = {stmts=stmts; resultExpr=childResultExpr; existVar=existVar; props=props; typeKindEncoding=tpeKind;icdComments=icdComments} let newAcc = {us=ns3; childIx=s.childIx + 1I; uperAccBits=s.uperAccBits + child.uperMaxSizeInBits; acnAccBits=s.acnAccBits + child.acnMaxSizeInBits} res, newAcc | AcnChild acnChild -> @@ -1978,11 +2075,11 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi match codec with | Encode -> let pRoot : CallerScope = lm.lg.getParamType t codec //???? - let updateStatement, lvs, errCodes = + let updateStatement, lvs, errCodes, icdComments = match acnChild.funcUpdateStatement with - | Some funcUpdateStatement -> Some (funcUpdateStatement.updateAcnChildFnc acnChild childNestingScope childP pRoot), funcUpdateStatement.localVariables, funcUpdateStatement.errCodes - | None -> None, [], [] - Some {acnStatement=AcnChildUpdateStatement; body=updateStatement; lvs=lvs; errCodes=errCodes}, us + | Some funcUpdateStatement -> Some (funcUpdateStatement.updateAcnChildFnc acnChild childNestingScope childP pRoot), funcUpdateStatement.localVariables, funcUpdateStatement.errCodes, funcUpdateStatement.icdComments + | None -> None, [], [], [] + Some {acnStatement=AcnChildUpdateStatement; body=updateStatement; lvs=lvs; errCodes=errCodes; icdComments=icdComments}, us | Decode -> None, us //acn child encode/decode @@ -1997,20 +2094,21 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi match acnChild.Type with | Asn1AcnAst.AcnNullType _ -> let childBody = Some (sequence_mandatory_child acnChild.c_name childContent.funcBody soSaveBitStrmPosStatement codec) - Some {acnStatement=AcnChildEncodeStatement; body=childBody; lvs=childContent.localVariables; errCodes=childContent.errCodes}, childContent.typeEncodingKind, ns1 + Some {acnStatement=AcnChildEncodeStatement; body=childBody; lvs=childContent.localVariables; errCodes=childContent.errCodes;icdComments=[]}, childContent.typeEncodingKind, ns1 | _ -> let _errCodeName = ToC ("ERR_ACN" + (codec.suffix.ToUpper()) + "_" + ((acnChild.id.AcnAbsPath |> Seq.skip 1 |> Seq.StrJoin("-")).Replace("#","elm")) + "_UNINITIALIZED") let errCode, ns1a = getNextValidErrorCode ns1 _errCodeName None let childBody = Some (sequence_acn_child acnChild.c_name childContent.funcBody errCode.errCodeName soSaveBitStrmPosStatement codec) - Some {acnStatement=AcnChildEncodeStatement; body=childBody; lvs=childContent.localVariables; errCodes=errCode::childContent.errCodes}, childContent.typeEncodingKind, ns1a + Some {acnStatement=AcnChildEncodeStatement; body=childBody; lvs=childContent.localVariables; errCodes=errCode::childContent.errCodes;icdComments=[]}, childContent.typeEncodingKind, ns1a | Decode -> let childBody = Some (sequence_mandatory_child acnChild.c_name childContent.funcBody soSaveBitStrmPosStatement codec) - Some {acnStatement=AcnChildEncodeStatement; body=childBody; lvs=childContent.localVariables; errCodes=childContent.errCodes}, childContent.typeEncodingKind, ns1 + Some {acnStatement=AcnChildEncodeStatement; body=childBody; lvs=childContent.localVariables; errCodes=childContent.errCodes;icdComments=[]}, childContent.typeEncodingKind, ns1 let stmts = (updateStatement |> Option.toList)@(childEncDecStatement |> Option.toList) + let icdComments = stmts |> List.collect(fun z -> z.icdComments) // Note: uperMaxSizeBits and uperAccBits here do not make sense since we are in ACN let typeInfo = {uperMaxSizeBits=0I; acnMaxSizeBits=child.acnMaxSizeInBits; typeKind=childTpeKind} let props = {sel=Some (childP.arg.joined lm.lg); uperMaxOffset=s.uperAccBits; acnMaxOffset=s.acnAccBits; typeInfo=typeInfo} - let res = {stmts=stmts; resultExpr=None; existVar=None; props=props; typeKindEncoding=childTpeKind} + let res = {stmts=stmts; resultExpr=None; existVar=None; props=props; typeKindEncoding=childTpeKind; icdComments=icdComments} let newAcc = {us=ns2; childIx=s.childIx + 1I; uperAccBits=s.uperAccBits; acnAccBits=s.acnAccBits + acnChild.Type.acnMaxSizeInBits} res, newAcc // find acn inserted fields, which are not NULL types and which have no dependency. @@ -2055,7 +2153,7 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi let childrenResultExpr = childrenStatements00 |> List.choose(fun res -> res.resultExpr) let childrenErrCodes = childrenStatements0 |> List.collect(fun s -> s.errCodes) let childrenTypeKindEncoding = childrenStatements00 |> List.map (fun s -> s.typeKindEncoding) - + let resultExpr, seqBuild= match codec, lm.lg.decodingKind with | Decode, Copy -> @@ -2083,9 +2181,9 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi match lm.lg.decodeEmptySeq (p.arg.joined lm.lg) with | None -> None, ns | Some decodeEmptySeq -> - Some ({AcnFuncBodyResult.funcBody = decodeEmptySeq; errCodes = errCode::childrenErrCodes; localVariables = localVariables@childrenLocalvars; bValIsUnReferenced= false; bBsIsUnReferenced=true; resultExpr=Some decodeEmptySeq; typeEncodingKind=Some (SequenceEncodingType childrenTypeKindEncoding)}), ns + Some ({AcnFuncBodyResult.funcBody = decodeEmptySeq; errCodes = errCode::childrenErrCodes; localVariables = localVariables@childrenLocalvars; bValIsUnReferenced= false; bBsIsUnReferenced=true; resultExpr=Some decodeEmptySeq; typeEncodingKind=Some (SequenceEncodingType childrenTypeKindEncoding); icdResult = Some icd}), ns | Some ret -> - Some ({AcnFuncBodyResult.funcBody = ret; errCodes = errCode::childrenErrCodes; localVariables = localVariables@childrenLocalvars; bValIsUnReferenced= false; bBsIsUnReferenced=(o.acnMaxSizeInBits = 0I); resultExpr=resultExpr; typeEncodingKind=Some (SequenceEncodingType childrenTypeKindEncoding)}), ns + Some ({AcnFuncBodyResult.funcBody = ret; errCodes = errCode::childrenErrCodes; localVariables = localVariables@childrenLocalvars; bValIsUnReferenced= false; bBsIsUnReferenced=(o.acnMaxSizeInBits = 0I); resultExpr=resultExpr; typeEncodingKind=Some (SequenceEncodingType childrenTypeKindEncoding); icdResult = Some icd}), ns | errChild::_ -> let determinantUsage = @@ -2113,53 +2211,8 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi | Some funcUpdateStatement -> (funcUpdateStatement.testCaseFnc atc).IsSome | None -> false) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let sPresenceBitIndexMap = - asn1Children |> - List.filter(fun c -> match c.Optionality with Some(Optional _) -> true | _ -> false) |> - List.mapi (fun i c -> (c.Name.Value, i)) |> - Map.ofList - let uperPresenceMask = - match sPresenceBitIndexMap.IsEmpty with - | true -> [] - | false -> - [{IcdRow.fieldName = "Presence Mask"; comments = [$"Presence bit mask"]; sPresent="always";sType=IcdPlainType "bit mask"; sConstraint=None; minLengthInBits = sPresenceBitIndexMap.Count.AsBigInt ;maxLengthInBits=sPresenceBitIndexMap.Count.AsBigInt;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}] - let icdFnc fieldName sPresent comments = - let chRows = - children |> - List.collect(fun c -> - match c with - | Asn1Child c -> - let optionality = - match c.Optionality with - | None -> "always" - | Some(AlwaysAbsent ) -> "never" - | Some(AlwaysPresent) -> "always" - | Some(Optional opt) -> - match opt.acnPresentWhen with - | None -> $"when bit %d{sPresenceBitIndexMap[c.Name.Value]} is set in the uPER bit mask" - | Some(PresenceWhenBool relPath) -> $"when %s{relPath.AsString} is true" - | Some(PresenceWhenBoolExpression acnExp) -> - let dummyScope = {CallerScope.modName = ""; arg = Selection.valueEmptyPath "dummy"} - let retExp = acnExpressionToBackendExpression o dummyScope acnExp - $"when %s{retExp}" - let comments = c.Comments |> Seq.toList - let x = c.Type.icdFunction - //let isRef = match c.Type.Kind with ReferenceType _ -> true | _ -> false - match x.canBeEmbedded with - | true -> - x.createRowsFunc c.Name.Value optionality comments - | false -> - let icdHash = x.typeAss.hash - let sType = TypeHash x.typeAss.hash - [{IcdRow.fieldName = c.Name.Value; comments = comments; sPresent=optionality;sType=sType; sConstraint=None; minLengthInBits = c.Type.acnMinSizeInBits; maxLengthInBits=c.Type.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}] - | AcnChild c -> - let icdFunc = createAcnChildIcdFunction c - let comments = c.Comments |> Seq.toList - [icdFunc c.Name.Value comments]) - uperPresenceMask@chRows |> List.mapi(fun i r -> {r with idxOffset = Some (i+1)}) - let icd = {IcdArgAux.canBeEmbedded = false; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=[]; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc funcBody isTestVaseValid icd soSparkAnnotations [] us + createAcnFunction r lm codec t typeDefinition isValidFunc funcBody isTestVaseValid soSparkAnnotations [] us @@ -2208,6 +2261,63 @@ let createChoiceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFiel | CEC_uper, CommonTypes.Decode -> [(Asn1SIntLocalVariable (sChoiceIndexName, None))] let typeDefinitionName = defOrRef.longTypedefName2 lm.lg.hasModules//getTypeDefinitionName t.id.tasInfo typeDefinition + let uperPresenceMask, extraComment = + match acnChildren.Length with + | 1 -> [], [] + | _ -> + match ec with + | CEC_uper -> + let indexSize = GetChoiceUperDeterminantLengthInBits acnChildren.Length.AsBigInt + [{IcdRow.fieldName = "ChoiceIndex"; comments = [$"Special field used by ACN to indicate which choice alternative is present."]; sPresent="always" ;sType=IcdPlainType "unsigned int"; sConstraint=None; minLengthInBits = indexSize; maxLengthInBits=indexSize;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}], [] + | CEC_enum (enm,d) -> [],[] + | CEC_presWhen -> + let extFields = acnChildren |> List.collect(fun c -> c.acnPresentWhenConditions) |> List.map(fun x -> "'" + x.relativePath.AsString + "'") |> Seq.distinct |> Seq.StrJoin "," + let plural = if extFields.Contains "," then "s" else "" + [],[$"Active alternative is determined by ACN using the field{plural}: %s{extFields}"] + + let icdFnc fieldName sPresent comments = + let chRows0, compositeChildren0 = + acnChildren |> + List.mapi(fun idx c -> + let childComments = c.Comments |> Seq.toList + let optionality = + match c.Optionality with + | Some(ChoiceAlwaysAbsent ) -> "never" + | Some(ChoiceAlwaysPresent) + | None -> + match ec with + | CEC_uper -> + match acnChildren.Length <= 1 with + | true -> "always" + | false -> sprintf "ChoiceIndex = %d" idx + | CEC_enum (enm,d) -> + let refToStr id = + match id with + | ReferenceToType sn -> sn |> List.rev |> List.head |> (fun x -> x.AsString) + sprintf "%s = %s" (refToStr d.id) c.Name.Value + | CEC_presWhen -> + let getPresenceSingle (pc:AcnGenericTypes.AcnPresentWhenConditionChoiceChild) = + match pc with + | AcnGenericTypes.PresenceInt (rp, intLoc) -> sprintf "%s=%A" rp.AsString intLoc.Value + | AcnGenericTypes.PresenceStr (rp, strLoc) -> sprintf "%s=%A" rp.AsString strLoc.Value + c.acnPresentWhenConditions |> Seq.map getPresenceSingle |> Seq.StrJoin " AND " + match c.chType.icdTas with + | Some childIcdTas -> + match childIcdTas.canBeEmbedded with + | true -> childIcdTas.createRowsFunc c.Name.Value optionality childComments + | false -> + let sType = TypeHash childIcdTas.hash + let icdRow = [{IcdRow.fieldName = c.Name.Value; comments = comments; sPresent=optionality;sType=sType; sConstraint=None; minLengthInBits = c.chType.acnMinSizeInBits; maxLengthInBits=c.chType.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}] + let compChild = [childIcdTas] + icdRow, compChild + |None -> [],[]) |> List.unzip + let chRows = chRows0 |> List.collect id + let compositeChildren = compositeChildren0 |> List.collect id + let icdRows = uperPresenceMask@chRows |> List.mapi(fun i r -> {r with idxOffset = Some (i+1)}) + icdRows, compositeChildren + + let icd = {IcdArgAux.canBeEmbedded = false; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=extraComment; scope="type"; name= None} + let funcBody (us:State) (errCode:ErrorCode) (acnArgs: (AcnGenericTypes.RelativePath*AcnGenericTypes.AcnParameter) list) (nestingScope: NestingScope) (p:CallerScope) = let td = (lm.lg.getChoiceTypeDefinition o.typeDef).longTypedefName2 lm.lg.hasModules (ToC p.modName) @@ -2319,68 +2429,18 @@ let createChoiceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFiel let extField = getExternalField r deps t.id choice_Enum pp access childrenStatements extField errCode.errCodeName codec, resultExpr | CEC_presWhen -> choice_preWhen pp access childrenStatements errCode.errCodeName codec, resultExpr - Some ({AcnFuncBodyResult.funcBody = choiceContent; errCodes = errCode::childrenErrCodes; localVariables = localVariables@childrenLocalvars; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (ChoiceEncodingType childrenTypeKindEncoding)}), ns + Some ({AcnFuncBodyResult.funcBody = choiceContent; errCodes = errCode::childrenErrCodes; localVariables = localVariables@childrenLocalvars; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind = Some (ChoiceEncodingType childrenTypeKindEncoding); icdResult = Some icd}), ns let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let uperPresenceMask, extraComment = - match acnChildren.Length with - | 1 -> [], [] - | _ -> - match ec with - | CEC_uper -> - let indexSize = GetChoiceUperDeterminantLengthInBits acnChildren.Length.AsBigInt - [{IcdRow.fieldName = "ChoiceIndex"; comments = [$"Special field used by ACN to indicate which choice alternative is present."]; sPresent="always" ;sType=IcdPlainType "unsigned int"; sConstraint=None; minLengthInBits = indexSize; maxLengthInBits=indexSize;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}], [] - | CEC_enum (enm,d) -> [],[] - | CEC_presWhen -> - let extFields = acnChildren |> List.collect(fun c -> c.acnPresentWhenConditions) |> List.map(fun x -> "'" + x.relativePath.AsString + "'") |> Seq.distinct |> Seq.StrJoin "," - let plural = if extFields.Contains "," then "s" else "" - [],[$"Active alternative is determined by ACN using the field{plural}: %s{extFields}"] - - let icdFnc fieldName sPresent comments = - let chRows = - acnChildren |> - List.mapi(fun idx c -> - let childComments = c.Comments |> Seq.toList - let optionality = - match c.Optionality with - | Some(ChoiceAlwaysAbsent ) -> "never" - | Some(ChoiceAlwaysPresent) - | None -> - match ec with - | CEC_uper -> - match acnChildren.Length <= 1 with - | true -> "always" - | false -> sprintf "ChoiceIndex = %d" idx - | CEC_enum (enm,d) -> - let refToStr id = - match id with - | ReferenceToType sn -> sn |> List.rev |> List.head |> (fun x -> x.AsString) - sprintf "%s = %s" (refToStr d.id) c.Name.Value - | CEC_presWhen -> - let getPresenceSingle (pc:AcnGenericTypes.AcnPresentWhenConditionChoiceChild) = - match pc with - | AcnGenericTypes.PresenceInt (rp, intLoc) -> sprintf "%s=%A" rp.AsString intLoc.Value - | AcnGenericTypes.PresenceStr (rp, strLoc) -> sprintf "%s=%A" rp.AsString strLoc.Value - c.acnPresentWhenConditions |> Seq.map getPresenceSingle |> Seq.StrJoin " AND " - let x = c.chType.icdFunction - match x.canBeEmbedded with - | true -> x.createRowsFunc c.Name.Value optionality childComments - | false -> - let sType = TypeHash x.typeAss.hash - [{IcdRow.fieldName = c.Name.Value; comments = comments; sPresent=optionality;sType=sType; sConstraint=None; minLengthInBits = c.chType.acnMinSizeInBits; maxLengthInBits=c.chType.acnMaxSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}]) |> - List.collect id - uperPresenceMask@chRows |> List.mapi(fun i r -> {r with idxOffset = Some (i+1)}) - - let icd = {IcdArgAux.canBeEmbedded = false; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=extraComment; scope="type"; name= None} - createAcnFunction r lm codec t typeDefinition isValidFunc funcBody (fun atc -> true) icd soSparkAnnotations [] us, ec + createAcnFunction r lm codec t typeDefinition isValidFunc funcBody (fun atc -> true) soSparkAnnotations [] us, ec let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (lm:LanguageMacros) (codec:CommonTypes.Codec) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.ReferenceType) (typeDefinition:TypeDefinitionOrReference) (isValidFunc: IsValidFunction option) (baseType:Asn1Type) (us:State) = let baseTypeDefinitionName, baseFncName = getBaseFuncName lm typeDefinition o t.id "_ACN" codec - let x = baseType.icdFunction + let td = lm.lg.getTypeDefinition t.FT_TypeDefinition let getNewSType (r:IcdRow) = let newType = @@ -2397,12 +2457,17 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF match o.hasExtraConstrainsOrChildrenOrAcnArgs with | false -> None | true -> Some t.id.AsString.RDD + match baseType.icdTas with + | Some baseTypeIcdTas -> + let icdFnc fieldName sPresent comments = + let rows, comp = baseTypeIcdTas.createRowsFunc fieldName sPresent comments + rows |> List.map(fun r -> getNewSType r), comp - let icdFnc fieldName sPresent comments = - let rows = x.createRowsFunc fieldName sPresent comments - rows |> List.map(fun r -> getNewSType r) - - icdFnc, x.typeAss.comments, name + icdFnc, baseTypeIcdTas.comments, name + | None -> + let icdFnc fieldName sPresent comments = [],[] + icdFnc, [], name + | Some encOptions -> let lengthDetRow = match encOptions.acnEncodingClass with @@ -2411,13 +2476,23 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF [ {IcdRow.fieldName = "Length"; comments = [$"The number of {sCommentUnit} used in the encoding"]; sPresent="always";sType=IcdPlainType "INTEGER"; sConstraint=None; minLengthInBits = nSizeInBits ;maxLengthInBits=nSizeInBits;sUnits=None; rowType = IcdRowType.LengthDeterminantRow; idxOffset = None}] | _ -> [] - let icdFnc fieldName sPresent comments = - let rows = x.createRowsFunc fieldName sPresent comments |> List.map(fun r -> getNewSType r) - lengthDetRow@rows |> List.mapi(fun i r -> {r with idxOffset = Some (i+1)}) - icdFnc, ("OCTET STING CONTAINING BY"::x.typeAss.comments), Some (t.id.AsString.RDD + "_OCT_STR" ) + match baseType.icdTas with + | Some baseTypeIcdTas -> + let icdFnc fieldName sPresent comments = + let rows0, compChildren = baseTypeIcdTas.createRowsFunc fieldName sPresent comments + let rows = rows0 |> List.map getNewSType + lengthDetRow@rows |> List.mapi(fun i r -> {r with idxOffset = Some (i+1)}), compChildren + icdFnc, ("OCTET STING CONTAINING BY"::baseTypeIcdTas.comments), Some (t.id.AsString.RDD + "_OCT_STR" ) + | None -> + let icdFnc fieldName sPresent comments = [],[] + icdFnc, [], None - let icd = {IcdArgAux.canBeEmbedded = x.canBeEmbedded; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=extraComment; scope="REFTYPE"; name=name} + let icd = + match baseType.icdTas with + | Some baseTypeIcdTas -> + Some {IcdArgAux.canBeEmbedded = baseTypeIcdTas.canBeEmbedded; baseAsn1Kind = (getASN1Name t); rowsFunc = icdFnc; commentsForTas=extraComment; scope="REFTYPE"; name=name} + | None -> None match o.encodingOptions with | None -> @@ -2448,11 +2523,11 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF toc, Some toc | _ -> str, None let funcBodyContent = callBaseTypeFunc lm pp baseFncName codec - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (ReferenceEncodingType baseTypeDefinitionName)}), us + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = [errCode]; localVariables = []; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (ReferenceEncodingType baseTypeDefinitionName); icdResult = icd}), us let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let a, ns = createAcnFunction r lm codec t typeDefinition isValidFunc funcBody (fun atc -> true) icd soSparkAnnotations [] us + let a, ns = createAcnFunction r lm codec t typeDefinition isValidFunc funcBody (fun atc -> true) soSparkAnnotations [] us Some a, ns | Some encOptions -> @@ -2518,8 +2593,8 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF let fncBody = bit_string_containing_func pp baseFncName sReqBytesForUperEncoding sReqBitForUperEncoding nBits encOptions.minSize.acn encOptions.maxSize.acn false codec fncBody, [errCode],[] | SZ_EC_TerminationPattern nullVal , _ -> raise(SemanticError (loc, "Invalid type for parameter4")) - Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (ReferenceEncodingType baseTypeDefinitionName)}) + Some ({AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false; bBsIsUnReferenced=false; resultExpr=resultExpr; typeEncodingKind=Some (ReferenceEncodingType baseTypeDefinitionName); icdResult = icd}) let soSparkAnnotations = Some(sparkAnnotations lm (typeDefinition.longTypedefName2 lm.lg.hasModules) codec) - let a,b = createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) icd soSparkAnnotations [] us + let a,b = createAcnFunction r lm codec t typeDefinition isValidFunc (fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us) (fun atc -> true) soSparkAnnotations [] us Some a, b diff --git a/BackendAst/DAstConstruction.fs b/BackendAst/DAstConstruction.fs index 21b28997b..5e003c813 100644 --- a/BackendAst/DAstConstruction.fs +++ b/BackendAst/DAstConstruction.fs @@ -34,7 +34,7 @@ let private mapAcnParameter (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF //funcUpdateStatement00 = funcUpdateStatement }, ns1 -let private createAcnChild (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (lm:LanguageMacros) (m:Asn1AcnAst.Asn1Module) (ch:Asn1AcnAst.AcnChild) (us:State) = +let private createAcnChild (r:Asn1AcnAst.AstRoot) (icdStgFileName:string) (deps:Asn1AcnAst.AcnInsertedFieldDependencies) (lm:LanguageMacros) (m:Asn1AcnAst.Asn1Module) (ch:Asn1AcnAst.AcnChild) (us:State) = let acnAlignment = match ch.Type with @@ -49,7 +49,7 @@ let private createAcnChild (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi | Asn1AcnAst.AcnInteger a -> DAstACN.createAcnIntegerFunction r lm Codec.Encode ch.id a us | Asn1AcnAst.AcnBoolean a -> DAstACN.createAcnBooleanFunction r lm Codec.Encode ch.id a us | Asn1AcnAst.AcnNullType a -> DAstACN.createAcnNullTypeFunction r lm Codec.Encode ch.id a us - | Asn1AcnAst.AcnReferenceToEnumerated a -> DAstACN.createAcnEnumeratedFunction r lm Codec.Encode ch.id a (defOrRef r m a) us + | Asn1AcnAst.AcnReferenceToEnumerated a -> DAstACN.createAcnEnumeratedFunction r icdStgFileName lm Codec.Encode ch.id a (defOrRef r m a) us | Asn1AcnAst.AcnReferenceToIA5String a -> DAstACN.createAcnStringFunction r deps lm Codec.Encode ch.id a us let funcBodyDecode, ns2 = @@ -57,7 +57,7 @@ let private createAcnChild (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi | Asn1AcnAst.AcnInteger a -> DAstACN.createAcnIntegerFunction r lm Codec.Decode ch.id a ns1 | Asn1AcnAst.AcnBoolean a -> DAstACN.createAcnBooleanFunction r lm Codec.Decode ch.id a ns1 | Asn1AcnAst.AcnNullType a -> DAstACN.createAcnNullTypeFunction r lm Codec.Decode ch.id a ns1 - | Asn1AcnAst.AcnReferenceToEnumerated a -> DAstACN.createAcnEnumeratedFunction r lm Codec.Decode ch.id a (defOrRef r m a) ns1 + | Asn1AcnAst.AcnReferenceToEnumerated a -> DAstACN.createAcnEnumeratedFunction r icdStgFileName lm Codec.Decode ch.id a (defOrRef r m a) ns1 | Asn1AcnAst.AcnReferenceToIA5String a -> DAstACN.createAcnStringFunction r deps lm Codec.Decode ch.id a ns1 let funcUpdateStatement, ns3 = DAstACN.getUpdateFunctionUsedInEncoding r deps lm m ch.id ns2 @@ -808,7 +808,7 @@ let private mapType (r:Asn1AcnAst.AstRoot) (icdStgFileName:string) (deps:Asn1Acn (fun pi t ti newChildren -> TL "createSequence" (fun () -> createSequence r deps lm m pi t ti newChildren)) (fun ch newChild -> TL "createAsn1Child" (fun () -> createAsn1Child r lm m ch newChild)) - (fun ch us -> TL "createAcnChild" (fun () -> createAcnChild r deps lm m ch us)) + (fun ch us -> TL "createAcnChild" (fun () -> createAcnChild r icdStgFileName deps lm m ch us)) (fun pi t ti newChildren -> TL "createChoice" (fun () -> createChoice r deps lm m pi t ti newChildren)) diff --git a/BackendAst/DAstUtilFunctions.fs b/BackendAst/DAstUtilFunctions.fs index 65317a872..1ee92422f 100644 --- a/BackendAst/DAstUtilFunctions.fs +++ b/BackendAst/DAstUtilFunctions.fs @@ -580,22 +580,22 @@ with | ReferenceType ref -> ref.resolvedType.MappingFunctionsModules | TimeType _ -> [] - member this.icdFunction = + member this.icdTas = match this.Kind with - | Integer t -> t.acnEncFunction.icd.Value - | Real t -> t.acnEncFunction.icd.Value - | IA5String t -> t.acnEncFunction.icd.Value - | OctetString t -> t.acnEncFunction.icd.Value - | NullType t -> t.acnEncFunction.icd.Value - | BitString t -> t.acnEncFunction.icd.Value - | Boolean t -> t.acnEncFunction.icd.Value - | Enumerated t -> t.acnEncFunction.icd.Value - | SequenceOf t -> t.acnEncFunction.icd.Value - | Sequence t -> t.acnEncFunction.icd.Value - | Choice t -> t.acnEncFunction.icd.Value - | ReferenceType t -> t.acnEncFunction.icd.Value - | ObjectIdentifier t -> t.acnEncFunction.icd.Value - | TimeType t -> t.acnEncFunction.icd.Value + | Integer t -> t.acnEncFunction.icdTas + | Real t -> t.acnEncFunction.icdTas + | IA5String t -> t.acnEncFunction.icdTas + | OctetString t -> t.acnEncFunction.icdTas + | NullType t -> t.acnEncFunction.icdTas + | BitString t -> t.acnEncFunction.icdTas + | Boolean t -> t.acnEncFunction.icdTas + | Enumerated t -> t.acnEncFunction.icdTas + | SequenceOf t -> t.acnEncFunction.icdTas + | Sequence t -> t.acnEncFunction.icdTas + | Choice t -> t.acnEncFunction.icdTas + | ReferenceType t -> t.acnEncFunction.icdTas + | ObjectIdentifier t -> t.acnEncFunction.icdTas + | TimeType t -> t.acnEncFunction.icdTas member this.acnEncFunction : AcnFunction option = match this.Kind with diff --git a/FrontEndAst/AcnCreateFromAntlr.fs b/FrontEndAst/AcnCreateFromAntlr.fs index 8e2d394e1..66fc6c265 100644 --- a/FrontEndAst/AcnCreateFromAntlr.fs +++ b/FrontEndAst/AcnCreateFromAntlr.fs @@ -531,7 +531,6 @@ let createAcnBooleanProperties (props: GenericAcnProperty list) (acnErrLoc: SrcL else {BooleanAcnProperties.encodingPattern = Some( FalseValueEncoding(fv))} | None, None -> {BooleanAcnProperties.encodingPattern = None } - | _ -> raise(SemanticError(acnErrLoc, "Both 'true-value' and 'false-value' properties must be defined")) | None -> {BooleanAcnProperties.encodingPattern = None } let private mergeBooleanType (args: CommandLineSettings) (acnErrLoc: SrcLoc option) (props: GenericAcnProperty list) cons withcons (tdarg: GetTypeDefinition_arg) (us: Asn1AcnMergeState)= diff --git a/FrontEndAst/DAst.fs b/FrontEndAst/DAst.fs index 5f31800d3..627234793 100644 --- a/FrontEndAst/DAst.fs +++ b/FrontEndAst/DAst.fs @@ -57,8 +57,17 @@ type IcdRow = { sUnits : string option rowType : IcdRowType } - -type IcdTypeAss = { +//The following function provides the content of the inner table of an ICD table for a given type. +//The function takes as input the field name (when embedded in a sequence or choice), the presence textual description and any comments linked with this type +// Primitive types such as INTEGER, BOOLEAN will return a sinle IcdRow and an empty list of IcdTypeAss +// An Octet string may return multiple IcdRow (e.g. one for length determinant and one for the body content) and an empty list of IcdTypeAss +// A composite type such as SEQUENCE will return multiple IcdRow one for each asn1/acn child. +// if the child can be embedded in the parent type then the rows of the child are returned as rows of the parent type. +// if the child cannot be embedded in the parent type then a single IcdRow is returned for this child (of type ReferenceToCompositeTypeRow) and +// the child IcdTypeAss is included in the list of the returned IcdTypeAss +type IcdInnerTableFunc = string-> string -> string list -> ((IcdRow list)*(IcdTypeAss list)) + +and IcdTypeAss = { linkId : ReferenceToType tasInfo : TypeAssignmentInfo option asn1Link : string option @@ -67,11 +76,15 @@ type IcdTypeAss = { kind : string comments : string list rows : IcdRow list - //compositeChildren : IcdTypeAss list + compositeChildren : IcdTypeAss list minLengthInBytes : BigInteger maxLengthInBytes : BigInteger hash : string + canBeEmbedded : bool + createRowsFunc : IcdInnerTableFunc } + + type State = { currErrorCode : int curErrCodeNames : Set @@ -420,6 +433,15 @@ type UPerFunction = { funcBody_e : ErrorCode -> NestingScope -> CallerScope -> (UPERFuncBodyResult option) } +type IcdArgAux = { + canBeEmbedded : bool + baseAsn1Kind : string + rowsFunc : IcdInnerTableFunc + commentsForTas : string list + scope : string + name : string option +} + type AcnFuncBodyResult = { funcBody : string errCodes : ErrorCode list @@ -428,6 +450,7 @@ type AcnFuncBodyResult = { bBsIsUnReferenced : bool resultExpr : string option typeEncodingKind : TypeEncodingKind option + icdResult : IcdArgAux option } type XERFuncBodyResult = { @@ -454,11 +477,9 @@ type XerFunction = | XerFunction of XerFunctionRec | XerFunctionDummy -type IcdAux = { - canBeEmbedded : bool - createRowsFunc : string->string->string list ->IcdRow list - typeAss : IcdTypeAss -} + + + type AcnFunction = { funcName : string option // the name of the function. Valid only for TASes) @@ -470,7 +491,7 @@ type AcnFunction = { funcBody : State->((AcnGenericTypes.RelativePath*AcnGenericTypes.AcnParameter) list) -> NestingScope -> CallerScope -> ((AcnFuncBodyResult option)*State) funcBodyAsSeqComp : State->((AcnGenericTypes.RelativePath*AcnGenericTypes.AcnParameter) list) -> NestingScope -> CallerScope -> string -> ((AcnFuncBodyResult option)*State) isTestVaseValid : AutomaticTestCase -> bool - icd : IcdAux option (* always present in Encode, always None in Decode *) + icdTas : IcdTypeAss option (* always present in Encode, always None in Decode *) } type EncodeDecodeTestFunc = { @@ -904,6 +925,7 @@ and ReferenceType = { } and AcnChildUpdateResult = { + icdComments : string list updateAcnChildFnc : AcnChild -> NestingScope -> CallerScope -> CallerScope -> string //Given an automatic test case (which includes a map with the IDs of the involved types), this function //checks if the automatic test case contains a type which depends on this acn Child. If this is true