Esempio n. 1
0
        public virtual Method GetMethodRecursively(string name, bool check_self)
        {
            Method p = null;

            if (check_self)
            {
                p = GetMethod(name);
            }
            if (p == null && Parent != null)
            {
                p = Parent.GetMethodRecursively(name, true);
            }

            if (check_self && p == null)
            {
                foreach (string iface in interfaces)
                {
                    ClassBase igen = SymbolTable.Table.GetClassGen(iface);
                    if (igen == null)
                    {
                        continue;
                    }
                    p = igen.GetMethodRecursively(name, true);
                    if (p != null)
                    {
                        break;
                    }
                }
            }

            return(p);
        }
Esempio n. 2
0
        private void GenerateDeclCommon(StreamWriter sw, ClassBase implementor)
        {
            if (IsStatic)
            {
                sw.Write("static ");
            }
            sw.Write(Safety);
            Method dup = null;

            if (container_type != null)
            {
                dup = container_type.GetMethodRecursively(Name);
            }
            if (implementor != null)
            {
                dup = implementor.GetMethodRecursively(Name);
            }

            if (Name == "ToString" && Parameters.Count == 0 && (!(container_type is InterfaceGen) || implementor != null))
            {
                sw.Write("override ");
            }
            else if (Name == "GetGType" && (container_type is ObjectGen || (container_type.Parent != null && container_type.Parent.Methods.ContainsKey("GetType"))))
            {
                sw.Write("new ");
            }
            else if (Modifiers == "new " || (dup != null && ((dup.Signature != null && Signature != null && dup.Signature.ToString() == Signature.ToString()) || (dup.Signature == null && Signature == null))))
            {
                sw.Write("new ");
            }

            if (Name.StartsWith(container_type.Name))
            {
                Name = Name.Substring(container_type.Name.Length);
            }

            if (is_get || is_set)
            {
                if (retval.IsVoid)
                {
                    sw.Write(Parameters.AccessorReturnType);
                }
                else
                {
                    sw.Write(retval.CSType);
                }
                sw.Write(" ");
                if (Name.StartsWith("Get") || Name.StartsWith("Set"))
                {
                    sw.Write(Name.Substring(3));
                }
                else
                {
                    int dot = Name.LastIndexOf('.');
                    if (dot != -1 && (Name.Substring(dot + 1, 3) == "Get" || Name.Substring(dot + 1, 3) == "Set"))
                    {
                        sw.Write(Name.Substring(0, dot + 1) + Name.Substring(dot + 4));
                    }
                    else
                    {
                        sw.Write(Name);
                    }
                }
                sw.WriteLine(" { ");
            }
            else if (IsAccessor)
            {
                sw.Write(Signature.AccessorType + " " + Name + "(" + Signature.AsAccessor + ")");
            }
            else
            {
                sw.Write(retval.CSType + " " + Name + "(" + (Signature != null ? Signature.ToString() : "") + ")");
            }
        }
Esempio n. 3
0
        private void GenerateDeclCommon(StreamWriter sw, ClassBase implementor)
        {
            if (IsStatic)
                sw.Write("static ");
            sw.Write (Safety);
            Method dup = null;
            if (container_type != null)
                dup = container_type.GetMethodRecursively (Name);
            if (implementor != null)
                dup = implementor.GetMethodRecursively (Name);

            if (Name == "ToString" && Parameters.Count == 0)
                sw.Write("override ");
            else if (Name == "GetGType" && container_type is ObjectGen)
                sw.Write("new ");
            else if (Modifiers == "new " || (dup != null && ((dup.Signature != null && Signature != null && dup.Signature.ToString() == Signature.ToString()) || (dup.Signature == null && Signature == null))))
                sw.Write("new ");

            if (is_get || is_set) {
                if (retval.IsVoid)
                    sw.Write (Parameters.AccessorReturnType);
                else
                    sw.Write(retval.CSType);
                sw.Write(" ");
                if (Name.StartsWith ("Get") || Name.StartsWith ("Set"))
                    sw.Write (Name.Substring (3));
                else {
                    int dot = Name.LastIndexOf ('.');
                    if (dot != -1 && (Name.Substring (dot + 1, 3) == "Get" || Name.Substring (dot + 1, 3) == "Set"))
                        sw.Write (Name.Substring (0, dot + 1) + Name.Substring (dot + 4));
                    else
                        sw.Write (Name);
                }
                sw.WriteLine(" { ");
            } else if (IsAccessor) {
                sw.Write (Signature.AccessorType + " " + Name + "(" + Signature.AsAccessor + ")");
            } else {
                sw.Write(retval.CSType + " " + Name + "(" + (Signature != null ? Signature.ToString() : "") + ")");
            }
        }