Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: pkg/dev_compiler/test/codegen_expected/sunflower/sunflower.js

Issue 2934623003: fix #29753, use ES5 constructors for ddc (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 define(['dart_sdk'], function(dart_sdk) { 1 define(['dart_sdk'], function(dart_sdk) {
2 'use strict'; 2 'use strict';
3 const core = dart_sdk.core; 3 const core = dart_sdk.core;
4 const html = dart_sdk.html; 4 const html = dart_sdk.html;
5 const math = dart_sdk.math; 5 const math = dart_sdk.math;
6 const dart = dart_sdk.dart; 6 const dart = dart_sdk.dart;
7 const dartx = dart_sdk.dartx; 7 const dartx = dart_sdk.dartx;
8 const sunflower = Object.create(null); 8 const sunflower = Object.create(null);
9 const circle = Object.create(null); 9 const circle = Object.create(null);
10 const painter = Object.create(null); 10 const painter = Object.create(null);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 }; 59 };
60 dart.fn(sunflower.main, VoidTovoid()); 60 dart.fn(sunflower.main, VoidTovoid());
61 sunflower.draw = function() { 61 sunflower.draw = function() {
62 sunflower.seeds = core.int.parse(sunflower.slider.value); 62 sunflower.seeds = core.int.parse(sunflower.slider.value);
63 sunflower.context.clearRect(0, 0, sunflower.MAX_D, sunflower.MAX_D); 63 sunflower.context.clearRect(0, 0, sunflower.MAX_D, sunflower.MAX_D);
64 for (let i = 0; i < dart.notNull(sunflower.seeds); i++) { 64 for (let i = 0; i < dart.notNull(sunflower.seeds); i++) {
65 let theta = i * painter.TAU / dart.notNull(sunflower.PHI); 65 let theta = i * painter.TAU / dart.notNull(sunflower.PHI);
66 let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR; 66 let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR;
67 let x = sunflower.centerX + r * dart.notNull(math.cos(theta)); 67 let x = sunflower.centerX + r * dart.notNull(math.cos(theta));
68 let y = sunflower.centerY - r * dart.notNull(math.sin(theta)); 68 let y = sunflower.centerY - r * dart.notNull(math.sin(theta));
69 new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.co ntext); 69 new sunflower.SunflowerSeed.new(x, y, sunflower.SEED_RADIUS).draw(sunflowe r.context);
70 } 70 }
71 sunflower.notes[dartx.text] = dart.str`${sunflower.seeds} seeds`; 71 sunflower.notes[dartx.text] = dart.str`${sunflower.seeds} seeds`;
72 }; 72 };
73 dart.fn(sunflower.draw, VoidTovoid()); 73 dart.fn(sunflower.draw, VoidTovoid());
74 circle.Circle = class Circle extends core.Object { 74 circle.Circle = class Circle extends core.Object {
75 get x() { 75 get x() {
76 return this[x$]; 76 return this[x$];
77 } 77 }
78 set x(value) { 78 set x(value) {
79 super.x = value; 79 super.x = value;
80 } 80 }
81 get y() { 81 get y() {
82 return this[y$]; 82 return this[y$];
83 } 83 }
84 set y(value) { 84 set y(value) {
85 super.y = value; 85 super.y = value;
86 } 86 }
87 get radius() { 87 get radius() {
88 return this[radius$]; 88 return this[radius$];
89 } 89 }
90 set radius(value) { 90 set radius(value) {
91 super.radius = value; 91 super.radius = value;
92 } 92 }
93 new(x, y, radius) {
94 this[x$] = x;
95 this[y$] = y;
96 this[radius$] = radius;
97 }
98 }; 93 };
94 (circle.Circle.new = function(x, y, radius) {
95 this[x$] = x;
96 this[y$] = y;
97 this[radius$] = radius;
98 }).prototype = circle.Circle.prototype;
99 const x$ = Symbol("Circle.x"); 99 const x$ = Symbol("Circle.x");
100 const y$ = Symbol("Circle.y"); 100 const y$ = Symbol("Circle.y");
101 const radius$ = Symbol("Circle.radius"); 101 const radius$ = Symbol("Circle.radius");
102 dart.setSignature(circle.Circle, { 102 dart.setSignature(circle.Circle, {
103 fields: () => ({ 103 fields: () => ({
104 x: dart.finalFieldType(core.num), 104 x: dart.finalFieldType(core.num),
105 y: dart.finalFieldType(core.num), 105 y: dart.finalFieldType(core.num),
106 radius: dart.finalFieldType(core.num) 106 radius: dart.finalFieldType(core.num)
107 }) 107 })
108 }); 108 });
109 painter.CirclePainter = class CirclePainter extends core.Object { 109 painter.CirclePainter = class CirclePainter extends core.Object {
110 new() {
111 this[color] = painter.ORANGE;
112 }
113 get color() { 110 get color() {
114 return this[color]; 111 return this[color];
115 } 112 }
116 set color(value) { 113 set color(value) {
117 this[color] = value; 114 this[color] = value;
118 } 115 }
119 draw(context) { 116 draw(context) {
120 context.beginPath(); 117 context.beginPath();
121 context.lineWidth = 2; 118 context.lineWidth = 2;
122 context.fillStyle = this.color; 119 context.fillStyle = this.color;
123 context.strokeStyle = this.color; 120 context.strokeStyle = this.color;
124 context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false); 121 context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false);
125 context[dartx.fill](); 122 context[dartx.fill]();
126 context.closePath(); 123 context.closePath();
127 context.stroke(); 124 context.stroke();
128 } 125 }
129 }; 126 };
127 (painter.CirclePainter.new = function() {
128 this[color] = painter.ORANGE;
129 }).prototype = painter.CirclePainter.prototype;
130 const color = Symbol("CirclePainter.color"); 130 const color = Symbol("CirclePainter.color");
131 painter.CirclePainter[dart.implements] = () => [circle.Circle]; 131 painter.CirclePainter[dart.implements] = () => [circle.Circle];
132 dart.setSignature(painter.CirclePainter, { 132 dart.setSignature(painter.CirclePainter, {
133 fields: () => ({color: dart.fieldType(core.String)}), 133 fields: () => ({color: dart.fieldType(core.String)}),
134 methods: () => ({draw: dart.fnType(dart.void, [html.CanvasRenderingContext2D ])}) 134 methods: () => ({draw: dart.fnType(dart.void, [html.CanvasRenderingContext2D ])})
135 }); 135 });
136 sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle , painter.CirclePainter) { 136 sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle , painter.CirclePainter) {};
137 new(x, y, radius, color) { 137 (sunflower.SunflowerSeed.new = function(x, y, radius, color) {
138 if (color === void 0) color = null; 138 if (color === void 0) color = null;
139 super.new(x, y, radius); 139 sunflower.SunflowerSeed.__proto__.new.call(this, x, y, radius);
140 if (color != null) this.color = color; 140 if (color != null) this.color = color;
141 } 141 }).prototype = sunflower.SunflowerSeed.prototype;
142 };
143 dart.defineLazy(painter, { 142 dart.defineLazy(painter, {
144 get ORANGE() { 143 get ORANGE() {
145 return "orange"; 144 return "orange";
146 }, 145 },
147 get RED() { 146 get RED() {
148 return "red"; 147 return "red";
149 }, 148 },
150 get BLUE() { 149 get BLUE() {
151 return "blue"; 150 return "blue";
152 }, 151 },
(...skipping 20 matching lines...) Expand all
173 }, null); 172 }, null);
174 // Exports: 173 // Exports:
175 return { 174 return {
176 sunflower: sunflower, 175 sunflower: sunflower,
177 circle: circle, 176 circle: circle,
178 painter: painter 177 painter: painter
179 }; 178 };
180 }); 179 });
181 180
182 //# sourceMappingURL=sunflower.js.map 181 //# sourceMappingURL=sunflower.js.map
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698