From ee0ebeddd008a9859935af72df31ac0ba370b4f1 Mon Sep 17 00:00:00 2001 From: Hernan Ponce de Leon Date: Thu, 12 Sep 2024 11:01:23 +0200 Subject: [PATCH] Allow to parse spirv code from ui (#730) Co-authored-by: Hernan Ponce de Leon --- .../com/dat3m/dartagnan/parsers/program/ProgramParser.java | 3 +++ ui/src/main/java/com/dat3m/ui/editor/Editor.java | 2 +- ui/src/main/java/com/dat3m/ui/editor/EditorsPane.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java index 1145997729..43cec38698 100644 --- a/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java +++ b/dartagnan/src/main/java/com/dat3m/dartagnan/parsers/program/ProgramParser.java @@ -61,6 +61,9 @@ public Program parse(String raw, String path, String format, String cflags) thro case "ll" -> { return new ParserLlvm().parse(CharStreams.fromString(raw)); } + case "spv.dis" -> { + return new ParserSpirv().parse(CharStreams.fromString(raw)); + } case "litmus" -> { return getConcreteLitmusParser(raw.toUpperCase()).parse(CharStreams.fromString(raw)); } diff --git a/ui/src/main/java/com/dat3m/ui/editor/Editor.java b/ui/src/main/java/com/dat3m/ui/editor/Editor.java index 671342e838..8df2bcaef9 100644 --- a/ui/src/main/java/com/dat3m/ui/editor/Editor.java +++ b/ui/src/main/java/com/dat3m/ui/editor/Editor.java @@ -100,7 +100,7 @@ public void actionPerformed(ActionEvent event) { if (chooser.showOpenDialog(null) == APPROVE_OPTION) { String path = chooser.getSelectedFile().getPath(); loadedPath = path.substring(0, path.lastIndexOf('/') + 1); - String format = path.substring(path.lastIndexOf('.') + 1).trim(); + String format = path.endsWith("spv.dis") ? "spv.dis" : path.substring(path.indexOf('.') + 1).trim(); if (allowedFormats.contains(format)) { loadedFormat = format; notifyListeners(); diff --git a/ui/src/main/java/com/dat3m/ui/editor/EditorsPane.java b/ui/src/main/java/com/dat3m/ui/editor/EditorsPane.java index 1601801b04..46f71ee839 100644 --- a/ui/src/main/java/com/dat3m/ui/editor/EditorsPane.java +++ b/ui/src/main/java/com/dat3m/ui/editor/EditorsPane.java @@ -10,7 +10,7 @@ public class EditorsPane { private final ImmutableMap editors = ImmutableMap.of( - EditorCode.PROGRAM, new Editor(EditorCode.PROGRAM, new RSyntaxTextArea(), "litmus", "c", "ll"), + EditorCode.PROGRAM, new Editor(EditorCode.PROGRAM, new RSyntaxTextArea(), "litmus", "c", "ll", "spv.dis"), EditorCode.TARGET_MM, new Editor(EditorCode.TARGET_MM, new RSyntaxTextArea(), "cat") );