JS parser minor: moved isEndOfLine method to Utils
This commit is contained in:
@@ -39,6 +39,8 @@ package com.google.gwt.dev.js.rhino;
|
||||
import java.io.Reader;
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.gwt.dev.js.rhino.Utils.isEndOfLine;
|
||||
|
||||
/**
|
||||
* An input buffer that combines fast character-based access with
|
||||
* (slower) support for retrieving the text of the current line. It
|
||||
@@ -118,7 +120,7 @@ final class LineBuffer {
|
||||
return;
|
||||
offset--;
|
||||
int c = buffer[offset];
|
||||
if ((c & EOL_HINT_MASK) == 0 && eolChar(c)) {
|
||||
if ((c & EOL_HINT_MASK) == 0 && isEndOfLine(c)) {
|
||||
lineStart = prevStart;
|
||||
lineno--;
|
||||
}
|
||||
@@ -153,7 +155,7 @@ final class LineBuffer {
|
||||
}
|
||||
|
||||
int c = buffer[offset];
|
||||
if ((c & EOL_HINT_MASK) == 0 && eolChar(c)) {
|
||||
if ((c & EOL_HINT_MASK) == 0 && isEndOfLine(c)) {
|
||||
return '\n';
|
||||
}
|
||||
if (c < 128 || !formatChar(c)) {
|
||||
@@ -166,7 +168,7 @@ final class LineBuffer {
|
||||
|
||||
boolean match(int test) throws IOException {
|
||||
// TokenStream never looks ahead for '\n', which allows simple code
|
||||
if ((test & EOL_HINT_MASK) == 0 && eolChar(test))
|
||||
if ((test & EOL_HINT_MASK) == 0 && isEndOfLine(test))
|
||||
Context.codeBug();
|
||||
// Format chars are not allowed either
|
||||
if (test >= 128 && formatChar(test))
|
||||
@@ -214,7 +216,7 @@ final class LineBuffer {
|
||||
end += charsRead;
|
||||
}
|
||||
int c = buffer[i];
|
||||
if ((c & EOL_HINT_MASK) == 0 && eolChar(c))
|
||||
if ((c & EOL_HINT_MASK) == 0 && isEndOfLine(c))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
@@ -310,10 +312,6 @@ final class LineBuffer {
|
||||
return Character.getType((char)c) == Character.FORMAT;
|
||||
}
|
||||
|
||||
private static boolean eolChar(int c) {
|
||||
return c == '\r' || c == '\n' || c == '\u2028' || c == '\u2029';
|
||||
}
|
||||
|
||||
// Optimization for faster check for eol character: eolChar(c) returns
|
||||
// true only when (c & EOL_HINT_MASK) == 0
|
||||
private static final int EOL_HINT_MASK = 0xdfd0;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.gwt.dev.js.rhino;
|
||||
|
||||
public class Utils {
|
||||
public static boolean isEndOfLine(int c) {
|
||||
return c == '\r' || c == '\n' || c == '\u2028' || c == '\u2029';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user