Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Scope"/> class.
        /// </summary>
        /// <param name="method">Gets the method that contains the scope.</param>
        /// <param name="unsafe">Whether the scope contains unsafe variables.</param>
        public Scope(IMethod method, bool @unsafe = false)
        {
            // Increment ID
            ID = _nextScopeID++;

            // Create stack segment
            StackValues = new StackSegment(this);

            // Misc
            Method = method;
            Unsafe = @unsafe;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the <see cref="Scope"/> class with the specified parent.
        /// </summary>
        /// <param name="parent">The parent scope of the current instance.</param>
        /// <param name="unsafe">Whether the scope has unsafe variables or not.</param>
        public Scope(Scope parent, bool @unsafe = false)
        {
            // Increment ID
            ID = _nextScopeID++;

            // Register as child of parent
            Parent = parent;
            parent.AddChild(this);

            // Create stack segment
            // (Must happen after setting parent)
            StackValues = new StackSegment(this);

            // Misc
            Method = parent.Method;
            Unsafe = parent.Unsafe || @unsafe;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers the <see cref="StackValue"/> with the specified <see cref="StackSegment"/>. For internal use only.
        /// </summary>
        /// <param name="stack">The <see cref="StackSegment"/> to register the <see cref="StackValue"/> to.</param>
        public void UpdateInfo(StackSegment stack)
        {
            // Check if previously registered
            if (_registered)
            {
                throw new InvalidOperationException("StackValue already registered to a StackSegment.");
            }

            // Not previously registered

            // Set relative stack start index
            StackStart = stack.GetNextIndex();

            // Set scope
            Scope = stack.Scope;

            // Mark as registered
            _registered = true;
        }