@@ -438,6 +438,7 @@ let private createAcnIntegerFunctionInternal (r:Asn1AcnAst.AstRoot)
438438 acnMinSizeInBits
439439 acnMaxSizeInBits
440440 unitsOfMeasure
441+ ( typeName : string )
441442 ( soMF : string option , soMFM : string option ): AcnIntegerFuncBody =
442443 let PositiveInteger_ConstSize_8 = lm.acn.PositiveInteger_ ConstSize_ 8
443444 let PositiveInteger_ConstSize_big_endian_16 = lm.acn.PositiveInteger_ ConstSize_ big_ endian_ 16
@@ -462,6 +463,7 @@ let private createAcnIntegerFunctionInternal (r:Asn1AcnAst.AstRoot)
462463 let ASCII_UINT_VarSize_NullTerminated = lm.acn.ASCII_ UINT_ VarSize_ NullTerminated
463464 let BCD_ConstSize = lm.acn.BCD_ ConstSize
464465 let BCD_VarSize_NullTerminated = lm.acn.BCD_ VarSize_ NullTerminated
466+ let mappingFunctionDeclaration = lm.acn.MappingFunctionDeclaration
465467
466468 let nUperMin , nUperMax =
467469 match uperRange with
@@ -470,6 +472,12 @@ let private createAcnIntegerFunctionInternal (r:Asn1AcnAst.AstRoot)
470472 | PosInf( a) -> a, r.args.IntMax ( a>= 0 I)
471473 | Full -> r.args.SIntMin, r.args.SIntMax
472474
475+ let userDefinedFunctions =
476+ match soMF with
477+ | None -> []
478+ | Some s ->
479+ [ UserMappingFunction ( mappingFunctionDeclaration typeName s)]
480+
473481 let funcBody ( errCode : ErrorCode )
474482 ( acnArgs : ( AcnGenericTypes.RelativePath * AcnGenericTypes.AcnParameter ) list )
475483 ( nestingScope : NestingScope )
@@ -544,7 +552,7 @@ let private createAcnIntegerFunctionInternal (r:Asn1AcnAst.AstRoot)
544552 let icdFnc fieldName sPresent comments =
545553 [{ IcdRow.fieldName = fieldName; comments = comments; sPresent= sPresent; sType=( IcdPlainType " INTEGER" ); sConstraint= sAsn1Constraints; minLengthInBits = acnMinSizeInBits ; maxLengthInBits= acnMaxSizeInBits; sUnits= unitsOfMeasure; rowType = IcdRowType.FieldRow; idxOffset = None}], []
546554 let icd = { IcdArgAux.canBeEmbedded = true ; baseAsn1Kind = " INTEGER" ; rowsFunc = icdFnc; commentsForTas=[]; scope= " type" ; name= None}
547- Some ({ AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= bValIsUnReferenced; bBsIsUnReferenced= bBsIsUnReferenced; resultExpr = resultExpr; auxiliaries = []; icdResult= Some icd})
555+ Some ({ AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = []; bValIsUnReferenced= bValIsUnReferenced; bBsIsUnReferenced= bBsIsUnReferenced; resultExpr = resultExpr; auxiliaries = []; userDefinedFunctions = userDefinedFunctions ; icdResult= Some icd})
548556 funcBody
549557
550558let getMappingFunctionModule ( r : Asn1AcnAst.AstRoot ) ( lm : LanguageMacros ) ( soMapFuncName : string option ) =
@@ -559,9 +567,10 @@ let getMappingFunctionModule (r:Asn1AcnAst.AstRoot) (lm:LanguageMacros) (soMapFu
559567 | true -> Some ( acn_ a.rtlModuleName() )
560568 | false -> r.args.mappingFunctionsModule
561569
562- let createAcnIntegerFunction ( r : Asn1AcnAst.AstRoot ) ( deps : Asn1AcnAst.AcnInsertedFieldDependencies ) ( lm : LanguageMacros ) ( codec : CommonTypes.Codec ) ( typeId : ReferenceToType ) ( t : Asn1AcnAst.AcnInteger ) ( us : State ) =
570+ let createAcnIntegerFunction ( r : Asn1AcnAst.AstRoot ) ( deps : Asn1AcnAst.AcnInsertedFieldDependencies ) ( lm : LanguageMacros ) ( codec : CommonTypes.Codec ) ( typeId : ReferenceToType ) ( t : Asn1AcnAst.AcnInteger ) ( typeName : string ) ( us : State ) =
563571 let errCodeName = ToC ( " ERR_ACN" + ( codec.suffix.ToUpper()) + " _" + (( typeId.AcnAbsPath |> Seq.skip 1 |> Seq.StrJoin( " -" )) .Replace( " #" , " elm" )))
564572 let errCode , ns = getNextValidErrorCode us errCodeName None
573+
565574
566575 let uperFuncBody ( errCode ) ( nestingScope : NestingScope ) ( p : CodegenScope ) ( fromACN : bool ) =
567576 DAstUPer.getIntfuncBodyByCons r lm codec t.uperRange t.Location ( getAcnIntegerClass r.args t) ( t.cons) ( t.cons@ t.withcons) typeId errCode nestingScope p
@@ -577,7 +586,7 @@ let createAcnIntegerFunction (r:Asn1AcnAst.AstRoot) (deps: Asn1AcnAst.AcnInserte
577586 let sAsn1Constraints = None
578587 let unitsOfMeasure = None
579588
580- let funcBody = createAcnIntegerFunctionInternal r lm codec t.uperRange t.intClass t.acnEncodingClass uperFuncBody sAsn1Constraints t.acnMinSizeInBits t.acnMaxSizeInBits unitsOfMeasure ( soMapFunc, soMapFunMod)
589+ let funcBody = createAcnIntegerFunctionInternal r lm codec t.uperRange t.intClass t.acnEncodingClass uperFuncBody sAsn1Constraints t.acnMinSizeInBits t.acnMaxSizeInBits unitsOfMeasure typeName ( soMapFunc, soMapFunMod)
581590 ( funcBody errCode), ns
582591
583592
@@ -588,6 +597,7 @@ let createIntegerFunction (r:Asn1AcnAst.AstRoot) (deps: Asn1AcnAst.AcnInsertedFi
588597 | " " -> None
589598 | _ -> Some sTmpCons
590599
600+ let typeName = typeDefinition.longTypedefName2 lm.lg.hasModules
591601 let soMapFunMod , soMapFunc =
592602 match o.acnProperties.mappingFunction with
593603 | Some ( MappingFunction ( soMapFunMod, mapFncName)) ->
@@ -596,7 +606,7 @@ let createIntegerFunction (r:Asn1AcnAst.AstRoot) (deps: Asn1AcnAst.AcnInsertedFi
596606 | None -> getMappingFunctionModule r lm soMapFunc, soMapFunc
597607 | Some soMapFunMod -> Some soMapFunMod.Value, soMapFunc
598608 | None -> None, None
599- let funcBodyOrig = createAcnIntegerFunctionInternal r lm codec o.uperRange o.intClass o.acnEncodingClass uperFunc.funcBody_ e sAsn1Constraints t.acnMinSizeInBits t.acnMaxSizeInBits t.unitsOfMeasure ( soMapFunc, soMapFunMod)
609+ let funcBodyOrig = createAcnIntegerFunctionInternal r lm codec o.uperRange o.intClass o.acnEncodingClass uperFunc.funcBody_ e sAsn1Constraints t.acnMinSizeInBits t.acnMaxSizeInBits t.unitsOfMeasure typeName ( soMapFunc, soMapFunMod)
600610 let funcBody ( errCode : ErrorCode )
601611 ( acnArgs : ( AcnGenericTypes.RelativePath * AcnGenericTypes.AcnParameter ) list )
602612 ( nestingScope : NestingScope )
0 commit comments