Files
sdk/pkg/dev_compiler/test/codegen/expect/misc.js
T
Olivier Chafik 3886194414 Generate _runtime.js from dart (https://github.com/dart-lang/dev_compiler/issues/310)
The following part files were ported from the original .js (lib/runtime/dart/_foo.js -> input_sdk/private/foo.dart):
- input_sdk/private/rtti.dart
- input_sdk/private/types.dart
- input_sdk/private/classes.dart
- input_sdk/private/errors.dart
- input_sdk/private/generators.dart
- input_sdk/private/operations.dart
- input_sdk/private/runtime.dart

Notes:
- Introduced genericTypeConstructor intrinsic: `JS('', '#(type)', genericTypeConstructor(List))` generates `core.List$(type)`
- Used new JS quasiquotes everywhere
- Depends on new internal `@JSExportName` annotation to alias symbols like dart.{as, is, const, assert, export, implements, throw, async, dynamic, void} (see https://codereview.chromium.org/1580413002/)

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1530563003 .
2016-01-21 00:45:31 +00:00

68 lines
1.9 KiB
JavaScript

dart_library.library('misc', null, /* Imports */[
'dart/_runtime',
'dart/core'
], /* Lazy imports */[
], function(exports, dart, core) {
'use strict';
let dartx = dart.dartx;
class _Uninitialized extends core.Object {
_Uninitialized() {
}
}
dart.setSignature(_Uninitialized, {
constructors: () => ({_Uninitialized: [_Uninitialized, []]})
});
const UNINITIALIZED = dart.const(new _Uninitialized());
const Generic$ = dart.generic(function(T) {
class Generic extends core.Object {
get type() {
return Generic$();
}
}
return Generic;
});
let Generic = Generic$();
class Base extends core.Object {
Base() {
this.x = 1;
this.y = 2;
}
['=='](obj) {
return dart.is(obj, Base) && dart.equals(dart.dload(obj, 'x'), this.x) && dart.equals(dart.dload(obj, 'y'), this.y);
}
}
class Derived extends core.Object {
Derived() {
this.z = 3;
}
['=='](obj) {
return dart.is(obj, Derived) && dart.equals(dart.dload(obj, 'z'), this.z) && super['=='](obj);
}
}
function _isWhitespace(ch) {
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
dart.fn(_isWhitespace, core.bool, [core.String]);
const expr = 'foo';
const _escapeMap = dart.const(dart.map({'\n': '\\n', '\r': '\\r', '\f': '\\f', '\b': '\\b', '\t': '\\t', '\v': '\\v', '': '\\x7F', [`\${${expr}}`]: ''}));
function main() {
core.print(dart.toString(1));
core.print(dart.toString(1.0));
core.print(dart.toString(1.1));
let x = 42;
core.print(dart.equals(x, dart.dynamic));
core.print(dart.equals(x, Generic));
core.print(new (Generic$(core.int))().type);
core.print(dart.equals(new Derived(), new Derived()));
}
dart.fn(main);
// Exports:
exports.UNINITIALIZED = UNINITIALIZED;
exports.Generic$ = Generic$;
exports.Generic = Generic;
exports.Base = Base;
exports.Derived = Derived;
exports.expr = expr;
exports.main = main;
});