]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix assertion failure on large rollback in parser
authorJürg Billeter <j@bitron.ch>
Tue, 23 Mar 2010 06:33:56 +0000 (07:33 +0100)
committerJürg Billeter <j@bitron.ch>
Tue, 23 Mar 2010 06:33:56 +0000 (07:33 +0100)
Fixes bug 573080.

vala/valaparser.vala
vala/valascanner.vala

index 4de43ec25e29b0e9c8083c77166c24ed0d430a46..c9563c0acd712af324aacf1e014b3e849f00bd62 100644 (file)
@@ -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 ();
+                       }
                }
        }
 
index 40e19751c1f9c734b2164cd99de6ab50e74bd845..d686a49d54fd2ddd8e5b973d15f9e867464e19c2 100644 (file)
@@ -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);
        }