Example #1
0
        /// <inheritdoc />
        public GraceObject FindReceiver(MethodRequest req, int skipRedirects)
        {
            ScopeLink   sl      = scope;
            GraceObject capture = null;

            while (sl != null && sl.scope != null)
            {
                if (skipRedirects > 0 &&
                    sl.scope.HasFlag(GraceObject.Flags.ObjectConstructor))
                {
                    sl = sl.next;
                    skipRedirects--;
                    continue;
                }
                if (sl.scope.RespondsTo(req))
                {
                    return(capture ?? sl.scope);
                }
                capture = null;
                var ls = sl.scope as LocalScope;
                if (ls != null)
                {
                    if (ls.RedirectSurrounding != null)
                    {
                        capture = ls.RedirectSurrounding;
                    }
                }
                sl = sl.next;
            }
            return(null);
        }
Example #2
0
 /// <param name="next">Next element in the list, or null</param>
 /// <param name="scope">Grace object to be used as a scope</param>
 /// <param name="minor">True if this link represents a "minor"
 /// scope that is used for internal names</param>
 public ScopeLink(ScopeLink next, GraceObject scope,
                  bool minor)
 {
     this.next  = next;
     this.scope = scope;
     this.minor = minor;
 }
Example #3
0
 /// <inheritdoc />
 public void RestoreExactly(ScopeMemo sm)
 {
     scope = sm.Link;
     while (dynamics.Count > sm.dynamicsSize)
     {
         dynamics.Pop();
     }
     restoreMajor();
 }
Example #4
0
        /// <summary>Set the majorScope field to the closest non-minor
        /// scope</summary>
        private void restoreMajor()
        {
            ScopeLink s = scope;

            while (s.minor)
            {
                s = s.next;
            }
            majorScope = s.scope;
        }
Example #5
0
        /// <inheritdoc />
        /// <seealso cref="ActivateDebuggingMessages" />
        public void DebugScopes()
        {
            ScopeLink s = scope;

            while (s != null && s.scope != null)
            {
                Debug("Scope " + s.scope);
                foreach (string k in s.scope.MethodNames())
                {
                    Debug("    " + k);
                }
                s = s.next;
            }
        }
Example #6
0
        /// <inheritdoc />
        public MethodScope FindNearestMethod()
        {
            ScopeLink sl = scope;

            while (sl != null && sl.scope != null)
            {
                var ms = sl.scope as MethodScope;
                if (ms != null)
                {
                    return(ms);
                }
                sl = sl.next;
            }
            return(null);
        }
Example #7
0
        /// <inheritdoc />
        public void InsertOuter(GraceObject obj)
        {
            var s = scope;

            while (s != null)
            {
                if (s.scope.HasFlag(GraceObject.Flags.ObjectConstructor))
                {
                    break;
                }
                s = s.next;
            }
            var newScope = new ScopeLink(s.next, obj);

            s.next = newScope;
        }
Example #8
0
        /// <inheritdoc />
        public string ScopeStringList()
        {
            string    ret = null;
            ScopeLink s   = scope;

            while (s != null && s.scope != null)
            {
                if (ret != null)
                {
                    ret += ", " + s.scope;
                }
                else
                {
                    ret = "" + s.scope;
                }
                s = s.next;
            }
            return(ret);
        }
Example #9
0
 /// <inheritdoc />
 public void Forget(ScopeMemo sm)
 {
     scope = dynamics.Pop();
     restoreMajor();
 }
Example #10
0
 /// <inheritdoc />
 public void Remember(ScopeMemo sm)
 {
     dynamics.Push(scope);
     scope = sm.Link;
     restoreMajor();
 }
Example #11
0
 /// <inheritdoc />
 public void Unextend(GraceObject o)
 {
     scope = scope.next;
     restoreMajor();
 }
Example #12
0
 /// <inheritdoc />
 public void ExtendMinor(GraceObject o)
 {
     scope = new ScopeLink(scope, o, true);
 }
Example #13
0
 /// <inheritdoc />
 public void Extend(GraceObject o)
 {
     scope      = new ScopeLink(scope, o);
     majorScope = scope.scope;
 }
Example #14
0
 /// <param name="link">Top of the static scope stack</param>
 /// <param name="dynamics">Size of the dynamic stack</param>
 internal ScopeMemo(ScopeLink link, int dynamics)
 {
     this.link         = link;
     this.dynamicsSize = dynamics;
 }
Example #15
0
 /// <param name="next">Next element in the list, or null</param>
 /// <param name="scope">Grace object to be used as a scope</param>
 public ScopeLink(ScopeLink next, GraceObject scope)
 {
     this.next  = next;
     this.scope = scope;
 }