Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 43344 Details for
Bug 145047
use chars instead of strings to process signatures in UnresolvedType
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
possible start of implementation
pr141730-asm-patch.txt (text/plain), 15.58 KB, created by
Helen Beeken
on 2006-06-02 08:23:25 EDT
(
hide
)
Description:
possible start of implementation
Filename:
MIME Type:
Creator:
Helen Beeken
Created:
2006-06-02 08:23:25 EDT
Size:
15.58 KB
patch
obsolete
>Index: src/org/aspectj/asm/IProgramElement.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/asm/src/org/aspectj/asm/IProgramElement.java,v >retrieving revision 1.23 >diff -u -r1.23 IProgramElement.java >--- src/org/aspectj/asm/IProgramElement.java 1 Jun 2006 09:33:56 -0000 1.23 >+++ src/org/aspectj/asm/IProgramElement.java 1 Jun 2006 10:46:15 -0000 >@@ -116,12 +116,13 @@ > public String toLabelString(); > public String toLabelString(boolean getFullyQualifiedArgTypes); > >- public List getParameterTypes(); >- public void setParameterTypes(List list); >- > public List getParameterNames(); > public void setParameterNames(List list); > >+ public List getParameterSignatures(); >+ public void setParameterSignatures(List list); >+ public List getParameterTypes(); >+ > /** > * The format of the string handle is not specified, but is stable across > * compilation sessions. >Index: src/org/aspectj/asm/internal/ProgramElement.java >=================================================================== >RCS file: /home/technology/org.aspectj/modules/asm/src/org/aspectj/asm/internal/ProgramElement.java,v >retrieving revision 1.31 >diff -u -r1.31 ProgramElement.java >--- src/org/aspectj/asm/internal/ProgramElement.java 1 Jun 2006 09:33:56 -0000 1.31 >+++ src/org/aspectj/asm/internal/ProgramElement.java 1 Jun 2006 10:46:15 -0000 >@@ -408,16 +408,22 @@ > sb.append(name); > > List ptypes = getParameterTypes(); >- if (ptypes != null) { >+ if (ptypes != null && (!ptypes.isEmpty() >+ || this.kind.equals(IProgramElement.Kind.METHOD)) >+ || this.kind.equals(IProgramElement.Kind.CONSTRUCTOR) >+ || this.kind.equals(IProgramElement.Kind.ADVICE) >+ || this.kind.equals(IProgramElement.Kind.POINTCUT) >+ || this.kind.equals(IProgramElement.Kind.INTER_TYPE_METHOD) >+ || this.kind.equals(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR)) { > sb.append('('); > for (Iterator it = ptypes.iterator(); it.hasNext(); ) { >- String arg = (String)it.next(); >+ char[] arg = (char[])it.next(); > if (getFullyQualifiedArgTypes) { > sb.append(arg); > } else { >- int index = arg.lastIndexOf("."); >+ int index = CharOperation.lastIndexOf('.',arg); > if (index != -1) { >- sb.append(arg.substring(index + 1)); >+ sb.append(CharOperation.subarray(arg,index+1,arg.length)); > } else { > sb.append(arg); > } >@@ -503,17 +509,29 @@ > //parameterNames = list; > } > >- public List getParameterTypes() { >- List parameterTypes = (List)kvpairs.get("parameterTypes"); >- return parameterTypes; >+ public List getParameterTypes() { >+ List l = getParameterSignatures(); >+ if (l == null || l.isEmpty()) { >+ return Collections.EMPTY_LIST; >+ } >+ List params = new ArrayList(); >+ for (Iterator iter = l.iterator(); iter.hasNext();) { >+ params.add(createReadableName((char[]) iter.next())); >+ } >+ return params; > } >- public void setParameterTypes(List list) { >- if (kvpairs==Collections.EMPTY_MAP) kvpairs = new HashMap(); >- if (list==null || list.size()==0) kvpairs.put("parameterTypes",Collections.EMPTY_LIST); >- else kvpairs.put("parameterTypes",list); >-// parameterTypes = list; >+ >+ public List getParameterSignatures() { >+ List parameters = (List)kvpairs.get("parameterSigs"); >+ return parameters; > } > >+ public void setParameterSignatures(List list) { >+ if (kvpairs==Collections.EMPTY_MAP) kvpairs = new HashMap(); >+ if (list==null || list.size()==0) kvpairs.put("parameterSigs",Collections.EMPTY_LIST); >+ else kvpairs.put("parameterSigs",list); >+ } >+ > public String getDetails() { > String details = (String)kvpairs.get("details"); > return details; >@@ -548,5 +566,87 @@ > public ExtraInformation getExtraInfo() { > return (ExtraInformation)kvpairs.get("ExtraInformation"); > } >+ >+ /** >+ * Creates a readable name from the given char array, for example, >+ * given 'I' returns 'int'. Moreover, given >+ * 'Ljava/lang/String;<Ljava/lang/String;>' returns >+ * 'java.lang.String<java.lang.String>' >+ */ >+ private char[] createReadableName(char[] c) { >+ int lt = CharOperation.indexOf('<',c); >+ int sc = CharOperation.indexOf(';',c); >+ int gt = CharOperation.indexOf('>',c); >+ >+ int smallest = 0; >+ if (lt == -1 && sc == -1 && gt == -1) { >+ // we have something like 'Ljava/lang/String' or 'I' >+ return getTypeName(c); >+ } else if (lt != -1 && (sc == -1 || lt <= sc) && (gt == -1 || lt <= gt)) { >+ // we have something like 'Ljava/lang/String<I' >+ smallest = lt; >+ } else if (sc != -1 && (lt == -1 || sc <= lt) && (gt == -1 || sc <= gt)) { >+ // we have something like 'Ljava/lang/String;I' >+ smallest = sc; >+ } else { >+ // we have something like '>;' >+ smallest = gt; >+ } >+ char[] first = CharOperation.subarray(c,0,smallest); >+ char[] second = CharOperation.subarray(c,smallest+1,c.length); >+ if (smallest == 0 && first.length == 0 && c[0] == '>') { >+ // c = {'>',';'} therefore we just want to return '>' to >+ // close the generic signature >+ return new char[]{'>'}; >+ } else if (first.length == 1 && second.length == 0) { >+ return first; >+ } else if (second.length == 0 || (second.length == 1 && second[0] == ';')){ >+ // we've reached the end of the array, therefore only care about >+ // the first part >+ return createReadableName(first); >+ } else if (smallest == lt) { >+ // if c = 'Ljava/lang/String;<I' then first = 'Ljava/Lang/String;' and >+ // second = 'I'. Want to end up with 'Ljava.lang.String<I' and so add >+ // the '<' back. >+ char[] inclLT = CharOperation.concat(createReadableName(first),new char[]{'<'}); >+ return CharOperation.concat(inclLT,createReadableName(second)); >+ } else if (smallest == gt) { >+ char[] inclLT = CharOperation.concat(createReadableName(first),new char[]{'>'}); >+ return CharOperation.concat(inclLT,createReadableName(second)); >+ } else if (second.length != 2) { >+ // if c = 'Ljava/lang/Sting;LMyClass' then first = 'Ljava/lang/String' >+ // and second = 'LMyClass'. Want to end up with 'java.lang.String,MyClass >+ // so want to add a ','. However, only want to do this if we're in the >+ // middle of a '<...>' >+ char[] inclComma = CharOperation.concat(createReadableName(first),new char[]{','}); >+ return CharOperation.concat(inclComma,createReadableName(second)); >+ } >+ return CharOperation.concat(createReadableName(first),createReadableName(second)); >+ } >+ >+ /** >+ * Given a char array, returns the type name for this. For example, given >+ * 'I' returns 'int' and given 'Ljava/lang/String' returns 'java.lang.String' >+ * Doesn't go any deaper so given 'Ljava/lang/String;<Ljava/lang/String;>' it >+ * returns 'java.lang.String;<Ljava.lang.String;>'. To create a fully readable >+ * name use createReadableName(char[]) >+ */ >+ private char[] getTypeName(char[] c) { >+ if (c.length == 0) { >+ return c; >+ } >+ SignatureType st = SignatureType.getSignatureTypeForChar(c[0]); >+ if (st.isPrimitiveType()) { >+ return st.getTypeName(); >+ } else if (st.isArray()) { >+ return CharOperation.concat( >+ getTypeName(CharOperation.subarray(c,1,c.length)), >+ new char[]{'[',']'}); >+ } else { >+ char[] type = CharOperation.subarray(c,1,c.length); >+ CharOperation.replace(type,'/','.'); >+ return type; >+ } >+ } > } > >Index: src/org/aspectj/asm/internal/CharOperation.java >=================================================================== >RCS file: src/org/aspectj/asm/internal/CharOperation.java >diff -N src/org/aspectj/asm/internal/CharOperation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/aspectj/asm/internal/CharOperation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,107 @@ >+/******************************************************************** >+ * Copyright (c) 2006 Contributors. All rights reserved. >+ * This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution and is available at >+ * http://eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: IBM Corporation - initial API and implementation >+ * Helen Hawkins - iniital version >+ *******************************************************************/ >+package org.aspectj.asm.internal; >+ >+ >+/** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ * >+ */ >+public class CharOperation { >+ >+ /** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ */ >+ public static final int indexOf(char toBeFound, char[] array) { >+ for (int i = 0; i < array.length; i++) >+ if (toBeFound == array[i]) >+ return i; >+ return -1; >+ } >+ >+ /** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ */ >+ public static final char[] subarray(char[] array, int start, int end) { >+ if (end == -1) >+ end = array.length; >+ if (start > end) >+ return null; >+ if (start < 0) >+ return null; >+ if (end > array.length) >+ return null; >+ >+ char[] result = new char[end - start]; >+ System.arraycopy(array, start, result, 0, end - start); >+ return result; >+ } >+ >+ /** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ */ >+ public static final void replace( >+ char[] array, >+ char toBeReplaced, >+ char replacementChar) { >+ if (toBeReplaced != replacementChar) { >+ for (int i = 0, max = array.length; i < max; i++) { >+ if (array[i] == toBeReplaced) >+ array[i] = replacementChar; >+ } >+ } >+ } >+ >+ /** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ */ >+ public static final int lastIndexOf(char toBeFound, char[] array) { >+ for (int i = array.length; --i >= 0;) >+ if (toBeFound == array[i]) >+ return i; >+ return -1; >+ } >+ >+ /** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ */ >+ public static final char[] concat(char[] first, char[] second) { >+ if (first == null) >+ return second; >+ if (second == null) >+ return first; >+ >+ int length1 = first.length; >+ int length2 = second.length; >+ char[] result = new char[length1 + length2]; >+ System.arraycopy(first, 0, result, 0, length1); >+ System.arraycopy(second, 0, result, length1, length2); >+ return result; >+ } >+ >+ /** >+ * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation >+ */ >+ public static final boolean equals(char[] first, char[] second) { >+ if (first == second) >+ return true; >+ if (first == null || second == null) >+ return false; >+ if (first.length != second.length) >+ return false; >+ >+ for (int i = first.length; --i >= 0;) >+ if (first[i] != second[i]) >+ return false; >+ return true; >+ } >+ >+} >Index: src/org/aspectj/asm/internal/SignatureType.java >=================================================================== >RCS file: src/org/aspectj/asm/internal/SignatureType.java >diff -N src/org/aspectj/asm/internal/SignatureType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/aspectj/asm/internal/SignatureType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,128 @@ >+/******************************************************************** >+ * Copyright (c) 2006 Contributors. All rights reserved. >+ * This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution and is available at >+ * http://eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: IBM Corporation - initial API and implementation >+ * Helen Hawkins - iniital version >+ *******************************************************************/ >+package org.aspectj.asm.internal; >+ >+public class SignatureType { >+ >+ private static final char C_BOOLEAN = 'Z'; >+ private static final char C_BYTE = 'B'; >+ private static final char C_CHAR = 'C'; >+ private static final char C_DOUBLE = 'D'; >+ private static final char C_FLOAT = 'F'; >+ private static final char C_INT = 'I'; >+ private static final char C_LONG = 'J'; >+ private static final char C_SHORT = 'S'; >+ private static final char C_ARRAY = '['; >+ private static final char C_RESOLVED = 'L'; >+ private static final char C_UNRESOLVED = 'Q'; >+ >+ public static final SignatureType BOOLEAN = new SignatureType(C_BOOLEAN); >+ public static final SignatureType BYTE = new SignatureType(C_BYTE); >+ public static final SignatureType CHAR = new SignatureType(C_CHAR); >+ public static final SignatureType DOUBLE = new SignatureType(C_DOUBLE); >+ public static final SignatureType FLOAT = new SignatureType(C_FLOAT); >+ public static final SignatureType INT = new SignatureType(C_INT); >+ public static final SignatureType LONG = new SignatureType(C_LONG); >+ public static final SignatureType SHORT = new SignatureType(C_SHORT); >+ public static final SignatureType ARRAY = new SignatureType(C_ARRAY); >+ public static final SignatureType RESOLVED = new SignatureType(C_RESOLVED); >+ public static final SignatureType UNRESOLVED = new SignatureType(C_UNRESOLVED); >+ public static final SignatureType ERROR = new SignatureType('E'); >+ >+ private static final char[] c_boolean = new char[]{'b','o','o','l','e','a','n'}; >+ private static final char[] c_byte = new char[]{'b','y','t','e'}; >+ private static final char[] c_char = new char[]{'c','h','a','r'}; >+ private static final char[] c_double = new char[]{'d','o','u','b','l','e'}; >+ private static final char[] c_float = new char[]{'f','l','o','a','t'}; >+ private static final char[] c_int = new char[]{'i','n','t'}; >+ private static final char[] c_long = new char[]{'l','o','n','g'}; >+ private static final char[] c_short = new char[]{'s','h','o','r','t'}; >+ >+ public static final SignatureType[] ALL = { >+ BOOLEAN,BYTE,CHAR,DOUBLE,FLOAT,INT,LONG,SHORT,ARRAY,RESOLVED,UNRESOLVED >+ }; >+ >+ final char name; >+ >+ private SignatureType(char name) { >+ this.name = name; >+ } >+ >+ public char getName() { >+ return name; >+ } >+ >+ public static SignatureType getSignatureTypeForChar(char charType) { >+ for (int i = 0; i < ALL.length; i++) { >+ if (ALL[i].getName() == charType) return ALL[i]; >+ } >+ return ERROR; >+ } >+ >+ public static char getTypeForCharName(char[] charName) { >+ if (CharOperation.equals(charName,c_boolean)) { >+ return C_BOOLEAN; >+ } else if (CharOperation.equals(charName,c_byte)) { >+ return C_BYTE; >+ } else if (CharOperation.equals(charName,c_char)) { >+ return C_CHAR; >+ } else if (CharOperation.equals(charName,c_double)) { >+ return C_DOUBLE; >+ } else if (CharOperation.equals(charName,c_float)) { >+ return C_FLOAT; >+ } else if (CharOperation.equals(charName,c_int)) { >+ return C_INT; >+ } else if (CharOperation.equals(charName,c_long)) { >+ return C_LONG; >+ } else if (CharOperation.equals(charName,c_short)) { >+ return C_SHORT; >+ } else { >+ return C_UNRESOLVED; >+ } >+ } >+ >+ public char[] getTypeName() { >+ if (this.equals(BOOLEAN)) { >+ return c_boolean; >+ } else if (this.equals(BYTE)) { >+ return c_byte; >+ } else if (this.equals(CHAR)) { >+ return c_char; >+ } else if (this.equals(DOUBLE)) { >+ return c_double; >+ } else if (this.equals(FLOAT)) { >+ return c_float; >+ } else if (this.equals(INT)) { >+ return c_int; >+ } else if (this.equals(LONG)) { >+ return c_long; >+ } else if (this.equals(SHORT)) { >+ return c_short; >+ } >+ return new char[0]; >+ } >+ >+ public boolean isArray() { >+ return this == ARRAY; >+ } >+ >+ public boolean isPrimitiveType() { >+ return this == BOOLEAN >+ || this == BYTE >+ || this == CHAR >+ || this == DOUBLE >+ || this == FLOAT >+ || this == INT >+ || this == LONG >+ || this == SHORT; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 145047
: 43344