@@ -14,6 +14,7 @@ open DAstUtilFunctions
1414open System.Globalization
1515open Language
1616
17+
1718let foldMap = Asn1Fold.foldMap
1819
1920
@@ -328,7 +329,11 @@ let private createAcnFunction (r: Asn1AcnAst.AstRoot)
328329 let prmNames = t.acnParameters |> List.map ( fun p -> p.c_ name)
329330 let func = Some( EmitTypeAssignment_ primitive varName sStar funcName isValidFuncName ( typeDefinition.longTypedefName2 lm.lg.hasModules) lvars bodyResult_ funcBody soSparkAnnotations sInitialExp prms prmNames ( t.acnMaxSizeInBits = 0 I) bBsIsUnreferenced bVarNameIsUnreferenced soInitFuncName funcDefAnnots precondAnnots postcondAnnots codec)
330331
331- let errCodStr = errCodes |> List.map( fun x -> EmitTypeAssignment_ def_ err_ code x.errCodeName ( BigInteger x.errCodeValue) x.comment) |> List.distinct
332+ let errCodStr =
333+ errCodes |>
334+ List.groupBy ( fun x -> x.errCodeName) |>
335+ List.map ( fun ( k , v ) -> { errCodeName = k; errCodeValue = v.Head.errCodeValue; comment = v.Head.comment}) |>
336+ List.map( fun x -> EmitTypeAssignment_ def_ err_ code x.errCodeName ( BigInteger x.errCodeValue) x.comment) |> List.distinct
332337 let funcDef = Some( EmitTypeAssignment_ primitive_ def varName sStar funcName ( typeDefinition.longTypedefName2 lm.lg.hasModules) errCodStr ( t.acnMaxSizeInBits = 0 I) nMaxBytesInACN ( t.acnMaxSizeInBits) prms soSparkAnnotations codec)
333338 let ns2a =
334339 match t.id.topLevelTas with
@@ -1932,6 +1937,9 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi
19321937
19331938 let handleChild ( s : SequenceChildState ) ( childInfo : SeqChildInfo ): SequenceChildResult * SequenceChildState =
19341939 // This binding is suspect, isn't it
1940+ let stateHash = getStateHash s.us
1941+ //printfn "child is %s" childInfo.Name
1942+ //printf "State hash: %s\n" stateHash
19351943 let us = s.us
19361944 let soSaveBitStrmPosStatement = None
19371945 let childNestingScope =
@@ -2099,6 +2107,10 @@ let createSequenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedFi
20992107 let res = { stmts= stmts; resultExpr= None; existVar= None; props= props; auxiliaries= auxiliaries; icdResult= icdResult}
21002108 let newAcc = { us= ns2; childIx= s.childIx + 1 I; uperAccBits= s.uperAccBits; acnAccBits= s.acnAccBits + acnChild.Type.acnMaxSizeInBits}
21012109 res, newAcc
2110+
2111+
2112+
2113+
21022114 // find acn inserted fields, which are not NULL types and which have no dependency.
21032115 // For those fields we should generated no anc encode/decode function
21042116 // Otherwise, the encoding function is wrong since an uninitialized value is encoded.
@@ -2559,8 +2571,8 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF
25592571 let bit_string_containing_ext_field_func = lm.acn.bit_ string_ containing_ ext_ field_ func
25602572
25612573 let baseTypeAcnFunction = baseType.getAcnFunction codec
2562-
2563- let funcBody ( errCode : ErrorCode ) ( acnArgs : ( AcnGenericTypes.RelativePath * AcnGenericTypes.AcnParameter ) list ) ( nestingScope : NestingScope ) ( p : CallerScope ) =
2574+ //(AcnFuncBodyResult option) * State
2575+ let funcBody ( us : State ) ( errCode : ErrorCode ) ( acnArgs : ( AcnGenericTypes.RelativePath * AcnGenericTypes.AcnParameter ) list ) ( nestingScope : NestingScope ) ( p : CallerScope ) : ( AcnFuncBodyResult option )* State =
25642576 TL " ACN_REF_04" ( fun () ->
25652577 let pp , resultExpr =
25662578 let str = lm.lg.getParamValue t p.arg codec
@@ -2569,22 +2581,22 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF
25692581 let toc = ToC str
25702582 toc, Some toc
25712583 | _ -> str, None
2572- let funcBodyContent , errCodes , localVariables =
2584+ let funcBodyContent , errCodes , localVariables , ns2 =
25732585 match encOptions.acnEncodingClass, encOptions.octOrBitStr with
25742586 | SZ_ EC_ ExternalField relPath , ContainedInOctString ->
25752587 let filterDependency ( d : AcnDependency ) =
25762588 match d.dependencyKind with
25772589 | AcnDepSizeDeterminant_ bit_ oct_ str_ contain _ -> true
25782590 | _ -> false
25792591 let extField = getExternalField0 r deps t.id filterDependency
2580- let soInner , errCodes0 , localVariables0 =
2592+ let soInner , errCodes0 , localVariables0 , ns1 =
25812593 match baseTypeAcnFunction with
2582- | None -> None, [], []
2594+ | None -> None, [], [], us
25832595 | Some baseTypeAcnFunction ->
25842596 let acnRes , ns = baseTypeAcnFunction.funcBody us acnArgs nestingScope p
25852597 match acnRes with
2586- | None -> None, [], []
2587- | Some r -> Some r.funcBody, r.errCodes, r.localVariables
2598+ | None -> None, [], [], ns
2599+ | Some r -> Some r.funcBody, r.errCodes, r.localVariables, ns
25882600
25892601 let fncBody = octet_ string_ containing_ ext_ field_ func pp baseFncName sReqBytesForUperEncoding extField errCode.errCodeName soInner codec
25902602 // For some reasons, the `soInner` is not inlined in the Ada backend,
@@ -2593,28 +2605,29 @@ let createReferenceFunction (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.AcnInsertedF
25932605 match ProgrammingLanguage.ActiveLanguages.Head with
25942606 | Ada -> []
25952607 | _ -> localVariables0
2596- fncBody, errCode:: errCodes0, lvs
2608+ fncBody, errCode:: errCodes0, lvs, ns1
25972609 | SZ_ EC_ ExternalField relPath , ContainedInBitString ->
25982610 let extField = getExternalField r deps t.id
25992611 let fncBody = bit_ string_ containing_ ext_ field_ func pp baseFncName sReqBytesForUperEncoding sReqBitForUperEncoding extField errCode.errCodeName codec
2600- fncBody, [ errCode],[]
2612+ fncBody, [ errCode],[], us
26012613 | SZ_ EC_ FIXED_ SIZE , ContainedInOctString ->
26022614 let fncBody = octet_ string_ containing_ func pp baseFncName sReqBytesForUperEncoding 0 I encOptions.minSize.acn encOptions.maxSize.acn true codec
2603- fncBody, [ errCode],[]
2615+ fncBody, [ errCode],[], us
26042616 | SZ_ EC_ LENGTH_ EMBEDDED nBits , ContainedInOctString ->
26052617 let fncBody = octet_ string_ containing_ func pp baseFncName sReqBytesForUperEncoding nBits encOptions.minSize.acn encOptions.maxSize.acn false codec
2606- fncBody, [ errCode],[]
2618+ fncBody, [ errCode],[], us
26072619 | SZ_ EC_ FIXED_ SIZE , ContainedInBitString ->
26082620 let fncBody = bit_ string_ containing_ func pp baseFncName sReqBytesForUperEncoding sReqBitForUperEncoding 0 I encOptions.minSize.acn encOptions.maxSize.acn true codec
2609- fncBody, [ errCode],[]
2621+ fncBody, [ errCode],[], us
26102622 | SZ_ EC_ LENGTH_ EMBEDDED nBits , ContainedInBitString ->
26112623 let fncBody = bit_ string_ containing_ func pp baseFncName sReqBytesForUperEncoding sReqBitForUperEncoding nBits encOptions.minSize.acn encOptions.maxSize.acn false codec
2612- fncBody, [ errCode],[]
2624+ fncBody, [ errCode],[], us
26132625 | SZ_ EC_ TerminationPattern nullVal , _ -> raise( SemanticError ( loc, " Invalid type for parameter4" ))
2614- Some ({ AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false ; bBsIsUnReferenced= false ; resultExpr= resultExpr; auxiliaries=[]; icdResult = icd}))
2626+ let funcBodyResult = Some ({ AcnFuncBodyResult.funcBody = funcBodyContent; errCodes = errCodes; localVariables = localVariables; bValIsUnReferenced= false ; bBsIsUnReferenced= false ; resultExpr= resultExpr; auxiliaries=[]; icdResult = icd})
2627+ funcBodyResult, ns2)
26152628
26162629 let soSparkAnnotations = Some( sparkAnnotations lm ( typeDefinition.longTypedefName2 lm.lg.hasModules) codec)
2617- let a , b = createAcnFunction r deps lm codec t typeDefinition isValidFunc ( fun us e acnArgs nestingScope p -> funcBody e acnArgs nestingScope p, us ) ( fun atc -> true ) soSparkAnnotations [] us
2630+ let a , b = createAcnFunction r deps lm codec t typeDefinition isValidFunc ( fun us e acnArgs nestingScope p -> funcBody us e acnArgs nestingScope p) ( fun atc -> true ) soSparkAnnotations [] us
26182631 Some a, b)
26192632
26202633
0 commit comments