1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-29 02:50:11 +00:00

#815 working on moving control flow graphs into procedure compilation.

This commit is contained in:
jespergravgaard 2023-04-10 10:23:00 +02:00
parent 40182a6ad6
commit c78b8c59b1
4 changed files with 21 additions and 21 deletions

View File

@ -18,6 +18,10 @@ public interface Graph {
void addBlock(Graph.Block block);
default List<Statement> getAllStatements() {
return getAllBlocks().stream().map(Block::getStatements).flatMap(Collection::stream).toList();
}
default List<Graph.Block> getPredecessors(Graph.Block block) {
ArrayList<Block> predecessorBlocks = new ArrayList<>();
for(Graph.Block other : getAllBlocks()) {

View File

@ -1,6 +1,5 @@
package dk.camelot64.kickc.model;
import dk.camelot64.kickc.model.statements.Statement;
import dk.camelot64.kickc.model.values.ProcedureRef;
/**

View File

@ -14,7 +14,6 @@ import dk.camelot64.kickc.passes.utils.ProcedureUtils;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
/** A KickC Intermediate Compiler Language (ICL) Program */
public class Program {

View File

@ -19,12 +19,11 @@ public class Pass1AssertInterrupts extends Pass1Base {
@Override
public boolean step() {
for(var block : getGraph().getAllBlocks()) {
for(Statement statement : block.getStatements()) {
for(Statement statement : getGraph().getAllStatements()) {
if(statement instanceof StatementCalling) {
ProcedureRef procedureRef = ((StatementCalling) statement).getProcedure();
Procedure procedure = getProgramScope().getProcedure(procedureRef);
if(procedure.getInterruptType()!=null) {
if(procedure.getInterruptType() != null) {
throw new CompileError("Interrupts cannot be called.", statement.getSource());
}
}
@ -42,7 +41,6 @@ public class Pass1AssertInterrupts extends Pass1Base {
}
}
}
}
return false;
}