diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
index ebd6bc6d..72220b51 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -101,7 +101,6 @@ ProjectName/
**Development Tools:**
- **JavaGenerator** - Java code generation utilities
-- **AntTasks** - Custom Ant build tasks
### Legacy Projects (No Gradle builds)
- **SpecsHWUtils** - Hardware utilities (Eclipse project only)
@@ -122,7 +121,7 @@ File: `.github/workflows/nightly.yml`
5. Generates dependency graphs
### Tested Projects (in CI order):
-AntTasks, AsmParser, CommonsCompressPlus, CommonsLangPlus, GearmanPlus, GitlabPlus, GitPlus, Gprofer, GsonPlus, GuiHelper, JacksonPlus, JadxPlus, JavaGenerator, jOptions, JsEngine, LogbackPlus, MvelPlus, SlackPlus, SpecsUtils, SymjaPlus, tdrcLibrary, XStreamPlus
+CommonsLangPlus, GitPlus, GsonPlus, GuiHelper, JacksonPlus, JadxPlus, JavaGenerator, jOptions, JsEngine, SpecsUtils, SymjaPlus, tdrcLibrary, XStreamPlus
### Local Validation Steps
1. **Build specific project**: `cd ProjectName && gradle build`
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index f6064405..d12a5a91 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout specs-java-libs
- uses: actions/checkout@v4
+ uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v4
@@ -37,13 +37,8 @@ jobs:
- name: Build and test all Gradle projects sequentially
run: |
projects=(
- AntTasks
- AsmParser
- CommonsCompressPlus
CommonsLangPlus
- GitlabPlus
GitPlus
- Gprofer
GsonPlus
GuiHelper
JacksonPlus
@@ -51,9 +46,6 @@ jobs:
JavaGenerator
jOptions
JsEngine
- LogbackPlus
- MvelPlus
- SlackPlus
SpecsUtils
SymjaPlus
tdrcLibrary
diff --git a/AntTasks/build.gradle b/AntTasks/build.gradle
deleted file mode 100644
index fcfe2501..00000000
--- a/AntTasks/build.gradle
+++ /dev/null
@@ -1,51 +0,0 @@
-plugins {
- id 'distribution'
- id 'java'
-}
-
-java {
- withSourcesJar()
-
- sourceCompatibility = JavaVersion.VERSION_17
- targetCompatibility = JavaVersion.VERSION_17
-}
-
-// Repositories providers
-repositories {
- mavenCentral()
-}
-
-dependencies {
- testImplementation "junit:junit:4.13.1"
-
- implementation ':jOptions'
- implementation ':SpecsUtils'
-
- // Ivy dependencies
- implementation 'org.apache.ant:ant:1.9.1'
- implementation 'org.apache.ivy:ivy:2.5.0-rc1'
- implementation 'org.apache.ant:ant-jsch:1.10.5'
- implementation 'org.slf4j:slf4j-simple:1.7.25'
- implementation 'com.io7m.xom:xom:1.2.10'
-}
-
-// Project sources
-sourceSets {
- main {
- java {
- srcDir 'src'
- }
- resources {
- srcDir 'resources'
- }
- }
-
- test {
- java {
- srcDir 'test'
- }
- resources {
- srcDir 'resources'
- }
- }
-}
diff --git a/AntTasks/resources/pt/up/fe/specs/ant/tasks/sftp.xml.template b/AntTasks/resources/pt/up/fe/specs/ant/tasks/sftp.xml.template
deleted file mode 100644
index 22fc7cb9..00000000
--- a/AntTasks/resources/pt/up/fe/specs/ant/tasks/sftp.xml.template
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/AntTasks/settings.gradle b/AntTasks/settings.gradle
deleted file mode 100644
index fd458edf..00000000
--- a/AntTasks/settings.gradle
+++ /dev/null
@@ -1,4 +0,0 @@
-rootProject.name = 'AntTasks'
-
-includeBuild("../jOptions")
-includeBuild("../SpecsUtils")
diff --git a/AntTasks/src/pt/up/fe/specs/ant/AAntTask.java b/AntTasks/src/pt/up/fe/specs/ant/AAntTask.java
deleted file mode 100644
index 17447a10..00000000
--- a/AntTasks/src/pt/up/fe/specs/ant/AAntTask.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.ant;
-
-import org.suikasoft.jOptions.DataStore.ADataClass;
-
-public abstract class AAntTask extends ADataClass implements AntTask {
-
-}
diff --git a/AntTasks/src/pt/up/fe/specs/ant/AntResource.java b/AntTasks/src/pt/up/fe/specs/ant/AntResource.java
deleted file mode 100644
index adda38d8..00000000
--- a/AntTasks/src/pt/up/fe/specs/ant/AntResource.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2013 SPeCS Research Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.ant;
-
-import pt.up.fe.specs.util.providers.ResourceProvider;
-
-/**
- * @author Joao Bispo
- *
- */
-public enum AntResource implements ResourceProvider {
-
- SFTP_TEMPLATE("sftp.xml.template");
-
- private final String resource;
-
- private static final String BASE_PATH = "pt/up/fe/specs/ant/tasks/";
-
- private AntResource(String resource) {
- this.resource = BASE_PATH + resource;
- }
-
- /* (non-Javadoc)
- * @see pt.up.fe.specs.util.Interfaces.ResourceProvider#getResource()
- */
- @Override
- public String getResource() {
- return resource;
- }
-
-}
diff --git a/AntTasks/src/pt/up/fe/specs/ant/AntTask.java b/AntTasks/src/pt/up/fe/specs/ant/AntTask.java
deleted file mode 100644
index 410a954c..00000000
--- a/AntTasks/src/pt/up/fe/specs/ant/AntTask.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.ant;
-
-import java.io.File;
-import java.util.UUID;
-
-import pt.up.fe.specs.util.SpecsIo;
-
-public interface AntTask {
-
- /**
- *
- * @return the ANT script of this task
- */
- String getScript();
-
- default void run() {
- String scriptName = getClass().getSimpleName() + "_" + UUID.randomUUID().toString() + ".xml";
-
- // Write script to a temporary folder
- File antScript = new File(SpecsAnt.getTemporaryFolder(), scriptName);
-
- // Save script
- SpecsIo.write(antScript, getScript());
-
- SpecsAnt.runAnt(antScript, null);
- }
-}
diff --git a/AntTasks/src/pt/up/fe/specs/ant/SpecsAnt.java b/AntTasks/src/pt/up/fe/specs/ant/SpecsAnt.java
deleted file mode 100644
index c487ca75..00000000
--- a/AntTasks/src/pt/up/fe/specs/ant/SpecsAnt.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.ant;
-
-import java.io.File;
-
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.SpecsLogs;
-import pt.up.fe.specs.util.lazy.Lazy;
-
-/**
- * Utility methods related with ANT.
- *
- * @author JoaoBispo
- *
- */
-public class SpecsAnt {
-
- private static final Lazy TEMPORARY_FOLDER = Lazy.newInstance(SpecsAnt::initTempFolder);
-
- private static File initTempFolder() {
- File tempFolder = SpecsIo.getTempFolder("specs_ant");
- SpecsIo.deleteFolderContents(tempFolder);
- return tempFolder;
- }
-
- public static void runAnt(File antScript, String target) {
-
- // Launch ant
- Project project = new Project();
- project.init();
-
- ProjectHelper.configureProject(project, antScript);
-
- project.addBuildListener(SpecsAnt.newStdoutListener());
-
- // Run script
- target = target != null ? target : project.getDefaultTarget();
- project.executeTarget(target);
- }
-
- /**
- * Standard listener for ANT project.
- *
- *
- * Outputs a message when an ANT target starts and finishes.
- *
- * @return
- */
- public static BuildListener newStdoutListener() {
- BuildListener outListener = new BuildListener() {
-
- @Override
- public void taskStarted(BuildEvent arg0) {
- // System.out.println("Task Started: "+arg0.getTask().getTaskName());
- // System.out.println(arg0.getMessage());
- }
-
- @Override
- public void taskFinished(BuildEvent arg0) {
- // System.out.println(arg0.getMessage());
- }
-
- @Override
- public void targetStarted(BuildEvent arg0) {
- SpecsLogs.msgInfo("[ANT]:Started target '" + arg0.getTarget() + "'");
- // System.out.println(arg0.getMessage());
-
- }
-
- @Override
- public void targetFinished(BuildEvent arg0) {
- SpecsLogs.msgInfo("[ANT]:Finished target '" + arg0.getTarget() + "'");
- }
-
- @Override
- public void messageLogged(BuildEvent arg0) {
- // So that it can show errors (e.g., javac)
- if (!arg0.getMessage().startsWith("[") && arg0.getPriority() < 3) {
- SpecsLogs.msgInfo(arg0.getMessage());
- }
- // if (arg0.getPriority() < 3) {
- // System.out.println(arg0.getMessage());
- // }
-
- // SpecsLogs.msgInfo(arg0.getMessage());
- // System.out.println(arg0.getMessage());
-
- }
-
- @Override
- public void buildStarted(BuildEvent arg0) {
- // System.out.println("Build Started");
- }
-
- @Override
- public void buildFinished(BuildEvent arg0) {
- // System.out.println(arg0.getMessage());
-
- }
- };
-
- return outListener;
- }
-
- /**
- * Returns a File object pointing to a file equal to the given, but with another name.
- *
- * @param file
- * @param newName
- * @return
- */
- public static File updateOutput(File file, String newName) {
-
- // If newName is null, return original file
- if (newName == null) {
- return file;
- }
-
- // If newName is the same as the current name, return original file
- if (file.getName().equals(newName)) {
- SpecsLogs.info("New name for file is the same as the current name ('" + newName + "')");
- return file;
- }
-
- // New file in temporary folder
- File tempFolder = getTemporaryFolder();
-
- // Put renamed file in a new folder. If we are in Windows and only the case of the name changes,
- // it will copy the file over itself, producing a file with 0-bytes
- File newOutputFolder = SpecsIo.mkdir(tempFolder, "renamedFile");
-
- File newOutputFile = new File(newOutputFolder, newName);
-
- // Copy file
- SpecsIo.copy(file, newOutputFile);
-
- // Update reference
- file = newOutputFile;
-
- return file;
- }
-
- public static File getTemporaryFolder() {
- return TEMPORARY_FOLDER.get();
- }
-}
diff --git a/AntTasks/src/pt/up/fe/specs/ant/tasks/Sftp.java b/AntTasks/src/pt/up/fe/specs/ant/tasks/Sftp.java
deleted file mode 100644
index 25910611..00000000
--- a/AntTasks/src/pt/up/fe/specs/ant/tasks/Sftp.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.ant.tasks;
-
-import java.io.File;
-
-import org.suikasoft.jOptions.Datakey.DataKey;
-import org.suikasoft.jOptions.Datakey.KeyFactory;
-
-import pt.up.fe.specs.ant.AAntTask;
-import pt.up.fe.specs.ant.AntResource;
-import pt.up.fe.specs.ant.SpecsAnt;
-import pt.up.fe.specs.util.SpecsIo;
-import pt.up.fe.specs.util.utilities.Replacer;
-
-public class Sftp extends AAntTask {
-
- public static final DataKey LOGIN = KeyFactory.string("login");
- public static final DataKey PASS = KeyFactory.string("pass");
- public static final DataKey HOST = KeyFactory.string("host");
- public static final DataKey PORT = KeyFactory.string("port");
- public static final DataKey DESTINATION_FOLDER = KeyFactory.string("destinatonFolder");
- public static final DataKey FILE_TO_TRANSFER = KeyFactory.file("fileToTransfer");
- public static final DataKey NEW_FILENAME = KeyFactory.string("newFilename");
- public static final DataKey COMMANDS_FILE = KeyFactory.file("commandsFile");
-
- @Override
- public String getScript() {
-
- File fileToTransfer = get(FILE_TO_TRANSFER);
-
- if (!fileToTransfer.isFile()) {
- throw new RuntimeException("Could not find file to transfer '" + fileToTransfer + "'");
- }
-
- // Check if it needs a name change
- if (hasValue(NEW_FILENAME)) {
- fileToTransfer = SpecsAnt.updateOutput(fileToTransfer, get(NEW_FILENAME));
- }
-
- Replacer template = new Replacer(AntResource.SFTP_TEMPLATE);
-
- template.replace("", get(LOGIN));
- template.replace("", get(PASS));
- template.replace("", get(HOST));
- template.replace("", get(PORT));
- template.replace("", get(DESTINATION_FOLDER));
-
- template = template.replace("", fileToTransfer.getAbsolutePath());
- template = template.replace("", fileToTransfer.getName());
-
- String commands = getCommands();
- template = template.replace("", commands);
-
- return template.toString();
- }
-
- private String getCommands() {
- if (!hasValue(COMMANDS_FILE)) {
- return "";
- }
-
- String commandsPath = SpecsIo.getCanonicalPath(get(COMMANDS_FILE));
-
- Replacer template = new Replacer(
- "\" trust=\"yes\" username=\"\" password=\"\" commandResource=\"\"/>");
-
- template.replace("", get(LOGIN));
- template.replace("", get(PASS));
- template.replace("", get(HOST));
- template.replace("", commandsPath);
-
- return template.toString();
- }
-}
diff --git a/AntTasks/test/pt/up/fe/specs/ant/TasksTest.java b/AntTasks/test/pt/up/fe/specs/ant/TasksTest.java
deleted file mode 100644
index 34ae00d8..00000000
--- a/AntTasks/test/pt/up/fe/specs/ant/TasksTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.ant;
-
-import java.io.File;
-
-import org.junit.Test;
-
-import pt.up.fe.specs.ant.tasks.Sftp;
-import pt.up.fe.specs.util.SpecsIo;
-
-public class TasksTest {
-
- @Test
- public void testSftp() {
- // Create dummy file for transfer
- File dummyFile = new File("dummmy_file.txt");
- SpecsIo.write(dummyFile, "dummy");
-
- AntTask sftpTask = new Sftp()
- .set(Sftp.LOGIN, "login")
- .set(Sftp.PASS, "pass")
- .set(Sftp.HOST, "host")
- .set(Sftp.PORT, "port")
- .set(Sftp.DESTINATION_FOLDER, "destinationFolder")
- .set(Sftp.NEW_FILENAME, "new_name.txt")
- .set(Sftp.FILE_TO_TRANSFER, dummyFile);
-
- System.out.println("Output:\n" + sftpTask.getScript());
-
- SpecsIo.delete(dummyFile);
- }
-
-}
diff --git a/AsmParser/build.gradle b/AsmParser/build.gradle
deleted file mode 100644
index 1f48c8a3..00000000
--- a/AsmParser/build.gradle
+++ /dev/null
@@ -1,45 +0,0 @@
-plugins {
- id 'distribution'
- id 'java'
-}
-
-java {
- withSourcesJar()
-
- sourceCompatibility = JavaVersion.VERSION_17
- targetCompatibility = JavaVersion.VERSION_17
-}
-
-// Repositories providers
-repositories {
- mavenCentral()
-}
-
-dependencies {
- testImplementation "junit:junit:4.13.1"
-
- implementation ':SpecsUtils'
- implementation ':jOptions'
-
- implementation 'com.google.code.gson:gson:2.12.1'
-}
-
-// Project sources
-sourceSets {
- main {
- java {
- srcDir 'src'
- }
- resources {
- srcDir 'resources'
- }
- }
- test {
- java {
- srcDir 'test'
- }
- resources {
- srcDir 'test'
- }
- }
-}
diff --git a/AsmParser/resources/pt/up/fe/specs/asmparser/example.json b/AsmParser/resources/pt/up/fe/specs/asmparser/example.json
deleted file mode 100644
index 7ca9f2bf..00000000
--- a/AsmParser/resources/pt/up/fe/specs/asmparser/example.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "fields": [
- "registerd",
- "registers",
- "opcodea",
- "imm"
- ],
-
- "instructions": {
- "type1": "100101_registerd(5)_1000_opcodea(1)_0_imm(15)",
- "type2": "100101_0_opcodea(1)_000_registera(5)_11_registers(14)"
- }
-
-
-}
\ No newline at end of file
diff --git a/AsmParser/settings.gradle b/AsmParser/settings.gradle
deleted file mode 100644
index 4c233b5d..00000000
--- a/AsmParser/settings.gradle
+++ /dev/null
@@ -1,4 +0,0 @@
-rootProject.name = 'AsmParser'
-
-includeBuild("../SpecsUtils")
-includeBuild("../jOptions")
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/ExtractResult.java b/AsmParser/src/pt/up/fe/specs/asmparser/ExtractResult.java
deleted file mode 100644
index d256b4d4..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/ExtractResult.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package pt.up.fe.specs.asmparser;
-
-public record ExtractResult(String currentString, int amount) {
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/InstructionFormatParser.java b/AsmParser/src/pt/up/fe/specs/asmparser/InstructionFormatParser.java
deleted file mode 100644
index c224f02f..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/InstructionFormatParser.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.suikasoft.jOptions.Interfaces.DataStore;
-import org.suikasoft.jOptions.storedefinition.StoreDefinitions;
-
-import pt.up.fe.specs.asmparser.ast.ConstantNode;
-import pt.up.fe.specs.asmparser.ast.FieldNode;
-import pt.up.fe.specs.asmparser.ast.IgnoreNode;
-import pt.up.fe.specs.asmparser.ast.InstructionFormatNode;
-import pt.up.fe.specs.asmparser.ast.RuleNode;
-import pt.up.fe.specs.asmparser.parser32bit.Asm32bitParser;
-import pt.up.fe.specs.binarytranslation.asm.parsing.AsmFieldData;
-import pt.up.fe.specs.binarytranslation.asm.parsing.AsmFieldType;
-import pt.up.fe.specs.binarytranslation.asm.parsing.binaryasmparser.BinaryAsmInstructionParser;
-import pt.up.fe.specs.util.SpecsStrings;
-import pt.up.fe.specs.util.SpecsSystem;
-
-public class InstructionFormatParser {
-
- public static void main(String[] args) {
- SpecsSystem.programStandardInit();
-
- // var rule = new InstructionFormatParser().parse("100101_registerd(5)_1000_opcodea(1)_0_imm(15)");
-
- var rule2 = new InstructionFormatParser().parse("0110_xx_registerd(5)_1000_opcodea(1)_0_imm(15)");
-
- System.out.println(rule2.toTree());
-
- var parser2 = Asm32bitParser.build(0, rule2);
- var res = parser2.parse(Long.parseLong("01100011111100000010101010101101", 2));
-
- System.out.println("RES: " + Arrays.toString(res));
-
- test();
- }
-
- enum TestAsmField implements AsmFieldType {
- INST1,
- INST2;
- }
-
- private static void test() {
- var addr = "0000";
- var rule = "0110_xx_registerd(5)_1000_opcodea(1)_0_imm(15)";
- var instruction = "01100011111100000010101010101101";
- var instructionHex = Long.toString(Long.parseLong(instruction, 2), 16);
- var instructionLong = Long.parseLong(instruction, 2);
- var iterations = 1_000_000;
-
- // String-based
- var stringParser = new BinaryAsmInstructionParser(TestAsmField.INST1, rule, null);
-
- var start1 = System.nanoTime();
- var acc1 = 0l;
- for (int i = 0; i < iterations; i++) {
- var res = stringParser.parse(addr, instructionHex);
- var fieldValueString = res.get().get(AsmFieldData.FIELDS).get("registerd");
- var fieldValue = Integer.parseInt(fieldValueString, 2);
- acc1 += fieldValue;
- }
- SpecsStrings.printTime("String parsing", start1);
- System.out.println("String result: " + acc1);
-
- // Long based
- var astRule = new InstructionFormatParser().parse(rule);
- var longParser = Asm32bitParser.build(0, astRule);
-
- var start2 = System.nanoTime();
- var acc2 = 0l;
- for (int i = 0; i < iterations; i++) {
- var res = longParser.parse(instructionLong);
- var fieldValue = res[1];
- acc2 += fieldValue;
- }
- SpecsStrings.printTime("Long parsing", start2);
- System.out.println("Long result: " + acc2);
-
- }
-
- public RuleNode parse(String instructionFormatRule) {
- String currentRule = instructionFormatRule;
-
- var root = newNode(RuleNode.class);
-
- while (!currentRule.isEmpty()) {
- // Ignore underscore
- if (currentRule.startsWith("_")) {
- currentRule = currentRule.substring(1);
- continue;
- }
-
- // If 0 or 1, create constant rule
- if (currentRule.startsWith("0") || currentRule.startsWith("1")) {
- String constString = currentRule.substring(0, 1);
- currentRule = currentRule.substring(1);
-
- // Check if has ()
- var result = extractAmount(currentRule, instructionFormatRule);
- if (result != null) {
- constString = SpecsStrings.buildLine(constString, result.amount());
- currentRule = result.currentString();
- }
-
- var constant = newNode(ConstantNode.class);
- constant.set(InstructionFormatNode.NUM_BITS, constString.length());
- constant.set(ConstantNode.LITERAL, constString);
- root.addChild(constant);
- continue;
- }
-
- // If x, create ignore rule
- if (currentRule.startsWith("x")) {
- int amount = 1;
- currentRule = currentRule.substring(1);
-
- // Check if has ()
- var result = extractAmount(currentRule, instructionFormatRule);
- if (result != null) {
- amount = result.amount();
- currentRule = result.currentString();
- }
-
- var ignore = newNode(IgnoreNode.class);
- ignore.set(InstructionFormatNode.NUM_BITS, amount);
- root.addChild(ignore);
- continue;
- }
-
- // Otherwise, interpret as a field with ()
- int startIndex = currentRule.indexOf('(');
- if (startIndex == -1) {
- throw new RuntimeException("Expected field name to have () associated: " + instructionFormatRule);
- }
-
- String fieldName = currentRule.substring(0, startIndex);
- currentRule = currentRule.substring(startIndex);
- var result = extractAmount(currentRule, instructionFormatRule);
-
- var field = newNode(FieldNode.class);
- field.set(InstructionFormatNode.NUM_BITS, result.amount());
- field.set(FieldNode.FIELD, fieldName);
- root.addChild(field);
-
- currentRule = result.currentString();
- }
-
- // Rules could be optimized - e.g., fuse constant rules together
- // System.out.println("RULES: " + rules);
- // return rules;
-
- // Fuse rules that are next to each other
- collapseConstantNodes(root);
- collapseIgnoreNodes(root);
-
- return root;
- }
-
- private void collapseConstantNodes(RuleNode root) {
- // Collapse sequential ConstantNodes
-
- var newChildren = new ArrayList();
-
- ConstantNode currentConstant = null;
- for (var child : root.getChildren()) {
-
- if (!(child instanceof ConstantNode)) {
- // If current constant not null, store it
- if (currentConstant != null) {
- newChildren.add(currentConstant);
- currentConstant = null;
- }
-
- // Just add node
- newChildren.add(child);
- continue;
- }
-
- // Is constant node
- var constant = (ConstantNode) child;
- var numBits = constant.get(InstructionFormatNode.NUM_BITS);
- var literal = constant.get(ConstantNode.LITERAL);
-
- if (currentConstant == null) {
- currentConstant = newNode(ConstantNode.class);
- } else {
- numBits = currentConstant.get(InstructionFormatNode.NUM_BITS) + numBits;
- literal = currentConstant.get(ConstantNode.LITERAL) + literal;
- }
-
- currentConstant.set(InstructionFormatNode.NUM_BITS, numBits);
- currentConstant.set(ConstantNode.LITERAL, literal);
- }
-
- // If current constant not null, store it
- if (currentConstant != null) {
- newChildren.add(currentConstant);
- currentConstant = null;
- }
-
- // Set children
- root.setChildren(newChildren);
-
- }
-
- private void collapseIgnoreNodes(RuleNode root) {
- // Collapse sequential IgnoreNodes
-
- var newChildren = new ArrayList();
-
- IgnoreNode currentIgnore = null;
- for (var child : root.getChildren()) {
-
- if (!(child instanceof IgnoreNode)) {
- // If current ignore not null, store it
- if (currentIgnore != null) {
- newChildren.add(currentIgnore);
- currentIgnore = null;
- }
-
- // Just add node
- newChildren.add(child);
- continue;
- }
-
- // Is ignore node
- var ignore = (IgnoreNode) child;
- var numBits = ignore.get(InstructionFormatNode.NUM_BITS);
-
- if (currentIgnore == null) {
- currentIgnore = newNode(IgnoreNode.class);
- } else {
- numBits = currentIgnore.get(InstructionFormatNode.NUM_BITS) + numBits;
- }
-
- currentIgnore.set(InstructionFormatNode.NUM_BITS, numBits);
- }
-
- // If current ignore not null, store it
- if (currentIgnore != null) {
- newChildren.add(currentIgnore);
- currentIgnore = null;
- }
-
- // Set children
- root.setChildren(newChildren);
-
- }
-
- private static ExtractResult extractAmount(String currentRule, String fullRule) {
- if (!currentRule.startsWith("(")) {
- return null;
- }
-
- int endIndex = currentRule.indexOf(')');
- if (endIndex == -1) {
- throw new RuntimeException("Unbalanced parenthesis on rule: " + fullRule);
- }
-
- int amount = Integer.parseInt(currentRule.substring(1, endIndex));
- String updatedCurrentRule = currentRule.substring(endIndex + 1);
-
- return new ExtractResult(updatedCurrentRule, amount);
- }
-
- private DataStore newDataStore(Class extends InstructionFormatNode> nodeClass) {
- return DataStore.newInstance(StoreDefinitions.fromInterface(nodeClass), true);
- }
-
- private T newNode(Class nodeClass) {
- var data = newDataStore(nodeClass);
-
- try {
- return nodeClass.getConstructor(DataStore.class, Collection.class).newInstance(data, null);
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | SecurityException e) {
- throw new RuntimeException("Could not create node", e);
- }
- }
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/Isa32bitParser.java b/AsmParser/src/pt/up/fe/specs/asmparser/Isa32bitParser.java
deleted file mode 100644
index 24c9fcf9..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/Isa32bitParser.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package pt.up.fe.specs.asmparser;
-
-import com.google.gson.Gson;
-import pt.up.fe.specs.asmparser.ast.FieldNode;
-import pt.up.fe.specs.asmparser.ast.RuleNode;
-import pt.up.fe.specs.asmparser.parser32bit.Asm32bitParser;
-import pt.up.fe.specs.util.SpecsIo;
-
-import java.util.*;
-
-public class Isa32bitParser {
-
- public static void main(String[] args) {
- var isaParser = newInstance(SpecsIo.getResource(() -> "pt/up/fe/specs/binarytranslation/asm/parsing/asm_test.json"));
-
- //"0110_xx_registerd(5)_1000_opcode(1)_0_imm(15)"
- // 31, 1, 10925
- var decoded = isaParser.parse(Long.parseLong("01100011111100010010101010101101", 2));
- System.out.println(Arrays.toString(decoded));
- }
-
-
- private final List parsers;
- private final Map fieldsMap;
-
- private Isa32bitParser(List parsers, Map fieldsMap) {
- this.parsers = parsers;
- this.fieldsMap = fieldsMap;
- }
-
-
- public static Isa32bitParser newInstance(String jsonContents) {
- var isa = new Gson().fromJson(jsonContents, Map.class);
-
- //var fields = new LinkedHashSet<>((List) isa.get("fields"));
-
- // Maps a field to an index
- var fieldsMap = new HashMap();
-
- // Index 0 is id of format
- var fieldId = 1;
- for (var field : (List) isa.get("fields")) {
- fieldsMap.put(field, fieldId);
- fieldId++;
- }
-
-// System.out.println("FIELDS MAP: " + fieldsMap);
-
- int id = 0;
- var parsers = new ArrayList();
- for (var format : (List) isa.get("formats")) {
-
- // Parse format
- var rule = new InstructionFormatParser().parse(format);
-
- // Verify rule
- verify(rule, format, fieldsMap.keySet());
-
- // Create parser
- var parser = Asm32bitParser.build(id, rule, fieldsMap);
- parsers.add(parser);
- id++;
- }
-
-
- return new Isa32bitParser(parsers, fieldsMap);
- }
-
- private static void verify(RuleNode rule, String format, Set fields) {
- // Go to all fields, check they are declared
- var invalidField = rule.getDescendants(FieldNode.class).stream()
- .filter(node -> !fields.contains(node.getField()))
- .findFirst()
- .orElse(null);
-
-
- if (invalidField != null) {
- throw new RuntimeException("Found undeclared field '" + invalidField.getField() + "' in format rule '" + format + "'");
- }
-
- }
-
- public Map getFieldsMap() {
- return fieldsMap;
- }
-
- public int[] parse(long instruction) {
- // Iterate over all parsers, looking for one that accepts the instruction
- for (var parser : parsers) {
- var decoded = parser.parse(instruction);
-
- // Could not decode, skip
- if (decoded == null) {
- continue;
- }
-
- // Decoded, return
- return decoded;
- }
-
- throw new RuntimeException("Could not decode instruction 0x" + Long.toString(instruction, 16));
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/ast/ConstantNode.java b/AsmParser/src/pt/up/fe/specs/asmparser/ast/ConstantNode.java
deleted file mode 100644
index 3435bde2..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/ast/ConstantNode.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.ast;
-
-import java.util.Collection;
-
-import org.suikasoft.jOptions.Datakey.DataKey;
-import org.suikasoft.jOptions.Datakey.KeyFactory;
-import org.suikasoft.jOptions.Interfaces.DataStore;
-
-public class ConstantNode extends InstructionFormatNode {
-
- public static final DataKey LITERAL = KeyFactory.string("literal");
-
- public ConstantNode(DataStore data, Collection extends InstructionFormatNode> children) {
- super(data, children);
- }
-
- public int getLiteralAsInt() {
- return Integer.parseInt(get(LITERAL), 2);
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/ast/FieldNode.java b/AsmParser/src/pt/up/fe/specs/asmparser/ast/FieldNode.java
deleted file mode 100644
index b76810be..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/ast/FieldNode.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.ast;
-
-import java.util.Collection;
-
-import org.suikasoft.jOptions.Datakey.DataKey;
-import org.suikasoft.jOptions.Datakey.KeyFactory;
-import org.suikasoft.jOptions.Interfaces.DataStore;
-
-public class FieldNode extends InstructionFormatNode {
-
- public static final DataKey FIELD = KeyFactory.string("field");
-
- public FieldNode(DataStore data, Collection extends InstructionFormatNode> children) {
- super(data, children);
- }
-
- public String getField() {
- return get(FIELD);
- }
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/ast/IgnoreNode.java b/AsmParser/src/pt/up/fe/specs/asmparser/ast/IgnoreNode.java
deleted file mode 100644
index 4d57032f..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/ast/IgnoreNode.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.ast;
-
-import java.util.Collection;
-
-import org.suikasoft.jOptions.Interfaces.DataStore;
-
-public class IgnoreNode extends InstructionFormatNode {
-
- public IgnoreNode(DataStore data, Collection extends InstructionFormatNode> children) {
- super(data, children);
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/ast/InstructionFormatNode.java b/AsmParser/src/pt/up/fe/specs/asmparser/ast/InstructionFormatNode.java
deleted file mode 100644
index 724fe048..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/ast/InstructionFormatNode.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.ast;
-
-import java.util.Collection;
-
-import org.suikasoft.jOptions.Datakey.DataKey;
-import org.suikasoft.jOptions.Datakey.KeyFactory;
-import org.suikasoft.jOptions.Interfaces.DataStore;
-import org.suikasoft.jOptions.treenode.DataNode;
-
-public class InstructionFormatNode extends DataNode {
-
- public static final DataKey NUM_BITS = KeyFactory.integer("numBits", -1);
-
- public InstructionFormatNode(DataStore data, Collection extends InstructionFormatNode> children) {
- super(data, children);
- }
-
- @Override
- protected Class getBaseClass() {
- return InstructionFormatNode.class;
- }
-
- public int getNumBits() {
- return get(NUM_BITS);
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/ast/RuleNode.java b/AsmParser/src/pt/up/fe/specs/asmparser/ast/RuleNode.java
deleted file mode 100644
index 42a536cb..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/ast/RuleNode.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.ast;
-
-import java.util.Collection;
-
-import org.suikasoft.jOptions.Interfaces.DataStore;
-
-public class RuleNode extends InstructionFormatNode {
-
- public RuleNode(DataStore data, Collection extends InstructionFormatNode> children) {
- super(data, children);
- }
-
- /**
- *
- * @return the total number of bits covered by this rule
- */
- public int getTotalBits() {
- return getChildren().stream()
- .mapToInt(n -> n.get(InstructionFormatNode.NUM_BITS))
- .sum();
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/Asm32bitParser.java b/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/Asm32bitParser.java
deleted file mode 100644
index fd88e1bf..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/Asm32bitParser.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.parser32bit;
-
-import pt.up.fe.specs.asmparser.ast.*;
-import pt.up.fe.specs.asmparser.parser32bit.rules.Asm32bitConstantRule;
-import pt.up.fe.specs.asmparser.parser32bit.rules.Asm32bitFieldRule;
-import pt.up.fe.specs.asmparser.parser32bit.rules.Asm32bitIgnoreRule;
-import pt.up.fe.specs.asmparser.parser32bit.rules.Asm32bitRule;
-import pt.up.fe.specs.util.exceptions.NotImplementedException;
-
-import java.util.List;
-import java.util.Map;
-
-public class Asm32bitParser {
-
- private final int id;
- private final List rules;
- private final Map fieldsMap;
-
- private final int numFields;
- private final int[] fieldIndexes;
-
- private Asm32bitParser(int id, List rules, Map fieldsMap) {
- this.id = id;
- this.rules = rules;
- this.fieldsMap = fieldsMap;
- this.fieldIndexes = buildFieldsIndexes(rules, fieldsMap);
- this.numFields = fieldIndexes.length;
- }
-
- private int[] buildFieldsIndexes(List rules, Map fieldsMap) {
- var fieldRules = rules.stream()
- .filter(rule -> rule instanceof Asm32bitFieldRule)
- .map(Asm32bitFieldRule.class::cast)
- .toList();
-
- var numFields = fieldsMap != null ? fieldsMap.size() : fieldRules.size();
-
- var fieldIndexes = new int[numFields];
-
- // If no map, just fill with indexes from 1 to N
- if (fieldsMap == null) {
- for (int i = 0; i < numFields; i++) {
- fieldIndexes[i] = i + 1;
- }
- } else {
- // Iterate over all rules with fields, store the corresponding index
- for (int i = 0; i < fieldRules.size(); i++) {
- fieldIndexes[i] = fieldsMap.get(fieldRules.get(i).getField());
- }
- }
-
- return fieldIndexes;
- }
-
- public int[] parse(long instruction) {
-
- // First element contains instruction format id
- int[] decoded = new int[1 + numFields];
- decoded[0] = id;
-
- //int fieldIndex = 1;
- int fieldIndex = 0;
- int startIndex = 0;
-
- // Iterate over all rules
- for (var rule : rules) {
- var res = rule.parse(instruction, startIndex);
-
- // If res null, parsing failed
- if (res == null) {
- return null;
- }
-
- // If rule extracts a value, store it
- if (rule instanceof Asm32bitFieldRule) {
- decoded[fieldIndexes[fieldIndex]] = res.value();
- fieldIndex++;
- }
-
- // Update start index
- startIndex = res.nextIndex();
- }
-
- return decoded;
- }
-
- public static Asm32bitParser build(int id, RuleNode rule) {
- return build(id, rule, null);
- }
-
- public static Asm32bitParser build(int id, RuleNode rule, Map fieldsMap) {
- // Check if total bits is 32
- var totalBits = rule.getTotalBits();
- if (totalBits != 32) {
- throw new RuntimeException("Given rule represents " + totalBits + " bits, only 32 bits are supported.");
- }
-
- var rules = rule.getChildren().stream()
- .map(Asm32bitParser::convert)
- .toList();
-
- return new Asm32bitParser(id, rules, fieldsMap);
- }
-
- private static Asm32bitRule convert(InstructionFormatNode node) {
- if (node instanceof ConstantNode constantNode) {
- return new Asm32bitConstantRule(constantNode.getLiteralAsInt(), constantNode.getNumBits());
- }
-
- if (node instanceof IgnoreNode) {
- return new Asm32bitIgnoreRule(node.getNumBits());
- }
-
- if (node instanceof FieldNode fieldNode) {
- return new Asm32bitFieldRule(fieldNode.getField(), fieldNode.getNumBits());
- }
-
- throw new NotImplementedException(node.getClass());
- }
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/Asm32bitResult.java b/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/Asm32bitResult.java
deleted file mode 100644
index 469550a4..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/Asm32bitResult.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.parser32bit;
-
-public record Asm32bitResult(int nextIndex, int value) {
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitConstantRule.java b/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitConstantRule.java
deleted file mode 100644
index abba6b7c..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitConstantRule.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.parser32bit.rules;
-
-import pt.up.fe.specs.asmparser.parser32bit.Asm32bitResult;
-import pt.up.fe.specs.util.SpecsBits;
-
-public class Asm32bitConstantRule implements Asm32bitRule {
-
- private final long literal;
- private final int numBits;
- private final long mask;
-
- public Asm32bitConstantRule(long literal, int numBits) {
- // System.out.println("Const literal: " + literal);
- this.literal = literal;
- this.numBits = numBits;
- this.mask = SpecsBits.mask(-1, numBits);
- // System.out.println("Num bits: " + numBits + "; Mask: " + Long.toBinaryString(mask));
- }
-
- @Override
- public Asm32bitResult parse(long asm, int startIndex) {
-
- // Shift instruction the 32 bits, except the startIndex and num bits
- var shiftAmount = 32 - numBits - startIndex;
-
- // System.out.println("ORIGINAL: " + Long.toBinaryString(asm));
- var asmShifted = asm >> shiftAmount;
- // System.out.println("SHIFTED: " + Long.toBinaryString(asmShifted));
-
- var asmFiltered = asmShifted & mask;
-
- // System.out.println("FILTERED: " + Long.toBinaryString(asmFiltered));
-
- // System.out.println("LITERAL: " + Long.toBinaryString(literal));
-
- // System.out.println("SAME? " + (literal == asmFiltered));
-
- if (literal != asmFiltered) {
- return null;
- }
-
- // Passed rule
- return new Asm32bitResult(startIndex + numBits, 0);
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitFieldRule.java b/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitFieldRule.java
deleted file mode 100644
index 53e1c8c4..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitFieldRule.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.parser32bit.rules;
-
-import pt.up.fe.specs.asmparser.parser32bit.Asm32bitResult;
-import pt.up.fe.specs.util.SpecsBits;
-
-public class Asm32bitFieldRule implements Asm32bitRule {
-
- private final String field;
- private final int numBits;
- private final long mask;
-
- public Asm32bitFieldRule(String field, int numBits) {
- this.field = field;
- this.numBits = numBits;
- this.mask = SpecsBits.mask(-1, numBits);
- }
-
- public String getField() {
- return field;
- }
-
- @Override
- public Asm32bitResult parse(long asm, int startIndex) {
-
- // Shift instruction the 32 bits, except the startIndex and num bits
- var shiftAmount = 32 - numBits - startIndex;
-
- var asmShifted = asm >> shiftAmount;
-
- var asmFiltered = asmShifted & mask;
-
- // Passed rule
- return new Asm32bitResult(startIndex + numBits, (int) asmFiltered);
- }
-
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitIgnoreRule.java b/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitIgnoreRule.java
deleted file mode 100644
index 31a609b9..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitIgnoreRule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.parser32bit.rules;
-
-import pt.up.fe.specs.asmparser.parser32bit.Asm32bitResult;
-
-public class Asm32bitIgnoreRule implements Asm32bitRule {
-
- private final int numBits;
-
- public Asm32bitIgnoreRule(int numBits) {
- this.numBits = numBits;
- }
-
- @Override
- public Asm32bitResult parse(long asm, int startIndex) {
-
- // Just ignore bits
- return new Asm32bitResult(startIndex + numBits, 0);
- }
-
-}
diff --git a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitRule.java b/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitRule.java
deleted file mode 100644
index 8ed8c5de..00000000
--- a/AsmParser/src/pt/up/fe/specs/asmparser/parser32bit/rules/Asm32bitRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright 2024 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.asmparser.parser32bit.rules;
-
-import pt.up.fe.specs.asmparser.parser32bit.Asm32bitResult;
-
-public interface Asm32bitRule {
-
- Asm32bitResult parse(long asm, int startIndex);
-
-// default boolean hasValue() {
-// return false;
-// }
-}
diff --git a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AIsaParser.java b/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AIsaParser.java
deleted file mode 100644
index f4436ac3..00000000
--- a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AIsaParser.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.binarytranslation.asm.parsing;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- *
- * @author Nuno
- *
- */
-public abstract class AIsaParser implements IsaParser {
-
- private final List instructionParsers;
- private final Set allowedFields;
-
- public AIsaParser(List instructionParsers, Set allowedFields) {
- this.instructionParsers = instructionParsers;
- this.allowedFields = allowedFields;
- }
-
- public AIsaParser(List instructionParsers) {
- this(instructionParsers, null);
- }
-
- protected AsmFieldData doparse(String addr, String instruction) {
- // Iterate over all parsers
- for (var parser : instructionParsers) {
- var instData = parser.parse(addr, instruction).orElse(null);
-
- // Parser not successful, try next one
- if (instData == null) {
- continue;
- }
-
- // If allowed fields set, test parsed fields
- if (allowedFields != null) {
- var fields = instData.get(AsmFieldData.FIELDS);
-
- if (!allowedFields.containsAll(fields.keySet())) {
- Set undefinedKeys = new HashSet<>(fields.keySet());
- undefinedKeys.removeAll(allowedFields);
-
- throw new RuntimeException(
- "Found undefined fields: " + undefinedKeys + "\nAllowed fields: " + allowedFields);
- }
-
- }
-
- return instData;
- }
-
- throw new RuntimeException("Could not parse instruction: " + instruction);
- }
-}
diff --git a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmField.java b/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmField.java
deleted file mode 100644
index 5bf4fb61..00000000
--- a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmField.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.binarytranslation.asm.parsing;
-
-public interface AsmField {
-
- /*
- *
- */
- public String getFieldName();
-}
diff --git a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java b/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java
deleted file mode 100644
index 2fc42a14..00000000
--- a/AsmParser/src/pt/up/fe/specs/binarytranslation/asm/parsing/AsmFieldData.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * Copyright 2019 SPeCS.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package pt.up.fe.specs.binarytranslation.asm.parsing;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Objects;
-
-import org.suikasoft.jOptions.DataStore.ADataClass;
-import org.suikasoft.jOptions.Datakey.DataKey;
-import org.suikasoft.jOptions.Datakey.KeyFactory;
-
-/**
- * Raw field data as extracted by an {@link IsaParser}
- *
- * @author NunoPaulino
- *
- */
-public class AsmFieldData extends ADataClass {
-
- /*
- * Addr of this instruction
- */
- public static final DataKey ADDR = KeyFactory.object("addr", Number.class);
-
- /*
- * This datakey only holds the instruction type (i.e., binary instruction format as specified in the parsers)
- */
- public static final DataKey TYPE = KeyFactory.object("type", AsmFieldType.class);
-
- /*
- * This map contains the field names specified in the parsers, and their values
- */
- public static final DataKey