Skip to content
Snippets Groups Projects
Commit 4590b17b authored by dgelessus's avatar dgelessus
Browse files

Remove no longer needed casts after clone calls

parent a7664fcb
Branches
Tags
No related merge requests found
Showing
with 28 additions and 34 deletions
...@@ -82,7 +82,7 @@ public class AddAstProductions extends DepthFirstAdapter ...@@ -82,7 +82,7 @@ public class AddAstProductions extends DepthFirstAdapter
@Override @Override
public void outAAlt(AAlt node) public void outAAlt(AAlt node)
{ {
TId aAltname = node.getAltName() == null ? null : (TId)node.getAltName().clone(); TId aAltname = node.getAltName() == null ? null : node.getAltName().clone();
AAstAlt astAlt = new AAstAlt(aAltname, listElems); AAstAlt astAlt = new AAstAlt(aAltname, listElems);
listOfAstAlts.add(astAlt); listOfAstAlts.add(astAlt);
...@@ -96,8 +96,7 @@ public class AddAstProductions extends DepthFirstAdapter ...@@ -96,8 +96,7 @@ public class AddAstProductions extends DepthFirstAdapter
{ {
if(processingParsedAlt) if(processingParsedAlt)
{ {
AElem tmp = (AElem)node.clone(); listElems.add(node.clone());
listElems.add(tmp);
} }
} }
......
...@@ -96,7 +96,7 @@ public class CharSet implements Cloneable ...@@ -96,7 +96,7 @@ public class CharSet implements Cloneable
public CharSet union(CharSet chars) public CharSet union(CharSet chars)
{ {
CharSet result = (CharSet) clone(); CharSet result = clone();
Interval interval; Interval interval;
Interval largeInterval; Interval largeInterval;
...@@ -104,7 +104,7 @@ public class CharSet implements Cloneable ...@@ -104,7 +104,7 @@ public class CharSet implements Cloneable
for(Enumeration e = chars.intervals.elements(); e.hasMoreElements();) for(Enumeration e = chars.intervals.elements(); e.hasMoreElements();)
{ {
interval = (Interval) ((Interval) e.nextElement()).clone(); interval = ((Interval) e.nextElement()).clone();
do do
{ {
...@@ -130,14 +130,14 @@ public class CharSet implements Cloneable ...@@ -130,14 +130,14 @@ public class CharSet implements Cloneable
public CharSet diff(CharSet chars) public CharSet diff(CharSet chars)
{ {
CharSet result = (CharSet) clone(); CharSet result = clone();
Interval interval; Interval interval;
Interval overlap; Interval overlap;
for(Enumeration e = chars.intervals.elements(); e.hasMoreElements();) for(Enumeration e = chars.intervals.elements(); e.hasMoreElements();)
{ {
interval = (Interval) ((Interval) e.nextElement()).clone(); interval = ((Interval) e.nextElement()).clone();
do do
{ {
......
...@@ -163,7 +163,7 @@ public class ComputeCGNomenclature extends DepthFirstAdapter ...@@ -163,7 +163,7 @@ public class ComputeCGNomenclature extends DepthFirstAdapter
if(name.startsWith("P") ) if(name.startsWith("P") )
{ {
//add termtail to the simpleterm //add termtail to the simpleterm
node.setSimpleTermTail( (TId)node.getId().clone() ); node.setSimpleTermTail(node.getId().clone());
} }
} }
else else
...@@ -259,7 +259,7 @@ public class ComputeCGNomenclature extends DepthFirstAdapter ...@@ -259,7 +259,7 @@ public class ComputeCGNomenclature extends DepthFirstAdapter
if( name.startsWith("P") ) if( name.startsWith("P") )
{ {
//add termtail to the simpleterm //add termtail to the simpleterm
node.setSimpleTermTail( (TId)node.getId().clone() ); node.setSimpleTermTail(node.getId().clone());
} }
} }
else else
......
...@@ -66,7 +66,7 @@ public class ComputeInlining ...@@ -66,7 +66,7 @@ public class ComputeInlining
if( prod.getAlts().size() <= SableCC.inliningMaxAlts && !isProductionRecursive(prod) ) if( prod.getAlts().size() <= SableCC.inliningMaxAlts && !isProductionRecursive(prod) )
{ {
//This class construct a special data structure for the production to inline. //This class construct a special data structure for the production to inline.
final In_Production in_production = new In_Production((AProd)prod.clone()); final In_Production in_production = new In_Production(prod.clone());
tree.apply(new DepthFirstAdapter() tree.apply(new DepthFirstAdapter()
{ {
......
...@@ -222,7 +222,7 @@ public class DFA ...@@ -222,7 +222,7 @@ public class DFA
if(dest != null) if(dest != null)
{ {
state.transitions.addElement( state.transitions.addElement(
new Transition((CharSet.Interval) interval.clone(), dest.intValue())); new Transition(interval.clone(), dest.intValue()));
} }
else else
{ {
...@@ -231,7 +231,7 @@ public class DFA ...@@ -231,7 +231,7 @@ public class DFA
finder.put(s.nfaStates, states.size() - 1); finder.put(s.nfaStates, states.size() - 1);
state.transitions.addElement( state.transitions.addElement(
new Transition((CharSet.Interval) interval.clone(), states.size() - 1)); new Transition(interval.clone(), states.size() - 1));
} }
} }
......
...@@ -314,8 +314,7 @@ public final class Grammar ...@@ -314,8 +314,7 @@ public final class Grammar
for(int i = 0; i < productions.length; i++) for(int i = 0; i < productions.length; i++)
{ {
SymbolSet before = SymbolSet before = FIRST_Nonterminal[productions[i].leftside].clone();
(SymbolSet) FIRST_Nonterminal[productions[i].leftside].clone();
FIRST_Nonterminal[productions[i].leftside]. FIRST_Nonterminal[productions[i].leftside].
or(FIRST(productions[i].rightside())); or(FIRST(productions[i].rightside()));
...@@ -429,8 +428,7 @@ public final class Grammar ...@@ -429,8 +428,7 @@ public final class Grammar
{ {
if(!rightside[j].terminal) if(!rightside[j].terminal)
{ {
SymbolSet before = SymbolSet before = FOLLOW[rightside[j].index].clone();
(SymbolSet) FOLLOW[rightside[j].index].clone();
if(FIRST(rightside, j + 1).getEmpty()) if(FIRST(rightside, j + 1).getEmpty())
{ {
......
...@@ -97,7 +97,7 @@ public class In_Production ...@@ -97,7 +97,7 @@ public class In_Production
for(int i=0; i<listOfElems.length; i++) for(int i=0; i<listOfElems.length; i++)
{ {
AElem tmpElem = (AElem)listOfElems[i].clone(); AElem tmpElem = listOfElems[i].clone();
if(tmpElem.getElemName() != null) if(tmpElem.getElemName() != null)
{ {
......
...@@ -251,8 +251,7 @@ public class Inlining ...@@ -251,8 +251,7 @@ public class Inlining
LinkedList listElems = inlineList(aParsed_alt.getElems(), LinkedList listElems = inlineList(aParsed_alt.getElems(),
prod_to_inline.getAlternative(j).getElems(), prod_to_inline.getAlternative(j).getElems(),
mapOfNewTermNames); mapOfNewTermNames);
AAltTransform aAltTransform = AAltTransform aAltTransform = ((AAltTransform)aParsed_alt.getAltTransform()).clone();
(AAltTransform)((AAltTransform)aParsed_alt.getAltTransform()).clone();
final Map<String, Node> currentMap = prod_to_inline.getAlternative(j).getProdTransform_AlTransformMap(); final Map<String, Node> currentMap = prod_to_inline.getAlternative(j).getProdTransform_AlTransformMap();
aAltTransform.apply(new DepthFirstAdapter() aAltTransform.apply(new DepthFirstAdapter()
...@@ -312,8 +311,8 @@ public class Inlining ...@@ -312,8 +311,8 @@ public class Inlining
public void caseANewTerm(ANewTerm node) public void caseANewTerm(ANewTerm node)
{ {
node_.replaceBy( new ANewListTerm( (AProdName)node.getProdName().clone(), node_.replaceBy( new ANewListTerm( (AProdName)node.getProdName().clone(),
(TLPar)node.getLPar().clone(), node.getLPar().clone(),
(LinkedList)cloneList(node.getParams()) cloneList(node.getParams())
) )
); );
} }
...@@ -329,10 +328,10 @@ public class Inlining ...@@ -329,10 +328,10 @@ public class Inlining
} }
if(node.getSimpleTermTail() != null) if(node.getSimpleTermTail() != null)
{ {
simpleTermTail = (TId)node.getSimpleTermTail().clone(); simpleTermTail = node.getSimpleTermTail().clone();
} }
node_.replaceBy( new ASimpleListTerm( specifier, node_.replaceBy( new ASimpleListTerm( specifier,
(TId)node.getId().clone(), node.getId().clone(),
simpleTermTail simpleTermTail
) )
); );
...@@ -384,7 +383,7 @@ public class Inlining ...@@ -384,7 +383,7 @@ public class Inlining
} }
); );
AAltTransform tmpaAltTransform = (AAltTransform)aAltTransform.clone(); AAltTransform tmpaAltTransform = aAltTransform.clone();
fixSimpleTermOrSimpleListTermNames(tmpaAltTransform, mapOfNewTermNames); fixSimpleTermOrSimpleListTermNames(tmpaAltTransform, mapOfNewTermNames);
String newAltName; String newAltName;
if(aParsed_alt.getAltName() != null) if(aParsed_alt.getAltName() != null)
......
...@@ -18,7 +18,7 @@ public class IntSet ...@@ -18,7 +18,7 @@ public class IntSet
private IntSet(IntSet set private IntSet(IntSet set
) )
{ {
elements = (int[]) set.elements.clone(); elements = set.elements.clone();
} }
public void and(IntSet set public void and(IntSet set
...@@ -331,8 +331,7 @@ public class IntSet ...@@ -331,8 +331,7 @@ public class IntSet
if(set if(set
== this) == this)
{ {
set set = set.clone();
= (IntSet) set.clone();
} }
int length = 0; int length = 0;
......
...@@ -183,14 +183,14 @@ public class InternalTransformationsToGrammar extends DepthFirstAdapter ...@@ -183,14 +183,14 @@ public class InternalTransformationsToGrammar extends DepthFirstAdapter
if(node.getAltName() != null) if(node.getAltName() != null)
{ {
nameOfAlt = (TId)node.getAltName().clone(); nameOfAlt = node.getAltName().clone();
} }
currentNewAltName = currentProd + "." + currentAltName.toLowerCase(); currentNewAltName = currentProd + "." + currentAltName.toLowerCase();
altIds.alts_elems.put(currentNewAltName, listElemsAltTransform); altIds.alts_elems.put(currentNewAltName, listElemsAltTransform);
altIds.alts_elems_list_elemName.put(currentNewAltName, listOfAlternativeElemsWHaveName); altIds.alts_elems_list_elemName.put(currentNewAltName, listOfAlternativeElemsWHaveName);
AAltTransform altTransform = (AAltTransform)currentAltTransform.clone(); AAltTransform altTransform = currentAltTransform.clone();
AltTransformAdapter altTransformAdapter = AltTransformAdapter altTransformAdapter =
new AltTransformAdapter(simpleTermTransform, listSimpleTermTransform, new AltTransformAdapter(simpleTermTransform, listSimpleTermTransform,
...@@ -247,7 +247,7 @@ public class InternalTransformationsToGrammar extends DepthFirstAdapter ...@@ -247,7 +247,7 @@ public class InternalTransformationsToGrammar extends DepthFirstAdapter
altIds.alts_elems.put(currentNewAltName, listElemsAltTransform); altIds.alts_elems.put(currentNewAltName, listElemsAltTransform);
altIds.alts_elems_list_elemName.put(currentNewAltName, listOfAlternativeElemsWHaveName); altIds.alts_elems_list_elemName.put(currentNewAltName, listOfAlternativeElemsWHaveName);
altTransform = (AAltTransform)currentAltTransform.clone(); altTransform = currentAltTransform.clone();
AltTransformAdapter altTransformAdapter = AltTransformAdapter altTransformAdapter =
new AltTransformAdapter(simpleTermTransform, listSimpleTermTransform, new AltTransformAdapter(simpleTermTransform, listSimpleTermTransform,
......
...@@ -138,8 +138,7 @@ final class LR1Collection ...@@ -138,8 +138,7 @@ final class LR1Collection
{ {
LR0ItemAndSetPair pair = (LR0ItemAndSetPair) e.nextElement(); LR0ItemAndSetPair pair = (LR0ItemAndSetPair) e.nextElement();
SymbolSet before = (SymbolSet) SymbolSet before = ((SymbolSet) lookaheads[pair.set].get(pair.item)).clone();
((SymbolSet) lookaheads[pair.set].get(pair.item)).clone();
((SymbolSet) lookaheads[pair.set].get(pair.item)). ((SymbolSet) lookaheads[pair.set].get(pair.item)).
or((SymbolSet) lookaheads[i].get(items[j])); or((SymbolSet) lookaheads[i].get(items[j]));
......
...@@ -50,8 +50,8 @@ final class SymbolSet implements Cloneable ...@@ -50,8 +50,8 @@ final class SymbolSet implements Cloneable
private SymbolSet(SymbolSet set private SymbolSet(SymbolSet set
) )
{ {
this.terminals = (IntSet) set.terminals.clone(); this.terminals = set.terminals.clone();
this.nonterminals = (IntSet) set.nonterminals.clone(); this.nonterminals = set.nonterminals.clone();
this.empty = set.empty; this.empty = set.empty;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment