Skip to content

Commit

Permalink
Fix access path for Scala
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-bucev committed Feb 14, 2024
1 parent 79cd600 commit bade67e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions BackendAst/DAstACN.fs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ let calcIcdTypeAssHash (codec:CommonTypes.Codec) bPrint (t1:IcdTypeAss) =
calcIcdTypeAssHash_aux t1

let adaptArgument = DAstUPer.adaptArgument
let adaptArgumentValue = DAstUPer.adaptArgumentValue

let joinedOrAsIdentifier = DAstUPer.joinedOrAsIdentifier

Expand Down Expand Up @@ -1401,17 +1402,18 @@ let rec handleSingleUpdateDependency (r:Asn1AcnAst.AstRoot) (deps:Asn1AcnAst.Acn
let choiceName = chc.typeDef[Scala].typeName
choiceDependencyEnum_Item v ch.presentWhenName choiceName (lm.lg.getNamedItemBackendName (Some (defOrRef2 r m enm)) enmItem) isOptional)
let updateStatement = choiceDependencyEnum v (choicePath.arg.joined lm.lg) (lm.lg.getAccess choicePath.arg) arrsChildUpdates isOptional (initExpr r lm m child.Type)
// TODO: !!!!!
let updateStatement =
// TODO: To remove this, getAccessFromScopeNodeList should be accounting for languages that rely on pattern matching for
// accessing enums fields instead of a compiler-unchecked access
let updateStatement2 =
match ST.lang with
| Scala ->
match checkPath.Length > 0 with
match checkPath.Length > 0 && checkPath[0].Contains("isInstanceOf") with
| true -> (sprintf "val %s = %s.%s\n%s" (choicePath.arg.joined lm.lg) (checkPath[0].Replace("isInstanceOf", "asInstanceOf")) (choicePath.arg.joined lm.lg) updateStatement)
| false -> updateStatement
| _ -> updateStatement
match checkPath with
| [] -> updateStatement
| _ -> checkAccessPath checkPath updateStatement v (initExpr r lm m child.Type)
| [] -> updateStatement2
| _ -> 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
Expand Down
4 changes: 2 additions & 2 deletions FrontEndAst/AcnCreateFromAntlr.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,8 @@ let rec private mergeType (asn1:Asn1Ast.AstRoot) (acn:AcnAst) (m:Asn1Ast.Asn1Mo
match newOptionality with
| None -> false
| Some AlwaysAbsent
| Some (Optional _) -> true
| Some AlwaysPresent -> false
| Some (Optional _)
| Some AlwaysPresent -> true

match cc with
| None ->
Expand Down
2 changes: 1 addition & 1 deletion StgScala/LangGeneric_scala.fs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ type LangGeneric_scala() =
override this.supportsStaticVerification = false

override this.getSeqChildIsPresent (sel: Selection) (childName: string) =
sprintf "%s%s%sisDefined" (sel.joined this) (this.getAccess sel) childName
sprintf "%s%s%s.isDefined" (sel.joined this) (this.getAccess sel) childName

override this.getSeqChild (sel: Selection) (childName:string) (childTypeIsString: bool) (childIsOptional: bool) =
sel.appendSelection childName (if childTypeIsString then FixArray else Value) childIsOptional
Expand Down

0 comments on commit bade67e

Please sign in to comment.