Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
usr3-1415 committed Jan 21, 2024
1 parent 994489c commit 2f1ab06
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 5 deletions.
2 changes: 1 addition & 1 deletion BackendAst/DAstUtilFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let getAccessFromScopeNodeList (ReferenceToType nodes) (childTypeIsString: bool
| SEQ_CHILD (chName, isOptional) ->
let isPresent =
match isOptional with
| true ->[sprintf "%s%sexist.%s" pVal.arg.p (lm.lg.getAccess pVal.arg) chName]
| true -> [lm.lg.getSeqChildIsPresent pVal.arg chName] //[sprintf "%s%sexist.%s" pVal.arg.p (lm.lg.getAccess pVal.arg) chName]
| false -> []
isPresent, {pVal with arg = lm.lg.getSeqChild pVal.arg (ToC chName) childTypeIsString false}
| CH_CHILD (chName,pre_name, chParent) ->
Expand Down
6 changes: 5 additions & 1 deletion FrontEndAst/Language.fs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ type ILangGeneric () =
abstract member getSequenceTypeDefinition :Map<ProgrammingLanguage, FE_SequenceTypeDefinition> -> FE_SequenceTypeDefinition
abstract member getSizeableTypeDefinition : Map<ProgrammingLanguage, FE_SizeableTypeDefinition> -> FE_SizeableTypeDefinition

abstract member getSeqChild : FuncParamType -> string -> bool -> bool -> FuncParamType;
abstract member getSeqChild : FuncParamType -> string -> bool -> bool -> FuncParamType

//return a string that contains code with a boolean expression that is true if the child is present
abstract member getSeqChildIsPresent : FuncParamType -> string -> string

abstract member getChChild : FuncParamType -> string -> bool -> FuncParamType;
abstract member getLocalVariableDeclaration : LocalVariable -> string;
abstract member getLongTypedefName : TypeDefintionOrReference -> string;
Expand Down
2 changes: 2 additions & 0 deletions StgAda/LangGeneric_a.fs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ type LangGeneric_a() =
let encRtl = []//match r.args.encodings |> Seq.exists(fun e -> e = UPER || e = ACN || e = XER) with true -> [] | false -> ["adaasn1rtl.encoding"]
encRtl@uperRtl@acnRtl@xerRtl |> List.distinct

override this.getSeqChildIsPresent (fpt:FuncParamType) (childName:string) =
sprintf "%s%sexist.%s = 1" fpt.p (this.getAccess fpt) childName

override this.getSeqChild (fpt:FuncParamType) (childName:string) (childTypeIsString: bool) (removeDots: bool) =
let newPath = sprintf "%s.%s" fpt.p childName
Expand Down
2 changes: 1 addition & 1 deletion StgAda/acn_a.stg
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ end case;


checkAccessPath(arrsCheckPaths, sUpdateStatement) ::= <<
if (<arrsCheckPaths; separator=" && ">) then
if (<arrsCheckPaths; separator=" and then ">) then
<sUpdateStatement>
end if;
>>
Expand Down
5 changes: 4 additions & 1 deletion StgC/LangGeneric_c.fs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ type LangGeneric_c() =
override this.allowsSrcFilesWithNoFunctions = true
override this.requiresValueAssignmentsInSrcFile = true
override this.supportsStaticVerification = false


override this.getSeqChildIsPresent (fpt:FuncParamType) (childName:string) =
sprintf "%s%sexist.%s" fpt.p (this.getAccess fpt) childName

override this.getSeqChild (fpt:FuncParamType) (childName:string) (childTypeIsString: bool) (removeDots: bool) =
let newPath = sprintf "%s%s%s" fpt.p (this.getAccess fpt) childName
if childTypeIsString then (FIXARRAY newPath) else (VALUE newPath)
Expand Down
5 changes: 5 additions & 0 deletions StgScala/LangGeneric_scala.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open DAst
open FsUtils
open Language
open System.IO
open System

let getAccess_scala (fpt:FuncParamType) =
match fpt with
Expand Down Expand Up @@ -196,6 +197,10 @@ type LangGeneric_scala() =
override this.requiresValueAssignmentsInSrcFile = true
override this.supportsStaticVerification = false

override this.getSeqChildIsPresent (fpt:FuncParamType) (childName:string) =
//sprintf "%s%sexist.%s = 1" fpt.p (this.getAccess fpt) childName
raise (NotImplementedException())

override this.getSeqChild (fpt:FuncParamType) (childName:string) (childTypeIsString: bool) (removeDots: bool) =
let newPath = sprintf "%s%s%s" fpt.p (this.getAccess fpt) childName
let newPath = if removeDots then (ToC newPath) else newPath
Expand Down
2 changes: 1 addition & 1 deletion asn1scc/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let printVersion () =
//let fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
//let version = fvi.FileVersion;

let version = "4.5.0.22"
let version = "4.5.0.23"
printfn "asn1scc version %s\n" version
()

Expand Down
17 changes: 17 additions & 0 deletions v4Tests/test-cases/acn/21-PresentWhenExpression/002.acn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TEST-CASE DEFINITIONS ::= BEGIN

MyChoiceEnum [size 32, encoding pos-int, endianness big, encode-values]

MyTopMostSeq []
{
myDeterminant MyChoiceEnum [],
myBool1 BOOLEAN [],
myBool2 BOOLEAN [],
myChoice1 <myDeterminant> [present-when myBool1],
myChoice2 <myDeterminant> [present-when myBool2]
}

MyChoice <MyChoiceEnum: theDeterminant> [determinant theDeterminant]

END

36 changes: 36 additions & 0 deletions v4Tests/test-cases/acn/21-PresentWhenExpression/002.asn1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
TEST-CASE DEFINITIONS AUTOMATIC TAGS::= BEGIN

MyChoiceEnum ::= ENUMERATED
{
choice1 (1),
choice2 (2)
}

MyTopMostSeq ::= SEQUENCE
{
myChoice1 MyChoice OPTIONAL,
myChoice2 MyChoice OPTIONAL
}

MyChoice ::= CHOICE
{
choice1 MyTuple,
choice2 INTEGER
}

MyTuple ::= SEQUENCE
{
fst INTEGER,
snd INTEGER
}

myTest MyTopMostSeq ::= {

myChoice1 choice1 : { fst 4, snd 2 }

}

END


--TCFS 002.acn

0 comments on commit 2f1ab06

Please sign in to comment.