Exemplo n.º 1
0
        internal void SetExplicitInterfaceMember(string name, CMember member, string ifaceName)
        {
            Dictionary <string, CMember> typeDict;

            if (!explicitInterfaces.TryGetValue(ifaceName, out typeDict))
            {
                typeDict = new Dictionary <string, CMember>();
                explicitInterfaces[ifaceName] = typeDict;
            }
            typeDict[name] = member;
        }
Exemplo n.º 2
0
 public void Add(CMember member)
 {
     if (member is CMemberOverload)
     {
         foreach (CMember m in ((CMemberOverload)member).overloads)
         {
             Add(m);
         }
     }
     else
     {
         overloads.Add(member);
     }
 }
Exemplo n.º 3
0
 public void add(CMember member)
 {
     if (member.MemberType == "field")
     {
         add(member.Name, member.Declared[0]);
     }
     else if (member.MemberType == "const")
     {
         add(member.Name, member.Declared[0]);
     }
     else
     {
         funcs[member.Name] = member;
     }
 }
Exemplo n.º 4
0
        public virtual CMember LookupMember(string k)
        {
            CMember direct = GetDirectMember(k);

            if (direct != null)
            {
                return(direct);
            }

            if (BaseClass.Resolved)
            {
                return(BaseClass.ActualType.LookupMember(k));
            }

            return(null);
        }
Exemplo n.º 5
0
        public override CMember LookupMember(string k)
        {
            CMember baseMember = base.LookupMember(k);

            if (baseMember == null)
            {
                foreach (CInterface iface in this.Interfaces)
                {
                    CMember lum = iface.LookupMember(k);
                    if (lum != null)
                    {
                        return(lum);
                    }
                }
            }
            return(baseMember);
        }
Exemplo n.º 6
0
        public virtual String UpdateMembers(IVisitor checker)
        {
            if (types.Count == 0)
            {
                return("Empty enum type used");
            }

            bool isObject = true;

            for (int i = 0; i < types.Count; i++)
            {
                CTypeRef otype = types[i];
                if (!otype.Resolved)
                {
                    CClass ntype = CProgram.Global.FindClass(otype.TypeName);
                    if (ntype == null)
                    {
                        return("Cannot find type " + otype.TypeName.RawValue);
                    }
                    otype.InternalLoad(ntype);
                }
                types[i] = otype;
                types[i].ActualType.Accept(checker);
                isObject = isObject && otype.ActualType.IsObject;
            }
            IsObject = isObject;

            base.ClearMembers();
            Scope.Clear();

            foreach (CMember member in types[0].ActualType.InheritedMemberIterator)
            {
                bool found;
                if (member is CMemberOverload)
                {
                    found = false;
                }
                else// Unions can only access public members
                {
                    found = member.Visibility == TokenTypes.visPublic;
                }


                IEnumerator <CTypeRef> it = types.GetEnumerator();
                it.MoveNext();
                while (found && it.MoveNext())
                {
                    CClass  type     = it.Current.ActualType;
                    CMember luMember = type.LookupMember(member.Name);
                    if (luMember == null)
                    {
                        found = false;
                    }
                    else if (luMember.MemberType != member.MemberType)
                    {
                        // one's a method, the other's a field, or etc...
                        found = false;
                    }
                    else if (luMember.Visibility != TokenTypes.visPublic)
                    {
                        found = false;
                    }
                    else
                    {
                        switch (luMember.MemberType)
                        {
                        case "method":
                            CMethod metho   = (CMethod)member;
                            CMethod luMetho = (CMethod)luMember;
                            // already checked return type, let's try the parameters
                            if (metho.Function.Arguments.Count != luMetho.Function.Arguments.Count)
                            {
                                found = false;
                            }
                            break;

                        case "property":
                            found = UnionProperty((CProperty)member, (CProperty)luMember);
                            // dur
                            break;

                        case "field":
                            // already checked return type, nothing left to check
                            break;

                        case "override":
                            found = false;    // dur
                            break;
                        }
                    }
                }
                if (found)
                {
                    CMember fmember;
                    switch (member.MemberType)
                    {
                    case "method":
                        fmember = new CMethod((CMethod)member, true);
                        break;

                    case "property":
                        fmember = new CProperty((CProperty)member, true);
                        break;

                    case "field":
                        fmember = new CField((CField)member, true);
                        break;

                    case "override":
                        fmember = new CMemberOverload((CMemberOverload)member, true);
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                    SetMember(member.Name, fmember);
                    Scope.add(fmember);
                }
            }

            bool hasDefault = true;

            DefaultMember = null;
            foreach (CTypeRef _class in types)
            {
                var memberBase = ((CClass)types[0]).DefaultMember;
                var member     = _class.ActualType.DefaultMember;
                if (memberBase == null ||
                    member == null ||
                    !UnionProperty((CProperty)memberBase, (CProperty)member))
                {
                    hasDefault = false;
                    break;
                }
            }
            if (hasDefault)
            {
                DefaultMember = ((CClass)types[0]).DefaultMember;
            }

            return(null);
        }
Exemplo n.º 7
0
 public virtual void SetClassMember(string k, CMember v)
 {
     classMembers[k] = v;
 }
Exemplo n.º 8
0
 public virtual void SetMember(string k, CMember v)
 {
     members[k] = v;
 }