equal
deleted
inserted
replaced
67 private final Check chk; |
67 private final Check chk; |
68 private final Resolve rs; |
68 private final Resolve rs; |
69 private final TreeMaker make; |
69 private final TreeMaker make; |
70 private final Names names; |
70 private final Names names; |
71 private final Target target; |
71 private final Target target; |
72 private final Type stringBufferType; |
|
73 private final Map<Type,Symbol> stringBufferAppend; |
72 private final Map<Type,Symbol> stringBufferAppend; |
74 private Name accessDollar; |
73 private Name accessDollar; |
75 private final Types types; |
74 private final Types types; |
76 private final Lower lower; |
75 private final Lower lower; |
77 private final Flow flow; |
76 private final Flow flow; |
105 rs = Resolve.instance(context); |
104 rs = Resolve.instance(context); |
106 make = TreeMaker.instance(context); |
105 make = TreeMaker.instance(context); |
107 target = Target.instance(context); |
106 target = Target.instance(context); |
108 types = Types.instance(context); |
107 types = Types.instance(context); |
109 methodType = new MethodType(null, null, null, syms.methodClass); |
108 methodType = new MethodType(null, null, null, syms.methodClass); |
110 stringBufferType = syms.stringBuilderType; |
|
111 stringBufferAppend = new HashMap<>(); |
109 stringBufferAppend = new HashMap<>(); |
112 accessDollar = names. |
110 accessDollar = names. |
113 fromString("access" + target.syntheticNameChar()); |
111 fromString("access" + target.syntheticNameChar()); |
114 flow = Flow.instance(context); |
112 flow = Flow.instance(context); |
115 lower = Lower.instance(context); |
113 lower = Lower.instance(context); |
2068 } |
2066 } |
2069 //where |
2067 //where |
2070 /** Make a new string buffer. |
2068 /** Make a new string buffer. |
2071 */ |
2069 */ |
2072 void makeStringBuffer(DiagnosticPosition pos) { |
2070 void makeStringBuffer(DiagnosticPosition pos) { |
2073 code.emitop2(new_, makeRef(pos, stringBufferType)); |
2071 code.emitop2(new_, makeRef(pos, syms.stringBuilderType)); |
2074 code.emitop0(dup); |
2072 code.emitop0(dup); |
2075 callMethod( |
2073 callMethod( |
2076 pos, stringBufferType, names.init, List.<Type>nil(), false); |
2074 pos, syms.stringBuilderType, names.init, List.<Type>nil(), false); |
2077 } |
2075 } |
2078 |
2076 |
2079 /** Append value (on tos) to string buffer (on tos - 1). |
2077 /** Append value (on tos) to string buffer (on tos - 1). |
2080 */ |
2078 */ |
2081 void appendString(JCTree tree) { |
2079 void appendString(JCTree tree) { |
2089 Assert.checkNull(t.constValue()); |
2087 Assert.checkNull(t.constValue()); |
2090 Symbol method = stringBufferAppend.get(t); |
2088 Symbol method = stringBufferAppend.get(t); |
2091 if (method == null) { |
2089 if (method == null) { |
2092 method = rs.resolveInternalMethod(tree.pos(), |
2090 method = rs.resolveInternalMethod(tree.pos(), |
2093 attrEnv, |
2091 attrEnv, |
2094 stringBufferType, |
2092 syms.stringBuilderType, |
2095 names.append, |
2093 names.append, |
2096 List.of(t), |
2094 List.of(t), |
2097 null); |
2095 null); |
2098 stringBufferAppend.put(t, method); |
2096 stringBufferAppend.put(t, method); |
2099 } |
2097 } |
2120 /** Convert string buffer on tos to string. |
2118 /** Convert string buffer on tos to string. |
2121 */ |
2119 */ |
2122 void bufferToString(DiagnosticPosition pos) { |
2120 void bufferToString(DiagnosticPosition pos) { |
2123 callMethod( |
2121 callMethod( |
2124 pos, |
2122 pos, |
2125 stringBufferType, |
2123 syms.stringBuilderType, |
2126 names.toString, |
2124 names.toString, |
2127 List.<Type>nil(), |
2125 List.<Type>nil(), |
2128 false); |
2126 false); |
2129 } |
2127 } |
2130 |
2128 |