| OLD | NEW |
| 1 # Copyright 2013 the V8 project authors. All rights reserved. | 1 # Copyright 2013 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 r != TransitionKey.__unicode_literal_bounds): | 232 r != TransitionKey.__unicode_literal_bounds): |
| 233 last = (last[0], r[1]) | 233 last = (last[0], r[1]) |
| 234 else: | 234 else: |
| 235 merged.append(last) | 235 merged.append(last) |
| 236 last = r | 236 last = r |
| 237 if last != None: | 237 if last != None: |
| 238 merged.append(last) | 238 merged.append(last) |
| 239 return merged | 239 return merged |
| 240 | 240 |
| 241 @staticmethod | 241 @staticmethod |
| 242 def merged_key(keys): |
| 243 f = lambda acc, key: acc + list(key.__ranges) |
| 244 return TransitionKey.__key_from_ranges(False, reduce(f, keys, [])) |
| 245 |
| 246 @staticmethod |
| 242 def __invert_ranges(ranges): | 247 def __invert_ranges(ranges): |
| 243 inverted = [] | 248 inverted = [] |
| 244 last = None | 249 last = None |
| 245 contains_whitespace = False | 250 contains_whitespace = False |
| 246 contains_literal = False | 251 contains_literal = False |
| 247 for r in ranges: | 252 for r in ranges: |
| 248 if r == TransitionKey.__unicode_whitespace_bounds: | 253 if r == TransitionKey.__unicode_whitespace_bounds: |
| 249 contains_whitespace = True | 254 contains_whitespace = True |
| 250 continue | 255 continue |
| 251 if r == TransitionKey.__unicode_literal_bounds: | 256 if r == TransitionKey.__unicode_literal_bounds: |
| 252 contains_literal = True | 257 contains_literal = True |
| 253 continue | 258 continue |
| 254 if last == None: | 259 if last == None: |
| 255 if r[0] != TransitionKey.__lower_bound: | 260 if r[0] != TransitionKey.__lower_bound: |
| 256 inverted.append((TransitionKey.__lower_bound, r[0] - 1)) | 261 inverted.append((TransitionKey.__lower_bound, r[0] - 1)) |
| 257 elif last[1] + 1 < r[0]: | 262 elif last[1] + 1 < r[0]: |
| 258 inverted.append((last[1] + 1, r[0] - 1)) | 263 inverted.append((last[1] + 1, r[0] - 1)) |
| 259 last = r | 264 last = r |
| 260 if last != None and last[1] < TransitionKey.__latin_1_upper_bound: | 265 if last != None and last[1] < TransitionKey.__latin_1_upper_bound: |
| 261 inverted.append((last[1] + 1, TransitionKey.__latin_1_upper_bound)) | 266 inverted.append((last[1] + 1, TransitionKey.__latin_1_upper_bound)) |
| 262 if not contains_whitespace: | 267 if not contains_whitespace: |
| 263 inverted.append(TransitionKey.__unicode_whitespace_bounds) | 268 inverted.append(TransitionKey.__unicode_whitespace_bounds) |
| 264 if not contains_literal: | 269 if not contains_literal: |
| 265 inverted.append(TransitionKey.__unicode_literal_bounds) | 270 inverted.append(TransitionKey.__unicode_literal_bounds) |
| 266 return inverted | 271 return inverted |
| OLD | NEW |