Skip to content
Permalink
Browse files

mantis 0000566

  • Loading branch information...
usr3-1415 committed May 13, 2018
1 parent 932b98c commit 58ef34a13b5e5b4694265597fd7d5fb34fccbc36
@@ -29,8 +29,8 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Debug\Asn1f4.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
<StartWorkingDirectory>C:\prj\GitHub\asn1scc\mantis\0000535\</StartWorkingDirectory>
<StartArguments>-c -wordSize 4 -uPER -atc -o c_out32/ DataView.asn</StartArguments>
<StartWorkingDirectory>C:\prj\GitHub\asn1scc\mantis\0000498</StartWorkingDirectory>
<StartArguments>--icduper icdv4.html icd.asn1</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -87,10 +87,10 @@
<Compile Include="DAstExportToXml.fs" />
<Compile Include="GrammarGenerator.fs" />
<Compile Include="CustomStgExport.fs" />
<Compile Include="PrintAsn1.fs" />
<Compile Include="GenerateUperIcd.fs" />
<Compile Include="GenerateAcnIcd.fs" />
<Compile Include="PrintAcn.fs" />
<Compile Include="PrintAsn1.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Antlr\Antlr.csproj">
@@ -136,7 +136,7 @@ let rec PrintType (r:AstRoot) (f:Asn1File) (stgFileName:string) modName (deepRec
let sCModName = if sModName <> null then (ToC sModName) else null
let refTypeContent =
match uperRange with
| Some(sMin, sMax) -> gen.RefTypeMinMax sMin sMax asn1Name sModName (ToC asn1Name) (*typedefName*) sCModName stgFileName
| Some(sMin, sMax) -> gen.RefTypeMinMax sMin sMax asn1Name sModName (ToC asn1Name) (*typedefName*) sCModName (sMin = sMax) stgFileName
| None -> gen.RefType asn1Name sModName (ToC asn1Name) (*typedefName*) sCModName stgFileName
gen.TypeGeneric (BigInteger t.Location.srcLine) (BigInteger t.Location.charPos) f.FileName refTypeContent stgFileName
let PrintTypeAux (t:Asn1Type) =
@@ -190,7 +190,7 @@ let rec PrintType (r:AstRoot) (f:Asn1File) (stgFileName:string) modName (deepRec
|false -> printChildTypeAsReferencedType info.childType

let sMin, sMax = info.baseInfo.minSize.ToString(), info.baseInfo.maxSize.ToString()
gen.SequenceOfType sMin sMax childTypeExp stgFileName
gen.SequenceOfType sMin sMax childTypeExp (sMin=sMax) stgFileName
| ReferenceType info ->
let uperRange =
match (t.ActualType).Kind with
@@ -204,7 +204,7 @@ let rec PrintType (r:AstRoot) (f:Asn1File) (stgFileName:string) modName (deepRec
let sModName = if info.baseInfo.modName.Value=modName then null else info.baseInfo.modName.Value
let sCModName = if sModName <> null then (ToC sModName) else null
match uperRange with
| Some(sMin, sMax) -> gen.RefTypeMinMax sMin sMax info.baseInfo.tasName.Value sModName (ToC info.baseInfo.tasName.Value) sCModName stgFileName
| Some(sMin, sMax) -> gen.RefTypeMinMax sMin sMax info.baseInfo.tasName.Value sModName (ToC info.baseInfo.tasName.Value) sCModName (sMin=sMax) stgFileName
| None -> gen.RefType info.baseInfo.tasName.Value sModName (ToC info.baseInfo.tasName.Value) sCModName stgFileName

gen.TypeGeneric (BigInteger t.Location.srcLine) (BigInteger t.Location.charPos) f.FileName (PrintTypeAux t) stgFileName
@@ -104,7 +104,14 @@ let createBoolFunction (r:Asn1AcnAst.AstRoot) (t:Asn1AcnAst.Asn1Type) (o:Asn1Ac

let createEnumeratedFunction (r:Asn1AcnAst.AstRoot) (t:Asn1AcnAst.Asn1Type) (o:Asn1AcnAst.Enumerated) =
let conToStrFunc = foldGenericCon (fun b -> b)
o.AllCons |> List.map conToStrFunc
//remove the "virtual constraint" that is added in all ENUMERAED wich constraints the type to all of each possible values
let actualConstraints =
o.AllCons |>
List.filter(fun c ->
match c with
| Asn1AcnAst.UnionConstraint(_,_,virtCon) -> not virtCon
| _ -> true)
actualConstraints |> List.map conToStrFunc

//type OctetStringConstraint = SizableTypeConstraint<OctetStringValue*(ReferenceToValue*SrcLoc)>

@@ -156,7 +156,7 @@ let rec printType (stgFileName:string) (m:Asn1Module) (tas:TypeAssignment) (t:As
let sAsn1Constraints = ""
handlePrimitive sAsn1Constraints
| Enumerated o ->
let sAsn1Constraints = ""
let sAsn1Constraints = t.ConstraintsAsn1Str |> Seq.StrJoin ""
handlePrimitive sAsn1Constraints
|ReferenceType o ->
printType stgFileName m tas t.ActualType r color
BIN +23.3 KB (100%) Docs/ACN-UM-v-3-2.docx
Binary file not shown.
BIN +84 KB (120%) Docs/ACN-UM-v-3-2.pdf
Binary file not shown.
@@ -13,6 +13,7 @@ module ST

open FsUtils
open System
open System.Collections
open System.Numerics
open System.Globalization
open Antlr.StringTemplate
@@ -132,6 +133,8 @@ type BasicFormatRendererBigInt() =

let cache = System.Collections.Generic.Dictionary<string, StringTemplateGroup>()

let macrosWithErrorsDiscoveredInRunTime = System.Collections.Generic.Dictionary<string, int>()

let runsUnderMono() =
match System.Type.GetType("Mono.Runtime") with
| null -> false
@@ -197,6 +200,42 @@ let call fileName macroName (attrs:seq<string*#Object>)=
//printfn "%s\n" ret
ret

let call_generic fileName macroName (attrs:seq<string*#Object>)=
let group = get_group fileName

let template = group.GetInstanceOf(macroName);

let argsNotPresentInLocalMacro =
attrs |> Seq.filter(fun (attrName, obj) -> (not (template.FormalArguments.Contains attrName))) |> Seq.map fst |> Seq.toList

match argsNotPresentInLocalMacro with
| [] -> ()
| _ ->
let macroKey = fileName + "#" + macroName
match macrosWithErrorsDiscoveredInRunTime.ContainsKey macroKey with
| true -> () //we have already print a warning for this macro
| false ->
macrosWithErrorsDiscoveredInRunTime.Add(macroKey, 1)
let newArgs = attrs |> Seq.map fst |> Seq.StrJoin ", "
let newSignature = sprintf "%s(%s)" macroName newArgs
let orldArgs = template.FormalArguments.Values |> Seq.cast |> Seq.StrJoin ", "
let oldSignature = sprintf "%s(%s)" macroName orldArgs

let errMsg = sprintf "Warning: Signature of macro '%s' of custom stg file '%s' has changed from\n %s\nto\n %s\nConsider updating your custom stg file '%s' to comply to the new signature.\n" macroName fileName oldSignature newSignature fileName
Console.Error.WriteLine(errMsg)


attrs |>
Seq.iter(fun (attrName, obj) ->
match template.FormalArguments.Contains attrName with
| true -> template.SetAttribute(attrName,obj)
| false -> ()
)
let ret = template.ToString 80
//printfn "%s\n" ret
ret


let call2 (fileName, macroName, [<ParamArray>] attrs:array<string*#Object>)=
let group = get_group fileName

@@ -138,13 +138,13 @@ SequenceType(arrsChildren) ::= <<
>>


SequenceOfType(sMin, sMax, sChild) ::= <<
SequenceOfType(sMin, sMax, sChild, bFixedSize) ::= <<
"Kind": "SequenceOfType", "Min": "$sMin$", "Max": "$sMax$", "type": {
$sChild$
}
>>

RefTypeMinMax(sMin, sMax, sName, sModName, sCName, sCModName) ::= <<
RefTypeMinMax(sMin, sMax, sName, sModName, sCName, sCModName, bFixedSize) ::= <<
"Kind": "ReferenceType", "ReferencedTypeName": "$sName$", "Min": "$sMin$", "Max": "$sMax$"$if(sModName)$, "ReferencedModName": "$sModName$"$endif$
>>

@@ -200,14 +200,14 @@ SequenceType(arrsChildren) ::= <<


/* Sequence of (array) */
SequenceOfType(sMin, sMax, sChild) ::= <<
SequenceOfType(sMin, sMax, sChild, bFixedSize) ::= <<
"kind": "SequenceOfType", "Min": "$sMin$", "Max": "$sMax$", "type": type("SeqOf_type", (object,), {
$sChild$
})
>>


RefTypeMinMax(sMin, sMax, sName, sModName, sCName, sCModName) ::= <<
RefTypeMinMax(sMin, sMax, sName, sModName, sCName, sCModName, bFixedSize) ::= <<
"kind": "ReferenceType", "ReferencedTypeName": "$sName$", "Min": "$sMin$", "Max": "$sMax$"$if(sModName)$, "ReferencedModName": "$sModName$"$endif$
>>

@@ -149,13 +149,13 @@ SequenceType(arrsChildren) ::= <<
>>


SequenceOfType(sMin, sMax, sChild) ::= <<
SequenceOfType(sMin, sMax, sChild, bFixedSize) ::= <<
<SequenceOfType Min="$sMin$" Max="$sMax$">
$sChild$
</SequenceOfType>
>>

RefTypeMinMax(sMin, sMax, sName, sModName, sCName, sCModName) ::= <<
RefTypeMinMax(sMin, sMax, sName, sModName, sCName, sCModName, bFixedSize) ::= <<
<ReferenceType ReferencedTypeName="$sName$" Min="$sMin$" Max="$sMax$"$if(sModName)$ ReferencedModName="$sModName$"$endif$/>
>>

@@ -227,13 +227,13 @@ where line.Contains("::=") && !line.Contains("/*nogen*/") && !line.Contains("DEF
{
txt.WriteLine("let {0} {1} (fileName:string) =", func.name, paramerters);
txt.WriteLine(" {0}", lng);
txt.WriteLine(" ST.call {0} \"{1}\" [{2}]", "fileName", func.name, prms);
txt.WriteLine(" ST.call_generic {0} \"{1}\" [{2}]", "fileName", func.name, prms);
}
else if (inpFileNoExt == "icd_uper" || inpFileNoExt == "icd_acn" || inpFileNoExt == "icdtemplate_acn" || inpFileNoExt == "icdtemplate_uper")
{
txt.WriteLine("let {0} (fileName:string) {1} =", func.name, paramerters);
txt.WriteLine(" {0}", lng);
txt.WriteLine(" ST.call {0} \"{1}\" [{2}]", "fileName", func.name, prms);
txt.WriteLine(" ST.call_generic {0} \"{1}\" [{2}]", "fileName", func.name, prms);
}
else
{

0 comments on commit 58ef34a

Please sign in to comment.
You can’t perform that action at this time.