Provides optimized and cacheable support for scope storage. This is the default object used for storing values in a scope.
The implementation uses a case-insensitive dictionary which holds onto ScopeVariableIgnoreCase objects. The SVIC's hold onto ScopeVariable objects for each possible casing.
Inheritance: IDynamicMetaObjectProvider
        public void LoadInfo(ScopeStorage scope)
        {
            Dictionary<string, AType> functions = ExtractFunctions(scope);

            foreach (KeyValuePair<string, AType> function in functions)
            {
                AFunc func = function.Value.Data as AFunc;

                if (func.Valence <= 1)
                {
                    // skip the niladic functions
                    continue;
                }

                if (func.IsOperator)
                {
                    if (func.IsDyadic)
                    {
                        this.dyadicOperators.Add(function.Key);
                    }
                    else
                    {
                        this.monadicOperators.Add(function.Key);
                    }
                }
                else
                {
                    this.globalFunctions.Add(function.Key);
                }
            }
        }
示例#2
0
 public Meta(Expression parameter, ScopeStorage storage)
     : base(parameter, BindingRestrictions.Empty, storage) {
 }
示例#3
0
 public Meta(Expression parameter, ScopeStorage storage)
     : base(parameter, BindingRestrictions.Empty, storage)
 {
 }
        private static Dictionary<string, AType> ExtractFunctions(ScopeStorage scope)
        {
            Dictionary<string, AType> functions = new Dictionary<string, AType>();

            if (scope == null)
            {
                return functions;
            }

            foreach (KeyValuePair<string, object> context in scope.GetItems())
            {
                ICollection<KeyValuePair<string, object>> contextItems =
                    context.Value as ICollection<KeyValuePair<string, object>>;

                if (contextItems == null)
                {
                    ScopeStorage test = context.Value as ScopeStorage;
                    if (test == null)
                    {
                        continue;
                    }

                    contextItems = test.GetItems();
                }

                foreach (KeyValuePair<string, object> variableInfo in contextItems)
                {
                    AType variable = variableInfo.Value as AType;

                    if (variable != null && variable.Type == ATypes.AFunc && !variable.IsBox)
                    {
                        string[] parts = VariableHelper.CreateContextParts(context.Key, variableInfo.Key);
                        if (parts[0].Contains("."))
                        {
                            parts[0] = "";
                        }

                        string id = string.Join(".", parts);
                        functions.Add(id, variable);
                    }
                }
            }

            return functions;
        }