Changeset c5cb943d in mainline for uspace/dist/src/sysel/lib


Ignore:
Timestamp:
2010-06-09T19:01:08Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1113c9e
Parents:
051bc69a
Message:

Update SBI to rev. 291.

Location:
uspace/dist/src/sysel/lib
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/sysel/lib/arith.sy

    r051bc69a rc5cb943d  
    2929class Arith is
    3030        -- Return factorial of n.
    31         fun Factorial(n : int) : int is
     31        fun Factorial(n : int) : int, static is
    3232                var i : int;
    3333                var val : int;
  • uspace/dist/src/sysel/lib/boxed.sy

    r051bc69a rc5cb943d  
    3838class Char is
    3939        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
    4049end
    4150
    4251class Int is
    4352        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
    4462end
    4563
  • uspace/dist/src/sysel/lib/libflist

    r051bc69a rc5cb943d  
    11arith.sy
    22boxed.sy
     3ienum.sy
    34list.sy
    45map.sy
  • uspace/dist/src/sysel/lib/list.sy

    r051bc69a rc5cb943d  
    2828
    2929-- Doubly-linked list.
    30 class List/t is
     30class List/t : IEnumerable/t is
    3131        var head : ListNode/t;
    3232
     
    5959        prop First : ListNode/t is
    6060                get is
    61                     return get_first();
     61                        return get_first();
    6262                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());
    6368        end
    6469
     
    131136                end
    132137        end
     138end
    133139
     140class 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
    134167end
  • uspace/dist/src/sysel/lib/map.sy

    r051bc69a rc5cb943d  
    9191                end
    9292        end
     93
     94        fun GetEnumerator() : IEnumerator/tkey is
     95                return new MapEnumerator/tkey/tvalue(data.get_first());
     96        end
    9397end
    9498
     
    97101        var Value : tvalue;
    98102end
     103
     104class 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
     131end
Note: See TracChangeset for help on using the changeset viewer.