mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 03:35: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:
parent
c19d0b2050
commit
e3d6782e51
2 changed files with 48 additions and 12 deletions
|
@ -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
|
2004-07-12 Alain Magloire
|
||||||
|
|
||||||
Remove some compiler warnings.
|
Remove some compiler warnings.
|
||||||
|
|
|
@ -66,10 +66,12 @@ public class GDBTypeParser {
|
||||||
// Initialize.
|
// Initialize.
|
||||||
line = s;
|
line = s;
|
||||||
index = 0;
|
index = 0;
|
||||||
|
tokenType = -1;
|
||||||
token = ""; //$NON-NLS-1$
|
token = ""; //$NON-NLS-1$
|
||||||
dataType = ""; //$NON-NLS-1$
|
dataType = ""; //$NON-NLS-1$
|
||||||
name = ""; //$NON-NLS-1$
|
name = ""; //$NON-NLS-1$
|
||||||
gdbDerivedType = null;
|
gdbDerivedType = null;
|
||||||
|
genericType = null;
|
||||||
|
|
||||||
// Fetch the datatype.
|
// Fetch the datatype.
|
||||||
while (getToken() == NAME) {
|
while (getToken() == NAME) {
|
||||||
|
@ -244,15 +246,22 @@ public class GDBTypeParser {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void prependChild(int kind) {
|
void insertingChild(int kind) {
|
||||||
prependChild(kind, 0);
|
insertingChild(kind, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prependChild(int kind, int d) {
|
void insertingChild(int kind, int d) {
|
||||||
if (gdbDerivedType == null) {
|
if (gdbDerivedType == null) {
|
||||||
gdbDerivedType = new GDBDerivedType(genericType, kind, d);
|
gdbDerivedType = new GDBDerivedType(genericType, kind, d);
|
||||||
} else {
|
} 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();
|
dirdcl();
|
||||||
while (nstar-- > 0) {
|
while (nstar-- > 0) {
|
||||||
prependChild(GDBType.POINTER);
|
insertingChild(GDBType.POINTER);
|
||||||
}
|
}
|
||||||
while (namp-- > 0) {
|
while (namp-- > 0) {
|
||||||
prependChild(GDBType.REFERENCE);
|
insertingChild(GDBType.REFERENCE);
|
||||||
}
|
}
|
||||||
|
//dirdcl();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse a direct declarator
|
// parse a direct declarator
|
||||||
|
@ -349,7 +360,7 @@ public class GDBTypeParser {
|
||||||
// Useless we do not need the name of the variable
|
// Useless we do not need the name of the variable
|
||||||
name = " " + token; //$NON-NLS-1$
|
name = " " + token; //$NON-NLS-1$
|
||||||
} else if (tokenType == PARENS) {
|
} else if (tokenType == PARENS) {
|
||||||
prependChild(GDBType.FUNCTION);
|
insertingChild(GDBType.FUNCTION);
|
||||||
} else if (tokenType == BRACKETS) {
|
} else if (tokenType == BRACKETS) {
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if (token.length() > 0) {
|
if (token.length() > 0) {
|
||||||
|
@ -358,7 +369,7 @@ public class GDBTypeParser {
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prependChild(GDBType.ARRAY, len);
|
insertingChild(GDBType.ARRAY, len);
|
||||||
} else {
|
} else {
|
||||||
// oops bad declaration ?
|
// oops bad declaration ?
|
||||||
return;
|
return;
|
||||||
|
@ -369,7 +380,7 @@ public class GDBTypeParser {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type == PARENS) {
|
if (type == PARENS) {
|
||||||
prependChild(GDBType.FUNCTION);
|
insertingChild(GDBType.FUNCTION);
|
||||||
} else {
|
} else {
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if (token.length() > 0) {
|
if (token.length() > 0) {
|
||||||
|
@ -378,7 +389,7 @@ public class GDBTypeParser {
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prependChild(GDBType.ARRAY, len);
|
insertingChild(GDBType.ARRAY, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,40 +398,60 @@ public class GDBTypeParser {
|
||||||
|
|
||||||
GDBTypeParser parser = new 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$
|
parser.parse("struct link { int i; int j; struct link * next} *"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("char **argv"); //$NON-NLS-1$
|
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(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("int (*daytab)[13]"); //$NON-NLS-1$
|
System.out.println("int (*daytab)[13]"); //$NON-NLS-1$
|
||||||
parser.parse("int (*daytab)[13]"); //$NON-NLS-1$
|
parser.parse("int (*daytab)[13]"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("int *daytab[13]"); //$NON-NLS-1$
|
System.out.println("int *daytab[13]"); //$NON-NLS-1$
|
||||||
parser.parse("int *daytab[13]"); //$NON-NLS-1$
|
parser.parse("int *daytab[13]"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("void *comp()"); //$NON-NLS-1$
|
System.out.println("void *comp()"); //$NON-NLS-1$
|
||||||
parser.parse("void *comp()"); //$NON-NLS-1$
|
parser.parse("void *comp()"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("void (*comp)()"); //$NON-NLS-1$
|
System.out.println("void (*comp)()"); //$NON-NLS-1$
|
||||||
parser.parse("void (*comp)()"); //$NON-NLS-1$
|
parser.parse("void (*comp)()"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("int (*func[15])()"); //$NON-NLS-1$
|
System.out.println("int (*func[15])()"); //$NON-NLS-1$
|
||||||
parser.parse("int (*func[15])()"); //$NON-NLS-1$
|
parser.parse("int (*func[15])()"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("char (*(*x())[])()"); //$NON-NLS-1$
|
System.out.println("char (*(*x())[])()"); //$NON-NLS-1$
|
||||||
parser.parse("char (*(*x())[])()"); //$NON-NLS-1$
|
parser.parse("char (*(*x())[])()"); //$NON-NLS-1$
|
||||||
System.out.println(parser.getGDBType().verbose());
|
System.out.println(parser.getGDBType().verbose());
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("char (*(*x[3])())[5]"); //$NON-NLS-1$
|
System.out.println("char (*(*x[3])())[5]"); //$NON-NLS-1$
|
||||||
parser.parse("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(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();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue