示例#1
0
文件: DocTree.cs 项目: nhweston/dfy
        private FunctionNode ToFunctionNode(Function f)
        {
            Console.WriteLine("Function: " + f.Name);
            var dc        = new DocComment(f.DocComment);
            var modifiers = new List <string>();

            if (f.IsGhost)
            {
                modifiers.Add("ghost");
            }
            if (f.IsStatic)
            {
                modifiers.Add("static");
            }
            var token = ToTokenNode(f.tok);
            var spec  = new List <SpecNode>();

            foreach (var req in f.Req)
            {
                spec.Add(ToSpecNode(req, "requires", token));
            }
            foreach (var ens in f.Ens)
            {
                spec.Add(ToSpecNode(ens, "ensures", token));
            }
            foreach (var reads in f.Reads)
            {
                spec.Add(ToSpecNode(reads, "reads", token));
            }
            spec.Add(ToSpecNode(f.Decreases, "decreases", token));
            return(new FunctionNode {
                Name = f.Name,
                Kind =
                    f is GreatestPredicate ? "greatest predicate"
          : f is LeastPredicate ? "least predicate"
          : f is Predicate || f is TwoStatePredicate ?
                    f.IsGhost ? "predicate"
            : "predicate method"
          : f.IsGhost ? "function"
          : "function method",
                Modifiers = modifiers,
                TypeParams = f.TypeArgs.Select(tp => ToTypeParamNode(tp, dc)).ToList(),
                ValueParams = f.Formals.Select(vp => ToValueParamNode(vp, dc, false)).ToList(),
                ReturnType = ToTypeRefNode(f.ResultType, token),
                Spec = spec,
                UserDoc = dc.MainBody,
                Token = token,
            });
        }
        public override void Visit(Function o)
        {
            var symbol = CreateSymbol(
                name: o.Name,
                kind: Kind.Function,
                type: o.ResultType,

                positionAsToken: o.tok,
                bodyStartPosAsToken: o.BodyStartTok,
                bodyEndPosAsToken: o.BodyEndTok,

                isDeclaration: true,
                declarationSymbol: null,
                addUsageAtDeclaration: false,

                canHaveChildren: true,
                canBeUsed: true
                );

            SetScope(symbol);
        }
 public override void Leave(Function o)
 {
 }
 public override void Visit(Function o)
 {
 }
 public override void Leave(Function o)
 {
     JumpUpInScope();
 }
示例#6
0
        public override void Visit(Function o)
        {
            var preDeclaredSymbol = FindDeclaration(o.Name, SurroundingScope, Kind.Function);

            SetScope(preDeclaredSymbol);
        }