-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #167 - infinite loop representation
- Loading branch information
1 parent
7fba9d8
commit 57b396b
Showing
6 changed files
with
137 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...er/bytecode/analysis/structured/statement/AbstractStructuredConditionalLoopStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.benf.cfr.reader.bytecode.analysis.structured.statement; | ||
|
||
import org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement; | ||
import org.benf.cfr.reader.bytecode.analysis.parse.expression.ConditionalExpression; | ||
import org.benf.cfr.reader.bytecode.analysis.parse.rewriters.ExpressionRewriter; | ||
import org.benf.cfr.reader.bytecode.analysis.parse.utils.BlockIdentifier; | ||
import org.benf.cfr.reader.bytecode.analysis.parse.utils.scope.LValueScopeDiscoverer; | ||
import org.benf.cfr.reader.bytecode.analysis.structured.StructuredStatement; | ||
import org.benf.cfr.reader.state.TypeUsageCollector; | ||
|
||
import java.util.List; | ||
|
||
// do / while. | ||
public abstract class AbstractStructuredConditionalLoopStatement extends AbstractStructuredBlockStatement { | ||
protected ConditionalExpression condition; | ||
protected final BlockIdentifier block; | ||
|
||
AbstractStructuredConditionalLoopStatement(ConditionalExpression condition, BlockIdentifier block, Op04StructuredStatement body) { | ||
super(body); | ||
this.condition = condition; | ||
this.block = block; | ||
} | ||
|
||
public BlockIdentifier getBlock() { | ||
return block; | ||
} | ||
|
||
public ConditionalExpression getCondition() { | ||
return condition; | ||
} | ||
|
||
@Override | ||
public BlockIdentifier getBreakableBlockOrNull() { | ||
return block; | ||
} | ||
|
||
@Override | ||
public boolean supportsBreak() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void collectTypeUsages(TypeUsageCollector collector) { | ||
collector.collectFrom(condition); | ||
super.collectTypeUsages(collector); | ||
} | ||
|
||
public boolean isInfinite() { | ||
return condition == null; | ||
} | ||
|
||
@Override | ||
public boolean isScopeBlock() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean supportsContinueBreak() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void traceLocalVariableScope(LValueScopeDiscoverer scopeDiscoverer) { | ||
if (condition != null) { | ||
condition.collectUsedLValues(scopeDiscoverer); | ||
} | ||
scopeDiscoverer.processOp04Statement(getBody()); | ||
} | ||
|
||
@Override | ||
public void linearizeInto(List<StructuredStatement> out) { | ||
out.add(this); | ||
getBody().linearizeStatementsInto(out); | ||
} | ||
|
||
@Override | ||
public void rewriteExpressions(ExpressionRewriter expressionRewriter) { | ||
if (condition != null) { | ||
condition = expressionRewriter.rewriteExpression(condition, null, this.getContainer(), null); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.