Pseudocode: Do not store "synthetic" flag of magic instructions
This commit is contained in:
@@ -115,8 +115,7 @@ public interface JetControlFlowBuilder {
|
||||
@NotNull JetElement instructionElement,
|
||||
@Nullable JetElement valueElement,
|
||||
@NotNull List<PseudoValue> inputValues,
|
||||
@NotNull Map<PseudoValue, TypePredicate> expectedTypes,
|
||||
boolean synthetic
|
||||
@NotNull Map<PseudoValue, TypePredicate> expectedTypes
|
||||
);
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -71,10 +71,9 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil
|
||||
@NotNull JetElement instructionElement,
|
||||
@Nullable JetElement valueElement,
|
||||
@NotNull List<PseudoValue> inputValues,
|
||||
@NotNull Map<PseudoValue, TypePredicate> expectedTypes,
|
||||
boolean synthetic
|
||||
@NotNull Map<PseudoValue, TypePredicate> expectedTypes
|
||||
) {
|
||||
return getDelegateBuilder().magic(instructionElement, valueElement, inputValues, expectedTypes, synthetic);
|
||||
return getDelegateBuilder().magic(instructionElement, valueElement, inputValues, expectedTypes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -180,13 +180,13 @@ public class JetControlFlowProcessor {
|
||||
@NotNull
|
||||
private PseudoValue createSyntheticValue(@NotNull JetElement instructionElement, JetElement... from) {
|
||||
List<PseudoValue> values = elementsToValues(from.length > 0 ? Arrays.asList(from) : Collections.<JetElement>emptyList());
|
||||
return builder.magic(instructionElement, null, values, defaultTypeMap(values), true).getOutputValue();
|
||||
return builder.magic(instructionElement, null, values, defaultTypeMap(values)).getOutputValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PseudoValue createNonSyntheticValue(@NotNull JetElement to, @NotNull List<? extends JetElement> from) {
|
||||
List<PseudoValue> values = elementsToValues(from);
|
||||
return builder.magic(to, to, values, defaultTypeMap(values), false).getOutputValue();
|
||||
return builder.magic(to, to, values, defaultTypeMap(values)).getOutputValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -886,8 +886,7 @@ public class JetControlFlowProcessor {
|
||||
loopRange != null ? loopRange : expression,
|
||||
null,
|
||||
Collections.singletonList(loopRangeValue),
|
||||
Collections.singletonMap(loopRangeValue, loopRangeTypePredicate),
|
||||
true
|
||||
Collections.singletonMap(loopRangeValue, loopRangeTypePredicate)
|
||||
).getOutputValue();
|
||||
|
||||
if (loopParameter != null) {
|
||||
@@ -1387,7 +1386,7 @@ public class JetControlFlowProcessor {
|
||||
if (expectedTypePredicate == null) {
|
||||
expectedTypePredicate = AllTypes.instance$;
|
||||
}
|
||||
builder.magic(specifier, specifier, arguments, PseudocodePackage.expectedTypeFor(expectedTypePredicate, arguments), false);
|
||||
builder.magic(specifier, specifier, arguments, PseudocodePackage.expectedTypeFor(expectedTypePredicate, arguments));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-5
@@ -418,7 +418,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@Override
|
||||
public InstructionWithValue loadStringTemplate(@NotNull JetStringTemplateExpression expression, @NotNull List<PseudoValue> inputValues) {
|
||||
if (inputValues.isEmpty()) return read(expression);
|
||||
return magic(expression, expression, inputValues, PseudocodePackage.expectedTypeFor(AllTypes.instance$, inputValues), false);
|
||||
return magic(expression, expression, inputValues, PseudocodePackage.expectedTypeFor(AllTypes.instance$, inputValues));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -427,11 +427,10 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
@NotNull JetElement instructionElement,
|
||||
@Nullable JetElement valueElement,
|
||||
@NotNull List<PseudoValue> inputValues,
|
||||
@NotNull Map<PseudoValue, TypePredicate> expectedTypes,
|
||||
boolean synthetic
|
||||
@NotNull Map<PseudoValue, TypePredicate> expectedTypes
|
||||
) {
|
||||
MagicInstruction instruction = MagicInstruction.object$.create(
|
||||
instructionElement, valueElement, getCurrentScope(), synthetic, inputValues, expectedTypes, valueFactory
|
||||
instructionElement, valueElement, getCurrentScope(), inputValues, expectedTypes, valueFactory
|
||||
);
|
||||
add(instruction);
|
||||
return instruction;
|
||||
@@ -497,7 +496,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
||||
throw new IllegalArgumentException("Invalid operation: " + operation);
|
||||
}
|
||||
|
||||
return magic(expression, expression, inputValues, expectedTypes, false);
|
||||
return magic(expression, expression, inputValues, expectedTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-14
@@ -97,34 +97,30 @@ public class CallInstruction private(
|
||||
// consume input values (so that they aren't considered unused)
|
||||
// denote value transformation which can't be expressed by other instructions (such as call or read)
|
||||
// pass more than one value to instruction which formally requires only one (e.g. jump)
|
||||
// "Synthetic" means that the instruction does not correspond to some operation explicitly expressed by PSI element
|
||||
// Examples: providing initial values for parameters, missing right-hand side in assignments
|
||||
public class MagicInstruction(
|
||||
element: JetElement,
|
||||
lexicalScope: LexicalScope,
|
||||
val synthetic: Boolean,
|
||||
inputValues: List<PseudoValue>,
|
||||
val expectedTypes: Map<PseudoValue, TypePredicate>
|
||||
) : OperationInstruction(element, lexicalScope, inputValues), StrictlyValuedOperationInstruction {
|
||||
public val synthetic: Boolean get() = outputValue.element == null
|
||||
|
||||
override fun accept(visitor: InstructionVisitor) = visitor.visitMagic(this)
|
||||
|
||||
override fun <R> accept(visitor: InstructionVisitorWithResult<R>): R = visitor.visitMagic(this)
|
||||
|
||||
override fun createCopy() = MagicInstruction(element, lexicalScope, synthetic, inputValues, expectedTypes).setResult(resultValue)
|
||||
override fun createCopy() = MagicInstruction(element, lexicalScope, inputValues, expectedTypes).setResult(resultValue)
|
||||
|
||||
override fun toString() = renderInstruction("magic", render(element))
|
||||
|
||||
class object {
|
||||
fun create(
|
||||
element: JetElement,
|
||||
valueElement: JetElement?,
|
||||
lexicalScope: LexicalScope,
|
||||
synthetic: Boolean,
|
||||
inputValues: List<PseudoValue>,
|
||||
expectedTypes: Map<PseudoValue, TypePredicate>,
|
||||
factory: PseudoValueFactory
|
||||
): MagicInstruction = MagicInstruction(
|
||||
element, lexicalScope, synthetic, inputValues, expectedTypes
|
||||
fun create(element: JetElement,
|
||||
valueElement: JetElement?,
|
||||
lexicalScope: LexicalScope,
|
||||
inputValues: List<PseudoValue>,
|
||||
expectedTypes: Map<PseudoValue, TypePredicate>,
|
||||
factory: PseudoValueFactory): MagicInstruction = MagicInstruction(
|
||||
element, lexicalScope, inputValues, expectedTypes
|
||||
).setResult(factory, valueElement) as MagicInstruction
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user