예제 #1
0
        private void Init()
        {
            DebugDataList   = new List <DebugData>();
            TopLevelClasses = new List <TopLevelClassDeclaration>();
            Globals         = new List <DatatypeDecl>();

            foreach (var item in DafnyProgram.DefaultModuleDef.TopLevelDecls)
            {
                ClassDecl curDecl = item as ClassDecl;
                if (curDecl != null)
                {
                    var temp = new TopLevelClassDeclaration();

                    foreach (var member in curDecl.Members)
                    {
                        Tactic tac = member as Tactic;
                        if (tac != null)
                        {
                            try {
                                temp.Tactics.Add(tac.Name, tac);
                            }
                            catch (ArgumentException) {
                                Contract.Assert(false, $"tactic {tac.Name} is already declared in the current context");
                            }
                        }
                        else
                        {
                            var tacFun = member as TacticFunction;
                            if (tacFun != null)
                            {
                                temp.Tactics.Add(tacFun.Name, tacFun);
                            }
                            else
                            {
                                temp.Members.Add(member.Name, member);
                            }
                        }
                    }
                    TopLevelClasses.Add(temp);
                }
                else
                {
                    DatatypeDecl dd = item as DatatypeDecl;
                    if (dd != null)
                    {
                        Globals.Add(dd);
                    }
                }
            }
        }
예제 #2
0
파일: ProofState.cs 프로젝트: ggrov/tacny
        /// <summary>
        ///   Fill permanent state information, which will be common across all tactics
        /// </summary>
        /// <param name="program">fresh Dafny program</param>
        private void FillStaticState(Program program)
        {
            Contract.Requires <ArgumentNullException>(program != null);


            foreach (var item in program.DefaultModuleDef.TopLevelDecls)
            {
                var curDecl = item as ClassDecl;
                if (curDecl != null)
                {
                    var temp = new TopLevelClassDeclaration(curDecl.Name);

                    foreach (var member in curDecl.Members)
                    {
                        var tac = member as ITactic;
                        if (tac != null)
                        {
                            temp.Tactics.Add(tac.Name, tac);
                        }
                        else
                        {
                            temp.Members.Add(member.Name, member);
                        }
                    }
                    _topLevelClasses.Add(temp);
                }
                else
                {
                    var dd = item as DatatypeDecl;
                    if (dd != null)
                    {
                        Datatypes.Add(dd.Name, dd);
                    }
                }
            }
        }
예제 #3
0
파일: ProofState.cs 프로젝트: ggrov/tacny
 /// <summary>
 ///   Set active the enclosing TopLevelClass
 /// </summary>
 /// <param name="name"></param>
 public void SetTopLevelClass(string name)
 {
     ActiveClass = _topLevelClasses.FirstOrDefault(x => x.Name == name);
 }