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