Esempio n. 1
0
// Save frame to a LoadSaver.
func (w Window) Save(ls *persist.LoadSaver) {
	ls.SaveByte(windowLoader)
	ls.SaveByte(byte(w.OffType))
	ls.SaveInt(w.MinOff)
	ls.SaveInt(w.MaxOff)
	w.Pattern.Save(ls)
}
Esempio n. 2
0
func (s *Set) Save(ls *persist.LoadSaver) {
	ls.SaveInts(s.idx)
	ls.SaveSmallInt(len(s.lists))
	for _, v := range s.lists {
		ls.SaveSmallInt(len(v))
		for _, w := range v {
			ls.SaveInts(w)
		}
	}
	ls.SaveSmallInt(len(s.maxOffsets))
	for _, v := range s.maxOffsets {
		ls.SaveInt(v[0])
		ls.SaveInt(v[1])
	}
}
Esempio n. 3
0
func saveKeyFrames(ls *persist.LoadSaver, kfs [][]keyFrame) {
	ls.SaveSmallInt(len(kfs))
	for _, v := range kfs {
		ls.SaveSmallInt(len(v))
		for _, kf := range v {
			ls.SaveByte(byte(kf.typ))
			ls.SaveInt(int(kf.seg.pMin))
			ls.SaveInt(int(kf.seg.pMax))
			ls.SaveSmallInt(kf.seg.lMin)
			ls.SaveSmallInt(kf.seg.lMax)
			ls.SaveInt(int(kf.key.pMin))
			ls.SaveInt(int(kf.key.pMax))
			ls.SaveSmallInt(kf.key.lMin)
			ls.SaveSmallInt(kf.key.lMax)
		}
	}

}
Esempio n. 4
0
// Save persists a Matcher.
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveBool(false)
		return
	}
	b := c.(*Matcher)
	ls.SaveBool(true)
	saveKeyFrames(ls, b.keyFrames)
	saveTests(ls, b.tests)
	b.bofFrames.save(ls)
	b.eofFrames.save(ls)
	b.bofSeq.save(ls)
	b.eofSeq.save(ls)
	ls.SaveInt(b.knownBOF)
	ls.SaveInt(b.knownEOF)
	ls.SaveInt(b.maxBOF)
	ls.SaveInt(b.maxEOF)
	b.priorities.Save(ls)
}
Esempio n. 5
0
func saveTests(ls *persist.LoadSaver, tts []*testTree) {
	ls.SaveSmallInt(len(tts))
	for _, tt := range tts {
		ls.SaveSmallInt(len(tt.complete))
		for _, kfid := range tt.complete {
			ls.SaveSmallInt(kfid[0])
			ls.SaveSmallInt(kfid[1])
		}
		ls.SaveSmallInt(len(tt.incomplete))
		for _, fu := range tt.incomplete {
			ls.SaveSmallInt(fu.kf[0])
			ls.SaveSmallInt(fu.kf[1])
			ls.SaveBool(fu.l)
			ls.SaveBool(fu.r)
		}
		ls.SaveInt(tt.maxLeftDistance)
		ls.SaveInt(tt.maxRightDistance)
		saveTestNodes(ls, tt.left)
		saveTestNodes(ls, tt.right)
	}
}
Esempio n. 6
0
func (ii indexes) save(ls *persist.LoadSaver) {
	ls.SaveInt(ii.start)
	ls.SaveStrings(ii.ids)
}
Esempio n. 7
0
// Save frame to a LoadSaver.
func (w WildMin) Save(ls *persist.LoadSaver) {
	ls.SaveByte(wildMinLoader)
	ls.SaveByte(byte(w.OffType))
	ls.SaveInt(w.MinOff)
	w.Pattern.Save(ls)
}
Esempio n. 8
0
// Save frame to a LoadSaver.
func (f Fixed) Save(ls *persist.LoadSaver) {
	ls.SaveByte(fixedLoader)
	ls.SaveByte(byte(f.OffType))
	ls.SaveInt(f.Off)
	f.Pattern.Save(ls)
}