Ignore:
Timestamp:
2011-03-23T20:53:30Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
71af5a4
Parents:
5716e9a (diff), ab10b842 (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 mainline changes.

File:
1 edited

Legend:

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

    r5716e9a r76b5a95c  
    3333        prop X : int is
    3434                get is
    35                         Builtin.Write("Getting value of X which is ");
    36                         Builtin.WriteLine(x);
     35                        Console.Write("Getting value of X which is ");
     36                        Console.WriteLine(x);
    3737                        return x;
    3838                end
    3939
    4040                set value is
    41                         Builtin.Write("Setting value of X to ");
    42                         Builtin.WriteLine(value);
     41                        Console.Write("Setting value of X to ");
     42                        Console.WriteLine(value);
    4343                        x = value;
    4444                end
     45        end
     46
     47        -- Test accessing property via an unqualified name
     48        fun TestUnqualPropAcc() is
     49                var i : int;
     50
     51                X = 1;
     52                i = X;
     53
     54                Console.Write("TestUnqualPropAcc(): Got ");
     55                Console.WriteLine(i);
    4556        end
    4657
     
    5162        prop self[index : int] : int is
    5263                get is
    53                         Builtin.Write("Getting property with index ");
    54                         Builtin.Write(index);
    55                         Builtin.Write(" which is ");
    56                         Builtin.WriteLine(iprops[index]);
     64                        Console.Write("Getting property with index ");
     65                        Console.Write(index);
     66                        Console.Write(" which is ");
     67                        Console.WriteLine(iprops[index]);
    5768
    5869                        return iprops[index];
     
    6071
    6172                set value is
    62                         Builtin.Write("Setting property with index ");
    63                         Builtin.Write(index);
    64                         Builtin.Write(" to ");
    65                         Builtin.WriteLine(value);
     73                        Console.Write("Setting property with index ");
     74                        Console.Write(index);
     75                        Console.Write(" to ");
     76                        Console.WriteLine(value);
    6677
    6778                        iprops[index] = value;
     
    8293        prop B : Bar is
    8394                get is
    84                         Builtin.WriteLine("Getting B");
     95                        Console.WriteLine("Getting B");
    8596                        return bprop;
    8697                end
    8798                set value is
    88                         Builtin.WriteLine("Setting B");
     99                        Console.WriteLine("Setting B");
    89100                        bprop = value;
    90101                end
     
    110121                i = a.X;
    111122
    112                 Builtin.Write("Main(): Got ");
    113                 Builtin.WriteLine(i);
     123                Console.Write("Main(): Got ");
     124                Console.WriteLine(i);
     125
     126                a.TestUnqualPropAcc();
    114127
    115128                a.iprops = new int[5];
     
    121134                i = a[1];
    122135
    123                 Builtin.Write("Main(): Got ");
    124                 Builtin.WriteLine(i);
     136                Console.Write("Main(): Got ");
     137                Console.WriteLine(i);
    125138
    126139                -- Property field access
     
    132145                a.bprop = b;
    133146
    134                 Builtin.WriteLine(a.bprop.i);
     147                Console.WriteLine(a.bprop.i);
    135148                a.bprop.i = 2;
    136                 Builtin.WriteLine(a.bprop.i);
     149                Console.WriteLine(a.bprop.i);
    137150        end
    138151end
Note: See TracChangeset for help on using the changeset viewer.