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