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

Unified Diff: test/codegen/expect/sunflower/sunflower.js

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen/expect/sunflower/sunflower.html ('k') | test/codegen/expect/sunflower/sunflower.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/expect/sunflower/sunflower.js
diff --git a/test/codegen/expect/sunflower/sunflower.js b/test/codegen/expect/sunflower/sunflower.js
index 8393ae500ed3314ae2abb960f65836808aa6df68..314405434bf34d44014fd0d1aa5cb138bdebf0e2 100644
--- a/test/codegen/expect/sunflower/sunflower.js
+++ b/test/codegen/expect/sunflower/sunflower.js
@@ -1,85 +1,129 @@
-dart_library.library('sunflower/sunflower', null, /* Imports */[
- 'dart/_runtime',
- 'sunflower/dom',
- 'dart/core',
- 'dart/math',
- 'sunflower/painter',
- 'sunflower/circle'
-], /* Lazy imports */[
-], function(exports, dart, dom, core, math, painter, circle) {
+dart_library.library('sunflower', null, /* Imports */[
+ 'dart_sdk'
+], function(exports, dart_sdk) {
'use strict';
- let dartx = dart.dartx;
- const SEED_RADIUS = 2;
- const SCALE_FACTOR = 4;
- const MAX_D = 300;
- const centerX = dart.notNull(MAX_D) / 2;
- const centerY = centerX;
- function querySelector(selector) {
- return dom.document.querySelector(selector);
- }
- dart.fn(querySelector, dom.Element, [core.String]);
- dart.defineLazyProperties(exports, {
+ const core = dart_sdk.core;
+ const html = dart_sdk.html;
+ const math = dart_sdk.math;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const sunflower = Object.create(null);
+ const circle = Object.create(null);
+ const painter = Object.create(null);
+ sunflower.SEED_RADIUS = 2;
+ sunflower.SCALE_FACTOR = 4;
+ sunflower.MAX_D = 300;
+ sunflower.centerX = dart.notNull(sunflower.MAX_D) / 2;
+ sunflower.centerY = sunflower.centerX;
+ sunflower.querySelector = function(selector) {
+ return html.document[dartx.querySelector](selector);
+ };
+ dart.fn(sunflower.querySelector, html.Element, [core.String]);
+ dart.defineLazy(sunflower, {
get canvas() {
- return dart.as(querySelector("#canvas"), dom.CanvasElement);
+ return dart.as(sunflower.querySelector("#canvas"), html.CanvasElement);
}
});
- dart.defineLazyProperties(exports, {
+ dart.defineLazy(sunflower, {
get context() {
- return dart.as(exports.canvas.getContext('2d'), dom.CanvasRenderingContext2D);
+ return dart.as(sunflower.canvas[dartx.getContext]('2d'), html.CanvasRenderingContext2D);
}
});
- dart.defineLazyProperties(exports, {
+ dart.defineLazy(sunflower, {
get slider() {
- return dart.as(querySelector("#slider"), dom.InputElement);
+ return dart.as(sunflower.querySelector("#slider"), html.InputElement);
}
});
- dart.defineLazyProperties(exports, {
+ dart.defineLazy(sunflower, {
get notes() {
- return querySelector("#notes");
+ return sunflower.querySelector("#notes");
}
});
- dart.defineLazyProperties(exports, {
+ dart.defineLazy(sunflower, {
get PHI() {
return (dart.notNull(math.sqrt(5)) + 1) / 2;
}
});
- exports.seeds = 0;
- function main() {
- exports.slider.addEventListener('change', dart.fn(e => draw(), dart.void, [dom.Event]));
- draw();
- }
- dart.fn(main, dart.void, []);
- function draw() {
- exports.seeds = core.int.parse(exports.slider.value);
- exports.context.clearRect(0, 0, MAX_D, MAX_D);
- for (let i = 0; i < dart.notNull(exports.seeds); i++) {
- let theta = i * dart.notNull(painter.TAU) / dart.notNull(exports.PHI);
- let r = dart.notNull(math.sqrt(i)) * dart.notNull(SCALE_FACTOR);
- let x = dart.notNull(centerX) + r * dart.notNull(math.cos(theta));
- let y = dart.notNull(centerY) - r * dart.notNull(math.sin(theta));
- new SunflowerSeed(x, y, SEED_RADIUS).draw(exports.context);
+ sunflower.seeds = 0;
+ sunflower.main = function() {
+ sunflower.slider[dartx.addEventListener]('change', dart.fn(e => sunflower.draw(), dart.void, [html.Event]));
+ sunflower.draw();
+ };
+ dart.fn(sunflower.main, dart.void, []);
+ sunflower.draw = function() {
+ sunflower.seeds = core.int.parse(sunflower.slider[dartx.value]);
+ sunflower.context[dartx.clearRect](0, 0, sunflower.MAX_D, sunflower.MAX_D);
+ for (let i = 0; i < dart.notNull(sunflower.seeds); i++) {
+ let theta = i * dart.notNull(painter.TAU) / dart.notNull(sunflower.PHI);
+ let r = dart.notNull(math.sqrt(i)) * dart.notNull(sunflower.SCALE_FACTOR);
+ let x = dart.notNull(sunflower.centerX) + r * dart.notNull(math.cos(theta));
+ let y = dart.notNull(sunflower.centerY) - r * dart.notNull(math.sin(theta));
+ new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.context);
}
- exports.notes.textContent = `${exports.seeds} seeds`;
- }
- dart.fn(draw, dart.void, []);
- class SunflowerSeed extends dart.mixin(circle.Circle, painter.CirclePainter) {
+ sunflower.notes[dartx.text] = `${sunflower.seeds} seeds`;
+ };
+ dart.fn(sunflower.draw, dart.void, []);
+ circle.Circle = class Circle extends core.Object {
+ Circle(x, y, radius) {
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ }
+ };
+ dart.setSignature(circle.Circle, {
+ constructors: () => ({Circle: [circle.Circle, [core.num, core.num, core.num]]})
+ });
+ painter.CirclePainter = class CirclePainter extends core.Object {
+ CirclePainter() {
+ this.color = painter.ORANGE;
+ }
+ draw(context) {
+ context[dartx.beginPath]();
+ context[dartx.lineWidth] = 2;
+ context[dartx.fillStyle] = this.color;
+ context[dartx.strokeStyle] = this.color;
+ context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false);
+ context[dartx.fill]();
+ context[dartx.closePath]();
+ context[dartx.stroke]();
+ }
+ };
+ painter.CirclePainter[dart.implements] = () => [circle.Circle];
+ dart.setSignature(painter.CirclePainter, {
+ methods: () => ({draw: [dart.void, [html.CanvasRenderingContext2D]]})
+ });
+ sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle, painter.CirclePainter) {
SunflowerSeed(x, y, radius, color) {
if (color === void 0) color = null;
super.Circle(x, y, radius);
if (color != null) this.color = color;
}
- }
- dart.setSignature(SunflowerSeed, {
- constructors: () => ({SunflowerSeed: [SunflowerSeed, [core.num, core.num, core.num], [core.String]]})
+ };
+ dart.setSignature(sunflower.SunflowerSeed, {
+ constructors: () => ({SunflowerSeed: [sunflower.SunflowerSeed, [core.num, core.num, core.num], [core.String]]})
+ });
+ painter.ORANGE = "orange";
+ painter.RED = "red";
+ painter.BLUE = "blue";
+ painter.TAU = dart.notNull(math.PI) * 2;
+ painter.querySelector = function(selector) {
+ return html.document[dartx.querySelector](selector);
+ };
+ dart.fn(painter.querySelector, html.Element, [core.String]);
+ dart.defineLazy(painter, {
+ get canvas() {
+ return dart.as(painter.querySelector("#canvas"), html.CanvasElement);
+ }
+ });
+ dart.defineLazy(painter, {
+ get context() {
+ return dart.as(painter.canvas[dartx.getContext]('2d'), html.CanvasRenderingContext2D);
+ }
});
// Exports:
- exports.SEED_RADIUS = SEED_RADIUS;
- exports.SCALE_FACTOR = SCALE_FACTOR;
- exports.MAX_D = MAX_D;
- exports.centerX = centerX;
- exports.centerY = centerY;
- exports.querySelector = querySelector;
- exports.main = main;
- exports.draw = draw;
- exports.SunflowerSeed = SunflowerSeed;
+ exports.sunflower = sunflower;
+ exports.circle = circle;
+ exports.painter = painter;
});
+
+//# sourceMappingURL=sunflower.js.map
« no previous file with comments | « test/codegen/expect/sunflower/sunflower.html ('k') | test/codegen/expect/sunflower/sunflower.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698