1.1 --- a/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java Tue Nov 01 15:49:45 2011 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java Fri Nov 04 12:36:40 2011 +0000 1.3 @@ -26,8 +26,12 @@ 1.4 package com.sun.tools.javac.parser; 1.5 1.6 import com.sun.tools.javac.file.JavacFileManager; 1.7 +import com.sun.tools.javac.util.Log; 1.8 +import com.sun.tools.javac.util.Name; 1.9 +import com.sun.tools.javac.util.Names; 1.10 + 1.11 import java.nio.CharBuffer; 1.12 -import com.sun.tools.javac.util.Log; 1.13 + 1.14 import static com.sun.tools.javac.util.LayoutCharacters.*; 1.15 1.16 /** The char reader used by the javac lexer/tokenizer. Returns the sequence of 1.17 @@ -58,6 +62,12 @@ 1.18 protected int unicodeConversionBp = -1; 1.19 1.20 protected Log log; 1.21 + protected Names names; 1.22 + 1.23 + /** A character buffer for saved chars. 1.24 + */ 1.25 + protected char[] sbuf = new char[128]; 1.26 + protected int sp; 1.27 1.28 /** 1.29 * Create a scanner from the input array. This method might 1.30 @@ -76,6 +86,7 @@ 1.31 1.32 protected UnicodeReader(ScannerFactory sf, char[] input, int inputLength) { 1.33 log = sf.log; 1.34 + names = sf.names; 1.35 if (inputLength == input.length) { 1.36 if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { 1.37 inputLength--; 1.38 @@ -103,6 +114,48 @@ 1.39 } 1.40 } 1.41 1.42 + /** Read next character in comment, skipping over double '\' characters. 1.43 + */ 1.44 + protected void scanCommentChar() { 1.45 + scanChar(); 1.46 + if (ch == '\\') { 1.47 + if (peekChar() == '\\' && !isUnicode()) { 1.48 + skipChar(); 1.49 + } else { 1.50 + convertUnicode(); 1.51 + } 1.52 + } 1.53 + } 1.54 + 1.55 + /** Append a character to sbuf. 1.56 + */ 1.57 + protected void putChar(char ch, boolean scan) { 1.58 + if (sp == sbuf.length) { 1.59 + char[] newsbuf = new char[sbuf.length * 2]; 1.60 + System.arraycopy(sbuf, 0, newsbuf, 0, sbuf.length); 1.61 + sbuf = newsbuf; 1.62 + } 1.63 + sbuf[sp++] = ch; 1.64 + if (scan) 1.65 + scanChar(); 1.66 + } 1.67 + 1.68 + protected void putChar(char ch) { 1.69 + putChar(ch, false); 1.70 + } 1.71 + 1.72 + protected void putChar(boolean scan) { 1.73 + putChar(ch, scan); 1.74 + } 1.75 + 1.76 + Name name() { 1.77 + return names.fromChars(sbuf, 0, sp); 1.78 + } 1.79 + 1.80 + String chars() { 1.81 + return new String(sbuf, 0, sp); 1.82 + } 1.83 + 1.84 /** Convert unicode escape; bp points to initial '\' character 1.85 * (Spec 3.3). 1.86 */