Beispiel #1
0
        public static string ParseCheck(List <string> modules, string name, out Program program)
        {
            LiteralExpr.MakeBigInt = new MakeBigInt(s => new LiteralExpr(BigInteger.Parse(s)));
            program = new Program(modules.ConvertAll(m => new ModuleDefinition(m, Parser.parse(m))));

            Resolver resolver = new Resolver(program);

            Resolve(resolver, program);

            List <MemberDecl> fullFunctions = new List <MemberDecl>();

            foreach (MemberDecl member in ClassDecl.TheClass.Members)
            {
                Function fun = member as Function;
                if (fun != null && Attributes.Contains(fun.Attributes, "opaque"))
                {
                    Function full = new Function(fun.tok, fun.Attributes, "#" + fun.Name + "_FULL",
                                                 fun.IsGhost, fun.TypeArgs, fun.Formals, fun.ResultType, fun.Req, fun.Ens,
                                                 fun.Decreases, fun.Body);
                    full.IsRecursive = fun.IsRecursive;
                    fun.Body         = null;
                    fullFunctions.Add(full);
                }
            }
            ClassDecl.TheClass.Members.AddRange(fullFunctions);

            AutoReq autoReq = new AutoReq(resolver);

            foreach (MemberDecl member in ClassDecl.TheClass.Members)
            {
                Function fun    = member as Function;
                Method   method = member as Method;
                if (fun != null)
                {
                    autoReq.ReqFunction(fun);
                }
                if (method != null)
                {
                    autoReq.ReqMethod(method);
                }
            }

            Resolve(resolver, program);

            return(null);
        }
Beispiel #2
0
    public static string ParseCheck(List<string> modules, string name, out Program program)
    {
        LiteralExpr.MakeBigInt = new MakeBigInt(s => new LiteralExpr(BigInteger.Parse(s)));
        program = new Program(modules.ConvertAll(m => new ModuleDefinition(m, Parser.parse(m))));

        Resolver resolver = new Resolver(program);
        Resolve(resolver, program);

        List<MemberDecl> fullFunctions = new List<MemberDecl>();
        foreach (MemberDecl member in ClassDecl.TheClass.Members)
        {
            Function fun = member as Function;
            if (fun != null && Attributes.Contains(fun.Attributes, "opaque"))
            {
                Function full = new Function(fun.tok, fun.Attributes, "#" + fun.Name + "_FULL",
                    fun.IsGhost, fun.TypeArgs, fun.Formals, fun.ResultType, fun.Req, fun.Ens,
                    fun.Decreases, fun.Body);
                full.IsRecursive = fun.IsRecursive;
                fun.Body = null;
                fullFunctions.Add(full);
            }
        }
        ClassDecl.TheClass.Members.AddRange(fullFunctions);

        AutoReq autoReq = new AutoReq(resolver);
        foreach (MemberDecl member in ClassDecl.TheClass.Members)
        {
            Function fun = member as Function;
            Method method = member as Method;
            if (fun != null) { autoReq.ReqFunction(fun); }
            if (method != null) { autoReq.ReqMethod(method);}
        }

        Resolve(resolver, program);

        return null;
    }