Beispiel #1
0
        internal VProgramEmitter(CertificationRequest certReq)
        {
            AppendFormattedLine("public static class Program {{");
            IncreaseIndent();
            AppendFormattedLine("public static void Main() {{");
            IncreaseIndent();

            AppendFormattedLine("SVX.VProgram_API.InitVProgram();");

            sb.AppendLine();

            participantsSeen.Add(certReq.participantId);
            participantsSeen.UnionWith(certReq.predicateParticipants);
            ScanParticipants(certReq.scrutineeSymT);
            foreach (var participant in participantsSeen)
            {
                AppendFormattedLine("SVX.VProgram_API.CreateParticipant({0}, new {1}({0}));",
                                    EmitPrincipal(participant.principal), FormatTypeFullName(participant.typeFullName));
            }

            sb.AppendLine();

            string scrutineeVarName = EmitMessage(certReq.scrutineeSymT, null /* scope initially empty */);

            sb.AppendLine();

            AppendFormattedLine("SVX.VProgram_API.InPredicate = true;");
            // We list System.Diagnostics.Contracts as a direct dependency as a
            // good practice, even though we'll nearly always get it as an
            // indirect dependency.
            AppendFormattedLine("System.Diagnostics.Contracts.Contract.Assert({0}.{1}({2}));",
                                EmitParticipant(certReq.participantId), certReq.methodName, scrutineeVarName);

            DecreaseIndent();
            AppendFormattedLine("}}");
            DecreaseIndent();
            AppendFormattedLine("}}");
        }