Changes in uspace/dist/src/sysel/demos/property.sy [051b3db8:c5cb943d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/demos/property.sy
r051b3db8 rc5cb943d 33 33 prop X : int is 34 34 get is 35 Console.Write("Getting value of X which is ");36 Console.WriteLine(x);35 Builtin.Write("Getting value of X which is "); 36 Builtin.WriteLine(x); 37 37 return x; 38 38 end 39 39 40 40 set value is 41 Console.Write("Setting value of X to ");42 Console.WriteLine(value);41 Builtin.Write("Setting value of X to "); 42 Builtin.WriteLine(value); 43 43 x = value; 44 44 end 45 end46 47 -- Test accessing property via an unqualified name48 fun TestUnqualPropAcc() is49 var i : int;50 51 X = 1;52 i = X;53 54 Console.Write("TestUnqualPropAcc(): Got ");55 Console.WriteLine(i);56 45 end 57 46 … … 62 51 prop self[index : int] : int is 63 52 get is 64 Console.Write("Getting property with index ");65 Console.Write(index);66 Console.Write(" which is ");67 Console.WriteLine(iprops[index]);53 Builtin.Write("Getting property with index "); 54 Builtin.Write(index); 55 Builtin.Write(" which is "); 56 Builtin.WriteLine(iprops[index]); 68 57 69 58 return iprops[index]; … … 71 60 72 61 set value is 73 Console.Write("Setting property with index ");74 Console.Write(index);75 Console.Write(" to ");76 Console.WriteLine(value);62 Builtin.Write("Setting property with index "); 63 Builtin.Write(index); 64 Builtin.Write(" to "); 65 Builtin.WriteLine(value); 77 66 78 67 iprops[index] = value; … … 93 82 prop B : Bar is 94 83 get is 95 Console.WriteLine("Getting B");84 Builtin.WriteLine("Getting B"); 96 85 return bprop; 97 86 end 98 87 set value is 99 Console.WriteLine("Setting B");88 Builtin.WriteLine("Setting B"); 100 89 bprop = value; 101 90 end … … 121 110 i = a.X; 122 111 123 Console.Write("Main(): Got "); 124 Console.WriteLine(i); 125 126 a.TestUnqualPropAcc(); 112 Builtin.Write("Main(): Got "); 113 Builtin.WriteLine(i); 127 114 128 115 a.iprops = new int[5]; … … 134 121 i = a[1]; 135 122 136 Console.Write("Main(): Got ");137 Console.WriteLine(i);123 Builtin.Write("Main(): Got "); 124 Builtin.WriteLine(i); 138 125 139 126 -- Property field access … … 145 132 a.bprop = b; 146 133 147 Console.WriteLine(a.bprop.i);134 Builtin.WriteLine(a.bprop.i); 148 135 a.bprop.i = 2; 149 Console.WriteLine(a.bprop.i);136 Builtin.WriteLine(a.bprop.i); 150 137 end 151 138 end
Note:
See TracChangeset
for help on using the changeset viewer.