1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 10:45:37 +02:00

2004-07-22 Alain Magloire

Fix for PR 70688
	* src/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java
This commit is contained in:
Alain Magloire 2004-07-22 19:49:09 +00:00
parent c19d0b2050
commit e3d6782e51
2 changed files with 48 additions and 12 deletions

View file

@ -1,3 +1,8 @@
2004-07-22 Alain Magloire
Fix for PR 70688
* src/org/eclipse/cdt/debug/mi/core/GDBTypeParser.java
2004-07-12 Alain Magloire
Remove some compiler warnings.

View file

@ -66,10 +66,12 @@ public class GDBTypeParser {
// 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,11 +337,13 @@ public class GDBTypeParser {
}
dirdcl();
while (nstar-- > 0) {
prependChild(GDBType.POINTER);
insertingChild(GDBType.POINTER);
}
while (namp-- > 0) {
prependChild(GDBType.REFERENCE);
insertingChild(GDBType.REFERENCE);
}
//dirdcl();
}
// parse a direct declarator
@ -349,7 +360,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 +369,7 @@ public class GDBTypeParser {
} catch (NumberFormatException e) {
}
}
prependChild(GDBType.ARRAY, len);
insertingChild(GDBType.ARRAY, len);
} else {
// oops bad declaration ?
return;
@ -369,7 +380,7 @@ public class GDBTypeParser {
return;
}
if (type == PARENS) {
prependChild(GDBType.FUNCTION);
insertingChild(GDBType.FUNCTION);
} else {
int len = 0;
if (token.length() > 0) {
@ -378,7 +389,7 @@ public class GDBTypeParser {
} catch (NumberFormatException e) {
}
}
prependChild(GDBType.ARRAY, len);
insertingChild(GDBType.ARRAY, len);
}
}
}
@ -387,40 +398,60 @@ 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("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("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();
}
}