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


C# AstGenerator.Get方法代码示例

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


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

示例1: Transform

 internal override MSAst.Expression Transform(AstGenerator ag, Type type) {
     return ag.Get(
         type,
         SymbolTable.IdToString(_name),
         ag.Transform(_target)
     );
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:7,代码来源:MemberExpression.cs

示例2: Transform

 internal override MSAst.Expression Transform(AstGenerator ag, Type type) {
     return ag.Get(
         type,
         _name,
         ag.Transform(_target)
     );
 }
开发者ID:techarch,项目名称:ironruby,代码行数:7,代码来源:MemberExpression.cs

示例3: SetMemberOperator

 private MSAst.Expression SetMemberOperator(AstGenerator ag, MSAst.Expression right, PythonOperationKind op, MSAst.ParameterExpression temp) {
     return ag.Set(
         typeof(object),
         _name,
         temp,
         ag.Operation(
             typeof(object),
             op,
             ag.Get(
                 typeof(object),
                 _name,
                 temp
             ),
             right
         )
     );
 }
开发者ID:techarch,项目名称:ironruby,代码行数:17,代码来源:MemberExpression.cs

示例4: Transform

        /// <summary>
        /// WithStatement is translated to the DLR AST equivalent to
        /// the following Python code snippet (from with statement spec):
        /// 
        /// mgr = (EXPR)
        /// exit = mgr.__exit__  # Not calling it yet
        /// value = mgr.__enter__()
        /// exc = True
        /// try:
        ///     VAR = value  # Only if "as VAR" is present
        ///     BLOCK
        /// except:
        ///     # The exceptional case is handled here
        ///     exc = False
        ///     if not exit(*sys.exc_info()):
        ///         raise
        ///     # The exception is swallowed if exit() returns true
        /// finally:
        ///     # The normal and non-local-goto cases are handled here
        ///     if exc:
        ///         exit(None, None, None)
        /// 
        /// </summary>
        internal override MSAst.Expression Transform(AstGenerator ag) {            
            MSAst.ParameterExpression lineUpdated = ag.GetTemporary("$lineUpdated_with", typeof(bool));
            // Five statements in the result...
            MSAst.Expression[] statements = new MSAst.Expression[6];

            //******************************************************************
            // 1. mgr = (EXPR)
            //******************************************************************
            MSAst.ParameterExpression manager = ag.GetTemporary("with_manager");
            statements[0] = ag.MakeAssignment(
                manager,
                ag.Transform(_contextManager),
                new SourceSpan(Start, _header)
            );

            //******************************************************************
            // 2. exit = mgr.__exit__  # Not calling it yet
            //******************************************************************
            MSAst.ParameterExpression exit = ag.GetTemporary("with_exit");
            statements[1] = ag.MakeAssignment(
                exit,
                ag.Get(
                    typeof(object),
                    "__exit__",
                    manager
                )
            );

            //******************************************************************
            // 3. value = mgr.__enter__()
            //******************************************************************
            MSAst.ParameterExpression value = ag.GetTemporary("with_value");
            statements[2] = ag.AddDebugInfo(
                ag.MakeAssignment(
                    value,
                    ag.Invoke(
                        typeof(object),
                        new CallSignature(0),
                        ag.Get(
                            typeof(object),
                            "__enter__",
                            manager
                        )
                    )
                ),
                new SourceSpan(Start, _header)
            );

            //******************************************************************
            // 4. exc = True
            //******************************************************************
            MSAst.ParameterExpression exc = ag.GetTemporary("with_exc", typeof(bool));
            statements[3] = ag.MakeAssignment(
                exc,
                AstUtils.Constant(true)
            );

            //******************************************************************
            //  5. The final try statement:
            //
            //  try:
            //      VAR = value  # Only if "as VAR" is present
            //      BLOCK
            //  except:
            //      # The exceptional case is handled here
            //      exc = False
            //      if not exit(*sys.exc_info()):
            //          raise
            //      # The exception is swallowed if exit() returns true
            //  finally:
            //      # The normal and non-local-goto cases are handled here
            //      if exc:
            //          exit(None, None, None)
            //******************************************************************

            MSAst.ParameterExpression exception = ag.GetTemporary("exception", typeof(Exception));
            MSAst.ParameterExpression nestedFrames = ag.GetTemporary("$nestedFrames", typeof(List<DynamicStackFrame>));
//.........这里部分代码省略.........
开发者ID:m4dc4p,项目名称:ironruby,代码行数:101,代码来源:WithStatement.cs


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