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:
parent
40182a6ad6
commit
c78b8c59b1
@ -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()) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dk.camelot64.kickc.model;
|
||||
|
||||
import dk.camelot64.kickc.model.statements.Statement;
|
||||
import dk.camelot64.kickc.model.values.ProcedureRef;
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user