public static IEnumerable<UnifiedFunctionDefinition> FindFunctionCollision(UnifiedElement element, UnifiedFunctionDefinition target)
        {
            foreach (var function in element.Descendants<UnifiedFunctionDefinition>())
            {
                if (IsFunctionCollision(function, target))
                {
                    yield return function;
                }

            }
        }
        // 関数定義(UnifiedFunctionDefinition)
        public override bool Visit(
				UnifiedFunctionDefinition element, VisitorArgument arg)
        {
            // int main(int param) { ... };
            element.Modifiers.TryAccept(this, arg);
            element.Type.TryAccept(this, arg);
            Writer.Write(" ");
            element.Name.TryAccept(this, arg);
            element.Parameters.TryAccept(this, arg);
            element.Body.TryAccept(this, arg.Set(ForBlock));
            return element.Body == null;
        }
        private static Boolean IsFunctionCollision(UnifiedFunctionDefinition src, UnifiedFunctionDefinition dst)
        {
            // Judge whether src and dst have same signature
            var judges = new List<Boolean>();
            judges.Add(src.Name.Name == dst.Name.Name);
            judges.Add(src.Parameters.All(e => dst.Parameters.Any(e.Equals)));

            if (judges.All(e => e))
            {
                return true;
            }
            return false;
        }
        public override bool Visit(
                UnifiedFunctionDefinition element, VisitorArgument arg)
        {
            element.Annotations.TryAccept(this, arg);
            element.Modifiers.TryAccept(this, arg);
            Writer.Write("def ");
            element.Name.TryAccept(this, arg);
            element.Parameters.TryAccept(this, arg);
            Writer.WriteLine(":");

            element.Body.TryAccept(this, arg.IncrementDepth());
            return false;
        }
Ejemplo n.º 5
0
 public override bool Visit(
     UnifiedFunctionDefinition element, VisitorArgument arg)
 {
     element.Annotations.TryAccept(this, arg);
     element.Modifiers.TryAccept(this, arg);
     element.Type.TryAccept(this, arg);
     Writer.Write(" ");
     element.Name.TryAccept(this, arg);
     element.GenericParameters.TryAccept(this, arg);
     element.Parameters.TryAccept(this, arg);
     element.Throws.TryAccept(this, arg);
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return element.Body == null;
 }
Ejemplo n.º 6
0
        public static Namespace GetNamespace(
            UnifiedFunctionDefinition functionNode)
        {
            var type = NamespaceType.Function;
            var functionName = functionNode.Name.Name;
            var parents =
                    DetectorHelper.GetParentTypes(type).Select(
                            t => DetectorHelper.Namespace2UnifiedType(t));
            var parentNode = DetectorHelper.GetFirstFoundNode(
                    functionNode, parents);

            return new Namespace {
                    Value = functionName,
                    NamespaceType = type,
                    Parent = Dispatcher(parentNode),
            };
        }
 //関数定義 : e.g. function hoge() { }
 public override bool Visit(
         UnifiedFunctionDefinition element, VisitorArgument arg)
 {
     WriteIndent(arg.IndentDepth);
     Writer.Write("function ");
     element.Name.TryAccept(this, arg);
     element.Parameters.TryAccept(this, arg);
     element.Body.TryAccept(this, arg.Set(ForBlock));
     return element.Body == null;
 }