PERWAPI.PDBWriter.OpenScope C# (CSharp) Method

OpenScope() public method

Open a new scope.
public OpenScope ( int offset ) : void
offset int Offset as to where the scope should start.
return void
        public void OpenScope(int offset)
        {
            // Make sure we are in a method
            if (currentMethod == null)
                throw new Exception("You can not open a scope before opening a method.");

            // Create and add the new scope
            Scope scope = new Scope();
            scope.OffsetStart = offset;
            scope.ParentScope = currentScope;

            // Check if this is the first/root scope or a child scope.
            if (currentScope == null) {

                // Check to make sure we don't try to create two root scopes.
                if (currentMethod.Scope != null)
                    throw new Exception("Only one top-most scope is permitted.");

                currentMethod.Scope = scope;
            } else {
                currentScope.ChildScopes.Add(scope);
            }

            // Set the current scope
            currentScope = scope;
        }