private static GetBindingStrategyBase ParseGetBindingStrategy(string moniker)
        {
            string[] monikerParts = DiscreteBindingCallSiteBinderBase.ParseMoniker(moniker);
            for (int i = 0; i < monikerParts.Length; i++)
            {
                if (String.IsNullOrWhiteSpace(monikerParts[i]))
                {
                    throw new ImplementationException(String.Format("Invalid discrete binding moniker ({0})", moniker));
                }
            }

            if (monikerParts.Length < 1)
            {
                throw new ImplementationException(String.Format("Invalid discrete binding moniker ({0})", moniker));
            }
            string type = monikerParts[0];

            if ((type == DiscreteBindingCallSiteBinderBase.GlobalPrefix) && (monikerParts.Length == 2))
            {
                return(new GetGlobalBindingStrategy(monikerParts[1]));
            }
            if ((type == DiscreteBindingCallSiteBinderBase.ClassVariablePrefix) && (monikerParts.Length == 3))
            {
                return(new GetClassVariableBindingStrategy(monikerParts[1], monikerParts[2]));
            }
            if ((type == DiscreteBindingCallSiteBinderBase.PoolItemPrefix) && (monikerParts.Length == 3))
            {
                return(new GetPoolItemBindingStrategy(monikerParts[1], monikerParts[2]));
            }
            throw new ImplementationException(String.Format("Invalid discrete binding moniker ({0})", moniker));
        }
 public DiscreteBindingCallSiteBinderBase(string moniker)
 {
     if (moniker == null)
     {
         throw new ArgumentNullException("moniker");
     }
     this.Moniker            = moniker;
     this.GetBindingStrategy = DiscreteBindingCallSiteBinderBase.ParseGetBindingStrategy(moniker);
 }
        public static string GetMoniker(IDiscreteGlobalBinding binding)
        {
            if (binding == null)
            {
                throw new ArgumentNullException();
            }

            return(DiscreteBindingCallSiteBinderBase.GetMoniker(
                       DiscreteBindingCallSiteBinderBase.GlobalPrefix,
                       binding.Name.Value));
        }
        protected override Expression GetExpression(ExecutionContext executionContext)
        {
            IDiscreteBinding binding = this.GetBindingStrategy.GetBinding(executionContext);

            if (binding == null)
            {
                throw new CodeGenerationException(String.Format("Could not find global binding {0}. This may indicate a bug in our code.", this.Moniker));
            }
            return(Expression.Property(
                       Expression.Constant(binding, binding.GetType()),
                       DiscreteBindingCallSiteBinderBase.GetPropertyInfo(binding.GetType())));
        }
        public static string GetMoniker(PoolBinding poolBinding, PoolVariableOrConstantBinding binding)
        {
            if (poolBinding == null)
            {
                throw new ArgumentNullException("poolBinding");
            }
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            return(DiscreteBindingCallSiteBinderBase.GetMoniker(
                       DiscreteBindingCallSiteBinderBase.PoolItemPrefix,
                       poolBinding.Name.Value,
                       binding.Name.Value));
        }
        public static string GetMoniker(SmalltalkClass cls, ClassVariableBinding binding)
        {
            if (cls == null)
            {
                throw new ArgumentNullException("cls");
            }
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

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