diff --git a/.githooks/pre-push.sh b/.githooks/pre-push.sh
deleted file mode 100755
index 09b2a4d0b..000000000
--- a/.githooks/pre-push.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-mvn verify
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 770d35368..45a714b78 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -15,7 +15,7 @@ on:
branches: ["main"]
jobs:
- verify-and-artifact:
+ artifact:
runs-on: ubuntu-latest
steps:
@@ -30,8 +30,8 @@ jobs:
uses: r-lib/actions/setup-r@v2
with:
r-version: "4.3.2"
- - name: Run tests and static analyses
- run: mvn --batch-mode --update-snapshots verify
+ - name: Build artifact
+ run: mvn --batch-mode --update-snapshots package
- run: mkdir staging && cp target/*.jar staging
- name: Upload snapshot as artifact
uses: actions/upload-artifact@v3
@@ -42,6 +42,42 @@ jobs:
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
+ test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 21
+ uses: actions/setup-java@v3
+ with:
+ java-version: "21"
+ distribution: "temurin"
+ cache: maven
+ - name: Set up GNU-R
+ uses: r-lib/actions/setup-r@v2
+ with:
+ r-version: "4.3.2"
+ - name: Run tests (no static analyses)
+ run: mvn --batch-mode --update-snapshots test
+
+ verify:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 21
+ uses: actions/setup-java@v3
+ with:
+ java-version: "21"
+ distribution: "temurin"
+ cache: maven
+ - name: Set up GNU-R
+ uses: r-lib/actions/setup-r@v2
+ with:
+ r-version: "4.3.2"
+ - name: Run tests and static analyses
+ run: mvn --batch-mode --update-snapshots verify
+
verify-macos:
runs-on: macos-latest
diff --git a/.gitignore b/.gitignore
index 5324456be..84ba91324 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,7 +20,7 @@ target/
.classpath
.factorypath
.project
-# We actually want to sync this to ensure NonNullByDefault
+# We actually want to sync this
# .settings
.springBeans
.sts4-cache
@@ -36,7 +36,8 @@ build/
!**/src/test/**/build/
### VS Code ###
-.vscode/
+# We actually want to sync this
+# .vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
diff --git a/.pmd-rules.xml b/.pmd-rules.xml
new file mode 100644
index 000000000..ea4528a9e
--- /dev/null
+++ b/.pmd-rules.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+ This is the default pmd ruleset with the following changes:
+
+ - Remove UnnecessaryImport, because it marks star imports in static members which aren't unnecessary, and
+ unused imports don't signal bugs.
+ - Remove UselessParenthesis, because we don't care and extra parentheses don't signal bugs.
+
+ See https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html.
+
+ [0] https://raw.githubusercontent.com/apache/maven-pmd-plugin/pmd7/src/main/resources/rulesets/java/maven-pmd-plugin-default.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..cdfe4f1b6
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 000000000..d4313d4b2
--- /dev/null
+++ b/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 64161896b..4adc96d52 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,19 @@
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=disabled
-org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
+org.eclipse.jdt.core.compiler.compliance=21
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=21
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 000000000..8f2b7113d
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.compile.nullAnalysis.mode": "disabled"
+}
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 31a390a14..bdf75f733 100644
--- a/Makefile
+++ b/Makefile
@@ -21,4 +21,3 @@ clean:
# Install pre-commit and pre-push hooks
setup:
cp -f .githooks/pre-commit.sh .git/hooks/pre-commit
- cp -f .githooks/pre-push.sh .git/hooks/pre-push
diff --git a/pom.xml b/pom.xml
index ca25242bc..7fe4aa71d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,7 +77,6 @@
.githooks/pre-commit.sh
- .githooks/pre-push.sh
@@ -130,9 +129,6 @@
target/**/*
-
- 2.18
-
1.19.2
@@ -218,12 +214,15 @@
org.apache.maven.plugins
maven-pmd-plugin
3.21.2
-
-
-
+
+
+
false
- false
+
+
+ .pmd-rules.xml
+
diff --git a/src/main/java/org/prlprg/bc/Compiler.java b/src/main/java/org/prlprg/bc/Compiler.java
index 5af882d2a..e10cb9644 100644
--- a/src/main/java/org/prlprg/bc/Compiler.java
+++ b/src/main/java/org/prlprg/bc/Compiler.java
@@ -12,6 +12,7 @@
import org.prlprg.RSession;
import org.prlprg.bc.BcInstr.*;
import org.prlprg.sexp.*;
+import org.prlprg.util.NotImplementedError;
// FIXME: use null instead of Optional (except for return types)
// FIXME: update the SEXP API based on the experience with this code
@@ -22,7 +23,6 @@
// TODO: 13 Assignments expressions
// TODO: 16 Improved subset and sub-assignment handling
// TODO: simple interpreter for the constantFoldCode
-@SuppressWarnings("PMD.UnnecessaryImport")
public class Compiler {
private static final Set MAYBE_NSE_SYMBOLS = Set.of("bquote");
private static final Set ALLOWED_INLINES =
@@ -850,10 +850,10 @@ private boolean inlineLogicalAndOr(LangSXP call, boolean isAnd) {
private boolean inlineRepeat(LangSXP call) {
var body = call.arg(0).value();
- return inlineSimpleLoop(call, body, this::compileRepeatBody);
+ return inlineSimpleLoop(body, this::compileRepeatBody);
}
- private boolean inlineSimpleLoop(LangSXP call, SEXP body, Consumer cmpBody) {
+ private boolean inlineSimpleLoop(SEXP body, Consumer cmpBody) {
if (canSkipLoopContext(body, true)) {
cmpBody.accept(body);
} else {
@@ -907,7 +907,7 @@ private boolean inlineWhile(LangSXP call) {
var test = call.arg(0).value();
var body = call.arg(1).value();
- return inlineSimpleLoop(call, body, (b) -> compileWhileBody(call, test, b));
+ return inlineSimpleLoop(body, (b) -> compileWhileBody(call, test, b));
}
private void compileWhileBody(LangSXP call, SEXP test, SEXP body) {
@@ -1208,13 +1208,13 @@ private Optional constantFoldSym(RegSymSXP sym) {
}
private Optional constantFoldCall(LangSXP call) {
- // if (!(call.fun() instanceof RegSymSXP funSym && isFoldableFun(funSym))) {
- // return Optional.empty();
- // }
+ if (!(call.fun() instanceof RegSymSXP funSym && isFoldableFun(funSym))) {
+ return Optional.empty();
+ }
// fold args -- check consts
// do.call <- need a basic interpreter
- return Optional.empty();
+ throw new NotImplementedError();
}
private boolean isFoldableFun(RegSymSXP sym) {