-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove usages of K error handling infrastructure (#1001)
Part of: #999 We are currently working on removing the reverse dependency that the LLVM backend has on the K frontend's data structures; this PR takes a first step towards that goal by removing the backend's use of the K exception infrastructure for throwing errors. The K infrastructure is replaced with a simple exception class that the frontend will be able to catch and reinterpret as appropriate. This PR needs a matching change to the K frontend to work, along with appropriate lockstep merging. --------- Co-authored-by: Tamás Tóth <[email protected]>
- Loading branch information
1 parent
7b744a2
commit 30f813a
Showing
5 changed files
with
73 additions
and
23 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
matching/src/main/java/org/kframework/backend/llvm/matching/MatchingException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.kframework.backend.llvm.matching; | ||
|
||
import org.kframework.attributes.Location; | ||
import org.kframework.attributes.Source; | ||
|
||
import java.util.Optional; | ||
|
||
public final class MatchingException extends Throwable { | ||
public enum Type { | ||
USELESS_RULE, | ||
NON_EXHAUSTIVE_MATCH, | ||
INTERNAL_ERROR, | ||
COMPILER_ERROR, | ||
} | ||
|
||
Type type; | ||
String message; | ||
Optional<Source> source; | ||
Optional<Location> location; | ||
|
||
public MatchingException(Type type, String message, Optional<Source> source, Optional<Location> location) { | ||
this.type = type; | ||
this.message = message; | ||
this.source = source; | ||
this.location = location; | ||
} | ||
|
||
public MatchingException(Type type, String message, Source source, Location location) { | ||
this(type, message, Optional.of(source), Optional.of(location)); | ||
} | ||
|
||
public MatchingException(Type type, String message) { | ||
this(type, message, Optional.empty(), Optional.empty()); | ||
} | ||
|
||
public Type getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public Optional<Source> getSource() { | ||
return source; | ||
} | ||
|
||
public Optional<Location> getLocation() { | ||
return location; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters