OLD | NEW |
1 dart_library.library('opassign', null, /* Imports */[ | 1 dart_library.library('opassign', null, /* Imports */[ |
2 "dart_runtime/dart", | 2 "dart_runtime/dart", |
3 'dart/core' | 3 'dart/core' |
4 ], /* Lazy imports */[ | 4 ], /* Lazy imports */[ |
5 ], function(exports, dart, core) { | 5 ], function(exports, dart, core) { |
6 'use strict'; | 6 'use strict'; |
7 let dartx = dart.dartx; | 7 let dartx = dart.dartx; |
8 dart.copyProperties(exports, { | 8 dart.copyProperties(exports, { |
9 get index() { | 9 get index() { |
10 core.print('called "index" getter'); | 10 dart.dcall(core.print, 'called "index" getter'); |
11 return 0; | 11 return 0; |
12 } | 12 } |
13 }); | 13 }); |
14 dart.defineLazyProperties(exports, { | 14 dart.defineLazyProperties(exports, { |
15 get _foo() { | 15 get _foo() { |
16 return new Foo(); | 16 return new Foo(); |
17 } | 17 } |
18 }); | 18 }); |
19 dart.copyProperties(exports, { | 19 dart.copyProperties(exports, { |
20 get foo() { | 20 get foo() { |
21 core.print('called "foo" getter'); | 21 dart.dcall(core.print, 'called "foo" getter'); |
22 return exports._foo; | 22 return exports._foo; |
23 } | 23 } |
24 }); | 24 }); |
25 class Foo extends core.Object { | 25 class Foo extends core.Object { |
26 Foo() { | 26 Foo() { |
27 this.x = 100; | 27 this.x = 100; |
28 } | 28 } |
29 } | 29 } |
30 function main() { | 30 function main() { |
31 let f = dart.map([0, 40]); | 31 let f = dart.map([0, 40]); |
32 core.print('should only call "index" 2 times:'); | 32 dart.dcall(core.print, 'should only call "index" 2 times:'); |
33 let i = exports.index; | 33 let i = exports.index; |
34 f.set(i, dart.dsend(f.get(i), '+', 1)); | 34 f.set(i, dart.dsend(f.get(i), '+', 1)); |
35 forcePostfix((() => { | 35 dart.dcall(forcePostfix, (() => { |
36 let i = exports.index, x = f.get(i); | 36 let i = exports.index, x = f.get(i); |
37 f.set(i, dart.dsend(x, '+', 1)); | 37 f.set(i, dart.dsend(x, '+', 1)); |
38 return x; | 38 return x; |
39 })()); | 39 })()); |
40 core.print('should only call "foo" 2 times:'); | 40 dart.dcall(core.print, 'should only call "foo" 2 times:'); |
41 let o = exports.foo; | 41 let o = exports.foo; |
42 dart.dput(o, 'x', dart.dsend(dart.dload(o, 'x'), '+', 1)); | 42 dart.dput(o, 'x', dart.dsend(dart.dload(o, 'x'), '+', 1)); |
43 forcePostfix((() => { | 43 dart.dcall(forcePostfix, (() => { |
44 let o = exports.foo, x = dart.dload(o, 'x'); | 44 let o = exports.foo, x = dart.dload(o, 'x'); |
45 dart.dput(o, 'x', dart.dsend(x, '+', 1)); | 45 dart.dput(o, 'x', dart.dsend(x, '+', 1)); |
46 return x; | 46 return x; |
47 })()); | 47 })()); |
48 core.print('op assign test, should only call "index" twice:'); | 48 dart.dcall(core.print, 'op assign test, should only call "index" twice:'); |
49 let i$ = exports.index; | 49 let i$ = exports.index; |
50 f.set(i$, dart.dsend(f.get(i$), '+', f.get(exports.index))); | 50 f.set(i$, dart.dsend(f.get(i$), '+', f.get(exports.index))); |
51 } | 51 } |
52 dart.fn(main); | 52 dart.fn(main); |
53 function forcePostfix(x) { | 53 function forcePostfix(x) { |
54 } | 54 } |
55 dart.fn(forcePostfix); | 55 dart.fn(forcePostfix); |
56 // Exports: | 56 // Exports: |
57 exports.Foo = Foo; | 57 exports.Foo = Foo; |
58 exports.main = main; | 58 exports.main = main; |
59 exports.forcePostfix = forcePostfix; | 59 exports.forcePostfix = forcePostfix; |
60 }); | 60 }); |
OLD | NEW |