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


C# Ast.AstGenerator类代码示例

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


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

示例1: TransformRead

 internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
     return AstFactory.Condition(
         _condition.TransformCondition(gen, false),            
         gen.TransformStatementsToExpression(_statements),
         gen.TransformStatementsToExpression(_elseClause != null ? _elseClause.Statements : null)
     );
 }
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:UnlessExpression.cs

示例2: TransformWriteVariable

        /*!*/
        internal override MSA.Expression TransformWriteVariable(AstGenerator/*!*/ gen, MSA.Expression/*!*/ rightValue)
        {
            Assert.NotNull(gen, rightValue);

            // no-op
            return rightValue;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:Placeholder.cs

示例3: TransformBody

        private void TransformBody(AstGenerator/*!*/ gen) {
            ScopeBuilder scope = DefineLocals();

            var scopeVariable = gen.TopLevelScope.Builder.DefineHiddenVariable("#scope", typeof(RubyScope));
            
            gen.EnterFileInitializer(
                scope,
                gen.TopLevelScope.SelfVariable,
                scopeVariable
            );

            // visit nested initializers depth-first:
            var body = gen.TransformStatements(_statements, ResultOperation.Ignore);

            gen.LeaveFileInitializer();

            gen.AddFileInitializer(
                scope.CreateScope(
                    scopeVariable,
                    Methods.CreateFileInitializerScope.OpCall(
                        scope.MakeLocalsStorage(), 
                        scope.GetVariableNamesExpression(), 
                        gen.TopLevelScope.RuntimeScopeVariable
                    ),
                    body
                )
            );
        }
开发者ID:BenHall,项目名称:ironruby,代码行数:28,代码来源:FileInitializerStatement.cs

示例4: String

 MSA.Expression/*!*/ StringConstructor.IFactory.CreateExpressionM(AstGenerator/*!*/ gen, MSAst.ExpressionCollectionBuilder/*!*/ args) {
     string suffix = new String('M', args.Count);
     args.Add(gen.Encoding.Expression);
     args.Add(AstUtils.Constant(_options));
     args.Add(AstUtils.Constant(new StrongBox<RubyRegex>(null)));
     return Methods.CreateRegex(suffix).OpCall(args);
 }
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:RegularExpression.cs

示例5: TransformRead

 internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
     return AstFactory.Condition(
         Methods.IsFalse.OpCall(AstFactory.Box(_condition.TransformRead(gen))),
         gen.TransformStatementsToExpression(_statements),
         gen.TransformStatementsToExpression(_elseClause != null ? _elseClause.Statements : null)
     );
 }
开发者ID:aslakhellesoy,项目名称:ironruby,代码行数:7,代码来源:UnlessExpression.cs

示例6:

 MSA.Expression/*!*/ StringConstructor.IFactory.CreateExpressionN(AstGenerator/*!*/ gen, IEnumerable<MSA.Expression>/*!*/ args) {
     return Methods.CreateRegex("N").OpCall(
         Ast.NewArrayInit(typeof(MutableString), args),
         AstUtils.Constant(_options), 
         AstUtils.Constant(new StrongBox<RubyRegex>(null))
     );
 }
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:RegularExpression.cs

示例7: TransformRead

 internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
     return Methods.MatchString.OpCall(
         Ast.Dynamic(ConvertToStrAction.Make(gen.Context), typeof(MutableString), _expression.Transform(gen)),
         _regex.Transform(gen),
         gen.CurrentScopeVariable
     );
 }
开发者ID:aceptra,项目名称:ironruby,代码行数:7,代码来源:MatchExpression.cs

示例8: TransformOptionalsInitialization

        internal MSA.Expression/*!*/ TransformOptionalsInitialization(AstGenerator/*!*/ gen) {
            Assert.NotNull(gen);

            if (_optional.Length == 0) {
                return AstUtils.Empty();
            }

            MSA.Expression singleton = gen.CurrentScope.DefineHiddenVariable("#default", typeof(object));

            MSA.Expression result = AstUtils.Empty();
            for (int i = 0; i < _optional.Length; i++) {
                result = AstUtils.IfThen(
                    Ast.Equal(_optional[i].Left.TransformRead(gen), singleton),
                    Ast.Block(
                        result,
                        _optional[i].TransformRead(gen) // assignment
                    )
                );
            }
            
            return Ast.Block(
                Ast.Assign(singleton, Ast.Field(null, Fields.DefaultArgument)),
                result,
                AstUtils.Empty()
            );
        }
开发者ID:jschementi,项目名称:iron,代码行数:26,代码来源:Parameters.cs

示例9: Transform

        // see Ruby Language.doc/Runtime/Control Flow Implementation/Next
        /*!*/
        internal override MSA.Expression Transform(AstGenerator/*!*/ gen)
        {
            MSA.Expression transformedReturnValue = TransformReturnValue(gen);

            // eval:
            if (gen.CompilerOptions.IsEval) {
                return Methods.EvalNext.OpCall(gen.CurrentScopeVariable, AstUtils.Box(transformedReturnValue));
            }

            // loop:
            if (gen.CurrentLoop != null) {
                return Ast.Block(
                    transformedReturnValue, // evaluate for side-effects
                    Ast.Continue(gen.CurrentLoop.ContinueLabel),
                    AstUtils.Empty()
                );
            }

            // block:
            if (gen.CurrentBlock != null) {
                return gen.Return(transformedReturnValue);
            }

            // method:
            return Methods.MethodNext.OpCall(gen.CurrentScopeVariable, AstUtils.Box(transformedReturnValue));
        }
开发者ID:TerabyteX,项目名称:main,代码行数:28,代码来源:NextStatement.cs

示例10: TransformBody

        private MSA.Expression/*!*/ TransformBody(AstGenerator/*!*/ gen, MSA.Expression/*!*/ methodDefinitionVariable) {
            string encodedName = RubyExceptionData.EncodeMethodName(gen.SourceUnit, _name, Location);
            
            ScopeBuilder scope = new ScopeBuilder();
            MSA.Expression parentScope = gen.CurrentScopeVariable;

            MSA.ParameterExpression[] parameters = DefineParameters(gen, scope);
            MSA.Expression currentMethodVariable = scope.DefineHiddenVariable("#method", typeof(RubyMethodInfo));
            MSA.Expression rfcVariable = scope.DefineHiddenVariable("#rfc", typeof(RuntimeFlowControl));
            MSA.Expression scopeVariable = scope.DefineHiddenVariable("#scope", typeof(RubyMethodScope));
            MSA.Expression selfParameter = parameters[0];
            MSA.Expression blockParameter = parameters[1];

            gen.EnterMethodDefinition(
                scope,
                selfParameter,
                scopeVariable,
                blockParameter,
                rfcVariable,
                currentMethodVariable,
                _name,
                _parameters
            );

            DefinedScope.TransformLocals(scope);

            MSA.ParameterExpression unwinder = scope.DefineHiddenVariable("#unwinder", typeof(MethodUnwinder));

            MSA.Expression body = AstFactory.MakeUserMethodBody(
                gen, Location.End.Line,
                blockParameter,
                rfcVariable,
                unwinder,
                Ast.Block(
                    Ast.Assign(currentMethodVariable, methodDefinitionVariable),

                    Ast.Assign(scopeVariable, Methods.CreateMethodScope.OpCall(
                        scope.VisibleVariables(), parentScope, currentMethodVariable, rfcVariable, selfParameter, blockParameter)
                    ),
                
                    _parameters.TransformOptionalsInitialization(gen),
                    gen.TraceEnabled ? Methods.TraceMethodCall.OpCall(scopeVariable, Ast.Convert(AstUtils.Constant(gen.SourceUnit.Path), typeof(string)), AstUtils.Constant(Location.Start.Line)) : AstUtils.Empty(),
                    Body.TransformResult(gen, ResultOperation.Return),
                    AstUtils.Empty()
                ),
                ResultOperation.Return,
                (gen.Profiler != null) ? gen.Profiler.GetTickIndex(encodedName) : -1,
                (gen.Profiler != null) ? scope.DefineHiddenVariable("#stamp", typeof(long)) : null,
                gen.ReturnLabel
            );

            body = gen.AddReturnTarget(scope.CreateScope(body));
            gen.LeaveMethodDefinition();

            return CreateLambda(
                encodedName, 
                parameters, 
                body
            );
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:60,代码来源:MethodDeclaration.cs

示例11: Transform

        // see Ruby Language.doc/Runtime/Control Flow Implementation/Break
        internal override MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) {

            MSA.Expression transformedReturnValue = TransformReturnValue(gen);

            // eval:
            if (gen.CompilerOptions.IsEval) {
                return Methods.EvalBreak.OpCall(gen.CurrentRfcVariable, AstFactory.Box(transformedReturnValue));
            }

            // loop:
            if (gen.CurrentLoop != null) {
                return Ast.Block(
                    Ast.Assign(
                        gen.CurrentLoop.ResultVariable,
                        Ast.Convert(transformedReturnValue, gen.CurrentLoop.ResultVariable.Type)
                    ),
                    Ast.Break(gen.CurrentLoop.BreakLabel),
                    Ast.Empty()
                );
            }

            // block:
            if (gen.CurrentBlock != null) {
                return gen.Return(Methods.BlockBreak.OpCall(gen.CurrentBlock.BfcVariable, AstFactory.Box(transformedReturnValue)));
            }

            // primary frame:
            return Methods.MethodBreak.OpCall(AstFactory.Box(transformedReturnValue));
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:30,代码来源:BreakStatement.cs

示例12: TransformRead

 internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
     return AstFactory.Condition(
         _condition.TransformReadBoolean(gen, true),
         _trueExpression.TransformRead(gen),
         _falseExpression.TransformRead(gen)
     );
 }
开发者ID:jschementi,项目名称:iron,代码行数:7,代码来源:ConditionalExpression.cs

示例13: Transform

 internal override MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) {
     return AstUtils.IfThenElse(
         _condition.TransformCondition(gen, !_negateCondition), 
         _body.Transform(gen),
         _elseStatement != null ? _elseStatement.Transform(gen) : AstUtils.Empty()
     );
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:7,代码来源:ConditionalStatement.cs

示例14: TransformRead

 internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
     return Ast.Condition(
         _condition.TransformReadBoolean(gen, !_negateCondition),
         AstUtils.Box(_body.TransformRead(gen)),
         (_elseStatement != null) ? AstUtils.Box(_elseStatement.TransformRead(gen)) : (MSA.Expression)AstUtils.Constant(null)
     );
 }
开发者ID:atczyc,项目名称:ironruby,代码行数:7,代码来源:ConditionalStatement.cs

示例15: TransformRead

        // see Ruby Language.doc/Runtime/Control Flow Implementation/Yield
        internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
            MSA.Expression bfcVariable = gen.CurrentScope.DefineHiddenVariable("#yielded-bfc", typeof(BlockParam));
            MSA.Expression resultVariable = gen.CurrentScope.DefineHiddenVariable("#result", typeof(object));
            
            MSA.Expression postYield;

            if (gen.CompilerOptions.IsEval) {
                // eval:
                postYield = Methods.EvalYield.OpCall(gen.CurrentScopeVariable, bfcVariable, resultVariable);
            } else if (gen.CurrentBlock != null) {
                // block:
                postYield = Methods.BlockYield.OpCall(gen.CurrentScopeVariable, gen.CurrentBlock.BfcVariable, bfcVariable, resultVariable);
            } else {
                // method:
                postYield = Methods.MethodYield.OpCall(gen.CurrentScopeVariable, bfcVariable, resultVariable);
            }

            return new AstBlock {
                gen.DebugMarker("#RB: yield begin"),

                Ast.Assign(bfcVariable, Methods.CreateBfcForYield.OpCall(gen.MakeMethodBlockParameterRead())),

                Ast.Assign(
                    resultVariable, 
                    (Arguments ?? Arguments.Empty).TransformToYield(gen, bfcVariable, gen.MakeMethodBlockParameterSelfRead())
                ),

                AstUtils.IfThen(postYield, gen.Return(resultVariable)),

                gen.DebugMarker("#RB: yield end"),

                resultVariable
            };
        }
开发者ID:jschementi,项目名称:iron,代码行数:35,代码来源:YieldCall.cs


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