1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-21 14:30:21 +00:00

Merge branch 'fix-procedure-code-segment-updates' into 'master'

Fixes functions declared in header files not assigned the correct code segment.

See merge request camelot/kickc!26
This commit is contained in:
Jesper Balman Gravgaard 2023-02-18 18:47:36 +00:00
commit addfe05454
2 changed files with 6 additions and 1 deletions

View File

@ -34,7 +34,7 @@ public class Procedure extends Scope {
/** Reserved zeropage addresses. */
private List<Integer> reservedZps;
/** The code segment to put the procedure into. */
private final String codeSegment;
private String codeSegment;
/** The list of constructor procedures for this procedure. The constructor procedures are called during program initialization. */
private final List<ProcedureRef> constructorRefs;
/** Is this procedure declared as a constructor procedure. */
@ -117,6 +117,10 @@ public class Procedure extends Scope {
return codeSegment;
}
public void setCodeSegment(String codeSegment) {
this.codeSegment = codeSegment;
}
public List<String> getParameterNames() {
return parameterNames;
}

View File

@ -548,6 +548,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
parameterList.add(paramVar);
}
procedure.setParameters(parameterList);
procedure.setCodeSegment(currentCodeSegment); // When a procedure is defined, the currentCodeSegment is to be set.
// Add return variable
if(!SymbolType.VOID.equals(procedure.getReturnType())) {
final VariableBuilder builder = new VariableBuilder("return", procedure, false, false, procedure.getReturnType(), varDecl.getDeclDirectives(), currentDataSegment, program.getTargetPlatform().getVariableBuilderConfig());