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

Side by Side Diff: lib/runtime/dart_runtime.js

Issue 1177253002: Fix runtime ordering and other minor fixes (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Refactor Created 5 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
« no previous file with comments | « no previous file | lib/src/codegen/html_codegen.dart » ('j') | lib/src/codegen/html_codegen.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 var dart, dartx; 5 var dart, dartx;
6 (function (dart) { 6 (function (dart) {
7 'use strict'; 7 'use strict';
8 8
9 const defineProperty = Object.defineProperty; 9 const defineProperty = Object.defineProperty;
10 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; 10 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (names.length == 0) return false; 481 if (names.length == 0) return false;
482 for (name of names) { 482 for (name of names) {
483 if (!(Object.prototype.hasOwnProperty.call(this.named, name))) { 483 if (!(Object.prototype.hasOwnProperty.call(this.named, name))) {
484 return false; 484 return false;
485 } 485 }
486 if (!instanceOfOrNull(opts[name], this.named[name])) return false; 486 if (!instanceOfOrNull(opts[name], this.named[name])) return false;
487 } 487 }
488 return true; 488 return true;
489 } 489 }
490 490
491 toString() { return this.name; }
492
491 get name() { 493 get name() {
492 if (this._stringValue) return this._stringValue; 494 if (this._stringValue) return this._stringValue;
493 495
494 let buffer = '('; 496 let buffer = '(';
495 for (let i = 0; i < this.args.length; ++i) { 497 for (let i = 0; i < this.args.length; ++i) {
496 if (i > 0) { 498 if (i > 0) {
497 buffer += ', '; 499 buffer += ', ';
498 } 500 }
499 buffer += _typeName(this.args[i]); 501 buffer += _typeName(this.args[i]);
500 } 502 }
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 this.dartIterator = dartIterator; 1290 this.dartIterator = dartIterator;
1289 } 1291 }
1290 next() { 1292 next() {
1291 let i = this.dartIterator; 1293 let i = this.dartIterator;
1292 let done = !i.moveNext(); 1294 let done = !i.moveNext();
1293 return { done: done, value: done ? void 0 : i.current }; 1295 return { done: done, value: done ? void 0 : i.current };
1294 } 1296 }
1295 } 1297 }
1296 dart.JsIterator = JsIterator; 1298 dart.JsIterator = JsIterator;
1297 1299
1298 // TODO(jmesserly): right now this is a sentinel. It should be a type object 1300 // TODO(jmesserly/vsm): Right now these are sentinels. They should be type
1299 // of some sort, assuming we keep around `dynamic` at runtime. 1301 // objects of some sort, assuming we keep them at runtime.
1300 dart.dynamic = { toString() { return 'dynamic'; }, get name() {return toString ();}}; 1302 function _sentinel(_name) {
1301 dart.void = { toString() { return 'void'; }, get name() {return toString();}}; 1303 return {
1302 dart.bottom = { toString() { return 'bottom'; }, get name() {return toString() ;}}; 1304 toString() { return _name; },
1305 get name() { return this.toString(); }
1306 };
1307 }
1308 dart.dynamic = _sentinel('dynamic');
1309 dart.void = _sentinel('void');
1310 dart.bottom = _sentinel('bottom');
1303 1311
1304 dart.global = window || global; 1312 dart.global = window || global;
1305 dart.JsSymbol = Symbol; 1313 dart.JsSymbol = Symbol;
1306 1314
1307 // Module support. This is a simplified module system for Dart. 1315 // Module support. This is a simplified module system for Dart.
1308 // Longer term, we can easily migrate to an existing JS module system: 1316 // Longer term, we can easily migrate to an existing JS module system:
1309 // ES6, AMD, RequireJS, .... 1317 // ES6, AMD, RequireJS, ....
1310 1318
1311 class LibraryLoader { 1319 class LibraryLoader {
1312 constructor(name, defaultValue, imports, lazyImports, loader) { 1320 constructor(name, defaultValue, imports, lazyImports, loader) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 } 1390 }
1383 LibraryLoader.NOT_LOADED = 0; 1391 LibraryLoader.NOT_LOADED = 0;
1384 LibraryLoader.LOADING = 1; 1392 LibraryLoader.LOADING = 1;
1385 LibraryLoader.LOADED = 2; 1393 LibraryLoader.LOADED = 2;
1386 LibraryLoader.READY = 3; 1394 LibraryLoader.READY = 3;
1387 1395
1388 // Map from name to LibraryLoader 1396 // Map from name to LibraryLoader
1389 let libraries = new Map(); 1397 let libraries = new Map();
1390 1398
1391 function library(name, defaultValue, imports, lazyImports, loader) { 1399 function library(name, defaultValue, imports, lazyImports, loader) {
1392 libraries[name] = 1400 return libraries[name] =
1393 new LibraryLoader(name, defaultValue, imports, lazyImports, loader); 1401 new LibraryLoader(name, defaultValue, imports, lazyImports, loader);
1394 } 1402 }
1395 dart.library = library; 1403 dart.library = library;
1396 1404
1397 function import_(libraryName) { 1405 function import_(libraryName) {
1398 bootstrap(); 1406 bootstrap();
1399 let loader = libraries[libraryName]; 1407 let loader = libraries[libraryName];
1400 return loader.load(); 1408 return loader.load();
1401 } 1409 }
1402 dart.import = import_; 1410 dart.import = import_;
1403 1411
1404 function start(libraryName) { 1412 function start(libraryName) {
1405 let library = import_(libraryName); 1413 let library = import_(libraryName);
1406 _isolate_helper.startRootIsolate(library.main, []); 1414 _isolate_helper.startRootIsolate(library.main, []);
1407 } 1415 }
1408 dart.start = start; 1416 dart.start = start;
1409 1417
1410 // Libraries used in this file. 1418 // Libraries used in this file.
1411 let core; 1419 let core;
1412 let collection; 1420 let collection;
1413 let async; 1421 let async;
1414 let _interceptors; 1422 let _interceptors;
1415 let _isolate_helper; 1423 let _isolate_helper;
1416 let _js_helper; 1424 let _js_helper;
1417 let _js_primitives; 1425 let _js_primitives;
1418 1426
1427 let _bootstrapped = false;
1419 function bootstrap() { 1428 function bootstrap() {
1420 if (core) return; 1429 if (_bootstrapped) return;
1430 _bootstrapped = true;
1421 1431
1432 // Setup stubs for top-level symbols.
1422 let lazyImport = (name) => libraries[name].stub(); 1433 let lazyImport = (name) => libraries[name].stub();
1423
1424 core = lazyImport('dart/core'); 1434 core = lazyImport('dart/core');
1425 collection = lazyImport('dart/collection'); 1435 collection = lazyImport('dart/collection');
1426 async = lazyImport('dart/async'); 1436 async = lazyImport('dart/async');
1427 _interceptors = lazyImport('dart/_interceptors'); 1437 _interceptors = lazyImport('dart/_interceptors');
1428 _isolate_helper = lazyImport('dart/_isolate_helper'); 1438 _isolate_helper = lazyImport('dart/_isolate_helper');
1429 _js_helper = lazyImport('dart/_js_helper'); 1439 _js_helper = lazyImport('dart/_js_helper');
1430 _js_helper.checkNum = notNull; 1440 _js_helper.checkNum = notNull;
1431 _js_primitives = lazyImport('dart/_js_primitives'); 1441 _js_primitives = lazyImport('dart/_js_primitives');
1432 _js_primitives.printString = (s) => console.log(s); 1442 _js_primitives.printString = (s) => console.log(s);
1433 1443
1444 // Create namespace for dart extension members.
1445 dartx = dartx || {};
1446
1447 // Force import of core.
1448 import_('dart/core');
vsm 2015/06/11 17:27:40 Note, I need to do a lazy import above first to en
Leaf 2015/06/11 18:05:03 Just a note - I'm refactoring a lot of this follow
1449
1434 // TODO(vsm): DOM facades? 1450 // TODO(vsm): DOM facades?
1435 // See: https://github.com/dart-lang/dev_compiler/issues/173 1451 // See: https://github.com/dart-lang/dev_compiler/issues/173
1436 NodeList.prototype.get = function(i) { return this[i]; }; 1452 NodeList.prototype.get = function(i) { return this[i]; };
1437 NamedNodeMap.prototype.get = function(i) { return this[i]; }; 1453 NamedNodeMap.prototype.get = function(i) { return this[i]; };
1438 DOMTokenList.prototype.get = function(i) { return this[i]; }; 1454 DOMTokenList.prototype.get = function(i) { return this[i]; };
1455 HTMLCollection.prototype.get = function(i) { return this[i]; };
1439 1456
1440 // TODO(vsm): This is referenced (as init.globalState) from 1457 // TODO(vsm): This is referenced (as init.globalState) from
1441 // isolate_helper.dart. Where should it go? 1458 // isolate_helper.dart. Where should it go?
1442 // See: https://github.com/dart-lang/dev_compiler/issues/164 1459 // See: https://github.com/dart-lang/dev_compiler/issues/164
1443 dart.globalState = null; 1460 dart.globalState = null;
1444
1445 /** Dart extension members. */
1446 dartx = dartx || {};
1447 } 1461 }
1448 })(dart || (dart = {})); 1462 })(dart || (dart = {}));
OLDNEW
« no previous file with comments | « no previous file | lib/src/codegen/html_codegen.dart » ('j') | lib/src/codegen/html_codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698