Exemplo n.º 1
0
        public uint WalkMemoryBack(Scope until)
        {
            uint memory = 0;
            Scope current = this;

            while(current != until)
            {
                if (current == null)
                    throw new InvalidOperationException("Reached top-level scope without finding needle while walking memory");

                if(current != this)
                    memory += current.MemorySpace;

                current = current.Parent;
            }

            memory += current.MemorySpace;

            return memory;
        }
Exemplo n.º 2
0
        public Scope PushScope(Scope scope)
        {
            if (scopeStack.Count > 0)
                scope.Parent = scopeStack.Peek();

            scopeStack.Push(scope);
            return scope;
        }