Skip to content

Commit

Permalink
Remove 'TypeEncodingKind'
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-bucev committed Sep 9, 2024
1 parent 40137f6 commit c44f2b4
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 210 deletions.
213 changes: 89 additions & 124 deletions BackendAst/DAstACN.fs

Large diffs are not rendered by default.

73 changes: 29 additions & 44 deletions BackendAst/DAstUPer.fs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CommonTypes/FsUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ module List =
match xs with
| [] -> None
| x :: xs ->
match f(x) with
| Some(b) -> Some(b)
match f x with
| Some b -> Some b
| None -> tryFindMap f xs

let foldBackWith (f: 'a -> 's -> 's) (init: 'a -> 's) (xs: 'a list): 's =
Expand Down
22 changes: 0 additions & 22 deletions FrontEndAst/DAst.fs
Original file line number Diff line number Diff line change
Expand Up @@ -382,26 +382,8 @@ type Asn1IntegerEncodingType =
| UnconstrainedMax of bigint
| Unconstrained

type TypeEncodingKind = // TODO: Alignment???
| Asn1IntegerEncodingType of Asn1IntegerEncodingType option // None if range min = max
| Asn1RealEncodingType of Asn1AcnAst.RealClass
| AcnIntegerEncodingType of AcnIntegerEncodingType
| AcnRealEncodingType of AcnRealEncodingType
| AcnBooleanEncodingType of AcnBooleanEncoding option
| AcnNullEncodingType of PATTERN_PROP_VALUE option
| AcnStringEncodingType of Asn1AcnAst.StringAcnEncodingClass
| AcnOctetStringEncodingType of Asn1AcnAst.SizeableAcnEncodingClass
| AcnBitStringEncodingType of Asn1AcnAst.SizeableAcnEncodingClass
| SequenceOfEncodingType of TypeEncodingKind * Asn1AcnAst.SizeableAcnEncodingClass
| SequenceEncodingType of TypeEncodingKind option list
| ChoiceEncodingType of TypeEncodingKind option list
| ReferenceEncodingType of string
| OptionEncodingType of TypeEncodingKind
| Placeholder

/////////////////////////////////////////////////////////////////////


type NestingScope = {
acnOuterMaxSize: bigint
uperOuterMaxSize: bigint
Expand Down Expand Up @@ -429,7 +411,6 @@ type UPERFuncBodyResult = {
bValIsUnReferenced : bool
bBsIsUnReferenced : bool
resultExpr : string option
typeEncodingKind : TypeEncodingKind option
auxiliaries : string list
}
type UPerFunction = {
Expand Down Expand Up @@ -457,7 +438,6 @@ type AcnFuncBodyResult = {
bValIsUnReferenced : bool
bBsIsUnReferenced : bool
resultExpr : string option
typeEncodingKind : TypeEncodingKind option
auxiliaries : string list
icdResult : IcdArgAux option
}
Expand Down Expand Up @@ -843,7 +823,6 @@ and Asn1Child = {
isEqualBodyStats : CallerScope -> CallerScope -> (string*(LocalVariable list)) option
Type : Asn1Type
Optionality : Asn1AcnAst.Asn1Optionality option
// acnArgs : RelativePath list
Comments : string array
} with
member this.toAsn1AcnAst: Asn1AcnAst.Asn1Child =
Expand All @@ -854,7 +833,6 @@ and Asn1Child = {
_ada_name = this._ada_name
Type = this.Type.toAsn1AcnAst
Optionality = this.Optionality
// acnArgs = this.acnArgs
asn1Comments = this.Comments |> Array.toList
acnComments = []
}
Expand Down
16 changes: 0 additions & 16 deletions FrontEndAst/Language.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ type UncheckedAccessKind =
| FullAccess // unwrap all selection, including the last one
| PartialAccess // unwrap all but the last selection

// TODO: Remove?
type TypeInfo = {
uperMaxSizeBits: bigint
acnMaxSizeBits: bigint
typeKind: TypeEncodingKind option
} with
member this.maxSize (enc: Asn1Encoding): bigint =
match enc with
| ACN -> this.acnMaxSizeBits
| UPER -> this.uperMaxSizeBits
| _ -> raise (BugErrorException $"Unexpected encoding: {enc}")

type SequenceChildProps = {
info: Asn1AcnAst.SeqChildInfo
sel: Selection
Expand Down Expand Up @@ -100,9 +88,6 @@ type SequenceProofGen = {
| UPER -> this.uperSiblingMaxSize
| _ -> raise (BugErrorException $"Unexpected encoding: {enc}")

// member this.maxSize (enc: Asn1Encoding): BigInteger =
// this.children |> List.map (fun c -> c.typeInfo.maxSize enc) |> List.sum

member this.outerMaxSize (enc: Asn1Encoding): bigint =
match enc with
| ACN -> this.acnOuterMaxSize
Expand Down Expand Up @@ -183,7 +168,6 @@ type SequenceOfLikeProofGen = {
nestingIx: bigint
acnMaxOffset: bigint
uperMaxOffset: bigint
typeInfo: TypeInfo
nestingScope: NestingScope
cs: CallerScope
encDec: string option
Expand Down
2 changes: 0 additions & 2 deletions StgScala/acn_scala.stg
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ locally {
assert(codec.base.bitStream.bitIndex \<= oldCodec.base.bitStream.bitIndex + <nSizeInBits>L)
BitStream.validateOffsetBitsIneqLemma(oldCodec.base.bitStream, codec.base.bitStream, <nRemainingMinBits>, <nSizeInBits>L)
check(codec.base.bitStream.bitIndex \<= codec_0_1.base.bitStream.bitIndex + <nAbsOffset>L + <nSizeInBits>L)
//check(codec.base.bitStream.bitIndex \<= codec_<nLevel>_<nIx>.base.bitStream.bitIndex + <nOffset>L + <nSizeInBits>L)
}
}
<soCallAux>
Expand All @@ -575,7 +574,6 @@ val <p>_nCount = locally {
assert(codec.base.bitStream.bitIndex \<= oldCodec.base.bitStream.bitIndex + <nSizeInBits>L)
BitStream.validateOffsetBitsIneqLemma(oldCodec.base.bitStream, codec.base.bitStream, <nRemainingMinBits>, <nSizeInBits>L)
check(codec.base.bitStream.bitIndex \<= codec_0_1.base.bitStream.bitIndex + <nAbsOffset>L + <nSizeInBits>L)
//check(codec.base.bitStream.bitIndex \<= codec_<nLevel>_<nIx>.base.bitStream.bitIndex + <nOffset>L + <nSizeInBits>L)
}
<p>_nCount
}
Expand Down

0 comments on commit c44f2b4

Please sign in to comment.