Skip to content

Commit

Permalink
Remove usages of K Source and Location
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltoli committed Mar 1, 2024
1 parent 9186ac2 commit ec7ffce
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.kframework.backend.llvm.matching;

public class Location {
int startLine;
int endLine;
int startColumn;
int endColumn;

public Location(int startLine, int endLine, int startColumn, int endColumn) {
this.startLine = startLine;
this.endLine = endLine;
this.startColumn = startColumn;
this.endColumn = endColumn;
}

public int getStartLine() {
return startLine;
}

public int getEndLine() {
return endLine;
}

public int getStartColumn() {
return startColumn;
}

public int getEndColumn() {
return endColumn;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.kframework.backend.llvm.matching;

public class Source {
String source;

public Source(String source) {
this.source = source;
}

public String getSource() {
return source;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package org.kframework.backend.llvm.matching
import java.util
import java.util.concurrent.ConcurrentHashMap
import java.util.Optional
import org.kframework.attributes.HasLocation
import org.kframework.attributes.Location
import org.kframework.attributes.Source
import org.kframework.backend.llvm.matching.dt._
import org.kframework.backend.llvm.matching.pattern._
import org.kframework.kore.KORE.KApply
Expand Down Expand Up @@ -328,7 +325,7 @@ case class Action(
source: Optional[Source],
location: Optional[Location],
nonlinear: Boolean
) extends HasLocation {
) {
override lazy val hashCode: Int = scala.runtime.ScalaRunTime._hashCode(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package org.kframework.backend.llvm.matching

import java.util
import java.util.Optional
import org.kframework.attributes.Location
import org.kframework.attributes.Source
import org.kframework.parser.kore._
import org.kframework.parser.kore.implementation.{ DefaultBuilders => B }
import org.kframework.parser.kore.parser.KoreToK
Expand Down Expand Up @@ -161,7 +159,7 @@ object Parser {
def source(att: Attributes): Optional[Source] =
if (hasAtt(att, SOURCE)) {
val sourceStr = getStringAtt(att, SOURCE).get
return Optional.of(Source(sourceStr.substring("Source(".length, sourceStr.length - 1)))
Optional.of(new Source(sourceStr.substring("Source(".length, sourceStr.length - 1)))
} else {
Optional.empty()
}
Expand All @@ -170,8 +168,8 @@ object Parser {
if (hasAtt(att, LOCATION)) {
val locStr = getStringAtt(att, LOCATION).get
val splitted = locStr.split("[(,)]")
return Optional.of(
Location(splitted(1).toInt, splitted(2).toInt, splitted(3).toInt, splitted(4).toInt)
Optional.of(
new Location(splitted(1).toInt, splitted(2).toInt, splitted(3).toInt, splitted(4).toInt)
)
} else {
Optional.empty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.kframework.backend.llvm.matching.pattern

import java.util.regex.{ Pattern => Regex }
import java.util.Optional
import org.kframework.attributes.Location
import org.kframework.attributes.Source
import org.kframework.backend.llvm.matching._
import org.kframework.backend.llvm.matching.dt._
import org.kframework.backend.llvm.matching.MatchingException
Expand Down

0 comments on commit ec7ffce

Please sign in to comment.