internal override void FinishBind(PythonNameBinder binder) { _contextInfo = CompilationMode.GetContext(); // create global variables for compiler context. PythonGlobal[] globalArray = new PythonGlobal[Variables == null ? 0 : Variables.Count]; Dictionary <string, PythonGlobal> globals = new Dictionary <string, PythonGlobal>(); GlobalDictionaryStorage storage = new GlobalDictionaryStorage(globals, globalArray); var modContext = _modContext = new ModuleContext(new PythonDictionary(storage), PyContext); #if FEATURE_REFEMIT if (_mode == CompilationMode.ToDisk) { _arrayExpression = _globalArray; } else #endif { var newArray = new ConstantExpression(globalArray); newArray.Parent = this; _arrayExpression = newArray; } if (Variables != null) { int globalIndex = 0; foreach (PythonVariable variable in Variables.Values) { PythonGlobal global = new PythonGlobal(modContext.GlobalContext, variable.Name); _globalVariables[variable] = CompilationMode.GetGlobal(GetGlobalContext(), globals.Count, variable, global); globalArray[globalIndex++] = globals[variable.Name] = global; } } CompilationMode.PublishContext(modContext.GlobalContext, _contextInfo); }
internal override void FinishBind(PythonNameBinder binder) { _contextInfo = CompilationMode.GetContext(); // create global variables for compiler context. PythonGlobal[] globalArray = new PythonGlobal[Variables == null ? 0 : Variables.Count]; Dictionary<string, PythonGlobal> globals = new Dictionary<string, PythonGlobal>(); GlobalDictionaryStorage storage = new GlobalDictionaryStorage(globals, globalArray); var modContext = _modContext = new ModuleContext(new PythonDictionary(storage), PyContext); #if FEATURE_REFEMIT if (_mode == CompilationMode.ToDisk) { _arrayExpression = _globalArray; } else #endif { var newArray = new ConstantExpression(globalArray); newArray.Parent = this; _arrayExpression = newArray; } if (Variables != null) { int globalIndex = 0; foreach (PythonVariable variable in Variables.Values) { PythonGlobal global = new PythonGlobal(modContext.GlobalContext, variable.Name); _globalVariables[variable] = CompilationMode.GetGlobal(GetGlobalContext(), globals.Count, variable, global); globalArray[globalIndex++] = globals[variable.Name] = global; } } CompilationMode.PublishContext(modContext.GlobalContext, _contextInfo); }