1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Fixed type inference for StackIdxValue. Added a few missing stack fragments for __stackcall with pointers.

This commit is contained in:
jespergravgaard 2020-02-26 11:44:15 +01:00
parent ee18c2c414
commit e1e17f6152
6 changed files with 16 additions and 3 deletions

View File

@ -0,0 +1,4 @@
lda #>{c1}
pha
lda #<{c1}
pha

View File

@ -0,0 +1,4 @@
lda {m1}+1
pha
lda {m1}
pha

View File

@ -0,0 +1,5 @@
tsx
lda STACK_BASE+{c1},x
sta {m1}
lda STACK_BASE+{c1}+1,x
sta {m1}+1

View File

@ -141,7 +141,7 @@ public class ControlFlowGraph implements Serializable {
public List<ControlFlowBlock> getEntryPointBlocks(Program program) {
List<ControlFlowBlock> entryPointBlocks = new ArrayList<>();
for(Procedure procedure : program.getScope().getAllProcedures(true)) {
if(Pass2ConstantIdentification.isAddressOfUsed(procedure.getRef(), program) || procedure.getCallingConvension().equals(Procedure.CallingConvension.STACK_CALL)) {
if(Pass2ConstantIdentification.isAddressOfUsed(procedure.getRef(), program) || Procedure.CallingConvension.STACK_CALL.equals(procedure.getCallingConvension())) {
// Address-of is used on the procedure
Label procedureLabel = procedure.getLabel();
ControlFlowBlock procedureBlock = getBlock(procedureLabel.getRef());

View File

@ -114,7 +114,7 @@ public class SymbolTypeInference {
} else if(rValue instanceof ParamValue) {
return inferType(symbols, ((ParamValue) rValue).getParameter());
} else if(rValue instanceof StackIdxValue) {
return SymbolType.BYTE;
return ((StackIdxValue) rValue).getValueType();
} else if(rValue instanceof MemsetValue) {
return ((MemsetValue) rValue).getType();
} else if(rValue instanceof MemcpyValue) {

View File

@ -21,7 +21,7 @@ public class Pass1AssertNoRecursion extends Pass1Base {
Collection<Procedure> procedures = getScope().getAllProcedures(true);
for(Procedure procedure : procedures) {
Collection<ScopeRef> recursiveCalls = callGraph.getRecursiveCalls(procedure.getRef());
if(recursiveCalls.contains(procedure.getRef()) && !procedure.getCallingConvension().equals(Procedure.CallingConvension.STACK_CALL)) {
if(recursiveCalls.contains(procedure.getRef()) && !Procedure.CallingConvension.STACK_CALL.equals(procedure.getCallingConvension())) {
throw new CompileError("ERROR! Recursion not allowed! Occurs in " + procedure.getRef());
}
}