IronPython.Compiler.Ast.FunctionDefinition.CompileAssignment C# (CSharp) Метод

CompileAssignment() приватный статический Метод

private static CompileAssignment ( LightCompiler compiler, System.Linq.Expressions variable, Action compileValue ) : void
compiler LightCompiler
variable System.Linq.Expressions
compileValue Action
Результат void
        private static void CompileAssignment(LightCompiler compiler, MSAst.Expression variable, Action<LightCompiler> compileValue) {
            var instructions = compiler.Instructions;

            ClosureExpression closure = variable as ClosureExpression;
            if (closure != null) {
                compiler.Compile(closure.ClosureCell);
            }
            LookupGlobalVariable lookup = variable as LookupGlobalVariable;
            if (lookup != null) {
                compiler.Compile(lookup.CodeContext);
                instructions.EmitLoad(lookup.Name);
            }

            compileValue(compiler);

            if (closure != null) {
                instructions.EmitStoreField(ClosureExpression._cellField);
                return;
            }
            if (lookup != null) {
                instructions.EmitCall(typeof(PythonOps).GetMethod(lookup.IsLocal ? "SetLocal" : "SetGlobal"));
                return;
            }

            MSAst.ParameterExpression functionValueParam = variable as MSAst.ParameterExpression;
            if (functionValueParam != null) {
                instructions.EmitStoreLocal(compiler.Locals.GetLocalIndex(functionValueParam));
                return;
            }

            var globalVar = variable as PythonGlobalVariableExpression;
            if (globalVar != null) {
                instructions.Emit(new PythonSetGlobalInstruction(globalVar.Global));
                instructions.EmitPop();
                return;
            }
            Debug.Assert(false, "Unsupported variable type for light compiling function");
        }