コード例 #1
0
    public TypeApply Compile_Method(Method method, Dictionary <TypeParameter, Type> typeArgs, List <TypeParameter> extraTypeParams = null)
    {
        Dictionary <string, TypeParameter> substArgs = new Dictionary <string, TypeParameter>();
        var fullTypeArgs = method.TypeArgs.Concat(extraTypeParams ?? new List <TypeParameter>()).ToList();

        fullTypeArgs.ForEach(t => substArgs.Add(t.Name, t));
        typeArgs = typeArgs.ToDictionary(p => substArgs[p.Key.Name], p => p.Value);
        TypeApply apply = new TypeApply(this, DafnySpec.SanitizedName(method), fullTypeArgs, typeArgs);

        //Console.Error.WriteLine("Compile_Method: " + method + " :: " + method.GetType() + " " + String.Join(",", typeArgs));
        if (!compileMethods.ContainsKey(apply))
        {
            //Console.Error.WriteLine("Compile_Method# " + method + " :: " + method.GetType() + " " + String.Join(",", typeArgs));
            compileMethods.Add(apply, apply);
            var tok     = method.tok;
            var writers = ChooseWriter(tok, method.Name, apply);
            CompileMethodGhost compile = NewCompileMethod(this, method, apply,
                                                          writers.Item1, writers.Item2, writers.Item3, writers.Item4);
            if (writers.Item3 == "Seq" && typeArgs.Count == 1)
            {
                compile.visibleElementType = new List <Type>(apply.typeArgs.Values)[0];
            }
            compile.minVerify = minVerify;
            try
            {
                compile.Compile();
            }
            catch (Exception e)
            {
                throw new Exception("while compiling method " + method.Name, e);
            }
        }
        return(apply);
    }
コード例 #2
0
ファイル: DafnySpec.cs プロジェクト: Paul1nh0/Singularity
    public TypeApply Compile_Method(Method method, Dictionary <TypeParameter, Type> typeArgs)
    {
        Dictionary <string, TypeParameter> substArgs = new Dictionary <string, TypeParameter>();

        method.TypeArgs.ForEach(t => substArgs.Add(t.Name, t));
        typeArgs = typeArgs.ToDictionary(p => substArgs[p.Key.Name], p => p.Value);
        TypeApply apply = new TypeApply(this, method.FullSanitizedName, method.TypeArgs, typeArgs);

        if (!compileMethods.ContainsKey(apply))
        {
            compileMethods.Add(apply, apply);
            var tok     = method.tok;
            var writers = ChooseWriter(tok, method.Name, apply);
            CompileMethodGhost compile = NewCompileMethod(this, method, apply,
                                                          writers.Item1, writers.Item2, writers.Item3, writers.Item4);
            if (writers.Item3 == "Seq" && typeArgs.Count == 1)
            {
                compile.visibleElementType = new List <Type>(apply.typeArgs.Values)[0];
            }
            compile.minVerify = minVerify;
            try
            {
                compile.Compile();
            }
            catch (Exception e)
            {
                throw new Exception("while compiling method " + method.Name, e);
            }
        }
        return(apply);
    }