@@ -23,6 +23,7 @@ import (
2323 "github.com/scionproto/scion/pkg/private/serrors"
2424 //@ . "github.com/scionproto/scion/verification/utils/definitions"
2525 //@ sl "github.com/scionproto/scion/verification/utils/slices"
26+ //@ "github.com/scionproto/scion/verification/utils/sif"
2627)
2728
2829// LinkType describes inter-AS links.
@@ -44,6 +45,7 @@ const (
4445 Peer LinkType = 4
4546)
4647
48+ // @ requires low(l)
4749// @ decreases
4850func (l LinkType ) String () string {
4951 if l == Unset {
@@ -59,6 +61,7 @@ func (l LinkType) String() string {
5961
6062// LinkTypeFromString returns the numerical link type associated with a string description. If the
6163// string is not recognized, an Unset link type is returned. The matching is case-insensitive.
64+ // @ requires low(s)
6265// @ decreases
6366func LinkTypeFromString (s string ) (res LinkType ) {
6467 var l /*@@@*/ LinkType
@@ -70,6 +73,7 @@ func LinkTypeFromString(s string) (res LinkType) {
7073 return l
7174}
7275
76+ // @ requires low(l)
7377// @ ensures (l == Core || l == Parent || l == Child || l == Peer) == (err == nil)
7478// @ ensures err == nil ==> sl.Bytes(res, 0, len(res))
7579// @ ensures err != nil ==> err.ErrorMem()
@@ -97,13 +101,21 @@ func (l LinkType) MarshalText() (res []byte, err error) {
97101 }
98102}
99103
104+ // @ requires acc(sl.Bytes(data, 0, len(data)), R15)
105+ // @ requires low(len(data)) &&
106+ // @ forall i int :: { sl.GetByte(data, 0, len(data), i) } 0 <= i && i < len(data) && low(i) ==>
107+ // @ low(sl.GetByte(data, 0, len(data), i))
100108// @ preserves acc(l)
101- // @ preserves acc(sl.Bytes(data, 0, len(data)), R15)
109+ // @ ensures acc(sl.Bytes(data, 0, len(data)), R15)
102110// @ ensures err != nil ==> err.ErrorMem()
111+ // @ ensures low(err != nil)
103112// @ decreases
104113func (l * LinkType ) UnmarshalText (data []byte ) (err error ) {
105- //@ unfold acc(sl.Bytes(data, 0, len(data)), R15)
106- //@ ghost defer fold acc(sl.Bytes(data, 0, len(data)), R15)
114+ //@ unfold acc(sl.Bytes(data, 0, len(data)), R16)
115+ //@ ghost defer fold acc(sl.Bytes(data, 0, len(data)), R16)
116+ //@ assert forall i int :: { &data[i] } 0 <= i && i < len(data) ==>
117+ //@ sl.GetByte(data, 0, len(data), i) == data[i]
118+ //@ sif.LowSliceImpliesLowString(data, R16)
107119 switch strings .ToLower (string (data )) {
108120 case "core" :
109121 * l = Core
0 commit comments