1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-01-14 09:30:57 +00:00

#814 Upgrade to Java 17 plus upgraded libraries.

This commit is contained in:
jespergravgaard 2023-04-06 08:44:31 +02:00
parent f864f61be2
commit a12a211d70
4 changed files with 26 additions and 28 deletions

24
pom.xml
View File

@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<argLine>-Xmx2048m</argLine> <argLine>-Xmx2048m</argLine>
</properties> </properties>
@ -47,24 +47,24 @@
<dependency> <dependency>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId> <artifactId>antlr4</artifactId>
<version>4.9.3</version> <version>4.12.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId> <artifactId>antlr4-runtime</artifactId>
<version>4.9.3</version> <version>4.12.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version> <version>5.9.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>info.picocli</groupId> <groupId>info.picocli</groupId>
<artifactId>picocli</artifactId> <artifactId>picocli</artifactId>
<version>4.6.2</version> <version>4.7.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>javax.json</groupId>
@ -124,7 +124,7 @@
<plugin> <plugin>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId> <artifactId>antlr4-maven-plugin</artifactId>
<version>4.9.3</version> <version>4.12.0</version>
<executions> <executions>
<execution> <execution>
<id>antlr</id> <id>antlr</id>
@ -152,7 +152,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version> <version>3.0.0-M9</version>
<configuration> <configuration>
<excludes> <excludes>
<exclude>**/TestFragments.java</exclude> <exclude>**/TestFragments.java</exclude>
@ -167,7 +167,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version> <version>0.8.9</version>
<executions> <executions>
<execution> <execution>
<id>pre-unit-test</id> <id>pre-unit-test</id>
@ -187,7 +187,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version> <version>3.3.0</version>
<configuration> <configuration>
<archive> <archive>
<manifest> <manifest>
@ -201,7 +201,7 @@
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>3.5.0</version> <version>5.1.8</version>
<executions> <executions>
<execution> <execution>
<id>bundle-manifest</id> <id>bundle-manifest</id>
@ -214,7 +214,7 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version> <version>3.5.0</version>
<configuration> <configuration>
<finalName>kickc</finalName> <finalName>kickc</finalName>
<tarLongFileMode>posix</tarLongFileMode> <tarLongFileMode>posix</tarLongFileMode>

View File

@ -1,13 +1,11 @@
package dk.camelot64.kickc.model.statements; package dk.camelot64.kickc.model.statements;
import dk.camelot64.kickc.model.Comment; import dk.camelot64.kickc.model.Comment;
import dk.camelot64.kickc.model.values.LabelRef;
import dk.camelot64.kickc.model.Program; import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.values.LabelRef;
import dk.camelot64.kickc.model.values.RValue; import dk.camelot64.kickc.model.values.RValue;
import dk.camelot64.kickc.model.values.VariableRef; import dk.camelot64.kickc.model.values.VariableRef;
import org.antlr.v4.runtime.RuleContext;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -24,7 +22,7 @@ public class StatementPhiBlock extends StatementBase {
private List<PhiVariable> phiVariables; private List<PhiVariable> phiVariables;
public StatementPhiBlock(List<Comment> comments) { public StatementPhiBlock(List<Comment> comments) {
super(new StatementSource(RuleContext.EMPTY), comments); super(StatementSource.NONE, comments);
this.phiVariables = new ArrayList<>(); this.phiVariables = new ArrayList<>();
} }

View File

@ -136,7 +136,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
initProc.setParameters(new ArrayList<>()); initProc.setParameters(new ArrayList<>());
program.getScope().add(initProc); program.getScope().add(initProc);
program.createProcedureCompilation(initProc.getRef()); program.createProcedureCompilation(initProc.getRef());
program.getProcedureCompilation(initProc.getRef()).getStatementSequence().addStatement(new StatementProcedureBegin(initProc.getRef(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); program.getProcedureCompilation(initProc.getRef()).getStatementSequence().addStatement(new StatementProcedureBegin(initProc.getRef(), StatementSource.NONE, Comment.NO_COMMENTS));
} }
return initProc; return initProc;
} }
@ -180,9 +180,9 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
if(initCompilation != null) { if(initCompilation != null) {
final StatementSequence initSequence = initCompilation.getStatementSequence(); final StatementSequence initSequence = initCompilation.getStatementSequence();
final Label initReturnLabel = program.getScope().getProcedure(initProcedureRef).addLabel(SymbolRef.PROCEXIT_BLOCK_NAME); final Label initReturnLabel = program.getScope().getProcedure(initProcedureRef).addLabel(SymbolRef.PROCEXIT_BLOCK_NAME);
initSequence.addStatement(new StatementLabel(initReturnLabel.getRef(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); initSequence.addStatement(new StatementLabel(initReturnLabel.getRef(), StatementSource.NONE, Comment.NO_COMMENTS));
initSequence.addStatement(new StatementReturn(null, new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); initSequence.addStatement(new StatementReturn(null, StatementSource.NONE, Comment.NO_COMMENTS));
initSequence.addStatement(new StatementProcedureEnd(initProcedureRef, new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); initSequence.addStatement(new StatementProcedureEnd(initProcedureRef, StatementSource.NONE, Comment.NO_COMMENTS));
} }
// Add the _start() procedure to the program // Add the _start() procedure to the program
@ -193,16 +193,16 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
program.getScope().add(startProcedure); program.getScope().add(startProcedure);
final ProcedureCompilation startProcedureCompilation = program.createProcedureCompilation(startProcedure.getRef()); final ProcedureCompilation startProcedureCompilation = program.createProcedureCompilation(startProcedure.getRef());
final StatementSequence startSequence = startProcedureCompilation.getStatementSequence(); final StatementSequence startSequence = startProcedureCompilation.getStatementSequence();
startSequence.addStatement(new StatementProcedureBegin(startProcedure.getRef(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementProcedureBegin(startProcedure.getRef(), StatementSource.NONE, Comment.NO_COMMENTS));
if(initCompilation != null) if(initCompilation != null)
startSequence.addStatement(new StatementCall(null, SymbolRef.INIT_PROC_NAME, new ArrayList<>(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementCall(null, SymbolRef.INIT_PROC_NAME, new ArrayList<>(), StatementSource.NONE, Comment.NO_COMMENTS));
final Procedure mainProc = program.getScope().getLocalProcedure(SymbolRef.MAIN_PROC_NAME); final Procedure mainProc = program.getScope().getLocalProcedure(SymbolRef.MAIN_PROC_NAME);
if(mainProc == null) if(mainProc == null)
throw new CompileError("Required main() not defined in program."); throw new CompileError("Required main() not defined in program.");
if(!SymbolType.VOID.equals(mainProc.getReturnType()) && !SymbolType.SWORD.equals(mainProc.getReturnType())) if(!SymbolType.VOID.equals(mainProc.getReturnType()) && !SymbolType.SWORD.equals(mainProc.getReturnType()))
throw new CompileError("return of main() must be 'void' or of type 'int'.", mainProc.getDefinitionSource()); throw new CompileError("return of main() must be 'void' or of type 'int'.", mainProc.getDefinitionSource());
if(mainProc.getParameterNames().size() == 0) { if(mainProc.getParameterNames().size() == 0) {
startSequence.addStatement(new StatementCall(null, SymbolRef.MAIN_PROC_NAME, new ArrayList<>(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementCall(null, SymbolRef.MAIN_PROC_NAME, new ArrayList<>(), StatementSource.NONE, Comment.NO_COMMENTS));
} else if(mainProc.getParameterNames().size() == 2) { } else if(mainProc.getParameterNames().size() == 2) {
final List<Variable> parameters = mainProc.getParameters(); final List<Variable> parameters = mainProc.getParameters();
final Variable argc = parameters.get(0); final Variable argc = parameters.get(0);
@ -214,15 +214,15 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
final ArrayList<RValue> params = new ArrayList<>(); final ArrayList<RValue> params = new ArrayList<>();
params.add(new ConstantInteger(0L, SymbolType.SWORD)); params.add(new ConstantInteger(0L, SymbolType.SWORD));
params.add(new ConstantPointer(0L, new SymbolTypePointer(SymbolType.BYTE))); params.add(new ConstantPointer(0L, new SymbolTypePointer(SymbolType.BYTE)));
startSequence.addStatement(new StatementCall(null, SymbolRef.MAIN_PROC_NAME, params, new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementCall(null, SymbolRef.MAIN_PROC_NAME, params, StatementSource.NONE, Comment.NO_COMMENTS));
} else } else
throw new CompileError("main() has wrong number of parameters. It must have zero or 2 parameters.", mainProc.getDefinitionSource()); throw new CompileError("main() has wrong number of parameters. It must have zero or 2 parameters.", mainProc.getDefinitionSource());
final Label startReturnLabel = startProcedure.addLabel(SymbolRef.PROCEXIT_BLOCK_NAME); final Label startReturnLabel = startProcedure.addLabel(SymbolRef.PROCEXIT_BLOCK_NAME);
startSequence.addStatement(new StatementLabel(startReturnLabel.getRef(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementLabel(startReturnLabel.getRef(), StatementSource.NONE, Comment.NO_COMMENTS));
startSequence.addStatement(new StatementReturn(null, new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementReturn(null, StatementSource.NONE, Comment.NO_COMMENTS));
startSequence.addStatement(new StatementProcedureEnd(startProcedure.getRef(), new StatementSource(RuleContext.EMPTY), Comment.NO_COMMENTS)); startSequence.addStatement(new StatementProcedureEnd(startProcedure.getRef(), StatementSource.NONE, Comment.NO_COMMENTS));
} }
} }

View File

@ -212,7 +212,7 @@ public class Pass4RegistersFinalize extends Pass2Base {
reserved = false; reserved = false;
int candidateZp = currentZp; int candidateZp = currentZp;
for(int i=0;i<size;i++) { for(int i=0;i<size;i++) {
if(reservedZp.contains(new Integer(candidateZp+i))) { if(reservedZp.contains(Integer.valueOf(candidateZp+i))) {
reserved = true; reserved = true;
currentZp++; currentZp++;
break; break;