forked from jasder/antlr
v4: remove unnecessary casts
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9362]
This commit is contained in:
parent
d01c583e36
commit
1da1fe8002
|
@ -95,7 +95,7 @@ public abstract class BaseAST implements AST {
|
|||
if ( t==null ) {
|
||||
return; // do nothing upon addChild(null)
|
||||
}
|
||||
BaseAST childTree = (BaseAST)t;
|
||||
BaseAST childTree = t;
|
||||
if ( childTree.isNil() ) { // t is an empty node possibly with children
|
||||
if ( this.children!=null && this.children == childTree.children ) {
|
||||
throw new RuntimeException("attempt to add child list to itself");
|
||||
|
@ -240,7 +240,7 @@ public abstract class BaseAST implements AST {
|
|||
public void freshenParentAndChildIndexesDeeply(int offset) {
|
||||
int n = getChildCount();
|
||||
for (int c = offset; c < n; c++) {
|
||||
BaseAST child = (BaseAST)getChild(c);
|
||||
BaseAST child = getChild(c);
|
||||
child.setChildIndex(c);
|
||||
child.setParent(this);
|
||||
child.freshenParentAndChildIndexesDeeply();
|
||||
|
|
|
@ -57,7 +57,7 @@ public abstract class BaseASTAdaptor<T extends BaseAST> implements ASTAdaptor<T>
|
|||
|
||||
@Override
|
||||
public boolean isNil(T tree) {
|
||||
return ((AST)tree).isNil();
|
||||
return tree.isNil();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +96,7 @@ public abstract class BaseASTAdaptor<T extends BaseAST> implements ASTAdaptor<T>
|
|||
@Override
|
||||
public void addChild(T t, T child) {
|
||||
if ( t!=null && child!=null ) {
|
||||
((BaseAST)t).addChild((BaseAST) child);
|
||||
t.addChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,20 +231,20 @@ public abstract class BaseASTAdaptor<T extends BaseAST> implements ASTAdaptor<T>
|
|||
|
||||
@Override
|
||||
public int getChildCount(T t) {
|
||||
return ((BaseAST)t).getChildCount();
|
||||
return t.getChildCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUniqueID(T node) {
|
||||
if ( treeToUniqueIDMap==null ) {
|
||||
treeToUniqueIDMap = new HashMap();
|
||||
treeToUniqueIDMap = new HashMap<BaseAST, Integer>();
|
||||
}
|
||||
Integer prevID = (Integer)treeToUniqueIDMap.get(node);
|
||||
Integer prevID = treeToUniqueIDMap.get(node);
|
||||
if ( prevID!=null ) {
|
||||
return prevID;
|
||||
}
|
||||
int ID = uniqueNodeID;
|
||||
treeToUniqueIDMap.put((BaseAST)node, ID);
|
||||
treeToUniqueIDMap.put(node, ID);
|
||||
uniqueNodeID++;
|
||||
return ID;
|
||||
// GC makes these nonunique:
|
||||
|
|
Loading…
Reference in New Issue