/// <summary>
        /// Create the binding object (association) for the pool in the global name scope (system dictionary).
        /// </summary>
        /// <param name="installer">Context within which the binding is to be created.</param>
        /// <returns>Returns true if successful, otherwise false.</returns>
        protected internal override bool CreateGlobalBinding(IDefinitionInstallerContext installer)
        {
            if (installer == null)
            {
                throw new ArgumentNullException();
            }
            // 1. Check if the name is not complete garbage.
            if (!IronSmalltalk.Common.Utilities.ValidateIdentifier(this.Name.Value))
            {
                return(installer.ReportError(this.Name, InstallerErrors.PoolInvalidName));
            }
            // 2. Check if there is already a global with that name in the inner name scope
            Symbol name = installer.Runtime.GetSymbol(this.Name.Value);
            IDiscreteGlobalBinding existingBinding = installer.GetLocalGlobalBinding(name);

            if (existingBinding != null)
            {
                return(installer.ReportError(this.Name, InstallerErrors.PoolNameNotUnique));
            }
            // 3. No global defined in the inner scope, but check the scopes (inner or outer) for protected names like Object etc.
            if (installer.IsProtectedName(name))
            {
                return(installer.ReportError(this.Name, InstallerErrors.PoolNameProtected));
            }
            if (IronSmalltalk.Common.GlobalConstants.ReservedIdentifiers.Contains(this.Name.Value))
            {
                return(installer.ReportError(this.Name, InstallerErrors.PoolReservedName));
            }

            // 4. OK ... create a binding - so far pointing to null.
            installer.AddPoolBinding(new PoolBinding(name));
            return(true);
        }
Beispiel #2
0
        public IDiscreteGlobalBinding GetGlobalBinding(Symbol name)
        {
            IDiscreteGlobalBinding result = this.GetLocalGlobalBinding(name);

            if ((result == null) && (this.OuterScope != null))
            {
                return(this.OuterScope.GetGlobalBinding(name));
            }
            return(result);
        }
        public static string GetMoniker(IDiscreteGlobalBinding binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException();
            }

            return(DiscreteBindingCallSiteBinderBase.GetMoniker(
                       DiscreteBindingCallSiteBinderBase.GlobalPrefix,
                       binding.Name.Value));
        }