Skip to content

Commit 6710a31

Browse files
committed
Fix bug introduced in ea449cf.
Possible return types will actually be empty for primitives.
1 parent f52bf4e commit 6710a31

File tree

1 file changed

+40
-52
lines changed

1 file changed

+40
-52
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/StreamStateMachine.java

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,11 @@ private static boolean deriveRomForVoidMethod(SSAInvokeInstruction invokeInstruc
208208
return true;
209209
else if (isTerminalOperationWhereReduceOrderDoesNotMatter(declaredTarget))
210210
return false;
211-
else
212-
throw new IllegalStateException("Can't decipher ROM for method: " + declaredTarget);
211+
else {
212+
boolean ret = true;
213+
LOGGER.warning(() -> "Can't decipher ROM for method: " + declaredTarget + ". Defaulting to: " + ret);
214+
return ret;
215+
}
213216
}
214217

215218
/**
@@ -558,7 +561,6 @@ private void discoverIfReduceOrderingPossiblyMatters(EclipseProjectAnalysisEngin
558561
assert numOfRetVals <= 1 : "How could you possibly return " + numOfRetVals + " values?";
559562

560563
Collection<TypeAbstraction> possibleReturnTypes = null;
561-
Boolean rom = null;
562564

563565
// if it's a non-void method.
564566
if (numOfRetVals > 0) {
@@ -567,63 +569,49 @@ private void discoverIfReduceOrderingPossiblyMatters(EclipseProjectAnalysisEngin
567569
possibleReturnTypes = Util.getPossibleTypesInterprocedurally(block.getNode(), returnValue, engine,
568570
orderingInference);
569571

570-
// if no return types can be found.
571-
if (possibleReturnTypes.isEmpty()) {
572-
// default to true.
573-
rom = true;
574-
575-
LOGGER.warning("Number of returned values is: " + numOfRetVals
576-
+ " but cannot find possible return types for node: " + block.getNode()
577-
+ " and return value: " + returnValue + ". Defaulting ROM to: " + rom + " for block: "
578-
+ block + ".");
579-
} else
580-
LOGGER.info("While determining ROM, found number of possible return types: "
581-
+ possibleReturnTypes.size());
582-
583572
LOGGER.fine("Possible reduce types are: " + possibleReturnTypes);
584573
} else
585574
// it's a void method.
586575
possibleReturnTypes = Collections.singleton(JavaPrimitiveType.VOID);
587576

588-
// if we haven't determined ROM yet.
589-
if (rom == null)
590-
if (isVoid(possibleReturnTypes))
591-
rom = deriveRomForVoidMethod(invokeInstruction);
592-
else {
593-
boolean scalar = Util.isScalar(possibleReturnTypes);
594-
if (scalar)
595-
try {
596-
rom = deriveRomForScalarMethod(invokeInstruction);
597-
} catch (UnknownIfReduceOrderMattersException e) {
598-
// for each possible receiver associated with the terminal block.
599-
OrdinalSet<InstanceKey> receivers = this.terminalBlockToPossibleReceivers.get(block);
600-
601-
for (InstanceKey instanceKey : receivers) {
602-
// get the stream for the instance key.
603-
Set<InstanceKey> originStreams = this.computePossibleOriginStreams(instanceKey);
604-
605-
// for each origin stream.
606-
for (InstanceKey origin : originStreams) {
607-
// get the "Stream" representing it.
608-
Stream stream = this.instanceToStreamMap.get(origin);
609-
610-
if (stream == null)
611-
LOGGER.warning(() -> "Can't find Stream instance for instance key: "
612-
+ instanceKey + " using origin: " + origin);
613-
else {
614-
LOGGER.log(Level.WARNING,
615-
"Unable to derive ROM for : " + stream.getCreation(), e);
616-
stream.addStatusEntry(
617-
PreconditionFailure.NON_DETERMINABLE_REDUCTION_ORDERING,
618-
"Cannot derive reduction ordering for stream: "
619-
+ stream.getCreation() + ".");
620-
}
577+
Boolean rom = null;
578+
579+
if (isVoid(possibleReturnTypes))
580+
rom = deriveRomForVoidMethod(invokeInstruction);
581+
else {
582+
boolean scalar = Util.isScalar(possibleReturnTypes);
583+
if (scalar)
584+
try {
585+
rom = deriveRomForScalarMethod(invokeInstruction);
586+
} catch (UnknownIfReduceOrderMattersException e) {
587+
// for each possible receiver associated with the terminal block.
588+
OrdinalSet<InstanceKey> receivers = this.terminalBlockToPossibleReceivers.get(block);
589+
590+
for (InstanceKey instanceKey : receivers) {
591+
// get the stream for the instance key.
592+
Set<InstanceKey> originStreams = this.computePossibleOriginStreams(instanceKey);
593+
594+
// for each origin stream.
595+
for (InstanceKey origin : originStreams) {
596+
// get the "Stream" representing it.
597+
Stream stream = this.instanceToStreamMap.get(origin);
598+
599+
if (stream == null)
600+
LOGGER.warning(() -> "Can't find Stream instance for instance key: "
601+
+ instanceKey + " using origin: " + origin);
602+
else {
603+
LOGGER.log(Level.WARNING, "Unable to derive ROM for : " + stream.getCreation(),
604+
e);
605+
stream.addStatusEntry(PreconditionFailure.NON_DETERMINABLE_REDUCTION_ORDERING,
606+
"Cannot derive reduction ordering for stream: " + stream.getCreation()
607+
+ ".");
621608
}
622609
}
623610
}
624-
else // !scalar
625-
rom = this.deriveRomForNonScalarMethod(possibleReturnTypes, orderingInference);
626-
}
611+
}
612+
else // !scalar
613+
rom = this.deriveRomForNonScalarMethod(possibleReturnTypes, orderingInference);
614+
}
627615

628616
// if reduce ordering matters.
629617
if (rom != null)

0 commit comments

Comments
 (0)