[vala] Fix assertion failure on large rollback in parser



commit 590012f000e4736daf4167be511129186e6f88cb
Author: Jürg Billeter <j bitron ch>
Date:   Tue Mar 23 07:33:56 2010 +0100

    Fix assertion failure on large rollback in parser
    
    Fixes bug 573080.

 vala/valaparser.vala  |   10 +++++++++-
 vala/valascanner.vala |   11 ++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 4de43ec..c9563c0 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -159,7 +159,15 @@ public class Vala.Parser : CodeVisitor {
 
 	void rollback (SourceLocation location) {
 		while (tokens[index].begin.pos != location.pos) {
-			prev ();
+			index = (index - 1 + BUFFER_SIZE) % BUFFER_SIZE;
+			size++;
+			if (size > BUFFER_SIZE) {
+				scanner.seek (location);
+				size = 0;
+				index = 0;
+
+				next ();
+			}
 		}
 	}
 
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index 40e1975..d686a49 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -1,6 +1,6 @@
 /* valascanner.vala
  *
- * Copyright (C) 2008-2009  Jürg Billeter
+ * Copyright (C) 2008-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -66,6 +66,15 @@ public class Vala.Scanner {
 		column = 1;
 	}
 
+	public void seek (SourceLocation location) {
+		current = location.pos;
+		line = location.line;
+		column = location.column;
+
+		conditional_stack = null;
+		state_stack = null;
+	}
+
 	bool in_template () {
 		return (state_stack.length > 0 && state_stack[state_stack.length - 1] == State.TEMPLATE);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]