Changeset c5cb943d in mainline for uspace/dist/src


Ignore:
Timestamp:
2010-06-09T19:01:08Z (15 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
Files:
3 added
23 edited

Legend:

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

    r051bc69a rc5cb943d  
    2828
    2929class ArithmeticDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                -- Test addition, multiplication and precedence.
    3232                Builtin.Write("2*2 + 2*2 = ");
     
    8888
    8989        -- Return factorial of n.
    90         fun Factorial(n : int) : int is
     90        fun Factorial(n : int) : int, static is
    9191                var i : int;
    9292                var val : int;
  • uspace/dist/src/sysel/demos/array.sy

    r051bc69a rc5cb943d  
    2828
    2929class ArrayDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                var a : int[,];
    3232                var i : int;
  • uspace/dist/src/sysel/demos/autobox.sy

    r051bc69a rc5cb943d  
    2828
    2929class AutoboxingDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                var b : Bool;
    3232                var c : Char;
     
    5151        end
    5252
    53         fun foo(args : Object[], packed) is
     53        fun foo(args : Object[], packed), static is
    5454        end
    5555end
  • uspace/dist/src/sysel/demos/count.sy

    r051bc69a rc5cb943d  
    2828
    2929class CountDemo is
    30         fun Count(a : int; b : int) is
     30        fun Count(a : int; b : int), static is
    3131                var i : int;
    3232
     
    3939        end
    4040
    41         fun Main() is
     41        fun Main(), static is
    4242                Count(0, 10);
    4343        end
  • uspace/dist/src/sysel/demos/ctor.sy

    r051bc69a rc5cb943d  
    2828
    2929class ConstructorDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                var a : A;
    3232
  • uspace/dist/src/sysel/demos/deleg.sy

    r051bc69a rc5cb943d  
    2828
    2929class DelegateDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                var demo : DelegateClass;
    3232
  • uspace/dist/src/sysel/demos/enum.sy

    r051bc69a rc5cb943d  
    2828
    2929class EnumDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                var color : ChessColor;
    3232
  • uspace/dist/src/sysel/demos/except.sy

    r051bc69a rc5cb943d  
    2828
    2929class ExceptionDemo is
    30         fun foo() is
     30        fun foo(), static is
    3131                Builtin.WriteLine("Entered foo().");
    3232                raise new BaseException();
    3333        end
    3434
    35         fun Main() is
     35        fun Main(), static is
    3636                do
    3737                        foo();
  • uspace/dist/src/sysel/demos/gen.sy

    r051bc69a rc5cb943d  
    3030
    3131class GenericsDemo is
    32         fun Main() is
     32        fun Main(), static is
    3333                Builtin.WriteLine("Let's try some generics.");
    3434
  • uspace/dist/src/sysel/demos/hello.sy

    r051bc69a rc5cb943d  
    2828
    2929class HelloWorld is
    30         fun Main() is
     30        fun Main(), static is
    3131                Builtin.WriteLine("Hello world!");
    3232        end
  • uspace/dist/src/sysel/demos/hexec.sy

    r051bc69a rc5cb943d  
    2828
    2929class HelenOSExecDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                Task.Exec("/app/tester");
    3232                Task.Exec("/app/tester", "print1");
  • uspace/dist/src/sysel/demos/htxtfile.sy

    r051bc69a rc5cb943d  
    2828
    2929class TextFileDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                var name : string;
    3232                var line : string;
  • uspace/dist/src/sysel/demos/inherit.sy

    r051bc69a rc5cb943d  
    4343
    4444class InheritanceDemo is
    45         fun Main() is
     45        fun Main(), static is
    4646                var a : A;
    4747                var c : C;
  • uspace/dist/src/sysel/demos/list.sy

    r051bc69a rc5cb943d  
    2929-- Using the List class from the library.
    3030class ListDemo is
    31         fun Main() is
     31        fun Main(), static is
    3232                var list : List/int;
    3333
     
    3939                list.Append(8);
    4040
    41                 var n : ListNode/int;
     41                var e : IEnumerator/int;
    4242
    43                 n = list.First;
    44                 while n != nil do
    45                         Builtin.WriteLine(n.Data);
    46                         n = n.Next;
     43                e = list.GetEnumerator();
     44                while e.MoveNext() do
     45                        Builtin.WriteLine(e.Data);
    4746                end
    4847        end
  • uspace/dist/src/sysel/demos/map.sy

    r051bc69a rc5cb943d  
    2929-- Using the Map class from the library.
    3030class MapDemo is
    31         fun Main() is
     31        fun Main(), static is
    3232                var map : Map/string/int;
    3333
     
    3939                map["four"] = 4;
    4040
    41                 Builtin.WriteLine(map["one"]);
    42                 Builtin.WriteLine(map["two"]);
    43                 Builtin.WriteLine(map["three"]);
    44                 Builtin.WriteLine(map["four"]);
     41                var e : IEnumerator/string;
     42
     43                e = map.GetEnumerator();
     44                while e.MoveNext() do
     45                        Builtin.Write(e.Data);
     46                        Builtin.Write(" -> ");
     47                        Builtin.WriteLine(map[e.Data]);
     48                end
    4549        end
    4650end
  • uspace/dist/src/sysel/demos/property.sy

    r051bc69a rc5cb943d  
    9898
    9999class PropertyDemo is
    100         fun Main() is
     100        fun Main(), static is
    101101                var a : Foo;
    102102                var i : int;
  • uspace/dist/src/sysel/demos/string.sy

    r051bc69a rc5cb943d  
    2828
    2929class StringDemo is
    30         fun Main() is
     30        fun Main(), static is
    3131                -- Concatenate some strings.
    3232                Builtin.WriteLine("One-" + "two-" + "three!");
  • uspace/dist/src/sysel/demos/varargs.sy

    r051bc69a rc5cb943d  
    3333        -- with the attribute 'packed'.
    3434        --
    35         fun Print(args : string[], packed) is
     35        fun Print(args : string[], packed), static is
    3636                var i : int;
    3737                var error : bool;
     
    5353        end
    5454
    55         fun Main() is
     55        fun Main(), static is
    5656                Print("One", "Two", "Three", "Four", "Five");
    5757        end
  • 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.