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

Working in classic structs. #197

This commit is contained in:
jespergravgaard 2021-07-25 22:30:22 +02:00
parent 6d39582e5f
commit 47d6ea3f9a
2 changed files with 17 additions and 10 deletions

View File

@ -553,6 +553,7 @@ public class Compiler {
private void pass3Analysis() { private void pass3Analysis() {
if(program.getTargetPlatform().getVariableBuilderConfig().isStructModelClassic()) { if(program.getTargetPlatform().getVariableBuilderConfig().isStructModelClassic()) {
new Pass1UnwindStructValues(program).execute();
new PassNStructUnwoundPlaceholderRemoval(program).execute(); new PassNStructUnwoundPlaceholderRemoval(program).execute();
} }

View File

@ -2,7 +2,10 @@ package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.model.*; import dk.camelot64.kickc.model.*;
import dk.camelot64.kickc.model.statements.*; import dk.camelot64.kickc.model.statements.*;
import dk.camelot64.kickc.model.symbols.*; import dk.camelot64.kickc.model.symbols.Procedure;
import dk.camelot64.kickc.model.symbols.ProgramScope;
import dk.camelot64.kickc.model.symbols.Scope;
import dk.camelot64.kickc.model.symbols.Variable;
import dk.camelot64.kickc.model.types.SymbolType; import dk.camelot64.kickc.model.types.SymbolType;
import dk.camelot64.kickc.model.types.SymbolTypeStruct; import dk.camelot64.kickc.model.types.SymbolTypeStruct;
import dk.camelot64.kickc.model.values.*; import dk.camelot64.kickc.model.values.*;
@ -117,18 +120,21 @@ public class Pass1CallPhiParameters {
LValue procReturnVarRef = null; LValue procReturnVarRef = null;
if(procReturnVar != null) { if(procReturnVar != null) {
procReturnVarRef = (LValue) procReturnVar.getRef(); procReturnVarRef = (LValue) procReturnVar.getRef();
// Special handing of struct value returns // Special handing of struct value returns
if(procReturnVar.getType() instanceof SymbolTypeStruct) { if(!program.getTargetPlatform().getVariableBuilderConfig().isStructModelClassic())
StructVariableMemberUnwinding.VariableUnwinding returnVarUnwinding = program.getStructVariableMemberUnwinding().getVariableUnwinding((VariableRef) procReturnVarRef); if(procReturnVar.getType() instanceof SymbolTypeStruct) {
if(returnVarUnwinding != null) { StructVariableMemberUnwinding.VariableUnwinding returnVarUnwinding = program.getStructVariableMemberUnwinding().getVariableUnwinding((VariableRef) procReturnVarRef);
ArrayList<RValue> unwoundReturnVars = new ArrayList<>(); if(returnVarUnwinding != null) {
for(String memberName : returnVarUnwinding.getMemberNames()) { ArrayList<RValue> unwoundReturnVars = new ArrayList<>();
final SymbolVariableRef memberUnwound = returnVarUnwinding.getMemberUnwound(memberName); for(String memberName : returnVarUnwinding.getMemberNames()) {
unwoundReturnVars.add(memberUnwound); final SymbolVariableRef memberUnwound = returnVarUnwinding.getMemberUnwound(memberName);
unwoundReturnVars.add(memberUnwound);
}
procReturnVarRef = new ValueList(unwoundReturnVars);
} }
procReturnVarRef = new ValueList(unwoundReturnVars);
} }
}
} }
// Save original LValue and update the LValue // Save original LValue and update the LValue
final LValue origCallLValue = call.getlValue(); final LValue origCallLValue = call.getlValue();