1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-10 10:35:23 +02:00

2004-07-22 Alain Magloire

Fix for 70688
	* src/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java
This commit is contained in:
Alain Magloire 2004-07-22 20:08:23 +00:00
parent d8cb99728b
commit 94c289a630
2 changed files with 42 additions and 13 deletions

View file

@ -1,3 +1,8 @@
2004-07-22 Alain Magloire
Fix for 70688
* src/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java
2004-07-12 Alain Magloire
Patch from Stefan Bylund, to permit backend

View file

@ -60,16 +60,18 @@ public class GDBTypeParser {
if (s == null) {
s = new String();
}
s = Pattern.compile("\\bconst\\b").matcher(s).replaceAll("");
s = Pattern.compile("\\bconst\\b").matcher(s).replaceAll(""); //$NON-NLS-1$//$NON-NLS-2$
s = s.trim();
// Initialize.
line = s;
index = 0;
tokenType = -1;
token = ""; //$NON-NLS-1$
dataType = ""; //$NON-NLS-1$
name = ""; //$NON-NLS-1$
gdbDerivedType = null;
genericType = null;
// Fetch the datatype.
while (getToken() == NAME) {
@ -244,15 +246,22 @@ public class GDBTypeParser {
return false;
}
void prependChild(int kind) {
prependChild(kind, 0);
void insertingChild(int kind) {
insertingChild(kind, 0);
}
void prependChild(int kind, int d) {
void insertingChild(int kind, int d) {
if (gdbDerivedType == null) {
gdbDerivedType = new GDBDerivedType(genericType, kind, d);
} else {
gdbDerivedType = new GDBDerivedType(gdbDerivedType, kind, d);
GDBDerivedType dType = gdbDerivedType;
GDBType gdbType = gdbDerivedType.getChild();
while (gdbType instanceof GDBDerivedType) {
dType = (GDBDerivedType)gdbType;
gdbType = dType.getChild();
}
gdbType = new GDBDerivedType(gdbType, kind, d);
dType.setChild(gdbType);
}
}
@ -328,10 +337,10 @@ public class GDBTypeParser {
}
dirdcl();
while (nstar-- > 0) {
prependChild(GDBType.POINTER);
insertingChild(GDBType.POINTER);
}
while (namp-- > 0) {
prependChild(GDBType.REFERENCE);
insertingChild(GDBType.REFERENCE);
}
}
@ -349,7 +358,7 @@ public class GDBTypeParser {
// Useless we do not need the name of the variable
name = " " + token; //$NON-NLS-1$
} else if (tokenType == PARENS) {
prependChild(GDBType.FUNCTION);
insertingChild(GDBType.FUNCTION);
} else if (tokenType == BRACKETS) {
int len = 0;
if (token.length() > 0) {
@ -358,7 +367,7 @@ public class GDBTypeParser {
} catch (NumberFormatException e) {
}
}
prependChild(GDBType.ARRAY, len);
insertingChild(GDBType.ARRAY, len);
} else {
// oops bad declaration ?
return;
@ -369,7 +378,7 @@ public class GDBTypeParser {
return;
}
if (type == PARENS) {
prependChild(GDBType.FUNCTION);
insertingChild(GDBType.FUNCTION);
} else {
int len = 0;
if (token.length() > 0) {
@ -378,7 +387,7 @@ public class GDBTypeParser {
} catch (NumberFormatException e) {
}
}
prependChild(GDBType.ARRAY, len);
insertingChild(GDBType.ARRAY, len);
}
}
}
@ -387,40 +396,55 @@ public class GDBTypeParser {
GDBTypeParser parser = new GDBTypeParser();
System.out.println("struct link { int i; int j; struct link * next} *"); //$NON-NLS-1$
System.out.println("struct link { int i; int j; struct link * next;} *"); //$NON-NLS-1$
parser.parse("struct link { int i; int j; struct link * next} *"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("char **argv"); //$NON-NLS-1$
parser.parse("unsigned long long int **argv"); //$NON-NLS-1$
parser.parse("char **argv"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("int (*daytab)[13]"); //$NON-NLS-1$
parser.parse("int (*daytab)[13]"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("int *daytab[13]"); //$NON-NLS-1$
parser.parse("int *daytab[13]"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("void *comp()"); //$NON-NLS-1$
parser.parse("void *comp()"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("void (*comp)()"); //$NON-NLS-1$
parser.parse("void (*comp)()"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("int (*func[15])()"); //$NON-NLS-1$
parser.parse("int (*func[15])()"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("char (*(*x())[])()"); //$NON-NLS-1$
parser.parse("char (*(*x())[])()"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("char (*(*x[3])())[5]"); //$NON-NLS-1$
parser.parse("char (*(*x[3])())[5]"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
System.out.println("char *[5]"); //$NON-NLS-1$
parser.parse("char *[5]"); //$NON-NLS-1$
System.out.println(parser.getGDBType().verbose());
System.out.println();
}
}