mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-08 17:54:40 +00:00
Added aseetion stopping compilation at pass 3 if any value list has survived.
This commit is contained in:
parent
347fc03f47
commit
4bcf51732b
@ -206,7 +206,6 @@ public class Compiler {
|
|||||||
ssaOptimized = true;
|
ssaOptimized = true;
|
||||||
getLog().append("CONTROL FLOW GRAPH");
|
getLog().append("CONTROL FLOW GRAPH");
|
||||||
getLog().append(program.getGraph().toString(program));
|
getLog().append(program.getGraph().toString(program));
|
||||||
//pass2AssertSSA(program);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,6 +214,8 @@ public class Compiler {
|
|||||||
|
|
||||||
private void pass3Analysis() {
|
private void pass3Analysis() {
|
||||||
|
|
||||||
|
new Pass3AssertNoValueLists(program).check();
|
||||||
|
|
||||||
new Pass3BlockSequencePlanner(program).plan();
|
new Pass3BlockSequencePlanner(program).plan();
|
||||||
|
|
||||||
// Phi lifting ensures that all variables in phi-blocks are in different live range equivalence classes
|
// Phi lifting ensures that all variables in phi-blocks are in different live range equivalence classes
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package dk.camelot64.kickc.passes;
|
||||||
|
|
||||||
|
import dk.camelot64.kickc.model.CompileError;
|
||||||
|
import dk.camelot64.kickc.model.Program;
|
||||||
|
import dk.camelot64.kickc.model.RValue;
|
||||||
|
import dk.camelot64.kickc.model.ValueList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert that no value lists still exist inside the code.
|
||||||
|
*/
|
||||||
|
public class Pass3AssertNoValueLists extends Pass2SsaAssertion {
|
||||||
|
|
||||||
|
public Pass3AssertNoValueLists(Program program) {
|
||||||
|
super(program);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void check() throws AssertionFailed {
|
||||||
|
ValueReplacer.executeAll(getGraph(), (replaceable, currentStmt, stmtIt, currentBlock) -> {
|
||||||
|
RValue value = replaceable.get();
|
||||||
|
if(value instanceof ValueList) {
|
||||||
|
throw new CompileError(
|
||||||
|
"Error! Value list not resolved to word constructor or array initializer" +
|
||||||
|
"\n value list: " + value.toString(getProgram()) +
|
||||||
|
"\n statement: " + currentStmt.toString(getProgram(), false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -323,7 +323,7 @@ public class PassNVariableReferenceInfos extends Pass2Base {
|
|||||||
} else if (rValue instanceof ValueList) {
|
} else if (rValue instanceof ValueList) {
|
||||||
LinkedHashSet<SymbolRef> used = new LinkedHashSet<>();
|
LinkedHashSet<SymbolRef> used = new LinkedHashSet<>();
|
||||||
for (RValue value : ((ValueList) rValue).getList()) {
|
for (RValue value : ((ValueList) rValue).getList()) {
|
||||||
used.addAll(getReferencedVars(value));
|
used.addAll(getReferenced(value));
|
||||||
}
|
}
|
||||||
return used;
|
return used;
|
||||||
} else {
|
} else {
|
||||||
|
@ -339,6 +339,10 @@ public class TestPrograms extends TestCase {
|
|||||||
assertError("invalid-consttype", "Constant variable has a non-matching type");
|
assertError("invalid-consttype", "Constant variable has a non-matching type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testValueListError() throws IOException, URISyntaxException {
|
||||||
|
assertError("valuelist-error", "Value list not resolved to word constructor");
|
||||||
|
}
|
||||||
|
|
||||||
private void assertError(String kcFile, String expectError) throws IOException, URISyntaxException {
|
private void assertError(String kcFile, String expectError) throws IOException, URISyntaxException {
|
||||||
try {
|
try {
|
||||||
compileAndCompare(kcFile);
|
compileAndCompare(kcFile);
|
||||||
|
5
src/main/java/dk/camelot64/kickc/test/valuelist-error.kc
Normal file
5
src/main/java/dk/camelot64/kickc/test/valuelist-error.kc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
void main() {
|
||||||
|
word w = { -1, -1};
|
||||||
|
byte* screen = $400;
|
||||||
|
*screen = <w;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user