Changeset 883fedc in mainline for uspace/dist/src/sysel/lib/list.sy


Ignore:
Timestamp:
2010-04-23T23:09:56Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37c9fc8
Parents:
80badbe (diff), 6c39a907 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jsvoboda/helenos/sysel. New: generic classes, autoboxing, delegates.

File:
1 edited

Legend:

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

    r80badbe r883fedc  
    2727--
    2828
    29 -- Doubly-linked non-generic list.
    30 class List is
    31         var head : ListNode;
     29-- Doubly-linked list.
     30class List/t is
     31        var head : ListNode/t;
    3232
    3333        -- Initialize list.
    3434        fun Init() is
    35                 head = new ListNode();
     35                head = new ListNode/t();
    3636                head.prev = head;
    3737                head.next = head;
     
    3939
    4040        -- Append new entry at the end of the list.
    41         fun Append(data : Object) is
    42                 var n : ListNode;
    43                 var ntl : ListNode;
     41        fun Append(data : t) is
     42                var n : ListNode/t;
     43                var ntl : ListNode/t;
    4444
    4545                ntl = head.prev;
    4646
    47                 n = new ListNode();
     47                n = new ListNode/t();
    4848                n.value = data;
    4949
     
    5757
    5858        -- Return first node in the list or @c nil if there is none.
    59         prop First : ListNode is
     59        prop First : ListNode/t is
    6060                get is
    6161                    return get_first();
     
    6464
    6565        -- Return first node in the list or @c nil if there is none.
    66         fun get_first() : ListNode is
     66        fun get_first() : ListNode/t is
    6767                if head.next == head then
    6868                        return nil;
     
    7373end
    7474
    75 class ListNode is
    76         var value : Object;
     75class ListNode/t is
     76        var value : t;
    7777
    78         var prev : ListNode;
    79         var next : ListNode;
    80         var head : ListNode;
     78        var prev : ListNode/t;
     79        var next : ListNode/t;
     80        var head : ListNode/t;
    8181
    8282        -- Value stored in this node.
    83         prop Value : Object is
     83        prop Value : t is
    8484                get is
    8585                        return value;
     
    8888
    8989        -- Previous node in list.
    90         prop Prev : ListNode is
     90        prop Prev : ListNode/t is
    9191                get is
    9292                        return get_prev();
     
    9595
    9696        -- Next node in list.
    97         prop Next : ListNode is
     97        prop Next : ListNode/t is
    9898                get is
    9999                        return get_next();
     
    102102
    103103        -- Get next node.
    104         fun get_next() : ListNode is
     104        fun get_next() : ListNode/t is
    105105                if next != head then
    106106                        return next;
     
    111111
    112112        -- Get previous node.
    113         fun get_prev() : ListNode is
     113        fun get_prev() : ListNode/t is
    114114                if prev != head then
    115115                        return next;
Note: See TracChangeset for help on using the changeset viewer.