Exemplo n.º 1
0
        protected override void GenerateConvertAtomicPath_LH()
        {
            string str;

            var skipped_strs = new List <string>();

            if (canHideTau)
            {
                str = @"
          predicate IsSkippedTauPath(s: LPlusState, path: LAtomic_Path, tid: Armada_ThreadHandle)
          {
            && path.LAtomic_Path_Tau?
            && tid in s.s.threads
            && |s.s.threads[tid].storeBuffer| > 0
            && !CanConvertStoreBufferEntry_LH(s.s.threads[tid].storeBuffer[0])
          }
        ";
                pgp.AddPredicate(str, "convert");

                skipped_strs.Add("IsSkippedTauPath(s, path, tid)");
            }

            string convert_str = @"
        function ConvertAtomicPath_LH(s: LPlusState, path: LAtomic_Path, tid: Armada_ThreadHandle) : HAtomic_Path
          requires LAtomic_ValidPath(s, path, tid)
          requires !IsSkippedPath(s, path, tid)
        {
          match path
      ";

            foreach (var lpath in lAtomic.AtomicPaths)
            {
                if (pathMap.ContainsKey(lpath))
                {
                    var hpath = pathMap[lpath];
                    var n     = lpath.NextRoutines.Count;
                    convert_str += $"case LAtomic_Path_{lpath.Name}(steps) => HAtomic_Path_{hpath.Name}(HAtomic_PathSteps_{hpath.Name}(";
                    convert_str += String.Join(", ", Enumerable.Range(0, n)
                                               .Where(i => nextRoutineMap.ContainsKey(lpath.NextRoutines[i]))
                                               .Select(i => $"ConvertStep_LH(steps.step{i})"));
                    convert_str += "))\n";
                }
                else
                {
                    skipped_strs.Add($"path.LAtomic_Path_{lpath.Name}?");
                }
            }

            convert_str += "}\n";

            pgp.AddPredicate($@"
        predicate IsSkippedPath(s: LPlusState, path: LAtomic_Path, tid: Armada_ThreadHandle)
        {{
          { AH.CombineStringsWithOr(skipped_strs) }
        }}
      ", "convert");

            pgp.AddFunction(convert_str, "convert");
        }
Exemplo n.º 2
0
 public override string Extract()
 {
     return(AH.CombineStringsWithOr(children.Select(child => child.Extract())));
 }