Skip to content
Snippets Groups Projects
Commit 32f3a9a0 authored by Mikaël Mayer's avatar Mikaël Mayer
Browse files

Moved StrOps to its own file.

Made StrOps available from the library.
parent 233c8969
No related branches found
No related tags found
No related merge requests found
package leon.lang
import leon.annotation._
/**
* @author Mikael
*/
object StrOps {
@ignore
def concat(a: String, b: String): String = {
a + b
}
@ignore
def length(a: String): BigInt = {
BigInt(a.length)
}
@ignore
def substring(a: String, start: BigInt, end: BigInt): String = {
if(start > end || start >= length(a) || end <= 0) "" else a.substring(start.toInt, end.toInt)
}
@ignore
def bigIntToString(a: BigInt): String = {
a.toString
}
@ignore
def intToString(a: Int): String = {
a.toString
}
@ignore
def doubleToString(a: Double): String = {
a.toString
}
def booleanToString(a: Boolean): String = {
if(a) "true" else "false"
}
@ignore
def charToString(a: Char): String = {
a.toString
}
@ignore
def realToString(a: Real): String = ???
}
\ No newline at end of file
......@@ -67,35 +67,4 @@ package object lang {
}
}
}
@ignore
object StrOps {
def concat(a: String, b: String): String = {
a + b
}
def length(a: String): BigInt = {
BigInt(a.length)
}
def substring(a: String, start: BigInt, end: BigInt): String = {
if(start > end || start >= length(a) || end <= 0) "" else a.substring(start.toInt, end.toInt)
}
def bigIntToString(a: BigInt): String = {
a.toString
}
def intToString(a: Int): String = {
a.toString
}
def doubleToString(a: Double): String = {
a.toString
}
def booleanToString(a: Boolean): String = {
if(a) "true" else "false"
}
def charToString(a: Char): String = {
a.toString
}
def realToString(a: Real): String = ???
}
}
......@@ -16,7 +16,8 @@ case class Library(pgm: Program) {
lazy val Some = lookup("leon.lang.Some").collectFirst { case ccd : CaseClassDef => ccd }
lazy val None = lookup("leon.lang.None").collectFirst { case ccd : CaseClassDef => ccd }
lazy val String = lookup("leon.lang.string.String").collectFirst { case ccd : CaseClassDef => ccd }
//lazy val String = lookup("leon.lang.string.String").collectFirst { case ccd : CaseClassDef => ccd }
lazy val StrOps = lookup("leon.lang.StrOps").collectFirst { case md: ModuleDef => md }
lazy val Dummy = lookup("leon.lang.Dummy").collectFirst { case ccd : CaseClassDef => ccd }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment