Adding local functions through builder
This commit is contained in:
@@ -44,6 +44,7 @@ public interface JetControlFlowBuilder {
|
|||||||
// Declarations
|
// Declarations
|
||||||
void declare(@NotNull JetParameter parameter);
|
void declare(@NotNull JetParameter parameter);
|
||||||
void declare(@NotNull JetVariableDeclaration property);
|
void declare(@NotNull JetVariableDeclaration property);
|
||||||
|
void declareFunction(@NotNull JetElement subroutine, @NotNull Pseudocode pseudocode);
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
import org.jetbrains.jet.lang.cfg.pseudocode.Pseudocode;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
||||||
@@ -208,6 +207,12 @@ public class JetControlFlowBuilderAdapter implements JetControlFlowBuilder {
|
|||||||
builder.declare(property);
|
builder.declare(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void declareFunction(@NotNull JetElement subroutine, @NotNull Pseudocode pseudocode) {
|
||||||
|
assert builder != null;
|
||||||
|
builder.declareFunction(subroutine, pseudocode);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void repeatPseudocode(@NotNull Label startLabel, @NotNull Label finishLabel) {
|
public void repeatPseudocode(@NotNull Label startLabel, @NotNull Label finishLabel) {
|
||||||
assert builder != null;
|
assert builder != null;
|
||||||
|
|||||||
+6
-2
@@ -74,8 +74,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
|
JetControlFlowInstructionsGeneratorWorker worker = popBuilder(subroutine);
|
||||||
if (!builders.empty()) {
|
if (!builders.empty()) {
|
||||||
JetControlFlowInstructionsGeneratorWorker builder = builders.peek();
|
JetControlFlowInstructionsGeneratorWorker builder = builders.peek();
|
||||||
LocalFunctionDeclarationInstruction instruction = new LocalFunctionDeclarationInstruction(subroutine, worker.getPseudocode());
|
builder.declareFunction(subroutine, worker.getPseudocode());
|
||||||
builder.add(instruction);
|
|
||||||
}
|
}
|
||||||
return worker.getPseudocode();
|
return worker.getPseudocode();
|
||||||
}
|
}
|
||||||
@@ -247,6 +246,11 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd
|
|||||||
add(new VariableDeclarationInstruction(property));
|
add(new VariableDeclarationInstruction(property));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void declareFunction(@NotNull JetElement subroutine, @NotNull Pseudocode pseudocode) {
|
||||||
|
add(new LocalFunctionDeclarationInstruction(subroutine, pseudocode));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(@NotNull JetElement element) {
|
public void read(@NotNull JetElement element) {
|
||||||
add(new ReadValueInstruction(element));
|
add(new ReadValueInstruction(element));
|
||||||
|
|||||||
Reference in New Issue
Block a user