Exemple #1
0
        private void GenerateMatchCaseStmt(int line, DatatypeCtor dtc, Solution solution, out MatchCaseStmt mcs)
        {
            Contract.Requires(dtc != null);
            Contract.Ensures(Contract.ValueAtReturn(out mcs) != null);
            List <CasePattern> casePatterns = new List <CasePattern>();

            dtc = new DatatypeCtor(dtc.tok, dtc.Name, dtc.Formals, dtc.Attributes);
            foreach (var formal in dtc.Formals)
            {
                CasePattern cp;
                GenerateCasePattern(line, formal, out cp);
                casePatterns.Add(cp);
            }

            List <Statement> body = new List <Statement>();

            if (solution != null)
            {
                Atomic ac = solution.State.Copy();
                body = ac.GetAllUpdated();
            }
            mcs = new MatchCaseStmt(CreateToken("cases", line, 0), dtc.CompileName, casePatterns, body);
        }