Changeset c5cb943d in mainline for uspace/dist/src/sysel/lib
- Timestamp:
- 2010-06-09T19:01:08Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1113c9e
- Parents:
- 051bc69a
- Location:
- uspace/dist/src/sysel/lib
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/lib/arith.sy
r051bc69a rc5cb943d 29 29 class Arith is 30 30 -- Return factorial of n. 31 fun Factorial(n : int) : int is31 fun Factorial(n : int) : int, static is 32 32 var i : int; 33 33 var val : int; -
uspace/dist/src/sysel/lib/boxed.sy
r051bc69a rc5cb943d 38 38 class Char is 39 39 var Value : char; 40 41 fun get_as_string() : string, builtin; 42 43 -- String representation. 44 prop AsString : string is 45 get is 46 return get_as_string(); 47 end 48 end 40 49 end 41 50 42 51 class Int is 43 52 var Value : int; 53 54 fun get_as_string() : string, builtin; 55 56 -- String representation. 57 prop AsString : string is 58 get is 59 return get_as_string(); 60 end 61 end 44 62 end 45 63 -
uspace/dist/src/sysel/lib/libflist
r051bc69a rc5cb943d 1 1 arith.sy 2 2 boxed.sy 3 ienum.sy 3 4 list.sy 4 5 map.sy -
uspace/dist/src/sysel/lib/list.sy
r051bc69a rc5cb943d 28 28 29 29 -- Doubly-linked list. 30 class List/t is30 class List/t : IEnumerable/t is 31 31 var head : ListNode/t; 32 32 … … 59 59 prop First : ListNode/t is 60 60 get is 61 return get_first();61 return get_first(); 62 62 end 63 end 64 65 -- Return first node in the list or @c nil if there is none. 66 fun GetEnumerator() : IEnumerator/t is 67 return new ListEnumerator/t(get_first()); 63 68 end 64 69 … … 131 136 end 132 137 end 138 end 133 139 140 class ListEnumerator/t : IEnumerator/t is 141 var first : ListNode/t; 142 var current : ListNode/t; 143 var started : bool; 144 145 new(first_node : ListNode/t) is 146 first = first_node; 147 current = nil; 148 started = false; 149 end 150 151 fun MoveNext() : bool is 152 if started then 153 current = current.Next; 154 else 155 current = first; 156 started = true; 157 end 158 159 return current != nil; 160 end 161 162 prop Data : t is 163 get is 164 return current.Data; 165 end 166 end 134 167 end -
uspace/dist/src/sysel/lib/map.sy
r051bc69a rc5cb943d 91 91 end 92 92 end 93 94 fun GetEnumerator() : IEnumerator/tkey is 95 return new MapEnumerator/tkey/tvalue(data.get_first()); 96 end 93 97 end 94 98 … … 97 101 var Value : tvalue; 98 102 end 103 104 class MapEnumerator/tkey/tvalue : IEnumerator/tkey is 105 var first : ListNode/(MapPair/tkey/tvalue); 106 var current : ListNode/(MapPair/tkey/tvalue); 107 var started : bool; 108 109 new(first_node : ListNode/(MapPair/tkey/tvalue)) is 110 first = first_node; 111 current = nil; 112 started = false; 113 end 114 115 fun MoveNext() : bool is 116 if started then 117 current = current.Next; 118 else 119 current = first; 120 started = true; 121 end 122 123 return current != nil; 124 end 125 126 prop Data : tkey is 127 get is 128 return current.Data.Key; 129 end 130 end 131 end
Note:
See TracChangeset
for help on using the changeset viewer.
