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

Side by Side Diff: test/codegen/expect/sunflower/sunflower.js

Issue 1965213003: simplify constructors, fixes #564 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « test/codegen/expect/opassign.js ('k') | test/codegen/expect/sunflower/sunflower.js.map » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('sunflower', null, /* Imports */[ 1 dart_library.library('sunflower', null, /* Imports */[
2 'dart_sdk' 2 'dart_sdk'
3 ], function(exports, dart_sdk) { 3 ], function(exports, dart_sdk) {
4 'use strict'; 4 'use strict';
5 const core = dart_sdk.core; 5 const core = dart_sdk.core;
6 const html = dart_sdk.html; 6 const html = dart_sdk.html;
7 const math = dart_sdk.math; 7 const math = dart_sdk.math;
8 const dart = dart_sdk.dart; 8 const dart = dart_sdk.dart;
9 const dartx = dart_sdk.dartx; 9 const dartx = dart_sdk.dartx;
10 const sunflower = Object.create(null); 10 const sunflower = Object.create(null);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 let theta = i * painter.TAU / dart.notNull(sunflower.PHI); 57 let theta = i * painter.TAU / dart.notNull(sunflower.PHI);
58 let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR; 58 let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR;
59 let x = sunflower.centerX + r * dart.notNull(math.cos(theta)); 59 let x = sunflower.centerX + r * dart.notNull(math.cos(theta));
60 let y = sunflower.centerY - r * dart.notNull(math.sin(theta)); 60 let y = sunflower.centerY - r * dart.notNull(math.sin(theta));
61 new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.co ntext); 61 new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.co ntext);
62 } 62 }
63 sunflower.notes[dartx.text] = `${sunflower.seeds} seeds`; 63 sunflower.notes[dartx.text] = `${sunflower.seeds} seeds`;
64 }; 64 };
65 dart.fn(sunflower.draw, dart.void, []); 65 dart.fn(sunflower.draw, dart.void, []);
66 circle.Circle = class Circle extends core.Object { 66 circle.Circle = class Circle extends core.Object {
67 Circle(x, y, radius) { 67 new(x, y, radius) {
68 this.x = x; 68 this.x = x;
69 this.y = y; 69 this.y = y;
70 this.radius = radius; 70 this.radius = radius;
71 } 71 }
72 }; 72 };
73 dart.setSignature(circle.Circle, { 73 dart.setSignature(circle.Circle, {
74 constructors: () => ({Circle: [circle.Circle, [core.num, core.num, core.num] ]}) 74 constructors: () => ({new: [circle.Circle, [core.num, core.num, core.num]]})
75 }); 75 });
76 painter.CirclePainter = class CirclePainter extends core.Object { 76 painter.CirclePainter = class CirclePainter extends core.Object {
77 CirclePainter() { 77 new() {
78 this.color = painter.ORANGE; 78 this.color = painter.ORANGE;
79 } 79 }
80 draw(context) { 80 draw(context) {
81 context[dartx.beginPath](); 81 context[dartx.beginPath]();
82 context[dartx.lineWidth] = 2; 82 context[dartx.lineWidth] = 2;
83 context[dartx.fillStyle] = this.color; 83 context[dartx.fillStyle] = this.color;
84 context[dartx.strokeStyle] = this.color; 84 context[dartx.strokeStyle] = this.color;
85 context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false); 85 context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false);
86 context[dartx.fill](); 86 context[dartx.fill]();
87 context[dartx.closePath](); 87 context[dartx.closePath]();
88 context[dartx.stroke](); 88 context[dartx.stroke]();
89 } 89 }
90 }; 90 };
91 painter.CirclePainter[dart.implements] = () => [circle.Circle]; 91 painter.CirclePainter[dart.implements] = () => [circle.Circle];
92 dart.setSignature(painter.CirclePainter, { 92 dart.setSignature(painter.CirclePainter, {
93 methods: () => ({draw: [dart.void, [html.CanvasRenderingContext2D]]}) 93 methods: () => ({draw: [dart.void, [html.CanvasRenderingContext2D]]})
94 }); 94 });
95 sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle , painter.CirclePainter) { 95 sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle , painter.CirclePainter) {
96 SunflowerSeed(x, y, radius, color) { 96 new(x, y, radius, color) {
97 if (color === void 0) color = null; 97 if (color === void 0) color = null;
98 super.Circle(x, y, radius); 98 super.new(x, y, radius);
99 if (color != null) this.color = color; 99 if (color != null) this.color = color;
100 } 100 }
101 }; 101 };
102 dart.setSignature(sunflower.SunflowerSeed, { 102 dart.setSignature(sunflower.SunflowerSeed, {
103 constructors: () => ({SunflowerSeed: [sunflower.SunflowerSeed, [core.num, co re.num, core.num], [core.String]]}) 103 constructors: () => ({new: [sunflower.SunflowerSeed, [core.num, core.num, co re.num], [core.String]]})
104 }); 104 });
105 painter.ORANGE = "orange"; 105 painter.ORANGE = "orange";
106 painter.RED = "red"; 106 painter.RED = "red";
107 painter.BLUE = "blue"; 107 painter.BLUE = "blue";
108 painter.TAU = math.PI * 2; 108 painter.TAU = math.PI * 2;
109 painter.querySelector = function(selector) { 109 painter.querySelector = function(selector) {
110 return html.document[dartx.querySelector](selector); 110 return html.document[dartx.querySelector](selector);
111 }; 111 };
112 dart.fn(painter.querySelector, html.Element, [core.String]); 112 dart.fn(painter.querySelector, html.Element, [core.String]);
113 dart.defineLazy(painter, { 113 dart.defineLazy(painter, {
114 get canvas() { 114 get canvas() {
115 return dart.as(painter.querySelector("#canvas"), html.CanvasElement); 115 return dart.as(painter.querySelector("#canvas"), html.CanvasElement);
116 } 116 }
117 }); 117 });
118 dart.defineLazy(painter, { 118 dart.defineLazy(painter, {
119 get context() { 119 get context() {
120 return dart.as(painter.canvas[dartx.getContext]('2d'), html.CanvasRenderin gContext2D); 120 return dart.as(painter.canvas[dartx.getContext]('2d'), html.CanvasRenderin gContext2D);
121 } 121 }
122 }); 122 });
123 // Exports: 123 // Exports:
124 exports.sunflower = sunflower; 124 exports.sunflower = sunflower;
125 exports.circle = circle; 125 exports.circle = circle;
126 exports.painter = painter; 126 exports.painter = painter;
127 }); 127 });
128 128
129 //# sourceMappingURL=sunflower.js.map 129 //# sourceMappingURL=sunflower.js.map
OLDNEW
« no previous file with comments | « test/codegen/expect/opassign.js ('k') | test/codegen/expect/sunflower/sunflower.js.map » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698