equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.parser; |
26 package com.sun.tools.javac.parser; |
27 |
27 |
|
28 import java.nio.CharBuffer; |
|
29 import java.util.Arrays; |
|
30 |
28 import com.sun.tools.javac.file.JavacFileManager; |
31 import com.sun.tools.javac.file.JavacFileManager; |
|
32 import com.sun.tools.javac.util.ArrayUtils; |
29 import com.sun.tools.javac.util.Log; |
33 import com.sun.tools.javac.util.Log; |
30 import com.sun.tools.javac.util.Name; |
34 import com.sun.tools.javac.util.Name; |
31 import com.sun.tools.javac.util.Names; |
35 import com.sun.tools.javac.util.Names; |
32 |
|
33 import java.nio.CharBuffer; |
|
34 |
36 |
35 import static com.sun.tools.javac.util.LayoutCharacters.*; |
37 import static com.sun.tools.javac.util.LayoutCharacters.*; |
36 |
38 |
37 /** The char reader used by the javac lexer/tokenizer. Returns the sequence of |
39 /** The char reader used by the javac lexer/tokenizer. Returns the sequence of |
38 * characters contained in the input stream, handling unicode escape accordingly. |
40 * characters contained in the input stream, handling unicode escape accordingly. |
89 names = sf.names; |
91 names = sf.names; |
90 if (inputLength == input.length) { |
92 if (inputLength == input.length) { |
91 if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { |
93 if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { |
92 inputLength--; |
94 inputLength--; |
93 } else { |
95 } else { |
94 char[] newInput = new char[inputLength + 1]; |
96 input = Arrays.copyOf(input, inputLength + 1); |
95 System.arraycopy(input, 0, newInput, 0, input.length); |
|
96 input = newInput; |
|
97 } |
97 } |
98 } |
98 } |
99 buf = input; |
99 buf = input; |
100 buflen = inputLength; |
100 buflen = inputLength; |
101 buf[buflen] = EOI; |
101 buf[buflen] = EOI; |
128 } |
128 } |
129 |
129 |
130 /** Append a character to sbuf. |
130 /** Append a character to sbuf. |
131 */ |
131 */ |
132 protected void putChar(char ch, boolean scan) { |
132 protected void putChar(char ch, boolean scan) { |
133 if (sp == sbuf.length) { |
133 sbuf = ArrayUtils.ensureCapacity(sbuf, sp); |
134 char[] newsbuf = new char[sbuf.length * 2]; |
|
135 System.arraycopy(sbuf, 0, newsbuf, 0, sbuf.length); |
|
136 sbuf = newsbuf; |
|
137 } |
|
138 sbuf[sp++] = ch; |
134 sbuf[sp++] = ch; |
139 if (scan) |
135 if (scan) |
140 scanChar(); |
136 scanChar(); |
141 } |
137 } |
142 |
138 |