Serilization and caching the table works!

This commit is contained in:
Nathan Braswell
2015-08-26 03:45:34 -04:00
parent b67d5e85fe
commit d72cbdcedb
16 changed files with 276 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ import mem
import set
import util
import conversions
import serialize
fun regex(in: *char):regex {
return regex(string::string(in))
@@ -40,7 +41,7 @@ obj regexState (Object) {
}
}
obj regex (Object) {
obj regex (Object, Serializable) {
var regexString: string::string
var begin: *regexState
var referenceCounter: *int
@@ -85,6 +86,15 @@ obj regex (Object) {
mem::delete(referenceCounter)
}
}
fun serialize(): vector::vector<char> {
return serialize::serialize(regexString)
}
fun unserialize(it: ref vector::vector<char>, pos: int): int {
var temp = string::string()
util::unpack(temp, pos) = serialize::unserialize<string::string>(it, pos)
construct(temp)
return pos
}
fun operator==(other: regex):bool {
return regexString == other.regexString