Skip to content

Commit

Permalink
RTL function BitStream_GetLength is always generated even if it is no…
Browse files Browse the repository at this point in the history
…t used by the generated sources
  • Loading branch information
usr3-1415 committed Jan 2, 2024
1 parent 1ddce9c commit 60bd963
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions FrontEndAst/Language.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type ILangGeneric () =
abstract member BodyExtention : string

abstract member RtlFuncNames : string list
abstract member AlwaysPresentRtlFuncNames : string list

abstract member detectFunctionCalls : string -> string -> string list
abstract member removeFunctionFromHeader : string -> string -> string
abstract member removeFunctionFromBody : string -> string -> string
Expand Down Expand Up @@ -154,6 +156,7 @@ type ILangGeneric () =
default this.requiresHandlingOfEmptySequences = false
default this.requiresHandlingOfZeroArrays = false
default this.RtlFuncNames = []
default this.AlwaysPresentRtlFuncNames = []
default this.detectFunctionCalls (sourceCode: string) (functionName: string) = []
default this.removeFunctionFromHeader (sourceCode: string) (functionName: string) : string =
sourceCode
Expand Down
10 changes: 9 additions & 1 deletion StgC/LangGeneric_c.fs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,15 @@ type LangGeneric_c() =

CreateCMainFile r di.srcDir
generateVisualStudtioProject r di.srcDir (arrsSrcTstFiles, arrsHdrTstFiles)

//AlwaysPresentRtlFuncNames
override this.AlwaysPresentRtlFuncNames : string list =
[
"ByteStream_GetLength"
"BitStream_AttachBuffer2"
"BitStream_AttachBuffer"
"BitStream_Init"
]

override this.RtlFuncNames : string list =
[
"BitStream_EncodeNonNegativeInteger32Neg"
Expand Down
5 changes: 2 additions & 3 deletions asn1scc/GenerateRTL.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ let findUnusedRtlFunctions (lm:LanguageMacros) (rtlContent:string) (generatedCon
//first detect all function names
let directlyUsedFunctions =
lm.lg.RtlFuncNames |> List.filter (fun fn -> generatedContent.Contains(fn))


let allUsedFunctions = findAllUsedRtlFunctions lm rtlContent ("BitStream_AttachBuffer"::"BitStream_Init"::directlyUsedFunctions) |> Set.ofList
let debug = allUsedFunctions |> Set.toList |> List.sort |> Seq.StrJoin "\n"
let debug2 = lm.lg.detectFunctionCalls rtlContent "BitStream_DecodeNonNegativeInteger32Neg" |> Seq.StrJoin "\n"
let allUsedFunctions = findAllUsedRtlFunctions lm rtlContent (lm.lg.AlwaysPresentRtlFuncNames@directlyUsedFunctions) |> Set.ofList
lm.lg.RtlFuncNames |> List.filter (fun fn -> not (allUsedFunctions.Contains(fn)))


Expand Down

0 comments on commit 60bd963

Please sign in to comment.