1 /* |
1 /* |
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 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 |
64 this.elems = elems; |
64 this.elems = elems; |
65 this.types = types; |
65 this.types = types; |
66 } |
66 } |
67 |
67 |
68 public final String mangle(CharSequence name, int mtype) { |
68 public final String mangle(CharSequence name, int mtype) { |
69 StringBuffer result = new StringBuffer(100); |
69 StringBuilder result = new StringBuilder(100); |
70 int length = name.length(); |
70 int length = name.length(); |
71 |
71 |
72 for (int i = 0; i < length; i++) { |
72 for (int i = 0; i < length; i++) { |
73 char ch = name.charAt(i); |
73 char ch = name.charAt(i); |
74 if (isalnum(ch)) { |
74 if (isalnum(ch)) { |
113 return result.toString(); |
113 return result.toString(); |
114 } |
114 } |
115 |
115 |
116 public String mangleMethod(ExecutableElement method, TypeElement clazz, |
116 public String mangleMethod(ExecutableElement method, TypeElement clazz, |
117 int mtype) throws TypeSignature.SignatureException { |
117 int mtype) throws TypeSignature.SignatureException { |
118 StringBuffer result = new StringBuffer(100); |
118 StringBuilder result = new StringBuilder(100); |
119 result.append("Java_"); |
119 result.append("Java_"); |
120 |
120 |
121 if (mtype == Mangle.Type.METHOD_JDK_1) { |
121 if (mtype == Mangle.Type.METHOD_JDK_1) { |
122 result.append(mangle(clazz.getQualifiedName(), Mangle.Type.CLASS)); |
122 result.append(mangle(clazz.getQualifiedName(), Mangle.Type.CLASS)); |
123 result.append('_'); |
123 result.append('_'); |
162 return new String(result); |
162 return new String(result); |
163 } |
163 } |
164 |
164 |
165 // Warning: duplicated in Gen |
165 // Warning: duplicated in Gen |
166 private String signature(ExecutableElement e) { |
166 private String signature(ExecutableElement e) { |
167 StringBuffer sb = new StringBuffer(); |
167 StringBuilder sb = new StringBuilder(); |
168 String sep = "("; |
168 String sep = "("; |
169 for (VariableElement p: e.getParameters()) { |
169 for (VariableElement p: e.getParameters()) { |
170 sb.append(sep); |
170 sb.append(sep); |
171 sb.append(types.erasure(p.asType()).toString()); |
171 sb.append(types.erasure(p.asType()).toString()); |
172 sep = ","; |
172 sep = ","; |