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


C# AstGenerator.AddError方法代码示例

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


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

示例1: Transform

 internal override MSAst.Expression Transform(AstGenerator ag) {
     if (ag.InFinally) {
         ag.AddError("'continue' not supported inside 'finally' clause", Span);
         return null;
     } else if (ag.InLoop) {
         return ag.AddDebugInfo(MSAst.Expression.Continue(ag.ContinueLabel), Span);
     } else {
         ag.AddError("'continue' not properly in loop", Span);
         return null;
     }
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:11,代码来源:ContinueStatement.cs

示例2: Transform

        internal override MSAst.Expression Transform(AstGenerator ag) {
            if (ag.IsGenerator) {
                if (_expression != null) {
                    // Return statements in Generators can not have an expression.
                    // Generators only return values via the yield keyword.
                    ag.AddError("'return' with argument inside generator", this.Span);

                    // 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:jcteague,项目名称:ironruby,代码行数:29,代码来源:ReturnStatement.cs

示例3: TransformSet

        internal override MSAst.Expression TransformSet(AstGenerator ag, SourceSpan span, MSAst.Expression right, PythonOperationKind op) {
            if (Items.Length == 0) {
                ag.AddError("can't assign to ()", Span);
                return null;
            }

            return base.TransformSet(ag, span, right, op);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:8,代码来源:TupleExpression.cs

示例4: TransformDelete

 internal override MSAst.Expression TransformDelete(AstGenerator ag) {
     ag.AddError("can't delete function call", Span);
     return null;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:4,代码来源:CallExpression.cs

示例5: TransformDelete

 internal virtual MSAst.Expression TransformDelete(AstGenerator ag) {
     ag.AddError("can't delete " + NodeName, Span);
     return null;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:4,代码来源:Expression.cs

示例6: TransformSet

 internal virtual MSAst.Expression TransformSet(AstGenerator ag, SourceSpan span, MSAst.Expression right, Operators op) {
     ag.AddError("can't assign to " + NodeName, Span);
     return null;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:4,代码来源:Expression.cs

示例7: TransformSet

 internal override MSAst.Expression TransformSet(AstGenerator ag, SourceSpan span, MSAst.Expression right, Operators op) {
     ag.AddError(_value == null ? "assignment to None" : "can't assign to literal", Span);
     return null;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:4,代码来源:ConstantExpression.cs

示例8: TransformSet

        internal override MSAst.Expression TransformSet(AstGenerator ag, SourceSpan span, MSAst.Expression right, Operators op) {
            if (op != Operators.None) {
                ag.AddError("augmented assign to sequence prohibited", Span);
                return null;
            }

            // 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;
            }

            MSAst.Expression[] statements = new MSAst.Expression[4];

            // 1. Evaluate the expression and assign the value to the temp.
            MSAst.ParameterExpression right_temp = ag.GetTemporary("unpacking");

            // 2. Add the assignment "right_temp = right" into the suite/block
            statements[0] = ag.MakeAssignment(right_temp, right);

            // 3. Call GetEnumeratorValues on the right side (stored in temp)
            MSAst.Expression enumeratorValues = Ast.Call(
                AstGenerator.GetHelperMethod("GetEnumeratorValues"),    // method
                // arguments
                AstUtils.CodeContext(),
                right_temp,
                Ast.Constant(_items.Length)
            );

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

            // 5. Assign the value of the method call (mce) into the array temp
            // And add the assignment "array_temp = Ops.GetEnumeratorValues(...)" into the block
            statements[1] = ag.MakeAssignment(
                array_temp, 
                enumeratorValues, 
                rightSpan
            );

            MSAst.Expression[] sets = new 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
                    Ast.Constant(i)                         // index
                );

                // 7. target = array_temp[i], and add the transformed assignment into the list of sets
                MSAst.Expression set = target.TransformSet(
                    ag,
                    emitIndividualSets ?                    // span
                        target.Span :
                        SourceSpan.None,
                    element,
                    Operators.None
                );
                if (set == null) {
                    throw PythonOps.SyntaxError(string.Format("can't assign to {0}", target.NodeName), ag.Context.SourceUnit, target.Span, -1);
                }

                sets[i] = set;
            }
            // 9. add the sets as their own block so they can be marked as a single span, if necessary.
            sets[_items.Length] = Ast.Empty();
            statements[2] = ag.AddDebugInfo(Ast.Block(sets), leftSpan);

            // 10. Free the temps
            ag.FreeTemp(array_temp);
            ag.FreeTemp(right_temp);

//.........这里部分代码省略.........
开发者ID:octavioh,项目名称:ironruby,代码行数:101,代码来源:SequenceExpression.cs

示例9: Transform

 internal override MSAst.Expression Transform(AstGenerator ag, Type type) {
     ag.AddError("Error expression encountered", Span);
     return null;
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:4,代码来源:ErrorExpression.cs


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