@@ -8,7 +8,7 @@ namespace Plang.Compiler.TypeChecker;
8
8
9
9
public abstract class ParamAssignment
10
10
{
11
- public static Dictionary < string , IPExpr > Dic2StrDic ( Dictionary < Variable , IPExpr > dic )
11
+ private static Dictionary < string , IPExpr > Dic2StrDic ( Dictionary < Variable , IPExpr > dic )
12
12
{
13
13
var dicAux = new Dictionary < string , IPExpr > ( ) ;
14
14
foreach ( var ( k , i ) in dic )
@@ -18,7 +18,7 @@ public static Dictionary<string, IPExpr> Dic2StrDic(Dictionary<Variable, IPExpr>
18
18
return dicAux ;
19
19
}
20
20
21
- public static Dictionary < Variable , IPExpr > IndexDic2Dic ( List < Variable > globalParams , IDictionary < string , List < IPExpr > > paramExprDic , IDictionary < string , int > indexDic )
21
+ private static Dictionary < Variable , IPExpr > IndexDic2Dic ( List < Variable > globalParams , IDictionary < string , List < IPExpr > > paramExprDic , IDictionary < string , int > indexDic )
22
22
{
23
23
var dic = new Dictionary < Variable , IPExpr > ( ) ;
24
24
foreach ( var ( k , i ) in indexDic )
@@ -33,6 +33,12 @@ public static Dictionary<Variable, IPExpr> IndexDic2Dic(List<Variable> globalPar
33
33
}
34
34
return dic ;
35
35
}
36
+
37
+ public static string RenameSafetyTestByAssignment ( string name , Dictionary < Variable , IPExpr > dic )
38
+ {
39
+ var postfix = $ "{ string . Join ( "__" , Dic2StrDic ( dic ) . ToList ( ) . Select ( p => $ "{ p . Key } _{ p . Value } ") ) } ";
40
+ return postfix . Length == 0 ? name : $ "{ name } ___{ postfix } ";
41
+ }
36
42
37
43
private static bool Next ( ( string , int ) [ ] indexArr , IDictionary < string , List < IPExpr > > globalParams )
38
44
{
@@ -46,7 +52,7 @@ private static bool Next((string, int)[] indexArr, IDictionary<string, List<IPEx
46
52
return false ;
47
53
}
48
54
49
- public static void IterateIndexDic ( SafetyTest safety , List < Variable > globalParams , Action < Dictionary < string , int > > f )
55
+ public static void IterateIndexDic ( SafetyTest safety , List < Variable > globalParams , Action < Dictionary < Variable , IPExpr > > f )
50
56
{
51
57
// Console.WriteLine($"safety.ParamExpr.Count = {safety.ParamExpr.Count}");
52
58
var indexArr = safety . ParamExprMap . ToList ( ) . Zip ( Enumerable . Repeat ( 0 , safety . ParamExprMap . Count ) , ( x , y ) => ( x . Key , y ) ) . ToArray ( ) ;
@@ -58,7 +64,7 @@ public static void IterateIndexDic(SafetyTest safety, List<Variable> globalParam
58
64
// Console.WriteLine($"{string.Join(',', dic.ToList())} |- {safety.AssumeExpr} = {ForceBool(Eval(dic, safety.AssumeExpr))}");
59
65
if ( ! SimpleExprEval . ForceBool ( SimpleExprEval . Eval ( dic , safety . AssumeExpr ) ) ) continue ;
60
66
// Console.WriteLine($"indexArr: {string.Join(',', indexArr)}");
61
- f ( indexDic ) ;
67
+ f ( dic ) ;
62
68
} while ( Next ( indexArr , safety . ParamExprMap ) ) ;
63
69
}
64
70
}
0 commit comments