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


C# Frame.SetContext方法代码示例

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


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

示例1: TrackCurrentFrameAndExpression

 void TrackCurrentFrameAndExpression(Token token)
 {
     while (frame.bracketType == '<' && !Tokens.ValidInsideTypeName[token.Kind]) {
         frame.type = FrameType.Popped;
         frame = frame.parent;
     }
     switch (token.Kind) {
         case Tokens.OpenCurlyBrace:
             frame.lastExpressionStart = Location.Empty;
             frame = new Frame(frame, '{');
             frame.parent.ResetCurlyChildType();
             break;
         case Tokens.CloseCurlyBrace:
             while (frame.parent != null) {
                 if (frame.bracketType == '{') {
                     frame.type = FrameType.Popped;
                     frame = frame.parent;
                     break;
                 } else {
                     frame.type = FrameType.Popped;
                     frame = frame.parent;
                 }
             }
             break;
         case Tokens.OpenParenthesis:
             if (frame.lastExpressionStart.IsEmpty)
                 frame.lastExpressionStart = token.Location;
             frame = new Frame(frame, '(');
             frame.parent.ResetParenthesisChildType();
             break;
         case Tokens.OpenSquareBracket:
             frame = new Frame(frame, '[');
             frame.parent.ResetSquareBracketChildType();
             break;
         case Tokens.CloseParenthesis:
         case Tokens.CloseSquareBracket:
             if (frame.parent != null && (frame.bracketType == '(' || frame.bracketType == '[')) {
                 frame.type = FrameType.Popped;
                 frame = frame.parent;
             }
             break;
         case Tokens.LessThan:
             if (Tokens.ValidInsideTypeName[lastToken]) {
                 frame = new Frame(frame, '<');
                 if (frame.parent.InExpressionMode) {
                     frame.SetContext(ExpressionContext.Default);
                 } else if ((frame.parent.state == FrameState.TypeDecl
                             || frame.parent.state == FrameState.MethodDecl
                             || frame.parent.state == FrameState.FieldDeclAfterIdentifier)
                            && frame.parent.context == ExpressionContext.IdentifierExpected)
                 {
                     frame.type = FrameType.TypeParameterDecl;
                     frame.SetContext(ExpressionContext.IdentifierExpected);
                     frame.parent.SetContext(ExpressionContext.ConstraintsStart);
                 } else {
                     frame.SetContext(ExpressionContext.Type);
                 }
             }
             break;
         case Tokens.GreaterThan:
             if (frame.parent != null && frame.bracketType == '<') {
                 frame.type = FrameType.Popped;
                 frame = frame.parent;
             } else {
                 frame.lastExpressionStart = Location.Empty;
                 frame.SetDefaultContext();
             }
             break;
         case Tokens.Question:
             // do not reset context - TrackCurrentContext will take care of this
             frame.lastExpressionStart = Location.Empty;
             break;
         case Tokens.Pointer:
         case Tokens.Dot:
         case Tokens.DoubleColon:
             // let the current expression continue
             break;
         default:
             if (Tokens.IdentifierTokens[token.Kind]) {
                 if (lastToken != Tokens.Dot && lastToken != Tokens.DoubleColon && lastToken != Tokens.Pointer) {
                     if (Tokens.ValidInsideTypeName[lastToken]) {
                         frame.SetDefaultContext();
                     }
                     frame.lastExpressionStart = token.Location;
                 }
             } else if (Tokens.SimpleTypeName[token.Kind] || Tokens.ExpressionStart[token.Kind] || token.Kind == Tokens.Literal) {
                 frame.lastExpressionStart = token.Location;
             } else {
                 frame.lastExpressionStart = Location.Empty;
                 frame.SetDefaultContext();
             }
             break;
     }
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:94,代码来源:ExpressionFinder.cs


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