Exemplo n.º 1
0
        private VariableScope _enter_scope_uncached()
        {
            ops.NameScope     current_name_scope;
            PureVariableScope pure_variable_scope = null;
            VariableScope     entered_pure_variable_scope;

            if (_auxiliary_name_scope)
            {
                // Create a new name scope later
                current_name_scope = null;
            }
            else
            {
                // Reenter the current name scope
                string name_scope = ops.get_name_scope();
                if (!string.IsNullOrEmpty(name_scope))
                {
                    // Hack to reenter
                    name_scope += "/";
                }
                current_name_scope = ops.name_scope(name_scope);
            }

            if (!string.IsNullOrEmpty(_name) || _scope != null)
            {
                var name_scope = _scope == null ? _name : _scope.name.Split('/').Last();
                if (current_name_scope == null)
                {
                    current_name_scope = ops.name_scope(name_scope);
                }
                current_name_scope.__enter__();
                string current_name_scope_name = current_name_scope;
                _current_name_scope = current_name_scope;
                string old_name_scope = _scope == null ? current_name_scope_name : _scope.original_name_scope;

                if (_scope == null)
                {
                    pure_variable_scope = new PureVariableScope(_name, old_name_scope: old_name_scope);
                }
                else
                {
                    pure_variable_scope = new PureVariableScope(_scope, old_name_scope: old_name_scope);
                }
                pure_variable_scope.__enter__();
                entered_pure_variable_scope = pure_variable_scope;
                _cached_pure_variable_scope = pure_variable_scope;
                return(entered_pure_variable_scope);
            }
            else
            {
                current_name_scope = ops.name_scope(_default_name);
                current_name_scope.__enter__();
                string current_name_scope_name = current_name_scope;
                _current_name_scope = current_name_scope;
                string unique_default_name = _get_unique_variable_scope(_default_name);
                pure_variable_scope = new PureVariableScope(unique_default_name,
                                                            old_name_scope: current_name_scope_name);
                pure_variable_scope.__enter__();
                entered_pure_variable_scope = pure_variable_scope;
                _cached_pure_variable_scope = pure_variable_scope;
                return(entered_pure_variable_scope);
            }
        }