• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ReadOnlyCollectionBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ReadOnlyCollectionBuilder的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollectionBuilder类的具体用法?C# ReadOnlyCollectionBuilder怎么用?C# ReadOnlyCollectionBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReadOnlyCollectionBuilder类属于命名空间,在下文中一共展示了ReadOnlyCollectionBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetArgumentValues

        public static IList<KeyValuePair<string, string>> GetArgumentValues(CodeActivityContext context, string argumentStartsWith)
        {
            PropertyDescriptorCollection properties = context.DataContext.GetProperties();
            IList<KeyValuePair<string, string>> arguments = new ReadOnlyCollectionBuilder<KeyValuePair<string, string>>();

            foreach (PropertyDescriptor property in properties)
            {
                // Get the name of the property/argument
                var name = property.DisplayName;

                // must be a string
                if ((property.PropertyType != typeof (string))) continue;

                // if an argumentStartsWith has a value and name starts with it
                if ((!string.IsNullOrWhiteSpace(argumentStartsWith)) && (!name.StartsWith(argumentStartsWith)))
                    continue;

                var value = (string) property.GetValue(context.DataContext);

                // the property/argument must have a value
                if (string.IsNullOrWhiteSpace(value)) continue;

                arguments.Add(new KeyValuePair<string, string>(name, value));
            }

            return arguments;
        }
开发者ID:jricke,项目名称:TfsVersioning,代码行数:27,代码来源:VersioningHelper.cs


示例2: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();

            for (int i = 0; i < _names.Length; i++) {
                statements.Add(
                    // _references[i] = PythonOps.Import(<code context>, _names[i])
                    ag.AddDebugInfoAndVoid(
                        GlobalAllocator.Assign(
                            ag.Globals.GetVariable(ag, _variables[i]), 
                            Ast.Call(
                                AstGenerator.GetHelperMethod(                           // helper
                                    _asNames[i] == null ? "ImportTop" : "ImportBottom"
                                ),
                                ag.LocalContext,                                        // 1st arg - code context
                                AstUtils.Constant(_names[i].MakeString()),                   // 2nd arg - module name
                                AstUtils.Constant(_forceAbsolute ? 0 : -1)                   // 3rd arg - absolute or relative imports
                            )
                        ),
                        _names[i].Span
                    )
                );
            }

            statements.Add(AstUtils.Empty());
            return ag.AddDebugInfo(Ast.Block(statements.ToReadOnlyCollection()), Span);
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:26,代码来源:ImportStatement.cs


示例3: Bind

        // Just splat the args and dispatch through a nested site
        public override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) {
            Debug.Assert(args.Length == 2);

            int count = ((object[])args[1]).Length;
            ParameterExpression array = parameters[1];

            var nestedArgs = new ReadOnlyCollectionBuilder<Expression>(count + 1);
            var delegateArgs = new Type[count + 3]; // args + target + returnType + CallSite
            nestedArgs.Add(parameters[0]);
            delegateArgs[0] = typeof(CallSite);
            delegateArgs[1] = typeof(object);
            for (int i = 0; i < count; i++) {
                nestedArgs.Add(Expression.ArrayAccess(array, Expression.Constant(i)));
                delegateArgs[i + 2] = typeof(object).MakeByRefType();
            }
            delegateArgs[delegateArgs.Length - 1] = typeof(object);

            return Expression.IfThen(
                Expression.Equal(Expression.ArrayLength(array), Expression.Constant(count)),
                Expression.Return(
                    returnLabel,
                    Expression.MakeDynamic(
                        Expression.GetDelegateType(delegateArgs),
                        new ComInvokeAction(new CallInfo(count)),
                        nestedArgs
                    )
                )
            );
        }
开发者ID:jschementi,项目名称:iron,代码行数:30,代码来源:ComInvokeAction.cs


示例4: Reduce

        public override System.Linq.Expressions.Expression Reduce()
        {
            if (_statements.Length == 0)
                return GlobalParent.AddDebugInfoAndVoid(Utils.Empty(), Span);

            ReadOnlyCollectionBuilder<ParameterExpression> locals = new ReadOnlyCollectionBuilder<ParameterExpression>();
            List<Expression> init = new List<Expression>();

            init.Add(Expression.ClearDebugInfo(GlobalParent.Document));

            CreateVariables(locals, init);

            foreach (var statement in _statements)
            {
                int newline = GlobalParent.IndexToLocation(statement.StartIndex).Line;
                if (statement.CanThrow && newline != -1)
                    init.Add(UpdateLineNumber(newline));

                init.Add(statement);
            }

            return GlobalParent.AddDebugInfoAndVoid(
                Expression.Block(
                    locals.ToReadOnlyCollection(),
                    init
                ),
                Span
            );
        }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:29,代码来源:BlockStmt.cs


示例5: TotemArgs

        public TotemArgs(TotemContext context, string[] names, IList<object> args, Dictionary<string, object> kwargs)
            : base(context.GetType<Types.Arguments>())
        {
            _names = new ReadOnlyCollectionBuilder<string>(names).ToReadOnlyCollection();
            var vb = new ReadOnlyCollectionBuilder<object>();
            var nvb = new Dictionary<string, object>();
            var snb = new ReadOnlyCollectionBuilder<string>();

            for (var i = 0; i < args.Count; i++)
            {
                vb.Add(args[i]);
                if (i < names.Length)
                    nvb.Add(names[i], args[i]);
            }

            foreach (var arg in kwargs)
            {
                nvb.Add(arg.Key, arg.Value);
                snb.Add(arg.Key);
            }

            _values = vb.ToReadOnlyCollection();
            _namedValues = new ReadOnlyDictionary<string, object>(nvb);
            _named = snb.ToReadOnlyCollection();
        }
开发者ID:Alxandr,项目名称:IronTotem,代码行数:25,代码来源:TotemArgs.cs


示例6: Reduce

        public override MSAst.Expression Reduce() {
            ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();

            for (int i = 0; i < _names.Length; i++) {
                statements.Add(
                    // _references[i] = PythonOps.Import(<code context>, _names[i])
                    GlobalParent.AddDebugInfoAndVoid(
                        AssignValue(
                            Parent.GetVariableExpression(_variables[i]),
                            LightExceptions.CheckAndThrow(
                                Expression.Call(
                                    _asNames[i] == null ? AstMethods.ImportTop : AstMethods.ImportBottom,
                                    Parent.LocalContext,                                     // 1st arg - code context
                                    AstUtils.Constant(_names[i].MakeString()),                   // 2nd arg - module name
                                    AstUtils.Constant(_forceAbsolute ? 0 : -1)                   // 3rd arg - absolute or relative imports
                                )
                            )
                        ),
                        _names[i].Span
                    )
                );
            }

            statements.Add(AstUtils.Empty());
            return GlobalParent.AddDebugInfo(Ast.Block(statements.ToReadOnlyCollection()), Span);
        }
开发者ID:jschementi,项目名称:iron,代码行数:26,代码来源:ImportStatement.cs


示例7: Reduce

        public override MSAst.Expression Reduce() {
            if (_statements.Length == 0) {
                return GlobalParent.AddDebugInfoAndVoid(AstUtils.Empty(), Span);
            }

            ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();

            int curStart = -1;
            foreach (var statement in _statements) {
                // CPython debugging treats multiple statements on the same line as a single step, we
                // match that behavior here.
                if (statement.Start.Line == curStart) {
                    statements.Add(new DebugInfoRemovalExpression(statement, curStart));
                } else {
                    if (statement.CanThrow && statement.Start.IsValid) {
                        statements.Add(UpdateLineNumber(statement.Start.Line));
                    }

                    statements.Add(statement);
                }
                curStart = statement.Start.Line;
            }
            
            return Ast.Block(statements.ToReadOnlyCollection());
        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:25,代码来源:SuiteStatement.cs


示例8: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            MSAst.Expression destination = ag.TransformAsObject(_dest);

            if (_expressions.Length == 0) {
                MSAst.Expression result;
                if (destination != null) {
                    result = Ast.Call(
                        AstGenerator.GetHelperMethod("PrintNewlineWithDest"),
                        ag.LocalContext,
                        destination
                    );
                } else {
                    result = Ast.Call(
                        AstGenerator.GetHelperMethod("PrintNewline"),
                        ag.LocalContext
                    );
                }
                return ag.AddDebugInfo(result, Span);
            } else {
                // Create list for the individual statements
                ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();

                // Store destination in a temp, if we have one
                if (destination != null) {
                    MSAst.ParameterExpression temp = ag.GetTemporary("destination");

                    statements.Add(
                        AstGenerator.MakeAssignment(temp, destination)
                    );

                    destination = temp;
                }
                for (int i = 0; i < _expressions.Length; i++) {
                    string method = (i < _expressions.Length - 1 || _trailingComma) ? "PrintComma" : "Print";
                    Expression current = _expressions[i];
                    MSAst.MethodCallExpression mce;

                    if (destination != null) {
                        mce = Ast.Call(
                            AstGenerator.GetHelperMethod(method + "WithDest"),
                            ag.LocalContext,
                            destination,
                            ag.TransformAsObject(current)
                        );
                    } else {
                        mce = Ast.Call(
                            AstGenerator.GetHelperMethod(method),
                            ag.LocalContext,
                            ag.TransformAsObject(current)
                        );
                    }

                    statements.Add(mce);
                }

                statements.Add(AstUtils.Empty());
                return ag.AddDebugInfo(Ast.Block(statements.ToReadOnlyCollection()), Span);
            }
        }
开发者ID:techarch,项目名称:ironruby,代码行数:59,代码来源:PrintStatement.cs


示例9: Reduce

 public override MSAst.Expression Reduce() {
     // Transform to series of individual del statements.
     ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>(_expressions.Length + 1);
     for (int i = 0; i < _expressions.Length; i++) {
         statements.Add(_expressions[i].TransformDelete());
     }
     statements.Add(AstUtils.Empty());
     return GlobalParent.AddDebugInfo(MSAst.Expression.Block(statements), Span);
 }
开发者ID:jschementi,项目名称:iron,代码行数:9,代码来源:DelStatement.cs


示例10: Transform

 internal override MSAst.Expression Transform(AstGenerator ag) {
     // Transform to series of individual del statements.
     ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>(_expressions.Length + 1);
     for (int i = 0; i < _expressions.Length; i++) {
         statements.Add(_expressions[i].TransformDelete(ag));
     }
     statements.Add(AstUtils.Empty());
     return ag.AddDebugInfo(MSAst.Expression.Block(statements), Span);
 }
开发者ID:techarch,项目名称:ironruby,代码行数:9,代码来源:DelStatement.cs


示例11: ScopeBuilder

        public ScopeBuilder(MSA.ParameterExpression/*!*/[] parameters, int firstClosureParam, int localCount, 
            ScopeBuilder parent, LexicalScope/*!*/ lexicalScope) {
            Debug.Assert(parent == null || parent.LexicalScope == lexicalScope.OuterScope);
#if DEBUG
            _id = Interlocked.Increment(ref _Id);
#endif
            _parent = parent;
            _parameters = parameters;
            _localCount = localCount;
            _firstClosureParam = firstClosureParam;
            _lexicalScope = lexicalScope;
            _hiddenVariables = new ReadOnlyCollectionBuilder<MSA.ParameterExpression>();
            _localsTuple = DefineHiddenVariable("#locals", MakeLocalsTupleType());
            _outermostClosureReferredTo = this;
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:15,代码来源:ScopeBuilder.cs


示例12: AstGenerator

        private AstGenerator(string name, bool generator, string profilerName, bool print) {
            _print = print;
            _isGenerator = generator;

            _name = name;
            _locals = new ReadOnlyCollectionBuilder<ParameterExpression>();
            _params = new List<ParameterExpression>();

            if (profilerName == null) {
                if (name.IndexOfAny(System.IO.Path.GetInvalidPathChars()) >= 0) {
                    _profilerName = "module " + name;
                } else {
                    _profilerName = "module " + System.IO.Path.GetFileNameWithoutExtension(name);
                }
            } else {
                _profilerName = profilerName;
            }
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:18,代码来源:AstGenerator.cs


示例13: Reduce

        public override System.Linq.Expressions.Expression Reduce()
        {
            if (_statements.Length == 0)
                return GlobalParent.AddDebugInfoAndVoid(AstUtils.Empty(), Span);

            ReadOnlyCollectionBuilder<MSAst.Expression> statements = new ReadOnlyCollectionBuilder<MSAst.Expression>();

            foreach (var stmt in _statements)
            {
                var line = GlobalParent.IndexToLocation(stmt.StartIndex).Line;
                if (stmt.CanThrow && line != -1)
                {
                    statements.Add(UpdateLineNumber(line));
                }

                statements.Add(stmt);
            }

            return Ast.Block(statements.ToReadOnlyCollection());
        }
开发者ID:Alxandr,项目名称:IronTotem,代码行数:20,代码来源:SuiteStatement.cs


示例14: FinishBind

        internal override void FinishBind(TotemNameBinder binder)
        {
            if (_freeVars != null && _freeVars.Count > 0)
            {
                ReadOnlyCollectionBuilder<TotemVariable> closureVariables = new ReadOnlyCollectionBuilder<TotemVariable>();
                _closureType = MutableTuple.MakeTupleType(_freeVars.Select(v => typeof(ClosureCell)).ToArray());
                _localClosureTuple = Expression.Parameter(_closureType, "$closure");
                for (var i = 0; i < _freeVars.Count; i++)
                {
                    var variable = _freeVars[i];
                    _variableMapping[variable] = new ClosureExpression(variable, Expression.Property(_localClosureTuple, String.Format("Item{0:D3}", i)), null);
                    closureVariables.Add(variable);
                }
                _closureVariables = closureVariables.ToReadOnlyCollection();
            }

            if (_scopeVars != null)
                foreach (var local in _scopeVars)
                {
                    if (local.Kind == VariableKind.Parameter) // handled in subclass
                        continue;

                    // scope variables, defined in this scope
                    Debug.Assert(local.Kind == VariableKind.Local);
                    Debug.Assert(local.Scope == this);

                    if (local.AccessedInNestedScope)
                    {
                        // Closure variable
                        _variableMapping[local] = new ClosureExpression(local, Expression.Parameter(typeof(ClosureCell), local.Name), null);
                    }
                    else
                    {
                        // Not used in nested function-scopes
                        _variableMapping[local] = Expression.Parameter(typeof(object), local.Name);
                    }
                }
        }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:38,代码来源:CompilableStmt.cs


示例15: MakeClassBody

        private Microsoft.Scripting.Ast.LightExpression<Func<CodeContext, CodeContext>> MakeClassBody() {
            // we always need to create a nested context for class defs            

            var init = new List<MSAst.Expression>();
            var locals = new ReadOnlyCollectionBuilder<MSAst.ParameterExpression>();

            locals.Add(LocalCodeContextVariable);
            locals.Add(PythonAst._globalContext);

            init.Add(Ast.Assign(PythonAst._globalContext, new GetGlobalContextExpression(_parentContextParam)));

            GlobalParent.PrepareScope(locals, init);

            CreateVariables(locals, init);

            var createLocal = CreateLocalContext(_parentContextParam);

            init.Add(Ast.Assign(LocalCodeContextVariable, createLocal));

            List<MSAst.Expression> statements = new List<MSAst.Expression>();
            // Create the body
            MSAst.Expression bodyStmt = _body;

            // __module__ = __name__
            MSAst.Expression modStmt = AssignValue(GetVariableExpression(_modVariable), GetVariableExpression(_modNameVariable));

            string doc = GetDocumentation(_body);
            if (doc != null) {
                statements.Add(
                    AssignValue(
                        GetVariableExpression(_docVariable),
                        AstUtils.Constant(doc)
                    )
                );
            }

            if (_body.CanThrow && GlobalParent.PyContext.PythonOptions.Frames) {
                bodyStmt = AddFrame(LocalContext, FuncCodeExpr, bodyStmt);
                locals.Add(FunctionStackVariable);
            }

            bodyStmt = WrapScopeStatements(
                Ast.Block(
                    Ast.Block(init),
                    statements.Count == 0 ?
                        EmptyBlock :
                        Ast.Block(new ReadOnlyCollection<MSAst.Expression>(statements)),
                    modStmt,
                    bodyStmt,
                    LocalContext
                ),
                _body.CanThrow
            );

            var lambda = AstUtils.LightLambda<Func<CodeContext, CodeContext>>(
                typeof(CodeContext),
                Ast.Block(
                    locals,
                    bodyStmt
                ),
                Name + "$" + Interlocked.Increment(ref _classId),
                new[] { _parentContextParam }
                );

            return lambda;
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:66,代码来源:ClassDefinition.cs


示例16: PrepareScope

 public virtual void PrepareScope(PythonAst ast, ReadOnlyCollectionBuilder<MSAst.ParameterExpression> locals, List<MSAst.Expression> init) {
 }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:2,代码来源:CompilationMode.cs


示例17: ReplaceAssemblyInfoPropertiesTests_WhenChangingAllPropertiesInWorkflowShouldUpdateAssemblyInfoWithSameValues

        public void ReplaceAssemblyInfoPropertiesTests_WhenChangingAllPropertiesInWorkflowShouldUpdateAssemblyInfoWithSameValues()
        {
            const string searchPatternShell = @"[\[<]+.*{0}.*\(\x22{1}\x22\)[\]>]+";
            string[] filePaths = new[] { "ReplaceTestAssemblyInfo.cs", "ReplaceTestAssemblyInfo.vb", "ReplaceTestAssemblyInfo.cpp", "ReplaceTestAssemblyInfo.fs" };

            const bool forceCreate = true;

            IList<Tuple<string, string>> assemblyProperties = new ReadOnlyCollectionBuilder<Tuple<string, string>>
                                                                  {
                                                                      new Tuple<string, string>("AssemblyTitle", "Assembly Title"),
                                                                      new Tuple<string, string>("AssemblyDescription", "Assembly Description"),
                                                                      new Tuple<string, string>("AssemblyConfiguration", "Assembly Configuration"),
                                                                      new Tuple<string, string>("AssemblyCompany", "Assembly Company"),
                                                                      new Tuple<string, string>("AssemblyProduct", "Assembly Product"),
                                                                      new Tuple<string, string>("AssemblyCopyright", "Assembly Copyright"),
                                                                      new Tuple<string, string>("AssemblyTrademark", "Assembly Trademark"),
                                                                      new Tuple<string, string>("AssemblyCulture", "Assembly Culture"),
                                                                      new Tuple<string, string>("AssemblyInformationalVersion", "Assembly Informational Version"),
                                                                  };

            foreach (var file in filePaths)
            {
                // Create an instance of our test workflow
                var workflow = new Tests.TestReplaceAssemblyInfoPropertiesWorkflow();

                // Create the workflow run-time environment
                var workflowInvoker = new WorkflowInvoker(workflow);

                var testFilename = string.Format("AllPropertiesTestAssemblyInfo{0}", Path.GetExtension(file));

                File.Copy(file, testFilename);

                var extension = " " + Path.GetExtension(testFilename).Remove(0, 1);

                // Set the workflow arguments
                workflow.FilePath = testFilename;
                workflow.ForceCreate = forceCreate;

                workflow.BuildDate = DateTime.Now;
                workflow.AssemblyTitleReplacementPattern = assemblyProperties[0].Item2 + extension;
                workflow.AssemblyDescriptionReplacementPattern = assemblyProperties[1].Item2 + extension;
                workflow.AssemblyConfigurationReplacementPattern = assemblyProperties[2].Item2 + extension;
                workflow.AssemblyCompanyReplacementPattern = assemblyProperties[3].Item2 + extension;
                workflow.AssemblyProductReplacementPattern = assemblyProperties[4].Item2 + extension;
                workflow.AssemblyCopyrightReplacementPattern = assemblyProperties[5].Item2 + extension;
                workflow.AssemblyTrademarkReplacementPattern = assemblyProperties[6].Item2 + extension;
                workflow.AssemblyCultureReplacementPattern = assemblyProperties[7].Item2 + extension;
                workflow.AssemblyInformationalVersionReplacementPattern = assemblyProperties[8].Item2 + extension;
                workflow.BuildDetail = new InArgument<IBuildDetail>(env => new BuildDetailStub(99));

                // Invoke the workflow and capture the outputs
                workflowInvoker.Invoke();

                // Verify using RegEx
                var fileData = File.ReadAllText(testFilename);

                foreach (var propertyTuple in assemblyProperties)
                {
                    var regexPattern = string.Format(searchPatternShell, propertyTuple.Item1,
                                                     propertyTuple.Item2 + extension);

                    var regex = new Regex(regexPattern);

                    Assert.IsTrue(regex.IsMatch(fileData),
                                  string.Format("Test Failed: File: {0} - Property: {1} - Value: {2}", testFilename,
                                                propertyTuple.Item1, propertyTuple.Item2 + extension));
                }
            }
        }
开发者ID:jricke,项目名称:TfsVersioning,代码行数:69,代码来源:ReplaceAssemblyInfoPropertiesTests.cs


示例18: ReferenceArgAssign

            /// <summary>
            /// Helper method for generating expressions that assign byRef call
            /// parameters back to their original variables
            /// </summary>
            private static Expression ReferenceArgAssign(Expression callArgs, Expression[] args) {
                ReadOnlyCollectionBuilder<Expression> block = null;

                for (int i = 0; i < args.Length; i++) {
                    ContractUtils.Requires(args[i] is ParameterExpression);
                    if (((ParameterExpression)args[i]).IsByRef) {
                        if (block == null)
                            block = new ReadOnlyCollectionBuilder<Expression>();

                        block.Add(
                            Expression.Assign(
                                args[i],
                                Expression.Convert(
                                    Expression.ArrayIndex(
                                        callArgs,
                                        Expression.Constant(i)
                                    ),
                                    args[i].Type
                                )
                            )
                        );
                    }
                }

                if (block != null)
                    return Expression.Block(block);
                else
                    return Expression.Empty();
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:DynamicObject.cs


示例19: TransformSet

        internal override MSAst.Expression TransformSet(SourceSpan span, MSAst.Expression right, PythonOperationKind op) {
            // if we just have a simple named multi-assignment  (e.g. a, b = 1,2)
            // then go ahead and step over the entire statement at once.  If we have a 
            // more complex statement (e.g. a.b, c.d = 1, 2) then we'll step over the
            // sets individually as they could be property sets the user wants to step
            // into.  TODO: Enable stepping of the right hand side?
            bool emitIndividualSets = false;
            foreach (Expression e in _items) {
                if (IsComplexAssignment(e)) {
                    emitIndividualSets = true;
                    break;
                }
            }

            SourceSpan rightSpan = SourceSpan.None;
            SourceSpan leftSpan =
                (Span.Start.IsValid && span.IsValid) ?
                    new SourceSpan(Span.Start, span.End) :
                    SourceSpan.None;

            SourceSpan totalSpan = SourceSpan.None;
            if (emitIndividualSets) {
                rightSpan = span;
                leftSpan = SourceSpan.None;
                totalSpan = (Span.Start.IsValid && span.IsValid) ?
                    new SourceSpan(Span.Start, span.End) :
                    SourceSpan.None;
            }

            // 1. Evaluate the expression and assign the value to the temp.
            MSAst.ParameterExpression right_temp = Ast.Variable(typeof(object), "unpacking");

            // 2. Add the assignment "right_temp = right" into the suite/block
            MSAst.Expression assignStmt1 = MakeAssignment(right_temp, right);

            // 3. Call GetEnumeratorValues on the right side (stored in temp)
            MSAst.Expression enumeratorValues = Expression.Convert(LightExceptions.CheckAndThrow(
                Expression.Call(
                    emitIndividualSets ? 
                        AstMethods.GetEnumeratorValues : 
                        AstMethods.GetEnumeratorValuesNoComplexSets,    // method
                    // arguments
                    Parent.LocalContext,
                    right_temp,
                    AstUtils.Constant(_items.Length)
                )
            ), typeof(object[]));

            // 4. Create temporary variable for the array
            MSAst.ParameterExpression array_temp = Ast.Variable(typeof(object[]), "array");

            // 5. Assign the value of the method call (mce) into the array temp
            // And add the assignment "array_temp = Ops.GetEnumeratorValues(...)" into the block
            MSAst.Expression assignStmt2 = MakeAssignment(
                array_temp,
                enumeratorValues,
                rightSpan
            );

            ReadOnlyCollectionBuilder<MSAst.Expression> sets = new ReadOnlyCollectionBuilder<MSAst.Expression>(_items.Length + 1);
            for (int i = 0; i < _items.Length; i++) {
                // target = array_temp[i]

                Expression target = _items[i];
                if (target == null) {
                    continue;
                }

                // 6. array_temp[i]
                MSAst.Expression element = Ast.ArrayAccess(
                    array_temp,                             // array expression
                    AstUtils.Constant(i)                         // index
                );

                // 7. target = array_temp[i], and add the transformed assignment into the list of sets
                MSAst.Expression set = target.TransformSet(
                    emitIndividualSets ?                    // span
                        target.Span :
                        SourceSpan.None,
                    element,
                    PythonOperationKind.None
                );
                sets.Add(set);
            }
            // 9. add the sets as their own block so they can be marked as a single span, if necessary.
            sets.Add(AstUtils.Empty());
            MSAst.Expression itemSet = GlobalParent.AddDebugInfo(Ast.Block(sets.ToReadOnlyCollection()), leftSpan);

            // 10. Return the suite statement (block)
            return GlobalParent.AddDebugInfo(Ast.Block(new[] { array_temp, right_temp }, assignStmt1, assignStmt2, itemSet, AstUtils.Empty()), totalSpan);
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:91,代码来源:SequenceExpression.cs


示例20: PrepareScope

 public virtual void PrepareScope(TotemAst ast, ReadOnlyCollectionBuilder<ParameterExpression> locals, List<Expression> init)
 {
 }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:3,代码来源:CompilationMode.cs



注:本文中的ReadOnlyCollectionBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ReadOnlyDictionary类代码示例发布时间:2022-05-24
下一篇:
C# ReadOnlyCollection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap