当前位置: 首页>>代码示例>>C#>>正文


C# AstGenerator.TransformOrConstantNull方法代码示例

本文整理汇总了C#中IronPython.Compiler.Ast.AstGenerator.TransformOrConstantNull方法的典型用法代码示例。如果您正苦于以下问题:C# AstGenerator.TransformOrConstantNull方法的具体用法?C# AstGenerator.TransformOrConstantNull怎么用?C# AstGenerator.TransformOrConstantNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IronPython.Compiler.Ast.AstGenerator的用法示例。


在下文中一共展示了AstGenerator.TransformOrConstantNull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            MSAst.Expression raiseExpression;
            if (_type == null && _value == null && _traceback == null) {
                raiseExpression = Ast.Call(
                    AstGenerator.GetHelperMethod("MakeRethrownException"),
                    ag.LocalContext
                );

                if (!ag._isEmittingFinally) {
                    raiseExpression = Ast.Block(
                        ag.UpdateLineUpdated(true),
                        raiseExpression
                    );
                }
            } else {
                raiseExpression = Ast.Call(
                    AstGenerator.GetHelperMethod("MakeException"),
                    ag.LocalContext,
                    ag.TransformOrConstantNull(_type, typeof(object)),
                    ag.TransformOrConstantNull(_value, typeof(object)),
                    ag.TransformOrConstantNull(_traceback, typeof(object))
                );
            }
            return ag.AddDebugInfo(
                Ast.Throw(raiseExpression),
                Span
            );
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:28,代码来源:RaiseStatement.cs

示例2: Transform

 internal override MSAst.Expression Transform(AstGenerator ag, Type type) {
     return Ast.Call(
         AstGenerator.GetHelperMethod("MakeSlice"),                  // method
         ag.TransformOrConstantNull(_sliceStart, typeof(object)),    // parameters
         ag.TransformOrConstantNull(_sliceStop, typeof(object)),
         ag.TransformOrConstantNull(_sliceStep, typeof(object))
     );
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:8,代码来源:SliceExpression.cs

示例3: Transform

        internal override MSAst.Expression Transform(AstGenerator ag, Type type) {
            // create keys & values into array and then call helper function
            // which creates the dictionary
            if (_items.Length != 0) {
                MSAst.Expression[] parts = new MSAst.Expression[_items.Length * 2];
                Type t = null;
                bool heterogeneous = false;
                for (int index = 0; index < _items.Length; index++) {
                    SliceExpression slice = _items[index];
                    // Eval order should be:
                    //   { 2 : 1, 4 : 3, 6 :5 }
                    // This is backwards from parameter list eval, so create temporaries to swap ordering.

                    
                    parts[index * 2] = ag.TransformOrConstantNull(slice.SliceStop, typeof(object));
                    MSAst.Expression key = parts[index * 2 + 1] = ag.TransformOrConstantNull(slice.SliceStart, typeof(object));

                    Type newType;
                    if (key.NodeType == System.Linq.Expressions.ExpressionType.Convert) {
                        newType = ((MSAst.UnaryExpression)key).Operand.Type;
                    } else {
                        newType = key.Type;
                    }

                    if (t == null) {
                        t = newType;
                    } else if (newType == typeof(object)) {
                        heterogeneous = true;
                    } else if (newType != t) {
                        heterogeneous = true;
                    }
                }

                return Ast.Call(
                    typeof(PythonOps).GetMethod(heterogeneous ? "MakeDictFromItems" : "MakeHomogeneousDictFromItems"),
                    Ast.NewArrayInit(
                        typeof(object),
                        parts
                    )
                );
            }

            // empty dictionary
            return Ast.Call(
                typeof(PythonOps).GetMethod("MakeDict"),
                Ast.Constant(0)
            );
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:48,代码来源:DictionaryExpression.cs

示例4: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            if (ag.IsGenerator) {
                if (_expression != null) {
                    // Statements can't return null, so return a rethrow. 
                    // Callers should detecet the ag.AddError and avoid trying to execute the tree, 
                    // but if they accidentally do, use Throw instead of empty so that
                    // we'll get an exception.
                    return Ast.Throw(
                        Ast.New(
                            typeof(InvalidOperationException).GetConstructor(Type.EmptyTypes)
                        )
                    );
                }

                return ag.AddDebugInfo(AstUtils.YieldBreak(ag.GeneratorLabel), Span);
            }

            return ag.AddDebugInfo(
                Ast.Return(
                    ag.ReturnLabel,
                    ag.TransformOrConstantNull(_expression, typeof(object))
                ),
                Span
            );
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:25,代码来源:ReturnStatement.cs

示例5: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            MSAst.MethodCallExpression call;

            if (_locals == null && _globals == null) {
                // exec code
                call = Ast.Call(
                    AstGenerator.GetHelperMethod("UnqualifiedExec"), 
                    AstUtils.CodeContext(), 
                    ag.TransformAsObject(_code)
                );
            } else {
                // exec code in globals [ , locals ]
                // We must have globals now (locals is last and may be absent)
                Debug.Assert(_globals != null);
                call = Ast.Call(
                    AstGenerator.GetHelperMethod("QualifiedExec"), 
                    AstUtils.CodeContext(), 
                    ag.TransformAsObject(_code), 
                    ag.TransformAndDynamicConvert(_globals, typeof(IAttributesCollection)), 
                    ag.TransformOrConstantNull(_locals, typeof(object))
                );
            }

            return ag.AddDebugInfo(call, Span);
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:25,代码来源:ExecStatement.cs

示例6: Transform

 internal override MSAst.Expression Transform(AstGenerator ag) {
     MSAst.MethodCallExpression raiseExpression;
     if (_type == null && _value == null && _traceback == null) {
         raiseExpression = Ast.Call(
             AstGenerator.GetHelperMethod("MakeRethrownException"),
             AstUtils.CodeContext()
         );
     } else {
         raiseExpression = Ast.Call(
             AstGenerator.GetHelperMethod("MakeException"),
             AstUtils.CodeContext(),
             ag.TransformOrConstantNull(_type, typeof(object)),
             ag.TransformOrConstantNull(_value, typeof(object)),
             ag.TransformOrConstantNull(_traceback, typeof(object))
         );
     }
     return ag.AddDebugInfo(
         Ast.Throw(raiseExpression),
         Span
     );
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:21,代码来源:RaiseStatement.cs

示例7: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            // If debugging is off, return empty statement
            if (ag.Optimize) {
                return AstUtils.Empty();
            }

            // Transform into:
            // if (_test) {
            // } else {
            //     RaiseAssertionError(_message);
            // }
            return ag.AddDebugInfoAndVoid(
                AstUtils.Unless(                                 // if
                    ag.TransformAndDynamicConvert(_test, typeof(bool)), // _test
                    Ast.Call(                                           // else branch
                        AstGenerator.GetHelperMethod("RaiseAssertionError"),
                        ag.TransformOrConstantNull(_message, typeof(object))
                    )
                ),
                Span
            );
        }
开发者ID:techarch,项目名称:ironruby,代码行数:22,代码来源:AssertStatement.cs


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