Esempio n. 1
0
        /// <summary>
        /// Imports given namespace set.
        /// </summary>
        /// <param name="nss">namespace set to import.</param>
        /// <returns>imported namespace set.</returns>
        public override AbcNamespaceSet Import(AbcNamespaceSet nss)
        {
            if (nss == null)
            {
                return(null);
            }
            if (IsDefined(nss))
            {
                return(nss);
            }

            string key = nss.Key;
            var    set = this[key];

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

            int n          = nss.Count;
            var namespaces = new AbcNamespace[n];

            for (int i = 0; i < n; ++i)
            {
                namespaces[i] = _abc.ImportConst(nss[i]);
            }

            set = new AbcNamespaceSet(namespaces, key);
            Add(set);

            return(set);
        }
Esempio n. 2
0
        public AbcScript DefineNamespaceScript(AbcNamespace ns, string name)
        {
            if (ns == null)
            {
                throw new ArgumentNullException("ns");
            }
            var script = _nsscripts[name] as AbcScript;

            if (script != null)
            {
                return(script);
            }
            ns = ImportConst(ns);

            var traitName = DefineName(QName.Global(name));

            script = new AbcScript
            {
                Initializer = DefineEmptyMethod()
            };
            _nsscripts[name] = script;

            script.Traits.AddConst(BuiltinTypes.Namespace, traitName, ns);

            return(script);
        }
Esempio n. 3
0
 private bool HasNamespace(AbcNamespace ns)
 {
     if (NamespaceSet == null)
     {
         return(false);
     }
     return(((IEnumerable <AbcNamespace>)NamespaceSet).Contains(ns));
 }
Esempio n. 4
0
        /// <summary>
        /// Defines namespace with given name.
        /// </summary>
        /// <param name="kind">kind of namespace to define.</param>
        /// <param name="name">name of namespace to define.</param>
        /// <returns></returns>
        public AbcNamespace DefineNamespace(AbcConstKind kind, AbcConst <string> name)
        {
            string key = name.MakeKey(kind);
            var    ns  = Namespaces[key];

            if (ns != null)
            {
                return(ns);
            }
            ns = new AbcNamespace(name, kind, key);
            Namespaces.Add(ns);
            return(ns);
        }
Esempio n. 5
0
        public AbcMultiname DefineMultiname(AbcConstKind kind, AbcNamespace ns, AbcConst <string> name)
        {
            string key = AbcMultiname.KeyOf(kind, ns, name);
            var    mn  = Multinames[key];

            if (mn != null)
            {
                return(mn);
            }
            mn = new AbcMultiname(kind, ns, name)
            {
                Key = key
            };
            Multinames.Add(mn);
            return(mn);
        }
Esempio n. 6
0
        private static QName GetName(ITypeMember member)
        {
            string name;
            string ns     = "";
            var    nskind = AbcConstKind.PackageNamespace;

            var type = member as IType;
            var attr = member.FindAttribute(Attrs.QName);

            if (attr == null)
            {
                if (type != null)
                {
                    ns = type.Namespace;
                }

                var method = member as IMethod;
                if (method != null && (method.IsGetter() || method.IsSetter()))
                {
                    name = member.Name.Substring(4);
                }
                else
                {
                    name = member.Name;
                }
            }
            else
            {
                int n = attr.Arguments.Count;
                if (n == 0)
                {
                    throw new InvalidOperationException("Invalid qname attribute");
                }

                name = (string)attr.Arguments[0].Value;
                if (n > 1)
                {
                    ns = (string)attr.Arguments[1].Value;
                    string kind = (string)attr.Arguments[2].Value;
                    nskind = AbcNamespace.FromShortNsKind(kind);
                }
            }

            return(new QName {
                Name = name, Namespace = ns, NamespaceKind = nskind
            });
        }
Esempio n. 7
0
        private AbcMultiname ImportQName(AbcNamespace ns, AbcConst <string> name, bool isAttribute)
        {
            var    kind = isAttribute ? AbcConstKind.QNameA : AbcConstKind.QName;
            string key  = AbcMultiname.KeyOf(kind, ns, name);

            var mn = this[key];

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

            name = _abc.ImportConst(name);
            ns   = _abc.ImportConst(ns);

            mn = new AbcMultiname(kind, ns, name)
            {
                Key = key
            };

            Add(mn);
            return(mn);
        }
Esempio n. 8
0
 public AbcMultiname(AbcConstKind kind, AbcNamespace ns, AbcConst <string> name)
 {
     Kind      = kind;
     Namespace = ns;
     Name      = name;
 }
Esempio n. 9
0
 public static string KeyOf(AbcConstKind kind, AbcNamespace ns, AbcConst <string> name)
 {
     return(ns.Key + "." + name.Value + (int)kind);
 }
Esempio n. 10
0
 /// <summary>
 /// Imports <see cref="AbcNamespace"/> constant.
 /// </summary>
 /// <param name="ns">namespace to import.</param>
 /// <returns></returns>
 public AbcNamespace ImportConst(AbcNamespace ns)
 {
     return(Namespaces.Import(ns));
 }
Esempio n. 11
0
        /// <summary>
        /// Defines qname.
        /// </summary>
        /// <param name="ns">namespace of qname to define</param>
        /// <param name="name">name of qname to define</param>
        /// <returns></returns>
        public AbcMultiname DefineQName(AbcNamespace ns, string name)
        {
            var s = DefineString(name);

            return(DefineMultiname(AbcConstKind.QName, ns, s));
        }