Esempio n. 1
0
        ///////////////////////////////////////////////////////////////////////

        internal StringList GetDefined(
            Interpreter interpreter,
            string pattern
            )
        {
            StringList result = new StringList();

            foreach (KeyValuePair <string, IVariable> pair in this)
            {
                IVariable variable = pair.Value;

                if (variable == null)
                {
                    continue;
                }

                if (EntityOps.IsUndefined(variable))
                {
                    continue;
                }

                string name = variable.Name;

                if ((pattern == null) || StringOps.Match(
                        interpreter, StringOps.DefaultMatchMode,
                        name, pattern, false))
                {
                    result.Add(name);
                }
            }

            return(result);
        }
Esempio n. 2
0
        ///////////////////////////////////////////////////////////////////////

        internal StringList GetLocals(
            Interpreter interpreter,
            string pattern
            )
        {
            if (pattern != null)
            {
                pattern = ScriptOps.MakeVariableName(pattern);
            }

            StringList result = new StringList();

            foreach (KeyValuePair <string, IVariable> pair in this)
            {
                IVariable variable = pair.Value;

                if (variable == null)
                {
                    continue;
                }

                if (EntityOps.IsUndefined(variable) ||
                    EntityOps.IsLink(variable))
                {
                    continue;
                }

                ICallFrame frame = CallFrameOps.FollowNext(variable.Frame);

                if (interpreter != null)
                {
                    if (interpreter.IsGlobalCallFrame(frame))
                    {
                        continue;
                    }

                    if (Interpreter.IsNamespaceCallFrame(frame))
                    {
                        continue;
                    }
                }

                string name = variable.Name;

                if ((pattern == null) || StringOps.Match(
                        interpreter, StringOps.DefaultMatchMode,
                        name, pattern, false))
                {
                    result.Add(name);
                }
            }

            return(result);
        }
Esempio n. 3
0
        ///////////////////////////////////////////////////////////////////////

        internal int SetUndefined(
            Interpreter interpreter,
            string pattern,
            bool undefined
            )
        {
            int result = 0;

            foreach (KeyValuePair <string, IVariable> pair in this)
            {
                IVariable variable = pair.Value;

                if (variable == null)
                {
                    continue;
                }

                //
                // NOTE: This method is EXEMPT from the normal requirement
                //       that all the variables operated on must be defined.
                //
                // if (EntityOps.IsUndefined(variable))
                //     continue;

                string name = variable.Name;

                if ((pattern == null) || StringOps.Match(
                        interpreter, StringOps.DefaultMatchMode,
                        name, pattern, false))
                {
                    if (EntityOps.IsUndefined(variable) == undefined)
                    {
                        continue;
                    }

                    if (EntityOps.SetUndefined(variable, undefined))
                    {
                        result++;
                    }
                }
            }

            return(result);
        }
Esempio n. 4
0
        ///////////////////////////////////////////////////////////////////////

        #region Private Methods
        internal int SetReadOnly(
            Interpreter interpreter,
            string pattern,
            bool readOnly
            )
        {
            int result = 0;

            foreach (KeyValuePair <string, IVariable> pair in this)
            {
                IVariable variable = pair.Value;

                if (variable == null)
                {
                    continue;
                }

                if (EntityOps.IsUndefined(variable))
                {
                    continue;
                }

                string name = variable.Name;

                if ((pattern == null) || StringOps.Match(
                        interpreter, StringOps.DefaultMatchMode,
                        name, pattern, false))
                {
                    if (EntityOps.IsReadOnly(variable) == readOnly)
                    {
                        continue;
                    }

                    if (EntityOps.SetReadOnly(variable, readOnly))
                    {
                        result++;
                    }
                }
            }

            return(result);
        }