當前位置: 首頁>>代碼示例>>C#>>正文


C# Scripting.SourceLocation類代碼示例

本文整理匯總了C#中Microsoft.Scripting.SourceLocation的典型用法代碼示例。如果您正苦於以下問題:C# SourceLocation類的具體用法?C# SourceLocation怎麽用?C# SourceLocation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SourceLocation類屬於Microsoft.Scripting命名空間,在下文中一共展示了SourceLocation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadToken

		public override TokenInfo ReadToken()
		{
			Token token = tokenizer.GetNext ();
			SourceLocation location = new SourceLocation(token.StartPosition,token.StartLine,token.StartColumn);
			SS.SourceSpan span = new SS.SourceSpan (ConvertToSSSrcLocation(location), ConvertToSSSrcLocation(tokenizer.Position));
			TokenTriggers trigger = GetTrigger(token.Kind);
			TokenCategory category = GetCategory (token.Kind);
			return new TokenInfo (span, category, trigger);
		}
開發者ID:alesliehughes,項目名稱:olive,代碼行數:9,代碼來源:JSTokenizerService.cs

示例2: ValidateLocations

 private static void ValidateLocations(SourceLocation start, SourceLocation end) {
     if (start.IsValid && end.IsValid) {
         if (start > end) {
             throw new ArgumentException("Start and End must be well ordered");
         }
     } else {
         if (start.IsValid || end.IsValid) {
             throw new ArgumentException("Start and End must both be valid or both invalid");
         }
     }
 }
開發者ID:jxnmaomao,項目名稱:ironruby,代碼行數:11,代碼來源:SourceSpan.cs

示例3: HappySourceLocation

 public HappySourceLocation(SourceUnit unit, SourceLocation start, SourceLocation end)
 {
     ContractUtils.RequiresNotNull(unit, "unit");
     ContractUtils.RequiresNotNull(start, "start");
     ContractUtils.RequiresNotNull(end, "end");
     //ContractUtils.Requires(isBefore(start, end), "start and end must be well ordered");
     if(!isBefore(start, end))
         throw new ApplicationException("start and end must be well ordered");
     this.Unit = unit;
     this.Span = new SourceSpan(start, end);
 }
開發者ID:dlurton,項目名稱:Happy,代碼行數:11,代碼來源:HappySourceLocation.cs

示例4: Init

		public void Init()
		{
			mockCompiler = new MockPythonCompiler();
			compiler = new DummyPythonCompilerTask(mockCompiler, @"C:\Projects\MyProject");
			compiler.TargetType = "Exe";
			compiler.OutputAssembly = "test.exe";
			
			TaskItem sourceFile = new TaskItem(@"D:\Projects\MyProject\PythonApp.Program.py");
			compiler.Sources = new ITaskItem[] {sourceFile};
			
			SourceUnit source = DefaultContext.DefaultPythonContext.CreateSourceUnit(NullTextContentProvider.Null, @"PythonApp\Program", SourceCodeKind.InteractiveCode);
			
			SourceLocation start = new SourceLocation(0, 1, 1);
			SourceLocation end = new SourceLocation(0, 2, 3);
			SourceSpan span = new SourceSpan(start, end);
			SyntaxErrorException ex = new SyntaxErrorException("Error", source, span, 1000, Severity.FatalError);
			mockCompiler.ThrowExceptionAtCompile = ex;
			
			success = compiler.Execute();
		}
開發者ID:Bombadil77,項目名稱:SharpDevelop,代碼行數:20,代碼來源:SyntaxErrorFileNameWithDotCharTestFixture.cs

示例5: Output

 public Token Output(Symbol symbol)
 {
     var loc = new SourceLocation(index, Line, Column);
     return new Token(symbol, new SourceSpan(loc, loc));
 }
開發者ID:fgretief,項目名稱:IronLua,代碼行數:5,代碼來源:Input.cs

示例6: TransformMaybeSingleLineSuite

        public MSAst.Expression TransformMaybeSingleLineSuite(Statement body, SourceLocation prevStart) {
            MSAst.Expression res;
            if (body.Start.Line == prevStart.Line) {
                // avoid creating and throwing away as much line number goo as we can...
                res = body.Transform(this);
            } else {
                res = Transform(body);
            }

            MSAst.BlockExpression block = res as MSAst.BlockExpression;
            if (block != null && block.Expressions.Count > 0) {
                MSAst.DebugInfoExpression dbgInfo = block.Expressions[0] as MSAst.DebugInfoExpression;
                // body on the same line as an if, don't generate a 2nd sequence point
                if (dbgInfo != null && dbgInfo.StartLine == prevStart.Line) {
                    // we remove the debug info based upon how it's generated in DebugStatement.AddDebugInfo which is
                    // the helper method which adds the debug info.
                    if (block.Type == typeof(void)) {
                        Debug.Assert(block.Expressions.Count == 3);
                        Debug.Assert(block.Expressions[2] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
                        res = block.Expressions[1];
                    } else {
                        Debug.Assert(block.Expressions.Count == 4);
                        Debug.Assert(block.Expressions[3] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear);
                        Debug.Assert(block.Expressions[1] is MSAst.BinaryExpression && ((MSAst.BinaryExpression)block.Expressions[2]).NodeType == MSAst.ExpressionType.Assign);
                        res = ((MSAst.BinaryExpression)block.Expressions[1]).Right;
                    }
                }
            }

            if (res.Type != typeof(void)) {
                res = AstUtils.Void(res);
            }

            return res;
        }
開發者ID:jxnmaomao,項目名稱:ironruby,代碼行數:35,代碼來源:AstGenerator.cs

示例7: TransformLoopBody

        internal MSAst.Expression TransformLoopBody(Statement body, SourceLocation headerStart, out LabelTarget breakLabel, out LabelTarget continueLabel) {
            // Save state
            bool savedInFinally = _inFinally;
            LabelTarget savedBreakLabel = _breakLabel;
            LabelTarget savedContinueLabel = _continueLabel;

            int loopId = ++_loopOrFinallyId;
            LoopOrFinallyIds.Add(loopId, false);

            _inFinally = false;
            breakLabel = _breakLabel = Ast.Label("break");
            continueLabel = _continueLabel = Ast.Label("continue");
            MSAst.Expression result;
            try {
                result = TransformMaybeSingleLineSuite(body, headerStart);
            } finally {
                _inFinally = savedInFinally;
                _breakLabel = savedBreakLabel;
                _continueLabel = savedContinueLabel;
                LoopOrFinallyIds.Remove(loopId);
            }
            return result;
        }
開發者ID:jxnmaomao,項目名稱:ironruby,代碼行數:23,代碼來源:AstGenerator.cs

示例8: FinishSlice

        private Expression FinishSlice(Expression e0, SourceLocation start) {
            Expression e1 = null;
            Expression e2 = null;
            bool stepProvided = false;

            switch (PeekToken().Kind) {
                case TokenKind.Comma:
                case TokenKind.RightBracket:
                    break;
                case TokenKind.Colon:
                    // x[?::?]
                    stepProvided = true;
                    NextToken();
                    e2 = ParseSliceEnd();
                    break;
                default:
                    // x[?:val:?]
                    e1 = ParseExpression();
                    if (MaybeEat(TokenKind.Colon)) {
                        stepProvided = true;
                        e2 = ParseSliceEnd();
                    }
                    break;
            }
            SliceExpression ret = new SliceExpression(e0, e1, e2, stepProvided);
            ret.SetLoc(start, GetEnd());
            return ret;
        }
開發者ID:techarch,項目名稱:ironruby,代碼行數:28,代碼來源:Parser.cs

示例9: ExpectMatch

        Token ExpectMatch(Symbol right, Symbol left, SourceLocation leftStart)
        {
            if (Current.Symbol != right)
            {
                if (Current.Line == leftStart.Line)
                {
                    throw ReportSyntaxErrorNear("'{0}' expected",
                        right.ToTokenString());
                }

                throw ReportSyntaxErrorNear("'{0}' expected (to close '{1}' at line {2})",
                    right.ToTokenString(),
                    left.ToTokenString(),
                    leftStart.Line);
            }
            return Consume();
        }
開發者ID:fgretief,項目名稱:IronLua,代碼行數:17,代碼來源:Parser.cs

示例10: SetLoc

 public void SetLoc(SourceLocation start, SourceLocation header, SourceLocation end) {
     Start = start;
     _header = header;
     End = end;
 }
開發者ID:mstram,項目名稱:ironruby,代碼行數:5,代碼來源:WhileStatement.cs

示例11: PythonProperty

		public PythonProperty(IClass declaringType, string name, SourceLocation location)
			: base(declaringType, name)
		{
			GetPropertyRegion(location);
			declaringType.Properties.Add(this);
		}
開發者ID:Rpinski,項目名稱:SharpDevelop,代碼行數:6,代碼來源:PythonProperty.cs

示例12: Initialize

        public override void Initialize(object state, TextReader/*!*/ reader, SourceUnit sourceUnit, SourceLocation initialLocation) {
            ContractUtils.RequiresNotNull(reader, "reader");

            _sourceUnit = sourceUnit;

            _input = reader;
            _initialLocation = initialLocation;
            _currentLine = _initialLocation.Line;
            _currentLineIndex = _initialLocation.Index;
            _tokenSpan = new SourceSpan(initialLocation, initialLocation);

            SetState(LexicalState.EXPR_BEG);

            _tokenValue = new TokenValue();
            _eofReached = false;
            _unterminatedToken = false;

            DumpBeginningOfUnit();
        }
開發者ID:bclubb,項目名稱:ironruby,代碼行數:19,代碼來源:Tokenizer.cs

示例13: SourceSpan

 /// <summary>
 /// Constructs a new span with a specific start and end location.
 /// </summary>
 /// <param name="start">The beginning of the span.</param>
 /// <param name="end">The end of the span.</param>
 public SourceSpan(SourceLocation start, SourceLocation end) {
     ValidateLocations(start, end);
     this._start = start;
     this._end = end;
 }
開發者ID:jxnmaomao,項目名稱:ironruby,代碼行數:10,代碼來源:SourceSpan.cs

示例14: GetBodyRegion

		/// <summary>
		/// Gets the body region for a class or a method.
		/// </summary>
		/// <remarks>
		/// Note that SharpDevelop line numbers are zero based but the
		/// DomRegion values are one based. IronPython columns and lines are one based.
		/// </remarks>
		/// <param name="body">The body statement.</param>
		/// <param name="header">The location of the header. This gives the end location for the
		/// method or class definition up to the colon.</param>
		public static DomRegion GetBodyRegion(Statement body, SourceLocation header)
		{
			int columnAfterColonCharacter = header.Column + 1;
			return new DomRegion(header.Line, header.Column + 1, body.End.Line, body.End.Column);
		}
開發者ID:siegfriedpammer,項目名稱:SharpDevelop,代碼行數:15,代碼來源:PythonMethodOrClassBodyRegion.cs

示例15: OutputBuffer

 public Token OutputBuffer(Symbol symbol)
 {
     var loc1 = new SourceLocation(storedIndex, storedLine, storedColumn);
     var loc2 = new SourceLocation(index, Line, Column);
     return new Token(symbol, new SourceSpan(loc1, loc2), buffer.ToString());
 }
開發者ID:fgretief,項目名稱:IronLua,代碼行數:6,代碼來源:Input.cs


注:本文中的Microsoft.Scripting.SourceLocation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。