Opened 16 years ago
Closed 16 years ago
#100 closed defect (fixed)
symbolic array dimensions are inverted
| Reported by: | Stephen Siegel | Owned by: | ywei |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | symbolic | Version: | 1.0 |
| Keywords: | symbolic array type | Cc: |
Description
If you ask the symbolic package for the array type with element type int[X1] and length X2, it returns the type int[X1][X2], when it should return the type int[X2][X1].
I think this is because there is a bug in the way the type is converted to a string in SymArray:
public String toString()
{
String result = baseType.toString() + "[";
if (dimension != null) result += dimension.toString();
result += "]";
return result;
}
and then this String is used as a key in a hashtable to retrieve the type in SymUniverse:
public SymType arrayType(SymType elementType, SymExpression dimension)
{
SymType temp = new SymArray(elementType, dimension);
if(typeTable.containsKey(temp.toString()))
{
return typeTable.get(temp.toString());
}
else
{
typeTable.put(temp.toString(), temp);
return temp;
}
}
By the way, I don't think it is a good idea to use the strings as keys in the hashtables. For one thing, constructing strings is very slow. It is also easy to make a mistake. Better to use something with a simple logic, like just give all the types a hashCode and look them up that way.
Change History (2)
comment:1 by , 16 years ago
| Owner: | set to |
|---|---|
| Status: | new → accepted |
comment:2 by , 16 years ago
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |

Bug fixed. The SymArray class now correctly place the dimension information in an orderly way. And I also changed the SymUniverse so that it doesn't use the string presentation of a symbolic type as the key in the type table.