Update trunk to version 0.4.6.0
svn merge -r 20992:21363 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
git-svn-id: http://dart.googlecode.com/svn/trunk@21377 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/compiler/.gitignore b/compiler/.gitignore
index 02aa8f2..5a9c6a0 100644
--- a/compiler/.gitignore
+++ b/compiler/.gitignore
@@ -13,8 +13,10 @@
/jsonlib_sources.gypi
/jsonlib_sources.xml
/sources.gypi
+/sources.txt
/sources.xml
/test_sources.gypi
+/test_sources.txt
/test_sources.xml
/out
/xcodebuild
diff --git a/compiler/generate_source_list.py b/compiler/generate_source_list.py
index 4fe72a5..d0dfa5b 100644
--- a/compiler/generate_source_list.py
+++ b/compiler/generate_source_list.py
@@ -57,6 +57,10 @@
out.write(''' r'%s/%s',%s''' % (self.path, filename,'\n'))
out.write(" ],\n")
+ def _print_txt_files(self, out, files):
+ for filename in files:
+ out.write('%s\n' % os.path.join(self.path, filename))
+
def _print_ant_files(self, out, name, files):
out.write(" <filelist id='%s' dir='%s'>\n" % (name, self.path))
for filename in files:
@@ -89,6 +93,7 @@
def generate(self):
self._list_files()
+
file_name = self.output + '.gypi';
gypi = self._make_output(file_name)
gypi.write("{\n 'variables': {\n")
@@ -96,6 +101,7 @@
self._print_gypi_files(gypi, self.name + '_resources', self.resources)
gypi.write(" },\n}\n")
self._close(file_name, gypi)
+
file_name = self.output + '.xml'
ant = self._make_output(file_name)
ant.write("<project>\n")
@@ -104,6 +110,11 @@
ant.write("</project>\n")
self._close(file_name, ant)
+ file_name = self.output + '.txt';
+ txt = self._make_output(file_name)
+ self._print_txt_files(txt, self.sources)
+ self._close(file_name, txt)
+
def Main(script_name = None, name = None, output = None, path = None,
*rest):
diff --git a/compiler/scripts/generate_my_projects.py b/compiler/scripts/generate_my_projects.py
index 82f7400..ff5800bb 100755
--- a/compiler/scripts/generate_my_projects.py
+++ b/compiler/scripts/generate_my_projects.py
@@ -12,28 +12,49 @@
return os.path.normpath(os.path.join(*args))
compiler = normjoin(sys.argv[0], os.pardir, os.pardir)
- tools = normjoin(compiler, os.pardir, 'tools')
+ editor = normjoin(compiler, os.pardir, 'editor')
+
locations = {
'compiler': compiler,
- 'tools': tools,
- }
+ 'editor': editor,
+ }
- exit_code = os.system("python %(compiler)s/generate_source_list.py "
- "java %(compiler)s/sources java" % locations)
- if exit_code:
- return exit_code
+ generate_source_list_calls = [
+ # The paths are relative to dart/compiler/
+ {
+ "name" : "java",
+ "output" : "%(compiler)s/sources" % locations,
+ "path" : "java",
+ },
+ {
+ "name" : "javatests",
+ "output" : "%(compiler)s/test_sources" % locations,
+ "path" : "javatests",
+ },
+ # The paths are relative to dart/editor/
+ {
+ "name" : "plugin_engine_java",
+ "output" : "%(editor)s/plugin_engine_sources" % locations,
+ "path" : "tools/plugins/com.google.dart.engine",
+ },
+ {
+ "name" : "plugin_command_analyze_java",
+ "output" : "%(editor)s/plugin_command_analyze_sources" % locations,
+ "path" : "tools/plugins/com.google.dart.command.analyze",
+ },
+ ]
-
- exit_code = os.system("python %(compiler)s/generate_source_list.py "
- "javatests %(compiler)s/test_sources javatests"
- % locations)
- if exit_code:
- return exit_code
+ for call_options in generate_source_list_calls:
+ command = ("python %(compiler)s/generate_source_list.py " % locations +
+ "%(name)s %(output)s %(path)s" % call_options)
+ exit_code = os.system(command)
+ if exit_code:
+ return exit_code
if '--no-gyp' in sys.argv:
print '--no-gyp is deprecated.'
- return exit_code
+ return 0
if __name__ == '__main__':
diff --git a/dart.gyp b/dart.gyp
index a40eae5..b4f7aa4 100644
--- a/dart.gyp
+++ b/dart.gyp
@@ -5,22 +5,7 @@
{
'targets': [
{
- # Contains all dependencies.
- 'target_name': 'everything',
- 'type': 'none',
- 'dependencies': [
- # Most dependencies.
- 'default',
- # All other targets.
- 'api_docs',
- 'dartc_bot',
- 'dart2js_bot',
- ],
- },
- {
- # Contains all the dependencies that will run by default.
- # Excludes api_docs.
- 'target_name': 'default',
+ 'target_name': 'most',
'type': 'none',
'dependencies': [
'analyzer',
@@ -75,7 +60,7 @@
'<!@(["python", "tools/list_files.py", "", "sdk/bin"])',
'tools/create_sdk.py',
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)',
- '<(PRODUCT_DIR)/dart2js.snapshot',
+ '<(SHARED_INTERMEDIATE_DIR)/utils_wrapper.dart.snapshot',
'<(PRODUCT_DIR)/analyzer/bin/dart_analyzer',
],
'outputs': [
@@ -84,7 +69,9 @@
'action': [
'python',
'tools/create_sdk.py',
- '<(PRODUCT_DIR)/dart-sdk',
+ '--sdk_output_dir', '<(PRODUCT_DIR)/dart-sdk',
+ '--utils_snapshot_location',
+ '<(SHARED_INTERMEDIATE_DIR)/utils_wrapper.dart.snapshot'
],
'message': 'Creating SDK.',
},
@@ -128,11 +115,21 @@
'target_name': 'analyzer',
'type': 'none',
'dependencies': [
- 'create_sdk',
'editor/analyzer.gyp:analyzer',
],
},
{
+ # This is the target that is built on the dart2dart bots.
+ # It must depend on anything that is required by dart2dart
+ # tests.
+ 'target_name': 'dart2dart_bot',
+ 'type': 'none',
+ 'dependencies': [
+ 'create_sdk',
+ 'packages',
+ ],
+ },
+ {
# This is the target that is built on the dartc bots.
# It must depend on anything that is required by dartc
# tests.
diff --git a/pkg/analyzer_experimental/lib/src/generated/ast.dart b/pkg/analyzer_experimental/lib/src/generated/ast.dart
index cc22cd4..96e7662 100644
--- a/pkg/analyzer_experimental/lib/src/generated/ast.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/ast.dart
@@ -13045,7 +13045,7 @@
owner.becomeParentOf(node);
elements.add(node);
}
- bool addAll(Collection<E> nodes) {
+ bool addAll(Iterable<E> nodes) {
if (nodes != null) {
for (E node in nodes) {
add(node);
@@ -13081,4 +13081,4 @@
ASTNode getOwner() {
return owner;
}
-}
\ No newline at end of file
+}
diff --git a/pkg/analyzer_experimental/lib/src/generated/element.dart b/pkg/analyzer_experimental/lib/src/generated/element.dart
index 1a140b9..3d7e2a4 100644
--- a/pkg/analyzer_experimental/lib/src/generated/element.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/element.dart
@@ -1277,9 +1277,9 @@
accept(ElementVisitor visitor) => visitor.visitClassElement(this);
List<PropertyAccessorElement> get accessors => _accessors;
List<InterfaceType> get allSupertypes {
- Collection<InterfaceType> list = new Set<InterfaceType>();
- collectAllSupertypes(list);
- return new List.from(list);
+ Set<InterfaceType> set = new Set<InterfaceType>();
+ collectAllSupertypes(set);
+ return set.toList();
}
ElementImpl getChild(String identifier25) {
for (PropertyAccessorElement accessor in _accessors) {
@@ -1541,7 +1541,7 @@
builder.append(">");
}
}
- void collectAllSupertypes(Collection<InterfaceType> list) {
+ void collectAllSupertypes(var list) {
if (_supertype == null || list.contains(_supertype)) {
return;
}
@@ -4913,4 +4913,4 @@
*/
abstract class VoidType implements Type2 {
VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes);
-}
\ No newline at end of file
+}
diff --git a/pkg/analyzer_experimental/lib/src/generated/java_core.dart b/pkg/analyzer_experimental/lib/src/generated/java_core.dart
index 900c2ca..f293998 100644
--- a/pkg/analyzer_experimental/lib/src/generated/java_core.dart
+++ b/pkg/analyzer_experimental/lib/src/generated/java_core.dart
@@ -2,6 +2,7 @@
import "dart:math" as math;
import "dart:uri";
+import "dart:collection" show ListBase;
class JavaSystem {
static int currentTimeMillis() {
@@ -257,7 +258,7 @@
String toString() => "IOException";
}
-class ListWrapper<E> extends Collection<E> implements List<E> {
+class ListWrapper<E> extends ListBase<E> implements List<E> {
List<E> elements = new List<E>();
Iterator<E> get iterator {
@@ -276,6 +277,8 @@
elements.length = newLength;
}
+ int get length => elements.length;
+
void add(E value) {
elements.add(value);
}
@@ -344,13 +347,13 @@
}
class JavaIterator<E> {
- Collection<E> _collection;
+ Iterable<E> _iterable;
List<E> _elements = new List<E>();
int _coPos = 0;
int _elPos = 0;
E _current = null;
- JavaIterator(this._collection) {
- Iterator iterator = _collection.iterator;
+ JavaIterator(this._iterable) {
+ Iterator iterator = _iterable.iterator;
while (iterator.moveNext()) {
_elements.add(iterator.current);
}
@@ -368,13 +371,13 @@
}
void remove() {
- if (_collection is List) {
+ if (_iterable is List) {
_coPos--;
- (_collection as List).remove(_coPos);
- } else if (_collection is Set) {
- _collection.remove(_current);
+ (_iterable as List).remove(_coPos);
+ } else if (_iterable is Set) {
+ _iterable.remove(_current);
} else {
- throw new StateError("Unsupported collection ${_collection.runtimeType}");
+ throw new StateError("Unsupported iterable ${_iterable.runtimeType}");
}
}
}
diff --git a/pkg/args/lib/args.dart b/pkg/args/lib/args.dart
index 48cef16..1337b46 100644
--- a/pkg/args/lib/args.dart
+++ b/pkg/args/lib/args.dart
@@ -417,7 +417,7 @@
return _options[name];
}
- /** Get the names of the options as a [Collection]. */
- Collection<String> get options => _options.keys.toList(growable: false);
+ /** Get the names of the options as an [Iterable]. */
+ Iterable<String> get options => _options.keys;
}
diff --git a/sdk/lib/core/expect.dart b/pkg/expect/lib/expect.dart
similarity index 96%
rename from sdk/lib/core/expect.dart
rename to pkg/expect/lib/expect.dart
index 0302d3d..0f83041 100644
--- a/sdk/lib/core/expect.dart
+++ b/pkg/expect/lib/expect.dart
@@ -2,23 +2,23 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-part of dart.core;
+/**
+ * This library contains an Expect class with static methods that can be used
+ * for simple unit-tests.
+ */
+library expect;
/**
- * This class is *deprecated*.
- *
* Expect is used for tests that do not want to make use of the
* Dart unit test library - for example, the core language tests.
* Third parties are discouraged from using this, and should use
* the expect() function in the unit test library instead for
* test assertions.
*/
-@deprecated
class Expect {
/**
* Checks whether the expected and actual values are equal (using `==`).
*/
- @deprecated
static void equals(var expected, var actual, [String reason = null]) {
if (expected == actual) return;
String msg = _getMessage(reason);
@@ -28,7 +28,6 @@
/**
* Checks whether the actual value is a bool and its value is true.
*/
- @deprecated
static void isTrue(var actual, [String reason = null]) {
if (_identical(actual, true)) return;
String msg = _getMessage(reason);
@@ -38,7 +37,6 @@
/**
* Checks whether the actual value is a bool and its value is false.
*/
- @deprecated
static void isFalse(var actual, [String reason = null]) {
if (_identical(actual, false)) return;
String msg = _getMessage(reason);
@@ -48,7 +46,6 @@
/**
* Checks whether [actual] is null.
*/
- @deprecated
static void isNull(actual, [String reason = null]) {
if (null == actual) return;
String msg = _getMessage(reason);
@@ -58,7 +55,6 @@
/**
* Checks whether [actual] is not null.
*/
- @deprecated
static void isNotNull(actual, [String reason = null]) {
if (null != actual) return;
String msg = _getMessage(reason);
@@ -69,7 +65,6 @@
* Checks whether the expected and actual values are identical
* (using `identical`).
*/
- @deprecated
static void identical(var expected, var actual, [String reason = null]) {
if (_identical(expected, actual)) return;
String msg = _getMessage(reason);
@@ -78,7 +73,6 @@
}
// Unconditional failure.
- @deprecated
static void fail(String msg) {
_fail("Expect.fail('$msg')");
}
@@ -88,7 +82,6 @@
* given tolerance. If no tolerance is given, tolerance is assumed to be the
* value 4 significant digits smaller than the value given for expected.
*/
- @deprecated
static void approxEquals(num expected,
num actual,
[num tolerance = null,
@@ -104,7 +97,6 @@
'tolerance:<$tolerance>$msg) fails');
}
- @deprecated
static void notEquals(unexpected, actual, [String reason = null]) {
if (unexpected != actual) return;
String msg = _getMessage(reason);
@@ -118,7 +110,6 @@
* used by the standard list implementation. It should also produce nicer
* error messages than just calling `Expect.equals(expected, actual)`.
*/
- @deprecated
static void listEquals(List expected, List actual, [String reason = null]) {
String msg = _getMessage(reason);
int n = (expected.length < actual.length) ? expected.length : actual.length;
@@ -143,7 +134,6 @@
* the semantics of [Map.containsKey] to determine what "same" means. For
* each key, checks that the values in both maps are equal using `==`.
*/
- @deprecated
static void mapEquals(Map expected, Map actual, [String reason = null]) {
String msg = _getMessage(reason);
@@ -168,7 +158,6 @@
* Specialized equality test for strings. When the strings don't match,
* this method shows where the mismatch starts and ends.
*/
- @deprecated
static void stringEquals(String expected,
String actual,
[String reason = null]) {
@@ -237,7 +226,6 @@
* Checks that every element of [expected] is also in [actual], and that
* every element of [actual] is also in [expected].
*/
- @deprecated
static void setEquals(Iterable expected,
Iterable actual,
[String reason = null]) {
@@ -278,7 +266,6 @@
*
* Expect.throws(myThrowingFunction, (e) => e is MyException);
*/
- @deprecated
static void throws(void f(),
[_CheckExceptionFn check = null,
String reason = null]) {
@@ -309,7 +296,6 @@
typedef bool _CheckExceptionFn(exception);
-@deprecated
class ExpectException implements Exception {
ExpectException(this.message);
String toString() => message;
diff --git a/pkg/expect/pubspec.yaml b/pkg/expect/pubspec.yaml
new file mode 100644
index 0000000..0b2ed15
--- /dev/null
+++ b/pkg/expect/pubspec.yaml
@@ -0,0 +1,9 @@
+name: expect
+author: "Dart Team <misc@dartlang.org>"
+homepage: http://www.dartlang.org
+description: >
+ Expect is used for tests that do not want to make use of the
+ Dart unit test library - for example, the core language tests.
+ Third parties are discouraged from using this, and should use
+ the expect() function in the unit test library instead for
+ test assertions.
diff --git a/pkg/fixnum/test/int_32_test.dart b/pkg/fixnum/test/int_32_test.dart
index dea6621..407f2a0 100644
--- a/pkg/fixnum/test/int_32_test.dart
+++ b/pkg/fixnum/test/int_32_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library int32test;
+import "package:expect/expect.dart";
import 'package:fixnum/fixnum.dart';
void main() {
diff --git a/pkg/fixnum/test/int_64_test.dart b/pkg/fixnum/test/int_64_test.dart
index a4e2537..8aa3e5b 100644
--- a/pkg/fixnum/test/int_64_test.dart
+++ b/pkg/fixnum/test/int_64_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library int64test;
+import "package:expect/expect.dart";
import 'package:fixnum/fixnum.dart';
void main() {
diff --git a/pkg/fixnum/test/int_64_vm_test.dart b/pkg/fixnum/test/int_64_vm_test.dart
index b9d0f70..b0a40a7 100644
--- a/pkg/fixnum/test/int_64_vm_test.dart
+++ b/pkg/fixnum/test/int_64_vm_test.dart
@@ -6,6 +6,7 @@
library int64vmtest;
+import "package:expect/expect.dart";
import 'dart:math' as math;
part 'package:fixnum/src/int32.dart';
diff --git a/pkg/http/lib/http.dart b/pkg/http/lib/http.dart
index 8a61f6e..07457cd 100644
--- a/pkg/http/lib/http.dart
+++ b/pkg/http/lib/http.dart
@@ -50,7 +50,6 @@
/// return _inner.send(request);
/// }
/// }
-
library http;
import 'dart:async';
diff --git a/pkg/http/lib/src/io_client.dart b/pkg/http/lib/src/io_client.dart
index 9bbb7ee..b7a6730 100644
--- a/pkg/http/lib/src/io_client.dart
+++ b/pkg/http/lib/src/io_client.dart
@@ -32,8 +32,7 @@
request.headers.forEach((name, value) {
ioRequest.headers.set(name, value);
});
- return Future.wait([stream.pipe(ioRequest), ioRequest.response])
- .then((list) => list[1]);
+ return stream.pipe(ioRequest);
}).then((response) {
var headers = {};
response.headers.forEach((key, values) {
diff --git a/pkg/http/lib/src/multipart_request.dart b/pkg/http/lib/src/multipart_request.dart
index bc58871..ab66bbd 100644
--- a/pkg/http/lib/src/multipart_request.dart
+++ b/pkg/http/lib/src/multipart_request.dart
@@ -41,6 +41,21 @@
static final Random _random = new Random();
+ /// The form fields to send for this request.
+ final Map<String, String> fields;
+
+ /// The private version of [files].
+ final List<MultipartFile> _files;
+
+ /// Creates a new [MultipartRequest].
+ MultipartRequest(String method, Uri url)
+ : super(method, url),
+ fields = {},
+ _files = <MultipartFile>[];
+
+ /// The list of files to upload for this request.
+ List<MultipartFile> get files => _files;
+
/// The total length of the request body, in bytes. This is calculated from
/// [fields] and [files] and cannot be set manually.
int get contentLength {
@@ -52,7 +67,7 @@
encodeUtf8(value).length + "\r\n".length;
});
- for (var file in _files.collection) {
+ for (var file in _files) {
length += "--".length + _BOUNDARY_LENGTH + "\r\n".length +
_headerForFile(file).length +
file.length + "\r\n".length;
@@ -66,25 +81,6 @@
"multipart requests.");
}
- /// The form fields to send for this request.
- final Map<String, String> fields;
-
- /// The sink for files to upload for this request.
- ///
- /// This doesn't need to be closed. When the request is sent, whichever files
- /// are written to this sink at that point will be used.
- CollectionSink<MultipartFile> get files => _files;
-
- /// The private version of [files], typed so that the underlying collection is
- /// accessible.
- final CollectionSink<MultipartFile> _files;
-
- /// Creates a new [MultipartRequest].
- MultipartRequest(String method, Uri url)
- : super(method, url),
- fields = {},
- _files = new CollectionSink<MultipartFile>(<MultipartFile>[]);
-
/// Freezes all mutable fields and returns a single-subscription [ByteStream]
/// that will emit the request body.
ByteStream finalize() {
@@ -111,7 +107,7 @@
writeLine();
});
- Future.forEach(_files.collection, (file) {
+ Future.forEach(_files, (file) {
writeAscii('--$boundary\r\n');
writeAscii(_headerForFile(file));
return writeStreamToSink(file.finalize(), controller)
diff --git a/pkg/http/lib/testing.dart b/pkg/http/lib/testing.dart
index 4c750ce..9fe7b06 100644
--- a/pkg/http/lib/testing.dart
+++ b/pkg/http/lib/testing.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library testing;
-
/// This library contains testing classes for the HTTP library.
///
/// The [MockClient] class is a drop-in replacement for `http.Client` that
@@ -23,5 +21,6 @@
/// 'content-type': 'application/json'
/// });
/// };
+library http.testing;
export 'src/mock_client.dart';
diff --git a/pkg/http/test/client_test.dart b/pkg/http/test/client_test.dart
index daa3acb..e898426 100644
--- a/pkg/http/test/client_test.dart
+++ b/pkg/http/test/client_test.dart
@@ -37,6 +37,7 @@
'path': '/',
'headers': {
'content-type': ['application/json; charset=utf-8'],
+ 'accept-encoding': ['gzip'],
'transfer-encoding': ['chunked']
},
'body': '{"hello": "world"}'
diff --git a/pkg/http/test/http_test.dart b/pkg/http/test/http_test.dart
index 81cca76..b3227f5 100644
--- a/pkg/http/test/http_test.dart
+++ b/pkg/http/test/http_test.dart
@@ -36,6 +36,7 @@
'path': '/',
'headers': {
'content-length': ['0'],
+ 'accept-encoding': ['gzip'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
},
@@ -62,6 +63,7 @@
'application/x-www-form-urlencoded; charset=utf-8'
],
'content-length': ['40'],
+ 'accept-encoding': ['gzip'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
},
@@ -83,6 +85,7 @@
'method': 'POST',
'path': '/',
'headers': {
+ 'accept-encoding': ['gzip'],
'content-length': ['0'],
'content-type': ['text/plain'],
'x-random-header': ['Value'],
@@ -110,6 +113,7 @@
'content-type': [
'application/x-www-form-urlencoded; charset=utf-8'
],
+ 'accept-encoding': ['gzip'],
'content-length': ['40'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
@@ -133,6 +137,7 @@
'path': '/',
'headers': {
'content-length': ['0'],
+ 'accept-encoding': ['gzip'],
'content-type': ['text/plain'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
@@ -154,6 +159,7 @@
'path': '/',
'headers': {
'content-length': ['0'],
+ 'accept-encoding': ['gzip'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
}
@@ -172,6 +178,7 @@
'path': '/',
'headers': {
'content-length': ['0'],
+ 'accept-encoding': ['gzip'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
},
@@ -197,6 +204,7 @@
'path': '/',
'headers': {
'content-length': ['0'],
+ 'accept-encoding': ['gzip'],
'x-random-header': ['Value'],
'x-other-header': ['Other Value']
},
diff --git a/pkg/http/test/request_test.dart b/pkg/http/test/request_test.dart
index ea49199..e17589c 100644
--- a/pkg/http/test/request_test.dart
+++ b/pkg/http/test/request_test.dart
@@ -27,6 +27,7 @@
'path': '/',
'headers': {
'content-type': ['text/plain; charset=utf-8'],
+ 'accept-encoding': ['gzip'],
'content-length': ['5']
},
'body': 'hello'
diff --git a/pkg/http/test/safe_http_server.dart b/pkg/http/test/safe_http_server.dart
index 408f080..2b388dd 100644
--- a/pkg/http/test/safe_http_server.dart
+++ b/pkg/http/test/safe_http_server.dart
@@ -131,7 +131,7 @@
List<Cookie> get cookies => _inner.cookies;
Future<Socket> detachSocket() => _inner.detachSocket();
HttpConnectionInfo get connectionInfo => _inner.connectionInfo;
- void writeBytes(List<int> data) => _inner.writeBytes(data);
+ void add(List<int> data) => _inner.add(data);
Future<HttpResponse> consume(Stream<List<int>> stream) =>
_inner.consume(stream);
Future<HttpResponse> writeStream(Stream<List<int>> stream) =>
diff --git a/pkg/intl/lib/intl.dart b/pkg/intl/lib/intl.dart
index c3cbdd5..9a9c529 100644
--- a/pkg/intl/lib/intl.dart
+++ b/pkg/intl/lib/intl.dart
@@ -21,12 +21,15 @@
import 'dart:math';
import 'date_symbols.dart';
import 'src/date_format_internal.dart';
+import "number_symbols.dart";
+import "number_symbols_data.dart";
part 'date_format.dart';
part 'src/date_format_field.dart';
part 'src/date_format_helpers.dart';
part 'bidi_formatter.dart';
part 'bidi_utils.dart';
+part 'number_format.dart';
/**
* The Intl class provides a common entry point for internationalization
@@ -170,7 +173,7 @@
// difficult. As a result, we call this more often. Consider keeping
// verified locales for each purpose if it turns out to be a performance
// issue.
- if (newLocale == null) return systemLocale;
+ if (newLocale == null) return getCurrentLocale();
if (localeExists(newLocale)) {
return newLocale;
}
@@ -244,8 +247,7 @@
// We have to do this silliness because Locale is not known at compile time,
// but must be a static variable in order to be visible to the Intl.message
// invocation.
- if (_defaultLocale == null) _defaultLocale = systemLocale;
- var oldLocale = _defaultLocale;
+ var oldLocale = getCurrentLocale();
_defaultLocale = locale;
var result = message_function();
_defaultLocale = oldLocale;
diff --git a/pkg/intl/lib/number_format.dart b/pkg/intl/lib/number_format.dart
index ed5cf2b..c700e62 100644
--- a/pkg/intl/lib/number_format.dart
+++ b/pkg/intl/lib/number_format.dart
@@ -2,14 +2,41 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library number_format;
-
-import 'dart:math';
-
-import "intl.dart";
-import "number_symbols.dart";
-import "number_symbols_data.dart";
-
+part of intl;
+/**
+ * Provides the ability to format a number in a locale-specific way. The
+ * format is specified as a pattern using a subset of the ICU formatting
+ * patterns.
+ *
+ * 0 - A single digit
+ * # - A single digit, omitted if the value is zero
+ * . - Decimal separator
+ * - - Minus sign
+ * , - Grouping separator
+ * E - Separates mantissa and expontent
+ * + - Before an exponent, indicates it should be prefixed with a plus sign.
+ * % - In prefix or suffix, multiply by 100 and show as percentage
+ * \u2030 - In prefix or suffix, multiply by 1000 and show as per mille
+ * \u00A4 - Currency sign, replaced by currency name
+ * ' - Used to quote special characters
+ * ; - Used to separate the positive and negative patterns if both are present
+ *
+ * For example,
+ * var f = new NumberFormat("###.0#", "en_US");
+ * print(f.format(12.345));
+ * ==> 12.34
+ * If the locale is not specified, it will default to the current locale. If
+ * the format is not specified it will print in a basic format with at least
+ * one integer digit and three fraction digits.
+ *
+ * There are also standard patterns available via the special constructors. e.g.
+ * var symbols = new NumberFormat.percentFormat("ar");
+ * There are four such constructors: decimalFormat, percentFormat,
+ * scientificFormat and currencyForamt. However, at the moment,
+ * scientificFormat prints only as equivalent to "#E0" and does not take
+ * into account significant digits. currencyFormat will always use the name
+ * of the currency rather than the symbol.
+ */
class NumberFormat {
/** Variables to determine how number printing behaves. */
// TODO(alanknight): If these remain as variables and are set based on the
@@ -18,19 +45,64 @@
String _positivePrefix = '';
String _negativeSuffix = '';
String _positiveSuffix = '';
- /** How many numbers in a group when using punctuation to group digits in
+ /**
+ * How many numbers in a group when using punctuation to group digits in
* large numbers. e.g. in en_US: "1,000,000" has a grouping size of 3 digits
* between commas.
*/
int _groupingSize = 3;
bool _decimalSeparatorAlwaysShown = false;
+ bool _useSignForPositiveExponent = false;
bool _useExponentialNotation = false;
+
int _maximumIntegerDigits = 40;
int _minimumIntegerDigits = 1;
- int _maximumFractionDigits = 3; // invariant, >= minFractionDigits
+ int _maximumFractionDigits = 3;
int _minimumFractionDigits = 0;
int _minimumExponentDigits = 0;
- bool _useSignForPositiveExponent = false;
+
+ int _multiplier = 1;
+
+ /**
+ * Stores the pattern used to create this format. This isn't used, but
+ * is helpful in debugging.
+ */
+ String _pattern;
+ /**
+ * Set the maximum digits printed to the left of the decimal point.
+ * Normally this is computed from the pattern, but it's exposed here for
+ * testing purposes and for rare cases where you want to force it explicitly.
+ */
+ void setMaximumIntegerDigits(int max) {
+ _maximumIntegerDigits = max;
+ }
+
+ /**
+ * Set the minimum number of digits printed to the left of the decimal point.
+ * Normally this is computed from the pattern, but it's exposed here for
+ * testing purposes and for rare cases where you want to force it explicitly.
+ */
+ void setMinimumIntegerDigits(int min) {
+ _minimumIntegerDigits = min;
+ }
+
+ /**
+ * Set the maximum number of digits printed to the right of the decimal point.
+ * Normally this is computed from the pattern, but it's exposed here for
+ * testing purposes and for rare cases where you want to force it explicitly.
+ */
+ void setMaximumFractionDigits(int max) {
+ _maximumFractionDigits = max;
+ }
+
+ /**
+ * Set the minimum digits printed to the left of the decimal point.
+ * Normally this is computed from the pattern, but it's exposed here for
+ * testing purposes and for rare cases where you want to force it explicitly.
+ */
+ void setMinimumFractionDigits(int max) {
+ _minimumFractionDigits = max;
+ }
/** The locale in which we print numbers. */
final String _locale;
@@ -48,15 +120,37 @@
StringBuffer _buffer;
/**
- * Create a number format that prints in [newPattern] as it applies in
+ * Create a number format that prints using [newPattern] as it applies in
* [locale].
*/
- NumberFormat([String newPattern, String locale]):
- _locale = Intl.verifiedLocale(locale, localeExists) {
- // TODO(alanknight): There will need to be some kind of async setup
- // operations so as not to bring along every locale in every program.
+ factory NumberFormat([String newPattern, String locale]) {
+ return new NumberFormat._forPattern(locale, (x) => newPattern);
+ }
+
+ /** Create a number format that prints as DECIMAL_PATTERN. */
+ NumberFormat.decimalPattern([String locale]) :
+ this._forPattern(locale, (x) => x.DECIMAL_PATTERN);
+
+ /** Create a number format that prints as PERCENT_PATTERN. */
+ NumberFormat.percentPattern([String locale]) :
+ this._forPattern(locale, (x) => x.PERCENT_PATTERN);
+
+ /** Create a number format that prints as SCIENTIFIC_PATTERN. */
+ NumberFormat.scientificPattern([String locale]) :
+ this._forPattern(locale, (x) => x.SCIENTIFIC_PATTERN);
+
+ /** Create a number format that prints as CURRENCY_PATTERN. */
+ NumberFormat.currencyPattern([String locale]) :
+ this._forPattern(locale, (x) => x.CURRENCY_PATTERN);
+
+ /**
+ * Create a number format that prints in a pattern we get from
+ * the [getPattern] function using the locale [locale].
+ */
+ NumberFormat._forPattern(String locale, Function getPattern) :
+ _locale = Intl.verifiedLocale(locale, localeExists) {
_symbols = numberFormatSymbols[_locale];
- _setPattern(newPattern);
+ _setPattern(getPattern(_symbols));
}
/**
@@ -81,9 +175,6 @@
return _symbols;
}
- // TODO(alanknight): Actually use the pattern and locale.
- _setPattern(String x) {}
-
/**
* Format [number] according to our pattern and return the formatted string.
*/
@@ -95,7 +186,7 @@
_newBuffer();
_add(_signPrefix(number));
- _formatNumber(number.abs());
+ _formatNumber(number.abs() * _multiplier);
_add(_signSuffix(number));
var result = _buffer.toString();
@@ -115,7 +206,7 @@
}
/** Format the number in exponential notation. */
- _formatExponential(num number) {
+ void _formatExponential(num number) {
if (number == 0.0) {
_formatFixed(number);
_formatExponent(0);
@@ -123,16 +214,32 @@
}
var exponent = (log(number) / log(10)).floor();
- var mantissa = number / pow(10, exponent);
+ var mantissa = number / pow(10.0, exponent);
- if (_minimumIntegerDigits < 1) {
- exponent++;
- mantissa /= 10;
+ var minIntDigits = _minimumIntegerDigits;
+ if (_maximumIntegerDigits > 1 &&
+ _maximumIntegerDigits > _minimumIntegerDigits) {
+ // A repeating range is defined; adjust to it as follows.
+ // If repeat == 3, we have 6,5,4=>3; 3,2,1=>0; 0,-1,-2=>-3;
+ // -3,-4,-5=>-6, etc. This takes into account that the
+ // exponent we have here is off by one from what we expect;
+ // it is for the format 0.MMMMMx10^n.
+ while ((exponent % _maximumIntegerDigits) != 0) {
+ mantissa *= 10;
+ exponent--;
+ }
+ minIntDigits = 1;
} else {
- exponent -= _minimumIntegerDigits - 1;
- mantissa *= pow(10, _minimumIntegerDigits - 1);
+ // No repeating range is defined, use minimum integer digits.
+ if (_minimumIntegerDigits < 1) {
+ exponent++;
+ mantissa /= 10;
+ } else {
+ exponent -= _minimumIntegerDigits - 1;
+ mantissa *= pow(10, _minimumIntegerDigits - 1);
+ }
}
- _formatFixed(number);
+ _formatFixed(mantissa);
_formatExponent(exponent);
}
@@ -150,24 +257,45 @@
_pad(_minimumExponentDigits, exponent.toString());
}
+ /** Used to test if we have exceeded Javascript integer limits. */
+ final _maxInt = pow(2, 52);
+
/**
* Format the basic number portion, inluding the fractional digits.
*/
void _formatFixed(num number) {
- // Round the number.
+ // Very fussy math to get integer and fractional parts.
var power = pow(10, _maximumFractionDigits);
- var intValue = number.truncate();
- var multiplied = (number * power).round();
- var fracValue = (multiplied - intValue * power).floor();
+ var shiftedNumber = (number * power);
+ // We must not roundToDouble() an int or it will lose precision. We must not
+ // round() a large double or it will take its loss of precision and
+ // preserve it in an int, which we will then print to the right
+ // of the decimal place. Therefore, only roundToDouble if we are already
+ // a double.
+ if (shiftedNumber is double) {
+ shiftedNumber = shiftedNumber.roundToDouble();
+ }
+ var intValue, fracValue;
+ if (shiftedNumber.isInfinite) {
+ intValue = number.toInt();
+ fracValue = 0;
+ } else {
+ intValue = shiftedNumber.round() ~/ power;
+ fracValue = (shiftedNumber - intValue * power).floor();
+ }
var fractionPresent = _minimumFractionDigits > 0 || fracValue > 0;
- // On dartj2s the integer part may be large enough to be a floating
- // point value, in which case we reduce it until it is small enough
- // to be printed as an integer and pad the remainder with zeros.
+ // If the int part is larger than 2^52 and we're on Javascript (so it's
+ // really a float) it will lose precision, so pad out the rest of it
+ // with zeros. Check for Javascript by seeing if an integer is double.
var paddingDigits = new StringBuffer();
- while ((intValue & 0x7fffffff) != intValue) {
- paddingDigits.write(symbols.ZERO_DIGIT);
- intValue = intValue ~/ 10;
+ if (1 is double && intValue > _maxInt) {
+ var howManyDigitsTooBig = (log(intValue) / LN10).ceil() - 16;
+ var divisor = pow(10, howManyDigitsTooBig).round();
+ for (var each in new List(howManyDigitsTooBig.toInt())) {
+ paddingDigits.write(symbols.ZERO_DIGIT);
+ }
+ intValue = (intValue / divisor).truncate();
}
var integerDigits = "${intValue}${paddingDigits}".codeUnits;
var digitLength = integerDigits.length;
@@ -193,7 +321,7 @@
void _formatFractionPart(String fractionPart) {
var fractionCodes = fractionPart.codeUnits;
var fractionLength = fractionPart.length;
- while (fractionPart[fractionLength - 1] == '0' &&
+ while(fractionCodes[fractionLength - 1] == _zero &&
fractionLength > _minimumFractionDigits + 1) {
fractionLength--;
}
@@ -258,14 +386,14 @@
}
/** Returns the code point for the character '0'. */
- int get _zero => '0'.codeUnits.first;
+ final _zero = '0'.codeUnits.first;
/** Returns the code point for the locale's zero digit. */
// Note that there is a slight risk of a locale's zero digit not fitting
// into a single code unit, but it seems very unlikely, and if it did,
// there's a pretty good chance that our assumptions about being able to do
// arithmetic on it would also be invalid.
- int get _localeZero => symbols.ZERO_DIGIT.codeUnits.first;
+ get _localeZero => symbols.ZERO_DIGIT.codeUnits.first;
/**
* Returns the prefix for [x] based on whether it's positive or negative.
@@ -282,4 +410,332 @@
String _signSuffix(num x) {
return x.isNegative ? _negativeSuffix : _positiveSuffix;
}
+
+ void _setPattern(String newPattern) {
+ if (newPattern == null) return;
+ // Make spaces non-breaking
+ _pattern = newPattern.replaceAll(' ', '\u00a0');
+ var parser = new _NumberFormatParser(this, newPattern);
+ parser.parse();
+ }
+
+ String toString() => "NumberFormat($_locale, $_pattern)";
}
+
+/**
+ * Private class that parses the numeric formatting pattern and sets the
+ * variables in [format] to appropriate values. Instances of this are
+ * transient and store parsing state in instance variables, so can only be used
+ * to parse a single pattern.
+ */
+class _NumberFormatParser {
+
+ /**
+ * The special characters in the pattern language. All others are treated
+ * as literals.
+ */
+ static const _PATTERN_SEPARATOR = ';';
+ static const _QUOTE = "'";
+ static const _PATTERN_DIGIT = '#';
+ static const _PATTERN_ZERO_DIGIT = '0';
+ static const _PATTERN_GROUPING_SEPARATOR = ',';
+ static const _PATTERN_DECIMAL_SEPARATOR = '.';
+ static const _PATTERN_CURRENCY_SIGN = '\u00A4';
+ static const _PATTERN_PER_MILLE = '\u2030';
+ static const _PATTERN_PERCENT = '%';
+ static const _PATTERN_EXPONENT = 'E';
+ static const _PATTERN_PLUS = '+';
+
+ /** The format whose state we are setting. */
+ final NumberFormat format;
+
+ /** The pattern we are parsing. */
+ final _StringIterator pattern;
+
+ /**
+ * Create a new [_NumberFormatParser] for a particular [NumberFormat] and
+ * [input] pattern.
+ */
+ _NumberFormatParser(this.format, input) : pattern = _iterator(input) {
+ pattern.moveNext();
+ }
+
+ /** The [NumberSymbols] for the locale in which our [format] prints. */
+ NumberSymbols get symbols => format.symbols;
+
+ /** Parse the input pattern and set the values. */
+ void parse() {
+ format._positivePrefix = _parseAffix();
+ var trunk = _parseTrunk();
+ format._positiveSuffix = _parseAffix();
+ // If we have separate positive and negative patterns, now parse the
+ // the negative version.
+ if (pattern.current == _NumberFormatParser._PATTERN_SEPARATOR) {
+ pattern.moveNext();
+ format._negativePrefix = _parseAffix();
+ // Skip over the negative trunk, verifying that it's identical to the
+ // positive trunk.
+ for (var each in _iterator(trunk)) {
+ if (pattern.current != each && pattern.current != null) {
+ throw new FormatException(
+ "Positive and negative trunks must be the same");
+ }
+ pattern.moveNext();
+ }
+ format._negativeSuffix = _parseAffix();
+ } else {
+ // If no negative affix is specified, they share the same positive affix.
+ format._negativePrefix = format._positivePrefix + format._negativePrefix;
+ format._negativeSuffix = format._negativeSuffix + format._positiveSuffix;
+ }
+ }
+
+ /** Variable used in parsing prefixes and suffixes to keep track of
+ * whether or not we are in a quoted region. */
+ bool inQuote = false;
+
+ /**
+ * Parse a prefix or suffix and return the prefix/suffix string. Note that
+ * this also may modify the state of [format].
+ */
+ String _parseAffix() {
+ var affix = new StringBuffer();
+ inQuote = false;
+ var loop = true;
+ while (loop) {
+ loop = parseCharacterAffix(affix) && pattern.moveNext();
+ }
+ return affix.toString();
+ }
+
+ /**
+ * Parse an individual character as part of a prefix or suffix. Return true
+ * if we should continue to look for more affix characters, and false if
+ * we have reached the end.
+ */
+ bool parseCharacterAffix(StringBuffer affix) {
+ var ch = pattern.current;
+ if (ch == null) return false;
+ if (ch == _QUOTE) {
+ var nextChar = pattern.peek;
+ if (nextChar == _QUOTE) {
+ pattern.moveNext();
+ affix.write(_QUOTE); // 'don''t'
+ } else {
+ inQuote = !inQuote;
+ }
+ return true;
+ }
+
+ if (inQuote) {
+ affix.write(ch);
+ } else {
+ switch (ch) {
+ case _PATTERN_DIGIT:
+ case _PATTERN_ZERO_DIGIT:
+ case _PATTERN_GROUPING_SEPARATOR:
+ case _PATTERN_DECIMAL_SEPARATOR:
+ case _PATTERN_SEPARATOR:
+ return false;
+ case _PATTERN_CURRENCY_SIGN:
+ // TODO(alanknight): Handle the local/global/portable currency signs
+ affix.write(symbols.DEF_CURRENCY_CODE);
+ break;
+ case _PATTERN_PERCENT:
+ if (format._multiplier != 1) {
+ throw new FormatException('Too many percent/permill');
+ }
+ format._multiplier = 100;
+ affix.write(symbols.PERCENT);
+ break;
+ case _PATTERN_PER_MILLE:
+ if (format._multiplier != 1) {
+ throw new FormatException('Too many percent/permill');
+ }
+ format._multiplier = 1000;
+ affix.write(symbols.PERMILL);
+ break;
+ default:
+ affix.write(ch);
+ }
+ }
+ return true;
+ }
+
+ /** Variables used in [parseTrunk] and [parseTrunkCharacter]. */
+ var decimalPos;
+ var digitLeftCount;
+ var zeroDigitCount;
+ var digitRightCount;
+ var groupingCount;
+ var trunk;
+
+ /**
+ * Parse the "trunk" portion of the pattern, the piece that doesn't include
+ * positive or negative prefixes or suffixes.
+ */
+ String _parseTrunk() {
+ decimalPos = -1;
+ digitLeftCount = 0;
+ zeroDigitCount = 0;
+ digitRightCount = 0;
+ groupingCount = -1;
+
+ var loop = true;
+ trunk = new StringBuffer();
+ while (pattern.current != null && loop) {
+ loop = parseTrunkCharacter();
+ }
+
+ if (zeroDigitCount == 0 && digitLeftCount > 0 && decimalPos >= 0) {
+ // Handle '###.###' and '###.' and '.###'
+ var n = decimalPos;
+ if (n == 0) { // Handle '.###'
+ n++;
+ }
+ digitRightCount = digitLeftCount - n;
+ digitLeftCount = n - 1;
+ zeroDigitCount = 1;
+ }
+
+ // Do syntax checking on the digits.
+ if (decimalPos < 0 && digitRightCount > 0 ||
+ decimalPos >= 0 && (decimalPos < digitLeftCount ||
+ decimalPos > digitLeftCount + zeroDigitCount) ||
+ groupingCount == 0) {
+ throw new FormatException('Malformed pattern "${pattern.input}"');
+ }
+ var totalDigits = digitLeftCount + zeroDigitCount + digitRightCount;
+
+ format._maximumFractionDigits =
+ decimalPos >= 0 ? totalDigits - decimalPos : 0;
+ if (decimalPos >= 0) {
+ format._minimumFractionDigits =
+ digitLeftCount + zeroDigitCount - decimalPos;
+ if (format._minimumFractionDigits < 0) {
+ format._minimumFractionDigits = 0;
+ }
+ }
+
+ // The effectiveDecimalPos is the position the decimal is at or would be at
+ // if there is no decimal. Note that if decimalPos<0, then digitTotalCount
+ // == digitLeftCount + zeroDigitCount.
+ var effectiveDecimalPos = decimalPos >= 0 ? decimalPos : totalDigits;
+ format._minimumIntegerDigits = effectiveDecimalPos - digitLeftCount;
+ if (format._useExponentialNotation) {
+ format._maximumIntegerDigits =
+ digitLeftCount + format._minimumIntegerDigits;
+
+ // In exponential display, we need to at least show something.
+ if (format._maximumFractionDigits == 0 &&
+ format._minimumIntegerDigits == 0) {
+ format._minimumIntegerDigits = 1;
+ }
+ }
+
+ format._groupingSize = max(0, groupingCount);
+ format._decimalSeparatorAlwaysShown = decimalPos == 0 ||
+ decimalPos == totalDigits;
+
+ return trunk.toString();
+ }
+
+ /**
+ * Parse an individual character of the trunk. Return true if we should
+ * continue to look for additional trunk characters or false if we have
+ * reached the end.
+ */
+ bool parseTrunkCharacter() {
+ var ch = pattern.current;
+ switch (ch) {
+ case _PATTERN_DIGIT:
+ if (zeroDigitCount > 0) {
+ digitRightCount++;
+ } else {
+ digitLeftCount++;
+ }
+ if (groupingCount >= 0 && decimalPos < 0) {
+ groupingCount++;
+ }
+ break;
+ case _PATTERN_ZERO_DIGIT:
+ if (digitRightCount > 0) {
+ throw new FormatException('Unexpected "0" in pattern "'
+ + pattern.input + '"');
+ }
+ zeroDigitCount++;
+ if (groupingCount >= 0 && decimalPos < 0) {
+ groupingCount++;
+ }
+ break;
+ case _PATTERN_GROUPING_SEPARATOR:
+ groupingCount = 0;
+ break;
+ case _PATTERN_DECIMAL_SEPARATOR:
+ if (decimalPos >= 0) {
+ throw new FormatException(
+ 'Multiple decimal separators in pattern "$pattern"');
+ }
+ decimalPos = digitLeftCount + zeroDigitCount + digitRightCount;
+ break;
+ case _PATTERN_EXPONENT:
+ trunk.write(ch);
+ if (format._useExponentialNotation) {
+ throw new FormatException(
+ 'Multiple exponential symbols in pattern "$pattern"');
+ }
+ format._useExponentialNotation = true;
+ format._minimumExponentDigits = 0;
+
+ // exponent pattern can have a optional '+'.
+ pattern.moveNext();
+ var nextChar = pattern.current;
+ if (nextChar == _PATTERN_PLUS) {
+ trunk.write(pattern.current);
+ pattern.moveNext();
+ format._useSignForPositiveExponent = true;
+ }
+
+ // Use lookahead to parse out the exponential part
+ // of the pattern, then jump into phase 2.
+ while (pattern.current == _PATTERN_ZERO_DIGIT) {
+ trunk.write(pattern.current);
+ pattern.moveNext();
+ format._minimumExponentDigits++;
+ }
+
+ if ((digitLeftCount + zeroDigitCount) < 1 ||
+ format._minimumExponentDigits < 1) {
+ throw new FormatException(
+ 'Malformed exponential pattern "$pattern"');
+ }
+ return false;
+ default:
+ return false;
+ }
+ trunk.write(ch);
+ pattern.moveNext();
+ return true;
+ }
+}
+
+/**
+ * Return an iterator on the string as a list of substrings.
+ */
+Iterator _iterator(String s) => new _StringIterator(s);
+
+/**
+ * Provides an iterator over a string as a list of substrings, and also
+ * gives us a lookahead of one via the [peek] method.
+ */
+class _StringIterator implements Iterator<String> {
+ String input;
+ var index = -1;
+ inBounds(i) => i >= 0 && i < input.length;
+ _StringIterator(this.input);
+ String get current => inBounds(index) ? input[index] : null;
+
+ bool moveNext() => inBounds(++index);
+ String get peek => inBounds(index + 1) ? input[index + 1] : null;
+ Iterator<String> get iterator => this;
+}
\ No newline at end of file
diff --git a/pkg/intl/lib/number_symbols.dart b/pkg/intl/lib/number_symbols.dart
index 6b2e616..f45cb2c 100644
--- a/pkg/intl/lib/number_symbols.dart
+++ b/pkg/intl/lib/number_symbols.dart
@@ -9,7 +9,6 @@
* and infinity. We expect the data for instances to be generated out of ICU
* or a similar reference source.
*/
-
class NumberSymbols {
final String NAME;
final String DECIMAL_SEP, GROUP_SEP, PERCENT, ZERO_DIGIT, PLUS_SIGN,
diff --git a/pkg/intl/lib/number_symbols_data.dart b/pkg/intl/lib/number_symbols_data.dart
index 1c11791..bb6ea5d 100644
--- a/pkg/intl/lib/number_symbols_data.dart
+++ b/pkg/intl/lib/number_symbols_data.dart
@@ -36,24 +36,24 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'ZAR'),
/**
* Number formatting symbols for locale am.
*/
"am" : const NumberSymbols(
NAME: "am",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '000\u12AA\u1263',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
@@ -72,7 +72,7 @@
EXP_SYMBOL: '\u0627\u0633',
PERMILL: '\u0609',
INFINITY: '\u221E',
- NAN: '\u0644\u064A\u0633 \u0631\u0642\u0645',
+ NAN: '\u0644\u064A\u0633\u00A0\u0631\u0642\u0645',
DECIMAL_PATTERN: '#0.###;#0.###-',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
@@ -89,7 +89,7 @@
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
+ EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
@@ -112,7 +112,7 @@
EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u09B8\u0982\u0996\u09CD\u09AF\u09BE \u09A8\u09BE',
+ NAN: '\u09B8\u0982\u0996\u09CD\u09AF\u09BE\u00A0\u09A8\u09BE',
DECIMAL_PATTERN: '#,##,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##,##0%',
@@ -136,7 +136,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale cs.
@@ -254,7 +254,7 @@
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
- SCIENTIFIC_PATTERN: '#E0',
+ SCIENTIFIC_PATTERN: '[#E0]',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
DEF_CURRENCY_CODE: 'EUR'),
@@ -453,7 +453,7 @@
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00',
@@ -476,7 +476,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '#0.00\u00A4;(#0.00\u00A4)',
DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale eu.
@@ -495,8 +495,8 @@
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ PERCENT_PATTERN: '%\u00A0#,##0',
+ CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4;(#,##0.00\u00A0\u00A4)',
DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale fa.
@@ -512,11 +512,11 @@
EXP_SYMBOL: '\u00D7\u06F1\u06F0^',
PERMILL: '\u0609',
INFINITY: '\u221E',
- NAN: 'NaN',
+ NAN: '\u0646\u0627\u0639\u062F\u062F',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4;\u2212#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u200E\u00A4#,##0.00;\u200E(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'IRR'),
/**
* Number formatting symbols for locale fi.
@@ -553,10 +553,10 @@
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0.0B',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4\u00A0#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'PHP'),
/**
* Number formatting symbols for locale fr.
@@ -576,7 +576,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0\u00A0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4;(#,##0.00\u00A0\u00A4)',
DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale fr_CA.
@@ -593,7 +593,7 @@
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0.0B',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0\u00A0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4;(#,##0.00\u00A0\u00A4)',
@@ -616,7 +616,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale gsw.
@@ -643,20 +643,20 @@
*/
"gu" : const NumberSymbols(
NAME: "gu",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0AAA\u0AC2\u0AB0\u0ACD\u0AB5',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u0AB8\u0A82\u0A96\u0ACD\u0AAF\u0ABE \u0AA8\u0AA5\u0AC0\u0A82',
- DECIMAL_PATTERN: '#,##,##0.###',
+ NAN: 'NaN',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##,##0%',
- CURRENCY_PATTERN: '\u00A4\u00A0#,##,##0.00',
+ PERCENT_PATTERN: '#,##0%',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'INR'),
/**
* Number formatting symbols for locale he.
@@ -705,15 +705,15 @@
NAME: "hr",
DECIMAL_SEP: ',',
GROUP_SEP: '.',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
@@ -745,15 +745,15 @@
NAME: "id",
DECIMAL_SEP: ',',
GROUP_SEP: '.',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00',
@@ -765,15 +765,15 @@
NAME: "in",
DECIMAL_SEP: ',',
GROUP_SEP: '.',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00',
@@ -788,15 +788,15 @@
PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
- MINUS_SIGN: '\u2212',
- EXP_SYMBOL: '\u00D710^',
+ MINUS_SIGN: '-',
+ EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: 'EiTa',
+ NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'ISK'),
/**
* Number formatting symbols for locale it.
@@ -809,7 +809,7 @@
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
+ EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
@@ -845,14 +845,14 @@
NAME: "ja",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: 'NaN\uFF08\u975E\u6570\uFF09',
+ NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
@@ -863,20 +863,20 @@
*/
"kn" : const NumberSymbols(
NAME: "kn",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0CAA\u0CC2\u0CB0\u0CCD\u0CB5',
- PERMILL: '\u0609',
+ EXP_SYMBOL: '\u0C88',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6\u0CAF\u0CB2\u0CCD\u0CB2',
- DECIMAL_PATTERN: '#,##,##0.###',
+ NAN: 'NaN',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##,##0%',
- CURRENCY_PATTERN: '\u00A4\u00A0#,##,##0.00',
+ PERCENT_PATTERN: '#,##0%',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'INR'),
/**
* Number formatting symbols for locale ko.
@@ -896,7 +896,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'KRW'),
/**
* Number formatting symbols for locale ln.
@@ -905,12 +905,12 @@
NAME: "ln",
DECIMAL_SEP: ',',
GROUP_SEP: '.',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
@@ -923,19 +923,19 @@
*/
"lt" : const NumberSymbols(
NAME: "lt",
- DECIMAL_SEP: '.',
- GROUP_SEP: ',',
+ DECIMAL_SEP: ',',
+ GROUP_SEP: '\u00A0',
PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
- MINUS_SIGN: '\u2212',
- EXP_SYMBOL: '\u00D710^',
+ MINUS_SIGN: '\u2013',
+ EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u00A4\u00A4\u00A4',
+ NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##0\u00A0%',
+ PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
DEF_CURRENCY_CODE: 'LTL'),
/**
@@ -948,7 +948,7 @@
PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
- MINUS_SIGN: '\u2212',
+ MINUS_SIGN: '-',
EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
@@ -956,7 +956,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'LVL'),
/**
* Number formatting symbols for locale ml.
@@ -983,37 +983,37 @@
*/
"mr" : const NumberSymbols(
NAME: "mr",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u092A\u0942',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u0928\u093E\u0928',
- DECIMAL_PATTERN: '#,##,##0.###',
+ NAN: 'NaN',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##,##0%',
- CURRENCY_PATTERN: '\u00A4\u00A0#,##,##0.00',
+ PERCENT_PATTERN: '#,##0%',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'INR'),
/**
* Number formatting symbols for locale ms.
*/
"ms" : const NumberSymbols(
NAME: "ms",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0.0B',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
@@ -1025,19 +1025,19 @@
NAME: "mt",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00',
- DEF_CURRENCY_CODE: 'MTL'),
+ DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale nl.
*/
@@ -1085,12 +1085,12 @@
NAME: "or",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##,##0.###',
@@ -1116,7 +1116,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4;(#,##0.00\u00A0\u00A4)',
DEF_CURRENCY_CODE: 'PLN'),
/**
* Number formatting symbols for locale pt.
@@ -1173,7 +1173,7 @@
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
@@ -1195,7 +1195,7 @@
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##0%',
+ PERCENT_PATTERN: '#,##0\u00A0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
DEF_CURRENCY_CODE: 'RON'),
/**
@@ -1212,7 +1212,7 @@
EXP_SYMBOL: 'E',
PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u043D\u0435 \u0447\u0438\u0441\u043B\u043E',
+ NAN: '\u043D\u0435\u00A0\u0447\u0438\u0441\u043B\u043E',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0\u00A0%',
@@ -1225,19 +1225,19 @@
NAME: "sk",
DECIMAL_SEP: ',',
GROUP_SEP: '\u00A0',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0.0\u00A0tis\'.\'',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0\u00A0%',
CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
- DEF_CURRENCY_CODE: 'SKK'),
+ DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale sl.
*/
@@ -1256,7 +1256,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'EUR'),
/**
* Number formatting symbols for locale sq.
@@ -1264,13 +1264,13 @@
"sq" : const NumberSymbols(
NAME: "sq",
DECIMAL_SEP: ',',
- GROUP_SEP: '.',
- PERCENT: '\u066A',
+ GROUP_SEP: '\u00A0',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
@@ -1323,20 +1323,20 @@
*/
"sw" : const NumberSymbols(
NAME: "sw",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: 'M0.0',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'TZS'),
/**
* Number formatting symbols for locale ta.
@@ -1345,14 +1345,14 @@
NAME: "ta",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u0B8E\u0BA3\u0BCD \u0B87\u0BB2\u0BCD\u0BB2\u0BC8',
+ NAN: 'NaN',
DECIMAL_PATTERN: '#,##,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##,##0%',
@@ -1363,20 +1363,20 @@
*/
"te" : const NumberSymbols(
NAME: "te",
- DECIMAL_SEP: '\u066B',
- GROUP_SEP: '\u066C',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0C24\u0C42',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '#,##,##0.###',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
- PERCENT_PATTERN: '#,##,##0%',
- CURRENCY_PATTERN: '\u00A4\u00A0#,##,##0.00',
+ PERCENT_PATTERN: '#,##0%',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'INR'),
/**
* Number formatting symbols for locale th.
@@ -1396,7 +1396,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4#,##0.00;\u00A4-#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'THB'),
/**
* Number formatting symbols for locale tl.
@@ -1413,10 +1413,10 @@
PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
- DECIMAL_PATTERN: '0.0B',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4\u00A0#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'PHP'),
/**
* Number formatting symbols for locale tr.
@@ -1436,7 +1436,7 @@
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '%#,##0',
- CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4',
+ CURRENCY_PATTERN: '#,##0.00\u00A0\u00A4;(#,##0.00\u00A0\u00A4)',
DEF_CURRENCY_CODE: 'TRY'),
/**
* Number formatting symbols for locale uk.
@@ -1452,7 +1452,7 @@
EXP_SYMBOL: '\u0415',
PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: '\u041D\u0435 \u0447\u0438\u0441\u043B\u043E',
+ NAN: '\u041D\u0435\u00A0\u0447\u0438\u0441\u043B\u043E',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
@@ -1505,18 +1505,18 @@
NAME: "zh",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'CNY'),
/**
* Number formatting symbols for locale zh_CN.
@@ -1525,18 +1525,18 @@
NAME: "zh_CN",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: 'NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'CNY'),
/**
* Number formatting symbols for locale zh_HK.
@@ -1545,15 +1545,15 @@
NAME: "zh_HK",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: '\u975E\u6578\u503C',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
@@ -1565,15 +1565,15 @@
NAME: "zh_TW",
DECIMAL_SEP: '.',
GROUP_SEP: ',',
- PERCENT: '\u066A',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
NAN: '\u975E\u6578\u503C',
- DECIMAL_PATTERN: '0000',
+ DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
CURRENCY_PATTERN: '\u00A4#,##0.00',
@@ -1583,19 +1583,19 @@
*/
"zu" : const NumberSymbols(
NAME: "zu",
- DECIMAL_SEP: ',',
- GROUP_SEP: '\u00A0',
- PERCENT: '\u066A',
+ DECIMAL_SEP: '.',
+ GROUP_SEP: ',',
+ PERCENT: '%',
ZERO_DIGIT: '0',
PLUS_SIGN: '+',
MINUS_SIGN: '-',
- EXP_SYMBOL: '\u0627\u0633',
- PERMILL: '\u0609',
+ EXP_SYMBOL: 'E',
+ PERMILL: '\u2030',
INFINITY: '\u221E',
- NAN: 'NaN',
+ NAN: 'I-NaN',
DECIMAL_PATTERN: '#,##0.###',
SCIENTIFIC_PATTERN: '#E0',
PERCENT_PATTERN: '#,##0%',
- CURRENCY_PATTERN: '\u00A4#,##0.00',
+ CURRENCY_PATTERN: '\u00A4#,##0.00;(\u00A4#,##0.00)',
DEF_CURRENCY_CODE: 'ZAR')
};
\ No newline at end of file
diff --git a/pkg/intl/test/date_time_format_file_even_test.dart b/pkg/intl/test/date_time_format_file_even_test.dart
index ca9daee..1fdebe5 100644
--- a/pkg/intl/test/date_time_format_file_even_test.dart
+++ b/pkg/intl/test/date_time_format_file_even_test.dart
@@ -9,9 +9,10 @@
*/
library date_time_format_file_test_2;
-import 'date_time_format_file_test_stub.dart';
-import 'date_time_format_test_core.dart';
+import 'date_time_format_test_stub.dart';
+import 'data_directory.dart';
+import 'package:intl/date_symbol_data_file.dart';
main() {
- runWith(evenLocales);
+ runWith(evenLocales, dataDirectory, initializeDateFormatting);
}
diff --git a/pkg/intl/test/date_time_format_file_odd_test.dart b/pkg/intl/test/date_time_format_file_odd_test.dart
index fbf05bd..acc9c4c 100644
--- a/pkg/intl/test/date_time_format_file_odd_test.dart
+++ b/pkg/intl/test/date_time_format_file_odd_test.dart
@@ -9,9 +9,10 @@
*/
library date_time_format_file_test_1;
-import 'date_time_format_file_test_stub.dart';
-import 'date_time_format_test_core.dart';
+import 'date_time_format_test_stub.dart';
+import 'data_directory.dart';
+import 'package:intl/date_symbol_data_file.dart';
main() {
- runWith(oddLocales);
+ runWith(oddLocales, dataDirectory, initializeDateFormatting);
}
diff --git a/pkg/intl/test/date_time_format_file_test_stub.dart b/pkg/intl/test/date_time_format_file_test_stub.dart
deleted file mode 100644
index e3868c8..0000000
--- a/pkg/intl/test/date_time_format_file_test_stub.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * Tests date formatting and parsing using locale data read from the
- * local file system.
- */
-library date_time_format_file_test;
-
-import 'dart:async';
-import 'package:intl/intl.dart';
-import 'package:intl/date_symbol_data_file.dart';
-import 'dart:io';
-import 'date_time_format_test_core.dart';
-import 'data_directory.dart';
-import 'package:unittest/unittest.dart';
-
-runWith([Function getSubset]) {
- // Initialize one locale just so we know what the list is.
- test('Run all date formatting tests with locales from files', () {
- initializeDateFormatting("en_US", dataDirectory).then(
- expectAsync1((_) => runEverything(getSubset)));
- });
-}
-
-void runEverything(Function getSubset) {
- // Initialize all locales sequentially before running tests. Be sure not
- // to do it in parallel or we can run into ulimit problems on fast machines.
- var futureList = Future.forEach(DateFormat.allLocalesWithSymbols(),
- (locale) => initializeDateFormatting(locale, dataDirectory));
-
- test('Run all date formatting tests nested test', () {
- futureList.then(
- expectAsync1((results) => runDateTests(getSubset())));
- });
-}
diff --git a/pkg/intl/test/date_time_format_http_request_test.dart b/pkg/intl/test/date_time_format_http_request_test.dart
index 65bc87b..d36ac2b 100644
--- a/pkg/intl/test/date_time_format_http_request_test.dart
+++ b/pkg/intl/test/date_time_format_http_request_test.dart
@@ -9,30 +9,15 @@
library date_time_format_http_request_test;
-import 'dart:async';
-import 'package:intl/intl.dart';
-import 'package:intl/date_symbol_data_http_request.dart';
-import 'date_time_format_test_core.dart';
import 'dart:html';
-import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
-
-var url = '';
+import 'package:intl/date_symbol_data_http_request.dart';
+import 'date_time_format_test_stub.dart';
main() {
useHtmlConfiguration();
- url = "http://localhost:${window.location.port}/root_dart/pkg/intl/lib/src/data/dates/";
- // Initialize one locale just so we know what the list is.
- test('Run everything', () {
- initializeDateFormatting("en_US", url).then(expectAsync1(runEverything));});
-}
+ var url = "http://localhost:${window.location.port}"
+ "/root_dart/pkg/intl/lib/src/data/dates/";
-void runEverything(_) {
- // Initialize all locales and wait for them to finish before running tests.
- var futures = DateFormat.allLocalesWithSymbols()
- .map((locale) => initializeDateFormatting(locale, url))
- .toList();
- Future.wait(futures).then(expectAsync1((_) {
- runDateTests(smallSetOfLocales());
- }));
+ runWith(smallSetOfLocales, url, initializeDateFormatting);
}
diff --git a/pkg/intl/test/date_time_format_local_even_test.dart b/pkg/intl/test/date_time_format_local_even_test.dart
index 3516cda..e21f01e 100644
--- a/pkg/intl/test/date_time_format_local_even_test.dart
+++ b/pkg/intl/test/date_time_format_local_even_test.dart
@@ -10,9 +10,9 @@
*/
library date_time_format_test_2;
-import 'date_time_format_local_test_stub.dart';
-import 'date_time_format_test_core.dart';
+import 'date_time_format_test_stub.dart';
+import 'package:intl/date_symbol_data_local.dart';
main() {
- runWith(evenLocales);
+ runWith(evenLocales, null, initializeDateFormatting);
}
diff --git a/pkg/intl/test/date_time_format_local_odd_test.dart b/pkg/intl/test/date_time_format_local_odd_test.dart
index ef55b44..229cbdb 100644
--- a/pkg/intl/test/date_time_format_local_odd_test.dart
+++ b/pkg/intl/test/date_time_format_local_odd_test.dart
@@ -10,9 +10,9 @@
*/
library date_time_format_test_1;
-import 'date_time_format_local_test_stub.dart';
-import 'date_time_format_test_core.dart';
+import 'date_time_format_test_stub.dart';
+import 'package:intl/date_symbol_data_local.dart';
main() {
- runWith(oddLocales);
+ runWith(oddLocales, null, initializeDateFormatting);
}
diff --git a/pkg/intl/test/date_time_format_local_test_stub.dart b/pkg/intl/test/date_time_format_local_test_stub.dart
deleted file mode 100644
index 1b9bfc2..0000000
--- a/pkg/intl/test/date_time_format_local_test_stub.dart
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * Test date formatting and parsing using locale data which is available
- * directly in the program as a constant.
- */
-
-library date_time_format_test;
-
-import 'dart:async';
-import 'package:intl/intl.dart';
-import 'package:intl/date_time_patterns.dart';
-import 'package:intl/date_symbol_data_local.dart';
-import 'date_time_format_test_core.dart';
-
-runWith([Function getSubset]) {
- // Initialize one locale just so we know what the list is.
- // Also, note that we take the list of locales as a function so that we don't
- // evaluate it until after we know that all the locales are available.
- initializeDateFormatting("en_US",null).then(
- (_) => runEverything(getSubset));
-}
-
-void runEverything(Function getSubset) {
- // Initialize all locales and wait for them to finish before running tests.
- var futures = DateFormat.allLocalesWithSymbols()
- .map((locale) => initializeDateFormatting(locale, null))
- .toList();
- Future.wait(futures).then((results) => runDateTests(getSubset()));
-}
diff --git a/pkg/intl/test/date_time_format_test_core.dart b/pkg/intl/test/date_time_format_test_core.dart
index ff880f8..a4fb30d 100644
--- a/pkg/intl/test/date_time_format_test_core.dart
+++ b/pkg/intl/test/date_time_format_test_core.dart
@@ -171,35 +171,24 @@
/** A shortcut for returning all the locales we have available.*/
List<String> allLocales() => DateFormat.allLocalesWithSymbols();
-/**
- * Return only the odd-numbered locales. A simple way to divide the list into
- * two roughly equal parts.
- */
-List oddLocales() {
- int i = 1;
- return allLocales().where((x) => (i++).isOdd).toList();
-}
+Function _subsetFunc;
-/**
- * Return a set of a few locales to run just the tests on a small sample.
- */
-List smallSetOfLocales() {
- return allLocales().sublist(0,10);
-}
+List<String> _subsetValue;
-/**
- * Return only the even-numbered locales. A simple way to divide the list into
- * two roughly equal parts.
- */
-List evenLocales() {
- int i = 1;
- return allLocales().where((x) => !((i++).isOdd)).toList();
+List<String> get subset {
+ if(_subsetValue == null) {
+ _subsetValue = _subsetFunc();
+ }
+ return _subsetValue;
}
// TODO(alanknight): Run specific tests for the en_ISO locale which isn't
// included in CLDR, and check that our patterns for it are correct (they
// very likely aren't).
-runDateTests([List<String> subset]) {
+void runDateTests(Function subsetFunc) {
+ assert(subsetFunc != null);
+ _subsetFunc = subsetFunc;
+
test('Multiple patterns', () {
var date = new DateTime.now();
var multiple1 = new DateFormat.yMd().add_jms();
@@ -244,8 +233,7 @@
test('Test round-trip parsing of dates', () {
var hours = [0, 1, 11, 12, 13, 23];
var months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
- var locales = subset == null ? allLocales() : subset;
- for (var locale in locales) {
+ for (var locale in subset) {
for (var month in months) {
var aDate = new DateTime(2012, month, 27, 13, 58, 59, 012);
testRoundTripParsing(locale, aDate);
diff --git a/pkg/intl/test/date_time_format_test_stub.dart b/pkg/intl/test/date_time_format_test_stub.dart
new file mode 100644
index 0000000..1aa1577
--- /dev/null
+++ b/pkg/intl/test/date_time_format_test_stub.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * Test date formatting and parsing using locale data which is available
+ * directly in the program as a constant.
+ */
+
+library date_time_format_test;
+
+import 'dart:async';
+import 'package:unittest/unittest.dart';
+import 'package:intl/intl.dart';
+import 'date_time_format_test_core.dart';
+
+typedef List<String> TestListFunc();
+
+typedef Future InitializeDateFormattingFunc(String locale, String filePath);
+
+/**
+ * Return only the odd-numbered locales. A simple way to divide the list into
+ * two roughly equal parts.
+ */
+List<String> oddLocales() {
+ int i = 1;
+ return allLocales().where((x) => (i++).isOdd).toList();
+}
+
+/**
+ * Return a set of a few locales to run just the tests on a small sample.
+ */
+List smallSetOfLocales() {
+ return allLocales().sublist(0,10);
+}
+
+/**
+ * Return only the even-numbered locales. A simple way to divide the list into
+ * two roughly equal parts.
+ */
+List<String> evenLocales() {
+ int i = 1;
+ return allLocales().where((x) => !((i++).isOdd)).toList();
+}
+
+void runWith(TestListFunc getSubset, String dir,
+ InitializeDateFormattingFunc initFunction) {
+ // Initialize one locale just so we know what the list is.
+ // Also, note that we take the list of locales as a function so that we don't
+ // evaluate it until after we know that all the locales are available.
+
+ bool initialized = false;
+
+ setUp(() {
+ if(initialized) {
+ return;
+ }
+ return initFunction("en_US", dir)
+ .then((_) {
+ return Future.forEach(DateFormat.allLocalesWithSymbols(), (locale) {
+ return initFunction(locale, dir);
+ });
+ })
+ .then((_) {
+ initialized = true;
+ });
+ });
+
+ runDateTests(getSubset);
+}
diff --git a/pkg/intl/test/date_time_format_uninitialized_test.dart b/pkg/intl/test/date_time_format_uninitialized_test.dart
index dcd97cd..d460c47 100644
--- a/pkg/intl/test/date_time_format_uninitialized_test.dart
+++ b/pkg/intl/test/date_time_format_uninitialized_test.dart
@@ -8,11 +8,8 @@
*/
library date_time_format_file_test;
-import 'package:intl/intl.dart';
-import 'package:intl/date_symbol_data_local.dart';
import 'date_time_format_test_core.dart';
-import 'package:unittest/unittest.dart';
main() {
- runDateTests(['en_US']);
+ runDateTests(() => ['en_US']);
}
diff --git a/pkg/intl/test/number_closure_test.dart b/pkg/intl/test/number_closure_test.dart
new file mode 100644
index 0000000..8574e08
--- /dev/null
+++ b/pkg/intl/test/number_closure_test.dart
@@ -0,0 +1,388 @@
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * Tests based on the closure number formatting tests.
+ */
+library number_closure_test;
+
+import "package:intl/intl.dart";
+import "package:unittest/unittest.dart";
+
+main() {
+ test("testVeryBigNumber", testVeryBigNumber);
+ test("testStandardFormat", testStandardFormat);
+ test("testNegativePercentage", testNegativePercentage);
+ test("testCustomPercentage", testCustomPercentage);
+ test("testBasicFormat", testBasicFormat);
+ test("testGrouping", testGrouping);
+ test("testPerMill", testPerMill);
+ test("testQuotes", testQuotes);
+ test("testZeros", testZeros);
+ test("testExponential", testExponential);
+ test("testPlusSignInExponentPart", testPlusSignInExponentPart);
+ test("testApis", testApis);
+ test("testLocaleSwitch", testLocaleSwitch);
+}
+
+/**
+ * Test two large numbers for equality, assuming that there may be some
+ * loss of precision in the less significant digits.
+ */
+veryBigNumberCompare(str1, str2) {
+ return str1.length == str2.length &&
+ str1.substring(0, 8) == str2.substring(0, 8);
+}
+
+testVeryBigNumber() {
+ var str;
+ var fmt;
+
+ fmt = new NumberFormat.decimalPattern();
+ str = fmt.format(1.3456E20);
+ expect(veryBigNumberCompare('134,559,999,999,999,000,000', str), isTrue);
+
+ fmt = new NumberFormat.percentPattern();
+ str = fmt.format(1.3456E20);
+ expect(veryBigNumberCompare('13,456,000,000,000,000,000,000%', str), isTrue);
+
+ // TODO(alanknight): Note that this disagrees with what ICU would print
+ // for this. We need significant digit support to do this properly.
+ fmt = new NumberFormat.scientificPattern();
+ str = fmt.format(1.3456E20);
+ expect('1E20', str);
+
+ fmt = new NumberFormat.decimalPattern();
+ str = fmt.format(-1.234567890123456e306);
+ expect(1 + 1 + 306 + 306 / 3, str.length);
+ expect('-1,234,567,890,123,45', str.substring(0, 21));
+
+ str = fmt.format(1 / 0);
+ expect('∞', str);
+ str = fmt.format(-1 / 0);
+ expect('-∞', str);
+}
+
+void testStandardFormat() {
+ var str;
+ var fmt;
+ fmt = new NumberFormat.decimalPattern();
+ str = fmt.format(1234.579);
+ expect('1,234.579', str);
+ fmt = new NumberFormat.percentPattern();
+ str = fmt.format(1234.579);
+ expect('123,458%', str);
+ fmt = new NumberFormat.scientificPattern();
+ str = fmt.format(1234.579);
+ expect('1E3', str);
+}
+
+void testNegativePercentage() {
+ var str;
+ var fmt = new NumberFormat('#,##0.00%');
+ str = fmt.format(-1234.56);
+ expect('-123,456.00%', str);
+
+ fmt = new NumberFormat.percentPattern();
+ str = fmt.format(-1234.579);
+ expect('-123,458%', str);
+}
+
+void testCustomPercentage() {
+ var fmt = new NumberFormat.percentPattern();
+ fmt.setMaximumFractionDigits(1);
+ fmt.setMinimumFractionDigits(1);
+ var str = fmt.format(0.1291);
+ expect('12.9%', str);
+ fmt.setMaximumFractionDigits(2);
+ fmt.setMinimumFractionDigits(1);
+ str = fmt.format(0.129);
+ expect('12.9%', str);
+ fmt.setMaximumFractionDigits(2);
+ fmt.setMinimumFractionDigits(1);
+ str = fmt.format(0.12);
+ expect('12.0%', str);
+ fmt.setMaximumFractionDigits(2);
+ fmt.setMinimumFractionDigits(1);
+ str = fmt.format(0.12911);
+ expect('12.91%', str);
+}
+
+void testBasicFormat() {
+ var fmt = new NumberFormat('0.0000');
+ var str = fmt.format(123.45789179565757);
+ expect('123.4579', str);
+}
+
+void testGrouping() {
+ var str;
+
+ var fmt = new NumberFormat('#,###');
+ str = fmt.format(1234567890);
+ expect('1,234,567,890', str);
+ fmt = new NumberFormat('#,####');
+ str = fmt.format(1234567890);
+ expect('12,3456,7890', str);
+
+ fmt = new NumberFormat('#');
+ str = fmt.format(1234567890);
+ expect('1234567890', str);
+}
+
+void testPerMill() {
+ var str;
+
+ var fmt = new NumberFormat('###.###\u2030');
+ str = fmt.format(0.4857);
+ expect('485.7\u2030', str);
+}
+
+void testQuotes() {
+ var str;
+
+ var fmt = new NumberFormat('a\'fo\'\'o\'b#');
+ str = fmt.format(123);
+ expect('afo\'ob123', str);
+
+ fmt = new NumberFormat('a\'\'b#');
+ str = fmt.format(123);
+ expect('a\'b123', str);
+
+ fmt = new NumberFormat('a\'fo\'\'o\'b#');
+ str = fmt.format(-123);
+ expect('afo\'ob-123', str);
+
+ fmt = new NumberFormat('a\'\'b#');
+ str = fmt.format(-123);
+ expect('a\'b-123', str);
+}
+
+void testZeros() {
+ var str;
+ var fmt;
+
+ fmt = new NumberFormat('#.#');
+ str = fmt.format(0);
+ expect('0', str);
+ fmt = new NumberFormat('#.');
+ str = fmt.format(0);
+ expect('0.', str);
+ fmt = new NumberFormat('.#');
+ str = fmt.format(0);
+ expect('.0', str);
+ fmt = new NumberFormat('#');
+ str = fmt.format(0);
+ expect('0', str);
+
+ fmt = new NumberFormat('#0.#');
+ str = fmt.format(0);
+ expect('0', str);
+ fmt = new NumberFormat('#0.');
+ str = fmt.format(0);
+ expect('0.', str);
+ fmt = new NumberFormat('#.0');
+ str = fmt.format(0);
+ expect('.0', str);
+ fmt = new NumberFormat('#');
+ str = fmt.format(0);
+ expect('0', str);
+ fmt = new NumberFormat('000');
+ str = fmt.format(0);
+ expect('000', str);
+}
+
+void testExponential() {
+ var str;
+ var fmt;
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(0.01234);
+ expect('1.234E-2', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(0.01234);
+ expect('12.340E-03', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(0.01234);
+ expect('12.34E-003', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(0.01234);
+ expect('1.234E-2', str);
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(123456789);
+ expect('1.2346E8', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(123456789);
+ expect('12.346E07', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(123456789);
+ expect('123.456789E006', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(123456789);
+ expect('1.235E8', str);
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(1.23e300);
+ expect('1.23E300', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(1.23e300);
+ expect('12.300E299', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(1.23e300);
+ expect('1.23E300', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(1.23e300);
+ expect('1.23E300', str);
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(-3.141592653e-271);
+ expect('-3.1416E-271', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(-3.141592653e-271);
+ expect('-31.416E-272', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(-3.141592653e-271);
+ expect('-314.159265E-273', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(-3.141592653e-271);
+ expect('[3.142E-271]', str);
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(0);
+ expect('0E0', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(0);
+ expect('00.000E00', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(0);
+ expect('0E000', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(0);
+ expect('0E0', str);
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(-1);
+ expect('-1E0', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(-1);
+ expect('-10.000E-01', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(-1);
+ expect('-1E000', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(-1);
+ expect('[1E0]', str);
+
+ fmt = new NumberFormat('0.####E0');
+ str = fmt.format(1);
+ expect('1E0', str);
+ fmt = new NumberFormat('00.000E00');
+ str = fmt.format(1);
+ expect('10.000E-01', str);
+ fmt = new NumberFormat('##0.######E000');
+ str = fmt.format(1);
+ expect('1E000', str);
+ fmt = new NumberFormat('0.###E0;[0.###E0]');
+ str = fmt.format(1);
+ expect('1E0', str);
+
+ fmt = new NumberFormat('#E0');
+ str = fmt.format(12345.0);
+ expect('1E4', str);
+ fmt = new NumberFormat('0E0');
+ str = fmt.format(12345.0);
+ expect('1E4', str);
+ fmt = new NumberFormat('##0.###E0');
+ str = fmt.format(12345.0);
+ expect('12.345E3', str);
+ fmt = new NumberFormat('##0.###E0');
+ str = fmt.format(12345.00001);
+ expect('12.345E3', str);
+ fmt = new NumberFormat('##0.###E0');
+ str = fmt.format(12345);
+ expect('12.345E3', str);
+
+ fmt = new NumberFormat('##0.####E0');
+ str = fmt.format(789.12345e-9);
+ fmt = new NumberFormat('##0.####E0');
+ str = fmt.format(780e-9);
+ expect('780E-9', str);
+ fmt = new NumberFormat('.###E0');
+ str = fmt.format(45678.0);
+ expect('.457E5', str);
+ fmt = new NumberFormat('.###E0');
+ str = fmt.format(0);
+ expect('.0E0', str);
+
+ fmt = new NumberFormat('#E0');
+ str = fmt.format(45678000);
+ expect('5E7', str);
+ fmt = new NumberFormat('##E0');
+ str = fmt.format(45678000);
+ expect('46E6', str);
+ fmt = new NumberFormat('####E0');
+ str = fmt.format(45678000);
+ expect('4568E4', str);
+ fmt = new NumberFormat('0E0');
+ str = fmt.format(45678000);
+ expect('5E7', str);
+ fmt = new NumberFormat('00E0');
+ str = fmt.format(45678000);
+ expect('46E6', str);
+ fmt = new NumberFormat('000E0');
+ str = fmt.format(45678000);
+ expect('457E5', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(0.0000123);
+ expect('12E-6', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(0.000123);
+ expect('123E-6', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(0.00123);
+ expect('1E-3', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(0.0123);
+ expect('12E-3', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(0.123);
+ expect('123E-3', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(1.23);
+ expect('1E0', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(12.3);
+ expect('12E0', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(123.0);
+ expect('123E0', str);
+ fmt = new NumberFormat('###E0');
+ str = fmt.format(1230.0);
+ expect('1E3', str);
+}
+
+void testPlusSignInExponentPart() {
+ var fmt;
+ fmt = new NumberFormat('0E+0');
+ var str = fmt.format(45678000);
+ expect('5E+7', str);
+}
+
+void testApis() {
+ var fmt;
+ var str;
+
+ fmt = new NumberFormat('#,###');
+ str = fmt.format(1234567890);
+ expect('1,234,567,890', str);
+}
+
+testLocaleSwitch() {
+ Intl.withLocale("fr", verifyFrenchLocale);
+}
+
+void verifyFrenchLocale() {
+ var fmt = new NumberFormat('#,###');
+ var str = fmt.format(1234567890);
+ expect('1\u00a0234\u00a0567\u00a0890', str);
+}
diff --git a/pkg/intl/test/number_format_test.dart b/pkg/intl/test/number_format_test.dart
index 048d6ad..2306470 100644
--- a/pkg/intl/test/number_format_test.dart
+++ b/pkg/intl/test/number_format_test.dart
@@ -7,13 +7,16 @@
library number_format_test;
import 'package:unittest/unittest.dart';
-import 'package:intl/number_format.dart';
+import 'package:intl/number_symbols.dart';
+import 'package:intl/number_symbols_data.dart';
import 'package:intl/intl.dart';
+import 'number_test_data.dart';
+import 'dart:math';
/**
* Tests the Numeric formatting library in dart.
*/
-var testNumbers = const {
+var testNumbers = {
"0.001": 0.001,
"0.01": 0.01,
"0.1": 0.1,
@@ -23,21 +26,59 @@
"100": 100,
"1,000": 1000,
"2,000,000,000,000": 2000000000000,
- "10,000,000,000,000,000,000,000,000,000,000":
- 10000000000000000000000000000000,
"0.123": 0.123,
"1,234": 1234.0,
"1.234": 1.234,
"1.23": 1.230,
- "NaN": 0/0,
- "∞": 1/0,
- "-∞": -1/0};
+ "NaN": double.NAN,
+ "∞": double.INFINITY,
+ "-∞": double.NEGATIVE_INFINITY,
+ "3.142": PI};
+
+var testExponential = const {
+ "1E-3" : 0.001,
+ "1E-2": 0.01,
+ "1.23E0" : 1.23
+ };
+
+// TODO(alanknight): Test against currency, which requires generating data
+// for the three different forms that this now supports.
+// TODO(alanknight): Test against scientific, which requires significant
+// digit support.
+List<NumberFormat> standardFormats(String locale) {
+ return [
+ new NumberFormat.decimalPattern(locale),
+ new NumberFormat.percentPattern(locale)
+ ];
+}
+
+inJavaScript() => 1 is double;
main() {
- test('Basic number printing', () {
- var number = new NumberFormat();
- expect(number.format(3.14),"3.14");
- });
+ if (!inJavaScript()) {
+ testNumbers["10,000,000,000,000,000,000,000,000,000,000"] =
+ 10000000000000000000000000000000;
+ }
+
+ // For data from a list of locales, run each locale's data as a separate
+ // test so we can see exactly which ones pass or fail.
+ var mainList = numberTestData;
+ var sortedLocales = new List.from(numberFormatSymbols.keys);
+ sortedLocales.sort((a, b) => a.compareTo(b));
+ for (var locale in sortedLocales) {
+ var testFormats = standardFormats(locale);
+ var list = mainList.take(testFormats.length + 1).iterator;
+ mainList = mainList.skip(testFormats.length + 1);
+ var nextLocaleFromList = (list..moveNext()).current;
+ test("Test against ICU data for $locale", () {
+ expect(locale, nextLocaleFromList);
+ for (var format in testFormats) {
+ var formatted = format.format(123);
+ var expected = (list..moveNext()).current;
+ expect(formatted, expected);
+ }
+ });
+ }
test('Simple set of numbers', () {
var number = new NumberFormat();
@@ -46,4 +87,12 @@
expect(formatted, x);
}
});
-}
+
+ test('Exponential form', () {
+ var number = new NumberFormat("#.###E0");
+ for (var x in testExponential.keys) {
+ var formatted = number.format(testExponential[x]);
+ expect(formatted, x);
+ }
+ });
+}
\ No newline at end of file
diff --git a/pkg/intl/test/number_test_data.dart b/pkg/intl/test/number_test_data.dart
new file mode 100644
index 0000000..4d780bf
--- /dev/null
+++ b/pkg/intl/test/number_test_data.dart
@@ -0,0 +1,252 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * Test data for numeric formatting from a large set of locales.
+ *
+ * DO NOT EDIT. This file is autogenerated from ICU data.
+ * File generated from CLDR ver. 22.1
+ */
+
+library number_test_data;
+
+var numberTestData = const [
+ "af",
+ r"123",
+ r"12 300%",
+ "am",
+ r"123",
+ r"12,300%",
+ "ar",
+ r"١٢٣",
+ r"١٢٬٣٠٠٪",
+ "bg",
+ r"123",
+ r"12 300%",
+ "bn",
+ r"১২৩",
+ r"১২,৩০০%",
+ "ca",
+ r"123",
+ r"12.300%",
+ "cs",
+ r"123",
+ r"12 300 %",
+ "da",
+ r"123",
+ r"12.300 %",
+ "de",
+ r"123",
+ r"12.300 %",
+ "de_AT",
+ r"123",
+ r"12.300 %",
+ "de_CH",
+ r"123",
+ r"12'300 %",
+ "el",
+ r"123",
+ r"12.300%",
+ "en",
+ r"123",
+ r"12,300%",
+ "en_AU",
+ r"123",
+ r"12,300%",
+ "en_GB",
+ r"123",
+ r"12,300%",
+ "en_IE",
+ r"123",
+ r"12,300%",
+ "en_IN",
+ r"123",
+ r"12,300%",
+ "en_SG",
+ r"123",
+ r"12,300%",
+ "en_US",
+ r"123",
+ r"12,300%",
+ "en_ZA",
+ r"123",
+ r"12 300%",
+ "es",
+ r"123",
+ r"12.300%",
+ "es_419",
+ r"123",
+ r"12,300%",
+ "et",
+ r"123",
+ r"12 300%",
+ "eu",
+ r"123",
+ r"% 12.300",
+ "fa",
+ r"Û±Û²Û³",
+ r"Û±Û²Ù¬Û³Û°Û°Ùª",
+ "fi",
+ r"123",
+ r"12 300 %",
+ "fil",
+ r"123",
+ r"12,300%",
+ "fr",
+ r"123",
+ r"12 300 %",
+ "fr_CA",
+ r"123",
+ r"12 300 %",
+ "gl",
+ r"123",
+ r"12.300%",
+ "gsw",
+ r"123",
+ r"12’300 %",
+ "gu",
+ r"123",
+ r"12,300%",
+ "he",
+ r"123",
+ r"12,300%",
+ "hi",
+ r"123",
+ r"12,300%",
+ "hr",
+ r"123",
+ r"12.300%",
+ "hu",
+ r"123",
+ r"12 300%",
+ "id",
+ r"123",
+ r"12.300%",
+ "in",
+ r"123",
+ r"12.300%",
+ "is",
+ r"123",
+ r"12.300%",
+ "it",
+ r"123",
+ r"12.300%",
+ "iw",
+ r"123",
+ r"12,300%",
+ "ja",
+ r"123",
+ r"12,300%",
+ "kn",
+ r"123",
+ r"12,300%",
+ "ko",
+ r"123",
+ r"12,300%",
+ "ln",
+ r"123",
+ r"12.300%",
+ "lt",
+ r"123",
+ r"12 300%",
+ "lv",
+ r"123",
+ r"12 300%",
+ "ml",
+ r"123",
+ r"12,300%",
+ "mr",
+ r"123",
+ r"12,300%",
+ "ms",
+ r"123",
+ r"12,300%",
+ "mt",
+ r"123",
+ r"12,300%",
+ "nl",
+ r"123",
+ r"12.300%",
+ "no",
+ r"123",
+ r"12 300 %",
+ "or",
+ r"123",
+ r"12,300%",
+ "pl",
+ r"123",
+ r"12 300%",
+ "pt",
+ r"123",
+ r"12.300%",
+ "pt_BR",
+ r"123",
+ r"12.300%",
+ "pt_PT",
+ r"123",
+ r"12 300%",
+ "ro",
+ r"123",
+ r"12.300 %",
+ "ru",
+ r"123",
+ r"12 300 %",
+ "sk",
+ r"123",
+ r"12 300 %",
+ "sl",
+ r"123",
+ r"12.300%",
+ "sq",
+ r"123",
+ r"12 300%",
+ "sr",
+ r"123",
+ r"12.300%",
+ "sv",
+ r"123",
+ r"12 300 %",
+ "sw",
+ r"123",
+ r"12,300%",
+ "ta",
+ r"123",
+ r"12,300%",
+ "te",
+ r"123",
+ r"12,300%",
+ "th",
+ r"123",
+ r"12,300%",
+ "tl",
+ r"123",
+ r"12,300%",
+ "tr",
+ r"123",
+ r"%12.300",
+ "uk",
+ r"123",
+ r"12 300%",
+ "ur",
+ r"123",
+ r"12,300%",
+ "vi",
+ r"123",
+ r"12.300%",
+ "zh",
+ r"123",
+ r"12,300%",
+ "zh_CN",
+ r"123",
+ r"12,300%",
+ "zh_HK",
+ r"123",
+ r"12,300%",
+ "zh_TW",
+ r"123",
+ r"12,300%",
+ "zu",
+ r"123",
+ r"12,300%",
+ "END"];
\ No newline at end of file
diff --git a/pkg/oauth2/lib/src/client.dart b/pkg/oauth2/lib/src/client.dart
index afb59e4..0d422af 100644
--- a/pkg/oauth2/lib/src/client.dart
+++ b/pkg/oauth2/lib/src/client.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library client;
+library oauth2_client;
import 'dart:async';
import 'dart:uri';
diff --git a/pkg/pkg.status b/pkg/pkg.status
index 96f05ef..0c0512c 100644
--- a/pkg/pkg.status
+++ b/pkg/pkg.status
@@ -12,7 +12,7 @@
# Skip non-test files ending with "_test".
scheduled_test/lib/*: Skip
-scheduled_test/test/scheduled_server_test: Pass, Fail, Slow # Issue 9231, 9582
+scheduled_test/test/scheduled_server_test: Pass, Fail, Slow, Crash # Issue 9231, 9582
scheduled_test/test/scheduled_process_test: Pass, Slow # Issue 9231
# WebDriver tests have 3rd party dependencies (we need to run
@@ -20,11 +20,10 @@
# testing.
webdriver/test/webdriver_test: Skip
-[$compiler == none && $runtime == vm]
-intl/test/date_time_format_file_even_test: Pass, Crash # Issue 9342
-intl/test/date_time_format_file_odd_test: Pass, Crash # Issue 9342
-intl/test/date_time_format_local_even_test: Pass, Crash # Issue 9342
-intl/test/date_time_format_local_odd_test: Pass, Crash # Issue 9342
+
+[ $compiler == dart2js && $runtime == drt ]
+unittest/test/unittest_test: Pass, Fail, Crash # Bug in v8, http://dartbug.com/9407
+
[$compiler == dart2dart]
*: Skip
@@ -76,7 +75,7 @@
intl/test/date_time_format_http_request_test: Skip # Timeout.
[ $runtime == ie9 ]
-intl/test/date_time_format_http_request_test: Fail # Issue 8983
+intl/test/date_time_format_http_request_test: Skip # Issue 8983
[ $runtime == safari ]
fixnum/test/int_64_test: Pass, Fail # Bug in JSC.
@@ -90,11 +89,6 @@
intl/test/find_default_locale_standalone_test: Fail # Issue 8110
intl/test/message_extraction/message_extraction_test: Fail # Issue 9167
-# Skip http request tests on Dartium while resolving an odd
-# error there that causes the tests to timeout.
-[ $runtime == dartium || $runtime == drt ]
-intl/test/date_time_format_http_request_test: Skip
-
[ $compiler == dart2js ]
# Skip intl_message tests that use mirrors on dart2js until it's been
# implemented there.
diff --git a/pkg/scheduled_test/lib/descriptor.dart b/pkg/scheduled_test/lib/descriptor.dart
index ecb89f3..1b2b988 100644
--- a/pkg/scheduled_test/lib/descriptor.dart
+++ b/pkg/scheduled_test/lib/descriptor.dart
@@ -60,7 +60,7 @@
///
/// // ...
/// }
-library descriptor;
+library scheduled_test.descriptor;
import 'dart:async';
diff --git a/pkg/scheduled_test/lib/scheduled_process.dart b/pkg/scheduled_test/lib/scheduled_process.dart
index 57af0b6..cf37211 100644
--- a/pkg/scheduled_test/lib/scheduled_process.dart
+++ b/pkg/scheduled_test/lib/scheduled_process.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library scheduled_process;
+library scheduled_test.scheduled_process;
import 'dart:async';
import 'dart:io';
diff --git a/pkg/scheduled_test/lib/scheduled_server.dart b/pkg/scheduled_test/lib/scheduled_server.dart
index 88d9807..1ad8ac2 100644
--- a/pkg/scheduled_test/lib/scheduled_server.dart
+++ b/pkg/scheduled_test/lib/scheduled_server.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library scheduled_server;
+library scheduled_test.scheduled_server;
import 'dart:async';
import 'dart:collection';
diff --git a/pkg/scheduled_test/lib/src/descriptor/descriptor.dart b/pkg/scheduled_test/lib/src/descriptor/descriptor.dart
index 1d3a14a..1dc2c94 100644
--- a/pkg/scheduled_test/lib/src/descriptor/descriptor.dart
+++ b/pkg/scheduled_test/lib/src/descriptor/descriptor.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library descriptor.entry;
+library descriptor.descriptor;
import 'dart:async';
diff --git a/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart b/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
index feaa55b..d07b5bc 100644
--- a/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
+++ b/pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library descriptor.file;
+library descriptor.directory;
import 'dart:async';
import 'dart:io';
@@ -108,7 +108,7 @@
/// A class for formatting errors thrown by [DirectoryDescriptor].
class _DirectoryValidationError {
- final Collection<String> errors;
+ final Iterable<String> errors;
/// Flatten nested [_DirectoryValidationError]s in [errors] to create a single
/// list of errors.
diff --git a/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart b/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart
index 39f61cb..e56db2a 100644
--- a/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart
+++ b/pkg/scheduled_test/lib/src/descriptor/nothing_descriptor.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library descriptor.async;
+library descriptor.nothing;
import 'dart:async';
import 'dart:io';
diff --git a/pkg/scheduled_test/lib/src/mock_clock.dart b/pkg/scheduled_test/lib/src/mock_clock.dart
index d60e418..a4bbdee 100644
--- a/pkg/scheduled_test/lib/src/mock_clock.dart
+++ b/pkg/scheduled_test/lib/src/mock_clock.dart
@@ -67,7 +67,7 @@
/// code runs before the next tick.
void run() {
pumpEventQueue().then((_) {
- if (!_onTickController.hasSubscribers) return;
+ if (!_onTickController.hasListener) return;
tick();
return run();
});
diff --git a/pkg/scheduled_test/lib/src/schedule.dart b/pkg/scheduled_test/lib/src/schedule.dart
index 88c26eb..2569b4b 100644
--- a/pkg/scheduled_test/lib/src/schedule.dart
+++ b/pkg/scheduled_test/lib/src/schedule.dart
@@ -110,6 +110,14 @@
/// The timer for keeping track of task timeouts. This may be null.
Timer _timeoutTimer;
+ /// If `true`, then new [Task]s will capture the current stack trace before
+ /// running. This can be set to `false` to speed up running tests since
+ /// capturing stack traces is currently quite slow. Even when set to `false`,
+ /// stack traces from *thrown* exceptions will be caught. This only disables
+ /// the eager collection of stack traces *before* an error occurs. Defaults
+ /// to `true`.
+ bool captureStackTraces = true;
+
/// Creates a new schedule with empty task queues.
Schedule() {
_tasks = new TaskQueue._("tasks", this);
@@ -309,7 +317,7 @@
/// are no duplicate errors, and that all errors are wrapped in
/// [ScheduleError].
void _addError(error) {
- if (errors.contains(error)) return;
+ if (error is ScheduleError && errors.contains(error)) return;
errors.add(new ScheduleError.from(this, error));
}
}
@@ -340,12 +348,16 @@
class TaskQueue {
// TODO(nweiz): make this a read-only view when issue 8321 is fixed.
/// The tasks in the queue.
- Collection<Task> get contents => _contents;
+ Iterable<Task> get contents => _contents;
final _contents = new Queue<Task>();
/// The name of the queue, for debugging purposes.
final String name;
+ /// If `true`, then new [Task]s in this queue will capture the current stack
+ /// trace before running.
+ bool get captureStackTraces => _schedule.captureStackTraces;
+
/// The [Schedule] that created this queue.
final Schedule _schedule;
@@ -368,7 +380,7 @@
// TODO(nweiz): make this a read-only view when issue 8321 is fixed.
/// The descriptions of all callbacks that are blocking the completion of
/// [this].
- Collection<String> get pendingCallbacks => _pendingCallbacks;
+ Iterable<String> get pendingCallbacks => _pendingCallbacks;
final _pendingCallbacks = new Queue<String>();
/// A completer that will be completed once [_pendingCallbacks] becomes empty
@@ -496,8 +508,12 @@
if (description == null) {
description = "Out-of-band operation #${_totalCallbacks}";
}
- var stackString = prefixLines(terseTraceString(new Trace.current()));
- description = "$description\n\nStack trace:\n$stackString";
+
+ if (captureStackTraces) {
+ var stackString = prefixLines(terseTraceString(new Trace.current()));
+ description += "\n\nStack trace:\n$stackString";
+ }
+
_totalCallbacks++;
_pendingCallbacks.add(description);
diff --git a/pkg/scheduled_test/lib/src/schedule_error.dart b/pkg/scheduled_test/lib/src/schedule_error.dart
index 3df208a..7b66391 100644
--- a/pkg/scheduled_test/lib/src/schedule_error.dart
+++ b/pkg/scheduled_test/lib/src/schedule_error.dart
@@ -27,7 +27,7 @@
/// The descriptions of out-of-band callbacks that were pending when this
/// error occurred.
- final Collection<String> pendingCallbacks;
+ final Iterable<String> pendingCallbacks;
/// The state of the schedule at the time the error was detected.
final ScheduleState _stateWhenDetected;
@@ -50,12 +50,8 @@
error = error.error;
}
- if (stackTrace == null) {
- try {
- throw '';
- } catch (_, thrownStackTrace) {
- stackTrace = thrownStackTrace;
- }
+ if (schedule.captureStackTraces && stackTrace == null) {
+ stackTrace = new Trace.current();
}
return new ScheduleError(schedule, error, stackTrace, cause);
@@ -88,9 +84,11 @@
result.write('ScheduleError: "$errorString"\n');
}
- result.write('Stack trace:\n');
- result.write(prefixLines(terseTraceString(stackTrace)));
- result.write("\n\n");
+ if (stackTrace != null) {
+ result.write('Stack trace:\n');
+ result.write(prefixLines(terseTraceString(stackTrace)));
+ result.write("\n\n");
+ }
if (task != null) {
result.write('Error detected during task in queue "$queue":\n');
diff --git a/pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart b/pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart
index f326ac1..7e4e4cc 100644
--- a/pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart
+++ b/pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart
@@ -131,7 +131,7 @@
List<Cookie> get cookies => _inner.cookies;
Future<Socket> detachSocket() => _inner.detachSocket();
HttpConnectionInfo get connectionInfo => _inner.connectionInfo;
- void writeBytes(List<int> data) => _inner.writeBytes(data);
+ void add(List<int> data) => _inner.add(data);
Future<HttpResponse> consume(Stream<List<int>> stream) =>
_inner.consume(stream);
Future<HttpResponse> addStream(Stream<List<int>> stream) =>
diff --git a/pkg/scheduled_test/lib/src/task.dart b/pkg/scheduled_test/lib/src/task.dart
index 4ccb201..aabdbba 100644
--- a/pkg/scheduled_test/lib/src/task.dart
+++ b/pkg/scheduled_test/lib/src/task.dart
@@ -9,6 +9,7 @@
import 'package:stack_trace/stack_trace.dart';
+import '../scheduled_test.dart' show currentSchedule;
import 'future_group.dart';
import 'schedule.dart';
import 'utils.dart';
@@ -61,7 +62,7 @@
Future get result => _resultCompleter.future;
final _resultCompleter = new Completer();
- final stackTrace = new Trace.current();
+ final Trace stackTrace;
Task(fn(), String description, TaskQueue queue)
: this._(fn, description, queue, null, queue.contents.length);
@@ -69,7 +70,9 @@
Task._child(fn(), String description, Task parent)
: this._(fn, description, parent.queue, parent, parent.children.length);
- Task._(fn(), this.description, this.queue, this.parent, this._id) {
+ Task._(fn(), this.description, TaskQueue queue, this.parent, this._id)
+ : queue = queue,
+ stackTrace = queue.captureStackTraces ? new Trace.current() : null {
this.fn = () {
if (state != TaskState.WAITING) {
throw new StateError("Can't run $state task '$this'.");
@@ -121,8 +124,12 @@
String toString() => description == null ? "#$_id" : description;
String toStringWithStackTrace() {
- var stackString = prefixLines(terseTraceString(stackTrace));
- return "$this\n\nStack trace:\n$stackString";
+ var result = toString();
+ if (stackTrace != null) {
+ var stackString = prefixLines(terseTraceString(stackTrace));
+ result += "\n\nStack trace:\n$stackString";
+ }
+ return result;
}
/// Returns a detailed representation of [queue] with this task highlighted.
diff --git a/pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart b/pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart
new file mode 100644
index 0000000..6ea9e59
--- /dev/null
+++ b/pkg/scheduled_test/test/scheduled_test/capture_stack_traces_test.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:io' hide sleep;
+
+import 'package:scheduled_test/scheduled_test.dart';
+
+import '../metatest.dart';
+import '../utils.dart';
+
+void main() {
+ setUpTimeout();
+
+ expectTestsPass('error includes a stack trace by default', () {
+ var error;
+ test('test 1', () {
+ currentSchedule.onComplete.schedule(() {
+ error = currentSchedule.errors.first;
+ });
+
+ schedule(() => throw 'error');
+ });
+
+ test('test 2', () {
+ // There should be two stack traces: one for the thrown error, and one
+ // for the failed task (which is the captured one).
+ expect(error.toString(),
+ stringContainsInOrder(['Stack trace:', 'Stack trace:']));
+ });
+ }, passing: ['test 2']);
+
+ expectTestsPass('does not capture a stack trace if set to false', () {
+ var error;
+ test('test 1', () {
+ currentSchedule.captureStackTraces = false;
+ currentSchedule.onComplete.schedule(() {
+ error = currentSchedule.errors.first;
+ });
+
+ schedule(() => throw 'error');
+ });
+
+ test('test 2', () {
+ // There should only be the stack trace for the thrown exception, but no
+ // captured trace for the failed task.
+ var numStackTraces = 'Stack trace:'.allMatches(error.toString()).length;
+ expect(numStackTraces, equals(1));
+ });
+ }, passing: ['test 2']);
+}
diff --git a/pkg/serialization/lib/src/basic_rule.dart b/pkg/serialization/lib/src/basic_rule.dart
index fe9428f..c640ba6 100644
--- a/pkg/serialization/lib/src/basic_rule.dart
+++ b/pkg/serialization/lib/src/basic_rule.dart
@@ -375,7 +375,7 @@
}
valueIn(InstanceMirror mirror) =>
- deprecatedFutureValue(mirror.getField(name)).reflectee;
+ deprecatedFutureValue(mirror.getFieldAsync(name)).reflectee;
/** Return the function to use to set our value. */
Function get setter =>
@@ -383,7 +383,7 @@
/** Return a default setter function. */
void defaultSetter(InstanceMirror object, value) {
- object.setField(name, reflect(value));
+ object.setFieldAsync(name, reflect(value));
}
String toString() => 'Field($name)';
@@ -615,7 +615,7 @@
// TODO(alanknight): Handle named parameters
Iterable inflated = fieldNumbers.map(
(x) => (x is int) ? reflect(r.inflateReference(state[x])) : reflect(x));
- var result = type.newInstance(name, inflated.toList());
+ var result = type.newInstanceAsync(name, inflated.toList());
return deprecatedFutureValue(result);
}
}
diff --git a/pkg/serialization/lib/src/serialization_rule.dart b/pkg/serialization/lib/src/serialization_rule.dart
index 483197a..e83e804 100644
--- a/pkg/serialization/lib/src/serialization_rule.dart
+++ b/pkg/serialization/lib/src/serialization_rule.dart
@@ -544,7 +544,7 @@
lastIndexOf(x, [pos]) => _inflated.toList().lastIndexOf(x);
sublist(start, [end]) => _inflated.sublist(start, end);
- Map<int, dynamic> asMap() => IterableMixinWorkaround.asMapList(this);
+ Map<int, dynamic> asMap() => _inflated.asMap();
// These operations are all invalid
_throw() {
diff --git a/pkg/source_maps/lib/span.dart b/pkg/source_maps/lib/span.dart
index 1982994..fd302bc 100644
--- a/pkg/source_maps/lib/span.dart
+++ b/pkg/source_maps/lib/span.dart
@@ -5,7 +5,7 @@
/// Dart classes representing the souce spans and source files.
library source_maps.span;
-import 'dart:utf' show stringToCodepoints, codepointsToString;
+import 'dart:utf' show stringToCodepoints;
import 'dart:math' show min;
import 'src/utils.dart';
@@ -232,7 +232,7 @@
/// Gets the text at the given offsets.
String getText(int start, [int end]) {
- return codepointsToString(_decodedChars.sublist(start, end));
+ return new String.fromCharCodes(_decodedChars.sublist(start, end));
}
/// Create a pretty string representation from a span.
diff --git a/pkg/stack_trace/lib/src/trace.dart b/pkg/stack_trace/lib/src/trace.dart
index 43a598c..bed1d5d 100644
--- a/pkg/stack_trace/lib/src/trace.dart
+++ b/pkg/stack_trace/lib/src/trace.dart
@@ -5,6 +5,7 @@
library trace;
import 'dart:uri';
+import 'dart:math';
import 'frame.dart';
@@ -116,7 +117,7 @@
if (frames.length == '') return '';
// Figure out the longest path so we know how much to pad.
- var longest = frames.map((frame) => frame.location.length).max();
+ var longest = frames.map((frame) => frame.location.length).reduce(max);
// Print out the stack trace nicely formatted.
return frames.map((frame) {
diff --git a/pkg/stack_trace/lib/stack_trace.dart b/pkg/stack_trace/lib/stack_trace.dart
index 455dd57..5747b85 100644
--- a/pkg/stack_trace/lib/stack_trace.dart
+++ b/pkg/stack_trace/lib/stack_trace.dart
@@ -4,8 +4,5 @@
library stack_trace;
-import 'src/trace.dart';
-import 'src/frame.dart';
-
export 'src/trace.dart';
export 'src/frame.dart';
diff --git a/pkg/unittest/lib/matcher.dart b/pkg/unittest/lib/matcher.dart
index 29c5504..6584198 100644
--- a/pkg/unittest/lib/matcher.dart
+++ b/pkg/unittest/lib/matcher.dart
@@ -10,7 +10,7 @@
import 'dart:async';
part 'src/basematcher.dart';
-part 'src/collection_matchers.dart';
+part 'src/iterable_matchers.dart';
part 'src/core_matchers.dart';
part 'src/description.dart';
part 'src/expect.dart';
diff --git a/pkg/unittest/lib/mock.dart b/pkg/unittest/lib/mock.dart
index 730e4ff..db243db 100644
--- a/pkg/unittest/lib/mock.dart
+++ b/pkg/unittest/lib/mock.dart
@@ -671,7 +671,7 @@
* list is created.
*/
LogEntryList after(DateTime when, [bool inPlace = false]) =>
- _tail((e) => e.time > when, inPlace, 'after $when', logs.length);
+ _tail((e) => e.time.isAfter(when), inPlace, 'after $when', logs.length);
/**
* Returns log events that happened from [when] onwards. If
@@ -680,7 +680,7 @@
* a new list is created.
*/
LogEntryList from(DateTime when, [bool inPlace = false]) =>
- _tail((e) => e.time >= when, inPlace, 'from $when', logs.length);
+ _tail((e) => !e.time.isBefore(when), inPlace, 'from $when', logs.length);
/**
* Returns log events that happened until [when]. If [inPlace]
@@ -689,7 +689,7 @@
* list is created.
*/
LogEntryList until(DateTime when, [bool inPlace = false]) =>
- _head((e) => e.time > when, inPlace, 'until $when', logs.length);
+ _head((e) => e.time.isAfter(when), inPlace, 'until $when', logs.length);
/**
* Returns log events that happened before [when]. If [inPlace]
@@ -698,7 +698,10 @@
* list is created.
*/
LogEntryList before(DateTime when, [bool inPlace = false]) =>
- _head((e) => e.time >= when, inPlace, 'before $when', logs.length);
+ _head((e) => !e.time.isBefore(when),
+ inPlace,
+ 'before $when',
+ logs.length);
/**
* Returns log events that happened after [logEntry]'s time.
diff --git a/pkg/unittest/lib/src/core_matchers.dart b/pkg/unittest/lib/src/core_matchers.dart
index 236da4e..1a8143c 100644
--- a/pkg/unittest/lib/src/core_matchers.dart
+++ b/pkg/unittest/lib/src/core_matchers.dart
@@ -599,7 +599,7 @@
* Returns a matcher that matches if the match argument contains
* the expected value. For [String]s this means substring matching;
* for [Map]s it means the map has the key, and for [Iterable]s
- * (including [Collection]s) it means the iterable has a matching
+ * (including [Iterable]s) it means the iterable has a matching
* element. In the case of iterables, [expected] can itself be a
* matcher.
*/
@@ -645,7 +645,7 @@
bool matches(item, MatchState matchState) {
if (_expected is String) {
return _expected.indexOf(item) >= 0;
- } else if (_expected is Collection) {
+ } else if (_expected is Iterable) {
return _expected.any((e) => e == item);
} else if (_expected is Map) {
return _expected.containsKey(item);
diff --git a/pkg/unittest/lib/src/collection_matchers.dart b/pkg/unittest/lib/src/iterable_matchers.dart
similarity index 86%
rename from pkg/unittest/lib/src/collection_matchers.dart
rename to pkg/unittest/lib/src/iterable_matchers.dart
index 7f3a64c..e5b0e9a 100644
--- a/pkg/unittest/lib/src/collection_matchers.dart
+++ b/pkg/unittest/lib/src/iterable_matchers.dart
@@ -5,12 +5,12 @@
part of matcher;
/**
- * Returns a matcher which matches [Collection]s in which all elements
+ * Returns a matcher which matches [Iterable]s in which all elements
* match the given [matcher].
*/
Matcher everyElement(matcher) => new _EveryElement(wrapMatcher(matcher));
-class _EveryElement extends _CollectionMatcher {
+class _EveryElement extends _IterableMatcher {
Matcher _matcher;
_EveryElement(Matcher this._matcher);
@@ -51,12 +51,12 @@
}
/**
- * Returns a matcher which matches [Collection]s in which at least one
+ * Returns a matcher which matches [Iterable]s in which at least one
* element matches the given [matcher].
*/
Matcher someElement(matcher) => new _SomeElement(wrapMatcher(matcher));
-class _SomeElement extends _CollectionMatcher {
+class _SomeElement extends _IterableMatcher {
Matcher _matcher;
_SomeElement(this._matcher);
@@ -120,23 +120,8 @@
return 'not iterable';
}
// Check the lengths are the same.
- var expectedLength = 0;
- if (_expected is Collection) {
- Collection cast = _expected; // "_expected as Collection"
- expectedLength = cast.length;
- } else {
- for (var element in _expected) {
- ++expectedLength;
- }
- }
- var actualLength = 0;
- if (item is Collection) {
- actualLength = item.length;
- } else {
- for (var element in item) {
- ++actualLength;
- }
- }
+ var expectedLength = _expected.length;
+ var actualLength = item.length;
if (expectedLength > actualLength) {
return 'has too few elements (${actualLength} < ${expectedLength})';
} else if (expectedLength < actualLength) {
@@ -182,11 +167,11 @@
}
/**
- * Collection matchers match against [Collection]s. We add this intermediate
+ * Iterable matchers match against [Iterable]s. We add this intermediate
* class to give better mismatch error messages than the base Matcher class.
*/
-abstract class _CollectionMatcher extends BaseMatcher {
- const _CollectionMatcher();
+abstract class _IterableMatcher extends BaseMatcher {
+ const _IterableMatcher();
Description describeMismatch(item, Description mismatchDescription,
MatchState matchState, bool verbose) {
if (item is! Iterable) {
diff --git a/pkg/unittest/lib/src/test_case.dart b/pkg/unittest/lib/src/test_case.dart
index f8eb233..23d04de 100644
--- a/pkg/unittest/lib/src/test_case.dart
+++ b/pkg/unittest/lib/src/test_case.dart
@@ -158,7 +158,13 @@
[String messageText = '',
String stack = '']) {
if (runningTime == null) {
- _runningTime = new DateTime.now().difference(startTime);
+ // The startTime can be `null` if an error happened during setup. In this
+ // case we simply report a running time of 0.
+ if (startTime != null) {
+ _runningTime = new DateTime.now().difference(startTime);
+ } else {
+ _runningTime = const Duration(seconds: 0);
+ }
}
_setResult(testResult, messageText, stack);
if (!_doneTeardown) {
diff --git a/pkg/unittest/test/matchers_test.dart b/pkg/unittest/test/matchers_test.dart
index f49e0cb..7e97b38 100644
--- a/pkg/unittest/test/matchers_test.dart
+++ b/pkg/unittest/test/matchers_test.dart
@@ -461,7 +461,7 @@
});
});
- group('Collection Matchers', () {
+ group('Iterable Matchers', () {
test('isEmpty', () {
shouldPass([], isEmpty);
diff --git a/pkg/yaml/lib/parser.dart b/pkg/yaml/lib/parser.dart
index c84f374..9621b13 100644
--- a/pkg/yaml/lib/parser.dart
+++ b/pkg/yaml/lib/parser.dart
@@ -1119,7 +1119,7 @@
});
// 138
- Collection<_Node> ns_s_flowSeqEntries(int indent, int ctx) {
+ Iterable<_Node> ns_s_flowSeqEntries(int indent, int ctx) {
var first = ns_flowSeqEntry(indent, ctx);
if (!truth(first)) return new Queue<_Node>();
zeroOrOne(() => s_separate(indent, ctx));
diff --git a/pkg/yaml/test/yaml_test.dart b/pkg/yaml/test/yaml_test.dart
index 901bd3d..6013dc9 100644
--- a/pkg/yaml/test/yaml_test.dart
+++ b/pkg/yaml/test/yaml_test.dart
@@ -4,6 +4,8 @@
library yaml_test;
+// TODO(rnystrom): rewrite tests so that they don't need "Expect".
+import "package:expect/expect.dart";
import 'package:unittest/unittest.dart';
import 'package:yaml/yaml.dart';
import 'package:yaml/deep_equals.dart';
diff --git a/runtime/bin/bin.gypi b/runtime/bin/bin.gypi
index 2e360e0..c32c092 100644
--- a/runtime/bin/bin.gypi
+++ b/runtime/bin/bin.gypi
@@ -535,6 +535,11 @@
'OTHER_LDFLAGS': [ '-undefined', 'dynamic_lookup' ],
},
}],
+ ['OS=="linux"', {
+ 'cflags': [
+ '-fPIC',
+ ],
+ }],
],
},
],
diff --git a/runtime/bin/builtin_natives.cc b/runtime/bin/builtin_natives.cc
index 33be02e..b4b44d0 100644
--- a/runtime/bin/builtin_natives.cc
+++ b/runtime/bin/builtin_natives.cc
@@ -44,6 +44,7 @@
V(File_CreateLink, 2) \
V(File_LinkTarget, 1) \
V(File_Delete, 1) \
+ V(File_DeleteLink, 1) \
V(File_Directory, 1) \
V(File_FullPath, 1) \
V(File_OpenStdio, 1) \
diff --git a/runtime/bin/common_patch.dart b/runtime/bin/common_patch.dart
index 1c878aa..8b77d3a 100644
--- a/runtime/bin/common_patch.dart
+++ b/runtime/bin/common_patch.dart
@@ -7,4 +7,7 @@
native "Common_IsBuiltinList";
}
-
+patch class _IOCrypto {
+ /* patch */ static Uint8List getRandomBytes(int count)
+ native "Crypto_GetRandomBytes";
+}
diff --git a/runtime/bin/dbg_message.cc b/runtime/bin/dbg_message.cc
index d364d87..931d2bc 100644
--- a/runtime/bin/dbg_message.cc
+++ b/runtime/bin/dbg_message.cc
@@ -390,7 +390,8 @@
static void FormatLocationFromTrace(dart::TextBuffer* msg,
- Dart_StackTrace trace) {
+ Dart_StackTrace trace,
+ const char* prefix) {
intptr_t trace_len = 0;
Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
ASSERT_NOT_ERROR(res);
@@ -400,16 +401,21 @@
Dart_Handle script_url;
intptr_t token_number = 0;
intptr_t line_number = 0;
+ intptr_t library_id = 0;
+ // TODO(hausner): Remove this call and line_number once Editor no
+ // longer depends on line number info.
res = Dart_ActivationFrameInfo(frame, NULL, NULL, &line_number, NULL);
ASSERT_NOT_ERROR(res);
- res = Dart_ActivationFrameGetLocation(frame, &script_url, &token_number);
+ res = Dart_ActivationFrameGetLocation(
+ frame, &script_url, &library_id, &token_number);
ASSERT_NOT_ERROR(res);
if (!Dart_IsNull(script_url)) {
ASSERT(Dart_IsString(script_url));
- msg->Printf("\"location\": { \"url\":");
+ msg->Printf("%s\"location\": { \"url\":", prefix);
FormatEncodedString(msg, script_url);
- msg->Printf(",\"tokenOffset\":%"Pd",", token_number);
- msg->Printf("\"lineNumber\":%"Pd"},", line_number);
+ msg->Printf(",\"libraryId\":%"Pd",", library_id);
+ msg->Printf("\"tokenOffset\":%"Pd",", token_number);
+ msg->Printf("\"lineNumber\":%"Pd"}", line_number);
}
}
@@ -435,15 +441,19 @@
ASSERT(Dart_IsString(func_name));
msg->Printf("%s{\"functionName\":", (i > 0) ? "," : "");
FormatEncodedString(msg, func_name);
+ // TODO(hausner): Remove this libraryId field when Editor
+ // no longer depends on it.
msg->Printf(",\"libraryId\": %"Pd",", library_id);
- res = Dart_ActivationFrameGetLocation(frame, &script_url, &token_number);
+ res = Dart_ActivationFrameGetLocation(
+ frame, &script_url, NULL, &token_number);
ASSERT_NOT_ERROR(res);
if (!Dart_IsNull(script_url)) {
ASSERT(Dart_IsString(script_url));
msg->Printf("\"location\": { \"url\":");
FormatEncodedString(msg, script_url);
- msg->Printf(",\"tokenOffset\":%"Pd",", token_number);
+ msg->Printf(",\"libraryId\": %"Pd",", library_id);
+ msg->Printf("\"tokenOffset\":%"Pd",", token_number);
msg->Printf("\"lineNumber\":%"Pd"},", line_number);
}
@@ -479,6 +489,7 @@
{ "getGlobalVariables", DbgMessage::HandleGetGlobalsCmd },
{ "getScriptURLs", DbgMessage::HandleGetScriptURLsCmd },
{ "getScriptSource", DbgMessage::HandleGetSourceCmd },
+ { "getLineNumberTable", DbgMessage::HandleGetLineNumbersCmd },
{ "getStackTrace", DbgMessage::HandleGetStackTraceCmd },
{ "setBreakpoint", DbgMessage::HandleSetBpCmd },
{ "setPauseOnException", DbgMessage::HandlePauseOnExcCmd },
@@ -788,6 +799,53 @@
}
+bool DbgMessage::HandleGetLineNumbersCmd(DbgMessage* in_msg) {
+ ASSERT(in_msg != NULL);
+ MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
+ int msg_id = msg_parser.MessageId();
+ dart::TextBuffer msg(64);
+ intptr_t lib_id = msg_parser.GetIntParam("libraryId");
+ char* url_chars = msg_parser.GetStringParam("url");
+ ASSERT(url_chars != NULL);
+ Dart_Handle url = DartUtils::NewString(url_chars);
+ ASSERT_NOT_ERROR(url);
+ free(url_chars);
+ url_chars = NULL;
+ Dart_Handle info = Dart_ScriptGetTokenInfo(lib_id, url);
+ if (Dart_IsError(info)) {
+ in_msg->SendErrorReply(msg_id, Dart_GetError(info));
+ return false;
+ }
+ ASSERT(Dart_IsList(info));
+ intptr_t info_len = 0;
+ Dart_Handle res = Dart_ListLength(info, &info_len);
+ ASSERT_NOT_ERROR(res);
+ msg.Printf("{ \"id\": %d, ", msg_id);
+ msg.Printf("\"result\": { \"lines\": [");
+ Dart_Handle elem;
+ bool num_elems = 0;
+ for (intptr_t i = 0; i < info_len; i++) {
+ elem = Dart_ListGetAt(info, i);
+ if (Dart_IsNull(elem)) {
+ msg.Printf((i == 0) ? "[" : "], [");
+ num_elems = 0;
+ } else {
+ ASSERT(Dart_IsInteger(elem));
+ int value = GetIntValue(elem);
+ if (num_elems == 0) {
+ msg.Printf("%d", value);
+ } else {
+ msg.Printf(",%d", value);
+ }
+ num_elems++;
+ }
+ }
+ msg.Printf("]]}}");
+ in_msg->SendReply(&msg);
+ return false;
+}
+
+
bool DbgMessage::HandleGetStackTraceCmd(DbgMessage* in_msg) {
ASSERT(in_msg != NULL);
MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len());
@@ -950,9 +1008,8 @@
dart::TextBuffer msg(128);
msg.Printf("{ \"event\": \"paused\", \"params\": { ");
msg.Printf("\"reason\": \"breakpoint\", ");
- msg.Printf("\"id\": %"Pd64", ", isolate_id_);
- FormatLocationFromTrace(&msg, trace);
- FormatCallFrames(&msg, trace);
+ msg.Printf("\"isolateId\": %"Pd64"", isolate_id_);
+ FormatLocationFromTrace(&msg, trace, ", ");
msg.Printf("}}");
DebuggerConnectionHandler::BroadcastMsg(&msg);
}
@@ -967,12 +1024,10 @@
dart::TextBuffer msg(128);
msg.Printf("{ \"event\": \"paused\", \"params\": {");
msg.Printf("\"reason\": \"exception\", ");
- msg.Printf("\"id\": %"Pd64", ", isolate_id_);
+ msg.Printf("\"isolateId\": %"Pd64", ", isolate_id_);
msg.Printf("\"exception\":");
FormatRemoteObj(&msg, exception);
- msg.Printf(", ");
- FormatLocationFromTrace(&msg, stack_trace);
- FormatCallFrames(&msg, stack_trace);
+ FormatLocationFromTrace(&msg, stack_trace, ", ");
msg.Printf("}}");
DebuggerConnectionHandler::BroadcastMsg(&msg);
}
@@ -989,9 +1044,8 @@
ASSERT_NOT_ERROR(res);
msg.Printf("{ \"event\": \"paused\", \"params\": { ");
msg.Printf("\"reason\": \"interrupted\", ");
- msg.Printf("\"id\": %"Pd64", ", isolate_id);
- FormatLocationFromTrace(&msg, trace);
- FormatCallFrames(&msg, trace);
+ msg.Printf("\"isolateId\": %"Pd64"", isolate_id);
+ FormatLocationFromTrace(&msg, trace, ", ");
msg.Printf("}}");
} else {
msg.Printf("{ \"event\": \"isolate\", \"params\": { ");
diff --git a/runtime/bin/dbg_message.h b/runtime/bin/dbg_message.h
index 58d5df9..95bc688 100644
--- a/runtime/bin/dbg_message.h
+++ b/runtime/bin/dbg_message.h
@@ -104,6 +104,7 @@
static bool HandleGetListCmd(DbgMessage* msg);
static bool HandleGetScriptURLsCmd(DbgMessage* msg);
static bool HandleGetSourceCmd(DbgMessage* msg);
+ static bool HandleGetLineNumbersCmd(DbgMessage* msg);
static bool HandleGetStackTraceCmd(DbgMessage* msg);
static bool HandlePauseOnExcCmd(DbgMessage* msg);
static bool HandleSetBpCmd(DbgMessage* msg);
diff --git a/runtime/bin/directory_android.cc b/runtime/bin/directory_android.cc
index 1fb42cb..58060d8 100644
--- a/runtime/bin/directory_android.cc
+++ b/runtime/bin/directory_android.cc
@@ -54,10 +54,20 @@
};
+// A linked list of symbolic links, with their unique file system identifiers.
+// These are scanned to detect loops while doing a recursive directory listing.
+struct LinkList {
+ dev_t dev;
+ ino_t ino;
+ LinkList* next;
+};
+
+
// Forward declarations.
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing);
static bool DeleteRecursively(PathBuffer* path);
@@ -72,6 +82,7 @@
PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing *listing) {
if (strcmp(dir_name, ".") == 0) return true;
if (strcmp(dir_name, "..") == 0) return true;
@@ -80,7 +91,8 @@
return false;
}
return listing->HandleDirectory(path->data) &&
- (!recursive || ListRecursively(path, recursive, follow_links, listing));
+ (!recursive ||
+ ListRecursively(path, recursive, follow_links, seen, listing));
}
@@ -109,6 +121,7 @@
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing *listing) {
if (!path->Add(File::PathSeparator())) {
PostError(listing, path->data);
@@ -140,6 +153,7 @@
path,
recursive,
follow_links,
+ seen,
listing) && success;
break;
case DT_REG:
@@ -167,25 +181,63 @@
break;
}
int stat_success;
- if (follow_links) {
- stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
- if (stat_success == -1) {
- stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
- }
- } else {
- stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
- }
+ stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
if (stat_success == -1) {
success = false;
PostError(listing, path->data);
break;
}
+ if (follow_links && S_ISLNK(entry_info.st_mode)) {
+ // Check to see if we are in a loop created by a symbolic link.
+ LinkList current_link = { entry_info.st_dev,
+ entry_info.st_ino,
+ seen };
+ LinkList* previous = seen;
+ bool looping_link = false;
+ while (previous != NULL) {
+ if (previous->dev == current_link.dev &&
+ previous->ino == current_link.ino) {
+ // Report the looping link as a link, rather than following it.
+ path->Reset(path_length);
+ success = HandleLink(entry.d_name,
+ path,
+ listing) && success;
+ looping_link = true;
+ break;
+ }
+ previous = previous->next;
+ }
+ if (looping_link) break;
+ stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
+ if (stat_success == -1) {
+ // Report a broken link as a link, even if follow_links is true.
+ path->Reset(path_length);
+ success = HandleLink(entry.d_name,
+ path,
+ listing) && success;
+ break;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ // Recurse into the subdirectory with current_link added to the
+ // linked list of seen file system links.
+ path->Reset(path_length);
+ success = HandleDir(entry.d_name,
+ path,
+ recursive,
+ follow_links,
+ seen,
+ ¤t_link,
+ listing) && success;
+ break;
+ }
+ }
path->Reset(path_length);
if (S_ISDIR(entry_info.st_mode)) {
success = HandleDir(entry.d_name,
path,
recursive,
follow_links,
+ seen,
listing) && success;
} else if (S_ISREG(entry_info.st_mode)) {
success = HandleFile(entry.d_name,
@@ -221,7 +273,7 @@
static bool DeleteFile(char* file_name,
PathBuffer* path) {
- return path->Add(file_name) && remove(path->data) == 0;
+ return path->Add(file_name) && unlink(path->data) == 0;
}
@@ -235,11 +287,12 @@
static bool DeleteRecursively(PathBuffer* path) {
// Do not recurse into links for deletion. Instead delete the link.
+ // If it's a file, delete it.
struct stat st;
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
return false;
- } else if (S_ISLNK(st.st_mode)) {
- return (remove(path->data) == 0);
+ } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
+ return (unlink(path->data) == 0);
}
if (!path->Add(File::PathSeparator())) return false;
@@ -326,7 +379,7 @@
PostError(listing, dir_name);
return false;
}
- return ListRecursively(&path, recursive, follow_links, listing);
+ return ListRecursively(&path, recursive, follow_links, NULL, listing);
}
@@ -441,7 +494,11 @@
bool Directory::Delete(const char* dir_name, bool recursive) {
if (!recursive) {
- return (TEMP_FAILURE_RETRY(remove(dir_name)) == 0);
+ if (File::GetType(dir_name, false) == File::kIsLink &&
+ File::GetType(dir_name, true) == File::kIsDirectory) {
+ return (TEMP_FAILURE_RETRY(unlink(dir_name)) == 0);
+ }
+ return (TEMP_FAILURE_RETRY(rmdir(dir_name)) == 0);
} else {
PathBuffer path;
if (!path.Add(dir_name)) {
diff --git a/runtime/bin/directory_linux.cc b/runtime/bin/directory_linux.cc
index a316633..2f86f5b 100644
--- a/runtime/bin/directory_linux.cc
+++ b/runtime/bin/directory_linux.cc
@@ -54,10 +54,20 @@
};
+// A linked list of symbolic links, with their unique file system identifiers.
+// These are scanned to detect loops while doing a recursive directory listing.
+struct LinkList {
+ dev_t dev;
+ ino_t ino;
+ LinkList* next;
+};
+
+
// Forward declarations.
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing);
static bool DeleteRecursively(PathBuffer* path);
@@ -72,6 +82,7 @@
PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing *listing) {
if (strcmp(dir_name, ".") == 0) return true;
if (strcmp(dir_name, "..") == 0) return true;
@@ -80,7 +91,8 @@
return false;
}
return listing->HandleDirectory(path->data) &&
- (!recursive || ListRecursively(path, recursive, follow_links, listing));
+ (!recursive ||
+ ListRecursively(path, recursive, follow_links, seen, listing));
}
@@ -109,6 +121,7 @@
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing *listing) {
if (!path->Add(File::PathSeparator())) {
PostError(listing, path->data);
@@ -140,6 +153,7 @@
path,
recursive,
follow_links,
+ seen,
listing) && success;
break;
case DT_REG:
@@ -167,25 +181,62 @@
break;
}
int stat_success;
- if (follow_links) {
- stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
- if (stat_success == -1) {
- stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
- }
- } else {
- stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
- }
+ stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
if (stat_success == -1) {
success = false;
PostError(listing, path->data);
break;
}
+ if (follow_links && S_ISLNK(entry_info.st_mode)) {
+ // Check to see if we are in a loop created by a symbolic link.
+ LinkList current_link = { entry_info.st_dev,
+ entry_info.st_ino,
+ seen };
+ LinkList* previous = seen;
+ bool looping_link = false;
+ while (previous != NULL) {
+ if (previous->dev == current_link.dev &&
+ previous->ino == current_link.ino) {
+ // Report the looping link as a link, rather than following it.
+ path->Reset(path_length);
+ success = HandleLink(entry.d_name,
+ path,
+ listing) && success;
+ looping_link = true;
+ break;
+ }
+ previous = previous->next;
+ }
+ if (looping_link) break;
+ stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
+ if (stat_success == -1) {
+ // Report a broken link as a link, even if follow_links is true.
+ path->Reset(path_length);
+ success = HandleLink(entry.d_name,
+ path,
+ listing) && success;
+ break;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ // Recurse into the subdirectory with current_link added to the
+ // linked list of seen file system links.
+ path->Reset(path_length);
+ success = HandleDir(entry.d_name,
+ path,
+ recursive,
+ follow_links,
+ ¤t_link,
+ listing) && success;
+ break;
+ }
+ }
path->Reset(path_length);
if (S_ISDIR(entry_info.st_mode)) {
success = HandleDir(entry.d_name,
path,
recursive,
follow_links,
+ seen,
listing) && success;
} else if (S_ISREG(entry_info.st_mode)) {
success = HandleFile(entry.d_name,
@@ -221,7 +272,7 @@
static bool DeleteFile(char* file_name,
PathBuffer* path) {
- return path->Add(file_name) && remove(path->data) == 0;
+ return path->Add(file_name) && unlink(path->data) == 0;
}
@@ -235,11 +286,12 @@
static bool DeleteRecursively(PathBuffer* path) {
// Do not recurse into links for deletion. Instead delete the link.
+ // If it's a file, delete it.
struct stat st;
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
return false;
- } else if (S_ISLNK(st.st_mode)) {
- return (remove(path->data) == 0);
+ } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
+ return (unlink(path->data) == 0);
}
if (!path->Add(File::PathSeparator())) return false;
@@ -326,7 +378,7 @@
PostError(listing, dir_name);
return false;
}
- return ListRecursively(&path, recursive, follow_links, listing);
+ return ListRecursively(&path, recursive, follow_links, NULL, listing);
}
@@ -409,7 +461,11 @@
bool Directory::Delete(const char* dir_name, bool recursive) {
if (!recursive) {
- return (TEMP_FAILURE_RETRY(remove(dir_name)) == 0);
+ if (File::GetType(dir_name, false) == File::kIsLink &&
+ File::GetType(dir_name, true) == File::kIsDirectory) {
+ return (TEMP_FAILURE_RETRY(unlink(dir_name)) == 0);
+ }
+ return (TEMP_FAILURE_RETRY(rmdir(dir_name)) == 0);
} else {
PathBuffer path;
if (!path.Add(dir_name)) {
diff --git a/runtime/bin/directory_macos.cc b/runtime/bin/directory_macos.cc
index 401f80c..ece3685 100644
--- a/runtime/bin/directory_macos.cc
+++ b/runtime/bin/directory_macos.cc
@@ -54,10 +54,20 @@
};
+// A linked list of symbolic links, with their unique file system identifiers.
+// These are scanned to detect loops while doing a recursive directory listing.
+struct LinkList {
+ dev_t dev;
+ ino_t ino;
+ LinkList* next;
+};
+
+
// Forward declarations.
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing);
static bool DeleteRecursively(PathBuffer* path);
@@ -72,6 +82,7 @@
PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing *listing) {
if (strcmp(dir_name, ".") == 0) return true;
if (strcmp(dir_name, "..") == 0) return true;
@@ -80,7 +91,8 @@
return false;
}
return listing->HandleDirectory(path->data) &&
- (!recursive || ListRecursively(path, recursive, follow_links, listing));
+ (!recursive ||
+ ListRecursively(path, recursive, follow_links, seen, listing));
}
@@ -109,6 +121,7 @@
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing *listing) {
if (!path->Add(File::PathSeparator())) {
PostError(listing, path->data);
@@ -140,6 +153,7 @@
path,
recursive,
follow_links,
+ seen,
listing) && success;
break;
case DT_REG:
@@ -167,25 +181,62 @@
break;
}
int stat_success;
- if (follow_links) {
- stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
- if (stat_success == -1) {
- stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
- }
- } else {
- stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
- }
+ stat_success = TEMP_FAILURE_RETRY(lstat(path->data, &entry_info));
if (stat_success == -1) {
success = false;
PostError(listing, path->data);
break;
}
+ if (follow_links && S_ISLNK(entry_info.st_mode)) {
+ // Check to see if we are in a loop created by a symbolic link.
+ LinkList current_link = { entry_info.st_dev,
+ entry_info.st_ino,
+ seen };
+ LinkList* previous = seen;
+ bool looping_link = false;
+ while (previous != NULL) {
+ if (previous->dev == current_link.dev &&
+ previous->ino == current_link.ino) {
+ // Report the looping link as a link, rather than following it.
+ path->Reset(path_length);
+ success = HandleLink(entry.d_name,
+ path,
+ listing) && success;
+ looping_link = true;
+ break;
+ }
+ previous = previous->next;
+ }
+ if (looping_link) break;
+ stat_success = TEMP_FAILURE_RETRY(stat(path->data, &entry_info));
+ if (stat_success == -1) {
+ // Report a broken link as a link, even if follow_links is true.
+ path->Reset(path_length);
+ success = HandleLink(entry.d_name,
+ path,
+ listing) && success;
+ break;
+ }
+ if (S_ISDIR(entry_info.st_mode)) {
+ // Recurse into the subdirectory with current_link added to the
+ // linked list of seen file system links.
+ path->Reset(path_length);
+ success = HandleDir(entry.d_name,
+ path,
+ recursive,
+ follow_links,
+ ¤t_link,
+ listing) && success;
+ break;
+ }
+ }
path->Reset(path_length);
if (S_ISDIR(entry_info.st_mode)) {
success = HandleDir(entry.d_name,
path,
recursive,
follow_links,
+ seen,
listing) && success;
} else if (S_ISREG(entry_info.st_mode)) {
success = HandleFile(entry.d_name,
@@ -221,7 +272,7 @@
static bool DeleteFile(char* file_name,
PathBuffer* path) {
- return path->Add(file_name) && remove(path->data) == 0;
+ return path->Add(file_name) && unlink(path->data) == 0;
}
@@ -235,11 +286,12 @@
static bool DeleteRecursively(PathBuffer* path) {
// Do not recurse into links for deletion. Instead delete the link.
+ // If it's a file, delete it.
struct stat st;
if (TEMP_FAILURE_RETRY(lstat(path->data, &st)) == -1) {
return false;
- } else if (S_ISLNK(st.st_mode)) {
- return (remove(path->data) == 0);
+ } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
+ return (unlink(path->data) == 0);
}
if (!path->Add(File::PathSeparator())) return false;
@@ -326,7 +378,7 @@
PostError(listing, dir_name);
return false;
}
- return ListRecursively(&path, recursive, follow_links, listing);
+ return ListRecursively(&path, recursive, follow_links, NULL, listing);
}
@@ -409,7 +461,11 @@
bool Directory::Delete(const char* dir_name, bool recursive) {
if (!recursive) {
- return (TEMP_FAILURE_RETRY(remove(dir_name)) == 0);
+ if (File::GetType(dir_name, false) == File::kIsLink &&
+ File::GetType(dir_name, true) == File::kIsDirectory) {
+ return (TEMP_FAILURE_RETRY(unlink(dir_name)) == 0);
+ }
+ return (TEMP_FAILURE_RETRY(rmdir(dir_name)) == 0);
} else {
PathBuffer path;
if (!path.Add(dir_name)) {
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index d4b0aaf..79c7b08 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -6,6 +6,7 @@
#if defined(TARGET_OS_WINDOWS)
#include "bin/directory.h"
+#include "bin/file.h"
#include <errno.h> // NOLINT
#include <sys/stat.h> // NOLINT
@@ -48,11 +49,39 @@
}
};
+// If link_name points to a link, IsBrokenLink will return true if link_name
+// points to an invalid target.
+static bool IsBrokenLink(const wchar_t* link_name) {
+ HANDLE handle = CreateFileW(
+ link_name,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL);
+ if (handle == INVALID_HANDLE_VALUE) {
+ return true;
+ } else {
+ CloseHandle(handle);
+ return false;
+ }
+}
+
+// A linked list structure holding a link target's unique file system ID.
+// Used to detect loops in the file system when listing recursively.
+struct LinkList {
+ DWORD volume;
+ DWORD id_low;
+ DWORD id_high;
+ LinkList* next;
+};
// Forward declarations.
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing);
static bool DeleteRecursively(PathBuffer* path);
@@ -69,6 +98,7 @@
PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing) {
if (wcscmp(dir_name, L".") == 0) return true;
if (wcscmp(dir_name, L"..") == 0) return true;
@@ -80,7 +110,8 @@
bool ok = listing->HandleDirectory(utf8_path);
free(utf8_path);
return ok &&
- (!recursive || ListRecursively(path, recursive, follow_links, listing));
+ (!recursive ||
+ ListRecursively(path, recursive, follow_links, seen, listing));
}
@@ -116,24 +147,62 @@
PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing) {
DWORD attributes = find_file_data->dwFileAttributes;
if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
if (!follow_links) {
return HandleLink(find_file_data->cFileName, path, listing);
}
- // Attempt to list the directory, to see if it's a valid link or not.
int path_length = path->length;
if (!path->Add(find_file_data->cFileName)) return false;
- if (!path->Add(L"\\*")) return false;
- WIN32_FIND_DATAW tmp_file_data;
- HANDLE find_handle = FindFirstFileW(path->data, &tmp_file_data);
+ HANDLE handle = CreateFileW(
+ path->data,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL);
path->Reset(path_length);
- if (find_handle == INVALID_HANDLE_VALUE) {
- // Invalid handle, report as (broken) link.
+ if (handle == INVALID_HANDLE_VALUE) {
+ // Report as (broken) link.
return HandleLink(find_file_data->cFileName, path, listing);
- } else {
- FindClose(find_handle);
+ }
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ // Check the seen link targets to see if we are in a file system loop.
+ LinkList current_link;
+ BY_HANDLE_FILE_INFORMATION info;
+ // Get info
+ if (!GetFileInformationByHandle(handle, &info)) {
+ DWORD error = GetLastError();
+ CloseHandle(handle);
+ SetLastError(error);
+ PostError(listing, path->data);
+ return false;
+ }
+ CloseHandle(handle);
+ current_link.volume = info.dwVolumeSerialNumber;
+ current_link.id_low = info.nFileIndexLow;
+ current_link.id_high = info.nFileIndexHigh;
+ current_link.next = seen;
+ LinkList* previous = seen;
+ while (previous != NULL) {
+ if (previous->volume == current_link.volume &&
+ previous->id_low == current_link.id_low &&
+ previous->id_high == current_link.id_high) {
+ // Report the looping link as a link, rather than following it.
+ return HandleLink(find_file_data->cFileName, path, listing);
+ }
+ previous = previous->next;
+ }
+ // Recurse into the directory, adding current link to the seen links list.
+ return HandleDir(find_file_data->cFileName,
+ path,
+ recursive,
+ follow_links,
+ ¤t_link,
+ listing);
}
}
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
@@ -141,6 +210,7 @@
path,
recursive,
follow_links,
+ seen,
listing);
} else {
return HandleFile(find_file_data->cFileName, path, listing);
@@ -151,6 +221,7 @@
static bool ListRecursively(PathBuffer* path,
bool recursive,
bool follow_links,
+ LinkList* seen,
DirectoryListing* listing) {
if (!path->Add(L"\\*")) {
PostError(listing, path->data);
@@ -173,6 +244,7 @@
path,
recursive,
follow_links,
+ seen,
listing);
while ((FindNextFileW(find_handle, &find_file_data) != 0)) {
@@ -181,6 +253,7 @@
path,
recursive,
follow_links,
+ seen,
listing) && success;
}
@@ -248,14 +321,20 @@
static bool DeleteRecursively(PathBuffer* path) {
+ DWORD attributes = GetFileAttributesW(path->data);
+ if ((attributes == INVALID_FILE_ATTRIBUTES)) {
+ return false;
+ }
// If the directory is a junction, it's pointing to some other place in the
// filesystem that we do not want to recurse into.
- DWORD attributes = GetFileAttributesW(path->data);
- if ((attributes != INVALID_FILE_ATTRIBUTES) &&
- (attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
// Just delete the junction itself.
return RemoveDirectoryW(path->data) != 0;
}
+ // If it's a file, remove it directly.
+ if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ return DeleteFile(L"", path);
+ }
if (!path->Add(L"\\*")) return false;
@@ -299,7 +378,7 @@
return false;
}
free(const_cast<wchar_t*>(system_name));
- return ListRecursively(&path, recursive, follow_links, listing);
+ return ListRecursively(&path, recursive, follow_links, NULL, listing);
}
@@ -318,6 +397,7 @@
}
}
bool exists = (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
+ exists = exists && !IsBrokenLink(dir_name);
return exists ? Directory::EXISTS : Directory::DOES_NOT_EXIST;
}
@@ -407,13 +487,16 @@
bool result = false;
const wchar_t* system_dir_name = StringUtils::Utf8ToWide(dir_name);
if (!recursive) {
- result = (RemoveDirectoryW(system_dir_name) != 0);
+ if (File::GetType(dir_name, true) == File::kIsDirectory) {
+ result = (RemoveDirectoryW(system_dir_name) != 0);
+ } else {
+ SetLastError(ERROR_FILE_NOT_FOUND);
+ }
} else {
PathBuffer path;
- if (!path.Add(system_dir_name)) {
- return false;
+ if (path.Add(system_dir_name)) {
+ result = DeleteRecursively(&path);
}
- result = DeleteRecursively(&path);
}
free(const_cast<wchar_t*>(system_dir_name));
return result;
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index 5c54ed8..f04a367 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -488,6 +488,22 @@
}
+void FUNCTION_NAME(File_DeleteLink)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ const char* str =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ bool result = File::DeleteLink(str);
+ if (result) {
+ Dart_SetReturnValue(args, Dart_NewBoolean(result));
+ } else {
+ Dart_Handle err = DartUtils::NewDartOSError();
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ }
+ Dart_ExitScope();
+}
+
+
void FUNCTION_NAME(File_Directory)(Dart_NativeArguments args) {
Dart_EnterScope();
const char* str =
@@ -997,6 +1013,36 @@
}
+static CObject* FileCreateLinkRequest(const CObjectArray& request) {
+ if (request.Length() != 3 ||
+ !request[1]->IsString() ||
+ !request[2]->IsString()) {
+ return CObject::IllegalArgumentError();
+ }
+ CObjectString link_name(request[1]);
+ CObjectString target_name(request[2]);
+ if (File::CreateLink(link_name.CString(), target_name.CString())) {
+ return CObject::True();
+ } else {
+ return CObject::NewOSError();
+ }
+}
+
+
+static CObject* FileDeleteLinkRequest(const CObjectArray& request) {
+ if (request.Length() == 2 && request[1]->IsString()) {
+ CObjectString filename(request[1]);
+ bool result = File::DeleteLink(filename.CString());
+ if (result) {
+ return CObject::True();
+ } else {
+ return CObject::NewOSError();
+ }
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
static void FileService(Dart_Port dest_port_id,
Dart_Port reply_port_id,
Dart_CObject* message) {
@@ -1063,6 +1109,12 @@
case File::kWriteListRequest:
response = FileWriteListRequest(request);
break;
+ case File::kDeleteLinkRequest:
+ response = FileDeleteLinkRequest(request);
+ break;
+ case File::kCreateLinkRequest:
+ response = FileCreateLinkRequest(request);
+ break;
default:
UNREACHABLE();
}
diff --git a/runtime/bin/file.h b/runtime/bin/file.h
index 0895a84..b4c5c50 100644
--- a/runtime/bin/file.h
+++ b/runtime/bin/file.h
@@ -76,7 +76,9 @@
kWriteByteRequest = 15,
kReadRequest = 16,
kReadListRequest = 17,
- kWriteListRequest = 18
+ kWriteListRequest = 18,
+ kCreateLinkRequest = 19,
+ kDeleteLinkRequest = 20
};
~File();
@@ -131,6 +133,7 @@
static bool Create(const char* path);
static bool CreateLink(const char* path, const char* target);
static bool Delete(const char* path);
+ static bool DeleteLink(const char* path);
static off_t LengthFromPath(const char* path);
static time_t LastModified(const char* path);
static char* LinkTarget(const char* pathname);
diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc
index 21dcaa9..2d7c99d 100644
--- a/runtime/bin/file_android.cc
+++ b/runtime/bin/file_android.cc
@@ -166,11 +166,25 @@
bool File::Delete(const char* name) {
- int status = TEMP_FAILURE_RETRY(remove(name));
- if (status == -1) {
- return false;
+ File::Type type = File::GetType(name, true);
+ if (type == kIsFile) {
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0;
+ } else if (type == kIsDirectory) {
+ errno = EISDIR;
+ } else {
+ errno = ENOENT;
}
- return true;
+ return false;
+}
+
+
+bool File::DeleteLink(const char* name) {
+ File::Type type = File::GetType(name, false);
+ if (type == kIsLink) {
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0;
+ }
+ errno = EINVAL;
+ return false;
}
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
index ceac630..8126ff9 100644
--- a/runtime/bin/file_linux.cc
+++ b/runtime/bin/file_linux.cc
@@ -167,11 +167,25 @@
bool File::Delete(const char* name) {
- int status = TEMP_FAILURE_RETRY(remove(name));
- if (status == -1) {
- return false;
+ File::Type type = File::GetType(name, true);
+ if (type == kIsFile) {
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0;
+ } else if (type == kIsDirectory) {
+ errno = EISDIR;
+ } else {
+ errno = ENOENT;
}
- return true;
+ return false;
+}
+
+
+bool File::DeleteLink(const char* name) {
+ File::Type type = File::GetType(name, false);
+ if (type == kIsLink) {
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0;
+ }
+ errno = EINVAL;
+ return false;
}
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index 301424b..a5af904 100644
--- a/runtime/bin/file_macos.cc
+++ b/runtime/bin/file_macos.cc
@@ -169,11 +169,25 @@
bool File::Delete(const char* name) {
- int status = TEMP_FAILURE_RETRY(remove(name));
- if (status == -1) {
- return false;
+ File::Type type = File::GetType(name, true);
+ if (type == kIsFile) {
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0;
+ } else if (type == kIsDirectory) {
+ errno = EISDIR;
+ } else {
+ errno = ENOENT;
}
- return true;
+ return false;
+}
+
+
+bool File::DeleteLink(const char* name) {
+ File::Type type = File::GetType(name, false);
+ if (type == kIsLink) {
+ return TEMP_FAILURE_RETRY(unlink(name)) == 0;
+ }
+ errno = EINVAL;
+ return false;
}
diff --git a/runtime/bin/file_patch.dart b/runtime/bin/file_patch.dart
index e1e1bfa..c246002 100644
--- a/runtime/bin/file_patch.dart
+++ b/runtime/bin/file_patch.dart
@@ -13,6 +13,7 @@
native "File_CreateLink";
/* patch */ static _linkTarget(String path) native "File_LinkTarget";
/* patch */ static _delete(String path) native "File_Delete";
+ /* patch */ static _deleteLink(String path) native "File_DeleteLink";
/* patch */ static _directory(String path) native "File_Directory";
/* patch */ static _lengthFromPath(String path) native "File_LengthFromPath";
/* patch */ static _lastModified(String path) native "File_LastModified";
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 3780fca..78074cc 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -259,19 +259,25 @@
bool File::Delete(const char* name) {
const wchar_t* system_name = StringUtils::Utf8ToWide(name);
+ int status = _wremove(system_name);
+ free(const_cast<wchar_t*>(system_name));
+ return status != -1;
+}
+
+
+bool File::DeleteLink(const char* name) {
+ const wchar_t* system_name = StringUtils::Utf8ToWide(name);
+ bool result = false;
DWORD attributes = GetFileAttributesW(system_name);
if ((attributes != INVALID_FILE_ATTRIBUTES) &&
(attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
// It's a junction(link), delete it.
- return RemoveDirectoryW(system_name) != 0;
+ result = (RemoveDirectoryW(system_name) != 0);
} else {
- int status = _wremove(system_name);
- free(const_cast<wchar_t*>(system_name));
- if (status == -1) {
- return false;
- }
- return true;
+ SetLastError(ERROR_NOT_A_REPARSE_POINT);
}
+ free(const_cast<wchar_t*>(system_name));
+ return result;
}
@@ -319,14 +325,12 @@
if (result == 0) {
DWORD error = GetLastError();
CloseHandle(dir_handle);
- free(buffer);
SetLastError(error);
+ free(buffer);
return NULL;
}
if (CloseHandle(dir_handle) == 0) {
- DWORD error = GetLastError();
free(buffer);
- SetLastError(error);
return NULL;
}
@@ -372,10 +376,8 @@
utf8_length,
NULL,
NULL)) {
- DWORD error = GetLastError();
free(buffer);
free(utf8_target);
- SetLastError(error);
return NULL;
}
utf8_target[utf8_length] = '\0';
@@ -480,15 +482,11 @@
File::Type File::GetType(const char* pathname, bool follow_links) {
const wchar_t* name = StringUtils::Utf8ToWide(pathname);
- WIN32_FIND_DATAW file_data;
- HANDLE find_handle = FindFirstFileW(name, &file_data);
- if (find_handle == INVALID_HANDLE_VALUE) {
- // TODO(whesse): Distinguish other errors from does not exist.
- return File::kDoesNotExist;
- }
- FindClose(find_handle);
- DWORD attributes = file_data.dwFileAttributes;
- if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ DWORD attributes = GetFileAttributesW(name);
+ File::Type result = kIsFile;
+ if (attributes == INVALID_FILE_ATTRIBUTES) {
+ result = kDoesNotExist;
+ } else if ((attributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
if (follow_links) {
HANDLE dir_handle = CreateFileW(
name,
@@ -499,26 +497,19 @@
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (dir_handle == INVALID_HANDLE_VALUE) {
- // TODO(whesse): Distinguish other errors from does not exist.
- return File::kDoesNotExist;
+ result = File::kIsLink;
} else {
CloseHandle(dir_handle);
- return File::kIsDirectory;
+ result = File::kIsDirectory;
}
} else {
- DWORD reparse_tag = file_data.dwReserved0;
- if (reparse_tag == IO_REPARSE_TAG_SYMLINK ||
- reparse_tag == IO_REPARSE_TAG_MOUNT_POINT) {
- return File::kIsLink;
- } else {
- return File::kDoesNotExist;
- }
+ result = kIsLink;
}
} else if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- return File::kIsDirectory;
- } else {
- return File::kIsFile;
+ result = kIsDirectory;
}
+ free(const_cast<wchar_t*>(name));
+ return result;
}
@@ -536,9 +527,7 @@
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
NULL);
if (file_handle == INVALID_HANDLE_VALUE) {
- DWORD error = GetLastError();
free(const_cast<wchar_t*>(wide_name));
- SetLastError(error);
return File::kError;
}
free(const_cast<wchar_t*>(wide_name));
diff --git a/runtime/bin/http_patch.dart b/runtime/bin/http_patch.dart
deleted file mode 100644
index fc3da60..0000000
--- a/runtime/bin/http_patch.dart
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-patch class _HttpSessionManager {
- /* patch */ static Uint8List _getRandomBytes(int count)
- native "Crypto_GetRandomBytes";
-}
diff --git a/runtime/bin/io.dart b/runtime/bin/io.dart
index 92ca329..4b2e666 100644
--- a/runtime/bin/io.dart
+++ b/runtime/bin/io.dart
@@ -11,6 +11,7 @@
import "dart:collection";
import "dart:crypto";
import "dart:isolate";
+import 'dart:json' as JSON;
import "dart:math";
import "dart:nativewrappers";
import "dart:typeddata";
diff --git a/runtime/bin/io_sources.gypi b/runtime/bin/io_sources.gypi
index 52ec37c..67294c9 100644
--- a/runtime/bin/io_sources.gypi
+++ b/runtime/bin/io_sources.gypi
@@ -11,7 +11,6 @@
'file_patch.dart',
'file_system_entity_patch.dart',
'filter_patch.dart',
- 'http_patch.dart',
'platform_patch.dart',
'process_patch.dart',
'socket_patch.dart',
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 988f78a..5e266ce 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -293,7 +293,8 @@
char** executable_name,
char** script_name,
CommandLineOptions* dart_options,
- bool* print_flags_seen) {
+ bool* print_flags_seen,
+ bool* verbose_debug_seen) {
const char* kPrefix = "--";
const intptr_t kPrefixLen = strlen(kPrefix);
@@ -318,6 +319,10 @@
(strncmp(argv[i], kPrintFlags2, strlen(kPrintFlags2)) == 0)) {
*print_flags_seen = true;
}
+ const char* kVerboseDebug = "--verbose_debug";
+ if (strncmp(argv[i], kVerboseDebug, strlen(kVerboseDebug)) == 0) {
+ *verbose_debug_seen = true;
+ }
vm_options->AddArgument(argv[i]);
i++;
}
@@ -422,19 +427,19 @@
*error = strdup(Dart_GetError(result)); \
Dart_ExitScope(); \
Dart_ShutdownIsolate(); \
- return false; \
+ return NULL; \
} \
// Returns true on success, false on failure.
-static bool CreateIsolateAndSetupHelper(const char* script_uri,
- const char* main,
- void* data,
- char** error) {
+static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
+ const char* main,
+ void* data,
+ char** error) {
Dart_Isolate isolate =
Dart_CreateIsolate(script_uri, main, snapshot_buffer, data, error);
if (isolate == NULL) {
- return false;
+ return NULL;
}
Dart_EnterScope();
@@ -476,17 +481,28 @@
*error = strdup(errbuf);
Dart_ExitScope();
Dart_ShutdownIsolate();
- return false;
+ return NULL;
}
+
+ // Make the isolate runnable so that it is ready to handle messages.
Dart_ExitScope();
+ Dart_ExitIsolate();
+ bool retval = Dart_IsolateMakeRunnable(isolate);
+ if (!retval) {
+ *error = strdup("Invalid isolate state - Unable to make it runnable");
+ Dart_EnterIsolate(isolate);
+ Dart_ShutdownIsolate();
+ return NULL;
+ }
+
VmStats::AddIsolate(reinterpret_cast<IsolateData*>(data), isolate);
- return true;
+ return isolate;
}
-static bool CreateIsolateAndSetup(const char* script_uri,
- const char* main,
- void* data, char** error) {
+static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
+ const char* main,
+ void* data, char** error) {
return CreateIsolateAndSetupHelper(script_uri,
main,
new IsolateData(),
@@ -563,34 +579,20 @@
static Dart_Handle SetBreakpoint(const char* breakpoint_at,
Dart_Handle library) {
- Dart_Handle result;
- if (strchr(breakpoint_at, ':')) {
- char* bpt_line = strdup(breakpoint_at);
- char* colon = strchr(bpt_line, ':');
- ASSERT(colon != NULL);
- *colon = '\0';
- Dart_Handle url = DartUtils::NewString(bpt_line);
- Dart_Handle line_number = Dart_NewInteger(atoi(colon + 1));
- free(bpt_line);
- Dart_Breakpoint bpt;
- result = Dart_SetBreakpointAtLine(url, line_number, &bpt);
+ char* bpt_function = strdup(breakpoint_at);
+ Dart_Handle class_name;
+ Dart_Handle function_name;
+ char* dot = strchr(bpt_function, '.');
+ if (dot == NULL) {
+ class_name = DartUtils::NewString("");
+ function_name = DartUtils::NewString(breakpoint_at);
} else {
- char* bpt_function = strdup(breakpoint_at);
- Dart_Handle class_name;
- Dart_Handle function_name;
- char* dot = strchr(bpt_function, '.');
- if (dot == NULL) {
- class_name = DartUtils::NewString("");
- function_name = DartUtils::NewString(breakpoint_at);
- } else {
- *dot = '\0';
- class_name = DartUtils::NewString(bpt_function);
- function_name = DartUtils::NewString(dot + 1);
- }
- free(bpt_function);
- result = Dart_OneTimeBreakAtEntry(library, class_name, function_name);
+ *dot = '\0';
+ class_name = DartUtils::NewString(bpt_function);
+ function_name = DartUtils::NewString(dot + 1);
}
- return result;
+ free(bpt_function);
+ return Dart_OneTimeBreakAtEntry(library, class_name, function_name);
}
@@ -677,6 +679,7 @@
CommandLineOptions vm_options(argc);
CommandLineOptions dart_options(argc);
bool print_flags_seen = false;
+ bool verbose_debug_seen = false;
// Perform platform specific initialization.
if (!Platform::Initialize()) {
@@ -694,7 +697,8 @@
&executable_name,
&script_name,
&dart_options,
- &print_flags_seen) < 0) {
+ &print_flags_seen,
+ &verbose_debug_seen) < 0) {
if (has_help_option) {
PrintUsage();
return 0;
@@ -728,16 +732,20 @@
if (start_debugger) {
ASSERT(debug_port != 0);
DebuggerConnectionHandler::StartHandler(debug_ip, debug_port);
+ if (verbose_debug_seen) {
+ Log::Print("Debugger initialized\n");
+ }
}
// Call CreateIsolateAndSetup which creates an isolate and loads up
// the specified application script.
char* error = NULL;
char* isolate_name = BuildIsolateName(script_name, "main");
- if (!CreateIsolateAndSetupHelper(script_name,
- "main",
- new IsolateData(),
- &error)) {
+ Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name,
+ "main",
+ new IsolateData(),
+ &error);
+ if (isolate == NULL) {
Log::PrintErr("%s\n", error);
free(error);
delete [] isolate_name;
@@ -745,7 +753,8 @@
}
delete [] isolate_name;
- Dart_Isolate isolate = Dart_CurrentIsolate();
+ Dart_EnterIsolate(isolate);
+ ASSERT(isolate == Dart_CurrentIsolate());
ASSERT(isolate != NULL);
Dart_Handle result;
diff --git a/runtime/bin/process_patch.dart b/runtime/bin/process_patch.dart
index 281259b..64828f5 100644
--- a/runtime/bin/process_patch.dart
+++ b/runtime/bin/process_patch.dart
@@ -90,11 +90,11 @@
}
// stdin going to process.
- _stdin = new _Socket._writePipe();
+ _stdin = new _StdSink(new _Socket._writePipe());
// stdout coming from process.
- _stdout = new _Socket._readPipe();
+ _stdout = new _StdStream(new _Socket._readPipe());
// stderr coming from process.
- _stderr = new _Socket._readPipe();
+ _stderr = new _StdStream(new _Socket._readPipe());
_exitHandler = new _Socket._readPipe();
_ended = false;
_started = false;
@@ -163,9 +163,9 @@
_arguments,
_workingDirectory,
_environment,
- _stdin._nativeSocket,
- _stdout._nativeSocket,
- _stderr._nativeSocket,
+ _stdin._sink._nativeSocket,
+ _stdout._stream._nativeSocket,
+ _stderr._stream._nativeSocket,
_exitHandler._nativeSocket,
status);
if (!success) {
@@ -196,7 +196,7 @@
_ended = true;
_exitCode.complete(exitCode(exitDataBuffer));
// Kill stdin, helping hand if the user forgot to do it.
- _stdin.destroy();
+ _stdin._sink.destroy();
}
exitDataBuffer.setRange(exitDataRead, data.length, data);
@@ -222,17 +222,14 @@
_ProcessStartStatus status) native "Process_Start";
Stream<List<int>> get stdout {
- // TODO(ajohnsen): Get stream object only.
return _stdout;
}
Stream<List<int>> get stderr {
- // TODO(ajohnsen): Get stream object only.
return _stderr;
}
IOSink get stdin {
- // TODO(ajohnsen): Get consumer object only.
return _stdin;
}
@@ -255,9 +252,9 @@
String _workingDirectory;
List<String> _environment;
// Private methods of Socket are used by _in, _out, and _err.
- Socket _stdin;
- Socket _stdout;
- Socket _stderr;
+ _StdSink _stdin;
+ _StdStream _stdout;
+ _StdStream _stderr;
Socket _exitHandler;
bool _ended;
bool _started;
diff --git a/runtime/bin/secure_socket.cc b/runtime/bin/secure_socket.cc
index 0f9140b..e66ff35 100644
--- a/runtime/bin/secure_socket.cc
+++ b/runtime/bin/secure_socket.cc
@@ -17,6 +17,7 @@
#include <prerror.h>
#include <prinit.h>
#include <prnetdb.h>
+#include <secmod.h>
#include <ssl.h>
#include <sslproto.h>
@@ -333,36 +334,57 @@
bad_certificate_callback_ = ThrowIfError(Dart_NewPersistentHandle(callback));
}
+static const char* builtin_roots_module =
+#if defined(TARGET_OS_LINUX) || defined(TARGET_OS_ANDROID)
+ "name=\"Root Certs\" library=\"libnssckbi.so\"";
+#elif defined(TARGET_OS_MACOS)
+ "name=\"Root Certs\" library=\"libnssckbi.dylib\"";
+#elif defined(TARGET_OS_WINDOWS)
+ "name=\"Root Certs\" library=\"nssckbi.dll\"";
+#else
+#error Automatic target os detection failed.
+#endif
+
+
void SSLFilter::InitializeLibrary(const char* certificate_database,
const char* password,
bool use_builtin_root_certificates,
bool report_duplicate_initialization) {
MutexLocker locker(&mutex_);
+ SECStatus status;
if (!library_initialized_) {
password_ = strdup(password); // This one copy persists until Dart exits.
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
// TODO(whesse): Verify there are no UTF-8 issues here.
- PRUint32 init_flags = NSS_INIT_READONLY;
- if (certificate_database == NULL) {
- // Passing the empty string as the database path does not try to open
- // a database in the current directory.
- certificate_database = "";
- // The flag NSS_INIT_NOCERTDB is documented to do what we want here,
- // however it causes the builtins not to be available on Windows.
- init_flags |= NSS_INIT_FORCEOPEN;
- }
- if (!use_builtin_root_certificates) {
- init_flags |= NSS_INIT_NOMODDB;
- }
- SECStatus status = NSS_Initialize(certificate_database,
- "",
- "",
- SECMOD_DB,
- init_flags);
- if (status != SECSuccess) {
- mutex_.Unlock(); // MutexLocker destructor not called when throwing.
- ThrowPRException("Failed NSS_Init call.");
+ if (certificate_database == NULL || certificate_database[0] == '\0') {
+ status = NSS_NoDB_Init(NULL);
+ if (status != SECSuccess) {
+ mutex_.Unlock(); // MutexLocker destructor not called when throwing.
+ ThrowPRException("Failed NSS_NoDB_Init call.");
+ }
+ if (use_builtin_root_certificates) {
+ SECMODModule* module = SECMOD_LoadUserModule(
+ const_cast<char*>(builtin_roots_module), NULL, PR_FALSE);
+ if (!module) {
+ mutex_.Unlock(); // MutexLocker destructor not called when throwing.
+ ThrowPRException("Failed to load builtin root certificates.");
+ }
+ }
+ } else {
+ PRUint32 init_flags = NSS_INIT_READONLY;
+ if (!use_builtin_root_certificates) {
+ init_flags |= NSS_INIT_NOMODDB;
+ }
+ status = NSS_Initialize(certificate_database,
+ "",
+ "",
+ SECMOD_DB,
+ init_flags);
+ if (status != SECSuccess) {
+ mutex_.Unlock(); // MutexLocker destructor not called when throwing.
+ ThrowPRException("Failed NSS_Init call.");
+ }
}
library_initialized_ = true;
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index cb289e8..81e8ab3 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -471,7 +471,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
_resume();
} else {
close();
@@ -598,7 +598,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
_resume();
} else {
close();
@@ -659,7 +659,7 @@
}
-class _SocketStreamConsumer extends StreamConsumer<List<int>, Socket> {
+class _SocketStreamConsumer extends StreamConsumer<List<int>> {
StreamSubscription subscription;
final _Socket socket;
int offset;
@@ -813,9 +813,9 @@
void writeCharCode(int charCode) => _sink.writeCharCode(charCode);
- void writeAll(Iterable objects) => _sink.writeAll(objects);
+ void writeAll(Iterable objects, [sep = ""]) => _sink.writeAll(objects, sep);
- void writeBytes(List<int> bytes) => _sink.writeBytes(bytes);
+ void add(List<int> bytes) => _sink.add(bytes);
Future<Socket> consume(Stream<List<int>> stream) {
return _sink.consume(stream);
@@ -867,7 +867,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
_ensureRawSocketSubscription();
// Enable read events for providing data to subscription.
if (_raw != null) {
diff --git a/runtime/bin/stdio_patch.dart b/runtime/bin/stdio_patch.dart
index 941ae37..cb1c920 100644
--- a/runtime/bin/stdio_patch.dart
+++ b/runtime/bin/stdio_patch.dart
@@ -8,9 +8,9 @@
case _STDIO_HANDLE_TYPE_TERMINAL:
case _STDIO_HANDLE_TYPE_PIPE:
case _STDIO_HANDLE_TYPE_SOCKET:
- return new _Socket._readPipe(0);
+ return new _StdStream(new _Socket._readPipe(0));
case _STDIO_HANDLE_TYPE_FILE:
- return new _FileStream.forStdin();
+ return new _StdStream(new _FileStream.forStdin());
default:
throw new FileIOException("Unsupported stdin type");
}
@@ -22,9 +22,9 @@
case _STDIO_HANDLE_TYPE_TERMINAL:
case _STDIO_HANDLE_TYPE_PIPE:
case _STDIO_HANDLE_TYPE_SOCKET:
- return new _Socket._writePipe(fd);
+ return new _StdSink(new _Socket._writePipe(fd));
case _STDIO_HANDLE_TYPE_FILE:
- return new IOSink(new _FileStreamConsumer.fromStdio(fd));
+ return new _StdSink(new IOSink(new _FileStreamConsumer.fromStdio(fd)));
default:
throw new FileIOException("Unsupported stdin type");
}
diff --git a/runtime/bin/vmstats/bargraph.dart b/runtime/bin/vmstats/bargraph.dart
index c353253..865a5a8 100644
--- a/runtime/bin/vmstats/bargraph.dart
+++ b/runtime/bin/vmstats/bargraph.dart
@@ -38,7 +38,7 @@
void drawBarGraph() {
// Draw chart's outer box.
- var context = _canvas.context2d;
+ var context = _canvas.context2D;
context.beginPath();
context.strokeStyle = 'black';
// The '2's are the width of the line, even though 1 is specified.
@@ -76,7 +76,7 @@
void drawChart(int maxHeight, double scale) {
var dividerHeight = maxHeight ~/ NUM_DIVIDERS;
- var context = _canvas.context2d;
+ var context = _canvas.context2D;
context.beginPath();
var height = maxHeight.toInt();
var scaledY = dividerHeight * scale;
@@ -105,7 +105,7 @@
var y = INSIDE_MARGIN;
var w = _canvas.width - LEFT_MARGIN - RIGHT_MARGIN - INSIDE_MARGIN;
var h = (maxHeight * scale).ceil() - (2 * INSIDE_MARGIN);
- _canvas.context2d.clearRect(x, y, w, h);
+ _canvas.context2D.clearRect(x, y, w, h);
while (iterator.moveNext()) {
Sample s = iterator.current;
@@ -129,7 +129,7 @@
void drawVerticalSegment(int x, int y, int w, int h, String color,
num scale) {
- var context = _canvas.context2d;
+ var context = _canvas.context2D;
y = (y * scale).floor();
h = (h * scale).ceil();
context.beginPath();
diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h
index c9375ca..2ac024a 100755
--- a/runtime/include/dart_api.h
+++ b/runtime/include/dart_api.h
@@ -546,6 +546,20 @@
DART_EXPORT const char* Dart_VersionString();
/**
+ * An isolate is the unit of concurrency in Dart. Each isolate has
+ * its own memory and thread of control. No state is shared between
+ * isolates. Instead, isolates communicate by message passing.
+ *
+ * Each thread keeps track of its current isolate, which is the
+ * isolate which is ready to execute on the current thread. The
+ * current isolate may be NULL, in which case no isolate is ready to
+ * execute. Most of the Dart apis require there to be a current
+ * isolate in order to function without error. The current isolate is
+ * set by any call to Dart_CreateIsolate or Dart_EnterIsolate.
+ */
+typedef struct _Dart_Isolate* Dart_Isolate;
+
+/**
* An isolate creation and initialization callback function.
*
* This callback, provided by the embedder, is called when the vm
@@ -573,18 +587,20 @@
* eventually run. This is provided for advisory purposes only to
* improve debugging messages. The main function is not invoked by
* this function.
+ * \param unhandled_exc The name of the function to this isolate will
+ * call when an unhandled exception is encountered.
* \param callback_data The callback data which was passed to the
* parent isolate when it was created by calling Dart_CreateIsolate().
* \param error A structure into which the embedder can place a
* C string containing an error message in the case of failures.
*
- * \return The embedder returns false if the creation and
- * initialization was not successful and true if successful.
+ * \return The embedder returns NULL if the creation and
+ * initialization was not successful and the isolate if successful.
*/
-typedef bool (*Dart_IsolateCreateCallback)(const char* script_uri,
- const char* main,
- void* callback_data,
- char** error);
+typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri,
+ const char* main,
+ void* callback_data,
+ char** error);
/**
* An isolate interrupt callback function.
@@ -680,20 +696,6 @@
// --- Isolates ---
/**
- * An isolate is the unit of concurrency in Dart. Each isolate has
- * its own memory and thread of control. No state is shared between
- * isolates. Instead, isolates communicate by message passing.
- *
- * Each thread keeps track of its current isolate, which is the
- * isolate which is ready to execute on the current thread. The
- * current isolate may be NULL, in which case no isolate is ready to
- * execute. Most of the Dart apis require there to be a current
- * isolate in order to function without error. The current isolate is
- * set by any call to Dart_CreateIsolate or Dart_EnterIsolate.
- */
-typedef struct _Dart_Isolate* Dart_Isolate;
-
-/**
* Creates a new isolate. The new isolate becomes the current isolate.
*
* A snapshot can be used to restore the VM quickly to a saved state
@@ -827,6 +829,20 @@
*/
DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate);
+
+/**
+ * Make isolate runnable.
+ *
+ * When isolates are spawned this function is used to indicate that
+ * the creation and initialization (including script loading) of the
+ * isolate is complete and the isolate can start.
+ * This function does not expect there to be a current isolate.
+ *
+ * \param isolate The isolate to be made runnable.
+ */
+DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate);
+
+
// --- Messages and Ports ---
/**
diff --git a/runtime/include/dart_debugger_api.h b/runtime/include/dart_debugger_api.h
index 810623d9..1fa5f2d 100755
--- a/runtime/include/dart_debugger_api.h
+++ b/runtime/include/dart_debugger_api.h
@@ -68,22 +68,6 @@
/**
- * DEPRECATED -- use Dart_GetLibraryIds instead.
- *
- * Returns a list of urls (strings) of all the libraries loaded in the
- * current isolate.
- *
- * Requires there to be a current isolate.
- *
- * \return A handle to a list of string handles.
- */
-DART_EXPORT Dart_Handle Dart_GetLibraryURLs();
-// TODO(turnidge): The embedding and debugger apis are not consistent
-// in how they capitalize url. One uses 'Url' and the other 'URL'.
-// They should be the same.
-
-
-/**
* Returns a list of ids (integers) of all the libraries loaded in the
* current isolate.
*
@@ -142,6 +126,28 @@
/**
+ * Returns an array containing line number and token offset info
+ * for the given script.
+ *
+ * Returns an array of numbers. Null values indicate the beginning of
+ * a new line. The first number after null is the line number.
+ * The line number is followed by pairs of numbers, with the first value
+ * being the "token offset" and the second value being the character offset
+ * of the token relative to the beginning of the script.
+ * The "token offset" is a value that is used to indicate a location
+ * in code, similarly to a "PC" address.
+ * Source lines with no tokens are omitted.
+ *
+ * Requires there to be a current isolate.
+ *
+ * \return A handle to an array or an error object.
+ */
+DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(
+ intptr_t library_id,
+ Dart_Handle script_url_in);
+
+
+/**
* Returns a string containing a generated source code of the given script
* in the given library. This is essentially used to pretty print dart code
* generated from any tool (e.g: dart2dart).
@@ -201,41 +207,19 @@
/**
- * DEPRECATED -- use Dart_SetBreakpoint instead.
- *
- * Sets a breakpoint at line \line_number in \script_url, or the closest
- * following line (within the same function) where a breakpoint can be set.
- *
- * Requires there to be a current isolate.
- *
- * \breakpoint If non-null, will point to the breakpoint object
- * if a breakpoint was successfully created.
- *
- * \return A handle to the True object if no error occurs.
- */
-DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine(
- Dart_Handle script_url,
- Dart_Handle line_number,
- Dart_Breakpoint* breakpoint);
-
-
-/**
* Sets a one-time breakpoint at the entry of the given function.
* If class_name is the empty string, looks for a library function
* with the given name.
*
* Requires there to be a current isolate.
*
- * \breakpoint If non-null, will point to the breakpoint object
- * if a breakpoint was successfully created.
- *
- * \return A handle to the True object if no error occurs.
+ * \return A handle containing the breakpoint id, which is an integer
+ * value, or an error object if a breakpoint could not be set.
*/
DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
Dart_Handle library,
Dart_Handle class_name,
- Dart_Handle function_name,
- Dart_Breakpoint* breakpoint);
+ Dart_Handle function_name);
/**
@@ -254,19 +238,6 @@
/**
- * DEPRECATED -- use Dart_RemoveBreakpoint instead.
- *
- * Deletes the given \breakpoint.
- *
- * Requires there to be a current isolate.
- *
- * \return A handle to the True object if no error occurs.
- */
-DART_EXPORT Dart_Handle Dart_DeleteBreakpoint(
- Dart_Breakpoint breakpoint);
-
-
-/**
* Can be called from the breakpoint handler. Sets the debugger to
* single step mode.
*
@@ -434,6 +405,7 @@
DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation(
Dart_ActivationFrame activation_frame,
Dart_Handle* script_url,
+ intptr_t* library_id,
intptr_t* token_number);
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index e92744c..0ee4d08 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -13,7 +13,7 @@
void operator []=(int index, E value) native "ObjectArray_setIndexed";
String toString() {
- return Collections.collectionToString(this);
+ return ToString.iterableToString(this);
}
int get length native "ObjectArray_getLength";
@@ -39,17 +39,6 @@
"Cannot remove element of a non-extendable array");
}
- // Collection interface.
- void removeAll(Iterable elements) {
- throw new UnsupportedError(
- "Cannot remove element of a non-extendable array");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError(
- "Cannot remove element of a non-extendable array");
- }
-
void removeWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot remove element of a non-extendable array");
@@ -60,6 +49,10 @@
"Cannot remove element of a non-extendable array");
}
+ Iterable<E> getRange(int start, [int end]) {
+ return IterableMixinWorkaround.getRangeList(this, start, end);
+ }
+
// List interface.
void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
if (length < 0) {
@@ -94,8 +87,6 @@
return list;
}
- List<E> getRange(int start, int length) => sublist(start, start + length);
-
// Iterable interface.
bool contains(E element) {
@@ -106,7 +97,7 @@
IterableMixinWorkaround.forEach(this, f);
}
- String join([String separator]) {
+ String join([String separator = ""]) {
return IterableMixinWorkaround.joinList(this, separator);
}
@@ -114,8 +105,8 @@
return IterableMixinWorkaround.mapList(this, f);
}
- reduce(initialValue, combine(previousValue, E element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ E reduce(E combine(E value, E element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
fold(initialValue, combine(previousValue, E element)) {
@@ -174,7 +165,7 @@
return this.length == 0;
}
- Iterable<E> get reversed => new ReversedListIterable<E>(this);
+ Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this);
void sort([int compare(E a, E b)]) {
IterableMixinWorkaround.sortList(this, compare);
@@ -234,10 +225,6 @@
throw new StateError("More than one element");
}
- E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare);
-
- E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
-
List<E> toList({ bool growable: true}) {
return new List<E>.from(this, growable: growable);
}
@@ -290,16 +277,6 @@
"Cannot modify an immutable array");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError(
- "Cannot modify an immutable array");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError(
- "Cannot modify an immutable array");
- }
-
void removeWhere(bool test(E element)) {
throw new UnsupportedError(
"Cannot modify an immutable array");
@@ -341,7 +318,9 @@
return list;
}
- List<E> getRange(int start, int length) => sublist(start, start + length);
+ Iterable<E> getRange(int start, int end) {
+ return IterableMixinWorkaround.getRangeList(this, start, end);
+ }
// Collection interface.
@@ -357,12 +336,12 @@
return IterableMixinWorkaround.mapList(this, f);
}
- String join([String separator]) {
+ String join([String separator = ""]) {
return IterableMixinWorkaround.joinList(this, separator);
}
- reduce(initialValue, combine(previousValue, E element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ E reduce(E combine(E value, E element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
fold(initialValue, combine(previousValue, E element)) {
@@ -421,7 +400,7 @@
return this.length == 0;
}
- Iterable<E> get reversed => new ReversedListIterable<E>(this);
+ Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this);
void sort([int compare(E a, E b)]) {
throw new UnsupportedError(
@@ -429,7 +408,7 @@
}
String toString() {
- return Collections.collectionToString(this);
+ return ToString.iterableToString(this);
}
int indexOf(E element, [int start = 0]) {
@@ -486,10 +465,6 @@
throw new StateError("More than one element");
}
- E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare);
-
- E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
-
List<E> toList({ bool growable: true }) {
return new List<E>.from(this, growable: growable);
}
diff --git a/runtime/lib/collection_patch.dart b/runtime/lib/collection_patch.dart
index 2d4881e..8ed2abc 100644
--- a/runtime/lib/collection_patch.dart
+++ b/runtime/lib/collection_patch.dart
@@ -9,7 +9,6 @@
_hashTable._container = this;
}
-
/* patch */ bool containsKey(K key) {
return _hashTable._get(key) >= 0;
}
@@ -189,3 +188,815 @@
_table._clear();
}
}
+
+/**
+ * A hash-based map that iterates keys and values in key insertion order.
+ */
+patch class LinkedHashMap<K, V> {
+ final _LinkedHashMapTable _hashTable;
+
+ /* patch */ LinkedHashMap() : _hashTable = new _LinkedHashMapTable<K, V>() {
+ _hashTable._container = this;
+ }
+
+ /* patch */ bool containsKey(K key) {
+ return _hashTable._get(key) >= 0;
+ }
+
+ /* patch */ bool containsValue(V value) {
+ int modificationCount = _hashTable._modificationCount;
+ for (int offset = _hashTable._next(_LinkedHashTable._HEAD_OFFSET);
+ offset != _LinkedHashTable._HEAD_OFFSET;
+ offset = _hashTable._next(offset)) {
+ if (_hashTable._value(offset) == value) {
+ return true;
+ }
+ // The == call may modify the table.
+ _hashTable._checkModification(modificationCount);
+ }
+ return false;
+ }
+
+ /* patch */ void addAll(Map<K, V> other) {
+ other.forEach((K key, V value) {
+ int offset = _hashTable._put(key);
+ _hashTable._setValue(offset, value);
+ _hashTable._checkCapacity();
+ });
+ }
+
+ /* patch */ V operator [](K key) {
+ int offset = _hashTable._get(key);
+ if (offset >= 0) return _hashTable._value(offset);
+ return null;
+ }
+
+ /* patch */ void operator []=(K key, V value) {
+ int offset = _hashTable._put(key);
+ _hashTable._setValue(offset, value);
+ _hashTable._checkCapacity();
+ }
+
+ /* patch */ V putIfAbsent(K key, V ifAbsent()) {
+ int offset = _hashTable._probeForAdd(_hashTable._hashCodeOf(key), key);
+ Object entry = _hashTable._table[offset];
+ if (!_hashTable._isFree(entry)) {
+ return _hashTable._value(offset);
+ }
+ int modificationCount = _hashTable._modificationCount;
+ V value = ifAbsent();
+ if (modificationCount == _hashTable._modificationCount) {
+ _hashTable._setKey(offset, key);
+ _hashTable._setValue(offset, value);
+ _hashTable._linkLast(offset);
+ if (entry == null) {
+ _hashTable._entryCount++;
+ _hashTable._checkCapacity();
+ } else {
+ assert(identical(entry, _TOMBSTONE));
+ _hashTable._deletedCount--;
+ }
+ _hashTable._recordModification();
+ } else {
+ // The table might have changed, so we can't trust [offset] any more.
+ // Do another lookup before setting the value.
+ offset = _hashTable._put(key);
+ _hashTable._setValue(offset, value);
+ _hashTable._checkCapacity();
+ }
+ return value;
+ }
+
+ /* patch */ V remove(K key) {
+ int offset = _hashTable._remove(key);
+ if (offset < 0) return null;
+ Object oldValue = _hashTable._value(offset);
+ _hashTable._setValue(offset, null);
+ _hashTable._checkCapacity();
+ return oldValue;
+ }
+
+ /* patch */ void clear() {
+ _hashTable._clear();
+ }
+
+ /* patch */ void forEach(void action (K key, V value)) {
+ int modificationCount = _hashTable._modificationCount;
+ for (int offset = _hashTable._next(_LinkedHashTable._HEAD_OFFSET);
+ offset != _LinkedHashTable._HEAD_OFFSET;
+ offset = _hashTable._next(offset)) {
+ action(_hashTable._key(offset), _hashTable._value(offset));
+ _hashTable._checkModification(modificationCount);
+ }
+ }
+
+ /* patch */ Iterable<K> get keys =>
+ new _LinkedHashTableKeyIterable<K>(_hashTable);
+
+ /* patch */ Iterable<V> get values =>
+ new _LinkedHashTableValueIterable<V>(_hashTable,
+ _LinkedHashMapTable._VALUE_INDEX);
+
+ /* patch */ int get length => _hashTable._elementCount;
+
+ /* patch */ bool get isEmpty => _hashTable._elementCount == 0;
+}
+
+patch class LinkedHashSet<E> extends _HashSetBase<E> {
+ static const int _INITIAL_CAPACITY = 8;
+ _LinkedHashTable<E> _table;
+
+ /* patch */ LinkedHashSet() {
+ _table = new _LinkedHashTable(_INITIAL_CAPACITY);
+ _table._container = this;
+ }
+
+ // Iterable.
+ /* patch */ Iterator<E> get iterator {
+ return new _LinkedHashTableKeyIterator<E>(_table);
+ }
+
+ /* patch */ int get length => _table._elementCount;
+
+ /* patch */ bool get isEmpty => _table._elementCount == 0;
+
+ /* patch */ bool contains(Object object) => _table._get(object) >= 0;
+
+ /* patch */ void forEach(void action(E element)) {
+ int offset = _table._next(_LinkedHashTable._HEAD_OFFSET);
+ int modificationCount = _table._modificationCount;
+ while (offset != _LinkedHashTable._HEAD_OFFSET) {
+ E key = _table._key(offset);
+ action(key);
+ _table._checkModification(modificationCount);
+ offset = _table._next(offset);
+ }
+ }
+
+ /* patch */ E get first {
+ int firstOffset = _table._next(_LinkedHashTable._HEAD_OFFSET);
+ if (firstOffset == _LinkedHashTable._HEAD_OFFSET) {
+ throw new StateError("No elements");
+ }
+ return _table._key(firstOffset);
+ }
+
+ /* patch */ E get last {
+ int lastOffset = _table._prev(_LinkedHashTable._HEAD_OFFSET);
+ if (lastOffset == _LinkedHashTable._HEAD_OFFSET) {
+ throw new StateError("No elements");
+ }
+ return _table._key(lastOffset);
+ }
+
+ // Collection.
+ void _filterWhere(bool test(E element), bool removeMatching) {
+ int entrySize = _table._entrySize;
+ int length = _table._table.length;
+ int offset = _table._next(_LinkedHashTable._HEAD_OFFSET);
+ while (offset != _LinkedHashTable._HEAD_OFFSET) {
+ E key = _table._key(offset);
+ int nextOffset = _table._next(offset);
+ int modificationCount = _table._modificationCount;
+ bool shouldRemove = (removeMatching == test(key));
+ _table._checkModification(modificationCount);
+ if (shouldRemove) {
+ _table._deleteEntry(offset);
+ }
+ offset = nextOffset;
+ }
+ _table._checkCapacity();
+ }
+
+ /* patch */ void add(E element) {
+ _table._put(element);
+ _table._checkCapacity();
+ }
+
+ /* patch */ void addAll(Iterable<E> objects) {
+ for (E object in objects) {
+ _table._put(object);
+ _table._checkCapacity();
+ }
+ }
+
+ /* patch */ bool remove(Object object) {
+ int offset = _table._remove(object);
+ if (offset >= 0) {
+ _table._checkCapacity();
+ return true;
+ }
+ return false;
+ }
+
+ /* patch */ void removeAll(Iterable objectsToRemove) {
+ for (Object object in objectsToRemove) {
+ if (_table._remove(object) >= 0) {
+ _table._checkCapacity();
+ }
+ }
+ }
+
+ /* patch */ void removeWhere(bool test(E element)) {
+ _filterWhere(test, true);
+ }
+
+ /* patch */ void retainWhere(bool test(E element)) {
+ _filterWhere(test, false);
+ }
+
+ /* patch */ void clear() {
+ _table._clear();
+ }
+}
+
+class _DeadEntry {
+ const _DeadEntry();
+}
+
+class _NullKey {
+ const _NullKey();
+ int get hashCode => null.hashCode;
+}
+
+const _TOMBSTONE = const _DeadEntry();
+const _NULL = const _NullKey();
+
+class _HashTable<K> {
+ /**
+ * Table of entries with [_entrySize] slots per entry.
+ *
+ * Capacity in entries must be factor of two.
+ */
+ List _table;
+ /** Current capacity. Always equal to [:_table.length ~/ _entrySize:]. */
+ int _capacity;
+ /** Count of occupied entries, including deleted ones. */
+ int _entryCount = 0;
+ /** Count of deleted entries. */
+ int _deletedCount = 0;
+ /** Counter incremented when table is modified. */
+ int _modificationCount = 0;
+ /** If set, used as the source object for [ConcurrentModificationError]s. */
+ Object _container;
+
+ _HashTable(int initialCapacity) : _capacity = initialCapacity {
+ _table = _createTable(initialCapacity);
+ }
+
+ /** Reads key from table. Converts _NULL marker to null. */
+ Object _key(offset) {
+ assert(!_isFree(_table[offset]));
+ Object key = _table[offset];
+ if (!identical(key, _NULL)) return key;
+ return null;
+ }
+
+ /** Writes key to table. Converts null to _NULL marker. */
+ void _setKey(int offset, Object key) {
+ if (key == null) key = _NULL;
+ _table[offset] = key;
+ }
+
+ int get _elementCount => _entryCount - _deletedCount;
+
+ /** Size of each entry. */
+ int get _entrySize => 1;
+
+ void _checkModification(int expectedModificationCount) {
+ if (_modificationCount != expectedModificationCount) {
+ throw new ConcurrentModificationError(_container);
+ }
+ }
+
+ void _recordModification() {
+ // Value cycles after 2^30 modifications. If you keep hold of an
+ // iterator for that long, you might miss a modification detection,
+ // and iteration can go sour. Don't do that.
+ _modificationCount = (_modificationCount + 1) & (0x3FFFFFFF);
+ }
+
+ /**
+ * Create an empty table.
+ */
+ List _createTable(int capacity) {
+ List table = new List(capacity * _entrySize);
+ return table;
+ }
+
+ /** First table probe. */
+ int _firstProbe(int hashCode, int capacity) {
+ return hashCode & (capacity - 1);
+ }
+
+ /** Following table probes. */
+ int _nextProbe(int previousIndex, int probeCount, int capacity) {
+ // When capacity is a power of 2, this probing algorithm (the triangular
+ // number sequence modulo capacity) is guaranteed to hit all indices exactly
+ // once before repeating.
+ return (previousIndex + probeCount) & (capacity - 1);
+ }
+
+ /** Whether an object is a free-marker (either tombstone or free). */
+ bool _isFree(Object marker) =>
+ marker == null || identical(marker, _TOMBSTONE);
+
+ /**
+ * Look up the offset for an object in the table.
+ *
+ * Finds the offset of the object in the table, if it is there,
+ * or the first free offset for its hashCode.
+ */
+ int _probeForAdd(int hashCode, Object object) {
+ int entrySize = _entrySize;
+ int index = _firstProbe(hashCode, _capacity);
+ int firstTombstone = -1;
+ int probeCount = 0;
+ while (true) {
+ int offset = index * entrySize;
+ Object entry = _table[offset];
+ if (identical(entry, _TOMBSTONE)) {
+ if (firstTombstone < 0) firstTombstone = offset;
+ } else if (entry == null) {
+ if (firstTombstone < 0) return offset;
+ return firstTombstone;
+ } else if (identical(_NULL, entry) ? _equals(null, object)
+ : _equals(entry, object)) {
+ return offset;
+ }
+ // The _nextProbe is designed so that it hits
+ // every index eventually.
+ index = _nextProbe(index, ++probeCount, _capacity);
+ }
+ }
+
+ /**
+ * Look up the offset for an object in the table.
+ *
+ * If the object is in the table, its offset is returned.
+ *
+ * If the object is not in the table, Otherwise a negative value is returned.
+ */
+ int _probeForLookup(int hashCode, Object object) {
+ int entrySize = _entrySize;
+ int index = _firstProbe(hashCode, _capacity);
+ int probeCount = 0;
+ while (true) {
+ int offset = index * entrySize;
+ Object entry = _table[offset];
+ if (entry == null) {
+ return -1;
+ } else if (!identical(_TOMBSTONE, entry)) {
+ if (identical(_NULL, entry) ? _equals(null, object)
+ : _equals(entry, object)) {
+ return offset;
+ }
+ }
+ // The _nextProbe is designed so that it hits
+ // every index eventually.
+ index = _nextProbe(index, ++probeCount, _capacity);
+ }
+ }
+
+ // Override the following two to change equality/hashCode computations
+
+ /**
+ * Compare two object for equality.
+ *
+ * The first object is the one already in the table,
+ * and the second is the one being searched for.
+ */
+ bool _equals(Object element, Object other) {
+ return element == other;
+ }
+
+ /**
+ * Compute hash-code for an object.
+ */
+ int _hashCodeOf(Object object) => object.hashCode;
+
+ /**
+ * Ensure that the table isn't too full for its own good.
+ *
+ * Call this after adding an element.
+ */
+ int _checkCapacity() {
+ // Compute everything in multiples of entrySize to avoid division.
+ int freeCount = _capacity - _entryCount;
+ if (freeCount * 4 < _capacity ||
+ freeCount < _deletedCount) {
+ // Less than 25% free or more deleted entries than free entries.
+ _grow(_entryCount - _deletedCount);
+ }
+ }
+
+ void _grow(int contentCount) {
+ int capacity = _capacity;
+ // Don't grow to less than twice the needed capacity.
+ int minCapacity = contentCount * 2;
+ while (capacity < minCapacity) {
+ capacity *= 2;
+ }
+ // Reset to another table and add all existing elements.
+ List oldTable = _table;
+ _table = _createTable(capacity);
+ _capacity = capacity;
+ _entryCount = 0;
+ _deletedCount = 0;
+ _addAllEntries(oldTable);
+ _recordModification();
+ }
+
+ /**
+ * Copies all non-free entries from the old table to the new empty table.
+ */
+ void _addAllEntries(List oldTable) {
+ for (int i = 0; i < oldTable.length; i += _entrySize) {
+ Object object = oldTable[i];
+ if (!_isFree(object)) {
+ int toOffset = _put(object);
+ _copyEntry(oldTable, i, toOffset);
+ }
+ }
+ }
+
+ /**
+ * Copies everything but the key element from one entry to another.
+ *
+ * Called while growing the base array.
+ *
+ * Override this if any non-key fields need copying.
+ */
+ void _copyEntry(List fromTable, int fromOffset, int toOffset) {}
+
+ // The following three methods are for simple get/set/remove operations.
+ // They only affect the key of an entry. The remaining fields must be
+ // filled by the caller.
+
+ /**
+ * Returns the offset of a key in [_table], or negative if it's not there.
+ */
+ int _get(K key) {
+ return _probeForLookup(_hashCodeOf(key), key);
+ }
+
+ /**
+ * Puts the key into the table and returns its offset into [_table].
+ *
+ * If [_entrySize] is greater than 1, the caller should fill the
+ * remaining fields.
+ *
+ * Remember to call [_checkCapacity] after using this method.
+ */
+ int _put(K key) {
+ int offset = _probeForAdd(_hashCodeOf(key), key);
+ Object oldEntry = _table[offset];
+ if (oldEntry == null) {
+ _entryCount++;
+ } else if (identical(oldEntry, _TOMBSTONE)) {
+ _deletedCount--;
+ } else {
+ return offset;
+ }
+ _setKey(offset, key);
+ _recordModification();
+ return offset;
+ }
+
+ /**
+ * Removes a key from the table and returns its offset into [_table].
+ *
+ * Returns null if the key was not in the table.
+ * If [_entrySize] is greater than 1, the caller should clean up the
+ * remaining fields.
+ */
+ int _remove(K key) {
+ int offset = _probeForLookup(_hashCodeOf(key), key);
+ if (offset >= 0) {
+ _deleteEntry(offset);
+ }
+ return offset;
+ }
+
+ /** Clears the table completely, leaving it empty. */
+ void _clear() {
+ if (_elementCount == 0) return;
+ for (int i = 0; i < _table.length; i++) {
+ _table[i] = null;
+ }
+ _entryCount = _deletedCount = 0;
+ _recordModification();
+ }
+
+ /** Clears an entry in the table. */
+ void _deleteEntry(int offset) {
+ assert(!_isFree(_table[offset]));
+ _setKey(offset, _TOMBSTONE);
+ _deletedCount++;
+ _recordModification();
+ }
+}
+
+/**
+ * Generic iterable based on a [_HashTable].
+ */
+abstract class _HashTableIterable<E> extends Iterable<E> {
+ final _HashTable _hashTable;
+ _HashTableIterable(this._hashTable);
+
+ Iterator<E> get iterator;
+
+ /**
+ * Return the iterated value for a given entry.
+ */
+ E _valueAt(int offset, Object key);
+
+ int get length => _hashTable._elementCount;
+
+ bool get isEmpty => _hashTable._elementCount == 0;
+
+ void forEach(void action(E element)) {
+ int entrySize = _hashTable._entrySize;
+ List table = _hashTable._table;
+ int modificationCount = _hashTable._modificationCount;
+ for (int offset = 0; offset < table.length; offset += entrySize) {
+ Object entry = table[offset];
+ if (!_hashTable._isFree(entry)) {
+ E value = _valueAt(offset, entry);
+ action(value);
+ }
+ _hashTable._checkModification(modificationCount);
+ }
+ }
+}
+
+abstract class _HashTableIterator<E> implements Iterator<E> {
+ final _HashTable _hashTable;
+ final int _modificationCount;
+ /** Location right after last found element. */
+ int _offset = 0;
+ E _current = null;
+
+ _HashTableIterator(_HashTable hashTable)
+ : _hashTable = hashTable,
+ _modificationCount = hashTable._modificationCount;
+
+ bool moveNext() {
+ _hashTable._checkModification(_modificationCount);
+
+ List table = _hashTable._table;
+ int entrySize = _hashTable._entrySize;
+
+ while (_offset < table.length) {
+ int currentOffset = _offset;
+ Object entry = table[currentOffset];
+ _offset = currentOffset + entrySize;
+ if (!_hashTable._isFree(entry)) {
+ _current = _valueAt(currentOffset, entry);
+ return true;
+ }
+ }
+ _current = null;
+ return false;
+ }
+
+ E get current => _current;
+
+ E _valueAt(int offset, Object key);
+}
+
+class _HashTableKeyIterable<K> extends _HashTableIterable<K> {
+ _HashTableKeyIterable(_HashTable<K> hashTable) : super(hashTable);
+
+ Iterator<K> get iterator => new _HashTableKeyIterator<K>(_hashTable);
+
+ K _valueAt(int offset, Object key) {
+ if (identical(key, _NULL)) return null;
+ return key;
+ }
+
+ bool contains(Object value) => _hashTable._get(value) >= 0;
+}
+
+class _HashTableKeyIterator<K> extends _HashTableIterator<K> {
+ _HashTableKeyIterator(_HashTable hashTable) : super(hashTable);
+
+ K _valueAt(int offset, Object key) {
+ if (identical(key, _NULL)) return null;
+ return key;
+ }
+}
+
+class _HashTableValueIterable<V> extends _HashTableIterable<V> {
+ final int _entryIndex;
+
+ _HashTableValueIterable(_HashTable hashTable, this._entryIndex)
+ : super(hashTable);
+
+ Iterator<V> get iterator {
+ return new _HashTableValueIterator<V>(_hashTable, _entryIndex);
+ }
+
+ V _valueAt(int offset, Object key) => _hashTable._table[offset + _entryIndex];
+}
+
+class _HashTableValueIterator<V> extends _HashTableIterator<V> {
+ final int _entryIndex;
+
+ _HashTableValueIterator(_HashTable hashTable, this._entryIndex)
+ : super(hashTable);
+
+ V _valueAt(int offset, Object key) => _hashTable._table[offset + _entryIndex];
+}
+
+class _HashMapTable<K, V> extends _HashTable<K> {
+ static const int _INITIAL_CAPACITY = 8;
+ static const int _VALUE_INDEX = 1;
+
+ _HashMapTable() : super(_INITIAL_CAPACITY);
+
+ int get _entrySize => 2;
+
+ V _value(int offset) => _table[offset + _VALUE_INDEX];
+ void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
+
+ _copyEntry(List fromTable, int fromOffset, int toOffset) {
+ _table[toOffset + _VALUE_INDEX] = fromTable[fromOffset + _VALUE_INDEX];
+ }
+}
+
+/** Unique marker object for the head of a linked list of entries. */
+class _LinkedHashTableHeadMarker {
+ const _LinkedHashTableHeadMarker();
+}
+
+const _LinkedHashTableHeadMarker _HEAD_MARKER =
+ const _LinkedHashTableHeadMarker();
+
+class _LinkedHashTable<K> extends _HashTable<K> {
+ static const _NEXT_INDEX = 1;
+ static const _PREV_INDEX = 2;
+ static const _HEAD_OFFSET = 0;
+
+ _LinkedHashTable(int initialCapacity) : super(initialCapacity);
+
+ int get _entrySize => 3;
+
+ List _createTable(int capacity) {
+ List result = new List(capacity * _entrySize);
+ result[_HEAD_OFFSET] = _HEAD_MARKER;
+ result[_HEAD_OFFSET + _NEXT_INDEX] = _HEAD_OFFSET;
+ result[_HEAD_OFFSET + _PREV_INDEX] = _HEAD_OFFSET;
+ return result;
+ }
+
+ int _next(int offset) => _table[offset + _NEXT_INDEX];
+ void _setNext(int offset, int to) { _table[offset + _NEXT_INDEX] = to; }
+
+ int _prev(int offset) => _table[offset + _PREV_INDEX];
+ void _setPrev(int offset, int to) { _table[offset + _PREV_INDEX] = to; }
+
+ void _linkLast(int offset) {
+ // Add entry at offset at end of double-linked list.
+ int last = _prev(_HEAD_OFFSET);
+ _setNext(offset, _HEAD_OFFSET);
+ _setPrev(offset, last);
+ _setNext(last, offset);
+ _setPrev(_HEAD_OFFSET, offset);
+ }
+
+ void _unlink(int offset) {
+ assert(offset != _HEAD_OFFSET);
+ int next = _next(offset);
+ int prev = _prev(offset);
+ _setNext(offset, null);
+ _setPrev(offset, null);
+ _setNext(prev, next);
+ _setPrev(next, prev);
+ }
+
+ /**
+ * Copies all non-free entries from the old table to the new empty table.
+ */
+ void _addAllEntries(List oldTable) {
+ int offset = oldTable[_HEAD_OFFSET + _NEXT_INDEX];
+ while (offset != _HEAD_OFFSET) {
+ Object object = oldTable[offset];
+ int nextOffset = oldTable[offset + _NEXT_INDEX];
+ int toOffset = _put(object);
+ _copyEntry(oldTable, offset, toOffset);
+ offset = nextOffset;
+ }
+ }
+
+ void _clear() {
+ if (_elementCount == 0) return;
+ _setNext(_HEAD_OFFSET, _HEAD_OFFSET);
+ _setPrev(_HEAD_OFFSET, _HEAD_OFFSET);
+ for (int i = _entrySize; i < _table.length; i++) {
+ _table[i] = null;
+ }
+ _entryCount = _deletedCount = 0;
+ _recordModification();
+ }
+
+ int _put(K key) {
+ int offset = _probeForAdd(_hashCodeOf(key), key);
+ Object oldEntry = _table[offset];
+ if (identical(oldEntry, _TOMBSTONE)) {
+ _deletedCount--;
+ } else if (oldEntry == null) {
+ _entryCount++;
+ } else {
+ return offset;
+ }
+ _recordModification();
+ _setKey(offset, key);
+ _linkLast(offset);
+ return offset;
+ }
+
+ void _deleteEntry(int offset) {
+ _unlink(offset);
+ _setKey(offset, _TOMBSTONE);
+ _deletedCount++;
+ _recordModification();
+ }
+}
+
+class _LinkedHashTableKeyIterable<K> extends Iterable<K> {
+ final _LinkedHashTable<K> _table;
+ _LinkedHashTableKeyIterable(this._table);
+ Iterator<K> get iterator => new _LinkedHashTableKeyIterator<K>(_table);
+
+ bool contains(Object value) => _table._get(value) >= 0;
+
+ int get length => _table._elementCount;
+}
+
+class _LinkedHashTableKeyIterator<K> extends _LinkedHashTableIterator<K> {
+ _LinkedHashTableKeyIterator(_LinkedHashTable<K> hashTable): super(hashTable);
+
+ K _getCurrent(int offset) => _hashTable._key(offset);
+}
+
+class _LinkedHashTableValueIterable<V> extends Iterable<V> {
+ final _LinkedHashTable _hashTable;
+ final int _valueIndex;
+ _LinkedHashTableValueIterable(this._hashTable, this._valueIndex);
+ Iterator<V> get iterator =>
+ new _LinkedHashTableValueIterator<V>(_hashTable, _valueIndex);
+ int get length => _hashTable._elementCount;
+}
+
+class _LinkedHashTableValueIterator<V> extends _LinkedHashTableIterator<V> {
+ final int _valueIndex;
+
+ _LinkedHashTableValueIterator(_LinkedHashTable hashTable, this._valueIndex)
+ : super(hashTable);
+
+ V _getCurrent(int offset) => _hashTable._table[offset + _valueIndex];
+}
+
+abstract class _LinkedHashTableIterator<T> implements Iterator<T> {
+ final _LinkedHashTable _hashTable;
+ final int _modificationCount;
+ int _offset;
+ T _current;
+
+ _LinkedHashTableIterator(_LinkedHashTable table)
+ : _hashTable = table,
+ _modificationCount = table._modificationCount,
+ _offset = table._next(_LinkedHashTable._HEAD_OFFSET);
+
+ bool moveNext() {
+ _hashTable._checkModification(_modificationCount);
+ if (_offset == _LinkedHashTable._HEAD_OFFSET) {
+ _current = null;
+ return false;
+ }
+ _current = _getCurrent(_offset);
+ _offset = _hashTable._next(_offset);
+ return true;
+ }
+
+ T _getCurrent(int offset);
+
+ T get current => _current;
+}
+
+class _LinkedHashMapTable<K, V> extends _LinkedHashTable<K> {
+ static const int _INITIAL_CAPACITY = 8;
+ static const int _VALUE_INDEX = 3;
+
+ int get _entrySize => 4;
+
+ _LinkedHashMapTable() : super(_INITIAL_CAPACITY);
+
+ V _value(int offset) => _table[offset + _VALUE_INDEX];
+ void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
+
+ _copyEntry(List oldTable, int fromOffset, int toOffset) {
+ _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX];
+ }
+}
diff --git a/runtime/lib/date_patch.dart b/runtime/lib/date_patch.dart
index b83e96b..c1336c4 100644
--- a/runtime/lib/date_patch.dart
+++ b/runtime/lib/date_patch.dart
@@ -75,8 +75,9 @@
int daysSince1970 =
_flooredDivision(_localDateInUtcMs, Duration.MILLISECONDS_PER_DAY);
// 1970-1-1 was a Thursday.
- return ((daysSince1970 + DateTime.THU - DateTime.MON) % DateTime.DAYS_IN_WEEK) +
- DateTime.MON;
+ return ((daysSince1970 + DateTime.THURSDAY - DateTime.MONDAY)
+ % DateTime.DAYS_IN_WEEK) +
+ DateTime.MONDAY;
}
diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc
index 3fc2261..035b2e6 100644
--- a/runtime/lib/double.cc
+++ b/runtime/lib/double.cc
@@ -221,9 +221,8 @@
}
}
if (dot_ok) {
- char* p_end = NULL;
- const double double_value = strtod(cstr, &p_end);
- if (p_end == (cstr + len)) {
+ double double_value;
+ if (CStringToDouble(cstr, len, &double_value)) {
return Double::New(double_value);
}
}
@@ -238,10 +237,16 @@
Token::kDOUBLE,
&is_positive,
&number_string)) {
+ // Even if original string was two byte string the scanner should produce
+ // literal value that is represented as a one byte string because all
+ // characters in the double literal are Latin-1.
+ ASSERT(number_string->IsOneByteString());
const char* cstr = number_string->ToCString();
- char* p_end = NULL;
- double double_value = strtod(cstr, &p_end);
- ASSERT(p_end != cstr);
+
+ double double_value;
+ bool ok = CStringToDouble(cstr, number_string->Length(), &double_value);
+ ASSERT(ok);
+
if (!is_positive) {
double_value = -double_value;
}
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart
index 753ba1e..76cacb4 100644
--- a/runtime/lib/growable_array.dart
+++ b/runtime/lib/growable_array.dart
@@ -52,14 +52,6 @@
}
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAllList(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
void removeWhere(bool test(T element)) {
IterableMixinWorkaround.removeWhereList(this, test);
}
@@ -69,6 +61,10 @@
(T element) => !test(element));
}
+ Iterable<T> getRange(int start, int end) {
+ return IterableMixinWorkaround.getRangeList(this, start, end);
+ }
+
void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
}
@@ -119,8 +115,6 @@
return list;
}
- List<T> getRange(int start, int length) => sublist(start, start + length);
-
factory _GrowableObjectArray(int length) {
var data = new _ObjectArray((length == 0) ? 4 : length);
var result = new _GrowableObjectArray<T>.withData(data);
@@ -133,7 +127,7 @@
return new _GrowableObjectArray<T>.withData(data);
}
- factory _GrowableObjectArray.from(Collection<T> other) {
+ factory _GrowableObjectArray.from(Iterable<T> other) {
List<T> result = new _GrowableObjectArray<T>();
result.addAll(other);
return result;
@@ -208,10 +202,6 @@
throw new StateError("More than one element");
}
- T min([int compare(T a, T b)]) => IterableMixinWorkaround.min(this, compare);
-
- T max([int compare(T a, T b)]) => IterableMixinWorkaround.max(this, compare);
-
int indexOf(T element, [int start = 0]) {
return IterableMixinWorkaround.indexOfList(this, element, start);
}
@@ -242,11 +232,11 @@
}
}
- String join([String separator]) {
+ String join([String separator = ""]) {
if (isEmpty) return "";
if (this.length == 1) return "${this[0]}";
StringBuffer buffer = new StringBuffer();
- if (separator == null || separator == "") {
+ if (separator.isEmpty) {
for (int i = 0; i < this.length; i++) {
buffer.write("${this[i]}");
}
@@ -264,8 +254,8 @@
return IterableMixinWorkaround.mapList(this, f);
}
- reduce(initialValue, combine(previousValue, T element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ T reduce(T combine(T value, T element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
fold(initialValue, combine(previousValue, T element)) {
@@ -328,14 +318,14 @@
this.length = 0;
}
- Iterable<T> get reversed => new ReversedListIterable<T>(this);
+ Iterable<T> get reversed => IterableMixinWorkaround.reversedList(this);
void sort([int compare(T a, T b)]) {
IterableMixinWorkaround.sortList(this, compare);
}
String toString() {
- return Collections.collectionToString(this);
+ return ToString.iterableToString(this);
}
Iterator<T> get iterator {
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc
index 5282247..e631a3e 100644
--- a/runtime/lib/isolate.cc
+++ b/runtime/lib/isolate.cc
@@ -42,12 +42,6 @@
}
-static void StoreError(Isolate* isolate, const Object& obj) {
- ASSERT(obj.IsError());
- isolate->object_store()->set_sticky_error(Error::Cast(obj));
-}
-
-
// TODO(turnidge): Move to DartLibraryCalls.
static RawObject* ReceivePortCreate(intptr_t port_id) {
Isolate* isolate = Isolate::Current();
@@ -82,37 +76,6 @@
}
-static void ShutdownIsolate(uword parameter) {
- Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
- {
- // Print the error if there is one. This may execute dart code to
- // print the exception object, so we need to use a StartIsolateScope.
- StartIsolateScope start_scope(isolate);
- StackZone zone(isolate);
- HandleScope handle_scope(isolate);
- Error& error = Error::Handle();
- error = isolate->object_store()->sticky_error();
- if (!error.IsNull()) {
- OS::PrintErr("in ShutdownIsolate: %s\n", error.ToErrorCString());
- }
- }
- {
- // Shut the isolate down.
- SwitchIsolateScope switch_scope(isolate);
- Dart::ShutdownIsolate();
- }
-}
-
-
-static char* GetRootScriptUri(Isolate* isolate) {
- const Library& library =
- Library::Handle(isolate->object_store()->root_library());
- ASSERT(!library.IsNull());
- const String& script_name = String::Handle(library.url());
- return isolate->current_zone()->MakeCopyOfString(script_name.ToCString());
-}
-
-
DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) {
ASSERT(AbstractTypeArguments::CheckedHandle(
arguments->NativeArgAt(0)).IsNull());
@@ -202,100 +165,7 @@
}
-class SpawnState {
- public:
- SpawnState(const Function& func, const Function& callback_func)
- : isolate_(NULL),
- script_url_(NULL),
- library_url_(NULL),
- function_name_(NULL),
- exception_callback_name_(NULL) {
- script_url_ = strdup(GetRootScriptUri(Isolate::Current()));
- const Class& cls = Class::Handle(func.Owner());
- ASSERT(cls.IsTopLevel());
- const Library& lib = Library::Handle(cls.library());
- const String& lib_url = String::Handle(lib.url());
- library_url_ = strdup(lib_url.ToCString());
-
- const String& func_name = String::Handle(func.name());
- function_name_ = strdup(func_name.ToCString());
- if (!callback_func.IsNull()) {
- const String& callback_name = String::Handle(callback_func.name());
- exception_callback_name_ = strdup(callback_name.ToCString());
- } else {
- exception_callback_name_ = strdup("_unhandledExceptionCallback");
- }
- }
-
- explicit SpawnState(const char* script_url)
- : isolate_(NULL),
- library_url_(NULL),
- function_name_(NULL),
- exception_callback_name_(NULL) {
- script_url_ = strdup(script_url);
- library_url_ = NULL;
- function_name_ = strdup("main");
- exception_callback_name_ = strdup("_unhandledExceptionCallback");
- }
-
- ~SpawnState() {
- free(script_url_);
- free(library_url_);
- free(function_name_);
- free(exception_callback_name_);
- }
-
- Isolate* isolate() const { return isolate_; }
- void set_isolate(Isolate* value) { isolate_ = value; }
- char* script_url() const { return script_url_; }
- char* library_url() const { return library_url_; }
- char* function_name() const { return function_name_; }
- char* exception_callback_name() const { return exception_callback_name_; }
-
- RawObject* ResolveFunction() {
- // Resolve the library.
- Library& lib = Library::Handle();
- if (library_url()) {
- const String& lib_url = String::Handle(String::New(library_url()));
- lib = Library::LookupLibrary(lib_url);
- if (lib.IsNull() || lib.IsError()) {
- const String& msg = String::Handle(String::NewFormatted(
- "Unable to find library '%s'.", library_url()));
- return LanguageError::New(msg);
- }
- } else {
- lib = isolate()->object_store()->root_library();
- }
- ASSERT(!lib.IsNull());
-
- // Resolve the function.
- const String& func_name =
- String::Handle(String::New(function_name()));
- const Function& func = Function::Handle(lib.LookupLocalFunction(func_name));
- if (func.IsNull()) {
- const String& msg = String::Handle(String::NewFormatted(
- "Unable to resolve function '%s' in library '%s'.",
- function_name(), (library_url() ? library_url() : script_url())));
- return LanguageError::New(msg);
- }
- return func.raw();
- }
-
- void Cleanup() {
- SwitchIsolateScope switch_scope(isolate());
- Dart::ShutdownIsolate();
- }
-
- private:
- Isolate* isolate_;
- char* script_url_;
- char* library_url_;
- char* function_name_;
- char* exception_callback_name_;
-};
-
-
-static bool CreateIsolate(SpawnState* state, char** error) {
+static bool CreateIsolate(IsolateSpawnState* state, char** error) {
Isolate* parent_isolate = Isolate::Current();
Dart_IsolateCreateCallback callback = Isolate::CreateCallback();
@@ -306,87 +176,23 @@
}
void* init_data = parent_isolate->init_callback_data();
- bool retval = (callback)(state->script_url(),
- state->function_name(),
- init_data,
- error);
- if (!retval) {
+ Isolate* child_isolate = reinterpret_cast<Isolate*>(
+ (callback)(state->script_url(),
+ state->function_name(),
+ init_data,
+ error));
+ if (child_isolate == NULL) {
Isolate::SetCurrent(parent_isolate);
return false;
}
-
- Isolate* child_isolate = Isolate::Current();
- ASSERT(child_isolate);
- state->set_isolate(child_isolate);
-
- // Attempt to resolve the entry function now, so that we fail fast
- // in the case that the function cannot be resolved.
- //
- // TODO(turnidge): Revisit this once we have an isolate death api.
- bool resolve_error = false;
- {
- StackZone zone(child_isolate);
- HandleScope handle_scope(child_isolate);
- const Object& result = Object::Handle(state->ResolveFunction());
- if (result.IsError()) {
- Error& errobj = Error::Handle();
- errobj ^= result.raw();
- *error = strdup(errobj.ToErrorCString());
- resolve_error = true;
- } else {
- const String& callback_name =
- String::Handle(child_isolate,
- String::New(state->exception_callback_name()));
- child_isolate->object_store()->
- set_unhandled_exception_handler(callback_name);
- }
- }
- if (resolve_error) {
- Dart::ShutdownIsolate();
- Isolate::SetCurrent(parent_isolate);
- return false;
- }
+ state->set_isolate(reinterpret_cast<Isolate*>(child_isolate));
Isolate::SetCurrent(parent_isolate);
return true;
}
-static bool RunIsolate(uword parameter) {
- Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
- SpawnState* state = reinterpret_cast<SpawnState*>(isolate->spawn_data());
- isolate->set_spawn_data(0);
- {
- StartIsolateScope start_scope(isolate);
- StackZone zone(isolate);
- HandleScope handle_scope(isolate);
- if (!ClassFinalizer::FinalizePendingClasses()) {
- // Error is in sticky error already.
- return false;
- }
-
- Object& result = Object::Handle();
- result = state->ResolveFunction();
- delete state;
- state = NULL;
- if (result.IsError()) {
- StoreError(isolate, result);
- return false;
- }
- ASSERT(result.IsFunction());
- Function& func = Function::Handle(isolate);
- func ^= result.raw();
- result = DartEntry::InvokeFunction(func, Object::empty_array());
- if (result.IsError()) {
- StoreError(isolate, result);
- return false;
- }
- }
- return true;
-}
-
-
-static RawObject* Spawn(NativeArguments* arguments, SpawnState* state) {
+static RawObject* Spawn(NativeArguments* arguments, IsolateSpawnState* state) {
// Create a new isolate.
char* error = NULL;
if (!CreateIsolate(state, &error)) {
@@ -405,11 +211,12 @@
Exceptions::PropagateError(Error::Cast(port));
}
- // Start the new isolate.
+ // Start the new isolate if it is already marked as runnable.
+ MutexLocker ml(state->isolate()->mutex());
state->isolate()->set_spawn_data(reinterpret_cast<uword>(state));
- state->isolate()->message_handler()->Run(
- Dart::thread_pool(), RunIsolate, ShutdownIsolate,
- reinterpret_cast<uword>(state->isolate()));
+ if (state->isolate()->is_runnable()) {
+ state->isolate()->Run();
+ }
return port.raw();
}
@@ -464,7 +271,7 @@
}
#endif
- return Spawn(arguments, new SpawnState(func, callback_func));
+ return Spawn(arguments, new IsolateSpawnState(func, callback_func));
}
@@ -482,7 +289,7 @@
ThrowIsolateSpawnException(msg);
}
- return Spawn(arguments, new SpawnState(canonical_uri));
+ return Spawn(arguments, new IsolateSpawnState(canonical_uri));
}
diff --git a/runtime/lib/lib_sources.gypi b/runtime/lib/lib_sources.gypi
index d3efd48..7f1c37a 100644
--- a/runtime/lib/lib_sources.gypi
+++ b/runtime/lib/lib_sources.gypi
@@ -50,6 +50,7 @@
'string.cc',
'string_patch.dart',
'string_buffer_patch.dart',
+ 'symbol_patch.dart',
'type_patch.dart',
'weak_property.dart',
'weak_property.cc',
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index fce7051..c76e5e3 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -833,17 +833,23 @@
// TODO(turnidge): This should be an immutable map.
Dart_Handle map = MapNew();
- Dart_Handle lib_urls = Dart_GetLibraryURLs();
- if (Dart_IsError(lib_urls)) {
- return lib_urls;
+ Dart_Handle lib_ids = Dart_GetLibraryIds();
+ if (Dart_IsError(lib_ids)) {
+ return lib_ids;
}
intptr_t len;
- Dart_Handle result = Dart_ListLength(lib_urls, &len);
+ Dart_Handle result = Dart_ListLength(lib_ids, &len);
if (Dart_IsError(result)) {
return result;
}
for (intptr_t i = 0; i < len; i++) {
- Dart_Handle lib_url = Dart_ListGetAt(lib_urls, i);
+ Dart_Handle lib_id = Dart_ListGetAt(lib_ids, i);
+ int64_t id64;
+ Dart_IntegerToInt64(lib_id, &id64);
+ Dart_Handle lib_url = Dart_GetLibraryURL(id64);
+ if (Dart_IsError(lib_url)) {
+ return lib_url;
+ }
Dart_Handle lib = Dart_LookupLibrary(lib_url);
if (Dart_IsError(lib)) {
return lib;
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index 43f511c..6588649 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -139,10 +139,10 @@
abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl
implements ObjectMirror {
_LocalObjectMirrorImpl(ref) : super(ref) {}
-
- Future<InstanceMirror> invoke(String memberName,
- List positionalArguments,
- [Map<String,dynamic> namedArguments]) {
+
+Future<InstanceMirror> invokeAsync(String memberName,
+ List positionalArguments,
+ [Map<String,dynamic> namedArguments]) {
if (namedArguments != null) {
throw new UnimplementedError(
'named argument support is not implemented');
@@ -162,8 +162,7 @@
return completer.future;
}
- Future<InstanceMirror> getField(String fieldName)
- {
+ Future<InstanceMirror> getFieldAsync(String fieldName) {
Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
try {
completer.complete(_getField(this, fieldName));
@@ -173,8 +172,7 @@
return completer.future;
}
- Future<InstanceMirror> setField(String fieldName, Object arg)
- {
+ Future<InstanceMirror> setFieldAsync(String fieldName, Object arg) {
_validateArgument(0, arg);
Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
@@ -305,8 +303,8 @@
'ClosureMirror.source is not implemented');
}
- Future<InstanceMirror> apply(List<Object> positionalArguments,
- [Map<String,Object> namedArguments]) {
+ Future<InstanceMirror> applyAsync(List<Object> positionalArguments,
+ [Map<String,Object> namedArguments]) {
if (namedArguments != null) {
throw new UnimplementedError(
'named argument support is not implemented');
@@ -501,9 +499,9 @@
String toString() => "ClassMirror on '$simpleName'";
- Future<InstanceMirror> newInstance(String constructorName,
- List positionalArguments,
- [Map<String,dynamic> namedArguments]) {
+ Future<InstanceMirror> newInstanceAsync(String constructorName,
+ List positionalArguments,
+ [Map<String,dynamic> namedArguments]) {
if (namedArguments != null) {
throw new UnimplementedError(
'named argument support is not implemented');
@@ -970,4 +968,8 @@
static InstanceMirror reflect(Object reflectee) {
return makeLocalInstanceMirror(reflectee);
}
+
+ static ClassMirror reflectClass(Type reflectee) {
+ throw new UnimplementedError('reflectClass is not implemented');
+ }
}
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
index 1ba5e1a..43101b0 100644
--- a/runtime/lib/string_patch.dart
+++ b/runtime/lib/string_patch.dart
@@ -417,7 +417,7 @@
return result;
}
- List<int> get codeUnits => new CodeUnits(this);
+ List<int> get codeUnits => new _CodeUnits(this);
Runes get runes => new Runes(this);
@@ -613,3 +613,17 @@
final String str;
final String pattern;
}
+
+/**
+ * An [Iterable] of the UTF-16 code units of a [String] in index order.
+ */
+class _CodeUnits extends Object with ListMixin<int>,
+ UnmodifiableListMixin<int> {
+ /** The string that this is the code units of. */
+ String _string;
+
+ _CodeUnits(this._string);
+
+ int get length => _string.length;
+ int operator[](int i) => _string.codeUnitAt(i);
+}
diff --git a/runtime/lib/symbol_patch.dart b/runtime/lib/symbol_patch.dart
new file mode 100644
index 0000000..6771348
--- /dev/null
+++ b/runtime/lib/symbol_patch.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+patch class Symbol {
+ final String _name;
+ /* patch */ const Symbol(String name)
+ : this._name = _validate(name);
+
+
+ static final RegExp _validationPattern =
+ new RegExp(r'^[a-zA-Z$][a-zA-Z$0-9_]*=?');
+
+ static _validate(String name) {
+ if (name is! String) throw new ArgumentError('name must be a String');
+ if (name.isEmpty) return;
+ if (name.startsWith('_')) {
+ throw new ArgumentError('"$name" is a private identifier');
+ }
+ if (!_validationPattern.hasMatch(name)) {
+ throw new ArgumentError(
+ '"$name" is not an identifier or an empty String');
+ }
+ return name;
+ }
+
+ /* patch */ bool operator ==(other) {
+ return other is Symbol && _name == other._name;
+ }
+
+ /* patch */ int get hashCode {
+ const arbitraryPrime = 664597;
+ return 0x1fffffff & (arbitraryPrime * _name.hashCode);
+ }
+}
diff --git a/runtime/lib/typeddata.dart b/runtime/lib/typeddata.dart
index 244948c..75f81a7 100644
--- a/runtime/lib/typeddata.dart
+++ b/runtime/lib/typeddata.dart
@@ -13,6 +13,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Int8List.fromList(List<int> elements) {
+ var result = new _Int8Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Int8List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Int8ArrayView(buffer, offsetInBytes, length);
@@ -33,6 +39,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Uint8List.fromList(List<int> elements) {
+ var result = new _Uint8Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Uint8List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Uint8ArrayView(buffer, offsetInBytes, length);
@@ -53,6 +65,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Uint8ClampedList.fromList(List<int> elements) {
+ var result = new _Uint8ClampedArray(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Uint8ClampedList.view(ByteBuffer buffer,
[int offsetInBytes = 0,
int length]) {
@@ -74,6 +92,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Int16List.fromList(List<int> elements) {
+ var result = new _Int16Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Int16List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Int16ArrayView(buffer, offsetInBytes, length);
@@ -94,6 +118,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Uint16List.fromList(List<int> elements) {
+ var result = new _Uint16Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Uint16List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Uint16ArrayView(buffer, offsetInBytes, length);
@@ -114,6 +144,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Int32List.fromList(List<int> elements) {
+ var result = new _Int32Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Int32List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Int32ArrayView(buffer, offsetInBytes, length);
@@ -134,6 +170,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Uint32List.fromList(List<int> elements) {
+ var result = new _Uint32Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Uint32List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Uint32ArrayView(buffer, offsetInBytes, length);
@@ -154,6 +196,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Int64List.fromList(List<int> elements) {
+ var result = new _Int64Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Int64List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Int64ArrayView(buffer, offsetInBytes, length);
@@ -174,6 +222,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Uint64List.fromList(List<int> elements) {
+ var result = new _Uint64Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Uint64List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Uint64ArrayView(buffer, offsetInBytes, length);
@@ -194,6 +248,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Float32List.fromList(List<double> elements) {
+ var result = new _Float32Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Float32List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Float32ArrayView(buffer, offsetInBytes, length);
@@ -214,6 +274,12 @@
return _newTransferable(length);
}
+ /* patch */ factory Float64List.fromList(List<double> elements) {
+ var result = new _Float64Array(elements.length);
+ for (int i = 0; i < elements.length; i++) result[i] = elements[i];
+ return result;
+ }
+
/* patch */ factory Float64List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
return new _Float64ArrayView(buffer, offsetInBytes, length);
@@ -303,13 +369,12 @@
return IterableMixinWorkaround.mapList(this, f);
}
- String join([String separator]) {
+ String join([String separator = ""]) {
return IterableMixinWorkaround.join(this, separator);
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic initialValue, element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ dynamic reduce(dynamic combine(value, element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
dynamic fold(dynamic initialValue,
@@ -450,12 +515,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void removeRange(int start, int length) {
throw new UnsupportedError(
"Cannot remove from a non-extendable array");
@@ -483,8 +542,8 @@
return result;
}
- List getRange(int start, int length) {
- return sublist(start, start + length);
+ Iterable getRange(int start, [int end]) {
+ return IterableMixinWorkaround.getRangeList(this, start, end);
}
void setRange(int start, int length, List from, [int startFrom = 0]) {
@@ -498,7 +557,7 @@
// Method(s) implementing Object interface.
String toString() {
- return Collections.collectionToString(this);
+ return ToString.iterableToString(this);
}
diff --git a/runtime/tests/vm/dart/byte_array_optimized_test.dart b/runtime/tests/vm/dart/byte_array_optimized_test.dart
index 8713ecb..ca3f9e5 100644
--- a/runtime/tests/vm/dart/byte_array_optimized_test.dart
+++ b/runtime/tests/vm/dart/byte_array_optimized_test.dart
@@ -5,6 +5,7 @@
// Library tag to be able to run in html test framework.
library byte_array_test;
+import "package:expect/expect.dart";
import 'dart:typeddata';
// This test exercises optimized [] and []= operators
diff --git a/runtime/tests/vm/dart/byte_array_test.dart b/runtime/tests/vm/dart/byte_array_test.dart
index f4ede60..388e1bb 100644
--- a/runtime/tests/vm/dart/byte_array_test.dart
+++ b/runtime/tests/vm/dart/byte_array_test.dart
@@ -5,6 +5,7 @@
// Library tag to be able to run in html test framework.
library byte_array_test;
+import "package:expect/expect.dart";
import 'dart:typeddata';
class ByteArrayTest {
diff --git a/runtime/tests/vm/dart/inline_stack_frame_test.dart b/runtime/tests/vm/dart/inline_stack_frame_test.dart
index 64e24c7..f8592ac 100644
--- a/runtime/tests/vm/dart/inline_stack_frame_test.dart
+++ b/runtime/tests/vm/dart/inline_stack_frame_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This test tries to verify that we produce the correct stack trace when
// throwing exceptions even when functions are inlined.
// The test invokes a bunch of functions and then does a throw. There is a
diff --git a/runtime/tests/vm/dart/isolate_mirror_local_test.dart b/runtime/tests/vm/dart/isolate_mirror_local_test.dart
index 5d2e687..e72f5a1 100644
--- a/runtime/tests/vm/dart/isolate_mirror_local_test.dart
+++ b/runtime/tests/vm/dart/isolate_mirror_local_test.dart
@@ -9,6 +9,7 @@
library isolate_mirror_local_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
import 'dart:mirrors';
@@ -116,7 +117,7 @@
// Test library invocation by calling function(123).
Expect.equals(0, global_var);
- lib_mirror.invoke('function', [ 123 ]).then(
+ lib_mirror.invokeAsync('function', [123]).then(
(InstanceMirror retval) {
Expect.equals(123, global_var);
Expect.equals('int', retval.type.simpleName);
@@ -307,7 +308,7 @@
Expect.equals('Object', list_intf.superclass.simpleName);
Expect.equals('dart.core', list_intf.owner.simpleName);
Expect.isTrue(list_intf.isClass);
- Expect.equals('Collection', list_intf.superinterfaces[0].simpleName);
+ Expect.equals('Iterable', list_intf.superinterfaces[0].simpleName);
Expect.equals("ClassMirror on 'List'", list_intf.toString());
// Lookup a class from a library and make sure it is sane.
@@ -342,7 +343,7 @@
Expect.equals("InstanceMirror on <1001>", mirror.toString());
// Invoke (mirror + mirror).
- mirror.invoke('+', [ mirror ]).then(
+ mirror.invokeAsync('+', [ mirror ]).then(
(InstanceMirror retval) {
Expect.equals('int', retval.type.simpleName);
Expect.isTrue(retval.hasReflectee);
@@ -359,7 +360,7 @@
mirror.toString());
// Invoke mirror[0].
- mirror.invoke('[]', [ 0 ]).then(
+ mirror.invokeAsync('[]', [ 0 ]).then(
(InstanceMirror retval) {
Expect.equals('String', retval.type.simpleName);
Expect.isTrue(retval.hasReflectee);
@@ -431,7 +432,7 @@
cls.toString());
// Invoke mirror.method(1000).
- mirror.invoke('method', [ 1000 ]).then(
+ mirror.invokeAsync('method', [ 1000 ]).then(
(InstanceMirror retval) {
Expect.equals('int', retval.type.simpleName);
Expect.isTrue(retval.hasReflectee);
@@ -459,7 +460,7 @@
void testMirrorErrors(MirrorSystem mirrors) {
LibraryMirror lib_mirror = mirrors.isolate.rootLibrary;
- lib_mirror.invoke('methodWithException', [])
+ lib_mirror.invokeAsync('methodWithException', [])
.then((InstanceMirror retval) {
// Should not reach here.
Expect.isTrue(false);
@@ -475,7 +476,7 @@
testDone('testMirrorErrors1');
});
- lib_mirror.invoke('methodWithError', [])
+ lib_mirror.invokeAsync('methodWithError', [])
.then((InstanceMirror retval) {
// Should not reach here.
Expect.isTrue(false);
@@ -489,7 +490,7 @@
// TODO(turnidge): When we call a method that doesn't exist, we
// should probably call noSuchMethod(). I'm adding this test to
// document the current behavior in the meantime.
- lib_mirror.invoke('methodNotFound', [])
+ lib_mirror.invokeAsync('methodNotFound', [])
.then((InstanceMirror retval) {
// Should not reach here.
Expect.isTrue(false);
diff --git a/runtime/tests/vm/dart/isolate_mirror_remote_test.dart b/runtime/tests/vm/dart/isolate_mirror_remote_test.dart
index 1be85fc..f3fff3a 100644
--- a/runtime/tests/vm/dart/isolate_mirror_remote_test.dart
+++ b/runtime/tests/vm/dart/isolate_mirror_remote_test.dart
@@ -7,6 +7,7 @@
library isolate_mirror_local_test;
+import "package:expect/expect.dart";
import 'dart:isolate';
import 'dart:mirrors';
diff --git a/runtime/tests/vm/dart/isolate_unhandled_exception_test.dart b/runtime/tests/vm/dart/isolate_unhandled_exception_test.dart
index 68d2002..f7b0c04 100644
--- a/runtime/tests/vm/dart/isolate_unhandled_exception_test.dart
+++ b/runtime/tests/vm/dart/isolate_unhandled_exception_test.dart
@@ -4,6 +4,7 @@
library isolate_unhandled_exception_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/runtime/tests/vm/dart/isolate_unhandled_exception_uri_test.dart b/runtime/tests/vm/dart/isolate_unhandled_exception_uri_test.dart
index 6446ded..e3b9ebc 100644
--- a/runtime/tests/vm/dart/isolate_unhandled_exception_uri_test.dart
+++ b/runtime/tests/vm/dart/isolate_unhandled_exception_uri_test.dart
@@ -4,6 +4,7 @@
library isolate_unhandled_exception_uri_helper;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/runtime/tests/vm/dart/optimized_stacktrace_test.dart b/runtime/tests/vm/dart/optimized_stacktrace_test.dart
index c3e24ba..40413c5 100644
--- a/runtime/tests/vm/dart/optimized_stacktrace_test.dart
+++ b/runtime/tests/vm/dart/optimized_stacktrace_test.dart
@@ -1,8 +1,8 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-
// Test correct source positions in stack trace with optimized functions.
+import "package:expect/expect.dart";
// (1) Test normal exception.
foo(x) => bar(x);
diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status
index 1939598..45afdd9 100644
--- a/runtime/tests/vm/vm.status
+++ b/runtime/tests/vm/vm.status
@@ -40,9 +40,10 @@
# The source positions do not match with dart2js.
dart/optimized_stacktrace_test: Fail
-[ $compiler == dart2js && $minified ]
-# Methods in stack traces are renamed.
-dart/inline_stack_frame_test: Fail # Issue 7953.
+[ $compiler == dart2js ]
+# Methods can be missing in dart2js stack traces due to inlining. Also when
+# minifying they can be renamed, which is issue 7953.
+dart/inline_stack_frame_test: Fail
[ $runtime == ff || $runtime == ie9 ]
dart/inline_stack_frame_test: Skip
@@ -69,7 +70,6 @@
[ $arch == simmips ]
# Tests needing an assembler.
cc/Dart2JSCompileAll: Skip
-cc/FrameLookup: Skip
cc/UseDartApi: Skip
# Tests needing Dart execution.
dart/*: Skip
diff --git a/runtime/tools/create_snapshot_bin.py b/runtime/tools/create_snapshot_bin.py
index a6bb324..c80df4d 100755
--- a/runtime/tools/create_snapshot_bin.py
+++ b/runtime/tools/create_snapshot_bin.py
@@ -150,7 +150,7 @@
return 1
# Setup arguments to the snapshot generator binary.
- script_args = []
+ script_args = ["--error_on_malformed_type"]
# First setup the snapshot output filename.
script_args.append(''.join([ "--snapshot=", options.output_bin ]))
diff --git a/runtime/vm/assembler_arm.cc b/runtime/vm/assembler_arm.cc
index a698ada..3c6f644 100644
--- a/runtime/vm/assembler_arm.cc
+++ b/runtime/vm/assembler_arm.cc
@@ -1296,6 +1296,85 @@
}
+// Preserves object and value registers.
+void Assembler::StoreIntoObjectFilterNoSmi(Register object,
+ Register value,
+ Label* no_update) {
+ COMPILE_ASSERT((kNewObjectAlignmentOffset == kWordSize) &&
+ (kOldObjectAlignmentOffset == 0), young_alignment);
+
+ // Write-barrier triggers if the value is in the new space (has bit set) and
+ // the object is in the old space (has bit cleared).
+ // To check that, we compute value & ~object and skip the write barrier
+ // if the bit is not set. We can't destroy the object.
+ bic(IP, value, ShifterOperand(object));
+ tst(IP, ShifterOperand(kNewObjectAlignmentOffset));
+ b(no_update, EQ);
+}
+
+
+// Preserves object and value registers.
+void Assembler::StoreIntoObjectFilter(Register object,
+ Register value,
+ Label* no_update) {
+ // For the value we are only interested in the new/old bit and the tag bit.
+ // And the new bit with the tag bit. The resulting bit will be 0 for a Smi.
+ and_(IP, value, ShifterOperand(value, LSL, kObjectAlignmentLog2 - 1));
+ // And the result with the negated space bit of the object.
+ bic(IP, IP, ShifterOperand(object));
+ tst(IP, ShifterOperand(kNewObjectAlignmentOffset));
+ b(no_update, EQ);
+}
+
+
+void Assembler::StoreIntoObject(Register object,
+ const Address& dest,
+ Register value,
+ bool can_value_be_smi) {
+ ASSERT(object != value);
+ str(value, dest);
+ Label done;
+ if (can_value_be_smi) {
+ StoreIntoObjectFilter(object, value, &done);
+ } else {
+ StoreIntoObjectFilterNoSmi(object, value, &done);
+ }
+ // A store buffer update is required.
+ if (value != R0) Push(R0); // Preserve R0.
+ if (object != R0) {
+ mov(R0, ShifterOperand(object));
+ }
+ BranchLink(&StubCode::UpdateStoreBufferLabel());
+ if (value != R0) Pop(R0); // Restore R0.
+ Bind(&done);
+}
+
+
+void Assembler::StoreIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ Register value) {
+ str(value, dest);
+#if defined(DEBUG)
+ Label done;
+ StoreIntoObjectFilter(object, value, &done);
+ Stop("Store buffer update is required");
+ Bind(&done);
+#endif // defined(DEBUG)
+ // No store buffer update.
+}
+
+
+void Assembler::StoreIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ const Object& value) {
+ ASSERT(value.IsSmi() || value.InVMHeap() ||
+ (value.IsOld() && value.IsNotTemporaryScopedHandle()));
+ // No store buffer update.
+ LoadObject(IP, value);
+ str(IP, dest);
+}
+
+
void Assembler::LoadClassId(Register result, Register object) {
ASSERT(RawObject::kClassIdTagBit == 16);
ASSERT(RawObject::kClassIdTagSize == 16);
diff --git a/runtime/vm/assembler_arm.h b/runtime/vm/assembler_arm.h
index c5a2940..724652b 100644
--- a/runtime/vm/assembler_arm.h
+++ b/runtime/vm/assembler_arm.h
@@ -554,6 +554,18 @@
void PushObject(const Object& object);
void CompareObject(Register rn, const Object& object);
+ void StoreIntoObject(Register object, // Object we are storing into.
+ const Address& dest, // Where we are storing into.
+ Register value, // Value we are storing.
+ bool can_value_be_smi = true);
+
+ void StoreIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ Register value);
+ void StoreIntoObjectNoBarrier(Register object,
+ const Address& dest,
+ const Object& value);
+
void LoadClassId(Register result, Register object);
void LoadClassById(Register result, Register class_id);
void LoadClass(Register result, Register object, Register scratch);
@@ -772,10 +784,12 @@
int32_t EncodeTstOffset(int32_t offset, int32_t inst);
int DecodeTstOffset(int32_t inst);
- // Returns whether or not the given register is used for passing parameters.
- static int RegisterCompare(const Register* reg1, const Register* reg2) {
- return *reg1 - *reg2;
- }
+ void StoreIntoObjectFilter(Register object, Register value, Label* no_update);
+
+ // Shorter filtering sequence that assumes that value is not a smi.
+ void StoreIntoObjectFilterNoSmi(Register object,
+ Register value,
+ Label* no_update);
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(Assembler);
diff --git a/runtime/vm/assembler_arm_test.cc b/runtime/vm/assembler_arm_test.cc
index fa47c7f..93955a80 100644
--- a/runtime/vm/assembler_arm_test.cc
+++ b/runtime/vm/assembler_arm_test.cc
@@ -1536,6 +1536,21 @@
}
+// Called from assembler_test.cc.
+// LR: return address.
+// R0: context.
+// R1: value.
+// R2: growable array.
+ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
+ __ PushList((1 << CTX) | (1 << LR));
+ __ mov(CTX, ShifterOperand(R0));
+ __ StoreIntoObject(R2,
+ FieldAddress(R2, GrowableObjectArray::data_offset()),
+ R1);
+ __ PopList((1 << CTX) | (1 << LR));
+ __ Ret();
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_ARM
diff --git a/runtime/vm/assembler_ia32.cc b/runtime/vm/assembler_ia32.cc
index 3359f46..f293cb9 100644
--- a/runtime/vm/assembler_ia32.cc
+++ b/runtime/vm/assembler_ia32.cc
@@ -165,6 +165,14 @@
}
+void Assembler::setcc(Condition condition, ByteRegister dst) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x0F);
+ EmitUint8(0x90 + condition);
+ EmitUint8(0xC0 + dst);
+}
+
+
void Assembler::movl(Register dst, const Immediate& imm) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0xB8 + dst);
@@ -322,6 +330,13 @@
}
+void Assembler::rep_movsb() {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0xF3);
+ EmitUint8(0xA4);
+}
+
+
void Assembler::movss(XmmRegister dst, const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitUint8(0xF3);
diff --git a/runtime/vm/assembler_ia32.h b/runtime/vm/assembler_ia32.h
index d147296..4ed8c0e 100644
--- a/runtime/vm/assembler_ia32.h
+++ b/runtime/vm/assembler_ia32.h
@@ -329,6 +329,8 @@
void pushal();
void popal();
+ void setcc(Condition condition, ByteRegister dst);
+
void movl(Register dst, const Immediate& src);
void movl(Register dst, Register src);
@@ -356,6 +358,8 @@
void cmovs(Register dst, Register src);
void cmovns(Register dst, Register src);
+ void rep_movsb();
+
void movss(XmmRegister dst, const Address& src);
void movss(const Address& dst, XmmRegister src);
void movss(XmmRegister dst, XmmRegister src);
@@ -605,6 +609,7 @@
void Drop(intptr_t stack_elements);
void LoadObject(Register dst, const Object& object);
+
void PushObject(const Object& object);
void CompareObject(Register reg, const Object& object);
void LoadDoubleConstant(XmmRegister dst, double value);
diff --git a/runtime/vm/assembler_ia32_test.cc b/runtime/vm/assembler_ia32_test.cc
index 7933061..bada450 100644
--- a/runtime/vm/assembler_ia32_test.cc
+++ b/runtime/vm/assembler_ia32_test.cc
@@ -2426,6 +2426,21 @@
}
+ASSEMBLER_TEST_GENERATE(TestSetCC, assembler) {
+ __ movl(EAX, Immediate(0xFFFFFFFF));
+ __ cmpl(EAX, EAX);
+ __ setcc(NOT_EQUAL, AL);
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(TestSetCC, test) {
+ typedef uword (*TestSetCC)();
+ uword res = reinterpret_cast<TestSetCC>(test->entry())();
+ EXPECT_EQ(0xFFFFFF00, res);
+}
+
+
ASSEMBLER_TEST_GENERATE(TestNop, assembler) {
__ nop(1);
__ nop(2);
@@ -2506,6 +2521,35 @@
}
+ASSEMBLER_TEST_GENERATE(TestRepMovsBytes, assembler) {
+ // Preserve registers.
+ __ pushl(ESI);
+ __ pushl(EDI);
+ __ pushl(ECX);
+ __ movl(ESI, Address(ESP, 4 * kWordSize)); // from.
+ __ movl(EDI, Address(ESP, 5 * kWordSize)); // to.
+ __ movl(ECX, Address(ESP, 6 * kWordSize)); // count.
+ __ rep_movsb();
+ __ popl(ECX);
+ __ popl(EDI);
+ __ popl(ESI);
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(TestRepMovsBytes, test) {
+ const char* from = "0123456789";
+ const char* to = new char[10];
+ typedef void (*TestRepMovsBytes)(const char* from, const char* to, int count);
+ reinterpret_cast<TestRepMovsBytes>(test->entry())(from, to, 10);
+ EXPECT_EQ(to[0], '0');
+ for (int i = 0; i < 10; i++) {
+ EXPECT_EQ(from[i], to[i]);
+ }
+ delete [] to;
+}
+
+
// Called from assembler_test.cc.
ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
__ pushl(CTX);
@@ -2521,7 +2565,6 @@
__ ret();
}
-
} // namespace dart
#endif // defined TARGET_ARCH_IA32
diff --git a/runtime/vm/assembler_mips.cc b/runtime/vm/assembler_mips.cc
index c1b9721..b8aed32 100644
--- a/runtime/vm/assembler_mips.cc
+++ b/runtime/vm/assembler_mips.cc
@@ -79,6 +79,44 @@
}
+void Assembler::AdduDetectOverflow(Register rd, Register rs, Register rt,
+ Register ro) {
+ ASSERT(rd != ro);
+ ASSERT(rd != TMP1);
+ ASSERT(ro != TMP1);
+ ASSERT(ro != rs);
+ ASSERT(ro != rt);
+
+ if ((rs == rt) && (rd == rs)) {
+ ASSERT(rd != TMP2);
+ ASSERT(ro != TMP2);
+ ASSERT(rs != TMP2);
+ ASSERT(rt != TMP2);
+ mov(TMP2, rt);
+ rt = TMP2;
+ }
+
+ if (rd == rs) {
+ mov(TMP1, rs); // Preserve rs.
+ addu(rd, rs, rt); // rs is overwritten.
+ xor_(TMP1, rd, TMP1); // Original rs.
+ xor_(ro, rd, rt);
+ and_(ro, ro, TMP1);
+ } else if (rd == rt) {
+ mov(TMP1, rt); // Preserve rt.
+ addu(rd, rs, rt); // rt is overwritten.
+ xor_(TMP1, rd, TMP1); // Original rt.
+ xor_(ro, rd, rs);
+ and_(ro, ro, TMP1);
+ } else {
+ addu(rd, rs, rt);
+ xor_(ro, rd, rs);
+ xor_(TMP1, rd, rt);
+ and_(ro, TMP1, ro);
+ }
+}
+
+
void Assembler::LoadObject(Register rd, const Object& object) {
// Smi's and VM heap objects are never relocated; do not use object pool.
if (object.IsSmi()) {
@@ -119,15 +157,15 @@
void Assembler::PushObject(const Object& object) {
- LoadObject(TMP, object);
- Push(TMP);
+ LoadObject(TMP1, object);
+ Push(TMP1);
}
void Assembler::CompareObject(Register rd, Register rn, const Object& object) {
- ASSERT(rn != TMP);
- LoadObject(TMP, object);
- subu(rd, rn, TMP);
+ ASSERT(rn != TMP1);
+ LoadObject(TMP1, object);
+ subu(rd, rn, TMP1);
}
@@ -146,40 +184,67 @@
const intptr_t table_offset_in_isolate =
Isolate::class_table_offset() + ClassTable::table_offset();
lw(result, Address(result, table_offset_in_isolate));
- sll(TMP, class_id, 2);
- addu(result, result, TMP);
+ sll(TMP1, class_id, 2);
+ addu(result, result, TMP1);
lw(result, Address(result));
}
-void Assembler::LoadClass(Register result, Register object, Register scratch) {
- ASSERT(scratch != result);
- LoadClassId(scratch, object);
+void Assembler::LoadClass(Register result, Register object) {
+ ASSERT(TMP1 != result);
+ LoadClassId(TMP1, object);
lw(result, FieldAddress(CTX, Context::isolate_offset()));
const intptr_t table_offset_in_isolate =
Isolate::class_table_offset() + ClassTable::table_offset();
lw(result, Address(result, table_offset_in_isolate));
- sll(scratch, scratch, 2);
- addu(result, result, scratch);
+ sll(TMP1, TMP1, 2);
+ addu(result, result, TMP1);
lw(result, Address(result));
}
-void Assembler::EnterStubFrame() {
- addiu(SP, SP, Immediate(-3 * kWordSize));
- sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs.
- sw(RA, Address(SP, 1 * kWordSize));
- sw(FP, Address(SP, 0 * kWordSize));
- mov(FP, SP);
+void Assembler::EnterStubFrame(bool uses_pp) {
+ if (uses_pp) {
+ addiu(SP, SP, Immediate(-4 * kWordSize));
+ sw(ZR, Address(SP, 3 * kWordSize)); // PC marker is 0 in stubs.
+ sw(RA, Address(SP, 2 * kWordSize));
+ sw(PP, Address(SP, 1 * kWordSize));
+ sw(FP, Address(SP, 0 * kWordSize));
+ mov(FP, SP);
+ // Setup pool pointer for this stub.
+ Label next;
+ bal(&next);
+ delay_slot()->mov(T0, RA);
+
+ const intptr_t object_pool_pc_dist =
+ Instructions::HeaderSize() - Instructions::object_pool_offset() +
+ CodeSize();
+
+ Bind(&next);
+ lw(PP, Address(T0, -object_pool_pc_dist));
+ } else {
+ addiu(SP, SP, Immediate(-3 * kWordSize));
+ sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs.
+ sw(RA, Address(SP, 1 * kWordSize));
+ sw(FP, Address(SP, 0 * kWordSize));
+ mov(FP, SP);
+ }
}
-void Assembler::LeaveStubFrame() {
+void Assembler::LeaveStubFrame(bool uses_pp) {
mov(SP, FP);
- lw(RA, Address(SP, 1 * kWordSize));
- lw(FP, Address(SP, 0 * kWordSize));
- addiu(SP, SP, Immediate(3 * kWordSize));
+ if (uses_pp) {
+ lw(RA, Address(SP, 2 * kWordSize));
+ lw(PP, Address(SP, 1 * kWordSize));
+ lw(FP, Address(SP, 0 * kWordSize));
+ addiu(SP, SP, Immediate(4 * kWordSize));
+ } else {
+ lw(RA, Address(SP, 1 * kWordSize));
+ lw(FP, Address(SP, 0 * kWordSize));
+ addiu(SP, SP, Immediate(3 * kWordSize));
+ }
}
@@ -212,14 +277,15 @@
// the PC at this sw instruction.
Bind(&next);
- if (offset != 0) {
- // Adjust PC for any intrinsic code that could have been generated
- // before a frame is created.
- addiu(T0, T0, Immediate(-offset));
- }
-
// Save PC in frame for fast identification of corresponding code.
- sw(T0, Address(SP, 3 * kWordSize));
+ if (offset == 0) {
+ sw(T0, Address(SP, 3 * kWordSize));
+ } else {
+ // Adjust saved PC for any intrinsic code that could have been generated
+ // before a frame is created.
+ AddImmediate(T1, T0, -offset);
+ sw(T1, Address(SP, 3 * kWordSize));
+ }
// Set FP to the saved previous FP.
addiu(FP, SP, Immediate(kWordSize));
@@ -228,7 +294,7 @@
lw(PP, Address(T0, -object_pool_pc_dist));
// Reserve space for locals.
- addiu(SP, SP, Immediate(-frame_size));
+ AddImmediate(SP, -frame_size);
}
@@ -247,10 +313,10 @@
void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) {
// Reserve space for arguments and align frame before entering
// the C++ world.
- addiu(SP, SP, Immediate(-frame_space));
+ AddImmediate(SP, -frame_space);
if (OS::ActivationFrameAlignment() > 0) {
- LoadImmediate(TMP, ~(OS::ActivationFrameAlignment() - 1));
- and_(SP, SP, TMP);
+ LoadImmediate(TMP1, ~(OS::ActivationFrameAlignment() - 1));
+ and_(SP, SP, TMP1);
}
}
diff --git a/runtime/vm/assembler_mips.h b/runtime/vm/assembler_mips.h
index dda489f..8f430a6 100644
--- a/runtime/vm/assembler_mips.h
+++ b/runtime/vm/assembler_mips.h
@@ -58,13 +58,13 @@
}
uint32_t encoding() const {
- ASSERT(Utils::IsInt(16, offset_));
+ ASSERT(Utils::IsInt(kImmBits, offset_));
uint16_t imm_value = static_cast<uint16_t>(offset_);
return (base_ << kRsShift) | imm_value;
}
static bool CanHoldOffset(int32_t offset) {
- return Utils::IsInt(16, offset);
+ return Utils::IsInt(kImmBits, offset);
}
private:
@@ -169,8 +169,8 @@
// Set up a stub frame so that the stack traversal code can easily identify
// a stub frame.
- void EnterStubFrame();
- void LeaveStubFrame();
+ void EnterStubFrame(bool uses_pp = false);
+ void LeaveStubFrame(bool uses_pp = false);
// Instruction pattern from entrypoint is used in dart frame prologs
// to set up the frame and save a PC which can be used to figure out the
@@ -224,7 +224,7 @@
// CPU instructions in alphabetical order.
void addiu(Register rt, Register rs, const Immediate& imm) {
- ASSERT(Utils::IsInt(16, imm.value()));
+ ASSERT(Utils::IsInt(kImmBits, imm.value()));
const uint16_t imm_value = static_cast<uint16_t>(imm.value());
EmitIType(ADDIU, rs, rt, imm_value);
}
@@ -238,7 +238,7 @@
}
void andi(Register rt, Register rs, const Immediate& imm) {
- ASSERT(Utils::IsUint(16, imm.value()));
+ ASSERT(Utils::IsUint(kImmBits, imm.value()));
const uint16_t imm_value = static_cast<uint16_t>(imm.value());
EmitIType(ANDI, rs, rt, imm_value);
}
@@ -397,7 +397,7 @@
}
void lui(Register rt, const Immediate& imm) {
- ASSERT(Utils::IsUint(16, imm.value()));
+ ASSERT(Utils::IsUint(kImmBits, imm.value()));
uint16_t imm_value = static_cast<uint16_t>(imm.value());
EmitIType(LUI, R0, rt, imm_value);
}
@@ -447,7 +447,7 @@
}
void ori(Register rt, Register rs, const Immediate& imm) {
- ASSERT(Utils::IsUint(16, imm.value()));
+ ASSERT(Utils::IsUint(kImmBits, imm.value()));
uint16_t imm_value = static_cast<uint16_t>(imm.value());
EmitIType(ORI, rs, rt, imm_value);
}
@@ -506,45 +506,47 @@
// Macros in alphabetical order.
+ // Addition of rs and rt with the result placed in rd.
+ // After, ro < 0 if there was signed overflow, ro >= 0 otherwise.
+ // rd and ro must not be TMP1 or TMP2.
+ // ro must be different from all the other registers.
+ void AdduDetectOverflow(Register rd, Register rs, Register rt, Register ro);
+
+ // ro must be different from rd and rs.
+ // rd and ro must not be TMP1 or TMP2
+ void AddImmediateDetectOverflow(Register rd, Register rs, int32_t imm,
+ Register ro) {
+ LoadImmediate(rd, imm);
+ AdduDetectOverflow(rd, rs, rd, ro);
+ }
+
void Branch(const ExternalLabel* label) {
- LoadImmediate(TMP, label->address());
- jr(TMP);
+ LoadImmediate(TMP1, label->address());
+ jr(TMP1);
}
void BranchPatchable(const ExternalLabel* label) {
const uint16_t low = Utils::Low16Bits(label->address());
const uint16_t high = Utils::High16Bits(label->address());
- lui(TMP, Immediate(high));
- ori(TMP, TMP, Immediate(low));
- jr(TMP);
+ lui(TMP1, Immediate(high));
+ ori(TMP1, TMP1, Immediate(low));
+ jr(TMP1);
delay_slot_available_ = false; // CodePatcher expects a nop.
}
void BranchLink(const ExternalLabel* label) {
- LoadImmediate(TMP, label->address());
- jalr(TMP);
+ LoadImmediate(TMP1, label->address());
+ jalr(TMP1);
}
void BranchLinkPatchable(const ExternalLabel* label) {
const int32_t offset =
Array::data_offset() + 4*AddExternalLabel(label) - kHeapObjectTag;
- LoadWordFromPoolOffset(TMP, offset);
- jalr(TMP);
+ LoadWordFromPoolOffset(TMP1, offset);
+ jalr(TMP1);
delay_slot_available_ = false; // CodePatcher expects a nop.
}
- // If the signed value in rs is less than value, rd is 1, and 0 otherwise.
- void LessThanSImmediate(Register rd, Register rs, int32_t value) {
- LoadImmediate(TMP, value);
- slt(rd, rs, TMP);
- }
-
- // If the unsigned value in rs is less than value, rd is 1, and 0 otherwise.
- void LessThanUImmediate(Register rd, Register rs, uint32_t value) {
- LoadImmediate(TMP, value);
- sltu(rd, rs, TMP);
- }
-
void Drop(intptr_t stack_elements) {
ASSERT(stack_elements >= 0);
if (stack_elements > 0) {
@@ -553,7 +555,7 @@
}
void LoadImmediate(Register rd, int32_t value) {
- if (Utils::IsInt(16, value)) {
+ if (Utils::IsInt(kImmBits, value)) {
addiu(rd, ZR, Immediate(value));
} else {
const uint16_t low = Utils::Low16Bits(value);
@@ -563,6 +565,103 @@
}
}
+ void AddImmediate(Register rd, Register rs, int32_t value) {
+ if (Utils::IsInt(kImmBits, value)) {
+ addiu(rd, rs, Immediate(value));
+ } else {
+ LoadImmediate(TMP1, value);
+ addu(rd, rs, TMP1);
+ }
+ }
+
+ void AddImmediate(Register rd, int32_t value) {
+ AddImmediate(rd, rd, value);
+ }
+
+ void BranchEqual(Register rd, int32_t value, Label* l) {
+ LoadImmediate(TMP1, value);
+ beq(rd, TMP1, l);
+ }
+
+ void BranchEqual(Register rd, const Object& object, Label* l) {
+ LoadObject(TMP1, object);
+ beq(rd, TMP1, l);
+ }
+
+ void BranchNotEqual(Register rd, int32_t value, Label* l) {
+ LoadImmediate(TMP1, value);
+ bne(rd, TMP1, l);
+ }
+
+ void BranchNotEqual(Register rd, const Object& object, Label* l) {
+ LoadObject(TMP1, object);
+ bne(rd, TMP1, l);
+ }
+
+ void BranchGreater(Register rd, int32_t value, Label* l) {
+ if (Utils::IsInt(kImmBits, -value)) {
+ addiu(TMP1, rd, Immediate(-value));
+ bgtz(TMP1, l);
+ } else {
+ LoadImmediate(TMP1, value);
+ subu(TMP1, rd, TMP1);
+ bgtz(TMP1, l);
+ }
+ }
+
+ void BranchGreater(Register rd, Register rs, Label* l) {
+ subu(TMP1, rd, rs);
+ bgtz(TMP1, l);
+ }
+
+ void BranchGreaterEqual(Register rd, int32_t value, Label* l) {
+ if (Utils::IsInt(kImmBits, -value)) {
+ addiu(TMP1, rd, Immediate(-value));
+ bgez(TMP1, l);
+ } else {
+ LoadImmediate(TMP1, value);
+ subu(TMP1, rd, TMP1);
+ bgez(TMP1, l);
+ }
+ }
+
+ void BranchGreaterEqual(Register rd, Register rs, Label* l) {
+ subu(TMP1, rd, rs);
+ bgez(TMP1, l);
+ }
+
+ void BranchLess(Register rd, int32_t value, Label* l) {
+ if (Utils::IsInt(kImmBits, -value)) {
+ addiu(TMP1, rd, Immediate(-value));
+ bltz(TMP1, l);
+ } else {
+ LoadImmediate(TMP1, value);
+ subu(TMP1, rd, TMP1);
+ bltz(TMP1, l);
+ }
+ }
+
+ void BranchLess(Register rd, Register rs, Label* l) {
+ subu(TMP1, rd, rs);
+ bltz(TMP1, l);
+ }
+
+ void BranchLessEqual(Register rd, int32_t value, Label* l) {
+ if (Utils::IsInt(kImmBits, -value)) {
+ addiu(TMP1, rd, Immediate(-value));
+ blez(TMP1, l);
+ } else {
+ LoadImmediate(TMP1, value);
+ subu(TMP1, rd, TMP1);
+ blez(TMP1, l);
+ }
+ }
+
+ void BranchLessEqual(Register rd, Register rs, Label* l) {
+ subu(TMP1, rd, rs);
+ blez(TMP1, l);
+ }
+
void Push(Register rt) {
addiu(SP, SP, Immediate(-kWordSize));
sw(rt, Address(SP));
@@ -592,12 +691,12 @@
void PushObject(const Object& object);
// Sets register rd to zero if the object is equal to register rn,
- // set to non-zero otherwise.
+ // sets it to non-zero otherwise.
void CompareObject(Register rd, Register rn, const Object& object);
void LoadClassId(Register result, Register object);
void LoadClassById(Register result, Register class_id);
- void LoadClass(Register result, Register object, Register scratch);
+ void LoadClass(Register result, Register object);
void CallRuntime(const RuntimeEntry& entry);
diff --git a/runtime/vm/assembler_mips_test.cc b/runtime/vm/assembler_mips_test.cc
index 4124ee0..88d6472 100644
--- a/runtime/vm/assembler_mips_test.cc
+++ b/runtime/vm/assembler_mips_test.cc
@@ -1041,6 +1041,72 @@
EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
}
+
+ASSEMBLER_TEST_GENERATE(AddOverflow_detect, assembler) {
+ Register left = T0;
+ Register right = T1;
+ Register result = T2;
+ Register overflow = T3;
+ Label error, done;
+
+ __ LoadImmediate(V0, 1); // Success value.
+
+ __ LoadImmediate(left, 0x7fffffff);
+ __ LoadImmediate(right, 1);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bgez(overflow, &error); // INT_MAX + 1 overflows.
+
+ __ LoadImmediate(left, 0x7fffffff);
+ __ AdduDetectOverflow(result, left, left, overflow);
+ __ bgez(overflow, &error); // INT_MAX + INT_MAX overflows.
+
+ __ LoadImmediate(left, 0x7fffffff);
+ __ LoadImmediate(right, -1);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bltz(overflow, &error); // INT_MAX - 1 does not overflow.
+
+ __ LoadImmediate(left, -1);
+ __ LoadImmediate(right, 1);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bltz(overflow, &error); // -1 + 1 does not overflow.
+
+ __ LoadImmediate(left, 123456);
+ __ LoadImmediate(right, 654321);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bltz(overflow, &error); // 123456 + 654321 does not overflow.
+
+ __ LoadImmediate(left, 0x80000000);
+ __ LoadImmediate(right, -1);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bgez(overflow, &error); // INT_MIN - 1 overflows.
+
+ // result has 0x7fffffff.
+ __ AdduDetectOverflow(result, result, result, overflow);
+ __ bgez(overflow, &error); // INT_MAX + INT_MAX overflows.
+
+ __ LoadImmediate(left, 0x80000000);
+ __ LoadImmediate(right, 0x80000000);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bgez(overflow, &error); // INT_MIN + INT_MIN overflows.
+
+ __ LoadImmediate(left, -123456);
+ __ LoadImmediate(right, -654321);
+ __ AdduDetectOverflow(result, left, right, overflow);
+ __ bltz(overflow, &error); // -123456 + -654321 does not overflow.
+
+ __ b(&done);
+ __ Bind(&error);
+ __ mov(V0, ZR);
+ __ Bind(&done);
+ __ Ret();
+}
+
+
+ASSEMBLER_TEST_RUN(AddOverflow_detect, test) {
+ typedef int (*SimpleCode)();
+ EXPECT_EQ(1, EXECUTE_TEST_CODE_INT32(SimpleCode, test->entry()));
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_MIPS
diff --git a/runtime/vm/assembler_test.cc b/runtime/vm/assembler_test.cc
index 4071847..2e026d5 100644
--- a/runtime/vm/assembler_test.cc
+++ b/runtime/vm/assembler_test.cc
@@ -5,20 +5,33 @@
#include "vm/assembler.h"
#include "vm/globals.h"
#include "vm/os.h"
+#include "vm/simulator.h"
#include "vm/unit_test.h"
#include "vm/virtual_memory.h"
namespace dart {
-#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
+#if defined(TARGET_ARCH_IA32) || \
+ defined(TARGET_ARCH_X64) || \
+ defined(TARGET_ARCH_ARM)
ASSEMBLER_TEST_EXTERN(StoreIntoObject);
ASSEMBLER_TEST_RUN(StoreIntoObject, test) {
+#if defined(USING_SIMULATOR)
+#define test_code(ctx, value, growable_array) \
+ Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(test->entry()), \
+ reinterpret_cast<int32_t>(ctx), \
+ reinterpret_cast<int32_t>(value), \
+ reinterpret_cast<int32_t>(growable_array), \
+ 0)
+#else
typedef void (*StoreData)(RawContext* ctx,
RawObject* value,
RawObject* growable_array);
StoreData test_code = reinterpret_cast<StoreData>(test->entry());
+#endif
const Array& old_array = Array::Handle(Array::New(3, Heap::kOld));
const Array& new_array = Array::Handle(Array::New(3, Heap::kNew));
@@ -70,6 +83,6 @@
reinterpret_cast<uword>(grow_new_array.raw())));
}
-#endif
+#endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM
} // namespace dart
diff --git a/runtime/vm/assembler_x64.cc b/runtime/vm/assembler_x64.cc
index ec43f5d..2385749 100644
--- a/runtime/vm/assembler_x64.cc
+++ b/runtime/vm/assembler_x64.cc
@@ -155,6 +155,14 @@
}
+void Assembler::setcc(Condition condition, ByteRegister dst) {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0x0F);
+ EmitUint8(0x90 + condition);
+ EmitUint8(0xC0 + dst);
+}
+
+
void Assembler::movl(Register dst, Register src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
Operand operand(src);
@@ -382,6 +390,13 @@
}
+void Assembler::rep_movsb() {
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+ EmitUint8(0xF3);
+ EmitUint8(0xA4);
+}
+
+
void Assembler::leaq(Register dst, const Address& src) {
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
EmitOperandREX(dst, src, REX_W);
diff --git a/runtime/vm/assembler_x64.h b/runtime/vm/assembler_x64.h
index 6f049bb..9ba4fba 100644
--- a/runtime/vm/assembler_x64.h
+++ b/runtime/vm/assembler_x64.h
@@ -339,6 +339,8 @@
void popq(Register reg);
void popq(const Address& address);
+ void setcc(Condition condition, ByteRegister dst);
+
void movl(Register dst, Register src);
void movl(Register dst, const Immediate& imm);
void movl(Register dst, const Address& src);
@@ -368,6 +370,8 @@
void movsxd(Register dst, Register src);
void movsxd(Register dst, const Address& src);
+ void rep_movsb();
+
void leaq(Register dst, const Address& src);
void movss(XmmRegister dst, const Address& src);
diff --git a/runtime/vm/assembler_x64_test.cc b/runtime/vm/assembler_x64_test.cc
index 2d29d9d..bb29537 100644
--- a/runtime/vm/assembler_x64_test.cc
+++ b/runtime/vm/assembler_x64_test.cc
@@ -2291,6 +2291,51 @@
EXPECT_EQ(1, res);
}
+
+ASSEMBLER_TEST_GENERATE(TestSetCC, assembler) {
+ __ movq(RAX, Immediate(0xFFFFFFFF));
+ __ cmpq(RAX, RAX);
+ __ setcc(NOT_EQUAL, AL);
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(TestSetCC, test) {
+ typedef uword (*TestSetCC)();
+ uword res = reinterpret_cast<TestSetCC>(test->entry())();
+ EXPECT_EQ(0xFFFFFF00, res);
+}
+
+
+ASSEMBLER_TEST_GENERATE(TestRepMovsBytes, assembler) {
+ // Save incoming arguments.
+ __ pushq(RDI); // Arg0, from.
+ __ pushq(RSI); // Arg1, to.
+ __ pushq(RDX); // Arg2, count.
+ __ movq(RSI, Address(RSP, 2 * kWordSize)); // from.
+ __ movq(RDI, Address(RSP, 1 * kWordSize)); // to.
+ __ movq(RCX, Address(RSP, 0 * kWordSize)); // count.
+ __ rep_movsb();
+ // Remove saved arguments.
+ __ popq(RAX);
+ __ popq(RAX);
+ __ popq(RAX);
+ __ ret();
+}
+
+
+ASSEMBLER_TEST_RUN(TestRepMovsBytes, test) {
+ const char* from = "0123456789";
+ const char* to = new char[10];
+ typedef void (*TestRepMovsBytes)(const char* from, const char* to, int count);
+ reinterpret_cast<TestRepMovsBytes>(test->entry())(from, to, 10);
+ EXPECT_EQ(to[0], '0');
+ for (int i = 0; i < 10; i++) {
+ EXPECT_EQ(from[i], to[i]);
+ }
+ delete [] to;
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_X64
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index b72a1c5..2c8f1c1 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -68,6 +68,7 @@
void AddSuperType(const AbstractType& type,
GrowableArray<intptr_t>* finalized_super_classes) {
ASSERT(type.HasResolvedTypeClass());
+ ASSERT(!type.IsDynamicType());
if (type.IsObjectType()) {
return;
}
@@ -160,6 +161,7 @@
// Clear pending classes array.
class_array = GrowableObjectArray::New();
object_store->set_pending_classes(class_array);
+ VerifyImplicitFieldOffsets(); // Verification after an error may fail.
} else {
retval = false;
}
@@ -167,7 +169,6 @@
if (FLAG_use_cha) {
RemoveOptimizedCode(added_subclasses_to_cids);
}
- VerifyImplicitFieldOffsets();
return retval;
}
@@ -897,35 +898,6 @@
const Function& function) {
// Resolve result type.
AbstractType& type = AbstractType::Handle(function.result_type());
- // TODO(regis): Remove this code once the parser checks the factory name and
- // once the core library is fixed. See issue 6641.
- // In case of a factory, the parser sets the factory result type to a type
- // with an unresolved class whose name matches the factory name and no type
- // arguments. We resolve the class and specify type arguments in case the
- // class is generic.
- if (function.IsFactory()) {
- Type& factory_result_type = Type::Handle();
- factory_result_type ^= type.raw();
- ASSERT(factory_result_type.arguments() == TypeArguments::null());
- const UnresolvedClass& unresolved_factory_class =
- UnresolvedClass::Handle(factory_result_type.unresolved_class());
- const Class& factory_class =
- Class::Handle(ResolveClass(cls, unresolved_factory_class));
- if (factory_class.IsNull()) {
- type = NewFinalizedMalformedType(
- Error::Handle(), // No previous error.
- cls,
- unresolved_factory_class.token_pos(),
- kTryResolve, // No compile-time error.
- "cannot resolve factory class name '%s' from '%s'",
- String::Handle(unresolved_factory_class.Name()).ToCString(),
- String::Handle(cls.Name()).ToCString());
- } else {
- type = Type::New(factory_class,
- TypeArguments::Handle(factory_class.type_parameters()),
- unresolved_factory_class.token_pos());
- }
- }
// It is not a compile time error if this name does not resolve to a class or
// interface.
ResolveType(cls, type, kCanonicalize);
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 28b4c8e..e39278b 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -167,14 +167,16 @@
FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph);
}
- const ZoneGrowableArray<Field*>* guarded_fields = NULL;
-
+ // Collect all instance fields that are loaded in the graph and
+ // have non-generic type feedback attached to them that can
+ // potentially affect optimizations.
+ GrowableArray<Field*> guarded_fields(10);
if (optimized) {
TimerScope timer(FLAG_compiler_stats,
&CompilerStats::graphoptimizer_timer,
isolate);
- FlowGraphOptimizer optimizer(flow_graph);
+ FlowGraphOptimizer optimizer(flow_graph, &guarded_fields);
optimizer.ApplyICData();
DEBUG_ASSERT(flow_graph->VerifyUseLists());
@@ -189,14 +191,12 @@
if (FLAG_use_inlining) {
TimerScope timer(FLAG_compiler_stats,
&CompilerStats::graphinliner_timer);
- FlowGraphInliner inliner(flow_graph);
+ FlowGraphInliner inliner(flow_graph, &guarded_fields);
inliner.Inline();
// Use lists are maintained and validated by the inliner.
DEBUG_ASSERT(flow_graph->VerifyUseLists());
}
- guarded_fields = flow_graph->FieldDependencies();
-
// Propagate types and eliminate more type tests.
if (FLAG_propagate_types) {
FlowGraphTypePropagator propagator(flow_graph);
@@ -215,6 +215,9 @@
BranchSimplifier::Simplify(flow_graph);
DEBUG_ASSERT(flow_graph->VerifyUseLists());
+ IfConverter::Simplify(flow_graph);
+ DEBUG_ASSERT(flow_graph->VerifyUseLists());
+
if (FLAG_constant_propagation) {
ConstantPropagator::Optimize(flow_graph);
DEBUG_ASSERT(flow_graph->VerifyUseLists());
@@ -325,8 +328,8 @@
Code::Handle(function.unoptimized_code()).EntryPoint());
}
- for (intptr_t i = 0; i < guarded_fields->length(); i++) {
- const Field& field = *(*guarded_fields)[i];
+ for (intptr_t i = 0; i < guarded_fields.length(); i++) {
+ const Field& field = *guarded_fields[i];
field.RegisterDependentCode(code);
}
} else {
diff --git a/runtime/vm/constants_arm.h b/runtime/vm/constants_arm.h
index 43547b6..75edcfd 100644
--- a/runtime/vm/constants_arm.h
+++ b/runtime/vm/constants_arm.h
@@ -133,6 +133,7 @@
typedef DRegister FpuRegister;
const FpuRegister FpuTMP = D0;
const int kNumberOfFpuRegisters = kNumberOfDRegisters;
+const FpuRegister kNoFpuRegister = kNoDRegister;
// Register aliases.
diff --git a/runtime/vm/constants_ia32.h b/runtime/vm/constants_ia32.h
index 937ff99..b6b1367 100644
--- a/runtime/vm/constants_ia32.h
+++ b/runtime/vm/constants_ia32.h
@@ -56,6 +56,7 @@
typedef XmmRegister FpuRegister;
const FpuRegister FpuTMP = XMM0;
const int kNumberOfFpuRegisters = kNumberOfXmmRegisters;
+const FpuRegister kNoFpuRegister = kNoXmmRegister;
// Register aliases.
diff --git a/runtime/vm/constants_mips.h b/runtime/vm/constants_mips.h
index 9bad858..9a47410 100644
--- a/runtime/vm/constants_mips.h
+++ b/runtime/vm/constants_mips.h
@@ -31,11 +31,11 @@
R19 = 19,
R20 = 20,
R21 = 21,
+ kLastFreeCpuRegister = 21,
R22 = 22,
R23 = 23,
R24 = 24,
R25 = 25,
- kLastFreeCpuRegister = 25,
R26 = 26,
R27 = 27,
R28 = 28,
@@ -131,15 +131,23 @@
typedef FRegister FpuRegister;
const FpuRegister FpuTMP = F0;
const int kNumberOfFpuRegisters = kNumberOfFRegisters;
+const FpuRegister kNoFpuRegister = kNoFRegister;
// Register aliases.
-const Register TMP = AT; // Used as scratch register by assembler.
+const Register TMP1 = AT; // Used as scratch register by assembler.
+const Register TMP2 = T9; // Used as scratch register by assembler.
+const Register TMP = TMP1; // Arch independent flow graph compiler needs a
+ // Register called TMP.
const Register CTX = S6; // Caches current context in generated code.
const Register PP = S7; // Caches object pool pointer in generated code.
const Register SPREG = SP; // Stack pointer register.
const Register FPREG = FP; // Frame pointer register.
+// The code that generates a comparison can be far away from the code that
+// generates the branch that uses the result of that comparison. In this case,
+// CMPRES is used for the result of the comparison.
+const Register CMPRES = T8;
typedef uint32_t RegList;
const RegList kAllCpuRegistersList = 0xFFFFFFFF;
@@ -158,10 +166,12 @@
static const int kFirstLocalSlotIndex = -2;
-// Values for the condition field. // UNIMPLEMENTED.
+// Values for the condition field.
+// There is no condition field on MIPS, but Conditions are used and passed
+// around by the intermediate language, so we need them here, too.
enum Condition {
- kNoCondition = -1,
- kMaxCondition = 16,
+ EQ, // equal
+ NE, // not equal
};
diff --git a/runtime/vm/constants_x64.h b/runtime/vm/constants_x64.h
index a343543..d3f5f9f 100644
--- a/runtime/vm/constants_x64.h
+++ b/runtime/vm/constants_x64.h
@@ -70,6 +70,7 @@
typedef XmmRegister FpuRegister;
const FpuRegister FpuTMP = XMM0;
const int kNumberOfFpuRegisters = kNumberOfXmmRegisters;
+const FpuRegister kNoFpuRegister = kNoXmmRegister;
enum RexBits {
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 8ad2e6b..e7ee27b 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -938,6 +938,16 @@
}
+DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate) {
+ CHECK_NO_ISOLATE(Isolate::Current());
+ if (isolate == NULL) {
+ FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC);
+ }
+ Isolate* iso = reinterpret_cast<Isolate*>(isolate);
+ return iso->MakeRunnable();
+}
+
+
// --- Messages and Ports ---
DART_EXPORT void Dart_SetMessageNotifyCallback(
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 61c4dbc..cc2d2de 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -906,6 +906,13 @@
TEST_CASE(ByteDataAccess) {
const char* kScriptChars =
"import 'dart:typeddata';\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
"ByteData createByteData() native 'CreateByteData';"
"ByteData main() {"
" var length = 16;"
@@ -961,6 +968,13 @@
// appropriate getter instead of the host endian format used now.
const char* kScriptChars =
"import 'dart:typeddata';\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
"ByteData createExternalByteData() native 'CreateExternalByteData';"
"ByteData main() {"
" var length = 16;"
@@ -1073,6 +1087,13 @@
TEST_CASE(TypedDataDirectAccess1) {
const char* kScriptChars =
"import 'dart:typeddata';\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw new Exception('not equal. expected: $a, got: $b');\n"
+ " }\n"
+ " }\n"
+ "}\n"
"void setMain(var a) {"
" for (var i = 0; i < 10; i++) {"
" a[i] = i;"
@@ -1113,6 +1134,13 @@
TEST_CASE(TypedDataViewDirectAccess) {
const char* kScriptChars =
"import 'dart:typeddata';\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
"void setMain(var list) {"
" Expect.equals(10, list.length);"
" for (var i = 0; i < 10; i++) {"
@@ -1145,6 +1173,13 @@
TEST_CASE(ByteDataDirectAccess) {
const char* kScriptChars =
"import 'dart:typeddata';\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
"void setMain(var list) {"
" Expect.equals(10, list.length);"
" for (var i = 0; i < 10; i++) {"
@@ -6243,10 +6278,10 @@
}
-static bool RunLoopTestCallback(const char* script_name,
- const char* main,
- void* data,
- char** error) {
+static Dart_Isolate RunLoopTestCallback(const char* script_name,
+ const char* main,
+ void* data,
+ char** error) {
const char* kScriptChars =
"import 'builtin';\n"
"import 'dart:isolate';\n"
@@ -6282,7 +6317,10 @@
Dart_Handle lib = Dart_LoadScript(url, source, 0, 0);
EXPECT_VALID(lib);
Dart_ExitScope();
- return true;
+ Dart_ExitIsolate();
+ bool retval = Dart_IsolateMakeRunnable(isolate);
+ EXPECT(retval);
+ return isolate;
}
@@ -6308,8 +6346,9 @@
Dart_IsolateCreateCallback saved = Isolate::CreateCallback();
Isolate::SetCreateCallback(RunLoopTestCallback);
Isolate::SetUnhandledExceptionCallback(RunLoopUnhandledExceptionCallback);
- RunLoopTestCallback(NULL, NULL, NULL, NULL);
+ Dart_Isolate isolate = RunLoopTestCallback(NULL, NULL, NULL, NULL);
+ Dart_EnterIsolate(isolate);
Dart_EnterScope();
Dart_Handle lib = Dart_LookupLibrary(NewString(TestCase::url()));
EXPECT_VALID(lib);
@@ -6648,6 +6687,13 @@
" int bar43(int i, int j, int k) {\n"
" var func = foo4; return func(i, j, k); }\n"
"}\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
"int testMain() {\n"
" Test obj = new Test();\n"
" Expect.equals(1, obj.foo1());\n"
@@ -6786,6 +6832,13 @@
" int bar43(int i, int j, int k) {\n"
" var func = foo4; return func(i, j, k); }\n"
"}\n"
+ "class Expect {\n"
+ " static equals(a, b) {\n"
+ " if (a != b) {\n"
+ " throw 'not equal. expected: $a, got: $b';\n"
+ " }\n"
+ " }\n"
+ "}\n"
"int testMain() {\n"
" Test obj = new Test();\n"
" Expect.equals(0, Test.foo1());\n"
diff --git a/runtime/vm/dart_api_message.cc b/runtime/vm/dart_api_message.cc
index ab1e060..5315301b 100644
--- a/runtime/vm/dart_api_message.cc
+++ b/runtime/vm/dart_api_message.cc
@@ -164,6 +164,22 @@
}
+Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectInternal(
+ Dart_CObject_Internal::Type type) {
+ Dart_CObject_Internal* value =
+ reinterpret_cast<Dart_CObject_Internal*>(
+ alloc_(NULL, 0, sizeof(Dart_CObject_Internal)));
+ ASSERT(value != NULL);
+ value->type = static_cast<Dart_CObject::Type>(type);
+ return value;
+}
+
+
+Dart_CObject_Internal* ApiMessageReader::AllocateDartCObjectClass() {
+ return AllocateDartCObjectInternal(Dart_CObject_Internal::kClass);
+}
+
+
ApiMessageReader::BackRefNode* ApiMessageReader::AllocateBackRefNode(
Dart_CObject* reference,
DeserializeState state) {
@@ -182,9 +198,55 @@
USE(tags);
intptr_t class_id;
- // Reading of regular dart instances is not supported.
+ // There is limited support for reading regular dart instances. Only
+ // typed data views are currently handled.
if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) {
- return AllocateDartCObjectUnsupported();
+ Dart_CObject_Internal* object =
+ reinterpret_cast<Dart_CObject_Internal*>(GetBackRef(object_id));
+ if (object == NULL) {
+ object =
+ AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized);
+ AddBackRef(object_id, object, kIsDeserialized);
+ // Read class of object.
+ object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl());
+ ASSERT(object->cls->type ==
+ static_cast<Dart_CObject::Type>(Dart_CObject_Internal::kClass));
+ }
+ ASSERT(object->type ==
+ static_cast<Dart_CObject::Type>(
+ Dart_CObject_Internal::kUninitialized));
+
+ // Handle typed data views.
+ char* library_url =
+ object->cls->internal.as_class.library_url->value.as_string;
+ char* class_name =
+ object->cls->internal.as_class.class_name->value.as_string;
+ if (strcmp("dart:typeddata", library_url) == 0 &&
+ strncmp("_Uint8ArrayView", class_name, 15) == 0) {
+ object->type =
+ static_cast<Dart_CObject::Type>(Dart_CObject_Internal::kView);
+ // Skip type arguments.
+ ReadObjectImpl();
+ object->internal.as_view.buffer = ReadObjectImpl();
+ object->internal.as_view.offset_in_bytes = ReadSmiValue();
+ object->internal.as_view.length = ReadSmiValue();
+
+ // The buffer is fully read now as typed data objects are
+ // serialized in-line.
+ Dart_CObject* buffer = object->internal.as_view.buffer;
+ ASSERT(buffer->type == Dart_CObject::kUint8Array);
+
+ // Now turn the view into a byte array.
+ object->type = Dart_CObject::kUint8Array;
+ object->value.as_byte_array.length = object->internal.as_view.length;
+ object->value.as_byte_array.values =
+ buffer->value.as_byte_array.values +
+ object->internal.as_view.offset_in_bytes;
+ } else {
+ // TODO(sgjesse): Handle other instances. Currently this will
+ // skew the reading as the fields of the instance is not read.
+ }
+ return object;
}
ASSERT((class_header & kSmiTagMask) != 0);
@@ -265,11 +327,17 @@
// Read the class header information and lookup the class.
intptr_t class_header = ReadIntptrValue();
- // Reading of regular dart instances is not supported.
+ // Reading of regular dart instances has limited support in order to
+ // read typed data views.
if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) {
intptr_t object_id = SerializedHeaderData::decode(value);
- Dart_CObject* object = AllocateDartCObjectUnsupported();
+ Dart_CObject_Internal* object =
+ AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized);
AddBackRef(object_id, object, kIsNotDeserialized);
+ // Read class of object.
+ object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl());
+ ASSERT(object->cls->type ==
+ static_cast<Dart_CObject::Type>(Dart_CObject_Internal::kClass));
return object;
}
ASSERT((class_header & kSmiTagMask) != 0);
@@ -313,8 +381,14 @@
intptr_t object_id) {
switch (class_id) {
case kClassCid: {
- Dart_CObject* object = AllocateDartCObjectUnsupported();
+ Dart_CObject_Internal* object = AllocateDartCObjectClass();
AddBackRef(object_id, object, kIsDeserialized);
+ object->internal.as_class.library_url = ReadObjectImpl();
+ ASSERT(object->internal.as_class.library_url->type ==
+ Dart_CObject::kString);
+ object->internal.as_class.class_name = ReadObjectImpl();
+ ASSERT(object->internal.as_class.class_name->type ==
+ Dart_CObject::kString);
return object;
}
case kTypeArgumentsCid: {
diff --git a/runtime/vm/dart_api_message.h b/runtime/vm/dart_api_message.h
index 84d44a8..d215ab0 100644
--- a/runtime/vm/dart_api_message.h
+++ b/runtime/vm/dart_api_message.h
@@ -14,13 +14,26 @@
// data. These are objects that we need to process in order to
// generate the Dart_CObject graph but that we don't want to expose in
// that graph.
-// TODO(sjesse): Remove this when message serialization format is
-// updated.
struct Dart_CObject_Internal : public Dart_CObject {
enum Type {
kTypeArguments = Dart_CObject::kNumberOfTypes,
kDynamicType,
+ kClass,
+ kView,
+ kUninitialized,
};
+ struct Dart_CObject_Internal* cls;
+ union {
+ struct {
+ struct _Dart_CObject* library_url;
+ struct _Dart_CObject* class_name;
+ } as_class;
+ struct {
+ struct _Dart_CObject* buffer;
+ int offset_in_bytes;
+ int length;
+ } as_view;
+ } internal;
};
@@ -79,6 +92,11 @@
Dart_CObject* AllocateDartCObjectUint8Array(intptr_t length);
// Allocates a C array of Dart_CObject objects.
Dart_CObject* AllocateDartCObjectArray(intptr_t length);
+ // Allocates a Dart_CObject_Internal object with the specified type.
+ Dart_CObject_Internal* AllocateDartCObjectInternal(
+ Dart_CObject_Internal::Type type);
+ // Allocates a Dart_CObject_Internal object for a class object.
+ Dart_CObject_Internal* AllocateDartCObjectClass();
// Allocates a backwards reference node.
BackRefNode* AllocateBackRefNode(Dart_CObject* ref, DeserializeState state);
diff --git a/runtime/vm/dart_entry_test.cc b/runtime/vm/dart_entry_test.cc
index f067736..a09b35c 100644
--- a/runtime/vm/dart_entry_test.cc
+++ b/runtime/vm/dart_entry_test.cc
@@ -14,8 +14,10 @@
namespace dart {
-// Only ia32 and x64 can run execution tests.
-#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
+// Only IA32, X64, and ARM can run execution tests.
+#if defined(TARGET_ARCH_IA32) || \
+ defined(TARGET_ARCH_X64) || \
+ defined(TARGET_ARCH_ARM)
TEST_CASE(DartEntry) {
const char* kScriptChars =
@@ -113,6 +115,6 @@
EXPECT_SUBSTRING("++++", Error::Cast(retval).ToErrorCString());
}
-#endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64.
+#endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM
} // namespace dart
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index 30909a9..685a8c1 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -262,7 +262,6 @@
break;
}
}
- ASSERT(token_pos_ >= 0);
}
return token_pos_;
}
@@ -270,8 +269,7 @@
intptr_t ActivationFrame::PcDescIndex() {
if (pc_desc_index_ < 0) {
- TokenPos();
- ASSERT(pc_desc_index_ >= 0);
+ TokenPos(); // Sets pc_desc_index_ as a side effect.
}
return pc_desc_index_;
}
@@ -279,13 +277,17 @@
intptr_t ActivationFrame::TryIndex() {
intptr_t desc_index = PcDescIndex();
- return pc_desc_.TryIndex(desc_index);
+ if (desc_index < 0) {
+ return -1;
+ } else {
+ return pc_desc_.TryIndex(desc_index);
+ }
}
intptr_t ActivationFrame::LineNumber() {
// Compute line number lazily since it causes scanning of the script.
- if (line_number_ < 0) {
+ if ((line_number_ < 0) && (TokenPos() >= 0)) {
const Script& script = Script::Handle(SourceScript());
intptr_t ignore_column;
script.GetTokenLocation(TokenPos(), &line_number_, &ignore_column);
@@ -308,6 +310,12 @@
ASSERT(!code_.is_optimized());
context_level_ = 0;
intptr_t pc_desc_idx = PcDescIndex();
+ // TODO(hausner): What to do if there is no descriptor entry
+ // for the code position of the frame? For now say we are at context
+ // level 0.
+ if (pc_desc_idx < 0) {
+ return context_level_;
+ }
ASSERT(!pc_desc_.IsNull());
if (pc_desc_.DescriptorKind(pc_desc_idx) == PcDescriptors::kReturn) {
// Special case: the context chain has already been deallocated.
@@ -316,6 +324,7 @@
}
intptr_t innermost_begin_pos = 0;
intptr_t activation_token_pos = TokenPos();
+ ASSERT(activation_token_pos >= 0);
GetVarDescriptors();
intptr_t var_desc_len = var_descriptors_.Length();
for (int cur_idx = 0; cur_idx < var_desc_len; cur_idx++) {
@@ -406,8 +415,15 @@
return;
}
- GrowableArray<String*> var_names(8);
intptr_t activation_token_pos = TokenPos();
+ if (activation_token_pos < 0) {
+ // We don't have a token position for this frame, so can't determine
+ // which variables are visible.
+ vars_initialized_ = true;
+ return;
+ }
+
+ GrowableArray<String*> var_names(8);
intptr_t var_desc_len = var_descriptors_.Length();
for (int cur_idx = 0; cur_idx < var_desc_len; cur_idx++) {
ASSERT(var_names.length() == desc_indices_.length());
@@ -992,6 +1008,7 @@
intptr_t lowest_pc_index = -1;
for (int i = 0; i < desc.Length(); i++) {
intptr_t desc_token_pos = desc.TokenPos(i);
+ ASSERT(desc_token_pos >= 0);
if (desc_token_pos < first_token_pos) {
continue;
}
diff --git a/runtime/vm/debugger_api_impl.cc b/runtime/vm/debugger_api_impl.cc
index 84dc81e..cf4c340 100644
--- a/runtime/vm/debugger_api_impl.cc
+++ b/runtime/vm/debugger_api_impl.cc
@@ -225,6 +225,7 @@
DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation(
Dart_ActivationFrame activation_frame,
Dart_Handle* script_url,
+ intptr_t* library_id,
intptr_t* token_number) {
// TODO(hausner): Implement implement a way to recognize when there
// is no source code for the code in the frame.
@@ -234,6 +235,10 @@
if (script_url != NULL) {
*script_url = Api::NewHandle(isolate, frame->SourceUrl());
}
+ if (library_id != NULL) {
+ const Library& lib = Library::Handle(frame->Library());
+ *library_id = lib.index();
+ }
if (token_number != NULL) {
*token_number = frame->TokenPos();
}
@@ -268,43 +273,6 @@
}
-// TODO(hausner): remove this function.
-DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine(
- Dart_Handle script_url_in,
- Dart_Handle line_number_in,
- Dart_Breakpoint* breakpoint) {
- Isolate* isolate = Isolate::Current();
- DARTSCOPE(isolate);
- UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in);
- UNWRAP_AND_CHECK_PARAM(Integer, line_number, line_number_in);
- CHECK_NOT_NULL(breakpoint);
-
- if (!line_number.IsSmi()) {
- return Api::NewError("%s: line number out of range", CURRENT_FUNC);
- }
- intptr_t line = line_number.AsInt64Value();
-
- Dart_Handle state = Api::CheckIsolateState(isolate);
- if (::Dart_IsError(state)) {
- return state;
- }
-
- Dart_Handle result = Api::True(isolate);
- *breakpoint = NULL;
- Debugger* debugger = isolate->debugger();
- ASSERT(debugger != NULL);
- SourceBreakpoint* bpt =
- debugger->SetBreakpointAtLine(script_url, line);
- if (bpt == NULL) {
- result = Api::NewError("%s: could not set breakpoint at line %"Pd" of '%s'",
- CURRENT_FUNC, line, script_url.ToCString());
- } else {
- *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
- }
- return result;
-}
-
-
DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
@@ -338,14 +306,12 @@
DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
Dart_Handle library_in,
Dart_Handle class_name_in,
- Dart_Handle function_name_in,
- Dart_Breakpoint* breakpoint) {
+ Dart_Handle function_name_in) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
UNWRAP_AND_CHECK_PARAM(Library, library, library_in);
UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in);
UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in);
- CHECK_NOT_NULL(breakpoint);
Dart_Handle state = Api::CheckIsolateState(isolate);
if (::Dart_IsError(state)) {
@@ -365,18 +331,13 @@
function_name.ToCString());
}
- Dart_Handle result = Api::True(isolate);
- *breakpoint = NULL;
-
SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target);
if (bpt == NULL) {
const char* target_name = Debugger::QualifiedFunctionName(bp_target);
- result = Api::NewError("%s: no breakpoint location found in '%s'",
- CURRENT_FUNC, target_name);
- } else {
- *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
+ return Api::NewError("%s: no breakpoint location found in '%s'",
+ CURRENT_FUNC, target_name);
}
- return result;
+ return Dart_NewInteger(bpt->id());
}
@@ -413,9 +374,6 @@
}
-
-
-
DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
@@ -427,17 +385,6 @@
}
-DART_EXPORT Dart_Handle Dart_DeleteBreakpoint(
- Dart_Breakpoint breakpoint_in) {
- Isolate* isolate = Isolate::Current();
- DARTSCOPE(isolate);
-
- CHECK_AND_CAST(SourceBreakpoint, breakpoint, breakpoint_in);
- isolate->debugger()->RemoveBreakpoint(breakpoint->id());
- return Api::True(isolate);
-}
-
-
DART_EXPORT Dart_Handle Dart_SetStepOver() {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
@@ -587,6 +534,57 @@
}
+DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(
+ intptr_t library_id,
+ Dart_Handle script_url_in) {
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ const Library& lib = Library::Handle(Library::GetLibrary(library_id));
+ if (lib.IsNull()) {
+ return Api::NewError("%s: %"Pd" is not a valid library id",
+ CURRENT_FUNC, library_id);
+ }
+ UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in);
+ const Script& script = Script::Handle(lib.LookupScript(script_url));
+ if (script.IsNull()) {
+ return Api::NewError("%s: script '%s' not found in library '%s'",
+ CURRENT_FUNC, script_url.ToCString(),
+ String::Handle(lib.url()).ToCString());
+ }
+
+ const GrowableObjectArray& info =
+ GrowableObjectArray::Handle(GrowableObjectArray::New());
+ const String& source = String::Handle(script.Source());
+ const String& key = Symbols::Empty();
+ const Object& line_separator = Object::Handle();
+ const TokenStream& tkns = TokenStream::Handle(script.tokens());
+ ASSERT(!tkns.IsNull());
+ TokenStream::Iterator tkit(tkns, 0);
+ int current_line = -1;
+ Scanner s(source, key);
+ s.Scan();
+ while (s.current_token().kind != Token::kEOS) {
+ ASSERT(tkit.IsValid());
+ ASSERT(s.current_token().kind == tkit.CurrentTokenKind());
+ int token_line = s.current_token().position.line;
+ if (token_line != current_line) {
+ // emit line
+ info.Add(line_separator);
+ info.Add(Smi::Handle(Smi::New(token_line)));
+ current_line = token_line;
+ }
+ // TODO(hausner): Could optimize here by not reporting tokens
+ // that will never be a location used by the debugger, e.g.
+ // braces, semicolons, most keywords etc.
+ info.Add(Smi::Handle(Smi::New(tkit.CurrentPosition())));
+ info.Add(Smi::Handle(Smi::New(s.current_token().offset)));
+ s.Scan();
+ tkit.Advance();
+ }
+ return Api::NewHandle(isolate, Array::MakeArray(info));
+}
+
+
DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in,
Dart_Handle script_url_in) {
Isolate* isolate = Isolate::Current();
@@ -710,29 +708,6 @@
}
-DART_EXPORT Dart_Handle Dart_GetLibraryURLs() {
- Isolate* isolate = Isolate::Current();
- ASSERT(isolate != NULL);
- DARTSCOPE(isolate);
-
- const GrowableObjectArray& libs =
- GrowableObjectArray::Handle(isolate->object_store()->libraries());
- int num_libs = libs.Length();
-
- // Create new list and populate with the url of loaded libraries.
- Library &lib = Library::Handle();
- String& lib_url = String::Handle();
- const Array& library_url_list = Array::Handle(Array::New(num_libs));
- for (int i = 0; i < num_libs; i++) {
- lib ^= libs.At(i);
- ASSERT(!lib.IsNull());
- lib_url = lib.url();
- library_url_list.SetAt(i, lib_url);
- }
- return Api::NewHandle(isolate, library_url_list.raw());
-}
-
-
DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id,
bool* is_debuggable) {
Isolate* isolate = Isolate::Current();
diff --git a/runtime/vm/debugger_api_impl_test.cc b/runtime/vm/debugger_api_impl_test.cc
index 81e9c9d..a667fd0 100644
--- a/runtime/vm/debugger_api_impl_test.cc
+++ b/runtime/vm/debugger_api_impl_test.cc
@@ -29,12 +29,10 @@
ASSERT(script_lib != NULL);
ASSERT(!Dart_IsError(script_lib));
ASSERT(Dart_IsLibrary(script_lib));
- Dart_Breakpoint bpt;
Dart_Handle res = Dart_SetBreakpointAtEntry(script_lib,
NewString(cname),
- NewString(fname),
- &bpt);
- EXPECT_TRUE(res);
+ NewString(fname));
+ EXPECT(Dart_IsInteger(res));
}
@@ -998,14 +996,17 @@
func = test_lib.LookupFunctionInSource(script_url, 10);
EXPECT(func.IsNull());
- Dart_Handle libs = Dart_GetLibraryURLs();
+ Dart_Handle libs = Dart_GetLibraryIds();
EXPECT(Dart_IsList(libs));
intptr_t num_libs;
Dart_ListLength(libs, &num_libs);
EXPECT(num_libs > 0);
for (int i = 0; i < num_libs; i++) {
- Dart_Handle lib_url = Dart_ListGetAt(libs, i);
- EXPECT(Dart_IsString(lib_url));
+ Dart_Handle lib_id = Dart_ListGetAt(libs, i);
+ EXPECT(Dart_IsInteger(lib_id));
+ int64_t id = 0;
+ Dart_IntegerToInt64(lib_id, &id);
+ Dart_Handle lib_url = Dart_GetLibraryURL(id);
char const* chars;
Dart_StringToCString(lib_url, &chars);
OS::Print("Lib %d: %s\n", i, chars);
@@ -1033,35 +1034,6 @@
}
-TEST_CASE(GetLibraryURLs) {
- const char* kScriptChars =
- "main() {"
- " return 12345;"
- "}";
-
- Dart_Handle lib_list = Dart_GetLibraryURLs();
- EXPECT_VALID(lib_list);
- EXPECT(Dart_IsList(lib_list));
- Dart_Handle list_as_string = Dart_ToString(lib_list);
- const char* list_cstr = "";
- EXPECT_VALID(Dart_StringToCString(list_as_string, &list_cstr));
- EXPECT_NOTSUBSTRING(TestCase::url(), list_cstr);
-
- // Load a script.
- Dart_Handle url = NewString(TestCase::url());
- Dart_Handle source = NewString(kScriptChars);
- EXPECT_VALID(Dart_LoadScript(url, source, 0, 0));
-
- lib_list = Dart_GetLibraryURLs();
- EXPECT_VALID(lib_list);
- EXPECT(Dart_IsList(lib_list));
- list_as_string = Dart_ToString(lib_list);
- list_cstr = "";
- EXPECT_VALID(Dart_StringToCString(list_as_string, &list_cstr));
- EXPECT_SUBSTRING(TestCase::url(), list_cstr);
-}
-
-
static Dart_IsolateId test_isolate_id = ILLEGAL_ISOLATE_ID;
static int verify_callback = 0;
static void TestIsolateID(Dart_IsolateId isolate_id, Dart_IsolateEvent kind) {
diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc
index f505590..f6f8869 100644
--- a/runtime/vm/deopt_instructions.cc
+++ b/runtime/vm/deopt_instructions.cc
@@ -243,17 +243,16 @@
// Deoptimization instruction creating return address using function and
-// deopt-id stored at 'object_table_index'. Uses the deopt-after
-// continuation point.
-class DeoptRetAfterAddressInstr : public DeoptInstr {
+// deopt-id stored at 'object_table_index'.
+class DeoptRetAddressInstr : public DeoptInstr {
public:
- DeoptRetAfterAddressInstr(intptr_t object_table_index, intptr_t deopt_id)
+ DeoptRetAddressInstr(intptr_t object_table_index, intptr_t deopt_id)
: object_table_index_(object_table_index), deopt_id_(deopt_id) {
ASSERT(object_table_index >= 0);
ASSERT(deopt_id >= 0);
}
- explicit DeoptRetAfterAddressInstr(intptr_t from_index)
+ explicit DeoptRetAddressInstr(intptr_t from_index)
: object_table_index_(ObjectTableIndex::decode(from_index)),
deopt_id_(DeoptId::decode(from_index)) {
}
@@ -262,14 +261,12 @@
return ObjectTableIndex::encode(object_table_index_) |
DeoptId::encode(deopt_id_);
}
- virtual DeoptInstr::Kind kind() const { return kRetAfterAddress; }
+
+ virtual DeoptInstr::Kind kind() const { return kRetAddress; }
virtual const char* ToCString() const {
- const char* format = "ret aft oti:%"Pd"(%"Pd")";
- intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_, deopt_id_);
- char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
- OS::SNPrint(chars, len + 1, format, object_table_index_, deopt_id_);
- return chars;
+ return Isolate::Current()->current_zone()->PrintToString(
+ "ret oti:%"Pd"(%"Pd")", object_table_index_, deopt_id_);
}
void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
@@ -278,64 +275,8 @@
const Code& code =
Code::Handle(deopt_context->isolate(), function.unoptimized_code());
ASSERT(!code.IsNull());
- uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_);
- ASSERT(continue_at_pc != 0);
- intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index);
- *to_addr = continue_at_pc;
- }
-
- intptr_t object_table_index() const { return object_table_index_; }
- intptr_t deopt_id() const { return deopt_id_; }
-
- private:
- static const intptr_t kFieldWidth = kBitsPerWord / 2;
- class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { };
- class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { };
-
- const intptr_t object_table_index_;
- const intptr_t deopt_id_;
-
- DISALLOW_COPY_AND_ASSIGN(DeoptRetAfterAddressInstr);
-};
-
-
-// Deoptimization instruction creating return address using function and
-// deopt-id stored at 'object_table_index'. Uses the deopt-before
-// continuation point.
-class DeoptRetBeforeAddressInstr : public DeoptInstr {
- public:
- DeoptRetBeforeAddressInstr(intptr_t object_table_index, intptr_t deopt_id)
- : object_table_index_(object_table_index), deopt_id_(deopt_id) {
- ASSERT(object_table_index >= 0);
- ASSERT(deopt_id >= 0);
- }
-
- explicit DeoptRetBeforeAddressInstr(intptr_t from_index)
- : object_table_index_(ObjectTableIndex::decode(from_index)),
- deopt_id_(DeoptId::decode(from_index)) {
- }
-
- virtual intptr_t from_index() const {
- return ObjectTableIndex::encode(object_table_index_) |
- DeoptId::encode(deopt_id_);
- }
- virtual DeoptInstr::Kind kind() const { return kRetBeforeAddress; }
-
- virtual const char* ToCString() const {
- const char* format = "ret bef oti:%"Pd"(%"Pd")";
- intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_, deopt_id_);
- char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
- OS::SNPrint(chars, len + 1, format, object_table_index_, deopt_id_);
- return chars;
- }
-
- void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
- Function& function = Function::Handle(deopt_context->isolate());
- function ^= deopt_context->ObjectAt(object_table_index_);
- const Code& code =
- Code::Handle(deopt_context->isolate(), function.unoptimized_code());
- ASSERT(!code.IsNull());
- uword continue_at_pc = code.GetDeoptBeforePcAtDeoptId(deopt_id_);
+ uword continue_at_pc = code.GetPcForDeoptId(deopt_id_,
+ PcDescriptors::kDeopt);
ASSERT(continue_at_pc != 0);
intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index);
*to_addr = continue_at_pc;
@@ -352,6 +293,9 @@
}
}
+ intptr_t object_table_index() const { return object_table_index_; }
+ intptr_t deopt_id() const { return deopt_id_; }
+
private:
static const intptr_t kFieldWidth = kBitsPerWord / 2;
class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { };
@@ -360,7 +304,7 @@
const intptr_t object_table_index_;
const intptr_t deopt_id_;
- DISALLOW_COPY_AND_ASSIGN(DeoptRetBeforeAddressInstr);
+ DISALLOW_COPY_AND_ASSIGN(DeoptRetAddressInstr);
};
@@ -713,18 +657,20 @@
}
-uword DeoptInstr::GetRetAfterAddress(DeoptInstr* instr,
- const Array& object_table,
- Function* func) {
- ASSERT(instr->kind() == kRetAfterAddress);
- DeoptRetAfterAddressInstr* ret_after_instr =
- static_cast<DeoptRetAfterAddressInstr*>(instr);
+uword DeoptInstr::GetRetAddress(DeoptInstr* instr,
+ const Array& object_table,
+ Function* func) {
+ ASSERT(instr->kind() == kRetAddress);
+ DeoptRetAddressInstr* ret_address_instr =
+ static_cast<DeoptRetAddressInstr*>(instr);
+ ASSERT(Isolate::IsDeoptAfter(ret_address_instr->deopt_id()));
ASSERT(!object_table.IsNull());
ASSERT(func != NULL);
- *func ^= object_table.At(ret_after_instr->object_table_index());
+ *func ^= object_table.At(ret_address_instr->object_table_index());
const Code& code = Code::Handle(func->unoptimized_code());
ASSERT(!code.IsNull());
- uword res = code.GetDeoptAfterPcAtDeoptId(ret_after_instr->deopt_id());
+ uword res = code.GetPcForDeoptId(ret_address_instr->deopt_id(),
+ PcDescriptors::kDeopt);
ASSERT(res != 0);
return res;
}
@@ -740,8 +686,7 @@
return new DeoptFloat32x4StackSlotInstr(from_index);
case kUint32x4StackSlot:
return new DeoptUint32x4StackSlotInstr(from_index);
- case kRetAfterAddress: return new DeoptRetAfterAddressInstr(from_index);
- case kRetBeforeAddress: return new DeoptRetBeforeAddressInstr(from_index);
+ case kRetAddress: return new DeoptRetAddressInstr(from_index);
case kConstant: return new DeoptConstantInstr(from_index);
case kRegister: return new DeoptRegisterInstr(from_index);
case kFpuRegister: return new DeoptFpuRegisterInstr(from_index);
@@ -814,26 +759,19 @@
}
-void DeoptInfoBuilder::AddReturnAddressBefore(const Function& function,
- intptr_t deopt_id,
- intptr_t to_index) {
+void DeoptInfoBuilder::AddReturnAddress(const Function& function,
+ intptr_t deopt_id,
+ intptr_t to_index) {
// Check that deopt_id exists.
- ASSERT(Code::Handle(function.unoptimized_code()).
- GetDeoptBeforePcAtDeoptId(deopt_id) != 0);
+ // TODO(vegorov): verify after deoptimization targets as well.
+#ifdef DEBUG
+ const Code& code = Code::Handle(function.unoptimized_code());
+ ASSERT(Isolate::IsDeoptAfter(deopt_id) ||
+ (code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt) != 0));
+#endif
const intptr_t object_table_index = FindOrAddObjectInTable(function);
ASSERT(to_index == instructions_.length());
- instructions_.Add(new DeoptRetBeforeAddressInstr(object_table_index,
- deopt_id));
-}
-
-
-void DeoptInfoBuilder::AddReturnAddressAfter(const Function& function,
- intptr_t deopt_id,
- intptr_t to_index) {
- const intptr_t object_table_index = FindOrAddObjectInTable(function);
- ASSERT(to_index == instructions_.length());
- instructions_.Add(new DeoptRetAfterAddressInstr(object_table_index,
- deopt_id));
+ instructions_.Add(new DeoptRetAddressInstr(object_table_index, deopt_id));
}
@@ -846,24 +784,29 @@
}
-void DeoptInfoBuilder::AddCopy(const Location& from_loc,
+void DeoptInfoBuilder::AddCopy(Value* value,
+ const Location& from_loc,
const intptr_t to_index) {
DeoptInstr* deopt_instr = NULL;
if (from_loc.IsConstant()) {
intptr_t object_table_index = FindOrAddObjectInTable(from_loc.constant());
deopt_instr = new DeoptConstantInstr(object_table_index);
} else if (from_loc.IsRegister()) {
- ASSERT(from_loc.representation() == kTagged);
+ ASSERT(value->definition()->representation() == kTagged);
deopt_instr = new DeoptRegisterInstr(from_loc.reg());
} else if (from_loc.IsFpuRegister()) {
- if (from_loc.representation() == kUnboxedDouble) {
+ if (value->definition()->representation() == kUnboxedDouble) {
deopt_instr = new DeoptFpuRegisterInstr(from_loc.fpu_reg());
- } else {
- ASSERT(from_loc.representation() == kUnboxedMint);
+ } else if (value->definition()->representation() == kUnboxedMint) {
deopt_instr = new DeoptInt64FpuRegisterInstr(from_loc.fpu_reg());
+ } else if (value->definition()->representation() == kUnboxedFloat32x4) {
+ deopt_instr = new DeoptFloat32x4FpuRegisterInstr(from_loc.fpu_reg());
+ } else {
+ ASSERT(value->definition()->representation() == kUnboxedUint32x4);
+ deopt_instr = new DeoptUint32x4FpuRegisterInstr(from_loc.fpu_reg());
}
} else if (from_loc.IsStackSlot()) {
- ASSERT(from_loc.representation() == kTagged);
+ ASSERT(value->definition()->representation() == kTagged);
intptr_t from_index = (from_loc.stack_index() < 0) ?
from_loc.stack_index() + num_args_ :
from_loc.stack_index() + num_args_ - kFirstLocalSlotIndex + 1;
@@ -872,10 +815,10 @@
intptr_t from_index = (from_loc.stack_index() < 0) ?
from_loc.stack_index() + num_args_ :
from_loc.stack_index() + num_args_ - kFirstLocalSlotIndex + 1;
- if (from_loc.representation() == kUnboxedDouble) {
+ if (value->definition()->representation() == kUnboxedDouble) {
deopt_instr = new DeoptDoubleStackSlotInstr(from_index);
} else {
- ASSERT(from_loc.representation() == kUnboxedMint);
+ ASSERT(value->definition()->representation() == kUnboxedMint);
deopt_instr = new DeoptInt64StackSlotInstr(from_index);
}
} else {
diff --git a/runtime/vm/deopt_instructions.h b/runtime/vm/deopt_instructions.h
index 7967aa9..5f22368 100644
--- a/runtime/vm/deopt_instructions.h
+++ b/runtime/vm/deopt_instructions.h
@@ -95,8 +95,7 @@
class DeoptInstr : public ZoneAllocated {
public:
enum Kind {
- kRetAfterAddress,
- kRetBeforeAddress,
+ kRetAddress,
kConstant,
kRegister,
kFpuRegister,
@@ -136,9 +135,9 @@
// Get the function and return address which is encoded in this
// kRetAfterAddress deopt instruction.
- static uword GetRetAfterAddress(DeoptInstr* instr,
- const Array& object_table,
- Function* func);
+ static uword GetRetAddress(DeoptInstr* instr,
+ const Array& object_table,
+ Function* func);
protected:
virtual intptr_t from_index() const = 0;
@@ -164,17 +163,12 @@
const GrowableObjectArray& object_table() { return object_table_; }
// Return address before instruction.
- void AddReturnAddressBefore(const Function& function,
- intptr_t deopt_id,
- intptr_t to_index);
-
- // Return address after instruction.
- void AddReturnAddressAfter(const Function& function,
- intptr_t deopt_id,
- intptr_t to_index);
+ void AddReturnAddress(const Function& function,
+ intptr_t deopt_id,
+ intptr_t to_index);
// Copy from optimized frame to unoptimized.
- void AddCopy(const Location& from_loc, intptr_t to_index);
+ void AddCopy(Value* value, const Location& from_loc, intptr_t to_index);
void AddPcMarker(const Function& function, intptr_t to_index);
void AddCallerFp(intptr_t to_index);
void AddCallerPc(intptr_t to_index);
diff --git a/runtime/vm/disassembler_ia32.cc b/runtime/vm/disassembler_ia32.cc
index f17d0c7..49664cc 100644
--- a/runtime/vm/disassembler_ia32.cc
+++ b/runtime/vm/disassembler_ia32.cc
@@ -386,12 +386,16 @@
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
};
+static const int kMaxByteCPURegisters = 8;
+static const char* byte_cpu_regs[kMaxByteCPURegisters] = {
+ "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"
+};
+
static const int kMaxXmmRegisters = 8;
static const char* xmm_regs[kMaxXmmRegisters] = {
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
};
-
void X86Decoder::PrintCPURegister(int reg) {
ASSERT(0 <= reg);
ASSERT(reg < kMaxCPURegisters);
@@ -400,7 +404,9 @@
void X86Decoder::PrintCPUByteRegister(int reg) {
- UNIMPLEMENTED();
+ ASSERT(0 <= reg);
+ ASSERT(reg < kMaxByteCPURegisters);
+ Print(byte_cpu_regs[reg]);
}
@@ -634,8 +640,7 @@
int X86Decoder::PrintRightByteOperand(uint8_t* modrmp) {
- UNIMPLEMENTED();
- return 0;
+ return PrintRightOperandHelper(modrmp, &X86Decoder::PrintCPUByteRegister);
}
@@ -909,6 +914,11 @@
default:
UNIMPLEMENTED();
}
+ } else if (*(data+1) == 0xA4) {
+ Print("rep_movsb");
+ data += 2;
+ } else {
+ UNIMPLEMENTED();
}
return data;
}
diff --git a/runtime/vm/double_conversion.cc b/runtime/vm/double_conversion.cc
index 7f5b072..44233fe 100644
--- a/runtime/vm/double_conversion.cc
+++ b/runtime/vm/double_conversion.cc
@@ -166,4 +166,25 @@
return String::New(builder.Finalize());
}
+
+bool CStringToDouble(const char* str, intptr_t length, double* result) {
+ if (length == 0) {
+ return false;
+ }
+
+ double_conversion::StringToDoubleConverter converter(
+ double_conversion::StringToDoubleConverter::NO_FLAGS,
+ 0.0,
+ 0.0,
+ kDoubleToStringCommonInfinitySymbol,
+ kDoubleToStringCommonNaNSymbol);
+
+ int parsed_count = 0;
+ *result = converter.StringToDouble(str,
+ static_cast<int>(length),
+ &parsed_count);
+ return (parsed_count == length);
+}
+
+
} // namespace dart
diff --git a/runtime/vm/double_conversion.h b/runtime/vm/double_conversion.h
index c4f584d..ded82a4 100644
--- a/runtime/vm/double_conversion.h
+++ b/runtime/vm/double_conversion.h
@@ -15,6 +15,8 @@
RawString* DoubleToStringAsExponential(double d, int fraction_digits);
RawString* DoubleToStringAsPrecision(double d, int precision);
+bool CStringToDouble(const char* str, intptr_t length, double* result);
+
} // namespace dart
#endif // VM_DOUBLE_CONVERSION_H_
diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc
index 9f8e9a5..03074f7 100644
--- a/runtime/vm/flow_graph.cc
+++ b/runtime/vm/flow_graph.cc
@@ -29,8 +29,7 @@
graph_entry_(graph_entry),
preorder_(),
postorder_(),
- reverse_postorder_(),
- invalid_dominator_tree_(true) {
+ reverse_postorder_() {
DiscoverBlocks();
}
@@ -170,7 +169,11 @@
ASSERT(defn == curr->definition());
Instruction* instr = curr->instruction();
ASSERT(curr == instr->env()->ValueAtUseIndex(curr->use_index()));
- ASSERT((instr->IsPhi() && instr->AsPhi()->is_alive()) ||
+ // BlockEntry instructions have environments attached to them but
+ // have no reliable way to verify if they are still in the graph.
+ // Thus we just assume they are.
+ ASSERT(instr->IsBlockEntry() ||
+ (instr->IsPhi() && instr->AsPhi()->is_alive()) ||
(instr->previous() != NULL));
prev = curr;
curr = curr->next_use();
@@ -231,7 +234,6 @@
// (preorder block numbers of) blocks in the dominance frontier.
void FlowGraph::ComputeDominators(
GrowableArray<BitVector*>* dominance_frontier) {
- invalid_dominator_tree_ = false;
// Use the SEMI-NCA algorithm to compute dominators. This is a two-pass
// version of the Lengauer-Tarjan algorithm (LT is normally three passes)
// that eliminates a pass by using nearest-common ancestor (NCA) to
@@ -441,6 +443,23 @@
}
+void FlowGraph::AttachEnvironment(Instruction* instr,
+ GrowableArray<Definition*>* env) {
+ Environment* deopt_env =
+ Environment::From(*env,
+ num_non_copied_params_,
+ parsed_function_.function());
+ instr->SetEnvironment(deopt_env);
+ for (Environment::DeepIterator it(deopt_env); !it.Done(); it.Advance()) {
+ Value* use = it.CurrentValue();
+ use->definition()->AddEnvUse(use);
+ }
+ if (instr->CanDeoptimize()) {
+ instr->env()->set_deopt_id(instr->deopt_id());
+ }
+}
+
+
void FlowGraph::RenameRecursive(BlockEntryInstr* block_entry,
GrowableArray<Definition*>* env,
GrowableArray<PhiInstr*>* live_phis) {
@@ -458,25 +477,17 @@
}
}
+ // Attach environment to the block entry.
+ AttachEnvironment(block_entry, env);
+
// 2. Process normal instructions.
+
for (ForwardInstructionIterator it(block_entry); !it.Done(); it.Advance()) {
Instruction* current = it.Current();
- // Attach current environment to the instructions that can deoptimize and
- // at goto instructions. Optimizations like LICM expect an environment at
- // gotos.
- if (current->CanDeoptimize() || current->IsGoto()) {
- Environment* deopt_env =
- Environment::From(*env,
- num_non_copied_params_,
- parsed_function_.function());
- current->SetEnvironment(deopt_env);
- for (Environment::DeepIterator it(deopt_env); !it.Done(); it.Advance()) {
- Value* use = it.CurrentValue();
- use->definition()->AddEnvUse(use);
- }
- }
- if (current->CanDeoptimize()) {
- current->env()->set_deopt_id(current->deopt_id());
+
+ // Attach current environment to the instructions that need it.
+ if (current->NeedsEnvironment()) {
+ AttachEnvironment(current, env);
}
// 2a. Handle uses:
@@ -673,15 +684,6 @@
}
-void FlowGraph::RepairGraphAfterInlining() {
- DiscoverBlocks();
- if (invalid_dominator_tree_) {
- GrowableArray<BitVector*> dominance_frontier;
- ComputeDominators(&dominance_frontier);
- }
-}
-
-
intptr_t FlowGraph::InstructionCount() const {
intptr_t size = 0;
// Iterate each block, skipping the graph entry.
@@ -695,40 +697,4 @@
return size;
}
-
-const ZoneGrowableArray<Field*>* FlowGraph::FieldDependencies() const {
- ZoneGrowableArray<Field*>* result = new ZoneGrowableArray<Field*>(10);
-
- for (intptr_t i = 1; i < reverse_postorder().length(); i++) {
- BlockEntryInstr* entry = reverse_postorder()[i];
- for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
- LoadFieldInstr* load_field = it.Current()->AsLoadField();
- if (load_field == NULL) {
- continue;
- }
-
- Field* field = load_field->field();
- if ((field == NULL) ||
- (field->guarded_cid() == kDynamicCid) ||
- (field->guarded_cid() == kIllegalCid)) {
- continue;
- }
-
- bool found = false;
- for (intptr_t j = 0; j < result->length(); j++) {
- if ((*result)[j]->raw() == field->raw()) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- result->Add(field);
- }
- }
- }
-
- return result;
-}
-
} // namespace dart
diff --git a/runtime/vm/flow_graph.h b/runtime/vm/flow_graph.h
index a3c0235..13d9cba 100644
--- a/runtime/vm/flow_graph.h
+++ b/runtime/vm/flow_graph.h
@@ -129,29 +129,21 @@
// body blocks for each loop header.
void ComputeLoops(GrowableArray<BlockEntryInstr*>* loop_headers);
- void RepairGraphAfterInlining();
-
// TODO(zerny): Once the SSA is feature complete this should be removed.
void Bailout(const char* reason) const;
- void InvalidateDominatorTree() { invalid_dominator_tree_ = true; }
-
#ifdef DEBUG
// Verification methods for debugging.
bool VerifyUseLists();
#endif // DEBUG
- // Return all instance fields that are loaded in the graph and
- // have non-generic type feedback attached to them that can
- // potentially affect optimizations.
- const ZoneGrowableArray<Field*>* FieldDependencies() const;
+ void DiscoverBlocks();
private:
+ friend class IfConverter;
friend class BranchSimplifier;
friend class ConstantPropagator;
- void DiscoverBlocks();
-
// SSA transformation methods and fields.
void ComputeDominators(GrowableArray<BitVector*>* dominance_frontier);
@@ -168,6 +160,8 @@
GrowableArray<Definition*>* env,
GrowableArray<PhiInstr*>* live_phis);
+ void AttachEnvironment(Instruction* instr, GrowableArray<Definition*>* env);
+
void InsertPhis(
const GrowableArray<BlockEntryInstr*>& preorder,
const GrowableArray<BitVector*>& assigned_vars,
@@ -195,7 +189,6 @@
GrowableArray<BlockEntryInstr*> preorder_;
GrowableArray<BlockEntryInstr*> postorder_;
GrowableArray<BlockEntryInstr*> reverse_postorder_;
- bool invalid_dominator_tree_;
ConstantInstr* constant_null_;
};
diff --git a/runtime/vm/flow_graph_allocator.cc b/runtime/vm/flow_graph_allocator.cc
index c1f8f32..3b89eba 100644
--- a/runtime/vm/flow_graph_allocator.cc
+++ b/runtime/vm/flow_graph_allocator.cc
@@ -606,6 +606,7 @@
if (flow_graph_.num_copied_params() > 0) {
ASSERT(spill_slots_.length() == slot_index);
spill_slots_.Add(range->End());
+ quad_spill_slots_.Add(false);
}
AssignSafepoints(range);
} else {
@@ -993,9 +994,8 @@
}
for (intptr_t reg = 0; reg < kNumberOfFpuRegisters; reg++) {
- Representation ignored = kNoRepresentation;
BlockLocation(
- Location::FpuRegisterLocation(static_cast<FpuRegister>(reg), ignored),
+ Location::FpuRegisterLocation(static_cast<FpuRegister>(reg)),
pos,
pos + 1);
}
@@ -1581,40 +1581,76 @@
void FlowGraphAllocator::AllocateSpillSlotFor(LiveRange* range) {
ASSERT(range->spill_slot().IsInvalid());
- intptr_t idx = 0;
- for (; idx < spill_slots_.length(); idx++) {
- if (spill_slots_[idx] <= range->Start()) break;
- }
-
- if (idx == spill_slots_.length()) spill_slots_.Add(0);
-
+ // Compute range start and end.
LiveRange* last_sibling = range;
while (last_sibling->next_sibling() != NULL) {
last_sibling = last_sibling->next_sibling();
}
- spill_slots_[idx] = last_sibling->End();
+ const intptr_t start = range->Start();
+ const intptr_t end = last_sibling->End();
+ // During fpu register allocation spill slot indices are computed in terms of
+ // double (64bit) stack slots. We treat quad stack slot (128bit) as a
+ // consecutive pair of two double spill slots.
+ // Special care is taken to never allocate the same index to both
+ // double and quad spill slots as it complicates disambiguation during
+ // parallel move resolution.
+ const bool need_quad = (register_kind_ == Location::kFpuRegister) &&
+ ((range->representation() == kUnboxedFloat32x4) ||
+ (range->representation() == kUnboxedUint32x4));
+
+ // Search for a free spill slot among allocated: the value in it should be
+ // dead and its type should match (e.g. it should not be a part of the quad if
+ // we are allocating normal double slot).
+ intptr_t idx = 0;
+ for (; idx < spill_slots_.length(); idx++) {
+ if ((need_quad == quad_spill_slots_[idx]) &&
+ (spill_slots_[idx] <= start)) {
+ break;
+ }
+ }
+
+ if (idx == spill_slots_.length()) {
+ // No free spill slot found. Allocate a new one.
+ spill_slots_.Add(0);
+ quad_spill_slots_.Add(need_quad);
+ if (need_quad) { // Allocate two double stack slots if we need quad slot.
+ spill_slots_.Add(0);
+ quad_spill_slots_.Add(need_quad);
+ }
+ }
+
+
+ // Set spill slot expiration boundary to the live range's end.
+ spill_slots_[idx] = end;
+ if (need_quad) {
+ ASSERT(quad_spill_slots_[idx] && quad_spill_slots_[idx + 1]);
+ idx++; // Use the higher index it corresponds to the lower stack address.
+ spill_slots_[idx] = end;
+ } else {
+ ASSERT(!quad_spill_slots_[idx]);
+ }
+
+ // Assign spill slot to the range.
if (register_kind_ == Location::kRegister) {
range->set_spill_slot(Location::StackSlot(idx));
} else {
- // FPU register spill slots are essentially two (x64) or four (ia32) normal
- // word size spill slots. We use the index of the slot with the lowest
- // address as an index for the FPU register spill slot. In terms of indexes
- // this relation is inverted: so we have to take the highest index.
+ // We use the index of the slot with the lowest address as an index for the
+ // FPU register spill slot. In terms of indexes this relation is inverted:
+ // so we have to take the highest index.
const intptr_t slot_idx = cpu_spill_slot_count_ +
- idx * kFpuRegisterSpillFactor + (kFpuRegisterSpillFactor - 1);
+ idx * kDoubleSpillFactor + (kDoubleSpillFactor - 1);
Location location;
- if (range->representation() == kUnboxedFloat32x4) {
- location = Location::Float32x4StackSlot(slot_idx);
- } else if (range->representation() == kUnboxedUint32x4) {
- location = Location::Uint32x4StackSlot(slot_idx);
+ if ((range->representation() == kUnboxedFloat32x4) ||
+ (range->representation() == kUnboxedUint32x4)) {
+ ASSERT(need_quad);
+ location = Location::QuadStackSlot(slot_idx);
} else {
ASSERT((range->representation() == kUnboxedDouble) ||
(range->representation() == kUnboxedMint));
- location = Location::DoubleStackSlot(slot_idx,
- range->representation());
+ location = Location::DoubleStackSlot(slot_idx);
}
range->set_spill_slot(location);
}
@@ -1815,7 +1851,7 @@
TRACE_ALLOC(OS::Print(
"considering %s for v%"Pd": has interference on the back edge"
" {loop [%"Pd", %"Pd")}\n",
- MakeRegisterLocation(candidate, kUnboxedDouble).Name(),
+ MakeRegisterLocation(candidate).Name(),
unallocated->vreg(),
loop_header->entry()->start_pos(),
loop_header->last_block()->end_pos()));
@@ -1833,7 +1869,7 @@
free_until = intersection;
TRACE_ALLOC(OS::Print(
"found %s for v%"Pd" with no interference on the back edge\n",
- MakeRegisterLocation(candidate, kUnboxedDouble).Name(),
+ MakeRegisterLocation(candidate).Name(),
candidate));
break;
}
@@ -1842,7 +1878,7 @@
}
TRACE_ALLOC(OS::Print("assigning free register "));
- TRACE_ALLOC(MakeRegisterLocation(candidate, kUnboxedDouble).Print());
+ TRACE_ALLOC(MakeRegisterLocation(candidate).Print());
TRACE_ALLOC(OS::Print(" to v%"Pd"\n", unallocated->vreg()));
if (free_until != kMaxPosition) {
@@ -1853,8 +1889,7 @@
}
registers_[candidate].Add(unallocated);
- unallocated->set_assigned_location(
- MakeRegisterLocation(candidate, unallocated->representation()));
+ unallocated->set_assigned_location(MakeRegisterLocation(candidate));
return true;
}
@@ -1945,7 +1980,7 @@
}
TRACE_ALLOC(OS::Print("assigning blocked register "));
- TRACE_ALLOC(MakeRegisterLocation(candidate, kUnboxedDouble).Print());
+ TRACE_ALLOC(MakeRegisterLocation(candidate).Print());
TRACE_ALLOC(OS::Print(" to live range v%"Pd" until %"Pd"\n",
unallocated->vreg(), blocked_at));
@@ -2051,8 +2086,7 @@
if (first_evicted != -1) RemoveEvicted(reg, first_evicted);
registers_[reg].Add(unallocated);
- unallocated->set_assigned_location(
- MakeRegisterLocation(reg, unallocated->representation()));
+ unallocated->set_assigned_location(MakeRegisterLocation(reg));
}
@@ -2522,6 +2556,7 @@
cpu_spill_slot_count_ = spill_slots_.length();
spill_slots_.Clear();
+ quad_spill_slots_.Clear();
PrepareForAllocation(Location::kFpuRegister,
kNumberOfFpuRegisters,
@@ -2534,8 +2569,7 @@
GraphEntryInstr* entry = block_order_[0]->AsGraphEntry();
ASSERT(entry != NULL);
- intptr_t double_spill_slot_count =
- spill_slots_.length() * kFpuRegisterSpillFactor;
+ intptr_t double_spill_slot_count = spill_slots_.length() * kDoubleSpillFactor;
entry->set_spill_slot_count(cpu_spill_slot_count_ + double_spill_slot_count);
if (FLAG_print_ssa_liveranges) {
diff --git a/runtime/vm/flow_graph_allocator.h b/runtime/vm/flow_graph_allocator.h
index 5268c31..ab60b82 100644
--- a/runtime/vm/flow_graph_allocator.h
+++ b/runtime/vm/flow_graph_allocator.h
@@ -38,7 +38,7 @@
class FlowGraphAllocator : public ValueObject {
public:
// Number of stack slots needed for a fpu register spill slot.
- static const intptr_t kFpuRegisterSpillFactor = kFpuRegisterSize / kWordSize;
+ static const intptr_t kDoubleSpillFactor = kDoubleSize / kWordSize;
explicit FlowGraphAllocator(const FlowGraph& flow_graph);
@@ -227,8 +227,8 @@
MoveOperands* AddMoveAt(intptr_t pos, Location to, Location from);
- Location MakeRegisterLocation(intptr_t reg, Representation rep) {
- return Location::MachineRegisterLocation(register_kind_, reg, rep);
+ Location MakeRegisterLocation(intptr_t reg) {
+ return Location::MachineRegisterLocation(register_kind_, reg);
}
void PrintLiveRanges();
@@ -309,8 +309,13 @@
// List of used spill slots. Contains positions after which spill slots
// become free and can be reused for allocation.
GrowableArray<intptr_t> spill_slots_;
- intptr_t cpu_spill_slot_count_;
+ // For every used spill slot contains a flag determines whether it is
+ // QuadSpillSlot to ensure that indexes of quad and double spill slots
+ // are disjoint.
+ GrowableArray<bool> quad_spill_slots_;
+
+ intptr_t cpu_spill_slot_count_;
DISALLOW_COPY_AND_ASSIGN(FlowGraphAllocator);
};
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 337eebe..00b3932 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -62,17 +62,15 @@
}
-void InliningContext::PrepareGraphs(FlowGraph* caller_graph,
- Definition* call,
- FlowGraph* callee_graph) {
+void InliningContext::PrepareGraphs(FlowGraph* callee_graph) {
ASSERT(callee_graph->graph_entry()->SuccessorCount() == 1);
- ASSERT(callee_graph->max_block_id() > caller_graph->max_block_id());
+ ASSERT(callee_graph->max_block_id() > caller_graph_->max_block_id());
ASSERT(callee_graph->max_virtual_register_number() >
- caller_graph->max_virtual_register_number());
+ caller_graph_->max_virtual_register_number());
// Adjust the caller's maximum block id and current SSA temp index.
- caller_graph->set_max_block_id(callee_graph->max_block_id());
- caller_graph->set_current_ssa_temp_index(
+ caller_graph_->set_max_block_id(callee_graph->max_block_id());
+ caller_graph_->set_current_ssa_temp_index(
callee_graph->max_virtual_register_number());
// Attach the outer environment on each instruction in the callee graph.
@@ -86,7 +84,7 @@
// TODO(zerny): Avoid creating unnecessary environments. Note that some
// optimizations need deoptimization info for non-deoptable instructions,
// eg, LICM on GOTOs.
- if (instr->env() != NULL) call->env()->DeepCopyToOuter(instr);
+ if (instr->env() != NULL) call_->env()->DeepCopyToOuter(instr);
}
}
}
@@ -113,116 +111,181 @@
}
-void InliningContext::ReplaceCall(FlowGraph* caller_graph,
- Definition* call,
- FlowGraph* callee_graph) {
- ASSERT(call->previous() != NULL);
- ASSERT(call->next() != NULL);
- PrepareGraphs(caller_graph, call, callee_graph);
-
- BlockEntryInstr* caller_entry = call->GetBlock();
- TargetEntryInstr* callee_entry = callee_graph->graph_entry()->normal_entry();
-
- // Insert the callee graph into the caller graph. First sort the list of
- // exits by block id (recording block entries as a side effect).
+Definition* InliningContext::JoinReturns(BlockEntryInstr** exit_block,
+ Instruction** last_instruction) {
+ // First sort the list of exits by block id (caching return instruction
+ // block entries as a side effect).
SortExits();
intptr_t num_exits = exits_.length();
if (num_exits == 0) {
// TODO(zerny): Add support for non-local exits, such as throw.
UNREACHABLE();
+ return NULL;
} else if (num_exits == 1) {
- // For just one exit, replace the uses and remove the call from the graph.
- call->ReplaceUsesWith(ValueAt(0)->definition());
- ValueAt(0)->RemoveFromUseList();
- call->previous()->LinkTo(callee_entry->next());
- LastInstructionAt(0)->LinkTo(call->next());
- // In case of control flow, locally update the predecessors, phis and
- // dominator tree.
- // TODO(zerny): should we leave the dominator tree since we recompute it
- // after a full inlining pass?
- if (callee_graph->preorder().length() > 2) {
- BlockEntryInstr* exit_block = ExitBlockAt(0);
- // Pictorially, the graph structure is:
- //
- // Bc : caller_entry Bi : callee_entry
- // before_call inlined_head
- // call ... other blocks ...
- // after_call Be : exit_block
- // inlined_foot
- // And becomes:
- //
- // Bc : caller_entry
- // before_call
- // inlined_head
- // ... other blocks ...
- // Be : exit_block
- // inlined_foot
- // after_call
- //
- // For 'after_call', caller entry (Bc) is replaced by callee exit (Be).
- caller_entry->ReplaceAsPredecessorWith(exit_block);
- // For 'inlined_head', callee entry (Bi) is replaced by caller entry (Bc).
- callee_entry->ReplaceAsPredecessorWith(caller_entry);
- // The callee exit is now the immediate dominator of blocks whose
- // immediate dominator was the caller entry.
- ASSERT(exit_block->dominated_blocks().is_empty());
- for (intptr_t i = 0; i < caller_entry->dominated_blocks().length(); ++i) {
- BlockEntryInstr* block = caller_entry->dominated_blocks()[i];
- block->set_dominator(exit_block);
- exit_block->AddDominatedBlock(block);
- }
- // The caller entry is now the immediate dominator of blocks whose
- // immediate dominator was the callee entry.
- caller_entry->ClearDominatedBlocks();
- for (intptr_t i = 0; i < callee_entry->dominated_blocks().length(); ++i) {
- BlockEntryInstr* block = callee_entry->dominated_blocks()[i];
- block->set_dominator(caller_entry);
- caller_entry->AddDominatedBlock(block);
- }
- }
+ ReturnAt(0)->UnuseAllInputs();
+ *exit_block = ExitBlockAt(0);
+ *last_instruction = LastInstructionAt(0);
+ return call_->HasUses() ? ValueAt(0)->definition() : NULL;
} else {
// Create a join of the returns.
- intptr_t join_id = caller_graph->max_block_id() + 1;
- caller_graph->set_max_block_id(join_id);
+ intptr_t join_id = caller_graph_->max_block_id() + 1;
+ caller_graph_->set_max_block_id(join_id);
JoinEntryInstr* join =
new JoinEntryInstr(join_id, CatchClauseNode::kInvalidTryIndex);
+ join->InheritDeoptTarget(call_);
+
+ // The dominator set of the join is the intersection of the dominator
+ // sets of all the predecessors. If we keep the dominator sets ordered
+ // by height in the dominator tree, we can also get the immediate
+ // dominator of the join node from the intersection.
+ //
+ // block_dominators is the dominator set for each block, ordered from
+ // the immediate dominator to the root of the dominator tree. This is
+ // the order we collect them in (adding at the end).
+ //
+ // join_dominators is the join's dominators ordered from the root of the
+ // dominator tree to the immediate dominator. This order supports
+ // removing during intersection by truncating the list.
+ GrowableArray<BlockEntryInstr*> block_dominators;
+ GrowableArray<BlockEntryInstr*> join_dominators;
for (intptr_t i = 0; i < num_exits; ++i) {
- LastInstructionAt(i)->Goto(join);
- // Directly add the predecessors of the join in ascending block id order.
+ // Add the control-flow edge.
+ GotoInstr* goto_instr = new GotoInstr(join);
+ goto_instr->InheritDeoptTarget(ReturnAt(i));
+ LastInstructionAt(i)->LinkTo(goto_instr);
+ ExitBlockAt(i)->set_last_instruction(LastInstructionAt(i)->next());
join->predecessors_.Add(ExitBlockAt(i));
+
+ // Collect the block's dominators.
+ block_dominators.Clear();
+ BlockEntryInstr* dominator = ExitBlockAt(i)->dominator();
+ while (dominator != NULL) {
+ block_dominators.Add(dominator);
+ dominator = dominator->dominator();
+ }
+
+ if (i == 0) {
+ // The initial dominator set is the first predecessor's dominator
+ // set. Reverse it.
+ for (intptr_t j = block_dominators.length() - 1; j >= 0; --j) {
+ join_dominators.Add(block_dominators[j]);
+ }
+ } else {
+ // Intersect the block's dominators with the join's dominators so far.
+ intptr_t last = block_dominators.length() - 1;
+ for (intptr_t j = 0; j < join_dominators.length(); ++j) {
+ intptr_t k = last - j; // Corresponding index in block_dominators.
+ if ((k < 0) || (join_dominators[j] != block_dominators[k])) {
+ // We either exhausted the dominators for this block before
+ // exhausting the current intersection, or else we found a block
+ // on the path from the root of the tree that is not in common.
+ ASSERT(j >= 2);
+ join_dominators.TruncateTo(j);
+ break;
+ }
+ }
+ }
}
+ // The immediate dominator of the join is the last one in the ordered
+ // intersection.
+ join->set_dominator(join_dominators.Last());
+ join_dominators.Last()->AddDominatedBlock(join);
+ *exit_block = join;
+ *last_instruction = join;
+
// If the call has uses, create a phi of the returns.
- if (call->HasUses()) {
+ if (call_->HasUses()) {
// Add a phi of the return values.
PhiInstr* phi = new PhiInstr(join, num_exits);
- phi->set_ssa_temp_index(caller_graph->alloc_ssa_temp_index());
+ phi->set_ssa_temp_index(caller_graph_->alloc_ssa_temp_index());
phi->mark_alive();
for (intptr_t i = 0; i < num_exits; ++i) {
+ ReturnAt(i)->RemoveEnvironment();
phi->SetInputAt(i, ValueAt(i));
}
join->InsertPhi(phi);
- // Replace uses of the call with the phi.
- call->ReplaceUsesWith(phi);
+ return phi;
} else {
// In the case that the result is unused, remove the return value uses
// from their definition's use list.
for (intptr_t i = 0; i < num_exits; ++i) {
- ValueAt(i)->RemoveFromUseList();
+ ReturnAt(i)->UnuseAllInputs();
}
+ return NULL;
}
- // Remove the call from the graph.
- call->previous()->LinkTo(callee_entry->next());
- join->LinkTo(call->next());
- // Replace the blocks after splitting (see comment in the len=1 case above).
- caller_entry->ReplaceAsPredecessorWith(join);
- callee_entry->ReplaceAsPredecessorWith(caller_entry);
- // Update the last instruction pointers on each exit block to the new goto.
- for (intptr_t i = 0; i < num_exits; ++i) {
- ExitBlockAt(i)->set_last_instruction(LastInstructionAt(i)->next());
+ }
+}
+
+
+void InliningContext::ReplaceCall(FlowGraph* callee_graph) {
+ ASSERT(call_->previous() != NULL);
+ ASSERT(call_->next() != NULL);
+ PrepareGraphs(callee_graph);
+
+ BlockEntryInstr* call_block = call_->GetBlock();
+ TargetEntryInstr* callee_entry = callee_graph->graph_entry()->normal_entry();
+
+ // Insert the callee graph into the caller graph.
+ BlockEntryInstr* callee_exit = NULL;
+ Instruction* callee_last_instruction = NULL;
+ Definition* callee_result = JoinReturns(&callee_exit,
+ &callee_last_instruction);
+ if (callee_result != NULL) {
+ call_->ReplaceUsesWith(callee_result);
+ }
+ if (callee_last_instruction == callee_entry) {
+ // There are no instructions in the inlined function (e.g., it might be
+ // a return of a parameter or a return of a constant defined in the
+ // initial definitions).
+ call_->previous()->LinkTo(call_->next());
+ } else {
+ call_->previous()->LinkTo(callee_entry->next());
+ callee_last_instruction->LinkTo(call_->next());
+ }
+ if (callee_exit != callee_entry) {
+ // In case of control flow, locally update the predecessors, phis and
+ // dominator tree.
+ //
+ // Pictorially, the graph structure is:
+ //
+ // Bc : call_block Bi : callee_entry
+ // before_call inlined_head
+ // call ... other blocks ...
+ // after_call Be : callee_exit
+ // inlined_foot
+ // And becomes:
+ //
+ // Bc : call_block
+ // before_call
+ // inlined_head
+ // ... other blocks ...
+ // Be : callee_exit
+ // inlined_foot
+ // after_call
+ //
+ // For successors of 'after_call', the call block (Bc) is replaced as a
+ // predecessor by the callee exit (Be).
+ call_block->ReplaceAsPredecessorWith(callee_exit);
+ // For successors of 'inlined_head', the callee entry (Bi) is replaced
+ // as a predecessor by the call block (Bc).
+ callee_entry->ReplaceAsPredecessorWith(call_block);
+
+ // The callee exit is now the immediate dominator of blocks whose
+ // immediate dominator was the call block.
+ ASSERT(callee_exit->dominated_blocks().is_empty());
+ for (intptr_t i = 0; i < call_block->dominated_blocks().length(); ++i) {
+ BlockEntryInstr* block = call_block->dominated_blocks()[i];
+ block->set_dominator(callee_exit);
+ callee_exit->AddDominatedBlock(block);
}
- // Mark that the dominator tree is invalid.
- // TODO(zerny): Compute the dominator frontier locally.
- caller_graph->InvalidateDominatorTree();
+ // The call block is now the immediate dominator of blocks whose
+ // immediate dominator was the callee entry.
+ call_block->ClearDominatedBlocks();
+ for (intptr_t i = 0; i < callee_entry->dominated_blocks().length(); ++i) {
+ BlockEntryInstr* block = callee_entry->dominated_blocks()[i];
+ block->set_dominator(call_block);
+ call_block->AddDominatedBlock(block);
+ }
}
}
diff --git a/runtime/vm/flow_graph_builder.h b/runtime/vm/flow_graph_builder.h
index 825b381..4bb63ba 100644
--- a/runtime/vm/flow_graph_builder.h
+++ b/runtime/vm/flow_graph_builder.h
@@ -20,7 +20,8 @@
// graph construction so they can be plugged into the caller's flow graph.
class InliningContext: public ValueObject {
public:
- InliningContext() : exits_(4) { }
+ InliningContext(FlowGraph* caller_graph, Definition* call)
+ : caller_graph_(caller_graph), call_(call), exits_(4) { }
void AddExit(ReturnInstr* exit);
@@ -30,11 +31,11 @@
// context and transformed to SSA with ComputeSSA with a correct virtual
// register number, and that the use lists have been correctly computed.
//
- // After inlining the caller graph will correctly have adjusted the
- // pre/post orders, the dominator tree and the use lists.
- void ReplaceCall(FlowGraph* caller_graph,
- Definition* call,
- FlowGraph* callee_graph);
+ // After inlining the caller graph will have correctly adjusted the use
+ // lists. The block orders will need to be recomputed, and the dominator
+ // tree will need to be recomputed if it is marked invalid in the caller
+ // graph.
+ void ReplaceCall(FlowGraph* callee_graph);
private:
struct Data {
@@ -42,24 +43,33 @@
ReturnInstr* exit_return;
};
- static void PrepareGraphs(FlowGraph* caller_graph,
- Definition* call,
- FlowGraph* callee_graph);
+ void PrepareGraphs(FlowGraph* caller_graph);
BlockEntryInstr* ExitBlockAt(intptr_t i) const {
ASSERT(exits_[i].exit_block != NULL);
return exits_[i].exit_block;
}
+
Instruction* LastInstructionAt(intptr_t i) const {
- return exits_[i].exit_return->previous();
+ return ReturnAt(i)->previous();
}
+
Value* ValueAt(intptr_t i) const {
- return exits_[i].exit_return->value();
+ return ReturnAt(i)->value();
+ }
+
+ ReturnInstr* ReturnAt(intptr_t i) const {
+ return exits_[i].exit_return;
}
static int LowestBlockIdFirst(const Data* a, const Data* b);
void SortExits();
+ Definition* JoinReturns(BlockEntryInstr** exit_block,
+ Instruction** last_instruction);
+
+ FlowGraph* caller_graph_;
+ Definition* call_;
GrowableArray<Data> exits_;
};
diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc
index 55add24..14e4dd9 100644
--- a/runtime/vm/flow_graph_compiler.cc
+++ b/runtime/vm/flow_graph_compiler.cc
@@ -31,19 +31,6 @@
DECLARE_FLAG(int, optimization_counter_threshold);
DECLARE_FLAG(bool, use_cha);
-void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder,
- const Function& function,
- intptr_t slot_ix) {
- builder->AddReturnAddressAfter(function, deopt_id(), slot_ix);
-}
-
-
-void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder,
- const Function& function,
- intptr_t slot_ix) {
- builder->AddReturnAddressBefore(function, deopt_id(), slot_ix);
-}
-
// Assign locations to incoming arguments, i.e., values pushed above spill slots
// with PushArgument. Recursively allocates from outermost to innermost
@@ -72,14 +59,15 @@
intptr_t slot_ix = 0;
Environment* current = deoptimization_env_;
- // For the innermost environment, call the virtual return builder.
- BuildReturnAddress(builder, current->function(), slot_ix++);
+ builder->AddReturnAddress(current->function(),
+ deopt_id(),
+ slot_ix++);
// For the innermost environment, set outgoing arguments and the locals.
for (intptr_t i = current->Length() - 1;
i >= current->fixed_parameter_count();
i--) {
- builder->AddCopy(current->LocationAt(i), slot_ix++);
+ builder->AddCopy(current->ValueAt(i), current->LocationAt(i), slot_ix++);
}
// PC marker and caller FP.
@@ -91,21 +79,25 @@
while (current != NULL) {
// For any outer environment the deopt id is that of the call instruction
// which is recorded in the outer environment.
- builder->AddReturnAddressAfter(current->function(),
- current->deopt_id(),
- slot_ix++);
+ builder->AddReturnAddress(current->function(),
+ Isolate::ToDeoptAfter(current->deopt_id()),
+ slot_ix++);
// The values of outgoing arguments can be changed from the inlined call so
// we must read them from the previous environment.
for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) {
- builder->AddCopy(previous->LocationAt(i), slot_ix++);
+ builder->AddCopy(previous->ValueAt(i),
+ previous->LocationAt(i),
+ slot_ix++);
}
// Set the locals, note that outgoing arguments are not in the environment.
for (intptr_t i = current->Length() - 1;
i >= current->fixed_parameter_count();
i--) {
- builder->AddCopy(current->LocationAt(i), slot_ix++);
+ builder->AddCopy(current->ValueAt(i),
+ current->LocationAt(i),
+ slot_ix++);
}
// PC marker and caller FP.
@@ -124,7 +116,7 @@
// For the outermost environment, set the incoming arguments.
for (intptr_t i = previous->fixed_parameter_count() - 1; i >= 0; i--) {
- builder->AddCopy(previous->LocationAt(i), slot_ix++);
+ builder->AddCopy(previous->ValueAt(i), previous->LocationAt(i), slot_ix++);
}
const DeoptInfo& deopt_info = DeoptInfo::Handle(builder->CreateDeoptInfo());
@@ -151,6 +143,8 @@
may_reoptimize_(false),
double_class_(Class::ZoneHandle(
Isolate::Current()->object_store()->double_class())),
+ float32x4_class_(Class::ZoneHandle(
+ Isolate::Current()->object_store()->float32x4_class())),
parallel_move_resolver_(this),
pending_deoptimization_env_(NULL) {
ASSERT(assembler != NULL);
@@ -416,7 +410,7 @@
// FPU registers have the highest register number at the highest
// address (i.e., first in the stackmap).
const intptr_t kFpuRegisterSpillFactor =
- FlowGraphAllocator::kFpuRegisterSpillFactor;
+ kFpuRegisterSize / kWordSize;
for (intptr_t i = kNumberOfFpuRegisters - 1; i >= 0; --i) {
FpuRegister reg = static_cast<FpuRegister>(i);
if (regs->ContainsFpuRegister(reg)) {
@@ -944,6 +938,99 @@
}
+bool ParallelMoveResolver::IsScratchLocation(Location loc) {
+ for (int i = 0; i < moves_.length(); ++i) {
+ if (moves_[i]->Blocks(loc)) {
+ return false;
+ }
+ }
+
+ for (int i = 0; i < moves_.length(); ++i) {
+ if (moves_[i]->dest().Equals(loc)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+intptr_t ParallelMoveResolver::AllocateScratchRegister(Location::Kind kind,
+ intptr_t blocked,
+ intptr_t register_count,
+ bool* spilled) {
+ intptr_t scratch = -1;
+ for (intptr_t reg = 0; reg < register_count; reg++) {
+ if ((blocked != reg) &&
+ IsScratchLocation(Location::MachineRegisterLocation(kind, reg))) {
+ scratch = reg;
+ break;
+ }
+ }
+
+ if (scratch == -1) {
+ *spilled = true;
+ for (intptr_t reg = 0; reg < register_count; reg++) {
+ if (blocked != reg) {
+ scratch = reg;
+ }
+ }
+ } else {
+ *spilled = false;
+ }
+
+ return scratch;
+}
+
+
+ParallelMoveResolver::ScratchFpuRegisterScope::ScratchFpuRegisterScope(
+ ParallelMoveResolver* resolver, FpuRegister blocked)
+ : resolver_(resolver),
+ reg_(kNoFpuRegister),
+ spilled_(false) {
+ reg_ = static_cast<FpuRegister>(
+ resolver_->AllocateScratchRegister(Location::kFpuRegister,
+ blocked,
+ kNumberOfFpuRegisters,
+ &spilled_));
+
+ if (spilled_) {
+ resolver->SpillFpuScratch(reg_);
+ }
+}
+
+
+ParallelMoveResolver::ScratchFpuRegisterScope::~ScratchFpuRegisterScope() {
+ if (spilled_) {
+ resolver_->RestoreFpuScratch(reg_);
+ }
+}
+
+
+ParallelMoveResolver::ScratchRegisterScope::ScratchRegisterScope(
+ ParallelMoveResolver* resolver, Register blocked)
+ : resolver_(resolver),
+ reg_(kNoRegister),
+ spilled_(false) {
+ reg_ = static_cast<Register>(
+ resolver_->AllocateScratchRegister(Location::kRegister,
+ blocked,
+ kNumberOfCpuRegisters,
+ &spilled_));
+
+ if (spilled_) {
+ resolver->SpillScratch(reg_);
+ }
+}
+
+
+ParallelMoveResolver::ScratchRegisterScope::~ScratchRegisterScope() {
+ if (spilled_) {
+ resolver_->RestoreScratch(reg_);
+ }
+}
+
+
intptr_t FlowGraphCompiler::ElementSizeFor(intptr_t cid) {
if (RawObject::IsExternalTypedDataClassId(cid)) {
return ExternalTypedData::ElementSizeInBytes(cid);
diff --git a/runtime/vm/flow_graph_compiler.h b/runtime/vm/flow_graph_compiler.h
index f141fd1..6ae9b1f 100644
--- a/runtime/vm/flow_graph_compiler.h
+++ b/runtime/vm/flow_graph_compiler.h
@@ -31,6 +31,47 @@
void EmitNativeCode(ParallelMoveInstr* parallel_move);
private:
+ class ScratchFpuRegisterScope : public ValueObject {
+ public:
+ ScratchFpuRegisterScope(ParallelMoveResolver* resolver,
+ FpuRegister blocked);
+ ~ScratchFpuRegisterScope();
+
+ FpuRegister reg() const { return reg_; }
+
+ private:
+ ParallelMoveResolver* resolver_;
+ FpuRegister reg_;
+ bool spilled_;
+ };
+
+ class ScratchRegisterScope : public ValueObject {
+ public:
+ ScratchRegisterScope(ParallelMoveResolver* resolver, Register blocked);
+ ~ScratchRegisterScope();
+
+ Register reg() const { return reg_; }
+
+ private:
+ ParallelMoveResolver* resolver_;
+ Register reg_;
+ bool spilled_;
+ };
+
+
+ bool IsScratchLocation(Location loc);
+ intptr_t AllocateScratchRegister(Location::Kind kind,
+ intptr_t blocked,
+ intptr_t register_count,
+ bool* spilled);
+
+ void SpillScratch(Register reg);
+ void RestoreScratch(Register reg);
+ void SpillFpuScratch(FpuRegister reg);
+ void RestoreFpuScratch(FpuRegister reg);
+
+ // friend class ScratchXmmRegisterScope;
+
// Build the initial list of moves.
void BuildInitialMoveList(ParallelMoveInstr* parallel_move);
@@ -81,11 +122,6 @@
// No code needs to be generated.
virtual void GenerateCode(FlowGraphCompiler* compiler, intptr_t stub_ix) {}
- // Builds deopt-after continuation point.
- virtual void BuildReturnAddress(DeoptInfoBuilder* builder,
- const Function& function,
- intptr_t slot_ix);
-
intptr_t pc_offset() const { return pc_offset_; }
void set_pc_offset(intptr_t offset) { pc_offset_ = offset; }
@@ -119,11 +155,6 @@
// Implementation is in architecture specific file.
virtual void GenerateCode(FlowGraphCompiler* compiler, intptr_t stub_ix);
- // Builds deopt-before continuation point.
- virtual void BuildReturnAddress(DeoptInfoBuilder* builder,
- const Function& function,
- intptr_t slot_ix);
-
private:
Label entry_label_;
@@ -381,6 +412,7 @@
void FinalizeStaticCallTargetsTable(const Code& code);
const Class& double_class() const { return double_class_; }
+ const Class& float32x4_class() const { return float32x4_class_; }
void SaveLiveRegisters(LocationSummary* locs);
void RestoreLiveRegisters(LocationSummary* locs);
@@ -539,6 +571,7 @@
bool may_reoptimize_;
const Class& double_class_;
+ const Class& float32x4_class_;
ParallelMoveResolver parallel_move_resolver_;
diff --git a/runtime/vm/flow_graph_compiler_arm.cc b/runtime/vm/flow_graph_compiler_arm.cc
index db7e56a..c9b8b86 100644
--- a/runtime/vm/flow_graph_compiler_arm.cc
+++ b/runtime/vm/flow_graph_compiler_arm.cc
@@ -408,9 +408,18 @@
if (!is_optimizing()) {
if (FLAG_enable_type_checks && instr->IsAssertAssignable()) {
AssertAssignableInstr* assert = instr->AsAssertAssignable();
- AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
assert->deopt_id(),
assert->token_pos());
+ } else if (instr->IsGuardField()) {
+ GuardFieldInstr* guard = instr->AsGuardField();
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ guard->deopt_id(),
+ Scanner::kDummyTokenIndex);
+ } else if (instr->CanBeDeoptimizationTarget()) {
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ instr->deopt_id(),
+ Scanner::kDummyTokenIndex);
}
AllocateRegistersLocally(instr);
}
@@ -884,14 +893,13 @@
RecordSafepoint(locs);
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
- token_pos);
+ AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos);
}
}
@@ -906,13 +914,14 @@
if (deopt_id != Isolate::kNoDeoptId) {
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ deopt_id_after,
token_pos);
}
}
@@ -1146,8 +1155,7 @@
if (destination.IsDoubleStackSlot()) {
__ vstrd(source.fpu_reg(), destination.ToStackSlotAddress());
} else {
- ASSERT(destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot());
+ ASSERT(destination.IsQuadStackSlot());
UNIMPLEMENTED();
}
}
@@ -1159,7 +1167,7 @@
__ vldrd(FpuTMP, source.ToStackSlotAddress());
__ vstrd(FpuTMP, destination.ToStackSlotAddress());
}
- } else if (source.IsFloat32x4StackSlot() || source.IsUint32x4StackSlot()) {
+ } else if (source.IsQuadStackSlot()) {
UNIMPLEMENTED();
} else {
ASSERT(source.IsConstant());
@@ -1199,11 +1207,9 @@
__ vmovd(destination.fpu_reg(), FpuTMP);
} else if (source.IsFpuRegister() || destination.IsFpuRegister()) {
ASSERT(destination.IsDoubleStackSlot() ||
- destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot() ||
+ destination.IsQuadStackSlot() ||
source.IsDoubleStackSlot() ||
- source.IsFloat32x4StackSlot() ||
- source.IsUint32x4StackSlot());
+ source.IsQuadStackSlot());
bool double_width = destination.IsDoubleStackSlot() ||
source.IsDoubleStackSlot();
DRegister reg = source.IsFpuRegister() ? source.fpu_reg()
@@ -1219,6 +1225,17 @@
} else {
UNIMPLEMENTED();
}
+ } else if (source.IsDoubleStackSlot() && destination.IsDoubleStackSlot()) {
+ const Address& source_slot_address = source.ToStackSlotAddress();
+ const Address& destination_slot_address = destination.ToStackSlotAddress();
+
+ ScratchFpuRegisterScope ensure_scratch(this, FpuTMP);
+ __ vldrd(FpuTMP, source_slot_address);
+ __ vldrd(ensure_scratch.reg(), destination_slot_address);
+ __ vstrd(FpuTMP, destination_slot_address);
+ __ vstrd(ensure_scratch.reg(), source_slot_address);
+ } else if (source.IsQuadStackSlot() && destination.IsQuadStackSlot()) {
+ UNIMPLEMENTED();
} else {
UNREACHABLE();
}
@@ -1263,13 +1280,31 @@
void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) {
- // TODO(vegorov): allocate temporary registers for such moves.
- __ Push(R0);
- __ ldr(R0, mem1);
+ ScratchRegisterScope ensure_scratch(this, IP);
+ __ ldr(ensure_scratch.reg(), mem1);
__ ldr(IP, mem2);
+ __ str(ensure_scratch.reg(), mem2);
__ str(IP, mem1);
- __ str(R0, mem2);
- __ Pop(R0);
+}
+
+
+void ParallelMoveResolver::SpillScratch(Register reg) {
+ __ Push(reg);
+}
+
+
+void ParallelMoveResolver::RestoreScratch(Register reg) {
+ __ Pop(reg);
+}
+
+
+void ParallelMoveResolver::SpillFpuScratch(FpuRegister reg) {
+ __ vstrd(reg, Address(SP, -kDoubleSize, Address::PreIndex));
+}
+
+
+void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
+ __ vldrd(reg, Address(SP, kDoubleSize, Address::PostIndex));
}
diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc
index 0113aeb..dce40df 100644
--- a/runtime/vm/flow_graph_compiler_ia32.cc
+++ b/runtime/vm/flow_graph_compiler_ia32.cc
@@ -505,7 +505,10 @@
__ pushl(EDX); // Instantiator type arguments.
__ LoadObject(EAX, test_cache);
__ pushl(EAX);
- GenerateCallRuntime(token_pos, deopt_id, kInstanceofRuntimeEntry, locs);
+ GenerateCallRuntime(token_pos,
+ deopt_id,
+ kInstanceofRuntimeEntry,
+ locs);
// Pop the parameters supplied to the runtime entry. The result of the
// instanceof runtime call will be left as the result of the operation.
__ Drop(5);
@@ -628,14 +631,18 @@
if (!is_optimizing()) {
if (FLAG_enable_type_checks && instr->IsAssertAssignable()) {
AssertAssignableInstr* assert = instr->AsAssertAssignable();
- AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
assert->deopt_id(),
assert->token_pos());
} else if (instr->IsGuardField()) {
GuardFieldInstr* guard = instr->AsGuardField();
- AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
guard->deopt_id(),
Scanner::kDummyTokenIndex);
+ } else if (instr->CanBeDeoptimizationTarget()) {
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ instr->deopt_id(),
+ Scanner::kDummyTokenIndex);
}
AllocateRegistersLocally(instr);
}
@@ -1094,14 +1101,13 @@
RecordSafepoint(locs);
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
- token_pos);
+ AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos);
}
}
@@ -1116,14 +1122,13 @@
if (deopt_id != Isolate::kNoDeoptId) {
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
- token_pos);
+ AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos);
}
}
}
@@ -1235,7 +1240,7 @@
__ call(EAX);
AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
RecordSafepoint(locs);
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
__ Drop(argument_count);
}
@@ -1529,6 +1534,7 @@
case 2: return TIMES_1;
case 4: return TIMES_2;
case 8: return TIMES_4;
+ case 16: return TIMES_8;
default:
UNREACHABLE();
return TIMES_1;
@@ -1596,8 +1602,7 @@
if (destination.IsDoubleStackSlot()) {
__ movsd(destination.ToStackSlotAddress(), source.fpu_reg());
} else {
- ASSERT(destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot());
+ ASSERT(destination.IsQuadStackSlot());
__ movups(destination.ToStackSlotAddress(), source.fpu_reg());
}
}
@@ -1609,12 +1614,11 @@
__ movsd(XMM0, source.ToStackSlotAddress());
__ movsd(destination.ToStackSlotAddress(), XMM0);
}
- } else if (source.IsFloat32x4StackSlot() || source.IsUint32x4StackSlot()) {
+ } else if (source.IsQuadStackSlot()) {
if (destination.IsFpuRegister()) {
__ movups(destination.fpu_reg(), source.ToStackSlotAddress());
} else {
- ASSERT(destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot());
+ ASSERT(destination.IsQuadStackSlot());
__ movups(XMM0, source.ToStackSlotAddress());
__ movups(destination.ToStackSlotAddress(), XMM0);
}
@@ -1656,11 +1660,9 @@
__ movaps(destination.fpu_reg(), XMM0);
} else if (source.IsFpuRegister() || destination.IsFpuRegister()) {
ASSERT(destination.IsDoubleStackSlot() ||
- destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot() ||
+ destination.IsQuadStackSlot() ||
source.IsDoubleStackSlot() ||
- source.IsFloat32x4StackSlot() ||
- source.IsUint32x4StackSlot());
+ source.IsQuadStackSlot());
bool double_width = destination.IsDoubleStackSlot() ||
source.IsDoubleStackSlot();
XmmRegister reg = source.IsFpuRegister() ? source.fpu_reg()
@@ -1677,6 +1679,24 @@
__ movups(slot_address, reg);
}
__ movaps(reg, XMM0);
+ } else if (source.IsDoubleStackSlot() && destination.IsDoubleStackSlot()) {
+ const Address& source_slot_address = source.ToStackSlotAddress();
+ const Address& destination_slot_address = destination.ToStackSlotAddress();
+
+ ScratchFpuRegisterScope ensure_scratch(this, XMM0);
+ __ movsd(XMM0, source_slot_address);
+ __ movsd(ensure_scratch.reg(), destination_slot_address);
+ __ movsd(destination_slot_address, XMM0);
+ __ movsd(source_slot_address, ensure_scratch.reg());
+ } else if (source.IsQuadStackSlot() && destination.IsQuadStackSlot()) {
+ const Address& source_slot_address = source.ToStackSlotAddress();
+ const Address& destination_slot_address = destination.ToStackSlotAddress();
+
+ ScratchFpuRegisterScope ensure_scratch(this, XMM0);
+ __ movups(XMM0, source_slot_address);
+ __ movups(ensure_scratch.reg(), destination_slot_address);
+ __ movups(destination_slot_address, XMM0);
+ __ movups(source_slot_address, ensure_scratch.reg());
} else {
UNREACHABLE();
}
@@ -1701,48 +1721,60 @@
void ParallelMoveResolver::MoveMemoryToMemory(const Address& dst,
const Address& src) {
- // TODO(vegorov): allocate temporary register for such moves.
- __ pushl(EAX);
- __ movl(EAX, src);
- __ movl(dst, EAX);
- __ popl(EAX);
+ ScratchRegisterScope ensure_scratch(this, kNoRegister);
+ __ movl(ensure_scratch.reg(), src);
+ __ movl(dst, ensure_scratch.reg());
}
void ParallelMoveResolver::StoreObject(const Address& dst, const Object& obj) {
- // TODO(vegorov): allocate temporary register for such moves.
if (obj.IsSmi() || obj.IsNull()) {
__ movl(dst, Immediate(reinterpret_cast<int32_t>(obj.raw())));
} else {
- __ pushl(EAX);
- __ LoadObject(EAX, obj);
- __ movl(dst, EAX);
- __ popl(EAX);
+ ScratchRegisterScope ensure_scratch(this, kNoRegister);
+ __ LoadObject(ensure_scratch.reg(), obj);
+ __ movl(dst, ensure_scratch.reg());
}
}
void ParallelMoveResolver::Exchange(Register reg, const Address& mem) {
- // TODO(vegorov): allocate temporary register for such moves.
- Register scratch = (reg == EAX) ? ECX : EAX;
- __ pushl(scratch);
- __ movl(scratch, mem);
- __ xchgl(scratch, reg);
- __ movl(mem, scratch);
- __ popl(scratch);
+ ScratchRegisterScope ensure_scratch(this, reg);
+ __ movl(ensure_scratch.reg(), mem);
+ __ movl(mem, reg);
+ __ movl(reg, ensure_scratch.reg());
}
void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) {
- // TODO(vegorov): allocate temporary registers for such moves.
- __ pushl(EAX);
- __ pushl(ECX);
- __ movl(EAX, mem1);
- __ movl(ECX, mem2);
- __ movl(mem1, ECX);
- __ movl(mem2, EAX);
- __ popl(ECX);
- __ popl(EAX);
+ ScratchRegisterScope ensure_scratch1(this, kNoRegister);
+ ScratchRegisterScope ensure_scratch2(this, ensure_scratch1.reg());
+ __ movl(ensure_scratch1.reg(), mem1);
+ __ movl(ensure_scratch2.reg(), mem2);
+ __ movl(mem2, ensure_scratch1.reg());
+ __ movl(mem1, ensure_scratch2.reg());
+}
+
+
+void ParallelMoveResolver::SpillScratch(Register reg) {
+ __ pushl(reg);
+}
+
+
+void ParallelMoveResolver::RestoreScratch(Register reg) {
+ __ popl(reg);
+}
+
+
+void ParallelMoveResolver::SpillFpuScratch(FpuRegister reg) {
+ __ subl(ESP, Immediate(kFpuRegisterSize));
+ __ movups(Address(ESP, 0), reg);
+}
+
+
+void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
+ __ movups(reg, Address(ESP, 0));
+ __ addl(ESP, Immediate(kFpuRegisterSize));
}
diff --git a/runtime/vm/flow_graph_compiler_mips.cc b/runtime/vm/flow_graph_compiler_mips.cc
index 778ffcd..8a54d5b 100644
--- a/runtime/vm/flow_graph_compiler_mips.cc
+++ b/runtime/vm/flow_graph_compiler_mips.cc
@@ -49,13 +49,21 @@
#define __ assembler()->
+// Fall through if bool_register contains null.
void FlowGraphCompiler::GenerateBoolToJump(Register bool_register,
Label* is_true,
Label* is_false) {
- UNIMPLEMENTED();
+ Label fall_through;
+ __ BranchEqual(bool_register, reinterpret_cast<intptr_t>(Object::null()),
+ &fall_through);
+ __ BranchEqual(bool_register, Bool::True(), is_true);
+ __ b(is_false);
+ __ Bind(&fall_through);
}
+// A0: instance (must be preserved).
+// A1: instantiator type arguments (if used).
RawSubtypeTestCache* FlowGraphCompiler::GenerateCallSubtypeTestStub(
TypeTestStubKind test_kind,
Register instance_reg,
@@ -63,8 +71,28 @@
Register temp_reg,
Label* is_instance_lbl,
Label* is_not_instance_lbl) {
- UNIMPLEMENTED();
- return NULL;
+ ASSERT(instance_reg == A0);
+ ASSERT(temp_reg == kNoRegister); // Unused on MIPS.
+ const SubtypeTestCache& type_test_cache =
+ SubtypeTestCache::ZoneHandle(SubtypeTestCache::New());
+ __ LoadObject(A2, type_test_cache);
+ if (test_kind == kTestTypeOneArg) {
+ ASSERT(type_arguments_reg == kNoRegister);
+ __ LoadImmediate(A1, reinterpret_cast<intptr_t>(Object::null()));
+ __ BranchLink(&StubCode::Subtype1TestCacheLabel());
+ } else if (test_kind == kTestTypeTwoArgs) {
+ ASSERT(type_arguments_reg == kNoRegister);
+ __ LoadImmediate(A1, reinterpret_cast<intptr_t>(Object::null()));
+ __ BranchLink(&StubCode::Subtype2TestCacheLabel());
+ } else if (test_kind == kTestTypeThreeArgs) {
+ ASSERT(type_arguments_reg == A1);
+ __ BranchLink(&StubCode::Subtype3TestCacheLabel());
+ } else {
+ UNREACHABLE();
+ }
+ // Result is in V0: null -> not found, otherwise Bool::True or Bool::False.
+ GenerateBoolToJump(V0, is_instance_lbl, is_not_instance_lbl);
+ return type_test_cache.raw();
}
@@ -84,8 +112,7 @@
Label* is_equal_lbl,
Label* is_not_equal_lbl) {
for (intptr_t i = 0; i < class_ids.length(); i++) {
- __ LoadImmediate(TMP, class_ids[i]);
- __ beq(class_id_reg, TMP, is_equal_lbl);
+ __ BranchEqual(class_id_reg, class_ids[i], is_equal_lbl);
}
__ b(is_not_equal_lbl);
}
@@ -121,14 +148,13 @@
// Compare if the classes are equal.
const Register kClassIdReg = T0;
__ LoadClassId(kClassIdReg, kInstanceReg);
- __ LoadImmediate(T1, type_class.id());
- __ beq(kClassIdReg, T1, is_instance_lbl);
+ __ BranchEqual(kClassIdReg, type_class.id(), is_instance_lbl);
+
// See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
// interfaces.
// Bool interface can be implemented only by core class Bool.
if (type.IsBoolType()) {
- __ LoadImmediate(T1, kBoolCid);
- __ beq(kClassIdReg, T1, is_instance_lbl);
+ __ BranchEqual(kClassIdReg, kBoolCid, is_instance_lbl);
__ b(is_not_instance_lbl);
return false;
}
@@ -136,8 +162,8 @@
// Check if instance is a closure.
__ LoadClassById(T1, kClassIdReg);
__ lw(T1, FieldAddress(T1, Class::signature_function_offset()));
- __ LoadImmediate(T2, reinterpret_cast<int32_t>(Object::null()));
- __ bne(T1, T2, is_instance_lbl);
+ __ BranchNotEqual(T1, reinterpret_cast<int32_t>(Object::null()),
+ is_instance_lbl);
}
// Custom checking for numbers (Smi, Mint, Bigint and Double).
// Note that instance is not Smi (checked above).
@@ -155,13 +181,35 @@
}
+// Uses SubtypeTestCache to store instance class and result.
+// A0: instance to test.
+// Clobbers A1, A2, T0-T3.
+// Immediate class test already done.
+// TODO(srdjan): Implement a quicker subtype check, as type test
+// arrays can grow too high, but they may be useful when optimizing
+// code (type-feedback).
RawSubtypeTestCache* FlowGraphCompiler::GenerateSubtype1TestCacheLookup(
intptr_t token_pos,
const Class& type_class,
Label* is_instance_lbl,
Label* is_not_instance_lbl) {
- UNIMPLEMENTED();
- return NULL;
+ __ Comment("Subtype1TestCacheLookup");
+ const Register kInstanceReg = A0;
+ __ LoadClass(T0, kInstanceReg);
+ // T0: instance class.
+ // Check immediate superclass equality.
+ __ lw(T0, FieldAddress(T0, Class::super_type_offset()));
+ __ lw(T0, FieldAddress(T0, Type::type_class_offset()));
+ __ BranchEqual(T0, type_class, is_instance_lbl);
+
+ const Register kTypeArgumentsReg = kNoRegister;
+ const Register kTempReg = kNoRegister;
+ return GenerateCallSubtypeTestStub(kTestTypeOneArg,
+ kInstanceReg,
+ kTypeArgumentsReg,
+ kTempReg,
+ is_instance_lbl,
+ is_not_instance_lbl);
}
@@ -204,8 +252,7 @@
} else {
__ beq(T0, ZR, is_not_instance_lbl);
__ LoadClassId(T0, kInstanceReg);
- __ LoadImmediate(T1, type_cid);
- __ beq(T0, T1, is_instance_lbl);
+ __ BranchEqual(T0, type_cid, is_instance_lbl);
}
__ b(is_not_instance_lbl);
return SubtypeTestCache::null();
@@ -282,14 +329,12 @@
__ sw(A1, Address(SP, 0 * kWordSize));
// A null object is always assignable and is returned as result.
Label is_assignable, runtime_call;
- __ LoadImmediate(T0, reinterpret_cast<int32_t>(Object::null()));
- __ beq(A0, T0, &is_assignable);
+ __ BranchEqual(A0, reinterpret_cast<int32_t>(Object::null()), &is_assignable);
if (!FLAG_eliminate_type_checks) {
// If type checks are not eliminated during the graph building then
// a transition sentinel can be seen here.
- __ LoadObject(T0, Object::transition_sentinel());
- __ beq(A0, T0, &is_assignable);
+ __ BranchEqual(A0, Object::transition_sentinel(), &is_assignable);
}
// Generate throw new TypeError() if the type is malformed.
@@ -334,8 +379,8 @@
__ sw(A2, Address(SP, 1 * kWordSize));
__ sw(A1, Address(SP, 0 * kWordSize));
__ PushObject(dst_name); // Push the name of the destination.
- __ LoadObject(A0, test_cache);
- __ Push(A0);
+ __ LoadObject(T0, test_cache);
+ __ Push(T0);
GenerateCallRuntime(token_pos, deopt_id, kTypeCheckRuntimeEntry, locs);
// Pop the parameters supplied to the runtime entry. The result of the
// type check runtime call is the checked value.
@@ -344,9 +389,9 @@
__ Bind(&is_assignable);
// Restore instantiator and its type arguments.
- __ lw(A1, Address(SP, 0 * kWordSize));
- __ lw(A2, Address(SP, 1 * kWordSize));
- __ addiu(SP, SP, Immediate(2 * kWordSize));
+ __ lw(A1, Address(SP, 0 * kWordSize));
+ __ lw(A2, Address(SP, 1 * kWordSize));
+ __ addiu(SP, SP, Immediate(2 * kWordSize));
}
@@ -354,9 +399,18 @@
if (!is_optimizing()) {
if (FLAG_enable_type_checks && instr->IsAssertAssignable()) {
AssertAssignableInstr* assert = instr->AsAssertAssignable();
- AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
assert->deopt_id(),
assert->token_pos());
+ } else if (instr->IsGuardField()) {
+ GuardFieldInstr* guard = instr->AsGuardField();
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ guard->deopt_id(),
+ Scanner::kDummyTokenIndex);
+ } else if (instr->CanBeDeoptimizationTarget()) {
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ instr->deopt_id(),
+ Scanner::kDummyTokenIndex);
}
AllocateRegistersLocally(instr);
}
@@ -394,29 +448,27 @@
__ lw(T2, FieldAddress(S4, ArgumentsDescriptor::positional_count_offset()));
// Check that min_num_pos_args <= num_pos_args.
Label wrong_num_arguments;
- __ addiu(T3, T2, Immediate(-Smi::RawValue(min_num_pos_args)));
- __ bltz(T3, &wrong_num_arguments);
+ __ BranchLess(T2, Smi::RawValue(min_num_pos_args), &wrong_num_arguments);
// Check that num_pos_args <= max_num_pos_args.
- __ addiu(T3, T2, Immediate(-Smi::RawValue(max_num_pos_args)));
- __ bgtz(T3, &wrong_num_arguments);
+ __ BranchGreater(T2, Smi::RawValue(max_num_pos_args), &wrong_num_arguments);
// Copy positional arguments.
// Argument i passed at fp[kLastParamSlotIndex + num_args - 1 - i] is copied
// to fp[kFirstLocalSlotIndex - i].
__ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
- // Since T1 and T2 are Smi, use LSL 1 instead of LSL 2.
+ // Since T1 and T2 are Smi, use sll 1 instead of sll 2.
// Let T1 point to the last passed positional argument, i.e. to
// fp[kLastParamSlotIndex + num_args - 1 - (num_pos_args - 1)].
__ subu(T1, T1, T2);
__ sll(T1, T1, 1);
__ addu(T1, FP, T1);
- __ addiu(T1, T1, Immediate(kLastParamSlotIndex * kWordSize));
+ __ AddImmediate(T1, kLastParamSlotIndex * kWordSize);
// Let T0 point to the last copied positional argument, i.e. to
// fp[kFirstLocalSlotIndex - (num_pos_args - 1)].
- __ addiu(T0, FP, Immediate((kFirstLocalSlotIndex + 1) * kWordSize));
+ __ AddImmediate(T0, FP, (kFirstLocalSlotIndex + 1) * kWordSize);
__ sll(T3, T2, 1); // T2 is a Smi.
__ subu(T0, T0, T3);
@@ -429,8 +481,8 @@
__ Bind(&loop);
__ addu(T4, T1, T2);
__ addu(T5, T0, T2);
- __ lw(TMP, Address(T4));
- __ sw(TMP, Address(T5));
+ __ lw(T3, Address(T4));
+ __ sw(T3, Address(T5));
__ Bind(&loop_condition);
__ addiu(T2, T2, Immediate(-kWordSize));
__ bgez(T2, &loop);
@@ -464,10 +516,10 @@
// fp[kLastParamSlotIndex + num_args - 1 - 0]; num_args (T1) is Smi.
__ sll(T3, T1, 1);
__ addu(T1, FP, T3);
- __ addiu(T1, T1, Immediate((kLastParamSlotIndex - 1) * kWordSize));
+ __ AddImmediate(T1, (kLastParamSlotIndex - 1) * kWordSize);
// Let T0 point to the entry of the first named argument.
- __ addiu(T0, S4, Immediate(
- ArgumentsDescriptor::first_named_entry_offset() - kHeapObjectTag));
+ __ AddImmediate(T0, S4,
+ ArgumentsDescriptor::first_named_entry_offset() - kHeapObjectTag);
for (int i = 0; i < num_opt_named_params; i++) {
Label load_default_value, assign_optional_parameter;
const int param_pos = opt_param_position[i];
@@ -475,15 +527,14 @@
// Load T3 with the name of the argument.
__ lw(T3, Address(T0, ArgumentsDescriptor::name_offset()));
ASSERT(opt_param[i]->name().IsSymbol());
- __ LoadObject(T4, opt_param[i]->name());
- __ bne(T3, T4, &load_default_value);
+ __ BranchNotEqual(T3, opt_param[i]->name(), &load_default_value);
// Load T3 with passed-in argument at provided arg_pos, i.e. at
// fp[kLastParamSlotIndex + num_args - 1 - arg_pos].
__ lw(T3, Address(T0, ArgumentsDescriptor::position_offset()));
// T3 is arg_pos as Smi.
// Point to next named entry.
- __ addiu(T0, T0, Immediate(ArgumentsDescriptor::named_entry_size()));
+ __ AddImmediate(T0, ArgumentsDescriptor::named_entry_size());
__ subu(T3, ZR, T3);
__ sll(T3, T3, 1);
__ addu(T3, T1, T3);
@@ -508,8 +559,8 @@
delete[] opt_param_position;
// Check that T0 now points to the null terminator in the array descriptor.
__ lw(T3, Address(T0));
- __ LoadImmediate(T4, reinterpret_cast<int32_t>(Object::null()));
- __ beq(T3, T4, &all_arguments_processed);
+ __ BranchEqual(T3, reinterpret_cast<int32_t>(Object::null()),
+ &all_arguments_processed);
} else {
ASSERT(num_opt_pos_params > 0);
__ lw(T2,
@@ -521,8 +572,7 @@
// arguments have been passed, where k is param_pos, the position of this
// optional parameter in the formal parameter list.
const int param_pos = num_fixed_params + i;
- __ addiu(T3, T2, Immediate(-param_pos));
- __ bgtz(T3, &next_parameter);
+ __ BranchGreater(T2, param_pos, &next_parameter);
// Load T3 with default argument.
const Object& value = Object::ZoneHandle(
parsed_function().default_parameter_values().At(i));
@@ -538,7 +588,7 @@
__ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
__ SmiUntag(T1);
// Check that T2 equals T1, i.e. no named arguments passed.
- __ beq(T2, T2, &all_arguments_processed);
+ __ beq(T2, T1, &all_arguments_processed);
}
__ Bind(&wrong_num_arguments);
@@ -546,7 +596,7 @@
// We need to unwind the space we reserved for locals and copied parameters.
// The NoSuchMethodFunction stub does not expect to see that area on the
// stack.
- __ addiu(SP, SP, Immediate(StackSize() * kWordSize));
+ __ AddImmediate(SP, StackSize() * kWordSize);
}
// The call below has an empty stackmap because we have just
// dropped the spill slots.
@@ -590,13 +640,13 @@
__ lw(T2, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
__ SmiUntag(T2);
- __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
+ __ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null()));
Label null_args_loop, null_args_loop_condition;
__ b(&null_args_loop_condition);
__ delay_slot()->addiu(T1, FP, Immediate(kLastParamSlotIndex * kWordSize));
__ Bind(&null_args_loop);
__ addu(T3, T1, T2);
- __ sw(TMP, Address(T3));
+ __ sw(T0, Address(T3));
__ Bind(&null_args_loop_condition);
__ addiu(T2, T2, Immediate(-kWordSize));
__ bgez(T2, &null_args_loop);
@@ -622,7 +672,7 @@
Label next;
// The pool pointer is not setup before entering the Dart frame.
- __ mov(TMP, RA); // Save RA.
+ __ mov(TMP1, RA); // Save RA.
__ bal(&next); // Branch and link to next instruction to get PC in RA.
__ delay_slot()->mov(T2, RA); // Save PC of the following mov.
@@ -632,7 +682,7 @@
assembler()->CodeSize();
__ Bind(&next);
- __ mov(RA, TMP); // Restore RA.
+ __ mov(RA, TMP1); // Restore RA.
// Preserve PP of caller.
__ mov(T1, PP);
@@ -666,9 +716,7 @@
// Skip Branch if T1 is less than the threshold.
Label dont_branch;
- __ LoadImmediate(T2, FLAG_optimization_counter_threshold);
- __ sltu(T2, T1, T2);
- __ bgtz(T2, &dont_branch);
+ __ BranchLess(T1, FLAG_optimization_counter_threshold, &dont_branch);
ASSERT(function_reg == T0);
__ Branch(&StubCode::OptimizeFunctionLabel());
@@ -729,8 +777,8 @@
// Check that exactly num_fixed arguments are passed in.
Label correct_num_arguments, wrong_num_arguments;
__ lw(T0, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
- __ LoadImmediate(T1, Smi::RawValue(num_fixed_params));
- __ bne(T0, T1, &wrong_num_arguments);
+ __ BranchNotEqual(T0, Smi::RawValue(num_fixed_params),
+ &wrong_num_arguments);
__ lw(T1, FieldAddress(S4,
ArgumentsDescriptor::positional_count_offset()));
@@ -741,7 +789,7 @@
// We need to unwind the space we reserved for locals and copied
// parameters. The NoSuchMethodFunction stub does not expect to see
// that area on the stack.
- __ addiu(SP, SP, Immediate(StackSize() * kWordSize));
+ __ AddImmediate(SP, StackSize() * kWordSize);
}
// The call below has an empty stackmap because we have just
// dropped the spill slots.
@@ -853,13 +901,14 @@
RecordSafepoint(locs);
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ deopt_id_after,
token_pos);
}
}
@@ -869,7 +918,23 @@
intptr_t deopt_id,
const RuntimeEntry& entry,
LocationSummary* locs) {
- __ Unimplemented("call runtime");
+ __ CallRuntime(entry);
+ AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos);
+ RecordSafepoint(locs);
+ if (deopt_id != Isolate::kNoDeoptId) {
+ // Marks either the continuation point in unoptimized code or the
+ // deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
+ if (is_optimizing()) {
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
+ } else {
+ // Add deoptimization continuation point after the call and before the
+ // arguments are removed.
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ deopt_id_after,
+ token_pos);
+ }
+ }
}
@@ -943,7 +1008,16 @@
void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left,
Register right,
bool needs_number_check) {
- UNIMPLEMENTED();
+ if (needs_number_check) {
+ __ Push(left);
+ __ Push(right);
+ __ BranchLink(&StubCode::IdenticalWithNumberCheckLabel());
+ // Stub returns result in CMPRES. If it is 0, then left and right are equal.
+ __ Pop(right);
+ __ Pop(left);
+ } else {
+ __ subu(CMPRES, left, right);
+ }
}
@@ -1111,6 +1185,26 @@
}
+void ParallelMoveResolver::SpillScratch(Register reg) {
+ UNIMPLEMENTED();
+}
+
+
+void ParallelMoveResolver::RestoreScratch(Register reg) {
+ UNIMPLEMENTED();
+}
+
+
+void ParallelMoveResolver::SpillFpuScratch(FpuRegister reg) {
+ UNIMPLEMENTED();
+}
+
+
+void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
+ UNIMPLEMENTED();
+}
+
+
} // namespace dart
#endif // defined TARGET_ARCH_MIPS
diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc
index b4da30b..48d2624 100644
--- a/runtime/vm/flow_graph_compiler_x64.cc
+++ b/runtime/vm/flow_graph_compiler_x64.cc
@@ -504,7 +504,10 @@
__ pushq(RDX); // Instantiator type arguments.
__ LoadObject(RAX, test_cache);
__ pushq(RAX);
- GenerateCallRuntime(token_pos, deopt_id, kInstanceofRuntimeEntry, locs);
+ GenerateCallRuntime(token_pos,
+ deopt_id,
+ kInstanceofRuntimeEntry,
+ locs);
// Pop the parameters supplied to the runtime entry. The result of the
// instanceof runtime call will be left as the result of the operation.
__ Drop(5);
@@ -624,14 +627,18 @@
if (!is_optimizing()) {
if (FLAG_enable_type_checks && instr->IsAssertAssignable()) {
AssertAssignableInstr* assert = instr->AsAssertAssignable();
- AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
assert->deopt_id(),
assert->token_pos());
} else if (instr->IsGuardField()) {
GuardFieldInstr* guard = instr->AsGuardField();
- AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
guard->deopt_id(),
Scanner::kDummyTokenIndex);
+ } else if (instr->CanBeDeoptimizationTarget()) {
+ AddCurrentDescriptor(PcDescriptors::kDeopt,
+ instr->deopt_id(),
+ Scanner::kDummyTokenIndex);
}
AllocateRegistersLocally(instr);
}
@@ -1094,14 +1101,13 @@
RecordSafepoint(locs);
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
- token_pos);
+ AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos);
}
}
@@ -1116,14 +1122,13 @@
if (deopt_id != Isolate::kNoDeoptId) {
// Marks either the continuation point in unoptimized code or the
// deoptimization point in optimized code, after call.
+ const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id);
if (is_optimizing()) {
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(deopt_id_after, token_pos);
} else {
// Add deoptimization continuation point after the call and before the
// arguments are removed.
- AddCurrentDescriptor(PcDescriptors::kDeoptAfter,
- deopt_id,
- token_pos);
+ AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos);
}
}
}
@@ -1235,7 +1240,7 @@
__ call(RAX);
AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
RecordSafepoint(locs);
- AddDeoptIndexAtCall(deopt_id, token_pos);
+ AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
__ Drop(argument_count);
}
@@ -1529,6 +1534,7 @@
case 2: return TIMES_1;
case 4: return TIMES_2;
case 8: return TIMES_4;
+ case 16: return TIMES_8;
default:
UNREACHABLE();
return TIMES_1;
@@ -1596,8 +1602,7 @@
if (destination.IsDoubleStackSlot()) {
__ movsd(destination.ToStackSlotAddress(), source.fpu_reg());
} else {
- ASSERT(destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot());
+ ASSERT(destination.IsQuadStackSlot());
__ movups(destination.ToStackSlotAddress(), source.fpu_reg());
}
}
@@ -1609,12 +1614,11 @@
__ movsd(XMM0, source.ToStackSlotAddress());
__ movsd(destination.ToStackSlotAddress(), XMM0);
}
- } else if (source.IsFloat32x4StackSlot() || source.IsUint32x4StackSlot()) {
+ } else if (source.IsQuadStackSlot()) {
if (destination.IsFpuRegister()) {
__ movups(destination.fpu_reg(), source.ToStackSlotAddress());
} else {
- ASSERT(destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot());
+ ASSERT(destination.IsQuadStackSlot());
__ movups(XMM0, source.ToStackSlotAddress());
__ movups(destination.ToStackSlotAddress(), XMM0);
}
@@ -1656,11 +1660,9 @@
__ movaps(destination.fpu_reg(), XMM0);
} else if (source.IsFpuRegister() || destination.IsFpuRegister()) {
ASSERT(destination.IsDoubleStackSlot() ||
- destination.IsFloat32x4StackSlot() ||
- destination.IsUint32x4StackSlot() ||
+ destination.IsQuadStackSlot() ||
source.IsDoubleStackSlot() ||
- source.IsFloat32x4StackSlot() ||
- source.IsUint32x4StackSlot());
+ source.IsQuadStackSlot());
bool double_width = destination.IsDoubleStackSlot() ||
source.IsDoubleStackSlot();
XmmRegister reg = source.IsFpuRegister() ? source.fpu_reg()
@@ -1677,6 +1679,24 @@
__ movups(slot_address, reg);
}
__ movaps(reg, XMM0);
+ } else if (source.IsDoubleStackSlot() && destination.IsDoubleStackSlot()) {
+ const Address& source_slot_address = source.ToStackSlotAddress();
+ const Address& destination_slot_address = destination.ToStackSlotAddress();
+
+ ScratchFpuRegisterScope ensure_scratch(this, XMM0);
+ __ movsd(XMM0, source_slot_address);
+ __ movsd(ensure_scratch.reg(), destination_slot_address);
+ __ movsd(destination_slot_address, XMM0);
+ __ movsd(source_slot_address, ensure_scratch.reg());
+ } else if (source.IsQuadStackSlot() && destination.IsQuadStackSlot()) {
+ const Address& source_slot_address = source.ToStackSlotAddress();
+ const Address& destination_slot_address = destination.ToStackSlotAddress();
+
+ ScratchFpuRegisterScope ensure_scratch(this, XMM0);
+ __ movups(XMM0, source_slot_address);
+ __ movups(ensure_scratch.reg(), destination_slot_address);
+ __ movups(destination_slot_address, XMM0);
+ __ movups(source_slot_address, ensure_scratch.reg());
} else {
UNREACHABLE();
}
@@ -1720,6 +1740,28 @@
}
+void ParallelMoveResolver::SpillScratch(Register reg) {
+ __ pushq(reg);
+}
+
+
+void ParallelMoveResolver::RestoreScratch(Register reg) {
+ __ popq(reg);
+}
+
+
+void ParallelMoveResolver::SpillFpuScratch(FpuRegister reg) {
+ __ subq(RSP, Immediate(kFpuRegisterSize));
+ __ movups(Address(RSP, 0), reg);
+}
+
+
+void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
+ __ movups(reg, Address(RSP, 0));
+ __ addq(RSP, Immediate(kFpuRegisterSize));
+}
+
+
#undef __
} // namespace dart
diff --git a/runtime/vm/flow_graph_inliner.cc b/runtime/vm/flow_graph_inliner.cc
index 91552ab..2956d0c 100644
--- a/runtime/vm/flow_graph_inliner.cc
+++ b/runtime/vm/flow_graph_inliner.cc
@@ -292,7 +292,7 @@
class CallSiteInliner : public ValueObject {
public:
- explicit CallSiteInliner(FlowGraph* flow_graph)
+ CallSiteInliner(FlowGraph* flow_graph, GrowableArray<Field*>* guarded_fields)
: caller_graph_(flow_graph),
inlined_(false),
initial_size_(flow_graph->InstructionCount()),
@@ -300,7 +300,8 @@
inlining_depth_(1),
collected_call_sites_(NULL),
inlining_call_sites_(NULL),
- function_cache_() { }
+ function_cache_(),
+ guarded_fields_(guarded_fields) { }
// Inlining heuristics based on Cooper et al. 2008.
bool ShouldWeInline(intptr_t instr_count,
@@ -438,7 +439,7 @@
}
// Build the callee graph.
- InliningContext inlining_context;
+ InliningContext inlining_context(caller_graph_, call);
FlowGraphBuilder builder(*parsed_function, &inlining_context);
builder.SetInitialBlockId(caller_graph_->max_block_id());
FlowGraph* callee_graph;
@@ -501,7 +502,7 @@
&CompilerStats::graphinliner_opt_timer,
isolate);
// TODO(zerny): Do more optimization passes on the callee graph.
- FlowGraphOptimizer optimizer(callee_graph);
+ FlowGraphOptimizer optimizer(callee_graph, guarded_fields_);
optimizer.ApplyICData();
DEBUG_ASSERT(callee_graph->VerifyUseLists());
}
@@ -561,7 +562,7 @@
isolate);
// Plug result in the caller graph.
- inlining_context.ReplaceCall(caller_graph_, call, callee_graph);
+ inlining_context.ReplaceCall(callee_graph);
// Replace each stub with the actual argument or the caller's constant.
// Nulls denote optional parameters for which no actual was given.
@@ -834,6 +835,7 @@
CallSites* collected_call_sites_;
CallSites* inlining_call_sites_;
GrowableArray<ParsedFunction*> function_cache_;
+ GrowableArray<Field*>* guarded_fields_;
DISALLOW_COPY_AND_ASSIGN(CallSiteInliner);
};
@@ -874,11 +876,11 @@
printer.PrintBlocks();
}
- CallSiteInliner inliner(flow_graph_);
+ CallSiteInliner inliner(flow_graph_, guarded_fields_);
inliner.InlineCalls();
if (inliner.inlined()) {
- flow_graph_->RepairGraphAfterInlining();
+ flow_graph_->DiscoverBlocks();
if (FLAG_trace_inlining) {
OS::Print("Inlining growth factor: %f\n", inliner.GrowthFactor());
if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) {
diff --git a/runtime/vm/flow_graph_inliner.h b/runtime/vm/flow_graph_inliner.h
index f95f8de..fd8c518 100644
--- a/runtime/vm/flow_graph_inliner.h
+++ b/runtime/vm/flow_graph_inliner.h
@@ -9,13 +9,14 @@
namespace dart {
+class Field;
class FlowGraph;
template <typename T> class GrowableArray;
class FlowGraphInliner : ValueObject {
public:
- explicit FlowGraphInliner(FlowGraph* flow_graph)
- : flow_graph_(flow_graph) {}
+ FlowGraphInliner(FlowGraph* flow_graph, GrowableArray<Field*>* guarded_fields)
+ : flow_graph_(flow_graph), guarded_fields_(guarded_fields) {}
// The flow graph is destructively updated upon inlining.
void Inline();
@@ -24,6 +25,8 @@
private:
FlowGraph* flow_graph_;
+ GrowableArray<Field*>* guarded_fields_;
+
DISALLOW_COPY_AND_ASSIGN(FlowGraphInliner);
};
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index bcd752c..404caab 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -21,9 +21,6 @@
DEFINE_FLAG(bool, array_bounds_check_elimination, true,
"Eliminate redundant bounds checks.");
-// TODO(srdjan): Enable/remove flag once it works.
-DEFINE_FLAG(bool, inline_getter_with_guarded_cid, false,
- "Inline implict getter using guarded cid");
DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination.");
DEFINE_FLAG(int, max_polymorphic_checks, 4,
"Maximum number of polymorphic check, otherwise it is megamorphic.");
@@ -348,7 +345,7 @@
converted = new UnboxDoubleInstr(new Value(boxed), deopt_id);
} else if ((from == kUnboxedDouble) && (to == kTagged)) {
- converted = new BoxDoubleInstr(use->CopyWithType(), NULL);
+ converted = new BoxDoubleInstr(use->CopyWithType());
} else if ((from == kTagged) && (to == kUnboxedDouble)) {
ASSERT((deopt_target != NULL) ||
@@ -366,6 +363,14 @@
} else {
converted = new UnboxDoubleInstr(use->CopyWithType(), deopt_id);
}
+ } else if ((from == kTagged) && (to == kUnboxedFloat32x4)) {
+ ASSERT((deopt_target != NULL) ||
+ (use->Type()->ToCid() == kFloat32x4Cid));
+ const intptr_t deopt_id = (deopt_target != NULL) ?
+ deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
+ converted = new UnboxFloat32x4Instr(use->CopyWithType(), deopt_id);
+ } else if ((from == kUnboxedFloat32x4) && (to == kTagged)) {
+ converted = new BoxFloat32x4Instr(use->CopyWithType());
}
ASSERT(converted != NULL);
use->BindTo(converted);
@@ -766,6 +771,15 @@
}
break;
}
+ case kTypedDataFloat32x4ArrayCid: {
+ // Check that value is always a Float32x4.
+ value_check = call->ic_data()->AsUnaryClassChecksForArgNr(2);
+ if ((value_check.NumberOfChecks() != 1) ||
+ (value_check.GetReceiverClassIdAt(0) != kFloat32x4Cid)) {
+ return false;
+ }
+ }
+ break;
default:
// TODO(fschneider): Add support for other array types.
return false;
@@ -827,6 +841,13 @@
ASSERT(value_type.IsInstantiated());
break;
}
+ case kTypedDataFloat32x4ArrayCid: {
+ type_args = instantiator = flow_graph_->constant_null();
+ ASSERT((class_id != kTypedDataFloat32x4ArrayCid) ||
+ value_type.IsFloat32x4Type());
+ ASSERT(value_type.IsInstantiated());
+ break;
+ }
default:
// TODO(fschneider): Add support for other array types.
UNREACHABLE();
@@ -853,8 +874,8 @@
RawObject::IsExternalTypedDataClassId(array_cid)) ? kNoStoreBarrier
: kEmitStoreBarrier;
if (!value_check.IsNull()) {
- // No store barrier needed because checked value is a smi, an unboxed mint
- // or unboxed double.
+ // No store barrier needed because checked value is a smi, an unboxed mint,
+ // an unboxed double, an unboxed Float32x4, or unboxed Uint32x4.
needs_store_barrier = kNoStoreBarrier;
AddCheckClass(stored_value, value_check, call->deopt_id(), call->env(),
call);
@@ -883,6 +904,7 @@
case kGrowableObjectArrayCid:
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
+ case kTypedDataFloat32x4ArrayCid:
case kTypedDataInt8ArrayCid:
case kTypedDataUint8ArrayCid:
case kTypedDataUint8ClampedArrayCid:
@@ -1177,6 +1199,20 @@
}
+void FlowGraphOptimizer::AddToGuardedFields(Field* field) {
+ if ((field->guarded_cid() == kDynamicCid) ||
+ (field->guarded_cid() == kIllegalCid)) {
+ return;
+ }
+ for (intptr_t j = 0; j < guarded_fields_->length(); j++) {
+ if ((*guarded_fields_)[j]->raw() == field->raw()) {
+ return;
+ }
+ }
+ guarded_fields_->Add(field);
+}
+
+
void FlowGraphOptimizer::InlineImplicitInstanceGetter(InstanceCallInstr* call) {
ASSERT(call->HasICData());
const ICData& ic_data = *call->ic_data();
@@ -1202,7 +1238,9 @@
if (!field.is_nullable() || (field.guarded_cid() == kNullCid)) {
load->set_result_cid(field.guarded_cid());
}
- load->set_field(&Field::ZoneHandle(field.raw()));
+ Field* the_field = &Field::ZoneHandle(field.raw());
+ load->set_field(the_field);
+ AddToGuardedFields(the_field);
}
load->set_field_name(String::Handle(field.name()).ToCString());
@@ -1211,14 +1249,12 @@
call->RemoveEnvironment();
ReplaceCall(call, load);
- if (FLAG_inline_getter_with_guarded_cid) {
- if (load->result_cid() != kDynamicCid) {
- // Reset value types if guarded_cid was used.
- for (Value::Iterator it(load->input_use_list());
- !it.Done();
- it.Advance()) {
- it.Current()->SetReachingType(NULL);
- }
+ if (load->result_cid() != kDynamicCid) {
+ // Reset value types if guarded_cid was used.
+ for (Value::Iterator it(load->input_use_list());
+ !it.Done();
+ it.Advance()) {
+ it.Current()->SetReachingType(NULL);
}
}
}
@@ -1459,6 +1495,7 @@
case kTypedDataUint32ArrayCid:
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
+ case kTypedDataFloat32x4ArrayCid:
return true;
default:
return false;
@@ -1592,6 +1629,9 @@
case MethodRecognizer::kByteArrayBaseGetFloat64:
return BuildByteArrayViewLoad(
call, class_ids[0], kTypedDataFloat64ArrayCid);
+ case MethodRecognizer::kByteArrayBaseGetFloat32x4:
+ return BuildByteArrayViewLoad(
+ call, class_ids[0], kTypedDataFloat32x4ArrayCid);
// ByteArray setters.
case MethodRecognizer::kByteArrayBaseSetInt8:
@@ -1618,6 +1658,9 @@
case MethodRecognizer::kByteArrayBaseSetFloat64:
return BuildByteArrayViewStore(
call, class_ids[0], kTypedDataFloat64ArrayCid);
+ case MethodRecognizer::kByteArrayBaseSetFloat32x4:
+ return BuildByteArrayViewStore(
+ call, class_ids[0], kTypedDataFloat32x4ArrayCid);
default:
// Unsupported method.
return false;
@@ -1700,6 +1743,15 @@
value_check.AddReceiverCheck(kDoubleCid, Function::Handle());
break;
}
+ case kTypedDataFloat32x4ArrayCid: {
+ // Check that value is always Float32x4.
+ value_check = ICData::New(Function::Handle(),
+ String::Handle(),
+ Isolate::kNoDeoptId,
+ 1);
+ value_check.AddReceiverCheck(kFloat32x4Cid, Function::Handle());
+ break;
+ }
default:
// Array cids are already checked in the caller.
UNREACHABLE();
@@ -1846,7 +1898,8 @@
new Value(instantiator),
new Value(type_args),
type,
- negate);
+ negate,
+ call->deopt_id());
ReplaceCall(call, instance_of);
}
@@ -1886,6 +1939,9 @@
new Value(type_args),
type,
dst_name);
+ // Newly inserted instructions that can deoptimize or throw an exception
+ // must have a deoptimization id that is valid for lookup in the unoptimized
+ // code.
assert_as->deopt_id_ = call->deopt_id();
ReplaceCall(call, assert_as);
}
@@ -3919,6 +3975,39 @@
}
+void ConstantPropagator::VisitIfThenElse(IfThenElseInstr* instr) {
+ ASSERT(Token::IsEqualityOperator(instr->kind()));
+
+ const Object& left = instr->left()->definition()->constant_value();
+ const Object& right = instr->right()->definition()->constant_value();
+
+ if (IsNonConstant(left) || IsNonConstant(right)) {
+ // TODO(vegorov): incorporate nullability information into the lattice.
+ if ((left.IsNull() && instr->right()->Type()->HasDecidableNullability()) ||
+ (right.IsNull() && instr->left()->Type()->HasDecidableNullability())) {
+ bool result = left.IsNull() ? instr->right()->Type()->IsNull()
+ : instr->left()->Type()->IsNull();
+ if (instr->kind() == Token::kNE_STRICT ||
+ instr->kind() == Token::kNE) {
+ result = !result;
+ }
+ SetValue(instr, Smi::Handle(
+ Smi::New(result ? instr->if_true() : instr->if_false())));
+ } else {
+ SetValue(instr, non_constant_);
+ }
+ } else if (IsConstant(left) && IsConstant(right)) {
+ bool result = (left.raw() == right.raw());
+ if (instr->kind() == Token::kNE_STRICT ||
+ instr->kind() == Token::kNE) {
+ result = !result;
+ }
+ SetValue(instr, Smi::Handle(
+ Smi::New(result ? instr->if_true() : instr->if_false())));
+ }
+}
+
+
void ConstantPropagator::VisitStrictCompare(StrictCompareInstr* instr) {
const Object& left = instr->left()->definition()->constant_value();
const Object& right = instr->right()->definition()->constant_value();
@@ -4343,6 +4432,28 @@
}
+void ConstantPropagator::VisitUnboxFloat32x4(UnboxFloat32x4Instr* instr) {
+ const Object& value = instr->value()->definition()->constant_value();
+ if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ } else if (IsConstant(value)) {
+ // TODO(kmillikin): Handle conversion.
+ SetValue(instr, non_constant_);
+ }
+}
+
+
+void ConstantPropagator::VisitBoxFloat32x4(BoxFloat32x4Instr* instr) {
+ const Object& value = instr->value()->definition()->constant_value();
+ if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ } else if (IsConstant(value)) {
+ // TODO(kmillikin): Handle conversion.
+ SetValue(instr, non_constant_);
+ }
+}
+
+
void ConstantPropagator::Analyze() {
GraphEntryInstr* entry = graph_->graph_entry();
reachable_->Add(entry->preorder_number());
@@ -4428,6 +4539,7 @@
it.Current()->UnuseAllInputs();
}
}
+ block->UnuseAllInputs();
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
it.Current()->UnuseAllInputs();
}
@@ -4520,11 +4632,15 @@
ASSERT(if_false->parallel_move() == NULL);
ASSERT(if_false->loop_info() == NULL);
join = new JoinEntryInstr(if_false->block_id(), if_false->try_index());
+ join->InheritDeoptTarget(if_false);
+ if_false->UnuseAllInputs();
next = if_false->next();
} else if (!reachable_->Contains(if_false->preorder_number())) {
ASSERT(if_true->parallel_move() == NULL);
ASSERT(if_true->loop_info() == NULL);
join = new JoinEntryInstr(if_true->block_id(), if_true->try_index());
+ join->InheritDeoptTarget(if_true);
+ if_true->UnuseAllInputs();
next = if_true->next();
}
@@ -4534,9 +4650,12 @@
// as it is a strict compare (the only one we can determine is
// constant with the current analysis).
GotoInstr* jump = new GotoInstr(join);
+ jump->InheritDeoptTarget(branch);
+
Instruction* previous = branch->previous();
branch->set_previous(NULL);
previous->LinkTo(jump);
+
// Replace the false target entry with the new join entry. We will
// recompute the dominators after this pass.
join->LinkTo(next);
@@ -4557,6 +4676,28 @@
}
+// Returns true if the given phi has a single input use and
+// is used in the environments either at the corresponding block entry or
+// at the same instruction where input use is.
+static bool PhiHasSingleUse(PhiInstr* phi, Value* use) {
+ if ((use->next_use() != NULL) || (phi->input_use_list() != use)) {
+ return false;
+ }
+
+ BlockEntryInstr* block = phi->block();
+ for (Value* env_use = phi->env_use_list();
+ env_use != NULL;
+ env_use = env_use->next_use()) {
+ if ((env_use->instruction() != block) &&
+ (env_use->instruction() != use->instruction())) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
bool BranchSimplifier::Match(JoinEntryInstr* block) {
// Match the pattern of a branch on a comparison whose left operand is a
// phi from the same block, and whose right operand is a constant.
@@ -4578,7 +4719,7 @@
return (phi != NULL) &&
(constant != NULL) &&
(phi->GetBlock() == block) &&
- phi->HasOnlyUse(left) &&
+ PhiHasSingleUse(phi, left) &&
constant->HasOnlyUse(right) &&
(block->next() == constant) &&
(constant->next() == branch) &&
@@ -4592,8 +4733,10 @@
// from all the duplicated branches.
JoinEntryInstr* join =
new JoinEntryInstr(target->block_id(), target->try_index());
+ join->InheritDeoptTarget(target);
join->LinkTo(target->next());
join->set_last_instruction(target->last_instruction());
+ target->UnuseAllInputs();
return join;
}
@@ -4614,18 +4757,24 @@
if (comparison->IsStrictCompare()) {
new_comparison = new StrictCompareInstr(comparison->kind(), left, right);
} else if (comparison->IsEqualityCompare()) {
- new_comparison =
- new EqualityCompareInstr(comparison->AsEqualityCompare()->token_pos(),
+ EqualityCompareInstr* equality_compare = comparison->AsEqualityCompare();
+ EqualityCompareInstr* new_equality_compare =
+ new EqualityCompareInstr(equality_compare->token_pos(),
comparison->kind(),
left,
right);
+ new_equality_compare->set_ic_data(equality_compare->ic_data());
+ new_comparison = new_equality_compare;
} else {
ASSERT(comparison->IsRelationalOp());
- new_comparison =
- new RelationalOpInstr(comparison->AsRelationalOp()->token_pos(),
+ RelationalOpInstr* relational_op = comparison->AsRelationalOp();
+ RelationalOpInstr* new_relational_op =
+ new RelationalOpInstr(relational_op->token_pos(),
comparison->kind(),
left,
right);
+ new_relational_op->set_ic_data(relational_op->ic_data());
+ new_comparison = new_relational_op;
}
return new BranchInstr(new_comparison, branch->is_checked());
}
@@ -4694,6 +4843,7 @@
Value* new_left = phi->InputAt(i)->Copy();
Value* new_right = new Value(new_constant);
BranchInstr* new_branch = CloneBranch(branch, new_left, new_right);
+ new_branch->InheritDeoptTarget(old_goto);
new_branch->InsertBefore(old_goto);
new_branch->set_next(NULL); // Detaching the goto from the graph.
old_goto->UnuseAllInputs();
@@ -4709,16 +4859,20 @@
TargetEntryInstr* true_target =
new TargetEntryInstr(flow_graph->max_block_id() + 1,
block->try_index());
+ true_target->InheritDeoptTarget(join_true);
TargetEntryInstr* false_target =
new TargetEntryInstr(flow_graph->max_block_id() + 2,
block->try_index());
+ false_target->InheritDeoptTarget(join_false);
flow_graph->set_max_block_id(flow_graph->max_block_id() + 2);
*new_branch->true_successor_address() = true_target;
*new_branch->false_successor_address() = false_target;
GotoInstr* goto_true = new GotoInstr(join_true);
+ goto_true->InheritDeoptTarget(join_true);
true_target->LinkTo(goto_true);
true_target->set_last_instruction(goto_true);
GotoInstr* goto_false = new GotoInstr(join_false);
+ goto_false->InheritDeoptTarget(join_false);
false_target->LinkTo(goto_false);
false_target->set_last_instruction(goto_false);
}
@@ -4726,6 +4880,136 @@
// unreachable from the graph.
phi->UnuseAllInputs();
branch->UnuseAllInputs();
+ block->UnuseAllInputs();
+ }
+ }
+
+ if (changed) {
+ // We may have changed the block order and the dominator tree.
+ flow_graph->DiscoverBlocks();
+ GrowableArray<BitVector*> dominance_frontier;
+ flow_graph->ComputeDominators(&dominance_frontier);
+ }
+}
+
+
+static bool IsTrivialBlock(BlockEntryInstr* block, Definition* defn) {
+ return (block->IsTargetEntry() && (block->PredecessorCount() == 1)) &&
+ ((block->next() == block->last_instruction()) ||
+ ((block->next() == defn) && (defn->next() == block->last_instruction())));
+}
+
+
+static void EliminateTrivialBlock(BlockEntryInstr* block,
+ Definition* instr,
+ IfThenElseInstr* before) {
+ block->UnuseAllInputs();
+ block->last_instruction()->UnuseAllInputs();
+
+ if ((block->next() == instr) &&
+ (instr->next() == block->last_instruction())) {
+ before->previous()->LinkTo(instr);
+ instr->LinkTo(before);
+ }
+}
+
+
+void IfConverter::Simplify(FlowGraph* flow_graph) {
+ if (!IfThenElseInstr::IsSupported()) {
+ return;
+ }
+
+ bool changed = false;
+
+ const GrowableArray<BlockEntryInstr*>& postorder = flow_graph->postorder();
+ for (BlockIterator it(postorder); !it.Done(); it.Advance()) {
+ BlockEntryInstr* block = it.Current();
+ JoinEntryInstr* join = block->AsJoinEntry();
+
+ // Detect diamond control flow pattern which materializes a value depending
+ // on the result of the comparison:
+ //
+ // B_pred:
+ // ...
+ // Branch if COMP goto (B_pred1, B_pred2)
+ // B_pred1: -- trivial block that contains at most one definition
+ // v1 = Constant(...)
+ // goto B_block
+ // B_pred2: -- trivial block that contains at most one definition
+ // v2 = Constant(...)
+ // goto B_block
+ // B_block:
+ // v3 = phi(v1, v2) -- single phi
+ //
+ // and replace it with
+ //
+ // Ba:
+ // v3 = IfThenElse(COMP ? v1 : v2)
+ //
+ if ((join != NULL) &&
+ (join->phis() != NULL) &&
+ (join->phis()->length() == 1) &&
+ (block->PredecessorCount() == 2)) {
+ BlockEntryInstr* pred1 = block->PredecessorAt(0);
+ BlockEntryInstr* pred2 = block->PredecessorAt(1);
+
+ PhiInstr* phi = (*join->phis())[0];
+ Value* v1 = phi->InputAt(0);
+ Value* v2 = phi->InputAt(1);
+
+ if (IsTrivialBlock(pred1, v1->definition()) &&
+ IsTrivialBlock(pred2, v2->definition()) &&
+ (pred1->PredecessorAt(0) == pred2->PredecessorAt(0))) {
+ BlockEntryInstr* pred = pred1->PredecessorAt(0);
+ BranchInstr* branch = pred->last_instruction()->AsBranch();
+ ComparisonInstr* comparison = branch->comparison();
+
+ // Check if the platform supports efficient branchless IfThenElseInstr
+ // for the given combination of comparison and values flowing from
+ // false and true paths.
+ if (IfThenElseInstr::Supports(comparison, v1, v2)) {
+ Value* if_true = (pred1 == branch->true_successor()) ? v1 : v2;
+ Value* if_false = (pred2 == branch->true_successor()) ? v1 : v2;
+
+ IfThenElseInstr* if_then_else = new IfThenElseInstr(
+ comparison->kind(),
+ comparison->InputAt(0)->Copy(),
+ comparison->InputAt(1)->Copy(),
+ if_true->Copy(),
+ if_false->Copy());
+ flow_graph->InsertBefore(branch,
+ if_then_else,
+ NULL,
+ Definition::kValue);
+
+ phi->ReplaceUsesWith(if_then_else);
+
+ // Connect IfThenElseInstr to the first instruction in the merge block
+ // effectively eliminating diamond control flow.
+ // Current block as well as pred1 and pred2 blocks are no longer in
+ // the graph at this point.
+ if_then_else->LinkTo(join->next());
+ pred->set_last_instruction(join->last_instruction());
+
+ // Resulting block must inherit block id from the eliminated current
+ // block to guarantee that ordering of phi operands in its successor
+ // stays consistent.
+ pred->set_block_id(block->block_id());
+
+ // If v1 and v2 were defined inside eliminated blocks pred1/pred2
+ // move them out to the place before inserted IfThenElse instruction.
+ EliminateTrivialBlock(pred1, v1->definition(), if_then_else);
+ EliminateTrivialBlock(pred2, v2->definition(), if_then_else);
+
+ // Update use lists to reflect changes in the graph.
+ phi->UnuseAllInputs();
+ branch->UnuseAllInputs();
+
+ // The graph has changed. Recompute dominators and block orders after
+ // this pass is finished.
+ changed = true;
+ }
+ }
}
}
diff --git a/runtime/vm/flow_graph_optimizer.h b/runtime/vm/flow_graph_optimizer.h
index 03d623d..1b48ac2 100644
--- a/runtime/vm/flow_graph_optimizer.h
+++ b/runtime/vm/flow_graph_optimizer.h
@@ -16,9 +16,11 @@
class FlowGraphOptimizer : public FlowGraphVisitor {
public:
- explicit FlowGraphOptimizer(FlowGraph* flow_graph)
+ FlowGraphOptimizer(FlowGraph* flow_graph,
+ GrowableArray<Field*>* guarded_fields)
: FlowGraphVisitor(flow_graph->reverse_postorder()),
- flow_graph_(flow_graph) { }
+ flow_graph_(flow_graph),
+ guarded_fields_(guarded_fields) { }
virtual ~FlowGraphOptimizer() {}
FlowGraph* flow_graph() const { return flow_graph_; }
@@ -157,7 +159,10 @@
Definition* left_instr,
Definition* right_instr);
+ void AddToGuardedFields(Field* field);
+
FlowGraph* flow_graph_;
+ GrowableArray<Field*>* guarded_fields_;
DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer);
};
@@ -299,6 +304,15 @@
};
+// Rewrite diamond control flow patterns that materialize values to use more
+// efficient branchless code patterns if such are supported on the current
+// platform.
+class IfConverter : public AllStatic {
+ public:
+ static void Simplify(FlowGraph* flow_graph);
+};
+
+
} // namespace dart
#endif // VM_FLOW_GRAPH_OPTIMIZER_H_
diff --git a/runtime/vm/flow_graph_type_propagator.cc b/runtime/vm/flow_graph_type_propagator.cc
index 52fd2e2..2e5abea 100644
--- a/runtime/vm/flow_graph_type_propagator.cc
+++ b/runtime/vm/flow_graph_type_propagator.cc
@@ -645,6 +645,12 @@
}
+CompileType IfThenElseInstr::ComputeType() const {
+ ASSERT(InputCount() == 2);
+ return CompileType::FromCid(kSmiCid);
+}
+
+
CompileType ParameterInstr::ComputeType() const {
// Note that returning the declared type of the formal parameter would be
// incorrect, because ParameterInstr is used as input to the type check
@@ -971,6 +977,16 @@
}
+CompileType UnboxFloat32x4Instr::ComputeType() const {
+ return CompileType::FromCid(kFloat32x4Cid);
+}
+
+
+CompileType BoxFloat32x4Instr::ComputeType() const {
+ return CompileType::FromCid(kFloat32x4Cid);
+}
+
+
CompileType SmiToDoubleInstr::ComputeType() const {
return CompileType::FromCid(kDoubleCid);
}
diff --git a/runtime/vm/il_printer.cc b/runtime/vm/il_printer.cc
index cb6b005..1465a83 100644
--- a/runtime/vm/il_printer.cc
+++ b/runtime/vm/il_printer.cc
@@ -429,6 +429,16 @@
}
+void IfThenElseInstr::PrintOperandsTo(BufferFormatter* f) const {
+ left()->PrintTo(f);
+ f->Print(" %s ", Token::Str(kind_));
+ right()->PrintTo(f);
+ f->Print(" ? %"Pd" : %"Pd,
+ if_true_,
+ if_false_);
+}
+
+
void LoadStaticFieldInstr::PrintOperandsTo(BufferFormatter* f) const {
f->Print("%s", String::Handle(field().name()).ToCString());
}
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index 292d6aa..71acde1 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -510,11 +510,11 @@
bool Definition::HasOnlyUse(Value* use) const {
- if (((input_use_list() == use) && (env_use_list() == NULL)) ||
- ((input_use_list() == NULL) && (env_use_list() == use))) {
- return (use->next_use() == NULL);
- }
- return false;
+ return (input_use_list() == use) &&
+ (use->next_use() == NULL) &&
+ ((env_use_list() == NULL) ||
+ ((env_use_list()->instruction() == use->instruction()) &&
+ (env_use_list()->next_use() == NULL)));
}
@@ -568,6 +568,28 @@
}
+void Instruction::InheritDeoptTargetAfter(Instruction* other) {
+ ASSERT(other->env() != NULL);
+ deopt_id_ = Isolate::ToDeoptAfter(other->deopt_id_);
+ other->env()->DeepCopyTo(this);
+ env()->set_deopt_id(deopt_id_);
+}
+
+
+void Instruction::InheritDeoptTarget(Instruction* other) {
+ ASSERT(other->env() != NULL);
+ deopt_id_ = other->deopt_id_;
+ other->env()->DeepCopyTo(this);
+ env()->set_deopt_id(deopt_id_);
+}
+
+
+void BranchInstr::InheritDeoptTarget(Instruction* other) {
+ Instruction::InheritDeoptTarget(other);
+ comparison()->SetDeoptId(GetDeoptId());
+}
+
+
void Definition::ReplaceWith(Definition* other,
ForwardInstructionIterator* iterator) {
// Record other's input uses.
@@ -1260,9 +1282,11 @@
// Replace the comparison if the replacement is used at this branch,
// and has exactly one use.
- if ((comp->input_use_list()->instruction() == this) &&
- (comp->input_use_list()->next_use() == NULL) &&
- (comp->env_use_list() == NULL)) {
+ Value* use = comp->input_use_list();
+ if ((use->instruction() == this) && comp->HasOnlyUse(use)) {
+ RemoveEnvironment();
+ InheritDeoptTarget(comp);
+
comp->RemoveFromGraph();
SetComparison(comp);
if (FLAG_trace_optimization) {
@@ -1378,6 +1402,11 @@
void JoinEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) {
+ if (!compiler->is_optimizing()) {
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
+ deopt_id_,
+ Scanner::kDummyTokenIndex);
+ }
__ Bind(compiler->GetJumpLabel(this));
if (HasParallelMove()) {
compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
@@ -1386,6 +1415,11 @@
void TargetEntryInstr::PrepareEntry(FlowGraphCompiler* compiler) {
+ if (!compiler->is_optimizing()) {
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
+ deopt_id_,
+ Scanner::kDummyTokenIndex);
+ }
__ Bind(compiler->GetJumpLabel(this));
if (HasParallelMove()) {
compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
@@ -1553,7 +1587,7 @@
} else {
// Unoptimized code.
ASSERT(!HasICData());
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id(),
token_pos());
compiler->GenerateInstanceCall(deopt_id(),
@@ -1576,7 +1610,7 @@
if (!compiler->is_optimizing()) {
// Some static calls can be optimized by the optimizing compiler (e.g. sqrt)
// and therefore need a deoptimization descriptor.
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id(),
token_pos());
}
@@ -2039,6 +2073,14 @@
}
+void IfThenElseInstr::InferRange() {
+ const intptr_t min = Utils::Minimum(if_true_, if_false_);
+ const intptr_t max = Utils::Maximum(if_true_, if_false_);
+ range_ = new Range(RangeBoundary::FromConstant(min),
+ RangeBoundary::FromConstant(max));
+}
+
+
void PhiInstr::InferRange() {
RangeBoundary new_min;
RangeBoundary new_max;
diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h
index ac497ff..9ac45c1 100644
--- a/runtime/vm/intermediate_language.h
+++ b/runtime/vm/intermediate_language.h
@@ -46,6 +46,7 @@
V(_TypedList, _getUint32, ByteArrayBaseGetUint32, 380843687) \
V(_TypedList, _getFloat32, ByteArrayBaseGetFloat32, 979971573) \
V(_TypedList, _getFloat64, ByteArrayBaseGetFloat64, 979971573) \
+ V(_TypedList, _getFloat32x4, ByteArrayBaseGetFloat32x4, 690339584) \
V(_TypedList, _setInt8, ByteArrayBaseSetInt8, 287047804) \
V(_TypedList, _setUint8, ByteArrayBaseSetUint8, 287047804) \
V(_TypedList, _setInt16, ByteArrayBaseSetInt16, 287047804) \
@@ -54,6 +55,7 @@
V(_TypedList, _setUint32, ByteArrayBaseSetUint32, 287047804) \
V(_TypedList, _setFloat32, ByteArrayBaseSetFloat32, 1032541114) \
V(_TypedList, _setFloat64, ByteArrayBaseSetFloat64, 1032541114) \
+ V(_TypedList, _setFloat32x4, ByteArrayBaseSetFloat32x4, 1016704782) \
V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \
V(_GrowableObjectArray, get:_capacity, GrowableArrayCapacity, 725548050) \
V(_StringBase, get:length, StringBaseLength, 320803993) \
@@ -489,6 +491,8 @@
M(MathSqrt) \
M(UnboxDouble) \
M(BoxDouble) \
+ M(BoxFloat32x4) \
+ M(UnboxFloat32x4) \
M(UnboxInteger) \
M(BoxInteger) \
M(BinaryMintOp) \
@@ -499,7 +503,7 @@
M(StringFromCharCode) \
M(InvokeMathCFunction) \
M(GuardField) \
-
+ M(IfThenElse) \
#define FORWARD_DECLARATION(type) class type##Instr;
FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
@@ -535,7 +539,7 @@
virtual Tag tag() const = 0;
intptr_t deopt_id() const {
- ASSERT(CanDeoptimize());
+ ASSERT(CanDeoptimize() || CanBeDeoptimizationTarget());
return deopt_id_;
}
@@ -728,6 +732,18 @@
return false;
}
+ virtual void InheritDeoptTarget(Instruction* other);
+
+ bool NeedsEnvironment() const {
+ return CanDeoptimize() || CanBeDeoptimizationTarget();
+ }
+
+ virtual bool CanBeDeoptimizationTarget() const {
+ return false;
+ }
+
+ void InheritDeoptTargetAfter(Instruction* other);
+
protected:
// Fetch deopt id without checking if this computation can deoptimize.
intptr_t GetDeoptId() const {
@@ -740,6 +756,7 @@
// Classes that set deopt_id_.
friend class UnboxIntegerInstr;
friend class UnboxDoubleInstr;
+ friend class UnboxFloat32x4Instr;
friend class BinaryDoubleOpInstr;
friend class BinaryMintOpInstr;
friend class BinarySmiOpInstr;
@@ -760,6 +777,11 @@
friend class LoadIndexedInstr;
friend class StoreIndexedInstr;
friend class StoreInstanceFieldInstr;
+ friend class ControlInstruction;
+ friend class ComparisonInstr;
+ friend class TargetEntryInstr;
+ friend class JoinEntryInstr;
+ friend class InstanceOfInstr;
virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
@@ -981,6 +1003,12 @@
virtual intptr_t ArgumentCount() const { return 0; }
+ virtual bool CanBeDeoptimizationTarget() const {
+ // BlockEntry environment is copied to Goto and Branch instructions
+ // when we insert new blocks targeting this block.
+ return true;
+ }
+
virtual bool CanDeoptimize() const { return false; }
virtual bool HasSideEffect() const { return false; }
@@ -1001,6 +1029,8 @@
// successors.
void ReplaceAsPredecessorWith(BlockEntryInstr* new_block);
+ void set_block_id(intptr_t block_id) { block_id_ = block_id; }
+
protected:
BlockEntryInstr(intptr_t block_id, intptr_t try_index)
: block_id_(block_id),
@@ -1019,7 +1049,7 @@
virtual void ClearPredecessors() = 0;
virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0;
- const intptr_t block_id_;
+ intptr_t block_id_;
const intptr_t try_index_;
intptr_t preorder_number_;
intptr_t postorder_number_;
@@ -1653,6 +1683,12 @@
intptr_t token_pos() const { return token_pos_; }
Value* value() const { return inputs_[0]; }
+ virtual bool CanBeDeoptimizationTarget() const {
+ // Return instruction might turn into a Goto instruction after inlining.
+ // Every Goto must have an environment.
+ return true;
+ }
+
virtual bool CanDeoptimize() const { return false; }
virtual bool HasSideEffect() const { return false; }
@@ -1721,6 +1757,12 @@
virtual intptr_t SuccessorCount() const;
virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
+ virtual bool CanBeDeoptimizationTarget() const {
+ // Goto instruction can be used as a deoptimization target when LICM
+ // hoists instructions out of the loop.
+ return true;
+ }
+
virtual bool CanDeoptimize() const { return false; }
virtual bool HasSideEffect() const { return false; }
@@ -1789,6 +1831,7 @@
intptr_t InputCount() const;
Value* InputAt(intptr_t i) const;
virtual bool CanDeoptimize() const;
+ virtual bool CanBeDeoptimizationTarget() const;
virtual bool HasSideEffect() const;
@@ -1833,6 +1876,8 @@
return constant_target_;
}
+ virtual void InheritDeoptTarget(Instruction* other);
+
private:
virtual void RawSetInputAt(intptr_t i, Value* value);
@@ -2446,6 +2491,10 @@
virtual void EmitBranchCode(FlowGraphCompiler* compiler,
BranchInstr* branch) = 0;
+ void SetDeoptId(intptr_t deopt_id) {
+ deopt_id_ = deopt_id;
+ }
+
protected:
Token::Kind kind_;
};
@@ -2474,6 +2523,11 @@
}
+inline bool BranchInstr::CanBeDeoptimizationTarget() const {
+ return comparison()->CanBeDeoptimizationTarget();
+}
+
+
inline bool BranchInstr::HasSideEffect() const {
return comparison()->HasSideEffect();
}
@@ -2510,6 +2564,11 @@
virtual void PrintOperandsTo(BufferFormatter* f) const;
+ virtual bool CanBeDeoptimizationTarget() const {
+ // StrictCompare can be merged into Branch and thus needs an environment.
+ return true;
+ }
+
virtual bool CanDeoptimize() const { return false; }
virtual bool HasSideEffect() const { return false; }
@@ -2557,6 +2616,7 @@
bool HasICData() const {
return (ic_data() != NULL) && !ic_data()->IsNull();
}
+ void set_ic_data(const ICData* value) { ic_data_ = value; }
intptr_t token_pos() const { return token_pos_; }
@@ -2627,6 +2687,7 @@
bool HasICData() const {
return (ic_data() != NULL) && !ic_data()->IsNull();
}
+ void set_ic_data(const ICData* value) { ic_data_ = value; }
intptr_t token_pos() const { return token_pos_; }
@@ -2677,6 +2738,65 @@
};
+// TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for
+// materialization of true and false constants.
+class IfThenElseInstr : public TemplateDefinition<2> {
+ public:
+ IfThenElseInstr(Token::Kind kind,
+ Value* left,
+ Value* right,
+ Value* if_true,
+ Value* if_false)
+ : kind_(kind),
+ if_true_(Smi::Cast(if_true->BoundConstant()).Value()),
+ if_false_(Smi::Cast(if_false->BoundConstant()).Value()) {
+ ASSERT(Token::IsEqualityOperator(kind));
+ SetInputAt(0, left);
+ SetInputAt(1, right);
+ }
+
+ // Returns true if this instruction is supported on the current platform.
+ static bool IsSupported();
+
+ // Returns true if this combination of comparison and values flowing on
+ // the true and false paths is supported on the current platform.
+ static bool Supports(ComparisonInstr* comparison, Value* v1, Value* v2);
+
+ DECLARE_INSTRUCTION(IfThenElse)
+
+ virtual void PrintOperandsTo(BufferFormatter* f) const;
+
+ virtual CompileType ComputeType() const;
+
+ virtual void InferRange();
+
+ virtual bool CanDeoptimize() const { return false; }
+ virtual bool HasSideEffect() const { return false; }
+
+ virtual bool AttributesEqual(Instruction* other) const {
+ return kind_ == other->AsIfThenElse()->kind_;
+ }
+
+ virtual bool AffectedBySideEffect() const {
+ return false;
+ }
+
+ Value* left() const { return inputs_[0]; }
+ Value* right() const { return inputs_[1]; }
+ intptr_t if_true() const { return if_true_; }
+ intptr_t if_false() const { return if_false_; }
+
+ Token::Kind kind() const { return kind_; }
+
+ private:
+ const Token::Kind kind_;
+ const intptr_t if_true_;
+ const intptr_t if_false_;
+
+ DISALLOW_COPY_AND_ASSIGN(IfThenElseInstr);
+};
+
+
class StaticCallInstr : public TemplateDefinition<0> {
public:
StaticCallInstr(intptr_t token_pos,
@@ -2955,6 +3075,13 @@
virtual bool HasSideEffect() const { return true; }
private:
+ bool CanValueBeSmi() const {
+ const intptr_t cid = value()->Type()->ToNullableCid();
+ // Write barrier is skipped for nullable and non-nullable smis.
+ ASSERT(cid != kSmiCid);
+ return (cid == kDynamicCid);
+ }
+
const Field& field_;
DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldInstr);
@@ -3129,7 +3256,8 @@
Value* instantiator,
Value* instantiator_type_arguments,
const AbstractType& type,
- bool negate_result)
+ bool negate_result,
+ intptr_t deopt_id)
: token_pos_(token_pos),
type_(type),
negate_result_(negate_result) {
@@ -3137,6 +3265,7 @@
SetInputAt(0, value);
SetInputAt(1, instantiator);
SetInputAt(2, instantiator_type_arguments);
+ deopt_id_ = deopt_id;
}
DECLARE_INSTRUCTION(InstanceOf)
@@ -3677,15 +3806,12 @@
class BoxDoubleInstr : public TemplateDefinition<1> {
public:
- BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call)
- : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) {
+ explicit BoxDoubleInstr(Value* value) {
SetInputAt(0, value);
}
Value* value() const { return inputs_[0]; }
- intptr_t token_pos() const { return token_pos_; }
-
virtual bool CanDeoptimize() const { return false; }
virtual bool HasSideEffect() const { return false; }
@@ -3702,12 +3828,38 @@
virtual CompileType ComputeType() const;
private:
- const intptr_t token_pos_;
-
DISALLOW_COPY_AND_ASSIGN(BoxDoubleInstr);
};
+class BoxFloat32x4Instr : public TemplateDefinition<1> {
+ public:
+ explicit BoxFloat32x4Instr(Value* value) {
+ SetInputAt(0, value);
+ }
+
+ Value* value() const { return inputs_[0]; }
+
+ virtual bool CanDeoptimize() const { return false; }
+
+ virtual bool HasSideEffect() const { return false; }
+
+ virtual bool AffectedBySideEffect() const { return false; }
+ virtual bool AttributesEqual(Instruction* other) const { return true; }
+
+ virtual Representation RequiredInputRepresentation(intptr_t idx) const {
+ ASSERT(idx == 0);
+ return kUnboxedFloat32x4;
+ }
+
+ DECLARE_INSTRUCTION(BoxFloat32x4)
+ virtual CompileType ComputeType() const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BoxFloat32x4Instr);
+};
+
+
class BoxIntegerInstr : public TemplateDefinition<1> {
public:
explicit BoxIntegerInstr(Value* value) {
@@ -3767,6 +3919,36 @@
};
+class UnboxFloat32x4Instr : public TemplateDefinition<1> {
+ public:
+ UnboxFloat32x4Instr(Value* value, intptr_t deopt_id) {
+ SetInputAt(0, value);
+ deopt_id_ = deopt_id;
+ }
+
+ Value* value() const { return inputs_[0]; }
+
+ virtual bool CanDeoptimize() const {
+ return (value()->Type()->ToCid() != kFloat32x4Cid);
+ }
+
+ virtual bool HasSideEffect() const { return false; }
+
+ virtual Representation representation() const {
+ return kUnboxedFloat32x4;
+ }
+
+ virtual bool AffectedBySideEffect() const { return false; }
+ virtual bool AttributesEqual(Instruction* other) const { return true; }
+
+ DECLARE_INSTRUCTION(UnboxFloat32x4)
+ virtual CompileType ComputeType() const;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UnboxFloat32x4Instr);
+};
+
+
class UnboxIntegerInstr : public TemplateDefinition<1> {
public:
UnboxIntegerInstr(Value* value, intptr_t deopt_id) {
diff --git a/runtime/vm/intermediate_language_arm.cc b/runtime/vm/intermediate_language_arm.cc
index 69f9178..5ae8494 100644
--- a/runtime/vm/intermediate_language_arm.cc
+++ b/runtime/vm/intermediate_language_arm.cc
@@ -103,6 +103,30 @@
}
+bool IfThenElseInstr::IsSupported() {
+ return false;
+}
+
+
+bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
+ Value* v1,
+ Value* v2) {
+ UNREACHABLE();
+ return false;
+}
+
+
+LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
+ UNREACHABLE();
+ return NULL;
+}
+
+
+void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ UNREACHABLE();
+}
+
+
LocationSummary* ClosureCallInstr::MakeLocationSummary() const {
UNIMPLEMENTED();
return NULL;
@@ -311,7 +335,7 @@
LocationSummary* locs,
const ICData& original_ic_data) {
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id,
token_pos);
}
@@ -669,7 +693,7 @@
const String& function_name =
String::ZoneHandle(Symbols::New(Token::Str(kind())));
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id(),
token_pos());
}
@@ -1264,6 +1288,28 @@
}
+LocationSummary* BoxFloat32x4Instr::MakeLocationSummary() const {
+ UNIMPLEMENTED();
+ return NULL;
+}
+
+
+void BoxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ UNIMPLEMENTED();
+}
+
+
+LocationSummary* UnboxFloat32x4Instr::MakeLocationSummary() const {
+ UNIMPLEMENTED();
+ return NULL;
+}
+
+
+void UnboxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ UNIMPLEMENTED();
+}
+
+
LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary() const {
UNIMPLEMENTED();
return NULL;
@@ -1533,7 +1579,7 @@
// Add deoptimization descriptor for deoptimizing instructions
// that may be inserted before this instruction.
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
GetDeoptId(),
0); // No token position.
}
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index 50f3dc8..96e14fa 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -336,7 +336,7 @@
LocationSummary* locs,
const ICData& original_ic_data) {
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id,
token_pos);
}
@@ -972,7 +972,7 @@
const String& function_name =
String::ZoneHandle(Symbols::New(Token::Str(kind())));
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id(),
token_pos());
}
@@ -1124,6 +1124,8 @@
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
return CompileType::FromCid(kDoubleCid);
+ case kTypedDataFloat32x4ArrayCid:
+ return CompileType::FromCid(kFloat32x4Cid);
case kTypedDataInt8ArrayCid:
case kTypedDataUint8ArrayCid:
@@ -1173,6 +1175,8 @@
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
return kUnboxedDouble;
+ case kTypedDataFloat32x4ArrayCid:
+ return kUnboxedFloat32x4;
default:
UNIMPLEMENTED();
return kTagged;
@@ -1230,7 +1234,8 @@
}
if ((representation() == kUnboxedDouble) ||
- (representation() == kUnboxedMint)) {
+ (representation() == kUnboxedMint) ||
+ (representation() == kUnboxedFloat32x4)) {
XmmRegister result = locs()->out().fpu_reg();
if ((index_scale() == 1) && index.IsRegister()) {
__ SmiUntag(index.reg());
@@ -1252,6 +1257,9 @@
case kTypedDataFloat64ArrayCid:
__ movsd(result, element_address);
break;
+ case kTypedDataFloat32x4ArrayCid:
+ __ movups(result, element_address);
+ break;
}
return;
}
@@ -1332,6 +1340,8 @@
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
return kUnboxedDouble;
+ case kTypedDataFloat32x4ArrayCid:
+ return kUnboxedFloat32x4;
default:
UNIMPLEMENTED();
return kTagged;
@@ -1394,6 +1404,9 @@
// TODO(srdjan): Support Float64 constants.
locs->set_in(2, Location::RequiresFpuRegister());
break;
+ case kTypedDataFloat32x4ArrayCid:
+ locs->set_in(2, Location::RequiresFpuRegister());
+ break;
default:
UNREACHABLE();
return NULL;
@@ -1510,6 +1523,9 @@
case kTypedDataFloat64ArrayCid:
__ movsd(element_address, locs()->in(2).fpu_reg());
break;
+ case kTypedDataFloat32x4ArrayCid:
+ __ movups(element_address, locs()->in(2).fpu_reg());
+ break;
default:
UNREACHABLE();
}
@@ -1729,7 +1745,8 @@
__ LoadObject(temp, field());
if (this->value()->NeedsStoreBuffer()) {
- __ StoreIntoObject(temp, FieldAddress(temp, Field::value_offset()), value);
+ __ StoreIntoObject(temp,
+ FieldAddress(temp, Field::value_offset()), value, CanValueBeSmi());
} else {
__ StoreIntoObjectNoBarrier(
temp, FieldAddress(temp, Field::value_offset()), value);
@@ -2611,11 +2628,11 @@
locs->live_registers()->Remove(locs->out());
compiler->SaveLiveRegisters(locs);
- compiler->GenerateCall(instruction_->token_pos(),
+ compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position.
&label,
PcDescriptors::kOther,
locs);
- if (EAX != locs->out().reg()) __ movl(locs->out().reg(), EAX);
+ __ MoveRegister(locs->out().reg(), EAX);
compiler->RestoreLiveRegisters(locs);
__ jmp(exit_label());
@@ -2688,6 +2705,88 @@
}
+LocationSummary* BoxFloat32x4Instr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs,
+ kNumTemps,
+ LocationSummary::kCallOnSlowPath);
+ summary->set_in(0, Location::RequiresFpuRegister());
+ summary->set_out(Location::RequiresRegister());
+ return summary;
+}
+
+
+class BoxFloat32x4SlowPath : public SlowPathCode {
+ public:
+ explicit BoxFloat32x4SlowPath(BoxFloat32x4Instr* instruction)
+ : instruction_(instruction) { }
+
+ virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
+ __ Comment("BoxFloat32x4SlowPath");
+ __ Bind(entry_label());
+ const Class& float32x4_class = compiler->float32x4_class();
+ const Code& stub =
+ Code::Handle(StubCode::GetAllocationStubForClass(float32x4_class));
+ const ExternalLabel label(float32x4_class.ToCString(), stub.EntryPoint());
+
+ LocationSummary* locs = instruction_->locs();
+ locs->live_registers()->Remove(locs->out());
+
+ compiler->SaveLiveRegisters(locs);
+ compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position.
+ &label,
+ PcDescriptors::kOther,
+ locs);
+ __ MoveRegister(locs->out().reg(), EAX);
+ compiler->RestoreLiveRegisters(locs);
+
+ __ jmp(exit_label());
+ }
+
+ private:
+ BoxFloat32x4Instr* instruction_;
+};
+
+
+void BoxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ BoxFloat32x4SlowPath* slow_path = new BoxFloat32x4SlowPath(this);
+ compiler->AddSlowPathCode(slow_path);
+
+ Register out_reg = locs()->out().reg();
+ XmmRegister value = locs()->in(0).fpu_reg();
+
+ __ TryAllocate(compiler->float32x4_class(),
+ slow_path->entry_label(),
+ Assembler::kFarJump,
+ out_reg);
+ __ Bind(slow_path->exit_label());
+ __ movups(FieldAddress(out_reg, Float32x4::value_offset()), value);
+}
+
+
+LocationSummary* UnboxFloat32x4Instr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ summary->set_out(Location::RequiresFpuRegister());
+ return summary;
+}
+
+
+void UnboxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ const intptr_t value_cid = value()->Type()->ToCid();
+ const Register value = locs()->in(0).reg();
+ const XmmRegister result = locs()->out().fpu_reg();
+
+ ASSERT(value_cid == kFloat32x4Cid);
+ __ movups(result, FieldAddress(value, Float32x4::value_offset()));
+}
+
+
LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary() const {
const intptr_t kNumInputs = 2;
const intptr_t kNumTemps = 0;
@@ -2903,11 +3002,11 @@
const intptr_t kNumTemps = 0;
LocationSummary* result =
new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall);
- result->set_in(0, Location::FpuRegisterLocation(XMM1, kUnboxedDouble));
+ result->set_in(0, Location::FpuRegisterLocation(XMM1));
if (InputCount() == 2) {
- result->set_in(1, Location::FpuRegisterLocation(XMM2, kUnboxedDouble));
+ result->set_in(1, Location::FpuRegisterLocation(XMM2));
}
- result->set_out(Location::FpuRegisterLocation(XMM1, kUnboxedDouble));
+ result->set_out(Location::FpuRegisterLocation(XMM1));
return result;
}
@@ -3184,11 +3283,11 @@
locs->live_registers()->Remove(locs->out());
compiler->SaveLiveRegisters(locs);
- compiler->GenerateCall(0, // No token pos.
+ compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position.
&label,
PcDescriptors::kOther,
locs);
- if (EAX != locs->out().reg()) __ movl(locs->out().reg(), EAX);
+ __ MoveRegister(locs->out().reg(), EAX);
compiler->RestoreLiveRegisters(locs);
__ jmp(exit_label());
@@ -3442,7 +3541,7 @@
// Add deoptimization descriptor for deoptimizing instructions
// that may be inserted before this instruction.
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
GetDeoptId(),
0); // No token position.
}
@@ -3603,6 +3702,127 @@
}
+static bool BindsToSmiConstant(Value* val, intptr_t* smi_value) {
+ if (!val->BindsToConstant()) {
+ return false;
+ }
+
+ const Object& bound_constant = val->BoundConstant();
+ if (!bound_constant.IsSmi()) {
+ return false;
+ }
+
+ *smi_value = Smi::Cast(bound_constant).Value();
+ return true;
+}
+
+
+// Detect pattern when one value is zero and another is a power of 2.
+static bool IsPowerOfTwoKind(intptr_t v1, intptr_t v2) {
+ return (Utils::IsPowerOfTwo(v1) && (v2 == 0)) ||
+ (Utils::IsPowerOfTwo(v2) && (v1 == 0));
+}
+
+
+// Detect pattern when one value is increment of another.
+static bool IsIncrementKind(intptr_t v1, intptr_t v2) {
+ return ((v1 == v2 + 1) || (v1 + 1 == v2));
+}
+
+
+bool IfThenElseInstr::IsSupported() {
+ return true;
+}
+
+
+bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
+ Value* v1,
+ Value* v2) {
+ if (!(comparison->IsStrictCompare() &&
+ !comparison->AsStrictCompare()->needs_number_check()) &&
+ !(comparison->IsEqualityCompare() &&
+ (comparison->AsEqualityCompare()->receiver_class_id() == kSmiCid))) {
+ return false;
+ }
+
+ intptr_t v1_value, v2_value;
+
+ if (!BindsToSmiConstant(v1, &v1_value) ||
+ !BindsToSmiConstant(v2, &v2_value)) {
+ return false;
+ }
+
+ if (IsPowerOfTwoKind(v1_value, v2_value) ||
+ IsIncrementKind(v1_value, v2_value)) {
+ return true;
+ }
+
+ return false;
+}
+
+
+LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RegisterOrConstant(left()));
+ locs->set_in(1, Location::RegisterOrConstant(right()));
+ // TODO(vegorov): support byte register constraints in the register allocator.
+ locs->set_out(Location::RegisterLocation(EDX));
+ return locs;
+}
+
+
+void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ ASSERT(locs()->out().reg() == EDX);
+ ASSERT(Token::IsEqualityOperator(kind()));
+
+ Location left = locs()->in(0);
+ Location right = locs()->in(1);
+ ASSERT(!left.IsConstant() || !right.IsConstant());
+
+ // Clear upper part of the out register. We are going to use setcc on it
+ // which is a byte move.
+ __ xorl(EDX, EDX);
+
+ // Compare left and right. For now only equality comparison is supported.
+ // TODO(vegorov): reuse code from the other comparison instructions instead of
+ // generating it inline here.
+ if (left.IsConstant()) {
+ __ CompareObject(right.reg(), left.constant());
+ } else if (right.IsConstant()) {
+ __ CompareObject(left.reg(), right.constant());
+ } else {
+ __ cmpl(left.reg(), right.reg());
+ }
+
+ Condition true_condition =
+ ((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kEQ)) ? EQUAL
+ : NOT_EQUAL;
+
+ const bool is_power_of_two_kind = IsPowerOfTwoKind(if_true_, if_false_);
+
+ const intptr_t base = Utils::Minimum(if_true_, if_false_);
+
+ if (if_true_ == base) {
+ // We need to have zero in EDX on true_condition.
+ true_condition = NegateCondition(true_condition);
+ }
+
+ __ setcc(true_condition, DL);
+
+ if (is_power_of_two_kind) {
+ const intptr_t shift =
+ Utils::ShiftForPowerOfTwo(Utils::Maximum(if_true_, if_false_));
+ __ shll(EDX, Immediate(shift + kSmiTagSize));
+ } else {
+ ASSERT(kSmiTagSize == 1);
+ __ leal(EDX, Address(EDX, TIMES_2, base << kSmiTagSize));
+ }
+}
+
+
void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
// The arguments to the stub include the closure, as does the arguments
// descriptor.
diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc
index c912b09..b6ec1b0 100644
--- a/runtime/vm/intermediate_language_mips.cc
+++ b/runtime/vm/intermediate_language_mips.cc
@@ -13,6 +13,7 @@
#include "vm/locations.h"
#include "vm/object_store.h"
#include "vm/parser.h"
+#include "vm/simulator.h"
#include "vm/stub_code.h"
#include "vm/symbols.h"
@@ -87,8 +88,7 @@
const int sp_fp_dist = compiler->StackSize() + (-kFirstLocalSlotIndex - 1);
__ subu(T2, FP, SP);
- __ addiu(T2, T2, Immediate(-sp_fp_dist * kWordSize));
- __ beq(T2, ZR, &stack_ok);
+ __ BranchEqual(T2, sp_fp_dist * kWordSize, &stack_ok);
__ break_(0);
__ Bind(&stack_ok);
@@ -107,6 +107,30 @@
}
+bool IfThenElseInstr::IsSupported() {
+ return false;
+}
+
+
+bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
+ Value* v1,
+ Value* v2) {
+ UNREACHABLE();
+ return false;
+}
+
+
+LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
+ UNREACHABLE();
+ return NULL;
+}
+
+
+void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ UNREACHABLE();
+}
+
+
LocationSummary* ClosureCallInstr::MakeLocationSummary() const {
UNIMPLEMENTED();
return NULL;
@@ -171,13 +195,45 @@
LocationSummary* AssertBooleanInstr::MakeLocationSummary() const {
- UNIMPLEMENTED();
- return NULL;
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
+ locs->set_in(0, Location::RegisterLocation(A0));
+ locs->set_out(Location::RegisterLocation(A0));
+ return locs;
+}
+
+
+static void EmitAssertBoolean(Register reg,
+ intptr_t token_pos,
+ intptr_t deopt_id,
+ LocationSummary* locs,
+ FlowGraphCompiler* compiler) {
+ // Check that the type of the value is allowed in conditional context.
+ // Call the runtime if the object is not bool::true or bool::false.
+ ASSERT(locs->always_calls());
+ Label done;
+ __ BranchEqual(reg, Bool::True(), &done);
+ __ BranchEqual(reg, Bool::False(), &done);
+
+ __ Push(reg); // Push the source object.
+ compiler->GenerateCallRuntime(token_pos,
+ deopt_id,
+ kConditionTypeErrorRuntimeEntry,
+ locs);
+ // We should never return here.
+ __ break_(0);
+ __ Bind(&done);
}
void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ Register obj = locs()->in(0).reg();
+ Register result = locs()->out().reg();
+
+ EmitAssertBoolean(obj, token_pos(), deopt_id(), locs(), compiler);
+ ASSERT(obj == result);
}
@@ -193,19 +249,296 @@
LocationSummary* EqualityCompareInstr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 2;
+ const bool is_checked_strict_equal =
+ HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid);
+ if (receiver_class_id() == kMintCid) {
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresFpuRegister());
+ locs->set_in(1, Location::RequiresFpuRegister());
+ locs->set_temp(0, Location::RequiresRegister());
+ locs->set_out(Location::RequiresRegister());
+ return locs;
+ }
+ if (receiver_class_id() == kDoubleCid) {
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresFpuRegister());
+ locs->set_in(1, Location::RequiresFpuRegister());
+ locs->set_out(Location::RequiresRegister());
+ return locs;
+ }
+ if (receiver_class_id() == kSmiCid) {
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RegisterOrConstant(left()));
+ // Only one input can be a constant operand. The case of two constant
+ // operands should be handled by constant propagation.
+ locs->set_in(1, locs->in(0).IsConstant()
+ ? Location::RequiresRegister()
+ : Location::RegisterOrConstant(right()));
+ locs->set_out(Location::RequiresRegister());
+ return locs;
+ }
+ if (is_checked_strict_equal) {
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RequiresRegister());
+ locs->set_in(1, Location::RequiresRegister());
+ locs->set_temp(0, Location::RequiresRegister());
+ locs->set_out(Location::RequiresRegister());
+ return locs;
+ }
+ if (IsPolymorphic()) {
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
+ UNIMPLEMENTED(); // TODO(regis): Verify register allocation.
+ return locs;
+ }
+ const intptr_t kNumTemps = 1;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
+ locs->set_in(0, Location::RegisterLocation(A1));
+ locs->set_in(1, Location::RegisterLocation(A0));
+ locs->set_temp(0, Location::RegisterLocation(T0));
+ locs->set_out(Location::RegisterLocation(V0));
+ return locs;
+}
+
+
+// A1: left.
+// A0: right.
+// Uses T0 to load ic_call_data.
+// Result in V0.
+static void EmitEqualityAsInstanceCall(FlowGraphCompiler* compiler,
+ intptr_t deopt_id,
+ intptr_t token_pos,
+ Token::Kind kind,
+ LocationSummary* locs,
+ const ICData& original_ic_data) {
+ if (!compiler->is_optimizing()) {
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
+ deopt_id,
+ token_pos);
+ }
+ const int kNumberOfArguments = 2;
+ const Array& kNoArgumentNames = Array::Handle();
+ const int kNumArgumentsChecked = 2;
+
+ Label check_identity;
+ __ LoadImmediate(TMP1, reinterpret_cast<intptr_t>(Object::null()));
+ __ beq(A1, TMP1, &check_identity);
+ __ beq(A0, TMP1, &check_identity);
+
+ ICData& equality_ic_data = ICData::ZoneHandle();
+ if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
+ ASSERT(!original_ic_data.IsNull());
+ if (original_ic_data.NumberOfChecks() == 0) {
+ // IC call for reoptimization populates original ICData.
+ equality_ic_data = original_ic_data.raw();
+ } else {
+ // Megamorphic call.
+ equality_ic_data = original_ic_data.AsUnaryClassChecks();
+ }
+ } else {
+ equality_ic_data = ICData::New(compiler->parsed_function().function(),
+ Symbols::EqualOperator(),
+ deopt_id,
+ kNumArgumentsChecked);
+ }
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(A1, Address(SP, 1 * kWordSize));
+ __ sw(A0, Address(SP, 0 * kWordSize));
+ compiler->GenerateInstanceCall(deopt_id,
+ token_pos,
+ kNumberOfArguments,
+ kNoArgumentNames,
+ locs,
+ equality_ic_data);
+ Label check_ne;
+ __ b(&check_ne);
+
+ __ Bind(&check_identity);
+ Label equality_done;
+ if (compiler->is_optimizing()) {
+ // No need to update IC data.
+ Label is_true;
+ __ beq(A1, A0, &is_true);
+ __ LoadObject(V0, (kind == Token::kEQ) ? Bool::False() : Bool::True());
+ __ b(&equality_done);
+ __ Bind(&is_true);
+ __ LoadObject(V0, (kind == Token::kEQ) ? Bool::True() : Bool::False());
+ if (kind == Token::kNE) {
+ // Skip not-equal result conversion.
+ __ b(&equality_done);
+ }
+ } else {
+ // Call stub, load IC data in register. The stub will update ICData if
+ // necessary.
+ Register ic_data_reg = locs->temp(0).reg();
+ ASSERT(ic_data_reg == T0); // Stub depends on it.
+ __ LoadObject(ic_data_reg, equality_ic_data);
+ // Pass left in A1 and right in A0.
+ compiler->GenerateCall(token_pos,
+ &StubCode::EqualityWithNullArgLabel(),
+ PcDescriptors::kOther,
+ locs);
+ }
+ __ Bind(&check_ne);
+ if (kind == Token::kNE) {
+ Label true_label, done;
+ // Negate the condition: true label returns false and vice versa.
+ __ BranchEqual(V0, Bool::True(), &true_label);
+ __ LoadObject(V0, Bool::True());
+ __ b(&done);
+ __ Bind(&true_label);
+ __ LoadObject(V0, Bool::False());
+ __ Bind(&done);
+ }
+ __ Bind(&equality_done);
+}
+
+
+// Emit code when ICData's targets are all Object == (which is ===).
+static void EmitCheckedStrictEqual(FlowGraphCompiler* compiler,
+ const ICData& ic_data,
+ const LocationSummary& locs,
+ Token::Kind kind,
+ BranchInstr* branch,
+ intptr_t deopt_id) {
UNIMPLEMENTED();
- return NULL;
+}
+
+
+// First test if receiver is NULL, in which case === is applied.
+// If type feedback was provided (lists of <class-id, target>), do a
+// type by type check (either === or static call to the operator.
+static void EmitGenericEqualityCompare(FlowGraphCompiler* compiler,
+ LocationSummary* locs,
+ Token::Kind kind,
+ BranchInstr* branch,
+ const ICData& ic_data,
+ intptr_t deopt_id,
+ intptr_t token_pos) {
+ UNIMPLEMENTED();
+}
+
+
+static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
+ const LocationSummary& locs,
+ Token::Kind kind,
+ BranchInstr* branch) {
+ UNIMPLEMENTED();
+}
+
+
+static void EmitUnboxedMintEqualityOp(FlowGraphCompiler* compiler,
+ const LocationSummary& locs,
+ Token::Kind kind,
+ BranchInstr* branch) {
+ UNIMPLEMENTED();
+}
+
+
+static void EmitDoubleComparisonOp(FlowGraphCompiler* compiler,
+ const LocationSummary& locs,
+ Token::Kind kind,
+ BranchInstr* branch) {
+ UNIMPLEMENTED();
}
void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
+ BranchInstr* kNoBranch = NULL;
+ if (receiver_class_id() == kSmiCid) {
+ EmitSmiComparisonOp(compiler, *locs(), kind(), kNoBranch);
+ return;
+ }
+ if (receiver_class_id() == kMintCid) {
+ EmitUnboxedMintEqualityOp(compiler, *locs(), kind(), kNoBranch);
+ return;
+ }
+ if (receiver_class_id() == kDoubleCid) {
+ EmitDoubleComparisonOp(compiler, *locs(), kind(), kNoBranch);
+ return;
+ }
+ const bool is_checked_strict_equal =
+ HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid);
+ if (is_checked_strict_equal) {
+ EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), kNoBranch,
+ deopt_id());
+ return;
+ }
+ if (IsPolymorphic()) {
+ EmitGenericEqualityCompare(compiler, locs(), kind(), kNoBranch, *ic_data(),
+ deopt_id(), token_pos());
+ return;
+ }
+ Register left = locs()->in(0).reg();
+ Register right = locs()->in(1).reg();
+ ASSERT(left == A1);
+ ASSERT(right == A0);
+ EmitEqualityAsInstanceCall(compiler,
+ deopt_id(),
+ token_pos(),
+ kind(),
+ locs(),
+ *ic_data());
+ ASSERT(locs()->out().reg() == V0);
}
void EqualityCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
BranchInstr* branch) {
- UNIMPLEMENTED();
+ ASSERT((kind() == Token::kNE) || (kind() == Token::kEQ));
+ if (receiver_class_id() == kSmiCid) {
+ // Deoptimizes if both arguments not Smi.
+ EmitSmiComparisonOp(compiler, *locs(), kind(), branch);
+ return;
+ }
+ if (receiver_class_id() == kMintCid) {
+ EmitUnboxedMintEqualityOp(compiler, *locs(), kind(), branch);
+ return;
+ }
+ if (receiver_class_id() == kDoubleCid) {
+ EmitDoubleComparisonOp(compiler, *locs(), kind(), branch);
+ return;
+ }
+ const bool is_checked_strict_equal =
+ HasICData() && ic_data()->AllTargetsHaveSameOwner(kInstanceCid);
+ if (is_checked_strict_equal) {
+ EmitCheckedStrictEqual(compiler, *ic_data(), *locs(), kind(), branch,
+ deopt_id());
+ return;
+ }
+ if (IsPolymorphic()) {
+ EmitGenericEqualityCompare(compiler, locs(), kind(), branch, *ic_data(),
+ deopt_id(), token_pos());
+ return;
+ }
+ Register left = locs()->in(0).reg();
+ Register right = locs()->in(1).reg();
+ ASSERT(left == A1);
+ ASSERT(right == A0);
+ EmitEqualityAsInstanceCall(compiler,
+ deopt_id(),
+ token_pos(),
+ Token::kEQ, // kNE reverse occurs at branch.
+ locs(),
+ *ic_data());
+ if (branch->is_checked()) {
+ EmitAssertBoolean(V0, token_pos(), deopt_id(), locs(), compiler);
+ }
+ Condition branch_condition = (kind() == Token::kNE) ? NE : EQ;
+ __ CompareObject(CMPRES, V0, Bool::True());
+ branch->EmitBranchOnCondition(compiler, branch_condition);
}
@@ -249,10 +582,10 @@
__ PushObject(Object::ZoneHandle());
// Pass a pointer to the first argument in A2.
if (!function().HasOptionalParameters()) {
- __ addiu(A2, FP, Immediate((kLastParamSlotIndex +
- function().NumParameters() - 1) * kWordSize));
+ __ AddImmediate(A2, FP, (kLastParamSlotIndex +
+ function().NumParameters() - 1) * kWordSize);
} else {
- __ addiu(A2, FP, Immediate(kFirstLocalSlotIndex * kWordSize));
+ __ AddImmediate(A2, FP, kFirstLocalSlotIndex * kWordSize);
}
// Compute the effective address. When running under the simulator,
// this is a redirection address that forces the simulator to call
@@ -537,11 +870,10 @@
CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this);
compiler->AddSlowPathCode(slow_path);
- __ LoadImmediate(TMP, Isolate::Current()->stack_limit_address());
+ __ LoadImmediate(TMP1, Isolate::Current()->stack_limit_address());
- __ lw(TMP, Address(TMP));
- __ subu(TMP, SP, TMP);
- __ blez(TMP, slow_path->entry_label());
+ __ lw(TMP1, Address(TMP1));
+ __ BranchLessEqual(SP, TMP1, slow_path->entry_label());
__ Bind(slow_path->exit_label());
}
@@ -591,6 +923,28 @@
}
+LocationSummary* BoxFloat32x4Instr::MakeLocationSummary() const {
+ UNIMPLEMENTED();
+ return NULL;
+}
+
+
+void BoxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ UNIMPLEMENTED();
+}
+
+
+LocationSummary* UnboxFloat32x4Instr::MakeLocationSummary() const {
+ UNIMPLEMENTED();
+ return NULL;
+}
+
+
+void UnboxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ UNIMPLEMENTED();
+}
+
+
LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary() const {
UNIMPLEMENTED();
return NULL;
@@ -697,7 +1051,7 @@
void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ comparison()->EmitBranchCode(compiler, this);
}
@@ -813,25 +1167,79 @@
LocationSummary* GotoInstr::MakeLocationSummary() const {
- UNIMPLEMENTED();
- return NULL;
+ return new LocationSummary(0, 0, LocationSummary::kNoCall);
}
void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ // Add deoptimization descriptor for deoptimizing instructions
+ // that may be inserted before this instruction.
+ if (!compiler->is_optimizing()) {
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
+ GetDeoptId(),
+ 0); // No token position.
+ }
+
+ if (HasParallelMove()) {
+ compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
+ }
+
+ // We can fall through if the successor is the next block in the list.
+ // Otherwise, we need a jump.
+ if (!compiler->CanFallThroughTo(successor())) {
+ __ b(compiler->GetJumpLabel(successor()));
+ }
+}
+
+
+static Condition NegateCondition(Condition condition) {
+ switch (condition) {
+ case EQ: return NE;
+ case NE: return EQ;
+ default:
+ OS::Print("Error: Condition not recognized: %d\n", condition);
+ UNIMPLEMENTED();
+ return EQ;
+ }
}
void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler,
bool value) {
- UNIMPLEMENTED();
+ if (value && !compiler->CanFallThroughTo(true_successor())) {
+ __ b(compiler->GetJumpLabel(true_successor()));
+ } else if (!value && !compiler->CanFallThroughTo(false_successor())) {
+ __ b(compiler->GetJumpLabel(false_successor()));
+ }
}
+// The comparison result is in CMPRES.
void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler,
Condition true_condition) {
- UNIMPLEMENTED();
+ if (compiler->CanFallThroughTo(false_successor())) {
+ // If the next block is the false successor we will fall through to it.
+ if (true_condition == EQ) {
+ __ beq(CMPRES, ZR, compiler->GetJumpLabel(true_successor()));
+ } else {
+ ASSERT(true_condition == NE);
+ __ bne(CMPRES, ZR, compiler->GetJumpLabel(true_successor()));
+ }
+ } else {
+ // If the next block is the true successor we negate comparison and fall
+ // through to it.
+ Condition false_condition = NegateCondition(true_condition);
+ if (false_condition == EQ) {
+ __ beq(CMPRES, ZR, compiler->GetJumpLabel(false_successor()));
+ } else {
+ ASSERT(false_condition == NE);
+ __ bne(CMPRES, ZR, compiler->GetJumpLabel(false_successor()));
+ }
+ // Fall through or jump to the true successor.
+ if (!compiler->CanFallThroughTo(true_successor())) {
+ __ b(compiler->GetJumpLabel(true_successor()));
+ }
+ }
}
@@ -847,19 +1255,89 @@
LocationSummary* StrictCompareInstr::MakeLocationSummary() const {
- UNIMPLEMENTED();
- return NULL;
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RegisterOrConstant(left()));
+ locs->set_in(1, Location::RegisterOrConstant(right()));
+ locs->set_out(Location::RequiresRegister());
+ return locs;
}
+// Special code for numbers (compare values instead of references.)
void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
+ Location left = locs()->in(0);
+ Location right = locs()->in(1);
+ if (left.IsConstant() && right.IsConstant()) {
+ // TODO(vegorov): should be eliminated earlier by constant propagation.
+ const bool result = (kind() == Token::kEQ_STRICT) ?
+ left.constant().raw() == right.constant().raw() :
+ left.constant().raw() != right.constant().raw();
+ __ LoadObject(locs()->out().reg(), result ? Bool::True() : Bool::False());
+ return;
+ }
+ if (left.IsConstant()) {
+ compiler->EmitEqualityRegConstCompare(right.reg(),
+ left.constant(),
+ needs_number_check());
+ } else if (right.IsConstant()) {
+ compiler->EmitEqualityRegConstCompare(left.reg(),
+ right.constant(),
+ needs_number_check());
+ } else {
+ compiler->EmitEqualityRegRegCompare(left.reg(),
+ right.reg(),
+ needs_number_check());
+ }
+
+ Register result = locs()->out().reg();
+ Label load_true, done;
+ if (kind() == Token::kEQ_STRICT) {
+ __ beq(CMPRES, ZR, &load_true);
+ } else {
+ ASSERT(kind() == Token::kNE_STRICT);
+ __ bne(CMPRES, ZR, &load_true);
+ }
+ __ LoadObject(result, Bool::False());
+ __ b(&done);
+ __ Bind(&load_true);
+ __ LoadObject(result, Bool::True());
+ __ Bind(&done);
}
void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
BranchInstr* branch) {
- UNIMPLEMENTED();
+ ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
+ Location left = locs()->in(0);
+ Location right = locs()->in(1);
+ if (left.IsConstant() && right.IsConstant()) {
+ // TODO(vegorov): should be eliminated earlier by constant propagation.
+ const bool result = (kind() == Token::kEQ_STRICT) ?
+ left.constant().raw() == right.constant().raw() :
+ left.constant().raw() != right.constant().raw();
+ branch->EmitBranchOnValue(compiler, result);
+ return;
+ }
+ if (left.IsConstant()) {
+ compiler->EmitEqualityRegConstCompare(right.reg(),
+ left.constant(),
+ needs_number_check());
+ } else if (right.IsConstant()) {
+ compiler->EmitEqualityRegConstCompare(left.reg(),
+ right.constant(),
+ needs_number_check());
+ } else {
+ compiler->EmitEqualityRegRegCompare(left.reg(),
+ right.reg(),
+ needs_number_check());
+ }
+
+ Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQ : NE;
+ branch->EmitBranchOnCondition(compiler, true_condition);
}
@@ -902,13 +1380,19 @@
LocationSummary* AllocateObjectInstr::MakeLocationSummary() const {
- UNIMPLEMENTED();
- return NULL;
+ return MakeCallSummary();
}
void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- UNIMPLEMENTED();
+ const Class& cls = Class::ZoneHandle(constructor().Owner());
+ const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls));
+ const ExternalLabel label(cls.ToCString(), stub.EntryPoint());
+ compiler->GenerateCall(token_pos(),
+ &label,
+ PcDescriptors::kOther,
+ locs());
+ __ Drop(ArgumentCount()); // Discard arguments.
}
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc
index 3edf1ed..264c3199 100644
--- a/runtime/vm/intermediate_language_x64.cc
+++ b/runtime/vm/intermediate_language_x64.cc
@@ -113,6 +113,147 @@
}
+static Condition NegateCondition(Condition condition) {
+ switch (condition) {
+ case EQUAL: return NOT_EQUAL;
+ case NOT_EQUAL: return EQUAL;
+ case LESS: return GREATER_EQUAL;
+ case LESS_EQUAL: return GREATER;
+ case GREATER: return LESS_EQUAL;
+ case GREATER_EQUAL: return LESS;
+ case BELOW: return ABOVE_EQUAL;
+ case BELOW_EQUAL: return ABOVE;
+ case ABOVE: return BELOW_EQUAL;
+ case ABOVE_EQUAL: return BELOW;
+ default:
+ OS::Print("Error %d\n", condition);
+ UNIMPLEMENTED();
+ return EQUAL;
+ }
+}
+
+
+static bool BindsToSmiConstant(Value* val, intptr_t* smi_value) {
+ if (!val->BindsToConstant()) {
+ return false;
+ }
+
+ const Object& bound_constant = val->BoundConstant();
+ if (!bound_constant.IsSmi()) {
+ return false;
+ }
+
+ *smi_value = Smi::Cast(bound_constant).Value();
+ return true;
+}
+
+
+// Detect pattern when one value is zero and another is a power of 2.
+static bool IsPowerOfTwoKind(intptr_t v1, intptr_t v2) {
+ return (Utils::IsPowerOfTwo(v1) && (v2 == 0)) ||
+ (Utils::IsPowerOfTwo(v2) && (v1 == 0));
+}
+
+
+// Detect pattern when one value is increment of another.
+static bool IsIncrementKind(intptr_t v1, intptr_t v2) {
+ return ((v1 == v2 + 1) || (v1 + 1 == v2));
+}
+
+
+bool IfThenElseInstr::IsSupported() {
+ return true;
+}
+
+
+bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
+ Value* v1,
+ Value* v2) {
+ if (!(comparison->IsStrictCompare() &&
+ !comparison->AsStrictCompare()->needs_number_check()) &&
+ !(comparison->IsEqualityCompare() &&
+ (comparison->AsEqualityCompare()->receiver_class_id() == kSmiCid))) {
+ return false;
+ }
+
+ intptr_t v1_value, v2_value;
+
+ if (!BindsToSmiConstant(v1, &v1_value) ||
+ !BindsToSmiConstant(v2, &v2_value)) {
+ return false;
+ }
+
+ if (IsPowerOfTwoKind(v1_value, v2_value) ||
+ IsIncrementKind(v1_value, v2_value)) {
+ return true;
+ }
+
+ return false;
+}
+
+
+LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 2;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* locs =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ locs->set_in(0, Location::RegisterOrConstant(left()));
+ locs->set_in(1, Location::RegisterOrConstant(right()));
+ // TODO(vegorov): support byte register constraints in the register allocator.
+ locs->set_out(Location::RegisterLocation(RDX));
+ return locs;
+}
+
+
+void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ ASSERT(locs()->out().reg() == RDX);
+ ASSERT(Token::IsEqualityOperator(kind()));
+
+ Location left = locs()->in(0);
+ Location right = locs()->in(1);
+ ASSERT(!left.IsConstant() || !right.IsConstant());
+
+ // Clear upper part of the out register. We are going to use setcc on it
+ // which is a byte move.
+ __ xorq(RDX, RDX);
+
+ // Compare left and right. For now only equality comparison is supported.
+ // TODO(vegorov): reuse code from the other comparison instructions instead of
+ // generating it inline here.
+ if (left.IsConstant()) {
+ __ CompareObject(right.reg(), left.constant());
+ } else if (right.IsConstant()) {
+ __ CompareObject(left.reg(), right.constant());
+ } else {
+ __ cmpq(left.reg(), right.reg());
+ }
+
+ Condition true_condition =
+ ((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kEQ)) ? EQUAL
+ : NOT_EQUAL;
+
+ const bool is_power_of_two_kind = IsPowerOfTwoKind(if_true_, if_false_);
+
+ const intptr_t base = Utils::Minimum(if_true_, if_false_);
+
+ if (if_true_ == base) {
+ // We need to have zero in RDX on true_condition.
+ true_condition = NegateCondition(true_condition);
+ }
+
+ __ setcc(true_condition, DL);
+
+ if (is_power_of_two_kind) {
+ const intptr_t shift =
+ Utils::ShiftForPowerOfTwo(Utils::Maximum(if_true_, if_false_));
+ __ shlq(RDX, Immediate(shift + kSmiTagSize));
+ } else {
+ ASSERT(kSmiTagSize == 1);
+ __ leaq(RDX, Address(RDX, TIMES_2, base << kSmiTagSize));
+ }
+}
+
+
LocationSummary* ClosureCallInstr::MakeLocationSummary() const {
const intptr_t kNumInputs = 0;
const intptr_t kNumTemps = 1;
@@ -334,7 +475,7 @@
LocationSummary* locs,
const ICData& original_ic_data) {
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id,
token_pos);
}
@@ -842,7 +983,7 @@
const String& function_name =
String::ZoneHandle(Symbols::New(Token::Str(kind())));
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
deopt_id(),
token_pos());
}
@@ -991,6 +1132,8 @@
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
return CompileType::FromCid(kDoubleCid);
+ case kTypedDataFloat32x4ArrayCid:
+ return CompileType::FromCid(kFloat32x4Cid);
case kTypedDataInt8ArrayCid:
case kTypedDataUint8ArrayCid:
@@ -1031,6 +1174,8 @@
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
return kUnboxedDouble;
+ case kTypedDataFloat32x4ArrayCid:
+ return kUnboxedFloat32x4;
default:
UNIMPLEMENTED();
return kTagged;
@@ -1090,7 +1235,8 @@
Smi::Cast(index.constant()).Value());
}
- if (representation() == kUnboxedDouble) {
+ if ((representation() == kUnboxedDouble) ||
+ (representation() == kUnboxedFloat32x4)) {
if ((index_scale() == 1) && index.IsRegister()) {
__ SmiUntag(index.reg());
}
@@ -1101,9 +1247,11 @@
__ movss(result, element_address);
// Promote to double.
__ cvtss2sd(result, locs()->out().fpu_reg());
- } else {
- ASSERT(class_id() == kTypedDataFloat64ArrayCid);
+ } else if (class_id() == kTypedDataFloat64ArrayCid) {
__ movsd(result, element_address);
+ } else {
+ ASSERT(class_id() == kTypedDataFloat32x4ArrayCid);
+ __ movups(result, element_address);
}
return;
}
@@ -1170,6 +1318,8 @@
case kTypedDataFloat32ArrayCid:
case kTypedDataFloat64ArrayCid:
return kUnboxedDouble;
+ case kTypedDataFloat32x4ArrayCid:
+ return kUnboxedFloat32x4;
default:
UNIMPLEMENTED();
return kTagged;
@@ -1226,6 +1376,9 @@
// TODO(srdjan): Support Float64 constants.
locs->set_in(2, Location::RequiresFpuRegister());
break;
+ case kTypedDataFloat32x4ArrayCid:
+ locs->set_in(2, Location::RequiresFpuRegister());
+ break;
default:
UNREACHABLE();
return NULL;
@@ -1339,6 +1492,9 @@
case kTypedDataFloat64ArrayCid:
__ movsd(element_address, locs()->in(2).fpu_reg());
break;
+ case kTypedDataFloat32x4ArrayCid:
+ __ movups(element_address, locs()->in(2).fpu_reg());
+ break;
default:
UNREACHABLE();
}
@@ -1556,7 +1712,8 @@
__ LoadObject(temp, field());
if (this->value()->NeedsStoreBuffer()) {
- __ StoreIntoObject(temp, FieldAddress(temp, Field::value_offset()), value);
+ __ StoreIntoObject(temp,
+ FieldAddress(temp, Field::value_offset()), value, CanValueBeSmi());
} else {
__ StoreIntoObjectNoBarrier(
temp, FieldAddress(temp, Field::value_offset()), value);
@@ -2487,11 +2644,11 @@
locs->live_registers()->Remove(locs->out());
compiler->SaveLiveRegisters(locs);
- compiler->GenerateCall(instruction_->token_pos(),
+ compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position.
&label,
PcDescriptors::kOther,
locs);
- if (RAX != locs->out().reg()) __ movq(locs->out().reg(), RAX);
+ __ MoveRegister(locs->out().reg(), RAX);
compiler->RestoreLiveRegisters(locs);
__ jmp(exit_label());
@@ -2559,6 +2716,88 @@
}
+LocationSummary* BoxFloat32x4Instr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs,
+ kNumTemps,
+ LocationSummary::kCallOnSlowPath);
+ summary->set_in(0, Location::RequiresFpuRegister());
+ summary->set_out(Location::RequiresRegister());
+ return summary;
+}
+
+
+class BoxFloat32x4SlowPath : public SlowPathCode {
+ public:
+ explicit BoxFloat32x4SlowPath(BoxFloat32x4Instr* instruction)
+ : instruction_(instruction) { }
+
+ virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
+ __ Comment("BoxFloat32x4SlowPath");
+ __ Bind(entry_label());
+ const Class& float32x4_class = compiler->float32x4_class();
+ const Code& stub =
+ Code::Handle(StubCode::GetAllocationStubForClass(float32x4_class));
+ const ExternalLabel label(float32x4_class.ToCString(), stub.EntryPoint());
+
+ LocationSummary* locs = instruction_->locs();
+ locs->live_registers()->Remove(locs->out());
+
+ compiler->SaveLiveRegisters(locs);
+ compiler->GenerateCall(Scanner::kDummyTokenIndex, // No token position.
+ &label,
+ PcDescriptors::kOther,
+ locs);
+ __ MoveRegister(locs->out().reg(), RAX);
+ compiler->RestoreLiveRegisters(locs);
+
+ __ jmp(exit_label());
+ }
+
+ private:
+ BoxFloat32x4Instr* instruction_;
+};
+
+
+void BoxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ BoxFloat32x4SlowPath* slow_path = new BoxFloat32x4SlowPath(this);
+ compiler->AddSlowPathCode(slow_path);
+
+ Register out_reg = locs()->out().reg();
+ XmmRegister value = locs()->in(0).fpu_reg();
+
+ __ TryAllocate(compiler->float32x4_class(),
+ slow_path->entry_label(),
+ Assembler::kFarJump,
+ out_reg);
+ __ Bind(slow_path->exit_label());
+ __ movups(FieldAddress(out_reg, Float32x4::value_offset()), value);
+}
+
+
+LocationSummary* UnboxFloat32x4Instr::MakeLocationSummary() const {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
+ summary->set_in(0, Location::RequiresRegister());
+ summary->set_out(Location::RequiresFpuRegister());
+ return summary;
+}
+
+
+void UnboxFloat32x4Instr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ const intptr_t value_cid = value()->Type()->ToCid();
+ const Register value = locs()->in(0).reg();
+ const XmmRegister result = locs()->out().fpu_reg();
+
+ ASSERT(value_cid == kFloat32x4Cid);
+ __ movups(result, FieldAddress(value, Float32x4::value_offset()));
+}
+
+
LocationSummary* BinaryDoubleOpInstr::MakeLocationSummary() const {
const intptr_t kNumInputs = 2;
const intptr_t kNumTemps = 0;
@@ -2788,11 +3027,11 @@
const intptr_t kNumTemps = 0;
LocationSummary* result =
new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall);
- result->set_in(0, Location::FpuRegisterLocation(XMM1, kUnboxedDouble));
+ result->set_in(0, Location::FpuRegisterLocation(XMM1));
if (InputCount() == 2) {
- result->set_in(1, Location::FpuRegisterLocation(XMM2, kUnboxedDouble));
+ result->set_in(1, Location::FpuRegisterLocation(XMM2));
}
- result->set_out(Location::FpuRegisterLocation(XMM1, kUnboxedDouble));
+ result->set_out(Location::FpuRegisterLocation(XMM1));
return result;
}
@@ -3079,7 +3318,7 @@
// Add deoptimization descriptor for deoptimizing instructions
// that may be inserted before this instruction.
if (!compiler->is_optimizing()) {
- compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
+ compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
GetDeoptId(),
0); // No token position.
}
@@ -3096,26 +3335,6 @@
}
-static Condition NegateCondition(Condition condition) {
- switch (condition) {
- case EQUAL: return NOT_EQUAL;
- case NOT_EQUAL: return EQUAL;
- case LESS: return GREATER_EQUAL;
- case LESS_EQUAL: return GREATER;
- case GREATER: return LESS_EQUAL;
- case GREATER_EQUAL: return LESS;
- case BELOW: return ABOVE_EQUAL;
- case BELOW_EQUAL: return ABOVE;
- case ABOVE: return BELOW_EQUAL;
- case ABOVE_EQUAL: return BELOW;
- default:
- OS::Print("Error %d\n", condition);
- UNIMPLEMENTED();
- return EQUAL;
- }
-}
-
-
void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler,
bool value) {
if (value && !compiler->CanFallThroughTo(true_successor())) {
diff --git a/runtime/vm/intrinsifier.h b/runtime/vm/intrinsifier.h
index f57a929..0716629 100644
--- a/runtime/vm/intrinsifier.h
+++ b/runtime/vm/intrinsifier.h
@@ -80,6 +80,8 @@
V(_StringBase, get:length, String_getLength, 320803993) \
V(_StringBase, codeUnitAt, String_codeUnitAt, 984449525) \
V(_OneByteString, get:hashCode, OneByteString_getHashCode, 682660413) \
+ V(_OneByteString, _substringUncheckedNative, \
+ OneByteString_substringUnchecked, 713121438) \
#define MATH_LIB_INTRINSIC_LIST(V) \
diff --git a/runtime/vm/intrinsifier_arm.cc b/runtime/vm/intrinsifier_arm.cc
index 1f86747..2e8f6ea 100644
--- a/runtime/vm/intrinsifier_arm.cc
+++ b/runtime/vm/intrinsifier_arm.cc
@@ -335,6 +335,11 @@
return false;
}
+
+bool Intrinsifier::OneByteString_substringUnchecked(Assembler* assembler) {
+ return false;
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_ARM
diff --git a/runtime/vm/intrinsifier_ia32.cc b/runtime/vm/intrinsifier_ia32.cc
index fc32498..3a00aed 100644
--- a/runtime/vm/intrinsifier_ia32.cc
+++ b/runtime/vm/intrinsifier_ia32.cc
@@ -1498,6 +1498,110 @@
return true;
}
+
+// Allocates one-byte string of length 'end - start'. The content is not
+// initialized.
+static void TryAllocateOnebyteString(Assembler* assembler,
+ Label* failure,
+ intptr_t start_index_offset,
+ intptr_t end_index_offset) {
+ __ movl(EDI, Address(ESP, + end_index_offset));
+ __ subl(EDI, Address(ESP, + start_index_offset));
+ const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1;
+ __ SmiUntag(EDI);
+ __ leal(EDI, Address(EDI, TIMES_1, fixed_size)); // EDI is a Smi.
+ __ andl(EDI, Immediate(-kObjectAlignment));
+
+ Isolate* isolate = Isolate::Current();
+ Heap* heap = isolate->heap();
+
+ __ movl(EAX, Address::Absolute(heap->TopAddress()));
+ __ movl(EBX, EAX);
+
+ // EDI: allocation size.
+ __ addl(EBX, EDI);
+ __ j(CARRY, failure);
+
+ // Check if the allocation fits into the remaining space.
+ // EAX: potential new object start.
+ // EBX: potential next object start.
+ // EDI: allocation size.
+ __ cmpl(EBX, Address::Absolute(heap->EndAddress()));
+ __ j(ABOVE_EQUAL, failure);
+
+ // Successfully allocated the object(s), now update top to point to
+ // next object start and initialize the object.
+ __ movl(Address::Absolute(heap->TopAddress()), EBX);
+ __ addl(EAX, Immediate(kHeapObjectTag));
+
+ // Initialize the tags.
+ // EAX: new object start as a tagged pointer.
+ // EBX: new object end address.
+ // EDI: allocation size.
+ {
+ Label size_tag_overflow, done;
+ __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag));
+ __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
+ __ shll(EDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
+ __ jmp(&done, Assembler::kNearJump);
+
+ __ Bind(&size_tag_overflow);
+ __ xorl(EDI, EDI);
+ __ Bind(&done);
+
+ // Get the class index and insert it into the tags.
+ const Class& cls =
+ Class::Handle(isolate->object_store()->one_byte_string_class());
+ __ orl(EDI, Immediate(RawObject::ClassIdTag::encode(cls.id())));
+ __ movl(FieldAddress(EAX, String::tags_offset()), EDI); // Tags.
+ }
+
+ // Set the length field.
+ __ movl(EDI, Address(ESP, + end_index_offset));
+ __ subl(EDI, Address(ESP, + start_index_offset)); // Length.
+ __ StoreIntoObjectNoBarrier(EAX,
+ FieldAddress(EAX, String::length_offset()),
+ EDI);
+ // Clear hash.
+ __ movl(FieldAddress(EAX, String::hash_offset()), Immediate(0));
+}
+
+
+// Arg0: Onebyte String
+// Arg1: Start index as Smi.
+// Arg2: End index as Smi.
+// The indexes must be valid.
+bool Intrinsifier::OneByteString_substringUnchecked(Assembler* assembler) {
+ const intptr_t kStringOffset = 3 * kWordSize;
+ const intptr_t kStartIndexOffset = 2 * kWordSize;
+ const intptr_t kEndIndexOffset = 1 * kWordSize;
+ Label fall_through;
+ TryAllocateOnebyteString(
+ assembler, &fall_through, kStartIndexOffset, kEndIndexOffset);
+ // EAX: new string as tagged pointer.
+ // Copy string.
+ __ movl(EDI, Address(ESP, + kStringOffset));
+ __ movl(EBX, Address(ESP, + kStartIndexOffset));
+ __ SmiUntag(EBX);
+ __ leal(EDI, FieldAddress(EDI, EBX, TIMES_1, OneByteString::data_offset()));
+ // EDI: Start address to copy from (untagged).
+ // EBX: Untagged start index.
+ __ movl(ECX, Address(ESP, + kEndIndexOffset));
+ __ SmiUntag(ECX);
+ __ subl(ECX, EBX);
+ // ECX: Untagged number of bytes to copy.
+ ASSERT(CTX == ESI);
+ __ pushl(ESI); // Preserve CTX.
+ __ movl(ESI, EDI); // from.
+ __ leal(EDI, FieldAddress(EAX, OneByteString::data_offset())); // to.
+ __ rep_movsb();
+ __ popl(ESI); // Restore CTX.
+
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
#undef __
} // namespace dart
diff --git a/runtime/vm/intrinsifier_mips.cc b/runtime/vm/intrinsifier_mips.cc
index a93d678..7b47cdf 100644
--- a/runtime/vm/intrinsifier_mips.cc
+++ b/runtime/vm/intrinsifier_mips.cc
@@ -335,6 +335,11 @@
return false;
}
+
+bool Intrinsifier::OneByteString_substringUnchecked(Assembler* assembler) {
+ return false;
+}
+
} // namespace dart
#endif // defined TARGET_ARCH_MIPS
diff --git a/runtime/vm/intrinsifier_x64.cc b/runtime/vm/intrinsifier_x64.cc
index 231eacc..3e65b9f 100644
--- a/runtime/vm/intrinsifier_x64.cc
+++ b/runtime/vm/intrinsifier_x64.cc
@@ -1420,6 +1420,109 @@
}
+// Allocates one-byte string of length 'end - start'. The content is not
+// initialized.
+static void TryAllocateOnebyteString(Assembler* assembler,
+ Label* failure,
+ intptr_t start_index_offset,
+ intptr_t end_index_offset) {
+ __ movq(RDI, Address(RSP, + end_index_offset));
+ __ subq(RDI, Address(RSP, + start_index_offset));
+ const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1;
+ __ SmiUntag(RDI);
+ __ leaq(RDI, Address(RDI, TIMES_1, fixed_size)); // RDI is a Smi.
+ __ andq(RDI, Immediate(-kObjectAlignment));
+
+ Isolate* isolate = Isolate::Current();
+ Heap* heap = isolate->heap();
+
+ __ movq(RAX, Immediate(heap->TopAddress()));
+ __ movq(RAX, Address(RAX, 0));
+
+ // RDI: allocation size.
+ __ movq(RCX, RAX);
+ __ addq(RCX, RDI);
+ __ j(CARRY, failure);
+
+ // Check if the allocation fits into the remaining space.
+ // RAX: potential new object start.
+ // RCX: potential next object start.
+ // RDI: allocation size.
+ __ movq(R13, Immediate(heap->EndAddress()));
+ __ cmpq(RCX, Address(R13, 0));
+ __ j(ABOVE_EQUAL, failure);
+
+ // Successfully allocated the object(s), now update top to point to
+ // next object start and initialize the object.
+ __ movq(R13, Immediate(heap->TopAddress()));
+ __ movq(Address(R13, 0), RCX);
+ __ addq(RAX, Immediate(kHeapObjectTag));
+
+ // Initialize the tags.
+ // RAX: new object start as a tagged pointer.
+ // RDI: allocation size.
+ {
+ Label size_tag_overflow, done;
+ __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag));
+ __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump);
+ __ shlq(RDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2));
+ __ jmp(&done, Assembler::kNearJump);
+
+ __ Bind(&size_tag_overflow);
+ __ xorq(RDI, RDI);
+ __ Bind(&done);
+
+ // Get the class index and insert it into the tags.
+ const Class& cls =
+ Class::Handle(isolate->object_store()->one_byte_string_class());
+ __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id())));
+ __ movq(FieldAddress(RAX, String::tags_offset()), RDI); // Tags.
+ }
+
+ // Set the length field.
+ __ movq(RDI, Address(RSP, + end_index_offset));
+ __ subq(RDI, Address(RSP, + start_index_offset)); // Length.
+ __ StoreIntoObjectNoBarrier(RAX,
+ FieldAddress(RAX, String::length_offset()),
+ RDI);
+ // Clear hash.
+ __ movq(FieldAddress(RAX, String::hash_offset()), Immediate(0));
+}
+
+
+// Arg0: Onebyte String
+// Arg1: Start index as Smi.
+// Arg2: End index as Smi.
+// The indexes must be valid.
+bool Intrinsifier::OneByteString_substringUnchecked(Assembler* assembler) {
+ const intptr_t kStringOffset = 3 * kWordSize;
+ const intptr_t kStartIndexOffset = 2 * kWordSize;
+ const intptr_t kEndIndexOffset = 1 * kWordSize;
+ Label fall_through;
+ TryAllocateOnebyteString(
+ assembler, &fall_through, kStartIndexOffset, kEndIndexOffset);
+ // RAX: new string as tagged pointer.
+ // Copy string.
+ __ movq(RSI, Address(RSP, + kStringOffset));
+ __ movq(RBX, Address(RSP, + kStartIndexOffset));
+ __ SmiUntag(RBX);
+ __ leaq(RSI, FieldAddress(RSI, RBX, TIMES_1, OneByteString::data_offset()));
+ // RDI: Start address to copy from (untagged).
+ // RBX: Untagged start index.
+ __ movq(RCX, Address(RSP, + kEndIndexOffset));
+ __ SmiUntag(RCX);
+ __ subq(RCX, RBX);
+ // RCX: Untagged number of bytes to copy.
+
+ __ leaq(RDI, FieldAddress(RAX, OneByteString::data_offset())); // to.
+ __ rep_movsb();
+
+ __ ret();
+ __ Bind(&fall_through);
+ return false;
+}
+
+
#undef __
} // namespace dart
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index c5e68536..d67b4e1 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -337,6 +337,7 @@
saved_stack_limit_(0),
message_handler_(NULL),
spawn_data_(0),
+ is_runnable_(false),
gc_prologue_callbacks_(),
gc_epilogue_callbacks_(),
deopt_cpu_registers_copy_(NULL),
@@ -480,6 +481,109 @@
}
+bool Isolate::MakeRunnable() {
+ ASSERT(Isolate::Current() == NULL);
+ // Can't use MutexLocker here because MutexLocker is
+ // a StackResource, which requires a current isolate.
+ mutex_->Lock();
+ // Check if we are in a valid state to make the isolate runnable.
+ if (is_runnable_ == true) {
+ mutex_->Unlock();
+ return false; // Already runnable.
+ }
+ // Set the isolate as runnable and if we are being spawned schedule
+ // isolate on thread pool for execution.
+ is_runnable_ = true;
+ IsolateSpawnState* state = reinterpret_cast<IsolateSpawnState*>(spawn_data());
+ if (state != NULL) {
+ ASSERT(this == state->isolate());
+ Run();
+ }
+ mutex_->Unlock();
+ return true;
+}
+
+
+static void StoreError(Isolate* isolate, const Object& obj) {
+ ASSERT(obj.IsError());
+ isolate->object_store()->set_sticky_error(Error::Cast(obj));
+}
+
+
+static bool RunIsolate(uword parameter) {
+ Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
+ IsolateSpawnState* state = NULL;
+ {
+ MutexLocker ml(isolate->mutex());
+ state = reinterpret_cast<IsolateSpawnState*>(isolate->spawn_data());
+ isolate->set_spawn_data(0);
+ }
+ {
+ StartIsolateScope start_scope(isolate);
+ StackZone zone(isolate);
+ HandleScope handle_scope(isolate);
+ if (!ClassFinalizer::FinalizePendingClasses()) {
+ // Error is in sticky error already.
+ return false;
+ }
+
+ // Set up specific unhandled exception handler.
+ const String& callback_name = String::Handle(
+ isolate, String::New(state->exception_callback_name()));
+ isolate->object_store()->
+ set_unhandled_exception_handler(callback_name);
+
+ Object& result = Object::Handle();
+ result = state->ResolveFunction();
+ delete state;
+ state = NULL;
+ if (result.IsError()) {
+ StoreError(isolate, result);
+ return false;
+ }
+ ASSERT(result.IsFunction());
+ Function& func = Function::Handle(isolate);
+ func ^= result.raw();
+ result = DartEntry::InvokeFunction(func, Object::empty_array());
+ if (result.IsError()) {
+ StoreError(isolate, result);
+ return false;
+ }
+ }
+ return true;
+}
+
+
+static void ShutdownIsolate(uword parameter) {
+ Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
+ {
+ // Print the error if there is one. This may execute dart code to
+ // print the exception object, so we need to use a StartIsolateScope.
+ StartIsolateScope start_scope(isolate);
+ StackZone zone(isolate);
+ HandleScope handle_scope(isolate);
+ Error& error = Error::Handle();
+ error = isolate->object_store()->sticky_error();
+ if (!error.IsNull()) {
+ OS::PrintErr("in ShutdownIsolate: %s\n", error.ToErrorCString());
+ }
+ }
+ {
+ // Shut the isolate down.
+ SwitchIsolateScope switch_scope(isolate);
+ Dart::ShutdownIsolate();
+ }
+}
+
+
+void Isolate::Run() {
+ message_handler()->Run(Dart::thread_pool(),
+ RunIsolate,
+ ShutdownIsolate,
+ reinterpret_cast<uword>(this));
+}
+
+
uword Isolate::GetAndClearInterrupts() {
MutexLocker ml(mutex_);
if (stack_limit_ == saved_stack_limit_) {
@@ -878,4 +982,94 @@
return NULL; // Unimplemented query.
}
+
+static char* GetRootScriptUri(Isolate* isolate) {
+ const Library& library =
+ Library::Handle(isolate->object_store()->root_library());
+ ASSERT(!library.IsNull());
+ const String& script_name = String::Handle(library.url());
+ return isolate->current_zone()->MakeCopyOfString(script_name.ToCString());
+}
+
+
+IsolateSpawnState::IsolateSpawnState(const Function& func,
+ const Function& callback_func)
+ : isolate_(NULL),
+ script_url_(NULL),
+ library_url_(NULL),
+ function_name_(NULL),
+ exception_callback_name_(NULL) {
+ script_url_ = strdup(GetRootScriptUri(Isolate::Current()));
+ const Class& cls = Class::Handle(func.Owner());
+ ASSERT(cls.IsTopLevel());
+ const Library& lib = Library::Handle(cls.library());
+ const String& lib_url = String::Handle(lib.url());
+ library_url_ = strdup(lib_url.ToCString());
+
+ const String& func_name = String::Handle(func.name());
+ function_name_ = strdup(func_name.ToCString());
+ if (!callback_func.IsNull()) {
+ const String& callback_name = String::Handle(callback_func.name());
+ exception_callback_name_ = strdup(callback_name.ToCString());
+ } else {
+ exception_callback_name_ = strdup("_unhandledExceptionCallback");
+ }
+}
+
+
+IsolateSpawnState::IsolateSpawnState(const char* script_url)
+ : isolate_(NULL),
+ library_url_(NULL),
+ function_name_(NULL),
+ exception_callback_name_(NULL) {
+ script_url_ = strdup(script_url);
+ library_url_ = NULL;
+ function_name_ = strdup("main");
+ exception_callback_name_ = strdup("_unhandledExceptionCallback");
+}
+
+
+IsolateSpawnState::~IsolateSpawnState() {
+ free(script_url_);
+ free(library_url_);
+ free(function_name_);
+ free(exception_callback_name_);
+}
+
+
+RawObject* IsolateSpawnState::ResolveFunction() {
+ // Resolve the library.
+ Library& lib = Library::Handle();
+ if (library_url()) {
+ const String& lib_url = String::Handle(String::New(library_url()));
+ lib = Library::LookupLibrary(lib_url);
+ if (lib.IsNull() || lib.IsError()) {
+ const String& msg = String::Handle(String::NewFormatted(
+ "Unable to find library '%s'.", library_url()));
+ return LanguageError::New(msg);
+ }
+ } else {
+ lib = isolate()->object_store()->root_library();
+ }
+ ASSERT(!lib.IsNull());
+
+ // Resolve the function.
+ const String& func_name =
+ String::Handle(String::New(function_name()));
+ const Function& func = Function::Handle(lib.LookupLocalFunction(func_name));
+ if (func.IsNull()) {
+ const String& msg = String::Handle(String::NewFormatted(
+ "Unable to resolve function '%s' in library '%s'.",
+ function_name(), (library_url() ? library_url() : script_url())));
+ return LanguageError::New(msg);
+ }
+ return func.raw();
+}
+
+
+void IsolateSpawnState::Cleanup() {
+ SwitchIsolateScope switch_scope(isolate());
+ Dart::ShutdownIsolate();
+}
+
} // namespace dart
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index c2e1523..05c05b4 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -21,6 +21,7 @@
class ApiState;
class CodeIndexTable;
class Debugger;
+class Function;
class HandleScope;
class HandleVisitor;
class Heap;
@@ -35,6 +36,7 @@
class RawContext;
class RawDouble;
class RawMint;
+class RawObject;
class RawInteger;
class RawError;
class Simulator;
@@ -274,13 +276,22 @@
void ScheduleInterrupts(uword interrupt_bits);
uword GetAndClearInterrupts();
+ bool MakeRunnable();
+ void Run();
+
MessageHandler* message_handler() const { return message_handler_; }
void set_message_handler(MessageHandler* value) { message_handler_ = value; }
+ bool is_runnable() const { return is_runnable_; }
+ void set_is_runnable(bool value) { is_runnable_ = value; }
+
uword spawn_data() const { return spawn_data_; }
void set_spawn_data(uword value) { spawn_data_ = value; }
static const intptr_t kNoDeoptId = -1;
+ static const intptr_t kDeoptIdStep = 2;
+ static const intptr_t kDeoptIdBeforeOffset = 0;
+ static const intptr_t kDeoptIdAfterOffset = 1;
intptr_t deopt_id() const { return deopt_id_; }
void set_deopt_id(int value) {
ASSERT(value >= 0);
@@ -288,13 +299,30 @@
}
intptr_t GetNextDeoptId() {
ASSERT(deopt_id_ != kNoDeoptId);
- return deopt_id_++;
+ const intptr_t id = deopt_id_;
+ deopt_id_ += kDeoptIdStep;
+ return id;
+ }
+
+ static intptr_t ToDeoptAfter(intptr_t deopt_id) {
+ ASSERT(IsDeoptBefore(deopt_id));
+ return deopt_id + kDeoptIdAfterOffset;
+ }
+
+ static bool IsDeoptBefore(intptr_t deopt_id) {
+ return (deopt_id % kDeoptIdStep) == kDeoptIdBeforeOffset;
+ }
+
+ static bool IsDeoptAfter(intptr_t deopt_id) {
+ return (deopt_id % kDeoptIdStep) == kDeoptIdAfterOffset;
}
RawArray* ic_data_array() const { return ic_data_array_; }
void set_ic_data_array(RawArray* value) { ic_data_array_ = value; }
ICData* GetICDataForDeoptId(intptr_t deopt_id) const;
+ Mutex* mutex() const { return mutex_; }
+
Debugger* debugger() const { return debugger_; }
Simulator* simulator() const { return simulator_; }
@@ -463,6 +491,7 @@
uword saved_stack_limit_;
MessageHandler* message_handler_;
uword spawn_data_;
+ bool is_runnable_;
GcPrologueCallbacks gc_prologue_callbacks_;
GcEpilogueCallbacks gc_epilogue_callbacks_;
@@ -553,6 +582,31 @@
DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope);
};
+
+class IsolateSpawnState {
+ public:
+ IsolateSpawnState(const Function& func, const Function& callback_func);
+ explicit IsolateSpawnState(const char* script_url);
+ ~IsolateSpawnState();
+
+ Isolate* isolate() const { return isolate_; }
+ void set_isolate(Isolate* value) { isolate_ = value; }
+ char* script_url() const { return script_url_; }
+ char* library_url() const { return library_url_; }
+ char* function_name() const { return function_name_; }
+ char* exception_callback_name() const { return exception_callback_name_; }
+
+ RawObject* ResolveFunction();
+ void Cleanup();
+
+ private:
+ Isolate* isolate_;
+ char* script_url_;
+ char* library_url_;
+ char* function_name_;
+ char* exception_callback_name_;
+};
+
} // namespace dart
#endif // VM_ISOLATE_H_
diff --git a/runtime/vm/locations.cc b/runtime/vm/locations.cc
index 58ecdd9..1f8e01b 100644
--- a/runtime/vm/locations.cc
+++ b/runtime/vm/locations.cc
@@ -105,8 +105,7 @@
case kFpuRegister: return Assembler::FpuRegisterName(fpu_reg());
case kStackSlot: return "S";
case kDoubleStackSlot: return "DS";
- case kFloat32x4StackSlot: return "F32x4S";
- case kUint32x4StackSlot: return "UI32x4S";
+ case kQuadStackSlot: return "QS";
case kUnallocated:
switch (policy()) {
case kAny:
diff --git a/runtime/vm/locations.h b/runtime/vm/locations.h
index 031a290..d74b91c 100644
--- a/runtime/vm/locations.h
+++ b/runtime/vm/locations.h
@@ -35,7 +35,12 @@
// low 3 bits denote location kind, rest is kind specific location payload
// e.g. for REGISTER kind payload is register code (value of the Register
// enumeration), constant locations contain a tagged (low 2 bits are set to 01)
-// Object handle
+// Object handle.
+//
+// Locations must satisfy the following invariant: if two locations' encodings
+// are bitwise unequal then these two locations are guaranteed to be disjoint.
+// Properties like representation belong to the value that is stored in
+// the location not to the location itself.
class Location : public ValueObject {
private:
enum {
@@ -54,6 +59,9 @@
// Constant payload can overlap with kind field so Kind values
// have to be chosen in a way that their last 2 bits are never
// the same as kConstant.
+ // Note that two locations with different kinds should never point to
+ // the same place. For example kQuadStackSlot location should never intersect
+ // with kDoubleStackSlot location.
enum Kind {
// This location is invalid. Payload must be zero.
kInvalid = 0,
@@ -67,12 +75,11 @@
// contains register allocation policy.
kUnallocated = 2,
- // Spill slot allocated by the register allocator. Payload contains
+ // Spill slots allocated by the register allocator. Payload contains
// a spill index.
- kStackSlot = 3,
- kDoubleStackSlot = 4,
- kFloat32x4StackSlot = 8,
- kUint32x4StackSlot = 10,
+ kStackSlot = 3, // Word size slot.
+ kDoubleStackSlot = 4, // 64bit stack slot.
+ kQuadStackSlot = 8, // 128bit stack slot.
// Register location represents a fixed register. Payload contains
// register code.
@@ -175,11 +182,8 @@
}
// Register locations.
- static Location RegisterLocation(Register reg, Representation rep = kTagged) {
- uword payload =
- RegisterField::encode(reg) |
- RepresentationField::encode(rep);
- return Location(kRegister, payload);
+ static Location RegisterLocation(Register reg) {
+ return Location(kRegister, reg);
}
bool IsRegister() const {
@@ -188,19 +192,12 @@
Register reg() const {
ASSERT(IsRegister());
- return RegisterField::decode(payload());
- }
-
-
- Representation representation() const {
- return RepresentationField::decode(payload());
+ return static_cast<Register>(payload());
}
// FpuRegister locations.
- static Location FpuRegisterLocation(FpuRegister reg, Representation rep) {
- uword payload =
- FpuRegisterField::encode(reg) | RepresentationField::encode(rep);
- return Location(kFpuRegister, payload);
+ static Location FpuRegisterLocation(FpuRegister reg) {
+ return Location(kFpuRegister, reg);
}
bool IsFpuRegister() const {
@@ -209,7 +206,7 @@
FpuRegister fpu_reg() const {
ASSERT(IsFpuRegister());
- return FpuRegisterField::decode(payload());
+ return static_cast<FpuRegister>(payload());
}
static bool IsMachineRegisterKind(Kind kind) {
@@ -217,13 +214,12 @@
}
static Location MachineRegisterLocation(Kind kind,
- intptr_t reg,
- Representation rep) {
+ intptr_t reg) {
if (kind == kRegister) {
return RegisterLocation(static_cast<Register>(reg));
} else {
ASSERT(kind == kFpuRegister);
- return FpuRegisterLocation(static_cast<FpuRegister>(reg), rep);
+ return FpuRegisterLocation(static_cast<FpuRegister>(reg));
}
}
@@ -233,22 +229,18 @@
intptr_t register_code() const {
ASSERT(IsMachineRegister());
- return static_cast<intptr_t>(RegisterField::decode(payload()));
+ return static_cast<intptr_t>(payload());
}
- static uword make_stack_index_payload(intptr_t stack_index,
- Representation rep) {
+ static uword EncodeStackIndex(intptr_t stack_index) {
ASSERT((-kStackIndexBias <= stack_index) &&
- (stack_index < kStackIndexBias));
- uword payload =
- IndexField::encode(static_cast<uword>(kStackIndexBias + stack_index));
- return payload | RepresentationField::encode(rep);
+ (stack_index < kStackIndexBias));
+ return static_cast<uword>(kStackIndexBias + stack_index);
}
// Spill slots.
- static Location StackSlot(intptr_t stack_index,
- Representation rep = kTagged) {
- uword payload = make_stack_index_payload(stack_index, rep);
+ static Location StackSlot(intptr_t stack_index) {
+ uword payload = EncodeStackIndex(stack_index);
Location loc(kStackSlot, payload);
// Ensure that sign is preserved.
ASSERT(loc.stack_index() == stack_index);
@@ -259,8 +251,8 @@
return kind() == kStackSlot;
}
- static Location DoubleStackSlot(intptr_t stack_index, Representation rep) {
- uword payload = make_stack_index_payload(stack_index, rep);
+ static Location DoubleStackSlot(intptr_t stack_index) {
+ uword payload = EncodeStackIndex(stack_index);
Location loc(kDoubleStackSlot, payload);
// Ensure that sign is preserved.
ASSERT(loc.stack_index() == stack_index);
@@ -271,36 +263,22 @@
return kind() == kDoubleStackSlot;
}
- static Location Float32x4StackSlot(intptr_t stack_index) {
- uword payload = make_stack_index_payload(stack_index, kUnboxedFloat32x4);
- Location loc(kFloat32x4StackSlot, payload);
+ static Location QuadStackSlot(intptr_t stack_index) {
+ uword payload = EncodeStackIndex(stack_index);
+ Location loc(kQuadStackSlot, payload);
// Ensure that sign is preserved.
ASSERT(loc.stack_index() == stack_index);
return loc;
}
- bool IsFloat32x4StackSlot() const {
- return kind() == kFloat32x4StackSlot;
+ bool IsQuadStackSlot() const {
+ return kind() == kQuadStackSlot;
}
- static Location Uint32x4StackSlot(intptr_t stack_index) {
- uword payload = make_stack_index_payload(stack_index, kUnboxedUint32x4);
- Location loc(kUint32x4StackSlot, payload);
- // Ensure that sign is preserved.
- ASSERT(loc.stack_index() == stack_index);
- return loc;
- }
-
- bool IsUint32x4StackSlot() const {
- return kind() == kUint32x4StackSlot;
- }
-
-
intptr_t stack_index() const {
- ASSERT(IsStackSlot() || IsDoubleStackSlot() || IsFloat32x4StackSlot() ||
- IsUint32x4StackSlot());
+ ASSERT(IsStackSlot() || IsDoubleStackSlot() || IsQuadStackSlot());
// Decode stack index manually to preserve sign.
- return IndexField::decode(payload()) - kStackIndexBias;
+ return payload() - kStackIndexBias;
}
// Return a memory operand for stack slot locations.
@@ -344,30 +322,9 @@
// Layout for kUnallocated locations payload.
typedef BitField<Policy, 0, 3> PolicyField;
- // Layout for register locations payload.
- static const intptr_t kBitsForRepresentation = 3;
- COMPILE_ASSERT(kNumRepresentations <= (1 << kBitsForRepresentation),
- invalid_enum);
- static const intptr_t kBitsForRegister =
- kBitsForPayload - kBitsForRepresentation;
- typedef BitField<Representation,
- 0,
- kBitsForRepresentation> RepresentationField;
- typedef BitField<Register,
- kBitsForRepresentation,
- kBitsForRegister> RegisterField;
- typedef BitField<FpuRegister,
- kBitsForRepresentation,
- kBitsForRegister> FpuRegisterField;
-
// Layout for stack slots.
- static const intptr_t kBitsForIndex =
- kBitsForPayload - kBitsForRepresentation;
- typedef BitField<uword,
- kBitsForRepresentation,
- kBitsForIndex> IndexField;
static const intptr_t kStackIndexBias =
- static_cast<intptr_t>(1) << (kBitsForIndex - 1);
+ static_cast<intptr_t>(1) << (kBitsForPayload - 1);
// Location either contains kind and payload fields or a tagged handle for
// a constant locations. Values of enumeration Kind are selected in such a
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 45a0147..ded68b8 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -194,7 +194,11 @@
intptr_t dot_pos = len; // Position of '.' in the name.
bool is_setter = false;
- for (int i = 0; i < name.Length(); i++) {
+ if (name.Equals(Symbols::TopLevel())) {
+ // Name of invisible top-level class.
+ return Symbols::Empty().raw();
+ }
+ for (int i = start; i < name.Length(); i++) {
if (name.CharAt(i) == ':') {
ASSERT(start == 0);
if (name.CharAt(0) == 's') {
@@ -910,6 +914,19 @@
object_store->set_uint32x4_class(cls);
RegisterPrivateClass(cls, Symbols::_Uint32x4(), lib);
+ cls = Class::New<Instance>(Symbols::Float32x4(), script,
+ Scanner::kDummyTokenIndex);
+ RegisterClass(cls, Symbols::Float32x4(), lib);
+ pending_classes.Add(cls, Heap::kOld);
+ type = Type::NewNonParameterizedType(cls);
+ object_store->set_float32x4_type(type);
+
+ cls = Class::New<Instance>(Symbols::Uint32x4(), script,
+ Scanner::kDummyTokenIndex);
+ pending_classes.Add(cls, Heap::kOld);
+ type = Type::NewNonParameterizedType(cls);
+ object_store->set_uint32x4_type(type);
+
object_store->set_typeddata_classes(typeddata_classes);
// Set the super type of class Stacktrace to Object type so that the
@@ -6923,8 +6940,7 @@
const char* PcDescriptors::KindAsStr(intptr_t index) const {
switch (DescriptorKind(index)) {
- case PcDescriptors::kDeoptBefore: return "deopt-before ";
- case PcDescriptors::kDeoptAfter: return "deopt-after ";
+ case PcDescriptors::kDeopt: return "deopt ";
case PcDescriptors::kEntryPatch: return "entry-patch ";
case PcDescriptors::kPatchCode: return "patch ";
case PcDescriptors::kLazyDeoptJump: return "lazy-deopt ";
@@ -7005,10 +7021,19 @@
PcDescriptors::Kind kind = DescriptorKind(i);
// 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind.
intptr_t deopt_id = Isolate::kNoDeoptId;
- if ((DescriptorKind(i) == PcDescriptors::kDeoptBefore) ||
- (DescriptorKind(i) == PcDescriptors::kIcCall)) {
- deopt_id = DeoptId(i);
+ if ((DescriptorKind(i) != PcDescriptors::kDeopt) ||
+ (DescriptorKind(i) != PcDescriptors::kIcCall)) {
+ continue;
}
+
+ deopt_id = DeoptId(i);
+ if (Isolate::IsDeoptAfter(deopt_id)) {
+ // TODO(vegorov): some instructions contain multiple calls and have
+ // multiple "after" targets recorded. Right now it is benign but might
+ // lead to issues in the future. Fix that and enable verification.
+ continue;
+ }
+
for (intptr_t k = i + 1; k < Length(); k++) {
if (kind == DescriptorKind(k)) {
if (deopt_id != Isolate::kNoDeoptId) {
@@ -7750,18 +7775,6 @@
}
-uword Code::GetDeoptBeforePcAtDeoptId(intptr_t deopt_id) const {
- ASSERT(!is_optimized());
- return GetPcForDeoptId(deopt_id, PcDescriptors::kDeoptBefore);
-}
-
-
-uword Code::GetDeoptAfterPcAtDeoptId(intptr_t deopt_id) const {
- ASSERT(!is_optimized());
- return GetPcForDeoptId(deopt_id, PcDescriptors::kDeoptAfter);
-}
-
-
const char* Code::ToCString() const {
const char* kFormat = "Code entry:%p";
intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1;
@@ -9242,6 +9255,18 @@
}
+bool AbstractType::IsFloat32x4Type() const {
+ return HasResolvedTypeClass() &&
+ (type_class() == Type::Handle(Type::Float32x4()).type_class());
+}
+
+
+bool AbstractType::IsUint32x4Type() const {
+ return HasResolvedTypeClass() &&
+ (type_class() == Type::Handle(Type::Uint32x4()).type_class());
+}
+
+
bool AbstractType::IsNumberType() const {
return HasResolvedTypeClass() &&
(type_class() == Type::Handle(Type::Number()).type_class());
@@ -9390,6 +9415,16 @@
}
+RawType* Type::Float32x4() {
+ return Isolate::Current()->object_store()->float32x4_type();
+}
+
+
+RawType* Type::Uint32x4() {
+ return Isolate::Current()->object_store()->uint32x4_type();
+}
+
+
RawType* Type::Number() {
return Isolate::Current()->object_store()->number_type();
}
@@ -10607,29 +10642,9 @@
}
-static bool IsWhiteSpace(char ch) {
- return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t';
-}
-
-
-static bool StringToDouble(const String& str, double* double_value) {
- ASSERT(double_value != NULL);
- // TODO(regis): For now, we use strtod to convert a string to double.
- const char* nptr = str.ToCString();
- char* endptr = NULL;
- *double_value = strtod(nptr, &endptr);
- // We do not treat overflow or underflow as an error and therefore do not
- // check errno for ERANGE.
- if (!IsWhiteSpace(*endptr)) {
- return false;
- }
- return true;
-}
-
-
RawDouble* Double::New(const String& str, Heap::Space space) {
double double_value;
- if (!StringToDouble(str, &double_value)) {
+ if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) {
return Double::Handle().raw();
}
return New(double_value, space);
@@ -10666,7 +10681,7 @@
RawDouble* Double::NewCanonical(const String& str) {
double double_value;
- if (!StringToDouble(str, &double_value)) {
+ if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) {
return Double::Handle().raw();
}
return NewCanonical(double_value);
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index 6d73f43..5473069 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -2393,8 +2393,7 @@
public:
enum Kind {
- kDeoptBefore = 0, // Deoptimization continuation point before instruction.
- kDeoptAfter, // Deoptimization continuation point after instruction.
+ kDeopt, // Deoptimization continuation point.
kEntryPatch, // Location where to patch entry.
kPatchCode, // Buffer for patching code entry.
kLazyDeoptJump, // Lazy deoptimization trampoline.
@@ -2810,9 +2809,6 @@
uword GetPatchCodePc() const;
uword GetLazyDeoptPc() const;
- uword GetDeoptBeforePcAtDeoptId(intptr_t deopt_id) const;
- uword GetDeoptAfterPcAtDeoptId(intptr_t deopt_id) const;
-
uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const;
// Returns true if there is an object in the code between 'start_offset'
@@ -3510,6 +3506,12 @@
// Check if this type represents the 'double' type.
bool IsDoubleType() const;
+ // Check if this type represents the 'Float32x4' type.
+ bool IsFloat32x4Type() const;
+
+ // Check if this type represents the 'Uint32x4' type.
+ bool IsUint32x4Type() const;
+
// Check if this type represents the 'num' type.
bool IsNumberType() const;
@@ -3622,6 +3624,12 @@
// The 'double' type.
static RawType* Double();
+ // The 'Float32x4' type.
+ static RawType* Float32x4();
+
+ // The 'Uint32x4' type.
+ static RawType* Uint32x4();
+
// The 'num' type.
static RawType* Number();
diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h
index fde7670..5ceabd5 100644
--- a/runtime/vm/object_store.h
+++ b/runtime/vm/object_store.h
@@ -181,6 +181,9 @@
float32x4_class_ = value.raw();
}
+ RawType* float32x4_type() const { return float32x4_type_; }
+ void set_float32x4_type(const Type& value) { float32x4_type_ = value.raw(); }
+
RawClass* uint32x4_class() const {
return uint32x4_class_;
}
@@ -188,6 +191,9 @@
uint32x4_class_ = value.raw();
}
+ RawType* uint32x4_type() const { return uint32x4_type_; }
+ void set_uint32x4_type(const Type& value) { uint32x4_type_ = value.raw(); }
+
RawArray* typeddata_classes() const {
return typeddata_classes_;
}
@@ -442,6 +448,8 @@
RawClass* bigint_class_;
RawClass* double_class_;
RawType* double_type_;
+ RawType* float32x4_type_;
+ RawType* uint32x4_type_;
RawType* string_type_;
RawClass* one_byte_string_class_;
RawClass* two_byte_string_class_;
diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc
index 44d6e61..df54b52 100644
--- a/runtime/vm/object_test.cc
+++ b/runtime/vm/object_test.cc
@@ -2360,7 +2360,7 @@
PcDescriptors& descriptors = PcDescriptors::Handle();
descriptors ^= PcDescriptors::New(kNumEntries);
descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1);
- descriptors.AddDescriptor(1, 20, PcDescriptors::kDeoptBefore, 2, 30, 0);
+ descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0);
descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1);
descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2);
descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3);
@@ -2384,7 +2384,7 @@
EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5));
EXPECT_EQ(150, pc_descs.TokenPos(5));
EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0));
- EXPECT_EQ(PcDescriptors::kDeoptBefore, pc_descs.DescriptorKind(1));
+ EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1));
}
diff --git a/runtime/vm/os_android.cc b/runtime/vm/os_android.cc
index 0bf5d36..6b19878 100644
--- a/runtime/vm/os_android.cc
+++ b/runtime/vm/os_android.cc
@@ -22,6 +22,7 @@
#include "vm/dart.h"
#include "vm/debuginfo.h"
#include "vm/isolate.h"
+#include "vm/vtune.h"
#include "vm/zone.h"
@@ -381,7 +382,7 @@
CodeObservers::Register(new PprofCodeObserver);
}
#if defined(DART_VTUNE_SUPPORT)
- Register(new VTuneCodeObserver);
+ CodeObservers::Register(new VTuneCodeObserver);
#endif
}
diff --git a/runtime/vm/os_linux.cc b/runtime/vm/os_linux.cc
index ab50b27..cf113b6 100644
--- a/runtime/vm/os_linux.cc
+++ b/runtime/vm/os_linux.cc
@@ -21,6 +21,7 @@
#include "vm/dart.h"
#include "vm/debuginfo.h"
#include "vm/isolate.h"
+#include "vm/vtune.h"
#include "vm/zone.h"
@@ -477,7 +478,7 @@
CodeObservers::Register(new PprofCodeObserver);
}
#if defined(DART_VTUNE_SUPPORT)
- Register(new VTuneCodeObserver);
+ CodeObservers::Register(new VTuneCodeObserver);
#endif
}
diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc
index 7fa1b8c..2e1a398 100644
--- a/runtime/vm/os_win.cc
+++ b/runtime/vm/os_win.cc
@@ -6,6 +6,7 @@
#if defined(TARGET_OS_WINDOWS)
#include "vm/os.h"
+#include "vm/vtune.h"
#include <malloc.h> // NOLINT
#include <time.h> // NOLINT
@@ -254,7 +255,7 @@
void OS::RegisterCodeObservers() {
#if defined(DART_VTUNE_SUPPORT)
- Register(new VTuneCodeObserver);
+ CodeObservers::Register(new VTuneCodeObserver);
#endif
}
diff --git a/runtime/vm/pages.cc b/runtime/vm/pages.cc
index fdca884..1f06422 100644
--- a/runtime/vm/pages.cc
+++ b/runtime/vm/pages.cc
@@ -132,7 +132,7 @@
intptr_t PageSpace::LargePageSizeFor(intptr_t size) {
- intptr_t page_size = Utils::RoundUp(size + sizeof(HeapPage),
+ intptr_t page_size = Utils::RoundUp(size + HeapPage::ObjectStartOffset(),
VirtualMemory::PageSize());
return page_size;
}
diff --git a/runtime/vm/pages.h b/runtime/vm/pages.h
index f3e67a3..f89b083 100644
--- a/runtime/vm/pages.h
+++ b/runtime/vm/pages.h
@@ -35,8 +35,7 @@
}
uword object_start() const {
- return (reinterpret_cast<uword>(this) +
- Utils::RoundUp(sizeof(HeapPage), kObjectAlignment));
+ return (reinterpret_cast<uword>(this) + ObjectStartOffset());
}
uword object_end() const {
return object_end_;
@@ -59,6 +58,10 @@
void WriteProtect(bool read_only);
+ static intptr_t ObjectStartOffset() {
+ return Utils::RoundUp(sizeof(HeapPage), OS::kMaxPreferredCodeAlignment);
+ }
+
private:
void set_object_end(uword val) {
ASSERT((val & kObjectAlignmentMask) == kOldObjectAlignmentOffset);
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index fa258c4..83dcbcf 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -3071,14 +3071,19 @@
ErrorMsg(member.name_pos, "factory name must be '%s'",
members->class_name().ToCString());
}
+ // Do not bypass class resolution by using current_class() directly, since
+ // it may be a patch class.
const Object& result_type_class = Object::Handle(
UnresolvedClass::New(LibraryPrefix::Handle(),
*member.name,
member.name_pos));
- // The type arguments of the result type are set during finalization.
- member.type = &Type::ZoneHandle(Type::New(result_type_class,
- TypeArguments::Handle(),
- member.name_pos));
+ // The type arguments of the result type are the type parameters of the
+ // current class. Note that in the case of a patch class, they are copied
+ // from the class being patched.
+ member.type = &Type::ZoneHandle(Type::New(
+ result_type_class,
+ TypeArguments::Handle(current_class().type_parameters()),
+ member.name_pos));
} else if (member.has_static) {
ErrorMsg(member.name_pos, "constructor cannot be static");
}
@@ -3235,10 +3240,11 @@
// Preserve and reuse the original type parameters and bounds since the
// ones defined in the patch class will not be finalized.
orig_type_parameters = cls.type_parameters();
- String& patch = String::Handle(
- String::Concat(Symbols::PatchSpace(), class_name));
- patch = Symbols::New(patch);
- cls = Class::New(patch, script_, classname_pos);
+ // A patch class must be given the same name as the class it is patching,
+ // otherwise the generic signature classes it defines will not match the
+ // patched generic signature classes. Therefore, new signature classes
+ // will be introduced and the original ones will not get finalized.
+ cls = Class::New(class_name, script_, classname_pos);
cls.set_library(library_);
} else {
// Not patching a class, but it has been found. This must be one of the
@@ -3301,6 +3307,11 @@
class_name.ToCString(),
String::Handle(super_type.UserVisibleName()).ToCString());
}
+ if (super_type.IsDynamicType()) {
+ ErrorMsg(type_pos,
+ "class '%s' may not extend 'dynamic'",
+ class_name.ToCString());
+ }
if (CurrentToken() == Token::kWITH) {
super_type = ParseMixins(super_type);
}
@@ -3842,6 +3853,9 @@
"type parameter '%s' may not be used in interface list",
String::Handle(interface.UserVisibleName()).ToCString());
}
+ if (interface.IsDynamicType()) {
+ ErrorMsg(interface_pos, "'dynamic' may not be used in interface list");
+ }
all_interfaces.Add(interface);
} while (CurrentToken() == Token::kCOMMA);
cls_interfaces = Array::MakeArray(all_interfaces);
diff --git a/runtime/vm/resolver_test.cc b/runtime/vm/resolver_test.cc
index 5ce8ebb..2f253ba 100644
--- a/runtime/vm/resolver_test.cc
+++ b/runtime/vm/resolver_test.cc
@@ -14,11 +14,6 @@
namespace dart {
-// Compiler only implemented on IA32, X64, and ARM.
-#if defined(TARGET_ARCH_IA32) || \
- defined(TARGET_ARCH_X64) || \
- defined(TARGET_ARCH_ARM)
-
// Setup function for invocation.
static void SetupFunction(const char* test_library_name,
const char* test_class_name,
@@ -221,6 +216,4 @@
}
}
-#endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM
-
} // namespace dart
diff --git a/runtime/vm/simulator_mips.cc b/runtime/vm/simulator_mips.cc
index 41a1f4d..c868443 100644
--- a/runtime/vm/simulator_mips.cc
+++ b/runtime/vm/simulator_mips.cc
@@ -832,6 +832,8 @@
reinterpret_cast<intptr_t>(instr) - Instr::kInstrSize);
set_pc(get_pc() + Instr::kInstrSize);
dbg.Stop(instr, message);
+ // Adjust for extra pc increment.
+ set_pc(get_pc() - Instr::kInstrSize);
} else if (instr->BreakCodeField() == Instr::kRedirectCode) {
SimulatorSetjmpBuffer buffer(this);
@@ -914,6 +916,8 @@
} else {
SimulatorDebugger dbg(this);
dbg.Stop(instr, "breakpoint");
+ // Adjust for extra pc increment.
+ set_pc(get_pc() - Instr::kInstrSize);
}
}
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 6dbff55..d7ba30d 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -980,6 +980,10 @@
return;
}
+ if (RawObject::IsTypedDataViewClassId(class_id)) {
+ WriteInstanceRef(raw, cls);
+ return;
+ }
// Object is being referenced, add it to the forward ref list and mark
// it so that future references to this object in the snapshot will use
// this object id. Mark it as not having been serialized yet so that we
@@ -1014,15 +1018,6 @@
return;
}
#undef SNAPSHOT_WRITE
-#define SNAPSHOT_WRITE(clazz) \
- case kTypedData##clazz##ViewCid: \
-
- CLASS_LIST_TYPED_DATA(SNAPSHOT_WRITE)
- case kByteDataViewCid: {
- WriteInstanceRef(raw, cls);
- return;
- }
-#undef SNAPSHOT_WRITE
default: break;
}
UNREACHABLE();
@@ -1088,6 +1083,7 @@
value = SerializedHeaderTag::update(kObjectId, value);
value = SerializedHeaderData::update(object_id, value);
uword tags = raw->ptr()->tags_;
+ ASSERT(SerializedHeaderTag::decode(tags) != kObjectId);
raw->ptr()->tags_ = value;
ForwardObjectNode* node = new ForwardObjectNode(raw, tags, state);
ASSERT(node != NULL);
diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc
index 08b2ab8..41c9461 100644
--- a/runtime/vm/snapshot_test.cc
+++ b/runtime/vm/snapshot_test.cc
@@ -917,6 +917,11 @@
" static const int smi_sfld = 10;\n"
" static const int bigint_sfld = 0xfffffffffff;\n"
"}\n"
+ "class Expect {\n"
+ " static void equals(x, y) {\n"
+ " if (x != y) throw new RuntimeError('not equal');\n"
+ " }\n"
+ "}\n"
"class FieldsTest {\n"
" static Fields testMain() {\n"
" Expect.equals(true, Fields.bigint_sfld == 0xfffffffffff);\n"
@@ -1115,7 +1120,7 @@
EXPECT_VALID(Api::CheckIsolateState(Isolate::Current()));
// Get list of library URLs loaded and save the count.
- Dart_Handle libs = Dart_GetLibraryURLs();
+ Dart_Handle libs = Dart_GetLibraryIds();
EXPECT(Dart_IsList(libs));
Dart_ListLength(libs, &expected_num_libs);
@@ -1140,7 +1145,7 @@
EXPECT_VALID(result);
// Get list of library URLs loaded and compare with expected count.
- Dart_Handle libs = Dart_GetLibraryURLs();
+ Dart_Handle libs = Dart_GetLibraryIds();
EXPECT(Dart_IsList(libs));
Dart_ListLength(libs, &actual_num_libs);
@@ -1795,12 +1800,21 @@
" for (var i = 0; i < kArrayLength; i++) list[i] = d;\n"
" return list;\n"
"}\n"
- "getByteArrayList() {\n"
+ "getTypedDataList() {\n"
" var byte_array = new Uint8List(256);\n"
" var list = new List(kArrayLength);\n"
" for (var i = 0; i < kArrayLength; i++) list[i] = byte_array;\n"
" return list;\n"
"}\n"
+ "getTypedDataViewList() {\n"
+ " var uint8_list = new Uint8List(256);\n"
+ " uint8_list[64] = 1;\n"
+ " var uint8_list_view =\n"
+ " new Uint8List.view(uint8_list.buffer, 64, 128);\n"
+ " var list = new List(kArrayLength);\n"
+ " for (var i = 0; i < kArrayLength; i++) list[i] = uint8_list_view;\n"
+ " return list;\n"
+ "}\n"
"getMixedList() {\n"
" var list = new List(kArrayLength);\n"
" for (var i = 0; i < kArrayLength; i++) {\n"
@@ -1885,9 +1899,9 @@
}
}
{
- // Generate a list of doubles from Dart code.
+ // Generate a list of Uint8Lists from Dart code.
ApiNativeScope scope;
- Dart_CObject* root = GetDeserializedDartMessage(lib, "getByteArrayList");
+ Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList");
EXPECT_NOTNULL(root);
EXPECT_EQ(Dart_CObject::kArray, root->type);
EXPECT_EQ(kArrayLength, root->value.as_array.length);
@@ -1899,6 +1913,23 @@
}
}
{
+ // Generate a list of Uint8List views from Dart code.
+ ApiNativeScope scope;
+ Dart_CObject* root =
+ GetDeserializedDartMessage(lib, "getTypedDataViewList");
+ EXPECT_NOTNULL(root);
+ EXPECT_EQ(Dart_CObject::kArray, root->type);
+ EXPECT_EQ(kArrayLength, root->value.as_array.length);
+ for (int i = 0; i < kArrayLength; i++) {
+ Dart_CObject* element = root->value.as_array.values[i];
+ EXPECT_EQ(root->value.as_array.values[0], element);
+ EXPECT_EQ(Dart_CObject::kUint8Array, element->type);
+ EXPECT_EQ(128, element->value.as_byte_array.length);
+ EXPECT_EQ(1, element->value.as_byte_array.values[0]);
+ EXPECT_EQ(0, element->value.as_byte_array.values[1]);
+ }
+ }
+ {
// Generate a list of objects of different types from Dart code.
ApiNativeScope scope;
Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList");
@@ -1968,7 +1999,7 @@
" list.add(3.14);;\n"
" return list;\n"
"}\n"
- "getByteArrayList() {\n"
+ "getTypedDataList() {\n"
" var byte_array = new Uint8List(256);\n"
" var list = [];\n"
" for (var i = 0; i < kArrayLength; i++) {\n"
@@ -1976,6 +2007,17 @@
" }\n"
" return list;\n"
"}\n"
+ "getTypedDataViewList() {\n"
+ " var uint8_list = new Uint8List(256);\n"
+ " uint8_list[64] = 1;\n"
+ " var uint8_list_view =\n"
+ " new Uint8List.view(uint8_list.buffer, 64, 128);\n"
+ " var list = [];\n"
+ " for (var i = 0; i < kArrayLength; i++) {\n"
+ " list.add(uint8_list_view);\n"
+ " }\n"
+ " return list;\n"
+ "}\n"
"getMixedList() {\n"
" var list = [];\n"
" for (var i = 0; i < kArrayLength; i++) {\n"
@@ -2001,7 +2043,6 @@
{
DARTSCOPE(isolate);
-
{
// Generate a list of strings from Dart code.
ApiNativeScope scope;
@@ -2060,9 +2101,9 @@
}
}
{
- // Generate a list of doubles from Dart code.
+ // Generate a list of Uint8Lists from Dart code.
ApiNativeScope scope;
- Dart_CObject* root = GetDeserializedDartMessage(lib, "getByteArrayList");
+ Dart_CObject* root = GetDeserializedDartMessage(lib, "getTypedDataList");
EXPECT_NOTNULL(root);
EXPECT_EQ(Dart_CObject::kArray, root->type);
EXPECT_EQ(kArrayLength, root->value.as_array.length);
@@ -2074,6 +2115,23 @@
}
}
{
+ // Generate a list of Uint8List views from Dart code.
+ ApiNativeScope scope;
+ Dart_CObject* root =
+ GetDeserializedDartMessage(lib, "getTypedDataViewList");
+ EXPECT_NOTNULL(root);
+ EXPECT_EQ(Dart_CObject::kArray, root->type);
+ EXPECT_EQ(kArrayLength, root->value.as_array.length);
+ for (int i = 0; i < kArrayLength; i++) {
+ Dart_CObject* element = root->value.as_array.values[i];
+ EXPECT_EQ(root->value.as_array.values[0], element);
+ EXPECT_EQ(Dart_CObject::kUint8Array, element->type);
+ EXPECT_EQ(128, element->value.as_byte_array.length);
+ EXPECT_EQ(1, element->value.as_byte_array.values[0]);
+ EXPECT_EQ(0, element->value.as_byte_array.values[1]);
+ }
+ }
+ {
// Generate a list of objects of different types from Dart code.
ApiNativeScope scope;
Dart_CObject* root = GetDeserializedDartMessage(lib, "getMixedList");
diff --git a/runtime/vm/snapshot_test.dart b/runtime/vm/snapshot_test.dart
index 50ed111..f9c2336 100644
--- a/runtime/vm/snapshot_test.dart
+++ b/runtime/vm/snapshot_test.dart
@@ -5,6 +5,12 @@
import 'dart:isolate';
import 'dart:async';
+class Expect {
+ static void equals(x, y) {
+ if (x != y) throw new RuntimeError('not equal');
+ }
+}
+
class Fields {
Fields(int i, int j) : fld1 = i, fld2 = j, fld5 = true {}
int fld1;
diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc
index 47a72d2..3ae8d33 100644
--- a/runtime/vm/stack_frame.cc
+++ b/runtime/vm/stack_frame.cc
@@ -332,11 +332,8 @@
ASSERT(deopt_instructions_.length() != 0);
while (index_ < deopt_instructions_.length()) {
DeoptInstr* deopt_instr = deopt_instructions_[index_++];
- ASSERT(deopt_instr->kind() != DeoptInstr::kRetBeforeAddress);
- if (deopt_instr->kind() == DeoptInstr::kRetAfterAddress) {
- pc_ = DeoptInstr::GetRetAfterAddress(deopt_instr,
- object_table_,
- &func);
+ if (deopt_instr->kind() == DeoptInstr::kRetAddress) {
+ pc_ = DeoptInstr::GetRetAddress(deopt_instr, object_table_, &func);
code_ = func.unoptimized_code();
function_ = func.raw();
return;
diff --git a/runtime/vm/stack_frame_mips.cc b/runtime/vm/stack_frame_mips.cc
index a4a94f2..032197d6 100644
--- a/runtime/vm/stack_frame_mips.cc
+++ b/runtime/vm/stack_frame_mips.cc
@@ -9,6 +9,9 @@
namespace dart {
+// The constant kExitLinkOffsetInEntryFrame must be kept in sync with the
+// code in the InvokeDartCode stub.
+static const int kExitLinkOffsetInEntryFrame = -10 * kWordSize;
static const int kPcAddressOffsetFromSp = -2 * kWordSize;
static const int kEntrypointMarkerOffsetFromFp = 2 * kWordSize;
static const int kSpOffsetFromPreviousFp = 3 * kWordSize;
@@ -54,7 +57,10 @@
void StackFrameIterator::SetupNextExitFrameData() {
- UNIMPLEMENTED();
+ uword exit_address = entry_.fp() + kExitLinkOffsetInEntryFrame;
+ uword exit_marker = *reinterpret_cast<uword*>(exit_address);
+ frames_.fp_ = exit_marker;
+ frames_.sp_ = 0;
}
} // namespace dart
diff --git a/runtime/vm/stub_code_arm.cc b/runtime/vm/stub_code_arm.cc
index 4be2161..0bf4538 100644
--- a/runtime/vm/stub_code_arm.cc
+++ b/runtime/vm/stub_code_arm.cc
@@ -356,8 +356,52 @@
}
+DECLARE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, Isolate* isolate);
+
+// Helper stub to implement Assembler::StoreIntoObject.
+// Input parameters:
+// R0: Address (i.e. object) being stored into.
void StubCode::GenerateUpdateStoreBufferStub(Assembler* assembler) {
- __ Unimplemented("UpdateStoreBuffer stub");
+ // Save values being destroyed.
+ __ PushList((1 << R1) | (1 << R2) | (1 << R3));
+
+ // Load the isolate out of the context.
+ // Spilled: R1, R2, R3.
+ // R0: Address being stored.
+ __ ldr(R1, FieldAddress(CTX, Context::isolate_offset()));
+
+ // Load top_ out of the StoreBufferBlock and add the address to the pointers_.
+ // R1: Isolate.
+ intptr_t store_buffer_offset = Isolate::store_buffer_block_offset();
+ __ LoadFromOffset(kLoadWord, R2, R1,
+ store_buffer_offset + StoreBufferBlock::top_offset());
+ __ add(R3, R1, ShifterOperand(R2, LSL, 2));
+ __ StoreToOffset(kStoreWord, R0, R3,
+ store_buffer_offset + StoreBufferBlock::pointers_offset());
+
+ // Increment top_ and check for overflow.
+ // R2: top_
+ // R1: Isolate
+ Label L;
+ __ add(R2, R2, ShifterOperand(1));
+ __ StoreToOffset(kStoreWord, R2, R1,
+ store_buffer_offset + StoreBufferBlock::top_offset());
+ __ CompareImmediate(R2, StoreBufferBlock::kSize);
+ // Restore values.
+ __ PopList((1 << R1) | (1 << R2) | (1 << R3));
+ __ b(&L, EQ);
+ __ Ret();
+
+ // Handle overflow: Call the runtime leaf function.
+ __ Bind(&L);
+ // Setup frame, push callee-saved registers.
+
+ __ EnterCallRuntimeFrame(0 * kWordSize);
+ __ ldr(R0, FieldAddress(CTX, Context::isolate_offset()));
+ __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry);
+ // Restore callee-saved registers, tear down frame.
+ __ LeaveCallRuntimeFrame();
+ __ Ret();
}
@@ -720,7 +764,7 @@
// Instance in R0, return its class-id in R0 as Smi.
__ Bind(&get_class_id_as_smi);
- Label not_smi;
+
// Test if Smi -> load Smi class for comparison.
__ tst(R0, ShifterOperand(kSmiTagMask));
__ mov(R0, ShifterOperand(Smi::RawValue(kSmiCid)), EQ);
diff --git a/runtime/vm/stub_code_mips.cc b/runtime/vm/stub_code_mips.cc
index 01e9876..a56f2d9 100644
--- a/runtime/vm/stub_code_mips.cc
+++ b/runtime/vm/stub_code_mips.cc
@@ -8,6 +8,7 @@
#include "vm/assembler.h"
#include "vm/code_generator.h"
#include "vm/dart_entry.h"
+#include "vm/flow_graph_compiler.h"
#include "vm/instructions.h"
#include "vm/stack_frame.h"
#include "vm/stub_code.h"
@@ -16,6 +17,13 @@
namespace dart {
+DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
+DEFINE_FLAG(bool, use_slow_path, false,
+ "Set to true for debugging & verifying the slow paths.");
+DECLARE_FLAG(int, optimization_counter_threshold);
+DECLARE_FLAG(bool, trace_optimized_ic_calls);
+
+
// Input parameters:
// RA : return address.
// SP : address of last argument in argument array.
@@ -90,8 +98,8 @@
__ mov(SP, FP);
__ lw(RA, Address(SP, 1 * kWordSize));
__ lw(FP, Address(SP, 0 * kWordSize));
- __ addiu(SP, SP, Immediate(2 * kWordSize));
__ Ret();
+ __ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize));
}
@@ -167,8 +175,7 @@
__ jalr(T5);
// Reset exit frame information in Isolate structure.
- __ LoadImmediate(A2, 0);
- __ sw(A2, Address(CTX, Isolate::top_exit_frame_info_offset()));
+ __ sw(ZR, Address(CTX, Isolate::top_exit_frame_info_offset()));
// Load Context pointer from Isolate structure into R2.
__ lw(A2, Address(CTX, Isolate::top_context_offset()));
@@ -183,8 +190,8 @@
__ mov(SP, FP);
__ lw(RA, Address(SP, 1 * kWordSize));
__ lw(FP, Address(SP, 0 * kWordSize));
- __ addiu(SP, SP, Immediate(2 * kWordSize));
__ Ret();
+ __ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize));
}
@@ -193,25 +200,25 @@
void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) {
__ EnterStubFrame();
// Setup space on stack for return value and preserve arguments descriptor.
- __ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null()));
+ __ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null()));
__ addiu(SP, SP, Immediate(-2 * kWordSize));
__ sw(S4, Address(SP, 1 * kWordSize));
- __ sw(V0, Address(SP, 0 * kWordSize));
+ __ sw(T0, Address(SP, 0 * kWordSize));
__ CallRuntime(kPatchStaticCallRuntimeEntry);
// Get Code object result and restore arguments descriptor array.
- __ lw(V0, Address(SP, 0 * kWordSize));
+ __ lw(T0, Address(SP, 0 * kWordSize));
__ lw(S4, Address(SP, 1 * kWordSize));
__ addiu(SP, SP, Immediate(2 * kWordSize));
// Remove the stub frame as we are about to jump to the dart function.
__ LeaveStubFrame();
- __ lw(V0, FieldAddress(V0, Code::instructions_offset()));
- __ addiu(V0, V0, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
- __ jr(V0);
+ __ lw(T0, FieldAddress(T0, Code::instructions_offset()));
+ __ AddImmediate(T0, Instructions::HeaderSize() - kHeapObjectTag);
+ __ jr(T0);
}
@@ -284,23 +291,22 @@
// Load Isolate pointer from Context structure into temporary register R8.
__ lw(T2, FieldAddress(CTX, Context::isolate_offset()));
- // Save the top exit frame info. Use R5 as a temporary register.
+ // Save the top exit frame info. Use T0 as a temporary register.
// StackFrameIterator reads the top exit frame info saved in this frame.
- __ lw(S5, Address(T2, Isolate::top_exit_frame_info_offset()));
- __ LoadImmediate(T0, 0);
- __ sw(T0, Address(T2, Isolate::top_exit_frame_info_offset()));
+ __ lw(T0, Address(T2, Isolate::top_exit_frame_info_offset()));
+ __ sw(ZR, Address(T2, Isolate::top_exit_frame_info_offset()));
- // Save the old Context pointer. Use S4 as a temporary register.
+ // Save the old Context pointer. Use T1 as a temporary register.
// Note that VisitObjectPointers will find this saved Context pointer during
// GC marking, since it traverses any information between SP and
// FP - kExitLinkOffsetInEntryFrame.
// EntryFrame::SavedContext reads the context saved in this frame.
- __ lw(S4, Address(T2, Isolate::top_context_offset()));
+ __ lw(T1, Address(T2, Isolate::top_context_offset()));
// The constants kSavedContextOffsetInEntryFrame and
// kExitLinkOffsetInEntryFrame must be kept in sync with the code below.
- __ sw(S5, Address(SP, 1 * kWordSize));
- __ sw(S4, Address(SP, 0 * kWordSize));
+ __ sw(T0, Address(SP, 1 * kWordSize));
+ __ sw(T1, Address(SP, 0 * kWordSize));
// after the call, The stack pointer is restored to this location.
// Pushed A3, S0-7, S4, S5 = 11.
@@ -310,26 +316,24 @@
__ lw(S4, Address(A1, VMHandles::kOffsetOfRawPtrInHandle));
// Load number of arguments into S5.
- __ lw(S5, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
- __ SmiUntag(S5);
+ __ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
+ __ SmiUntag(T1);
// Compute address of 'arguments array' data area into A2.
__ lw(A2, Address(A2, VMHandles::kOffsetOfRawPtrInHandle));
- __ addiu(A2, A2, Immediate(Array::data_offset() - kHeapObjectTag));
+ __ AddImmediate(A2, Array::data_offset() - kHeapObjectTag);
// Set up arguments for the Dart call.
Label push_arguments;
Label done_push_arguments;
-
- __ beq(S5, ZR, &done_push_arguments); // check if there are arguments.
- __ LoadImmediate(A1, 0);
+ __ beq(T1, ZR, &done_push_arguments); // check if there are arguments.
+ __ mov(A1, ZR);
__ Bind(&push_arguments);
__ lw(A3, Address(A2));
__ Push(A3);
- __ addiu(A2, A2, Immediate(kWordSize));
__ addiu(A1, A1, Immediate(1));
- __ subu(T0, A1, S5);
- __ bltz(T0, &push_arguments);
+ __ BranchLess(A1, T1, &push_arguments);
+ __ delay_slot()->addiu(A2, A2, Immediate(kWordSize));
__ Bind(&done_push_arguments);
@@ -341,19 +345,19 @@
__ lw(CTX, Address(CTX, VMHandles::kOffsetOfRawPtrInHandle));
// Get rid of arguments pushed on the stack.
- __ addiu(SP, FP, Immediate(kSavedContextOffsetInEntryFrame));
+ __ AddImmediate(SP, FP, kSavedContextOffsetInEntryFrame);
// Load Isolate pointer from Context structure into CTX. Drop Context.
__ lw(CTX, FieldAddress(CTX, Context::isolate_offset()));
// Restore the saved Context pointer into the Isolate structure.
- // Uses S4 as a temporary register for this.
+ // Uses T1 as a temporary register for this.
// Restore the saved top exit frame info back into the Isolate structure.
- // Uses S5 as a temporary register for this.
- __ lw(S4, Address(SP, 0 * kWordSize));
- __ lw(S5, Address(SP, 1 * kWordSize));
- __ sw(S4, Address(CTX, Isolate::top_context_offset()));
- __ sw(S5, Address(CTX, Isolate::top_exit_frame_info_offset()));
+ // Uses T0 as a temporary register for this.
+ __ lw(T1, Address(SP, 0 * kWordSize));
+ __ lw(T0, Address(SP, 1 * kWordSize));
+ __ sw(T1, Address(CTX, Isolate::top_context_offset()));
+ __ sw(T0, Address(CTX, Isolate::top_exit_frame_info_offset()));
// Restore C++ ABI callee-saved registers.
for (int i = S0; i <= S7; i++) {
@@ -379,9 +383,174 @@
}
+// Called for inline allocation of objects.
+// Input parameters:
+// RA : return address.
+// SP + 4 : type arguments object (only if class is parameterized).
+// SP + 0 : type arguments of instantiator (only if class is parameterized).
void StubCode::GenerateAllocationStubForClass(Assembler* assembler,
const Class& cls) {
- __ Unimplemented("AllocateObject stub");
+ // The generated code is different if the class is parameterized.
+ const bool is_cls_parameterized =
+ cls.type_arguments_field_offset() != Class::kNoTypeArguments;
+ // kInlineInstanceSize is a constant used as a threshold for determining
+ // when the object initialization should be done as a loop or as
+ // straight line code.
+ const int kInlineInstanceSize = 12;
+ const intptr_t instance_size = cls.instance_size();
+ ASSERT(instance_size > 0);
+ const intptr_t type_args_size = InstantiatedTypeArguments::InstanceSize();
+ if (FLAG_inline_alloc &&
+ PageSpace::IsPageAllocatableSize(instance_size + type_args_size)) {
+ Label slow_case;
+ Heap* heap = Isolate::Current()->heap();
+ __ LoadImmediate(T5, heap->TopAddress());
+ __ lw(T2, Address(T5));
+ __ LoadImmediate(T4, instance_size);
+ __ addu(T3, T2, T4);
+ if (is_cls_parameterized) {
+ Label no_instantiator;
+ __ lw(T1, Address(SP, 1 * kWordSize));
+ __ lw(T0, Address(SP, 0 * kWordSize));
+ // A new InstantiatedTypeArguments object only needs to be allocated if
+ // the instantiator is provided (not kNoInstantiator, but may be null).
+ __ BranchEqual(T0, Smi::RawValue(StubCode::kNoInstantiator),
+ &no_instantiator);
+ __ delay_slot()->mov(T4, T3);
+ __ AddImmediate(T3, type_args_size);
+ __ Bind(&no_instantiator);
+ // T4: potential new object end and, if T4 != T3, potential new
+ // InstantiatedTypeArguments object start.
+ }
+ // Check if the allocation fits into the remaining space.
+ // T2: potential new object start.
+ // T3: potential next object start.
+ if (FLAG_use_slow_path) {
+ __ b(&slow_case);
+ } else {
+ __ BranchGreaterEqual(T3, heap->EndAddress(), &slow_case);
+ }
+
+ // Successfully allocated the object(s), now update top to point to
+ // next object start and initialize the object.
+ __ sw(T3, Address(T5));
+
+ if (is_cls_parameterized) {
+ // Initialize the type arguments field in the object.
+ // T2: new object start.
+ // T4: potential new object end and, if T4 != T3, potential new
+ // InstantiatedTypeArguments object start.
+ // T3: next object start.
+ Label type_arguments_ready;
+ __ beq(T4, T3, &type_arguments_ready);
+ // Initialize InstantiatedTypeArguments object at T4.
+ __ sw(T1, Address(T4,
+ InstantiatedTypeArguments::uninstantiated_type_arguments_offset()));
+ __ sw(T0, Address(T4,
+ InstantiatedTypeArguments::instantiator_type_arguments_offset()));
+ const Class& ita_cls =
+ Class::ZoneHandle(Object::instantiated_type_arguments_class());
+ // Set the tags.
+ uword tags = 0;
+ tags = RawObject::SizeTag::update(type_args_size, tags);
+ tags = RawObject::ClassIdTag::update(ita_cls.id(), tags);
+ __ LoadImmediate(T0, tags);
+ __ sw(T0, Address(T4, Instance::tags_offset()));
+ // Set the new InstantiatedTypeArguments object (T4) as the type
+ // arguments (T1) of the new object (T2).
+ __ addiu(T1, T4, Immediate(kHeapObjectTag));
+ // Set T3 to new object end.
+ __ mov(T3, T4);
+ __ Bind(&type_arguments_ready);
+ // T2: new object.
+ // T1: new object type arguments.
+ }
+
+ // T2: new object start.
+ // T3: next object start.
+ // T1: new object type arguments (if is_cls_parameterized).
+ // Set the tags.
+ uword tags = 0;
+ tags = RawObject::SizeTag::update(instance_size, tags);
+ ASSERT(cls.id() != kIllegalCid);
+ tags = RawObject::ClassIdTag::update(cls.id(), tags);
+ __ LoadImmediate(T0, tags);
+ __ sw(T0, Address(T2, Instance::tags_offset()));
+
+ // Initialize the remaining words of the object.
+ __ LoadImmediate(T0, reinterpret_cast<intptr_t>(Object::null()));
+
+ // T0: raw null.
+ // T2: new object start.
+ // T3: next object start.
+ // T1: new object type arguments (if is_cls_parameterized).
+ // First try inlining the initialization without a loop.
+ if (instance_size < (kInlineInstanceSize * kWordSize)) {
+ // Check if the object contains any non-header fields.
+ // Small objects are initialized using a consecutive set of writes.
+ for (intptr_t current_offset = sizeof(RawObject);
+ current_offset < instance_size;
+ current_offset += kWordSize) {
+ __ sw(T0, Address(T2, current_offset));
+ }
+ } else {
+ __ addiu(T4, T2, Immediate(sizeof(RawObject)));
+ // Loop until the whole object is initialized.
+ // T0: raw null.
+ // T2: new object.
+ // T3: next object start.
+ // T4: next word to be initialized.
+ // T1: new object type arguments (if is_cls_parameterized).
+ Label init_loop;
+ Label done;
+ __ Bind(&init_loop);
+ __ BranchGreaterEqual(T4, T3, &done); // Done if T4 >= T3.
+ __ sw(T0, Address(T4));
+ __ AddImmediate(T4, kWordSize);
+ __ b(&init_loop);
+ __ Bind(&done);
+ }
+ if (is_cls_parameterized) {
+ // R1: new object type arguments.
+ // Set the type arguments in the new object.
+ __ sw(T1, Address(T2, cls.type_arguments_field_offset()));
+ }
+ // Done allocating and initializing the instance.
+ // R2: new object still missing its heap tag.
+ __ Ret();
+ __ delay_slot()->addiu(V0, T2, Immediate(kHeapObjectTag));
+
+ __ Bind(&slow_case);
+ }
+ if (is_cls_parameterized) {
+ __ lw(T1, Address(SP, 1 * kWordSize));
+ __ lw(T0, Address(SP, 0 * kWordSize));
+ }
+ // Create a stub frame as we are pushing some objects on the stack before
+ // calling into the runtime.
+ __ EnterStubFrame(true); // Uses pool pointer to pass cls to runtime.
+ __ LoadImmediate(T2, reinterpret_cast<intptr_t>(Object::null()));
+ __ Push(T2); // Setup space on stack for return value.
+ __ PushObject(cls); // Push class of object to be allocated.
+ if (is_cls_parameterized) {
+ // Push type arguments of object to be allocated and of instantiator.
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(T1, Address(SP, 1 * kWordSize));
+ __ sw(T0, Address(SP, 0 * kWordSize));
+ } else {
+ // Push null type arguments and kNoInstantiator.
+ __ LoadImmediate(T1, Smi::RawValue(StubCode::kNoInstantiator));
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(T2, Address(SP, 1 * kWordSize));
+ __ sw(T1, Address(SP, 0 * kWordSize));
+ }
+ __ CallRuntime(kAllocateObjectRuntimeEntry); // Allocate object.
+ __ Drop(3); // Pop arguments.
+ __ Pop(V0); // Pop result (newly allocated object).
+ // V0: new object
+ // Restore the frame pointer.
+ __ LeaveStubFrame(true);
+ __ Ret();
}
@@ -401,30 +570,242 @@
}
+// Loads function into 'temp_reg'.
void StubCode::GenerateUsageCounterIncrement(Assembler* assembler,
Register temp_reg) {
- __ Unimplemented("UsageCounterIncrement stub");
+ Register ic_reg = S5;
+ Register func_reg = temp_reg;
+ ASSERT(temp_reg == T0);
+ __ lw(func_reg, FieldAddress(ic_reg, ICData::function_offset()));
+ __ lw(T1, FieldAddress(func_reg, Function::usage_counter_offset()));
+ Label is_hot;
+ if (FlowGraphCompiler::CanOptimize()) {
+ ASSERT(FLAG_optimization_counter_threshold > 1);
+ // The usage_counter is always less than FLAG_optimization_counter_threshold
+ // except when the function gets optimized.
+ __ BranchEqual(T1, FLAG_optimization_counter_threshold, &is_hot);
+ // As long as VM has no OSR do not optimize in the middle of the function
+ // but only at exit so that we have collected all type feedback before
+ // optimizing.
+ }
+ __ addiu(T1, T1, Immediate(1));
+ __ sw(T1, FieldAddress(func_reg, Function::usage_counter_offset()));
+ __ Bind(&is_hot);
}
+// Generate inline cache check for 'num_args'.
+// AR: return address
+// S5: Inline cache data object.
+// S4: Arguments descriptor array.
+// Control flow:
+// - If receiver is null -> jump to IC miss.
+// - If receiver is Smi -> load Smi class.
+// - If receiver is not-Smi -> load receiver's class.
+// - Check if 'num_args' (including receiver) match any IC data group.
+// - Match found -> jump to target.
+// - Match not found -> jump to IC miss.
void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler,
intptr_t num_args) {
- __ Unimplemented("NArgsCheckInlineCache stub");
+ ASSERT(num_args > 0);
+#if defined(DEBUG)
+ { Label ok;
+ // Check that the IC data array has NumberOfArgumentsChecked() == num_args.
+ // 'num_args_tested' is stored as an untagged int.
+ __ lw(T0, FieldAddress(S5, ICData::num_args_tested_offset()));
+ __ BranchEqual(T0, num_args, &ok);
+ __ Stop("Incorrect stub for IC data");
+ __ Bind(&ok);
+ }
+#endif // DEBUG
+
+ // Preserve return address, since LR is needed for subroutine call.
+ __ mov(T2, RA);
+ // Loop that checks if there is an IC data match.
+ Label loop, update, test, found, get_class_id_as_smi;
+ // S5: IC data object (preserved).
+ __ lw(T0, FieldAddress(S5, ICData::ic_data_offset()));
+ // T0: ic_data_array with check entries: classes and target functions.
+ __ AddImmediate(T0, Array::data_offset() - kHeapObjectTag);
+ // T0: points directly to the first ic data array element.
+
+ // Get the receiver's class ID (first read number of arguments from
+ // arguments descriptor array and then access the receiver from the stack).
+ __ lw(T1, FieldAddress(S4, ArgumentsDescriptor::count_offset()));
+ __ AddImmediate(T1, -Smi::RawValue(1));
+ __ sll(T3, T1, 1); // T1 (argument_count - 1) is smi.
+ __ addu(T3, T3, SP);
+ __ bal(&get_class_id_as_smi);
+ __ delay_slot()->lw(T3, Address(T3));
+ // T1: argument_count - 1 (smi).
+ // T3: receiver's class ID (smi).
+ __ b(&test);
+ __ delay_slot()->lw(T4, Address(T0)); // First class id (smi) to check.
+
+ __ Bind(&loop);
+ for (int i = 0; i < num_args; i++) {
+ if (i > 0) {
+ // If not the first, load the next argument's class ID.
+ __ LoadImmediate(T3, Smi::RawValue(-i));
+ __ addu(T3, T1, T3);
+ __ sll(T3, T3, 1);
+ __ addu(T3, SP, T3);
+ __ bal(&get_class_id_as_smi);
+ __ delay_slot()->lw(T3, Address(T3));
+ // T3: next argument class ID (smi).
+ __ lw(T4, Address(T0, i * kWordSize));
+ // T4: next class ID to check (smi).
+ }
+ if (i < (num_args - 1)) {
+ __ bne(T3, T4, &update); // Continue.
+ } else {
+ // Last check, all checks before matched.
+ Label skip;
+ __ bne(T3, T4, &skip);
+ __ b(&found); // Break.
+ __ delay_slot()->mov(RA, T2); // Restore return address if found.
+ __ Bind(&skip);
+ }
+ }
+ __ Bind(&update);
+ // Reload receiver class ID. It has not been destroyed when num_args == 1.
+ if (num_args > 1) {
+ __ sll(T3, T1, 1);
+ __ addu(T3, SP, T3);
+ __ bal(&get_class_id_as_smi);
+ __ delay_slot()->lw(T3, Address(T3));
+ }
+
+ const intptr_t entry_size = ICData::TestEntryLengthFor(num_args) * kWordSize;
+ __ AddImmediate(T0, entry_size); // Next entry.
+ __ lw(T4, Address(T0)); // Next class ID.
+
+ __ Bind(&test);
+ __ BranchNotEqual(T4, Smi::RawValue(kIllegalCid), &loop); // Done?
+
+ // IC miss.
+ // Restore return address.
+ __ mov(RA, T2);
+
+ // Compute address of arguments (first read number of arguments from
+ // arguments descriptor array and then compute address on the stack).
+ // T1: argument_count - 1 (smi).
+ __ sll(T1, T1, 1);
+ __ addu(T1, SP, T1); // T1 is Smi.
+ // T1: address of receiver.
+ // Create a stub frame as we are pushing some objects on the stack before
+ // calling into the runtime.
+ __ EnterStubFrame();
+ __ LoadImmediate(T3, reinterpret_cast<intptr_t>(Object::null()));
+ // Preserve IC data object and arguments descriptor array and
+ // setup space on stack for result (target code object).
+ __ addiu(SP, SP, Immediate(-3 * kWordSize));
+ __ sw(S5, Address(SP, 2 * kWordSize));
+ __ sw(S4, Address(SP, 1 * kWordSize));
+ __ sw(T3, Address(SP, 0 * kWordSize));
+ // Push call arguments.
+ for (intptr_t i = 0; i < num_args; i++) {
+ __ lw(TMP, Address(T1, -i * kWordSize));
+ __ Push(TMP);
+ }
+ // Pass IC data object and arguments descriptor array.
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(S5, Address(SP, 1 * kWordSize));
+ __ sw(S4, Address(SP, 0 * kWordSize));
+
+ if (num_args == 1) {
+ __ CallRuntime(kInlineCacheMissHandlerOneArgRuntimeEntry);
+ } else if (num_args == 2) {
+ __ CallRuntime(kInlineCacheMissHandlerTwoArgsRuntimeEntry);
+ } else if (num_args == 3) {
+ __ CallRuntime(kInlineCacheMissHandlerThreeArgsRuntimeEntry);
+ } else {
+ UNIMPLEMENTED();
+ }
+ // Remove the call arguments pushed earlier, including the IC data object
+ // and the arguments descriptor array.
+ __ Drop(num_args + 2);
+ // Pop returned code object into T3 (null if not found).
+ // Restore arguments descriptor array and IC data array.
+ __ lw(T3, Address(SP, 0 * kWordSize));
+ __ lw(S4, Address(SP, 1 * kWordSize));
+ __ lw(S5, Address(SP, 2 * kWordSize));
+ __ addiu(SP, SP, Immediate(3 * kWordSize));
+ __ LeaveStubFrame();
+ Label call_target_function;
+ __ BranchNotEqual(T3, reinterpret_cast<intptr_t>(Object::null()),
+ &call_target_function);
+ // NoSuchMethod or closure.
+ // Mark IC call that it may be a closure call that does not collect
+ // type feedback.
+ __ LoadImmediate(TMP2, 1);
+ __ Branch(&StubCode::InstanceFunctionLookupLabel());
+ __ delay_slot()->sb(TMP2, FieldAddress(S5, ICData::is_closure_call_offset()));
+
+ __ Bind(&found);
+ // T0: Pointer to an IC data check group.
+ const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize;
+ const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize;
+ __ lw(T3, Address(T0, target_offset));
+ __ lw(T4, Address(T0, count_offset));
+
+ __ AddImmediateDetectOverflow(T4, T4, Smi::RawValue(1), T5);
+
+ __ bgez(T5, &call_target_function); // No overflow.
+ __ delay_slot()->sw(T4, Address(T0, count_offset));
+
+ __ LoadImmediate(T1, Smi::RawValue(Smi::kMaxValue));
+ __ sw(T1, Address(T0, count_offset));
+
+ __ Bind(&call_target_function);
+ // T0: Target function.
+ __ lw(T3, FieldAddress(T3, Function::code_offset()));
+ __ lw(T3, FieldAddress(T3, Code::instructions_offset()));
+ __ AddImmediate(T3, Instructions::HeaderSize() - kHeapObjectTag);
+ __ jr(T3);
+
+ // Instance in T3, return its class-id in T3 as Smi.
+ __ Bind(&get_class_id_as_smi);
+ Label not_smi;
+ // Test if Smi -> load Smi class for comparison.
+ __ andi(TMP1, T3, Immediate(kSmiTagMask));
+ __ bne(TMP1, ZR, ¬_smi);
+ __ LoadImmediate(T3, Smi::RawValue(kSmiCid));
+ __ jr(RA);
+
+ __ Bind(¬_smi);
+ __ LoadClassId(T3, T3);
+ __ SmiTag(T3);
+ __ jr(RA);
}
+// Use inline cache data array to invoke the target or continue in inline
+// cache miss handler. Stub for 1-argument check (receiver class).
+// RA: Return address.
+// S5: Inline cache data object.
+// S4: Arguments descriptor array.
+// Inline cache data object structure:
+// 0: function-name
+// 1: N, number of arguments checked.
+// 2 .. (length - 1): group of checks, each check containing:
+// - N classes.
+// - 1 target function.
void StubCode::GenerateOneArgCheckInlineCacheStub(Assembler* assembler) {
- __ Unimplemented("GenerateOneArgCheckInlineCacheStub stub");
+ GenerateUsageCounterIncrement(assembler, T0);
+ GenerateNArgsCheckInlineCacheStub(assembler, 1);
}
void StubCode::GenerateTwoArgsCheckInlineCacheStub(Assembler* assembler) {
- __ Unimplemented("GenerateTwoArgsCheckInlineCacheStub stub");
+ GenerateUsageCounterIncrement(assembler, T0);
+ GenerateNArgsCheckInlineCacheStub(assembler, 2);
}
void StubCode::GenerateThreeArgsCheckInlineCacheStub(Assembler* assembler) {
- __ Unimplemented("GenerateThreeArgsCheckInlineCacheStub stub");
+ GenerateUsageCounterIncrement(assembler, T0);
+ GenerateNArgsCheckInlineCacheStub(assembler, 3);
}
@@ -474,18 +855,106 @@
}
+// Used to check class and type arguments. Arguments passed in registers:
+// RA: return address.
+// A0: instance (must be preserved).
+// A1: instantiator type arguments or NULL.
+// A2: cache array.
+// Result in V0: null -> not found, otherwise result (true or false).
+static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) {
+ ASSERT((1 <= n) && (n <= 3));
+ if (n > 1) {
+ // Get instance type arguments.
+ __ LoadClass(T0, A0);
+ // Compute instance type arguments into R4.
+ Label has_no_type_arguments;
+ __ LoadImmediate(T1, reinterpret_cast<intptr_t>(Object::null()));
+ __ lw(T2, FieldAddress(T0,
+ Class::type_arguments_field_offset_in_words_offset()));
+ __ BranchEqual(T2, Class::kNoTypeArguments, &has_no_type_arguments);
+ __ sll(T2, T2, 2);
+ __ addu(T2, A0, T2); // T2 <- A0 + T2 * 4
+ __ lw(T1, FieldAddress(T2, 0));
+ __ Bind(&has_no_type_arguments);
+ }
+ __ LoadClassId(T0, A0);
+ // A0: instance.
+ // A1: instantiator type arguments or NULL.
+ // A2: SubtypeTestCache.
+ // T0: instance class id.
+ // T1: instance type arguments (null if none), used only if n > 1.
+ __ lw(T2, FieldAddress(A2, SubtypeTestCache::cache_offset()));
+ __ AddImmediate(T2, Array::data_offset() - kHeapObjectTag);
+
+ Label loop, found, not_found, next_iteration;
+ // T0: instance class id.
+ // T1: instance type arguments.
+ // T2: Entry start.
+ __ SmiTag(T0);
+ __ Bind(&loop);
+ __ lw(T3, Address(T2, kWordSize * SubtypeTestCache::kInstanceClassId));
+ __ BranchEqual(T3, reinterpret_cast<intptr_t>(Object::null()), ¬_found);
+
+ if (n == 1) {
+ __ BranchEqual(T3, T0, &found);
+ } else {
+ __ BranchNotEqual(T3, T0, &next_iteration);
+ __ lw(T3,
+ Address(T2, kWordSize * SubtypeTestCache::kInstanceTypeArguments));
+ if (n == 2) {
+ __ BranchEqual(T3, T1, &found);
+ } else {
+ __ BranchNotEqual(T3, T1, &next_iteration);
+ __ lw(T3, Address(T2, kWordSize *
+ SubtypeTestCache::kInstantiatorTypeArguments));
+ __ BranchEqual(T3, A1, &found);
+ }
+ }
+ __ Bind(&next_iteration);
+ __ AddImmediate(T2, kWordSize * SubtypeTestCache::kTestEntryLength);
+ __ b(&loop);
+ // Fall through to not found.
+ __ Bind(¬_found);
+ __ LoadImmediate(V0, reinterpret_cast<intptr_t>(Object::null()));
+ __ Ret();
+
+ __ Bind(&found);
+ __ Ret();
+ __ delay_slot()->lw(V0,
+ Address(T2, kWordSize * SubtypeTestCache::kTestResult));
+}
+
+
+// Used to check class and type arguments. Arguments passed in registers:
+// RA: return address.
+// A0: instance (must be preserved).
+// A1: instantiator type arguments or NULL.
+// A2: cache array.
+// Result in V0: null -> not found, otherwise result (true or false).
void StubCode::GenerateSubtype1TestCacheStub(Assembler* assembler) {
- __ Unimplemented("Subtype1TestCache Stub");
+ GenerateSubtypeNTestCacheStub(assembler, 1);
}
+// Used to check class and type arguments. Arguments passed in registers:
+// LR: return address.
+// A0: instance (must be preserved).
+// A1: instantiator type arguments or NULL.
+// A2: cache array.
+// Result in V0: null -> not found, otherwise result (true or false).
void StubCode::GenerateSubtype2TestCacheStub(Assembler* assembler) {
- __ Unimplemented("Subtype2TestCache Stub");
+ GenerateSubtypeNTestCacheStub(assembler, 2);
}
+// Used to check class and type arguments. Arguments passed in registers:
+// RA: return address.
+// A0: instance (must be preserved).
+// A1: instantiator type arguments or NULL.
+// A2: cache array.
+// Result in V0: null -> not found, otherwise result (true or false).
void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) {
- __ Unimplemented("Subtype3TestCache Stub");
+ GenerateSubtypeNTestCacheStub(assembler, 3);
}
@@ -511,17 +980,113 @@
void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) {
- __ Unimplemented("EqualityWithNullArg stub");
+ __ Unimplemented("EqualityWithNullArg Stub");
}
void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) {
- __ Unimplemented("OptimizeFunction stub");
+ __ Unimplemented("OptimizeFunction Stub");
}
+DECLARE_LEAF_RUNTIME_ENTRY(intptr_t,
+ BigintCompare,
+ RawBigint* left,
+ RawBigint* right);
+
+
+// Does identical check (object references are equal or not equal) with special
+// checks for boxed numbers.
+// LR: return address.
+// SP + 4: left operand.
+// SP + 0: right operand.
+// Return: CMPRES is zero if equal, non-zero otherwise.
+// Note: A Mint cannot contain a value that would fit in Smi, a Bigint
+// cannot contain a value that fits in Mint or Smi.
void StubCode::GenerateIdenticalWithNumberCheckStub(Assembler* assembler) {
- __ Unimplemented("IdenticalWithNumberCheck stub");
+ const Register ret = CMPRES;
+ const Register temp1 = TMP1;
+ const Register temp2 = TMP2;
+ const Register left = T1;
+ const Register right = T0;
+ // Preserve left, right and temp.
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(T1, Address(SP, 1 * kWordSize));
+ __ sw(T0, Address(SP, 0 * kWordSize));
+ // TOS + 4: left argument.
+ // TOS + 3: right argument.
+ // TOS + 1: saved left
+ // TOS + 0: saved right
+ __ lw(left, Address(SP, 3 * kWordSize));
+ __ lw(right, Address(SP, 2 * kWordSize));
+ Label reference_compare, done, check_mint, check_bigint;
+ // If any of the arguments is Smi do reference compare.
+ __ andi(temp1, left, Immediate(kSmiTagMask));
+ __ beq(temp1, ZR, &reference_compare);
+ __ andi(temp1, right, Immediate(kSmiTagMask));
+ __ beq(temp1, ZR, &reference_compare);
+
+ // Value compare for two doubles.
+ __ LoadImmediate(temp1, kDoubleCid);
+ __ LoadClassId(temp2, left);
+ __ bne(temp1, temp2, &check_mint);
+ __ LoadClassId(temp2, right);
+ __ subu(ret, temp1, temp2);
+ __ bne(ret, ZR, &done);
+
+ // Double values bitwise compare.
+ __ lw(temp1, FieldAddress(left, Double::value_offset() + 0 * kWordSize));
+ __ lw(temp1, FieldAddress(right, Double::value_offset() + 0 * kWordSize));
+ __ subu(ret, temp1, temp2);
+ __ bne(ret, ZR, &done);
+ __ lw(temp1, FieldAddress(left, Double::value_offset() + 1 * kWordSize));
+ __ lw(temp2, FieldAddress(right, Double::value_offset() + 1 * kWordSize));
+ __ b(&done);
+ __ delay_slot()->subu(ret, temp1, temp2);
+
+ __ Bind(&check_mint);
+ __ LoadImmediate(temp1, kMintCid);
+ __ LoadClassId(temp2, left);
+ __ bne(temp1, temp2, &check_bigint);
+ __ LoadClassId(temp2, right);
+ __ subu(ret, temp1, temp2);
+ __ bne(ret, ZR, &done);
+
+ __ lw(temp1, FieldAddress(left, Mint::value_offset() + 0 * kWordSize));
+ __ lw(temp2, FieldAddress(right, Mint::value_offset() + 0 * kWordSize));
+ __ subu(ret, temp1, temp2);
+ __ bne(ret, ZR, &done);
+ __ lw(temp1, FieldAddress(left, Mint::value_offset() + 1 * kWordSize));
+ __ lw(temp2, FieldAddress(right, Mint::value_offset() + 1 * kWordSize));
+ __ b(&done);
+ __ delay_slot()->subu(ret, temp1, temp2);
+
+ __ Bind(&check_bigint);
+ __ LoadImmediate(temp1, kBigintCid);
+ __ LoadClassId(temp2, left);
+ __ bne(temp1, temp2, &reference_compare);
+ __ LoadClassId(temp2, right);
+ __ subu(ret, temp1, temp2);
+ __ bne(ret, ZR, &done);
+
+ __ EnterStubFrame(0);
+ __ ReserveAlignedFrameSpace(2 * kWordSize);
+ __ addiu(SP, SP, Immediate(-2 * kWordSize));
+ __ sw(T1, Address(SP, 1 * kWordSize));
+ __ sw(T0, Address(SP, 0 * kWordSize));
+ __ CallRuntime(kBigintCompareRuntimeEntry);
+ // Result in V0, 0 means equal.
+ __ LeaveStubFrame();
+ __ b(&done);
+ __ delay_slot()->mov(CMPRES, V0);
+
+ __ Bind(&reference_compare);
+ __ subu(ret, left, right);
+ __ Bind(&done);
+ __ lw(T0, Address(SP, 0 * kWordSize));
+ __ lw(T1, Address(SP, 1 * kWordSize));
+ __ Ret();
+ __ delay_slot()->addiu(SP, SP, Immediate(2 * kWordSize));
}
} // namespace dart
diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h
index a3d62b9..5cf2f00 100644
--- a/runtime/vm/symbols.h
+++ b/runtime/vm/symbols.h
@@ -221,7 +221,6 @@
V(ColonSpace, ": ") \
V(RParenArrow, ") => ") \
V(SpaceExtendsSpace, " extends ") \
- V(PatchSpace, "patch ") \
V(SwitchExpr, ":switch_expr") \
V(TwoNewlines, "\n\n") \
V(TwoSpaces, " ") \
diff --git a/runtime/vm/unit_test.h b/runtime/vm/unit_test.h
index 392b69b..2749149 100644
--- a/runtime/vm/unit_test.h
+++ b/runtime/vm/unit_test.h
@@ -145,26 +145,29 @@
#else
// Not running on ARM or MIPS hardware, call simulator to execute code.
#define EXECUTE_TEST_CODE_INT32(name, entry) \
- static_cast<int32_t>(Simulator::Current()->Call((int32_t)entry, \
- 0, 0, 0, 0))
+ static_cast<int32_t>(Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(entry), 0, 0, 0, 0))
#define EXECUTE_TEST_CODE_INT64_LL(name, entry, long_arg0, long_arg1) \
- static_cast<int64_t>(Simulator::Current()->Call((int32_t)entry, \
+ static_cast<int64_t>(Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(entry), \
Utils::Low32Bits(long_arg0), \
Utils::High32Bits(long_arg0), \
Utils::Low32Bits(long_arg1), \
Utils::High32Bits(long_arg1)))
#define EXECUTE_TEST_CODE_FLOAT(name, entry) \
- bit_cast<float, int32_t>(Simulator::Current()->Call((int32_t)entry, \
- 0, 0, 0, 0))
+ bit_cast<float, int32_t>(Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(entry), 0, 0, 0, 0))
#define EXECUTE_TEST_CODE_DOUBLE(name, entry) \
- bit_cast<double, int64_t>(Simulator::Current()->Call((int32_t)entry, \
- 0, 0, 0, 0))
+ bit_cast<double, int64_t>(Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(entry), 0, 0, 0, 0))
#define EXECUTE_TEST_CODE_INT32_F(name, entry, float_arg) \
- static_cast<int32_t>(Simulator::Current()->Call((int32_t)entry, \
+ static_cast<int32_t>(Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(entry), \
bit_cast<int32_t, float>(float_arg), \
0, 0, 0))
#define EXECUTE_TEST_CODE_INT32_D(name, entry, double_arg) \
- static_cast<int32_t>(Simulator::Current()->Call((int32_t)entry, \
+ static_cast<int32_t>(Simulator::Current()->Call( \
+ bit_cast<int32_t, uword>(entry), \
Utils::Low32Bits(bit_cast<int64_t, double>(double_arg)), \
Utils::High32Bits(bit_cast<int64_t, double>(double_arg)), \
0, 0))
diff --git a/sdk/bin/dart2js b/sdk/bin/dart2js
index 9e70d6f..96354ca 100755
--- a/sdk/bin/dart2js
+++ b/sdk/bin/dart2js
@@ -23,7 +23,8 @@
DART="$BIN_DIR/dart"
-SNAPSHOT="${DART2JS}.snapshot"
+SNAPSHOT_DIR="$BIN_DIR/snapshots"
+SNAPSHOT="$SNAPSHOT_DIR/utils_wrapper.dart.snapshot"
unset EXTRA_OPTIONS
declare -a EXTRA_OPTIONS
@@ -42,6 +43,8 @@
if test -f "$SNAPSHOT"; then
# TODO(ahe): Remove the following line when we are relatively sure it works.
echo Using snapshot "$SNAPSHOT" 1>&2
+
+ EXTRA_OPTIONS[${#EXTRA_OPTIONS[@]}]="--library-root=$SDK_DIR"
fi
# Tell the VM to grow the heap more aggressively. This should only
@@ -57,7 +60,8 @@
esac
if test -f "$SNAPSHOT"; then
- exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "${EXTRA_OPTIONS[@]}" "$@"
+ exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$SNAPSHOT" "dart2js" \
+ "${EXTRA_OPTIONS[@]}" "$@"
else
exec "$DART" "${EXTRA_VM_OPTIONS[@]}" "$DART2JS" "${EXTRA_OPTIONS[@]}" "$@"
fi
diff --git a/sdk/bin/dart2js.bat b/sdk/bin/dart2js.bat
index 97bf774..be0219f 100644
--- a/sdk/bin/dart2js.bat
+++ b/sdk/bin/dart2js.bat
@@ -14,9 +14,12 @@
rem Get absolute full name for SDK_DIR.
for %%i in ("%BIN_DIR%\..\") do set SDK_DIR=%%~fi
-set DART2JS=%SDK_DIR%lib\_internal\compiler\implementation\dart2js.dart
+rem Remove trailing backslash if there is one
+IF %SDK_DIR:~-1%==\ set SDK_DIR=%SDK_DIR:~0,-1%
+
+set DART2JS=%SDK_DIR%\lib\_internal\compiler\implementation\dart2js.dart
set DART=%BIN_DIR%\dart
-set SNAPSHOT=%DART2JS%.snapshot
+set SNAPSHOT=%BIN_DIR%\snapshots\utils_wrapper.dart.snapshot
set EXTRA_OPTIONS=
set EXTRA_VM_OPTIONS=
@@ -27,13 +30,18 @@
if exist "%SNAPSHOT%" (
echo Using snapshot "%SNAPSHOT%" >&2
- set DART2JS=%SNAPSHOT%
+ set EXTRA_OPTIONS=%EXTRA_OPTIONS% "--library-root=%SDK_DIR%"
)
rem See comments regarding options below in dart2js shell script.
set EXTRA_VM_OPTIONS=%EXTRA_VM_OPTIONS% --heap_growth_rate=512
-"%DART%" %EXTRA_VM_OPTIONS% "%DART2JS%" %EXTRA_OPTIONS% %*
+if exist "%SNAPSHOT%" (
+ "%DART%" %EXTRA_VM_OPTIONS% "%SNAPSHOT%" "dart2js" %EXTRA_OPTIONS% %*
+) else (
+ "%DART%" %EXTRA_VM_OPTIONS% "%DART2JS%" %EXTRA_OPTIONS% %*
+)
+
endlocal
exit /b %errorlevel%
diff --git a/sdk/bin/analyzer b/sdk/bin/dartanalyzer_developer
similarity index 85%
rename from sdk/bin/analyzer
rename to sdk/bin/dartanalyzer_developer
index 0281b61..b522f56 100755
--- a/sdk/bin/analyzer
+++ b/sdk/bin/dartanalyzer_developer
@@ -31,11 +31,11 @@
if [[ `uname` == 'Darwin' ]];
then
- JAR_DIR="$CUR_DIR"/../../xcodebuild/$DART_CONFIGURATION/new_analyzer
+ JAR_DIR="$CUR_DIR"/../../xcodebuild/$DART_CONFIGURATION/dartanalyzer
else
- JAR_DIR="$CUR_DIR"/../../out/$DART_CONFIGURATION/new_analyzer
+ JAR_DIR="$CUR_DIR"/../../out/$DART_CONFIGURATION/dartanalyzer
fi
-JAR_FILE="$JAR_DIR/new_analyzer.jar"
+JAR_FILE="$JAR_DIR/dartanalyzer.jar"
exec java -jar $JAR_FILE --dart-sdk "$SDK_DIR" "$@"
diff --git a/sdk/bin/analyzer.bat b/sdk/bin/dartanalyzer_developer.bat
similarity index 88%
rename from sdk/bin/analyzer.bat
rename to sdk/bin/dartanalyzer_developer.bat
index 21daf3e..6ba62e0 100644
--- a/sdk/bin/analyzer.bat
+++ b/sdk/bin/dartanalyzer_developer.bat
@@ -20,8 +20,8 @@
set "SDK_DIR=%SCRIPTPATH%\..\..\build\%DART_CONFIGURATION%\dart-sdk"
-set "JAR_DIR=%SCRIPTPATH%\..\..\build\%DART_CONFIGURATION%\new_analyzer"
+set "JAR_DIR=%SCRIPTPATH%\..\..\build\%DART_CONFIGURATION%\dartanalyzer"
-set "JAR_FILE=%JAR_DIR%\new_analyzer.jar"
+set "JAR_FILE=%JAR_DIR%\dartanalyzer.jar"
java -jar %JAR_FILE% --dart-sdk %SDK_DIR% %arguments%
diff --git a/sdk/bin/dartdoc b/sdk/bin/dartdoc
index faec172..3f22367 100755
--- a/sdk/bin/dartdoc
+++ b/sdk/bin/dartdoc
@@ -23,4 +23,4 @@
echo Using snapshot "$BIN_DIR/../lib/_internal/dartdoc/bin/dartdoc.dart.snapshot" 1>&2
SNAPSHOT="--use-script-snapshot=$BIN_DIR/../lib/_internal/dartdoc/bin/dartdoc.dart.snapshot"
fi
-exec "$BIN_DIR"/dart --heap_growth_rate=32 "--package-root=$BIN_DIR/../packages/" $SNAPSHOT "$BIN_DIR/../lib/_internal/dartdoc/bin/dartdoc.dart" $COLORS "$@"
+exec "$BIN_DIR"/dart --heap_growth_rate=32 "--package-root=$BIN_DIR/../packages/" $SNAPSHOT "$BIN_DIR/../lib/_internal/dartdoc/bin/dartdoc.dart" "--package-root=$BIN_DIR/../packages/" $COLORS "$@"
diff --git a/sdk/lib/_collection_dev/collection_dev.dart b/sdk/lib/_collection_dev/collection_dev.dart
index dabbe2b..385d029 100644
--- a/sdk/lib/_collection_dev/collection_dev.dart
+++ b/sdk/lib/_collection_dev/collection_dev.dart
@@ -4,6 +4,8 @@
library dart._collection.dev;
+import 'dart:collection';
+
part 'arrays.dart';
part 'iterable.dart';
part 'list.dart';
diff --git a/sdk/lib/_collection_dev/iterable.dart b/sdk/lib/_collection_dev/iterable.dart
index e8a6a95..60777e9 100644
--- a/sdk/lib/_collection_dev/iterable.dart
+++ b/sdk/lib/_collection_dev/iterable.dart
@@ -126,49 +126,9 @@
throw new StateError("No matching element");
}
- E min([int compare(E a, E b)]) {
- if (length == 0) return null;
- if (compare == null) {
- var defaultCompare = Comparable.compare;
- compare = defaultCompare;
- }
- E min = elementAt(0);
+ String join([String separator = ""]) {
int length = this.length;
- for (int i = 1; i < length; i++) {
- E element = elementAt(i);
- if (compare(min, element) > 0) {
- min = element;
- }
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return min;
- }
-
- E max([int compare(E a, E b)]) {
- if (length == 0) return null;
- if (compare == null) {
- var defaultCompare = Comparable.compare;
- compare = defaultCompare;
- }
- E max = elementAt(0);
- int length = this.length;
- for (int i = 1; i < length; i++) {
- E element = elementAt(i);
- if (compare(max, element) < 0) {
- max = element;
- }
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return max;
- }
-
- String join([String separator]) {
- int length = this.length;
- if (separator != null && !separator.isEmpty) {
+ if (!separator.isEmpty) {
if (length == 0) return "";
String first = "${elementAt(0)}";
if (length != this.length) {
@@ -177,7 +137,7 @@
StringBuffer buffer = new StringBuffer(first);
for (int i = 1; i < length; i++) {
buffer.write(separator);
- buffer.write("${elementAt(i)}");
+ buffer.write(elementAt(i));
if (length != this.length) {
throw new ConcurrentModificationError(this);
}
@@ -186,7 +146,7 @@
} else {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < length; i++) {
- buffer.write("${elementAt(i)}");
+ buffer.write(elementAt(i));
if (length != this.length) {
throw new ConcurrentModificationError(this);
}
@@ -199,8 +159,13 @@
Iterable map(f(E element)) => new MappedListIterable(this, f);
- reduce(var initialValue, combine(var previousValue, E element)) {
- return fold(initialValue, combine);
+ E reduce(E combine(var value, E element)) {
+ if (length == 0) throw new StateError("No elements");
+ E value = elementAt(0);
+ for (int i = 1; i < length; i++) {
+ value = combine(value, elementAt(i));
+ }
+ return value;
}
fold(var initialValue, combine(var previousValue, E element)) {
@@ -663,18 +628,14 @@
throw new StateError("No matching element");
}
- E min([int compare(E a, E b)]) => null;
-
- E max([int compare(E a, E b)]) => null;
-
- String join([String separator]) => "";
+ String join([String separator = ""]) => "";
Iterable<E> where(bool test(E element)) => this;
Iterable map(f(E element)) => const EmptyIterable();
- reduce(var initialValue, combine(var previousValue, E element)) {
- return fold(initialValue, combine);
+ E reduce(E combine(E value, E element)) {
+ throw new StateError("No elements");
}
fold(var initialValue, combine(var previousValue, E element)) {
diff --git a/sdk/lib/_collection_dev/list.dart b/sdk/lib/_collection_dev/list.dart
index 1e40785..3ab841d 100644
--- a/sdk/lib/_collection_dev/list.dart
+++ b/sdk/lib/_collection_dev/list.dart
@@ -5,449 +5,6 @@
part of dart._collection.dev;
/**
- * Base implementation of a [List] class.
- *
- * This class can be used as a mixin.
- *
- * This implements all read operations using only the `length` and
- * `operator[]` members. It implements write operations using those and
- * `length=` and `operator[]=`
- *
- * A fixed-length list should mix this class in, and the [FixedLengthListMixin]
- * as well, in that order, to overwrite the methods that modify the length.
- *
- * An unmodifiable list should mix [UnmodifiableListMixin] on top of this
- * mixin to prevent all modifications.
- */
-abstract class ListMixin<E> implements List<E> {
- // Iterable interface.
- Iterator<E> get iterator => new ListIterator<E>(this);
-
- E elementAt(int index) => this[index];
-
- void forEach(void action(E element)) {
- int length = this.length;
- for (int i = 0; i < length; i++) {
- action(this[i]);
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- }
-
- bool get isEmpty => length == 0;
-
- E get first {
- if (length == 0) throw new StateError("No elements");
- return this[0];
- }
-
- E get last {
- if (length == 0) throw new StateError("No elements");
- return this[length - 1];
- }
-
- E get single {
- if (length == 0) throw new StateError("No elements");
- if (length > 1) throw new StateError("Too many elements");
- return this[0];
- }
-
- bool contains(E element) {
- int length = this.length;
- for (int i = 0; i < length; i++) {
- if (this[i] == element) return true;
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return false;
- }
-
- bool every(bool test(E element)) {
- int length = this.length;
- for (int i = 0; i < length; i++) {
- if (!test(this[i])) return false;
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return true;
- }
-
- bool any(bool test(E element)) {
- int length = this.length;
- for (int i = 0; i < length; i++) {
- if (test(this[i])) return true;
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return false;
- }
-
- E firstWhere(bool test(E element), { E orElse() }) {
- int length = this.length;
- for (int i = 0; i < length; i++) {
- E element = this[i];
- if (test(element)) return element;
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- if (orElse != null) return orElse();
- throw new StateError("No matching element");
- }
-
- E lastWhere(bool test(E element), { E orElse() }) {
- int length = this.length;
- for (int i = length - 1; i >= 0; i--) {
- E element = this[i];
- if (test(element)) return element;
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- if (orElse != null) return orElse();
- throw new StateError("No matching element");
- }
-
- E singleWhere(bool test(E element)) {
- int length = this.length;
- E match = null;
- bool matchFound = false;
- for (int i = 0; i < length; i++) {
- E element = this[i];
- if (test(element)) {
- if (matchFound) {
- throw new StateError("More than one matching element");
- }
- matchFound = true;
- match = element;
- }
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- if (matchFound) return match;
- throw new StateError("No matching element");
- }
-
- E min([int compare(E a, E b)]) {
- if (length == 0) return null;
- if (compare == null) {
- var defaultCompare = Comparable.compare;
- compare = defaultCompare;
- }
- E min = this[0];
- int length = this.length;
- for (int i = 1; i < length; i++) {
- E element = this[i];
- if (compare(min, element) > 0) {
- min = element;
- }
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return min;
- }
-
- E max([int compare(E a, E b)]) {
- if (length == 0) return null;
- if (compare == null) {
- var defaultCompare = Comparable.compare;
- compare = defaultCompare;
- }
- E max = this[0];
- int length = this.length;
- for (int i = 1; i < length; i++) {
- E element = this[i];
- if (compare(max, element) < 0) {
- max = element;
- }
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return max;
- }
-
- String join([String separator]) {
- int length = this.length;
- if (separator != null && !separator.isEmpty) {
- if (length == 0) return "";
- String first = "${this[0]}";
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- StringBuffer buffer = new StringBuffer(first);
- for (int i = 1; i < length; i++) {
- buffer.write(separator);
- buffer.write("${this[i]}");
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return buffer.toString();
- } else {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < length; i++) {
- buffer.write("${this[i]}");
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return buffer.toString();
- }
- }
-
- Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
-
- Iterable map(f(E element)) => new MappedListIterable(this, f);
-
- reduce(var initialValue, combine(var previousValue, E element)) {
- return fold(initialValue, combine);
- }
-
- fold(var initialValue, combine(var previousValue, E element)) {
- var value = initialValue;
- int length = this.length;
- for (int i = 0; i < length; i++) {
- value = combine(value, this[i]);
- if (length != this.length) {
- throw new ConcurrentModificationError(this);
- }
- }
- return value;
- }
-
- Iterable<E> skip(int count) => new SubListIterable(this, count, null);
-
- Iterable<E> skipWhile(bool test(E element)) {
- return new SkipWhileIterable<E>(this, test);
- }
-
- Iterable<E> take(int count) => new SubListIterable(this, 0, count);
-
- Iterable<E> takeWhile(bool test(E element)) {
- return new TakeWhileIterable<E>(this, test);
- }
-
- List<E> toList({ bool growable: true }) {
- List<E> result;
- if (growable) {
- result = new List<E>()..length = length;
- } else {
- result = new List<E>(length);
- }
- for (int i = 0; i < length; i++) {
- result[i] = this[i];
- }
- return result;
- }
-
- Set<E> toSet() {
- Set<E> result = new Set<E>();
- for (int i = 0; i < length; i++) {
- result.add(this[i]);
- }
- return result;
- }
-
- // Collection interface.
- void add(E element) {
- this[this.length++] = element;
- }
-
- void addAll(Iterable<E> iterable) {
- for (E element in iterable) {
- this[this.length++] = element;
- }
- }
-
- void remove(Object element) {
- for (int i = 0; i < this.length; i++) {
- if (this[i] == element) {
- this.setRange(i, this.length - i - 1, this, i + 1);
- this.length -= 1;
- return;
- }
- }
- }
-
- void removeAll(Iterable<Object> elements) {
- if (elements is! Set) {
- elements = elements.toSet();
- }
- _filter(this, elements.contains, false);
- }
-
-
- void retainAll(Iterable<E> iterable) {
- if (elements is! Set) {
- elements = elements.toSet();
- }
- _filter(this, elements.contains, true);
- }
-
- void removeWhere(bool test(E element)) {
- _filter(this, test, false);
- }
-
- void retainWhere(bool test(E element)) {
- _filter(this, test, true);
- }
-
- static void _filter(List source,
- bool test(var element),
- bool retainMatching) {
- List retained = [];
- int length = source.length;
- for (int i = 0; i < length; i++) {
- var element = source[i];
- if (test(element) == retainMatching) {
- retained.add(element);
- }
- if (length != source.length) {
- throw new ConcurrentModificationError(source);
- }
- }
- if (retained.length != source.length) {
- source.setRange(0, retained.length, retained);
- source.length = retained.length;
- }
- }
-
- // List interface.
-
- void sort([Comparator<E> compare]) {
- Sort.sort(this, compare);
- }
-
- Map<int, E> asMap() {
- return new ListMapView(this);
- }
-
- List<E> sublist(int start, [int end]) {
- if (end == null) end = length;
- if (start < 0 || start > this.length) {
- throw new RangeError.range(start, 0, this.length);
- }
- if (end < start || end > this.length) {
- throw new RangeError.range(end, start, this.length);
- }
- int length = end - start;
- List<E> result = new List<E>()..length = length;
- for (int i = 0; i < length; i++) {
- result[i] = this[start + i];
- }
- return result;
- }
-
- List<E> getRange(int start, int length) => sublist(start, start + length);
-
- void insertRange(int start, int length, [E initialValue]) {
- if (start < 0 || start > this.length) {
- throw new RangeError.range(start, 0, this.length);
- }
- int oldLength = this.length;
- int moveLength = oldLength - start;
- this.length += length;
- if (moveLength > 0) {
- this.setRange(start + length, moveLength, this, start);
- }
- for (int i = 0; i < length; i++) {
- this[start + i] = initialValue;
- }
- }
-
- void removeRange(int start, int length) {
- if (start < 0 || start > this.length) {
- throw new RangeError.range(start, 0, this.length);
- }
- if (length < 0 || start + length > this.length) {
- throw new RangeError.range(length, 0, this.length - start);
- }
- int end = start + length;
- setRange(start, this.length - end, this, end);
- this.length -= length;
- }
-
- void clearRange(int start, int length, [E fill]) {
- for (int i = 0; i < length; i++) {
- this[start + i] = fill;
- }
- }
-
- void setRange(int start, int length, List<E> from, [int startFrom]) {
- if (start < 0 || start > this.length) {
- throw new RangeError.range(start, 0, this.length);
- }
- if (length < 0 || start + length > this.length) {
- throw new RangeError.range(length, 0, this.length - start);
- }
- if (startFrom == null) {
- startFrom = 0;
- }
- if (startFrom < 0 || startFrom + length > from.length) {
- throw new RangeError.range(startFrom, 0, from.length - length);
- }
- if (startFrom < start) {
- // Copy backwards to ensure correct copy if [from] is this.
- for (int i = length - 1; i >= 0; i--) {
- this[start + i] = from[startFrom + i];
- }
- } else {
- for (int i = 0; i < length; i++) {
- this[start + i] = from[startFrom + i];
- }
- }
- }
-
- int indexOf(E element, [int startIndex = 0]) {
- if (startIndex >= this.length) {
- return -1;
- }
- if (startIndex < 0) {
- startIndex = 0;
- }
- for (int i = startIndex; i < this.length; i++) {
- if (this[i] == element) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Returns the last index in the list [a] of the given [element], starting
- * the search at index [startIndex] to 0.
- * Returns -1 if [element] is not found.
- */
- int lastIndexOf(E element, [int startIndex]) {
- if (startIndex == null) {
- startIndex = this.length - 1;
- } else {
- if (startIndex < 0) {
- return -1;
- }
- if (startIndex >= a.length) {
- startIndex = a.length - 1;
- }
- }
- for (int i = startIndex; i >= 0; i--) {
- if (this[i] == element) {
- return i;
- }
- }
- return -1;
- }
-
- Iterable<E> get reversed => new ReversedListIterable(this);
-}
-
-/**
* Mixin that throws on the length changing operations of [List].
*
* Intended to mix-in on top of [ListMixin] for fixed-length lists.
@@ -619,23 +176,13 @@
}
}
-
-/**
- * Abstract implementation of a list.
- *
- * All operations are defined in terms of `length`, `operator[]`,
- * `operator[]=` and `length=`, which need to be implemented.
- */
-abstract class ListBase<E> extends ListMixin<E> implements List<E> {}
-
/**
* Abstract implementation of a fixed-length list.
*
* All operations are defined in terms of `length`, `operator[]` and
* `operator[]=`, which need to be implemented.
*/
-abstract class FixedLengthListBase<E> extends ListBase<E>
- with FixedLengthListMixin<E> {}
+typedef FixedLengthListBase<E> = ListBase<E> with FixedLengthListMixin<E>;
/**
* Abstract implementation of an unmodifiable list.
@@ -643,41 +190,7 @@
* All operations are defined in terms of `length` and `operator[]`,
* which need to be implemented.
*/
-abstract class UnmodifiableListBase<E> extends ListBase<E>
- with UnmodifiableListMixin<E> {}
-
-/** An empty fixed-length (and therefore unmodifiable) list. */
-class EmptyList<E> extends FixedLengthListBase<E> {
- int get length => 0;
- E operator[](int index) { throw new RangeError.value(index); }
- void operator []=(int index, E value) { throw new RangeError.value(index); }
- Iterable<E> skip(int count) => const EmptyIterable();
- Iterable<E> take(int count) => const EmptyIterable();
- Iterable<E> get reversed => const EmptyIterable();
- void sort([int compare(E a, E b)]) {}
-}
-
-class ReversedListIterable<E> extends ListIterable<E> {
- Iterable<E> _source;
- ReversedListIterable(this._source);
-
- int get length => _source.length;
-
- E elementAt(int index) => _source.elementAt(_source.length - 1 - index);
-}
-
-/**
- * An [Iterable] of the UTF-16 code units of a [String] in index order.
- */
-class CodeUnits extends UnmodifiableListBase<int> {
- /** The string that this is the code units of. */
- String _string;
-
- CodeUnits(this._string);
-
- int get length => _string.length;
- int operator[](int i) => _string.codeUnitAt(i);
-}
+typedef UnmodifiableListBase<E> = ListBase<E> with UnmodifiableListMixin<E>;
class _ListIndicesIterable extends ListIterable<int> {
List _backedList;
@@ -734,3 +247,12 @@
throw new UnsupportedError("Cannot modify an unmodifiable map");
}
}
+
+class ReversedListIterable<E> extends ListIterable<E> {
+ Iterable<E> _source;
+ ReversedListIterable(this._source);
+
+ int get length => _source.length;
+
+ E elementAt(int index) => _source.elementAt(_source.length - 1 - index);
+}
diff --git a/sdk/lib/_collection_dev/to_string.dart b/sdk/lib/_collection_dev/to_string.dart
index f90ff18..e1ff05d 100644
--- a/sdk/lib/_collection_dev/to_string.dart
+++ b/sdk/lib/_collection_dev/to_string.dart
@@ -11,50 +11,50 @@
// TODO(jjb): visiting list should be an identityHashSet when it exists
/**
- * Returns a string representing the specified collection. If the
- * collection is a [List], the returned string looks like this:
+ * Returns a string representing the specified iterable. If the
+ * iterable is a [List], the returned string looks like this:
* [:'[element0, element1, ... elementN]':]. The value returned by its
* [toString] method is used to represent each element. If the specified
- * collection is not a list, the returned string looks like this:
+ * iterable is not a list, the returned string looks like this:
* [:{element0, element1, ... elementN}:]. In other words, the strings
* returned for lists are surrounded by square brackets, while the strings
- * returned for other collections are surrounded by curly braces.
+ * returned for other iterables are surrounded by curly braces.
*
- * If the specified collection contains a reference to itself, either
- * directly or indirectly through other collections or maps, the contained
+ * If the specified iterable contains a reference to itself, either
+ * directly or indirectly through other iterables or maps, the contained
* reference is rendered as [:'[...]':] if it is a list, or [:'{...}':] if
* it is not. This prevents the infinite regress that would otherwise occur.
* So, for example, calling this method on a list whose sole element is a
* reference to itself would return [:'[[...]]':].
*
- * A typical implementation of a collection's [toString] method will
- * simply return the results of this method applied to the collection.
+ * A typical implementation of a iterable's [toString] method will
+ * simply return the results of this method applied to the iterable.
*/
- static String collectionToString(Collection c) {
+ static String iterableToString(Iterable i) {
var result = new StringBuffer();
- _emitCollection(c, result, new List());
+ _emitValue(i, result, new List());
return result.toString();
}
/**
- * Appends a string representing the specified collection to the specified
- * string buffer. The string is formatted as per [collectionToString].
+ * Appends a string representing the specified iterable to the specified
+ * string buffer. The string is formatted as per [iterableToString].
* The [:visiting:] list contains references to all of the enclosing
- * collections and maps (which are currently in the process of being
+ * iterables and maps (which are currently in the process of being
* emitted into [:result:]). The [:visiting:] parameter allows this method to
* generate a [:'[...]':] or [:'{...}':] where required. In other words,
- * it allows this method and [_emitMap] to identify recursive collections
+ * it allows this method and [_emitMap] to identify recursive iterables
* and maps.
*/
- static void _emitCollection(Collection c,
- StringBuffer result,
- List visiting) {
- visiting.add(c);
- bool isList = c is List;
+ static void _emitValue(Iterable i,
+ StringBuffer result,
+ List visiting) {
+ visiting.add(i);
+ bool isList = i is List;
result.write(isList ? '[' : '{');
bool first = true;
- for (var e in c) {
+ for (var e in i) {
if (!first) {
result.write(', ');
}
@@ -68,8 +68,8 @@
/**
* Appends a string representing the specified object to the specified
- * string buffer. If the object is a [Collection] or [Map], it is formatted
- * as per [collectionToString] or [mapToString]; otherwise, it is formatted
+ * string buffer. If the object is a [iterable] or [Map], it is formatted
+ * as per [iterableToString] or [mapToString]; otherwise, it is formatted
* by invoking its own [toString] method.
*
* The [:visiting:] list contains references to all of the enclosing
@@ -80,17 +80,17 @@
* and collections.
*/
static void _emitObject(Object o, StringBuffer result, List visiting) {
- if (o is Collection) {
+ if (o is Iterable) {
if (_containsRef(visiting, o)) {
result.write(o is List ? '[...]' : '{...}');
} else {
- _emitCollection(o, result, visiting);
+ _emitValue(o, result, visiting);
}
} else if (o is Map) {
if (_containsRef(visiting, o)) {
result.write('{...}');
} else {
- _emitMap(o, result, visiting);
+ _emitPair(o, result, visiting);
}
} else { // o is neither a collection nor a map
result.write(o);
@@ -101,8 +101,8 @@
* Returns true if the specified collection contains the specified object
* reference.
*/
- static _containsRef(Collection c, Object ref) {
- for (var e in c) {
+ static _containsRef(Iterable i, Object ref) {
+ for (var e in i) {
if (identical(e, ref)) return true;
}
return false;
@@ -126,7 +126,7 @@
*/
static String mapToString(Map m) {
var result = new StringBuffer();
- _emitMap(m, result, new List());
+ _emitPair(m, result, new List());
return result.toString();
}
@@ -140,7 +140,7 @@
* it allows this method and [_emitCollection] to identify recursive maps
* and collections.
*/
- static void _emitMap(Map m, StringBuffer result, List visiting) {
+ static void _emitPair(Map m, StringBuffer result, List visiting) {
visiting.add(m);
result.write('{');
diff --git a/sdk/lib/_internal/compiler/implementation/apiimpl.dart b/sdk/lib/_internal/compiler/implementation/apiimpl.dart
index b3de769..6a81d46 100644
--- a/sdk/lib/_internal/compiler/implementation/apiimpl.dart
+++ b/sdk/lib/_internal/compiler/implementation/apiimpl.dart
@@ -56,7 +56,8 @@
enableConcreteTypeInference:
hasOption(options, '--enable-concrete-type-inference'),
preserveComments: hasOption(options, '--preserve-comments'),
- verbose: hasOption(options, '--verbose')) {
+ verbose: hasOption(options, '--verbose'),
+ buildId: getBuildId(options)) {
if (!libraryRoot.path.endsWith("/")) {
throw new ArgumentError("libraryRoot must end with a /");
}
@@ -65,6 +66,15 @@
}
}
+ static String getBuildId(List<String> options) {
+ for (String option in options) {
+ if (option.startsWith('--build-id=')) {
+ return option.substring('--build-id='.length);
+ }
+ }
+ return "build number could not be determined";
+ }
+
static List<String> getStrips(List<String> options) {
for (String option in options) {
if (option.startsWith('--force-strip=')) {
diff --git a/sdk/lib/_internal/compiler/implementation/closure.dart b/sdk/lib/_internal/compiler/implementation/closure.dart
index aa17a00..48fa3b3 100644
--- a/sdk/lib/_internal/compiler/implementation/closure.dart
+++ b/sdk/lib/_internal/compiler/implementation/closure.dart
@@ -63,6 +63,9 @@
}
}
+// TODO(ahe): These classes continuously cause problems. We need to
+// move these classes to elements/modelx.dart or see if we can find a
+// more general solution.
class ClosureFieldElement extends ElementX {
ClosureFieldElement(SourceString name, ClassElement enclosing)
: super(name, ElementKind.FIELD, enclosing);
@@ -79,6 +82,9 @@
String toString() => "ClosureFieldElement($name)";
}
+// TODO(ahe): These classes continuously cause problems. We need to
+// move these classes to elements/modelx.dart or see if we can find a
+// more general solution.
class ClosureClassElement extends ClassElementX {
DartType rawType;
DartType thisType;
@@ -114,11 +120,17 @@
Element methodElement;
}
+// TODO(ahe): These classes continuously cause problems. We need to
+// move these classes to elements/modelx.dart or see if we can find a
+// more general solution.
class BoxElement extends ElementX {
BoxElement(SourceString name, Element enclosingElement)
: super(name, ElementKind.VARIABLE, enclosingElement);
}
+// TODO(ahe): These classes continuously cause problems. We need to
+// move these classes to elements/modelx.dart or see if we can find a
+// more general solution.
class ThisElement extends ElementX {
ThisElement(Element enclosing)
: super(const SourceString('this'), ElementKind.PARAMETER, enclosing);
@@ -130,6 +142,9 @@
Token position() => enclosingElement.position();
}
+// TODO(ahe): These classes continuously cause problems. We need to
+// move these classes to elements/modelx.dart or see if we can find a
+// more general solution.
class CheckVariableElement extends ElementX {
Element parameter;
CheckVariableElement(SourceString name, this.parameter, Element enclosing)
diff --git a/sdk/lib/_internal/compiler/implementation/code_buffer.dart b/sdk/lib/_internal/compiler/implementation/code_buffer.dart
index 4c0a1fe..1d58b9b 100644
--- a/sdk/lib/_internal/compiler/implementation/code_buffer.dart
+++ b/sdk/lib/_internal/compiler/implementation/code_buffer.dart
@@ -40,7 +40,7 @@
CodeBuffer writeAll(Iterable<Object> objects, [String separator = ""]) {
Iterator iterator = objects.iterator;
if (!iterator.moveNext()) return this;
- if (separator == "") {
+ if (separator.isEmpty) {
do {
write(iterator.current);
} while (iterator.moveNext());
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 4270b83..1e2ab51 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -16,16 +16,6 @@
const bool DUMP_INFERRED_TYPES = false;
/**
- * A string to identify the revision or build.
- *
- * This ID is displayed if the compiler crashes and in verbose mode, and is
- * an aid in reproducing bug reports.
- *
- * The actual string is rewritten during the SDK build process.
- */
-const String BUILD_ID = 'build number could not be determined';
-
-/**
* Contains backend-specific data that is used throughout the compilation of
* one work item.
*/
@@ -85,6 +75,15 @@
}
}
+typedef void PostProcessAction();
+
+class PostProcessTask {
+ final Element element;
+ final PostProcessAction action;
+
+ PostProcessTask(this.element, this.action);
+}
+
class ReadingFilesTask extends CompilerTask {
ReadingFilesTask(Compiler compiler) : super(compiler);
String get name => 'Reading input files';
@@ -139,7 +138,8 @@
TreeElements elements) {}
void registerStringInterpolation(TreeElements elements) {}
void registerCatchStatement(TreeElements elements) {}
- void registerThrow(TreeElements elements) {}
+ void registerWrapException(TreeElements elements) {}
+ void registerThrowExpression(TreeElements elements) {}
void registerLazyField(TreeElements elements) {}
void registerTypeVariableExpression(TreeElements elements) {}
void registerTypeLiteral(TreeElements elements) {}
@@ -364,6 +364,7 @@
EnqueueTask enqueuer;
CompilerTask fileReadingTask;
DeferredLoadTask deferredLoadTask;
+ String buildId;
static const SourceString MAIN = const SourceString('main');
static const SourceString CALL_OPERATOR_NAME = const SourceString('call');
@@ -375,6 +376,14 @@
static const SourceString RUNTIME_TYPE = const SourceString('runtimeType');
static const SourceString START_ROOT_ISOLATE =
const SourceString('startRootIsolate');
+
+ final Selector iteratorSelector =
+ new Selector.getter(const SourceString('iterator'), null);
+ final Selector currentSelector =
+ new Selector.getter(const SourceString('current'), null);
+ final Selector moveNextSelector =
+ new Selector.call(const SourceString('moveNext'), null, 0);
+
bool enabledNoSuchMethod = false;
bool enabledRuntimeType = false;
bool enabledFunctionApply = false;
@@ -409,6 +418,7 @@
bool checkDeprecationInSdk: false,
bool preserveComments: false,
bool verbose: false,
+ String this.buildId: "build number could not be determined",
outputProvider,
List<String> strips: const []})
: tracer = tracer,
@@ -508,7 +518,7 @@
}
void pleaseReportCrash() {
- print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': BUILD_ID}));
+ print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': buildId}));
}
void cancel(String reason, {Node node, Token token,
@@ -715,15 +725,15 @@
scanBuiltinLibraries();
if (librariesToAnalyzeWhenRun != null) {
for (Uri libraryUri in librariesToAnalyzeWhenRun) {
- log('analyzing $libraryUri ($BUILD_ID)');
+ log('analyzing $libraryUri ($buildId)');
libraryLoader.loadLibrary(libraryUri, null, libraryUri);
}
}
if (uri != null) {
if (analyzeOnly) {
- log('analyzing $uri ($BUILD_ID)');
+ log('analyzing $uri ($buildId)');
} else {
- log('compiling $uri ($BUILD_ID)');
+ log('compiling $uri ($buildId)');
}
mainApp = libraryLoader.loadLibrary(uri, null, uri);
}
@@ -835,6 +845,9 @@
withCurrentElement(work.element, () => work.run(this, world));
});
world.queueIsClosed = true;
+ world.forEachPostProcessTask((PostProcessTask work) {
+ withCurrentElement(work.element, () => work.action());
+ });
if (compilationFailed) return;
assert(world.checkNoEnqueuedInvokedInstanceMethods());
if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) {
@@ -1239,13 +1252,16 @@
* [spannable] must be non-null and will be used to provide positional
* information in the generated error message.
*/
-bool invariant(Spannable spannable, var condition, {String message: null}) {
+bool invariant(Spannable spannable, var condition, {var message: null}) {
// TODO(johnniwinther): Use [spannable] and [message] to provide better
// information on assertion errors.
if (condition is Function){
condition = condition();
}
if (spannable == null || !condition) {
+ if (message is Function) {
+ message = message();
+ }
throw new SpannableAssertionFailure(spannable, message);
}
return true;
diff --git a/sdk/lib/_internal/compiler/implementation/dart2js.dart b/sdk/lib/_internal/compiler/implementation/dart2js.dart
index af7befd..d1f08f9 100644
--- a/sdk/lib/_internal/compiler/implementation/dart2js.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart2js.dart
@@ -20,6 +20,16 @@
const String LIBRARY_ROOT = '../../../../..';
const String OUTPUT_LANGUAGE_DART = 'Dart';
+/**
+ * A string to identify the revision or build.
+ *
+ * This ID is displayed if the compiler crashes and in verbose mode, and is
+ * an aid in reproducing bug reports.
+ *
+ * The actual string is rewritten by a wrapper script when included in the sdk.
+ */
+String BUILD_ID = null;
+
typedef void HandleOption(String option);
class OptionHandler {
@@ -87,6 +97,10 @@
passThrough(String argument) => options.add(argument);
+ if (BUILD_ID != null) {
+ passThrough("--build-id=$BUILD_ID");
+ }
+
setLibraryRoot(String argument) {
libraryRoot = cwd.resolve(extractPath(argument));
}
@@ -486,9 +500,9 @@
fail(message);
}
-void main() {
+void mainWithErrorHandler(Options options) {
try {
- compilerMain(new Options());
+ compilerMain(options);
} catch (exception, trace) {
try {
print('Internal error: $exception');
@@ -502,3 +516,7 @@
}
}
}
+
+void main() {
+ mainWithErrorHandler(new Options());
+}
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/emitter.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/emitter.dart
index c074af4..c58319e 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/emitter.dart
@@ -7,8 +7,8 @@
String emitCode(
Unparser unparser,
Map<LibraryElement, String> imports,
- Collection<Node> topLevelNodes,
- Map<ClassNode, Collection<Node>> classMembers) {
+ Iterable<Node> topLevelNodes,
+ Map<ClassNode, Iterable<Node>> classMembers) {
imports.forEach((libraryElement, prefix) {
unparser.unparseImportTag('${libraryElement.canonicalUri}', prefix);
});
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
index 9acc6ec..83531c7 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
@@ -71,7 +71,7 @@
final Map<LibraryElement, Map<String, String>> renamed
= new Map<LibraryElement, Map<String, String>>();
- renameNodes(Collection<Node> nodes, renamer) {
+ renameNodes(Iterable<Node> nodes, renamer) {
for (Node node in sorted(nodes, _compareNodes)) {
renames[node] = renamer(node);
}
diff --git a/sdk/lib/_internal/compiler/implementation/dart_types.dart b/sdk/lib/_internal/compiler/implementation/dart_types.dart
index 5f00a62..560bb53 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_types.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_types.dart
@@ -5,7 +5,8 @@
library dart_types;
import 'dart2jslib.dart' show Compiler, invariant, Script, Message;
-import 'elements/modelx.dart' show VoidElementX, LibraryElementX;
+import 'elements/modelx.dart'
+ show VoidElementX, LibraryElementX, BaseClassElementX;
import 'elements/elements.dart';
import 'scanner/scannerlib.dart' show SourceString;
import 'util/util.dart' show Link, LinkBuilder;
@@ -133,6 +134,15 @@
bool get containsTypeVariables => typeVariableOccurrence != null;
accept(DartTypeVisitor visitor, var argument);
+
+ void visitChildren(DartTypeVisitor visitor, var argument) {}
+
+ static void visitList(Link<DartType> types,
+ DartTypeVisitor visitor, var argument) {
+ for (Link<DartType> link = types; !link.isEmpty ; link = link.tail) {
+ link.head.accept(visitor, argument);
+ }
+ }
}
/**
@@ -396,6 +406,10 @@
return _findTypeVariableOccurrence(typeArguments);
}
+ void visitChildren(DartTypeVisitor visitor, var argument) {
+ DartType.visitList(typeArguments, visitor, argument);
+ }
+
String toString() {
StringBuffer sb = new StringBuffer();
sb.write(name.slowToString());
@@ -438,8 +452,8 @@
assert(invariant(element, element.isDeclaration));
assert(invariant(element, element.thisType == null ||
typeArguments.slowLength() == element.typeVariables.slowLength(),
- message: 'Invalid type argument count on ${element.thisType}. '
- 'Provided type arguments: $typeArguments.'));
+ message: () => 'Invalid type argument count on ${element.thisType}. '
+ 'Provided type arguments: $typeArguments.'));
}
InterfaceType.userProvidedBadType(this.element,
@@ -663,6 +677,13 @@
return visitor.visitFunctionType(this, argument);
}
+ void visitChildren(DartTypeVisitor visitor, var argument) {
+ returnType.accept(visitor, argument);
+ DartType.visitList(parameterTypes, visitor, argument);
+ DartType.visitList(optionalParameterTypes, visitor, argument);
+ DartType.visitList(namedParameterTypes, visitor, argument);
+ }
+
String toString() {
StringBuffer sb = new StringBuffer();
sb.write('(');
@@ -1033,8 +1054,30 @@
}
bool visitTypeVariableType(TypeVariableType t, DartType s) {
- if (s is !TypeVariableType) return false;
- return (identical(t.element, s.element));
+ // Identity check is handled in [isSubtype].
+ DartType bound = t.element.bound;
+ if (bound.element.isTypeVariable()) {
+ // The bound is potentially cyclic so we need to be extra careful.
+ Link<TypeVariableElement> seenTypeVariables =
+ const Link<TypeVariableElement>();
+ seenTypeVariables = seenTypeVariables.prepend(t.element);
+ while (bound.element.isTypeVariable()) {
+ TypeVariableElement element = bound.element;
+ if (identical(bound.element, s.element)) {
+ // [t] extends [s].
+ return true;
+ }
+ if (seenTypeVariables.contains(element)) {
+ // We have a cycle and have already checked all bounds in the cycle
+ // against [s] and can therefore conclude that [t] is not a subtype
+ // of [s].
+ return false;
+ }
+ seenTypeVariables = seenTypeVariables.prepend(element);
+ bound = element.bound;
+ }
+ }
+ return isSubtype(bound, s);
}
}
@@ -1045,11 +1088,11 @@
final DynamicType dynamicType;
final SubtypeVisitor subtypeVisitor;
- factory Types(Compiler compiler, ClassElement dynamicElement) {
+ factory Types(Compiler compiler, BaseClassElementX dynamicElement) {
LibraryElement library = new LibraryElementX(new Script(null, null));
VoidType voidType = new VoidType(new VoidElementX(library));
DynamicType dynamicType = new DynamicType(dynamicElement);
- dynamicElement.rawType = dynamicElement.thisType = dynamicType;
+ dynamicElement.rawTypeCache = dynamicElement.thisType = dynamicType;
SubtypeVisitor subtypeVisitor =
new SubtypeVisitor(compiler, dynamicType, voidType);
return new Types.internal(compiler, voidType, dynamicType, subtypeVisitor);
diff --git a/sdk/lib/_internal/compiler/implementation/elements/elements.dart b/sdk/lib/_internal/compiler/implementation/elements/elements.dart
index b35824d..94d8a1c 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/elements.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/elements.dart
@@ -185,7 +185,6 @@
bool isClosure();
bool isMember();
bool isInstanceMember();
- bool isInStaticMember();
bool isFactoryConstructor();
bool isGenerativeConstructor();
@@ -294,6 +293,20 @@
element.enclosingElement.kind == ElementKind.LIBRARY);
}
+ static bool isInStaticContext(Element element) {
+ if (isUnresolved(element)) return true;
+ if (element.enclosingElement.isClosure()) {
+ var closureClass = element.enclosingElement;
+ element = closureClass.methodElement;
+ }
+ Element outer = element.getOutermostEnclosingMemberOrTopLevel();
+ if (isUnresolved(outer)) return true;
+ if (outer.isTopLevel()) return true;
+ if (outer.isGenerativeConstructor()) return false;
+ if (outer.isInstanceMember()) return false;
+ return true;
+ }
+
static bool isStaticOrTopLevelField(Element element) {
return isStaticOrTopLevel(element)
&& (identical(element.kind, ElementKind.FIELD)
@@ -321,8 +334,11 @@
static bool isClosureSend(Send send, Element element) {
if (send.isPropertyAccess) return false;
if (send.receiver != null) return false;
+ Node selector = send.selector;
+ // this().
+ if (selector.isThis()) return true;
// (o)() or foo()().
- if (element == null && send.selector.asIdentifier() == null) return true;
+ if (element == null && selector.asIdentifier() == null) return true;
if (element == null) return false;
// foo() with foo a local or a parameter.
return isLocal(element);
@@ -459,8 +475,7 @@
static bool isListSupertype(Element element, Compiler compiler) {
LibraryElement coreLibrary = compiler.coreLibrary;
- return (element == coreLibrary.find(const SourceString('Collection')))
- || (element == coreLibrary.find(const SourceString('Iterable')));
+ return element == coreLibrary.find(const SourceString('Iterable'));
}
/// A `compareTo` function that places [Element]s in a consistent order based
@@ -741,7 +756,6 @@
bool get hasLocalScopeMembers;
// TODO(kasperl): These are bit fishy. Do we really need them?
- void set rawType(InterfaceType value);
void set thisType(InterfaceType value);
void set supertype(DartType value);
void set allSupertypes(Link<DartType> value);
diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
index 8e9bf31..915a55d 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -70,15 +70,6 @@
}
bool isInstanceMember() => false;
- /**
- * Returns [:true:] if this element is enclosed in a static member or is
- * itself a static member.
- */
- bool isInStaticMember() {
- Element member = getEnclosingMember();
- return member != null && member.modifiers.isStatic();
- }
-
bool isFactoryConstructor() => modifiers.isFactory();
bool isGenerativeConstructor() =>
identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR);
@@ -1364,7 +1355,7 @@
*
* This type is computed together with [thisType] in [computeType].
*/
- InterfaceType rawType;
+ InterfaceType rawTypeCache;
DartType supertype;
DartType defaultClass;
Link<DartType> interfaces;
@@ -1400,23 +1391,29 @@
Link<DartType> parameters = computeTypeParameters(compiler);
thisType = new InterfaceType(this, parameters);
if (parameters.isEmpty) {
- rawType = thisType;
+ rawTypeCache = thisType;
} else {
var dynamicParameters = const Link<DartType>();
parameters.forEach((_) {
dynamicParameters =
dynamicParameters.prepend(compiler.types.dynamicType);
});
- rawType = new InterfaceType(this, dynamicParameters);
+ rawTypeCache = new InterfaceType(this, dynamicParameters);
}
} else {
thisType = origin.computeType(compiler);
- rawType = origin.rawType;
+ rawTypeCache = origin.rawType;
}
}
return thisType;
}
+ InterfaceType get rawType {
+ assert(invariant(this, rawTypeCache != null,
+ message: 'Raw type has not been computed for $this'));
+ return rawTypeCache;
+ }
+
Link<DartType> computeTypeParameters(Compiler compiler);
/**
diff --git a/sdk/lib/_internal/compiler/implementation/enqueue.dart b/sdk/lib/_internal/compiler/implementation/enqueue.dart
index 125a355..70897cb 100644
--- a/sdk/lib/_internal/compiler/implementation/enqueue.dart
+++ b/sdk/lib/_internal/compiler/implementation/enqueue.dart
@@ -386,6 +386,15 @@
compiler.backend.registerIsCheck(type, this, elements);
}
+ /**
+ * If a factory constructor is used with type arguments, we lose track
+ * which arguments could be used to create instances of classes that use their
+ * type variables as expressions, so we have to remember if we saw such a use.
+ */
+ void registerFactoryWithTypeArguments(TreeElements elements) {
+ universe.usingFactoryWithTypeArguments = true;
+ }
+
void registerAsCheck(DartType type, TreeElements elements) {
registerIsCheck(type, elements);
compiler.backend.registerAsCheck(type, elements);
@@ -393,6 +402,8 @@
void forEach(f(WorkItem work));
+ void forEachPostProcessTask(f(PostProcessTask work)) {}
+
void logSummary(log(message)) {
_logSpecificSummary(log);
nativeEnqueuer.logSummary(log);
@@ -416,11 +427,18 @@
final Queue<ResolutionWorkItem> queue;
+ /**
+ * A post-processing queue for the resolution phase which is processed
+ * immediately after the resolution queue has been closed.
+ */
+ final Queue<PostProcessTask> postQueue;
+
ResolutionEnqueuer(Compiler compiler,
ItemCompilationContext itemCompilationContextCreator())
: super('resolution enqueuer', compiler, itemCompilationContextCreator),
resolvedElements = new Map<Element, TreeElements>(),
- queue = new Queue<ResolutionWorkItem>();
+ queue = new Queue<ResolutionWorkItem>(),
+ postQueue = new Queue<PostProcessTask>();
bool get isResolutionQueue => true;
@@ -521,6 +539,27 @@
}
}
+ /**
+ * Adds an action to the post-processing queue.
+ *
+ * The action is performed as part of the post-processing immediately after
+ * the resolution queue has been closed. As a consequence, [action] must not
+ * add elements to the resolution queue.
+ */
+ void addPostProcessAction(Element element, PostProcessAction action) {
+ if (queueIsClosed) {
+ throw new SpannableAssertionFailure(element,
+ "Resolution work list is closed.");
+ }
+ postQueue.add(new PostProcessTask(element, action));
+ }
+
+ void forEachPostProcessTask(f(PostProcessTask work)) {
+ while (!postQueue.isEmpty) {
+ f(postQueue.removeFirst());
+ }
+ }
+
void registerJsCall(Send node, ResolverVisitor resolver) {
nativeEnqueuer.registerJsCall(node, resolver);
}
diff --git a/sdk/lib/_internal/compiler/implementation/js/builder.dart b/sdk/lib/_internal/compiler/implementation/js/builder.dart
index 5492466..5247d67 100644
--- a/sdk/lib/_internal/compiler/implementation/js/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/js/builder.dart
@@ -10,18 +10,19 @@
class JsBuilder {
const JsBuilder();
- Expression operator [](String source) {
- return new MiniJsParser(source).expression();
- }
-
- // TODO(ahe): Remove this method.
- Binary equals(Expression left, Expression right) {
- return new Binary('==', left, right);
- }
-
- // TODO(ahe): Remove this method.
- Binary strictEquals(Expression left, Expression right) {
- return new Binary('===', left, right);
+ // Parse a bit of JS, and return an expression. See the MiniJsParser class.
+ // You can provide an expression or a list of expressions, which will be
+ // interpolated into the source at the '#' signs.
+ Expression call(String source, [var expression]) {
+ List<Expression> expressions;
+ if (expression != null) {
+ if (expression is List) {
+ expressions = expression;
+ } else {
+ expressions = <Expression>[expression];
+ }
+ }
+ return new MiniJsParser(source, expressions).expression();
}
LiteralString string(String value) => new LiteralString('"$value"');
@@ -92,7 +93,7 @@
if (expression is Expression) {
return expression;
} else if (expression is String) {
- return this[expression];
+ return this(expression);
} else if (expression is num) {
return new LiteralNumber('$expression');
} else if (expression is bool) {
@@ -161,12 +162,11 @@
/// * most operators.
/// * brackets.
/// * var declarations.
-/// Notable things it can't do yet include:
/// * operator precedence.
+/// Notable things it can't do yet include:
/// * non-empty object literals.
/// * throw, return.
/// * statements, including any flow control (if, while, for, etc.)
-/// * the 'in' keyword.
///
/// It's a fairly standard recursive descent parser.
///
@@ -178,11 +178,12 @@
/// to get early errors for unintentional escape sequences without complicating
/// this parser unneccessarily.
class MiniJsParser {
- MiniJsParser(this.src)
+ MiniJsParser(this.src, this.interpolatedValues)
: lastCategory = NONE,
lastToken = null,
lastPosition = 0,
- position = 0 {
+ position = 0,
+ valuesUsed = 0 {
getSymbol();
}
@@ -190,14 +191,16 @@
String lastToken;
int lastPosition;
int position;
+ int valuesUsed;
String src;
+ List<Expression> interpolatedValues;
static const NONE = -1;
static const ALPHA = 0;
static const NUMERIC = 1;
static const STRING = 2;
static const SYMBOL = 3;
- static const RELATION = 4;
+ static const ASSIGNMENT = 4;
static const DOT = 5;
static const LPAREN = 6;
static const RPAREN = 7;
@@ -208,7 +211,9 @@
static const COMMA = 12;
static const QUERY = 13;
static const COLON = 14;
- static const OTHER = 15;
+ static const HASH = 15;
+ static const WHITESPACE = 16;
+ static const OTHER = 17;
// Make sure that ]] is two symbols.
bool singleCharCategory(int category) => category >= DOT;
@@ -219,7 +224,7 @@
case ALPHA: return "ALPHA";
case NUMERIC: return "NUMERIC";
case SYMBOL: return "SYMBOL";
- case RELATION: return "RELATION";
+ case ASSIGNMENT: return "ASSIGNMENT";
case DOT: return "DOT";
case LPAREN: return "LPAREN";
case RPAREN: return "RPAREN";
@@ -230,6 +235,8 @@
case COMMA: return "COMMA";
case QUERY: return "QUERY";
case COLON: return "COLON";
+ case HASH: return "HASH";
+ case WHITESPACE: return "WHITESPACE";
case OTHER: return "OTHER";
}
return "Unknown: $cat";
@@ -237,14 +244,15 @@
static const CATEGORIES = const <int>[
OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, // 0-7
- OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, // 8-15
- OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, // 16-23
- OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, // 24-31
- OTHER, RELATION, OTHER, OTHER, ALPHA, SYMBOL, SYMBOL, OTHER, // !"#$%&´
+ OTHER, WHITESPACE, WHITESPACE, OTHER, OTHER, WHITESPACE, // 8-13
+ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, // 14-21
+ OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, OTHER, // 22-29
+ OTHER, OTHER, WHITESPACE, // 30-32
+ SYMBOL, OTHER, HASH, ALPHA, SYMBOL, SYMBOL, OTHER, // !"#$%&´
LPAREN, RPAREN, SYMBOL, SYMBOL, COMMA, SYMBOL, DOT, SYMBOL, // ()*+,-./
NUMERIC, NUMERIC, NUMERIC, NUMERIC, NUMERIC, // 01234
NUMERIC, NUMERIC, NUMERIC, NUMERIC, NUMERIC, // 56789
- COLON, OTHER, RELATION, RELATION, RELATION, QUERY, OTHER, // :;<=>?@
+ COLON, OTHER, SYMBOL, SYMBOL, SYMBOL, QUERY, OTHER, // :;<=>?@
ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // ABCDEFGH
ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // IJKLMNOP
ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // QRSTUVWX
@@ -254,11 +262,27 @@
ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, // qrstuvwx
ALPHA, ALPHA, LBRACE, SYMBOL, RBRACE, SYMBOL]; // yz{|}~
- static final BINARY_OPERATORS = [
- '+', '-', '*', '/', '%', '^', '|', '&', '||', '&&', '<<', '>>', '>>>',
- '+=', '-=', '*=', '/=', '%=', '^=', '|=', '&=', '<<=', '>>=', '>>>=',
- '=', '!=', '==', '!==', '===', '<', '<=', '>=', '>'].toSet();
- static final UNARY_OPERATORS = ['++', '--', '+', '-', '~', '!'].toSet();
+ // This must be a >= the highest precedence number handled by parseBinary.
+ static var HIGHEST_PARSE_BINARY_PRECEDENCE = 16;
+ static bool isAssignment(String symbol) => BINARY_PRECEDENCE[symbol] == 17;
+
+ // From https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Operator_Precedence
+ static final BINARY_PRECEDENCE = {
+ '+=': 17, '-=': 17, '*=': 17, '/=': 17, '%=': 17, '^=': 17, '|=': 17,
+ '&=': 17, '<<=': 17, '>>=': 17, '>>>=': 17, '=': 17,
+ '||': 14,
+ '&&': 13,
+ '|': 12,
+ '^': 11,
+ '&': 10,
+ '!=': 9, '==': 9, '!==': 9, '===': 9,
+ '<': 8, '<=': 8, '>=': 8, '>': 8, 'in': 8, 'instanceof': 8,
+ '<<': 7, '>>': 7, '>>>': 7,
+ '+': 6, '-': 6,
+ '*': 5, '/': 5, '%': 5
+ };
+ static final UNARY_OPERATORS =
+ ['++', '--', '+', '-', '~', '!', 'typeof', 'void', 'delete'].toSet();
static int category(int code) {
if (code >= CATEGORIES.length) return OTHER;
@@ -267,7 +291,7 @@
void getSymbol() {
while (position < src.length &&
- src.codeUnitAt(position) == charCodes.$SPACE) {
+ category(src.codeUnitAt(position)) == WHITESPACE) {
position++;
}
if (position == src.length) {
@@ -311,23 +335,32 @@
do {
position++;
if (position == src.length) break;
- newCat = category(src.codeUnitAt(position));
+ int code = src.codeUnitAt(position);
+ // Special code to disallow ! in non-first position in token, so that
+ // !! parses as two tokens and != parses as one.
+ newCat = (code == charCodes.$BANG) ? NONE : category(code);
} while (!singleCharCategory(cat) &&
(cat == newCat ||
(cat == ALPHA && newCat == NUMERIC) || // eg. level42.
- (cat == NUMERIC && newCat == DOT) || // eg. 3.1415
- (cat == SYMBOL && newCat == RELATION))); // eg. +=.
+ (cat == NUMERIC && newCat == DOT))); // eg. 3.1415
lastCategory = cat;
lastToken = src.substring(lastPosition, position);
if (cat == NUMERIC) {
double.parse(lastToken, (_) {
throw new MiniJsParserError(this, "Unparseable number");
});
- } else if (cat == SYMBOL || cat == RELATION) {
- if (!BINARY_OPERATORS.contains(lastToken) &&
- !UNARY_OPERATORS.contains(lastToken)) {
+ } else if (cat == SYMBOL) {
+ int binaryPrecendence = BINARY_PRECEDENCE[lastToken];
+ if (binaryPrecendence == null && !UNARY_OPERATORS.contains(lastToken)) {
throw new MiniJsParserError(this, "Unknown operator");
}
+ if (isAssignment(lastToken)) lastCategory = ASSIGNMENT;
+ } else if (cat == ALPHA) {
+ if (lastToken == 'typeof' || lastToken == 'void' ||
+ lastToken == 'delete' || lastToken == 'in' ||
+ lastToken == 'instanceof') {
+ lastCategory = SYMBOL;
+ }
}
}
}
@@ -387,6 +420,12 @@
expectCategory(RSQUARE);
}
return new ArrayInitializer(values.length, values);
+ } else if (acceptCategory(HASH)) {
+ if (interpolatedValues == null ||
+ valuesUsed >= interpolatedValues.length) {
+ throw new MiniJsParserError(this, "Too few values for #es");
+ }
+ return interpolatedValues[valuesUsed++];
} else {
throw new MiniJsParserError(this, "Expected primary expression");
}
@@ -412,25 +451,28 @@
Expression parseCall() {
bool constructor = acceptString("new");
Expression receiver = parseMember();
- if (acceptCategory(LPAREN)) {
- final arguments = <Expression>[];
- if (!acceptCategory(RPAREN)) {
- while (true) {
- Expression argument = parseExpression();
- arguments.add(argument);
- if (acceptCategory(RPAREN)) break;
- expectCategory(COMMA);
+ while (true) {
+ if (acceptCategory(LPAREN)) {
+ final arguments = <Expression>[];
+ if (!acceptCategory(RPAREN)) {
+ while (true) {
+ Expression argument = parseExpression();
+ arguments.add(argument);
+ if (acceptCategory(RPAREN)) break;
+ expectCategory(COMMA);
+ }
}
+ receiver = constructor ?
+ new New(receiver, arguments) :
+ new Call(receiver, arguments);
+ constructor = false;
+ } else {
+ if (constructor) {
+ // JS allows new without (), but we don't.
+ throw new MiniJsParserError(this, "Parentheses are required for new");
+ }
+ return receiver;
}
- return constructor ?
- new New(receiver, arguments) :
- new Call(receiver, arguments);
- } else {
- if (constructor) {
- // JS allows new without (), but we don't.
- throw new MiniJsParserError(this, "Parentheses are required for new");
- }
- return receiver;
}
}
@@ -443,71 +485,53 @@
return expression;
}
- Expression parseUnary() {
+ Expression parseUnaryHigh() {
String operator = lastToken;
- if (lastCategory == ALPHA) {
- if (acceptString("typeof") || acceptString("void") ||
- acceptString("delete")) {
- return new Prefix(operator, parsePostfix());
- }
- } else if (lastCategory == SYMBOL) {
- if (acceptString("~") || acceptString("-") || acceptString("++") ||
- acceptString("--") || acceptString("+")) {
- return new Prefix(operator, parsePostfix());
- }
- } else if (acceptString("!")) {
+ if (lastCategory == SYMBOL && UNARY_OPERATORS.contains(operator) &&
+ (acceptString("++") || acceptString("--"))) {
return new Prefix(operator, parsePostfix());
}
return parsePostfix();
}
- Expression parseBinary() {
- // Since we don't handle precedence we don't allow two different symbols
- // without parentheses.
- Expression lhs = parseUnary();
- String firstSymbol = lastToken;
- while (true) {
- String symbol = lastToken;
- if (!acceptCategory(SYMBOL)) return lhs;
- if (!BINARY_OPERATORS.contains(symbol)) {
- throw new MiniJsParserError(this, "Unknown binary operator");
- }
- if (symbol != firstSymbol) {
- throw new MiniJsParserError(
- this, "Mixed $firstSymbol and $symbol operators without ()");
- }
- Expression rhs = parseUnary();
- if (symbol.endsWith("=")) {
- // +=, -=, *= etc.
- lhs = new Assignment.compound(lhs,
- symbol.substring(0, symbol.length - 1),
- rhs);
- } else {
- lhs = new Binary(symbol, lhs, rhs);
- }
+ Expression parseUnaryLow() {
+ String operator = lastToken;
+ if (lastCategory == SYMBOL && UNARY_OPERATORS.contains(operator) &&
+ operator != "++" && operator != "--") {
+ expectCategory(SYMBOL);
+ return new Prefix(operator, parseUnaryLow());
}
+ return parseUnaryHigh();
}
- Expression parseRelation() {
- Expression lhs = parseBinary();
- String relation = lastToken;
- // The lexer returns "=" as a relational operator because it looks a bit
- // like ==, <=, etc. But we don't want to handle it here (that would give
- // it the wrong prescedence), so we just return if we see it.
- if (relation == "=" || !acceptCategory(RELATION)) return lhs;
- Expression rhs = parseBinary();
- if (relation == "<<=" || relation == ">>=" || relation == ">>>=") {
- return new Assignment.compound(lhs,
- relation.substring(0, relation.length - 1),
- rhs);
- } else {
- // Regular binary operation.
- return new Binary(relation, lhs, rhs);
+ Expression parseBinary(int maxPrecedence) {
+ Expression lhs = parseUnaryLow();
+ int minPrecedence;
+ String lastSymbol;
+ Expression rhs; // This is null first time around.
+ while (true) {
+ String symbol = lastToken;
+ if (lastCategory != SYMBOL ||
+ !BINARY_PRECEDENCE.containsKey(symbol) ||
+ BINARY_PRECEDENCE[symbol] > maxPrecedence) {
+ if (rhs == null) return lhs;
+ return new Binary(lastSymbol, lhs, rhs);
+ }
+ expectCategory(SYMBOL);
+ if (rhs == null || BINARY_PRECEDENCE[symbol] >= minPrecedence) {
+ if (rhs != null) lhs = new Binary(lastSymbol, lhs, rhs);
+ minPrecedence = BINARY_PRECEDENCE[symbol];
+ rhs = parseUnaryLow();
+ lastSymbol = symbol;
+ } else {
+ Expression higher = parseBinary(BINARY_PRECEDENCE[symbol]);
+ rhs = new Binary(symbol, rhs, higher);
+ }
}
}
Expression parseConditional() {
- Expression lhs = parseRelation();
+ Expression lhs = parseBinary(HIGHEST_PARSE_BINARY_PRECEDENCE);
if (!acceptCategory(QUERY)) return lhs;
Expression ifTrue = parseAssignment();
expectCategory(COLON);
@@ -518,8 +542,17 @@
Expression parseAssignment() {
Expression lhs = parseConditional();
- if (acceptString("=")) {
- return new Assignment(lhs, parseAssignment());
+ String assignmentOperator = lastToken;
+ if (acceptCategory(ASSIGNMENT)) {
+ Expression rhs = parseAssignment();
+ if (assignmentOperator == "=") {
+ return new Assignment(lhs, rhs);
+ } else {
+ // Handle +=, -=, etc.
+ String operator =
+ assignmentOperator.substring(0, assignmentOperator.length - 1);
+ return new Assignment.compound(lhs, operator, rhs);
+ }
}
return lhs;
}
@@ -552,6 +585,9 @@
throw new MiniJsParserError(
this, "Unparsed junk: ${categoryToString(lastCategory)}");
}
+ if (interpolatedValues != null && valuesUsed != interpolatedValues.length) {
+ throw new MiniJsParserError(this, "Too many values for #es");
+ }
return expression;
}
}
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index 2902003..69caf46 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -734,12 +734,19 @@
* the generic version that contains all possible type checks is
* also stored in this map.
*/
- final Map<String, Collection<ClassElement>> specializedGetInterceptors;
+ final Map<String, Set<ClassElement>> specializedGetInterceptors;
/**
* Set of classes whose methods are intercepted.
*/
- final Set<ClassElement> interceptedClasses;
+ final Set<ClassElement> interceptedClasses = new Set<ClassElement>();
+
+ /**
+ * Set of classes used as mixins on native classes. Methods on these classes
+ * might also be mixed in to non-native classes.
+ */
+ final Set<ClassElement> classesMixedIntoNativeClasses =
+ new Set<ClassElement>();
/**
* Set of classes whose `operator ==` methods handle `null` themselves.
@@ -760,9 +767,7 @@
oneShotInterceptors = new Map<String, Selector>(),
interceptedElements = new Map<SourceString, Set<Element>>(),
rti = new RuntimeTypes(compiler),
- specializedGetInterceptors =
- new Map<String, Collection<ClassElement>>(),
- interceptedClasses = new Set<ClassElement>(),
+ specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) {
emitter = disableEval
? new CodeEmitterNoEvalTask(compiler, namer, generateSourceMap)
@@ -783,7 +788,9 @@
bool isInterceptorClass(ClassElement element) {
if (element == null) return false;
if (element.isNative()) return true;
- return interceptedClasses.contains(element);
+ if (interceptedClasses.contains(element)) return true;
+ if (classesMixedIntoNativeClasses.contains(element)) return true;
+ return false;
}
void addInterceptedSelector(Selector selector) {
@@ -949,7 +956,19 @@
ClassElement cls, Enqueuer enqueuer) {
if (enqueuer.isResolutionQueue) {
cls.ensureResolved(compiler);
- addInterceptorMembers(cls);
+ cls.forEachMember((ClassElement classElement, Element member) {
+ // All methods on [Object] are shadowed by [Interceptor].
+ if (classElement == compiler.objectClass) return;
+ Set<Element> set = interceptedElements.putIfAbsent(
+ member.name, () => new Set<Element>());
+ set.add(member);
+ if (!classElement.isNative()) {
+ MixinApplicationElement mixinApplication = classElement;
+ assert(member.getEnclosingClass() == mixinApplication.mixin);
+ classesMixedIntoNativeClasses.add(mixinApplication.mixin);
+ }
+ },
+ includeSuperMembers: true);
}
}
@@ -958,22 +977,18 @@
TreeElements elements) {
if (enqueuer.isResolutionQueue) {
cls.ensureResolved(compiler);
- addInterceptorMembers(cls);
+ cls.forEachMember((ClassElement classElement, Element member) {
+ // All methods on [Object] are shadowed by [Interceptor].
+ if (classElement == compiler.objectClass) return;
+ Set<Element> set = interceptedElements.putIfAbsent(
+ member.name, () => new Set<Element>());
+ set.add(member);
+ },
+ includeSuperMembers: true);
}
enqueuer.registerInstantiatedClass(cls, elements);
}
- void addInterceptorMembers(ClassElement cls) {
- cls.forEachMember((ClassElement classElement, Element member) {
- // All methods on [Object] are shadowed by [Interceptor].
- if (classElement == compiler.objectClass) return;
- Set<Element> set = interceptedElements.putIfAbsent(
- member.name, () => new Set<Element>());
- set.add(member);
- },
- includeSuperMembers: true);
- }
-
void registerSpecializedGetInterceptor(Set<ClassElement> classes) {
String name = namer.getInterceptorName(getInterceptorMethod, classes);
if (classes.contains(jsInterceptorClass)) {
@@ -1119,8 +1134,12 @@
enqueueInResolution(getExceptionUnwrapper(), elements);
}
- void registerThrow(TreeElements elements) {
- enqueueInResolution(getThrowHelper(), elements);
+ void registerWrapException(TreeElements elements) {
+ enqueueInResolution(getWrapExceptionHelper(), elements);
+ }
+
+ void registerThrowExpression(TreeElements elements) {
+ enqueueInResolution(getThrowExpressionHelper(), elements);
}
void registerLazyField(TreeElements elements) {
@@ -1656,8 +1675,12 @@
return compiler.findHelper(const SourceString('S'));
}
- Element getThrowHelper() {
- return compiler.findHelper(const SourceString(r'$throw'));
+ Element getWrapExceptionHelper() {
+ return compiler.findHelper(const SourceString(r'wrapException'));
+ }
+
+ Element getThrowExpressionHelper() {
+ return compiler.findHelper(const SourceString('throwExpression'));
}
Element getClosureConverter() {
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart
index 2597d91..9397f1a 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/constant_emitter.dart
@@ -80,11 +80,11 @@
jsAst.Expression visitDouble(DoubleConstant constant) {
double value = constant.value;
if (value.isNaN) {
- return new jsAst.LiteralNumber("(0/0)");
+ return js("0/0");
} else if (value == double.INFINITY) {
- return new jsAst.LiteralNumber("(1/0)");
+ return js("1/0");
} else if (value == -double.INFINITY) {
- return new jsAst.LiteralNumber("(-1/0)");
+ return js("-1/0");
} else {
return new jsAst.LiteralNumber("$value");
}
@@ -93,18 +93,18 @@
jsAst.Expression visitTrue(TrueConstant constant) {
if (compiler.enableMinification) {
// Use !0 for true.
- return js["!0"];
+ return js("!0");
} else {
- return new jsAst.LiteralBool(true);
+ return js('true');
}
}
jsAst.Expression visitFalse(FalseConstant constant) {
if (compiler.enableMinification) {
// Use !1 for false.
- return js["!1"];
+ return js("!1");
} else {
- return new jsAst.LiteralBool(false);
+ return js('false');
}
}
@@ -286,8 +286,7 @@
Element helper = backend.getCreateRuntimeType();
String helperName = backend.namer.getName(helper);
DartType type = constant.representedType;
- Element element = type.element;
- String name = backend.rti.getRawTypeRepresentation(type);
+ String name = namer.getRuntimeTypeName(type.element);
jsAst.Expression typeName = new jsAst.LiteralString("'$name'");
return new jsAst.Call(
new jsAst.PropertyAccess.field(
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
index 4d32c89..124a132 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
@@ -142,7 +142,8 @@
void computeRequiredTypeChecks() {
assert(checkedClasses == null && checkedTypedefs == null);
- compiler.codegenWorld.addImplicitChecks(classesUsingTypeVariableTests);
+ backend.rti.addImplicitChecks(compiler.codegenWorld,
+ classesUsingTypeVariableTests);
checkedClasses = new Set<ClassElement>();
checkedTypedefs = new Set<TypedefElement>();
@@ -218,46 +219,46 @@
// function generateAccessor(field, prototype) {
jsAst.Fun fun = js.fun(['field', 'prototype'], [
- js['var len = field.length'],
- js['var code = field.charCodeAt(len - 1)'],
- js['code = ((code >= $RANGE1_FIRST) && (code <= $RANGE1_LAST))'
+ js('var len = field.length'),
+ js('var code = field.charCodeAt(len - 1)'),
+ js('code = ((code >= $RANGE1_FIRST) && (code <= $RANGE1_LAST))'
' ? code - $RANGE1_ADJUST'
' : ((code >= $RANGE2_FIRST) && (code <= $RANGE2_LAST))'
' ? code - $RANGE2_ADJUST'
' : ((code >= $RANGE3_FIRST) && (code <= $RANGE3_LAST))'
' ? code - $RANGE3_ADJUST'
- ' : $NO_FIELD_CODE'],
+ ' : $NO_FIELD_CODE'),
// if (needsAccessor) {
js.if_('code', [
- js['var getterCode = code & 3'],
- js['var setterCode = code >> 2'],
- js['var accessorName = field = field.substring(0, len - 1)'],
+ js('var getterCode = code & 3'),
+ js('var setterCode = code >> 2'),
+ js('var accessorName = field = field.substring(0, len - 1)'),
- js['var divider = field.indexOf(":")'],
+ js('var divider = field.indexOf(":")'),
js.if_('divider > 0', [ // Colon never in first position.
- js['accessorName = field.substring(0, divider)'],
- js['field = field.substring(divider + 1)']
+ js('accessorName = field.substring(0, divider)'),
+ js('field = field.substring(divider + 1)')
]),
// if (needsGetter) {
js.if_('getterCode', [
- js['var args = (getterCode & 2) ? "$receiverParamName" : ""'],
- js['var receiver = (getterCode & 1) ? "this" : "$receiverParamName"'],
- js['var body = "return " + receiver + "." + field'],
- js['prototype["${namer.getterPrefix}" + accessorName] = '
- 'new Function(args, body)']
+ js('var args = (getterCode & 2) ? "$receiverParamName" : ""'),
+ js('var receiver = (getterCode & 1) ? "this" : "$receiverParamName"'),
+ js('var body = "return " + receiver + "." + field'),
+ js('prototype["${namer.getterPrefix}" + accessorName] = '
+ 'new Function(args, body)')
]),
// if (needsSetter) {
js.if_('setterCode', [
- js['var args = (setterCode & 2)'
+ js('var args = (setterCode & 2)'
' ? "$receiverParamName,${_}$valueParamName"'
- ' : "$valueParamName"'],
- js['var receiver = (setterCode & 1) ? "this" : "$receiverParamName"'],
- js['var body = receiver + "." + field + "$_=$_$valueParamName"'],
- js['prototype["${namer.setterPrefix}" + accessorName] = '
- 'new Function(args, body)']
+ ' : "$valueParamName"'),
+ js('var receiver = (setterCode & 1) ? "this" : "$receiverParamName"'),
+ js('var body = receiver + "." + field + "$_=$_$valueParamName"'),
+ js('prototype["${namer.setterPrefix}" + accessorName] = '
+ 'new Function(args, body)')
]),
]),
@@ -288,33 +289,33 @@
// function(cls, fields, prototype) {
var defineClass = js.fun(['cls', 'fields', 'prototype'], [
- js['var constructor'],
+ js('var constructor'),
// if (typeof fields == "function") {
- js.if_(js['typeof fields == "function"'], [
- js['constructor = fields']
+ js.if_(js('typeof fields == "function"'), [
+ js('constructor = fields')
], /* else */ [
- js['var str = "function " + cls + "("'],
- js['var body = ""'],
+ js('var str = "function " + cls + "("'),
+ js('var body = ""'),
// for (var i = 0; i < fields.length; i++) {
js.for_('var i = 0', 'i < fields.length', 'i++', [
// if (i != 0) str += ", ";
- js.if_('i != 0', js['str += ", "']),
+ js.if_('i != 0', js('str += ", "')),
- js['var field = fields[i]'],
- js['field = generateAccessor(field, prototype)'],
- js['str += field'],
- js['body += ("this." + field + " = " + field + ";\\n")']
+ js('var field = fields[i]'),
+ js('field = generateAccessor(field, prototype)'),
+ js('str += field'),
+ js('body += ("this." + field + " = " + field + ";\\n")')
]),
- js['str += (") {" + body + "}\\nreturn " + cls)'],
+ js('str += (") {" + body + "}\\nreturn " + cls)'),
- js['constructor = (new Function(str))()']
+ js('constructor = new Function(str)()')
]),
- js['constructor.prototype = prototype'],
- js['constructor.builtin\$cls = cls'],
+ js('constructor.prototype = prototype'),
+ js('constructor.builtin\$cls = cls'),
// return constructor;
js.return_('constructor')
@@ -323,7 +324,7 @@
// defineClassFunction (it's a local declaration in init()).
return [
generateAccessorFunction,
- js['$generateAccessorHolder = generateAccessor'],
+ js('$generateAccessorHolder = generateAccessor'),
new jsAst.FunctionDeclaration(
new jsAst.VariableDeclaration('defineClass'), defineClass) ];
}
@@ -341,13 +342,13 @@
// TODO(8541): Remove this work around.
return [
- js['var $supportsProtoName = false'],
- js['var tmp = (defineClass("c", ["f?"], {})).prototype'],
+ js('var $supportsProtoName = false'),
+ js('var tmp = (defineClass("c", ["f?"], {})).prototype'),
- js.if_(js['tmp.__proto__'], [
- js['tmp.__proto__ = {}'],
- js.if_(js[r'typeof tmp.get$f != "undefined"'],
- js['$supportsProtoName = true'])
+ js.if_(js('tmp.__proto__'), [
+ js('tmp.__proto__ = {}'),
+ js.if_(js(r'typeof tmp.get$f != "undefined"'),
+ js('$supportsProtoName = true'))
])
];
@@ -498,37 +499,37 @@
var type = 0;
if (useDiffEncoding) {
statements.addAll([
- js['var objectClassObject = '
+ js('var objectClassObject = '
' collectedClasses["${namer.getName(objectClass)}"],'
' shortNames = "$diffEncoding".split(","),'
' nameNumber = 0,'
' diffEncodedString = shortNames[0],'
- ' calculatedShortNames = [0, 1]'], // 0, 1 are args for splice.
+ ' calculatedShortNames = [0, 1]'), // 0, 1 are args for splice.
js.for_('var i = 0', 'i < diffEncodedString.length', 'i++', [
- js['var codes = [],'
+ js('var codes = [],'
' diff = 0,'
- ' digit = diffEncodedString.charCodeAt(i)'],
+ ' digit = diffEncodedString.charCodeAt(i)'),
js.if_('digit == ${$PERIOD}', [
- js['nameNumber = 0'],
- js['digit = diffEncodedString.charCodeAt(++i)']
+ js('nameNumber = 0'),
+ js('digit = diffEncodedString.charCodeAt(++i)')
]),
js.while_('digit <= ${$Z}', [
- js['diff *= 26'],
- js['diff += (digit - ${$A})'],
- js['digit = diffEncodedString.charCodeAt(++i)']
+ js('diff *= 26'),
+ js('diff += (digit - ${$A})'),
+ js('digit = diffEncodedString.charCodeAt(++i)')
]),
- js['diff *= 26'],
- js['diff += (digit - ${$a})'],
- js['nameNumber += diff'],
+ js('diff *= 26'),
+ js('diff += (digit - ${$a})'),
+ js('nameNumber += diff'),
js.for_('var remaining = nameNumber',
'remaining > 0',
- 'remaining = ((remaining / 88) | 0)', [
- js['codes.unshift(${$HASH} + (remaining % 88))']
+ 'remaining = (remaining / 88) | 0', [
+ js('codes.unshift(${$HASH} + remaining % 88)')
]),
- js['calculatedShortNames.push('
- ' String.fromCharCode.apply(String, codes))']
+ js('calculatedShortNames.push('
+ ' String.fromCharCode.apply(String, codes))')
]),
- js['shortNames.splice.apply(shortNames, calculatedShortNames)']
+ js('shortNames.splice.apply(shortNames, calculatedShortNames)')
]);
} else {
// No useDiffEncoding version.
@@ -537,10 +538,10 @@
String longNamesConstant = minify ? "" :
',longNames = "${longs.join(",")}".split(",")';
statements.add(
- js['var objectClassObject = '
+ js('var objectClassObject = '
' collectedClasses["${namer.getName(objectClass)}"],'
' shortNames = "$diffEncoding".split(",")'
- ' $longNamesConstant']);
+ ' $longNamesConstant'));
}
String sliceOffset = '," + (j < $firstNormalSelector ? 1 : 0)';
@@ -553,11 +554,11 @@
statements.addAll([
js.for_('var j = 0', 'j < shortNames.length', 'j++', [
- js['var type = 0'],
- js['var short = shortNames[j]'],
- js.if_('short[0] == "${namer.getterPrefix[0]}"', js['type = 1']),
- js.if_('short[0] == "${namer.setterPrefix[0]}"', js['type = 2']),
- js['$whatToPatch[short] = Function("'
+ js('var type = 0'),
+ js('var short = shortNames[j]'),
+ js.if_('short[0] == "${namer.getterPrefix[0]}"', js('type = 1')),
+ js.if_('short[0] == "${namer.setterPrefix[0]}"', js('type = 2')),
+ js('$whatToPatch[short] = Function("'
'return this.$noSuchMethodName('
'this,'
'${namer.CURRENT_ISOLATE}.$createInvocationMirror(\'"'
@@ -566,7 +567,7 @@
' + type'
' + ",Array.prototype.slice.call(arguments'
'$sliceOffset'
- ' + "),[]))")']
+ ' + "),[]))")')
])
]);
}
@@ -586,15 +587,15 @@
// object and copy over the members.
List<jsAst.Node> statements = [
- js['var pendingClasses = {}'],
+ js('var pendingClasses = {}'),
- js['var hasOwnProperty = Object.prototype.hasOwnProperty'],
+ js('var hasOwnProperty = Object.prototype.hasOwnProperty'),
- // for (var cls in collectedClasses) {
+ // for (var cls in collectedClasses)
js.forIn('cls', 'collectedClasses', [
- // if (hasOwnProperty.call(collectedClasses, cls)) {
+ // if (hasOwnProperty.call(collectedClasses, cls))
js.if_('hasOwnProperty.call(collectedClasses, cls)', [
- js['var desc = collectedClasses[cls]'],
+ js('var desc = collectedClasses[cls]'),
/* The 'fields' are either a constructor function or a
* string encoding fields, constructor and superclass. Get
@@ -603,24 +604,24 @@
* descriptor.
*/
// var fields = desc[""], supr;
- js['var fields = desc[""], supr'],
+ js('var fields = desc[""], supr'),
js.if_('typeof fields == "string"', [
- js['var s = fields.split(";")'],
- js['supr = s[0]'],
- js['fields = s[1] == "" ? [] : s[1].split(",")'],
+ js('var s = fields.split(";")'),
+ js('supr = s[0]'),
+ js('fields = s[1] == "" ? [] : s[1].split(",")'),
], /* else */ [
- js['supr = desc.super']
+ js('supr = desc.super')
]),
- js['isolateProperties[cls] = defineClass(cls, fields, desc)'],
+ js('isolateProperties[cls] = defineClass(cls, fields, desc)'),
// if (supr) pendingClasses[cls] = supr;
- js.if_('supr', js['pendingClasses[cls] = supr'])
+ js.if_('supr', js('pendingClasses[cls] = supr'))
])
]),
- js['var finishedClasses = {}'],
+ js('var finishedClasses = {}'),
// function finishClass(cls) { ... }
buildFinishClass(),
@@ -630,11 +631,11 @@
statements.add(
// for (var cls in pendingClasses) finishClass(cls);
- js.forIn('cls', 'pendingClasses', js['finishClass(cls)'])
+ js.forIn('cls', 'pendingClasses', js('finishClass(cls)'))
);
// function(collectedClasses,
// isolateProperties,
- // existingIsolateProperties) {
+ // existingIsolateProperties)
return js.fun(['collectedClasses', 'isolateProperties',
'existingIsolateProperties'], statements);
}
@@ -646,37 +647,35 @@
// TODO(8540): Remove this work around.
/* Opera does not support 'getOwnPropertyNames'. Therefore we use
hasOwnProperty instead. */
- js['var hasOwnProperty = Object.prototype.hasOwnProperty'],
+ js('var hasOwnProperty = Object.prototype.hasOwnProperty'),
// if (hasOwnProperty.call(finishedClasses, cls)) return;
js.if_('hasOwnProperty.call(finishedClasses, cls)',
js.return_()),
- js['finishedClasses[cls] = true'],
+ js('finishedClasses[cls] = true'),
- js['var superclass = pendingClasses[cls]'],
+ js('var superclass = pendingClasses[cls]'),
// The superclass is only false (empty string) for Dart's Object class.
// The minifier together with noSuchMethod can put methods on the
// Object.prototype object, and they show through here, so we check that
// we have a string.
js.if_('!superclass || typeof superclass != "string"', js.return_()),
- js['finishClass(superclass)'],
- js['var constructor = isolateProperties[cls]'],
- js['var superConstructor = isolateProperties[superclass]'],
+ js('finishClass(superclass)'),
+ js('var constructor = isolateProperties[cls]'),
+ js('var superConstructor = isolateProperties[superclass]'),
- // if (!superConstructor)
- // superConstructor = existingIsolateProperties[superclass];
- js.if_(js['superConstructor'].not,
- js['superConstructor'].assign(
- js['existingIsolateProperties'][js['superclass']])),
+ js.if_(js('!superConstructor'),
+ js('superConstructor ='
+ 'existingIsolateProperties[superclass]')),
- js['var prototype = constructor.prototype'],
+ js('var prototype = constructor.prototype'),
// if ($supportsProtoName) {
js.if_(supportsProtoName, [
- js['prototype.__proto__ = superConstructor.prototype'],
- js['prototype.constructor = constructor'],
+ js('prototype.__proto__ = superConstructor.prototype'),
+ js('prototype.constructor = constructor'),
], /* else */ [
// function tmp() {};
@@ -684,11 +683,11 @@
new jsAst.VariableDeclaration('tmp'),
js.fun([], [])),
- js['tmp.prototype = superConstructor.prototype'],
- js['var newPrototype = new tmp()'],
+ js('tmp.prototype = superConstructor.prototype'),
+ js('var newPrototype = new tmp()'),
- js['constructor.prototype = newPrototype'],
- js['newPrototype.constructor = constructor'],
+ js('constructor.prototype = newPrototype'),
+ js('newPrototype.constructor = constructor'),
// for (var member in prototype) {
js.forIn('member', 'prototype', [
@@ -698,7 +697,7 @@
// if (hasOwnProperty.call(prototype, member)) {
js.if_('hasOwnProperty.call(prototype, member)', [
- js['newPrototype[member] = prototype[member]']
+ js('newPrototype[member] = prototype[member]')
])
])
@@ -736,41 +735,40 @@
List copyFinishClasses = [];
if (needsDefineClass) {
copyFinishClasses.add(
- // newIsolate.$finishClasses = oldIsolate.$finishClasses;
- js['newIsolate'][finishClassesProperty].assign(
- js['oldIsolate'][finishClassesProperty]));
+ js('newIsolate.$finishClassesProperty = '
+ ' oldIsolate.$finishClassesProperty'));
}
// function(oldIsolate) {
return js.fun('oldIsolate', [
- js['var isolateProperties = oldIsolate.${namer.isolatePropertiesName}'],
+ js('var isolateProperties = oldIsolate.${namer.isolatePropertiesName}'),
- js[r'isolateProperties.$currentScript ='
+ js(r'isolateProperties.$currentScript ='
'typeof document == "object" ?'
'(document.currentScript ||'
'document.scripts[document.scripts.length - 1]) :'
- 'null'],
+ 'null'),
- js['var isolatePrototype = oldIsolate.prototype'],
- js['var str = "{\\n"'],
- js['str += '
- '"var properties = $isolate.${namer.isolatePropertiesName};\\n"'],
- js['var hasOwnProperty = Object.prototype.hasOwnProperty'],
+ js('var isolatePrototype = oldIsolate.prototype'),
+ js('var str = "{\\n"'),
+ js('str += '
+ '"var properties = $isolate.${namer.isolatePropertiesName};\\n"'),
+ js('var hasOwnProperty = Object.prototype.hasOwnProperty'),
// for (var staticName in isolateProperties) {
js.forIn('staticName', 'isolateProperties', [
js.if_('hasOwnProperty.call(isolateProperties, staticName)', [
- js['str += ("this." + staticName + "= properties." + staticName + '
- '";\\n")']
+ js('str += ("this." + staticName + "= properties." + staticName + '
+ '";\\n")')
])
]),
- js['str += "}\\n"'],
+ js('str += "}\\n"'),
- js['var newIsolate = new Function(str)'],
- js['newIsolate.prototype = isolatePrototype'],
- js['isolatePrototype.constructor = newIsolate'],
- js['newIsolate.${namer.isolatePropertiesName} = isolateProperties'],
+ js('var newIsolate = new Function(str)'),
+ js('newIsolate.prototype = isolatePrototype'),
+ js('isolatePrototype.constructor = newIsolate'),
+ js('newIsolate.${namer.isolatePropertiesName} = isolateProperties'),
]..addAll(copyFinishClasses)
..addAll([
@@ -786,7 +784,7 @@
var parameters = <String>['prototype', 'staticName', 'fieldName',
'getterName', 'lazyValue'];
return js.fun(parameters, [
- js['var getter = new Function("{ return $isolate." + fieldName + ";}")'],
+ js('var getter = new Function("{ return $isolate." + fieldName + ";}")'),
]..addAll(addLazyInitializerLogic())
);
}
@@ -796,38 +794,38 @@
String cyclicThrow = namer.isolateAccess(backend.getCyclicThrowHelper());
return [
- js['var sentinelUndefined = {}'],
- js['var sentinelInProgress = {}'],
- js['prototype[fieldName] = sentinelUndefined'],
+ js('var sentinelUndefined = {}'),
+ js('var sentinelInProgress = {}'),
+ js('prototype[fieldName] = sentinelUndefined'),
- // prototype[getterName] = function() {
- js['prototype'][js['getterName']].assign(js.fun([], [
- js['var result = $isolate[fieldName]'],
+ // prototype[getterName] = function()
+ js('prototype[getterName] = #', js.fun([], [
+ js('var result = $isolate[fieldName]'),
- // try {
+ // try
js.try_([
js.if_('result === sentinelUndefined', [
- js['$isolate[fieldName] = sentinelInProgress'],
+ js('$isolate[fieldName] = sentinelInProgress'),
- // try {
+ // try
js.try_([
- js['result = $isolate[fieldName] = lazyValue()'],
+ js('result = $isolate[fieldName] = lazyValue()'),
], finallyPart: [
// Use try-finally, not try-catch/throw as it destroys the
// stack trace.
- // if (result === sentinelUndefined) {
+ // if (result === sentinelUndefined)
js.if_('result === sentinelUndefined', [
- // if ($isolate[fieldName] === sentinelInProgress) {
+ // if ($isolate[fieldName] === sentinelInProgress)
js.if_('$isolate[fieldName] === sentinelInProgress', [
- js['$isolate[fieldName] = null'],
+ js('$isolate[fieldName] = null'),
])
])
])
], /* else */ [
js.if_('result === sentinelInProgress',
- js['$cyclicThrow(staticName)']
+ js('$cyclicThrow(staticName)')
)
]),
@@ -835,7 +833,7 @@
js.return_('result')
], finallyPart: [
- js['$isolate[getterName] = getter']
+ js('$isolate[getterName] = getter')
])
]))
];
@@ -846,21 +844,19 @@
return defineClassFunction
..addAll(buildProtoSupportCheck())
..addAll([
- js[finishClassesName].assign(finishClassesFunction)
+ js('$finishClassesName = #', finishClassesFunction)
]);
}
List buildLazyInitializerFunctionIfNecessary() {
if (!needsLazyInitializer) return [];
- // $lazyInitializerName = $lazyInitializerFunction
- return [js[lazyInitializerName].assign(lazyInitializerFunction)];
+ return [js('$lazyInitializerName = #', lazyInitializerFunction)];
}
List buildFinishIsolateConstructor() {
return [
- // $finishIsolateConstructorName = $finishIsolateConstructorFunction
- js[finishIsolateConstructorName].assign(finishIsolateConstructorFunction)
+ js('$finishIsolateConstructorName = #', finishIsolateConstructorFunction)
];
}
@@ -922,7 +918,7 @@
if (isInterceptedMethod) {
count++;
parametersBuffer[0] = new jsAst.Parameter(receiverArgumentName);
- argumentsBuffer[0] = js[receiverArgumentName];
+ argumentsBuffer[0] = js(receiverArgumentName);
}
int optionalParameterStart = positionalArgumentCount + extraArgumentCount;
@@ -937,14 +933,14 @@
assert(jsName != receiverArgumentName);
if (count < optionalParameterStart) {
parametersBuffer[count] = new jsAst.Parameter(jsName);
- argumentsBuffer[count] = js[jsName];
+ argumentsBuffer[count] = js(jsName);
} else {
int index = names.indexOf(element.name);
if (index != -1) {
indexOfLastOptionalArgumentInParameters = count;
// The order of the named arguments is not the same as the
// one in the real method (which is in Dart source order).
- argumentsBuffer[count] = js[jsName];
+ argumentsBuffer[count] = js(jsName);
parametersBuffer[optionalParameterStart + index] =
new jsAst.Parameter(jsName);
// Note that [elements] may be null for a synthesized [member].
@@ -974,7 +970,7 @@
parametersBuffer, argumentsBuffer,
indexOfLastOptionalArgumentInParameters);
} else {
- body = [js.return_(js['this'][namer.getName(member)](argumentsBuffer))];
+ body = [js.return_(js('this')[namer.getName(member)](argumentsBuffer))];
}
jsAst.Fun function = js.fun(parametersBuffer, body);
@@ -1170,21 +1166,6 @@
}
}
- // TODO(kasperl): We should make sure to only emit one version of
- // overridden methods. Right now, we rely on the ordering so the
- // methods pulled in from mixins are replaced with the members
- // from the class definition.
-
- // If the class is a native class, we have to add the instance
- // members defined in the non-native mixin applications used by
- // the class.
- visitNativeMixins(classElement, (MixinApplicationElement mixin) {
- mixin.forEachMember(
- visitMember,
- includeBackendMembers: true,
- includeSuperMembers: false);
- });
-
classElement.implementation.forEachMember(
visitMember,
includeBackendMembers: true,
@@ -1199,7 +1180,7 @@
if (nativeEmitter.requiresNativeIsCheck(other)) {
code = js.fun([], [js.return_(true)]);
} else {
- code = new jsAst.LiteralBool(true);
+ code = js('true');
}
builder.addProperty(namer.operatorIs(other), code);
}
@@ -1270,7 +1251,7 @@
void maybeGenerateHolder(ClassElement cls) {
if (!needsHolder(cls)) return;
String holder = namer.isolateAccess(cls);
- String name = namer.getName(cls);
+ String name = namer.getRuntimeTypeName(cls);
buffer.write('$holder$_=$_{builtin\$cls:$_"$name"');
buffer.write('}$N');
}
@@ -1295,22 +1276,6 @@
}
}
- void visitNativeMixins(ClassElement classElement,
- void visit(MixinApplicationElement mixinApplication)) {
- if (!classElement.isNative()) return;
- // Use recursion to make sure to visit the superclasses before the
- // subclasses. Once we start keeping track of the emitted fields
- // and members, we're going to want to visit these in the other
- // order so we get the most specialized definition first.
- void recurse(ClassElement cls) {
- if (cls == null || !cls.isMixinApplication) return;
- recurse(cls.superclass);
- assert(!cls.isNative());
- visit(cls);
- }
- recurse(classElement.superclass);
- }
-
/**
* Documentation wanted -- johnniwinther
*
@@ -1388,15 +1353,6 @@
// fields pulled in from mixins are replaced with the fields from
// the class definition.
- // If the class is a native class, we have to add the fields
- // defined in the non-native mixin applications used by the class.
- visitNativeMixins(classElement, (MixinApplicationElement mixin) {
- mixin.forEachInstanceField(
- visitField,
- includeBackendMembers: true,
- includeSuperMembers: false);
- });
-
// If a class is not instantiated then we add the field just so we can
// generate the field getter/setter dynamically. Since this is only
// allowed on fields that are in [classElement] we don't need to visit
@@ -1404,7 +1360,7 @@
classElement.implementation.forEachInstanceField(
visitField,
includeBackendMembers: true,
- includeSuperMembers: isInstantiated && !classElement.isNative());
+ includeSuperMembers: isInstantiated);
}
void generateGetter(Element member, String fieldName, String accessorName,
@@ -1416,7 +1372,7 @@
? ['receiver']
: [];
builder.addProperty(getterName,
- js.fun(args, js.return_(js['$receiver.$fieldName'])));
+ js.fun(args, js.return_(js('$receiver.$fieldName'))));
}
void generateSetter(Element member, String fieldName, String accessorName,
@@ -1428,7 +1384,7 @@
? ['receiver', 'v']
: ['v'];
builder.addProperty(setterName,
- js.fun(args, js[receiver][fieldName].assign('v')));
+ js.fun(args, js('$receiver.$fieldName = v')));
}
bool canGenerateCheckedSetter(Element member) {
@@ -1453,7 +1409,7 @@
FunctionElement helperElement
= backend.getCheckedModeHelper(type, typeCast: false);
String helperName = namer.isolateAccess(helperElement);
- List<jsAst.Expression> arguments = <jsAst.Expression>[js['v']];
+ List<jsAst.Expression> arguments = <jsAst.Expression>[js('v')];
if (helperElement.computeSignature(compiler).parameterCount != 1) {
arguments.add(js.string(namer.operatorIs(type.element)));
}
@@ -1466,7 +1422,7 @@
: ['v'];
builder.addProperty(setterName,
js.fun(args,
- js[receiver][fieldName].assign(js[helperName](arguments))));
+ js('$receiver.$fieldName = #', js(helperName)(arguments))));
}
void emitClassConstructor(ClassElement classElement, ClassBuilder builder) {
@@ -1589,12 +1545,7 @@
needsDefineClass = true;
String className = namer.getName(classElement);
- // Find the first non-native superclass.
ClassElement superclass = classElement.superclass;
- while (superclass != null && superclass.isNative()) {
- superclass = superclass.superclass;
- }
-
String superName = "";
if (superclass != null) {
superName = namer.getName(superclass);
@@ -1610,7 +1561,7 @@
emitInstanceMembers(classElement, builder);
jsAst.Expression init =
- js[classesCollector][className].assign(builder.toObjectInitializer());
+ js('$classesCollector.$className = #', builder.toObjectInitializer());
buffer.write(jsAst.prettyPrint(init, compiler));
buffer.write('$N$n');
}
@@ -1724,17 +1675,6 @@
generateInterfacesIsTests(interfaceType.element, emitIsTest,
emitSubstitution, generated);
}
-
- // For native classes, we also have to run through their mixin
- // applications and make sure we deal with 'is' tests correctly
- // for those.
- visitNativeMixins(cls, (MixinApplicationElement mixin) {
- for (DartType interfaceType in mixin.interfaces) {
- ClassElement interfaceElement = interfaceType.element;
- generateInterfacesIsTests(interfaceType.element, emitIsTest,
- emitSubstitution, generated);
- }
- });
}
/**
@@ -1784,7 +1724,7 @@
// interceptors are needed.
Set<ClassElement> needed = new Set<ClassElement>();
backend.specializedGetInterceptors.forEach(
- (_, Collection<ClassElement> elements) {
+ (_, Iterable<ClassElement> elements) {
needed.addAll(elements);
}
);
@@ -1833,7 +1773,7 @@
String name,
jsAst.Expression functionExpression) {
jsAst.Expression assignment =
- js[isolateProperties][name].assign(functionExpression);
+ js('$isolateProperties.$name = #', functionExpression);
buffer.write(jsAst.prettyPrint(assignment, compiler));
buffer.write('$N$n');
}
@@ -1890,7 +1830,7 @@
addParameterStubs(callElement, (String name, jsAst.Expression value) {
jsAst.Expression assignment =
- js[isolateProperties][staticName][name].assign(value);
+ js('$isolateProperties.$staticName.$name = #', value);
buffer.write(jsAst.prettyPrint(assignment.toStatement(), compiler));
buffer.write('$N');
});
@@ -2012,28 +1952,28 @@
List<String> parameters = <String>[];
List<jsAst.Expression> arguments = <jsAst.Expression>[];
if (inInterceptor) {
- arguments.add(js['this'][fieldNames[2]]);
+ arguments.add(js('this')[fieldNames[2]]);
}
for (int i = 0; i < parameterCount; i++) {
String name = 'p$i';
parameters.add(name);
- arguments.add(js[name]);
+ arguments.add(js(name));
}
jsAst.Expression fun = js.fun(
parameters,
js.return_(
- js['this'][fieldNames[0]][js['this'][fieldNames[1]]](arguments)));
+ js('this')[fieldNames[0]][js('this')[fieldNames[1]]](arguments)));
boundClosureBuilder.addProperty(invocationName, fun);
addParameterStubs(callElement, boundClosureBuilder.addProperty);
typedefChecks.forEach((Element typedef) {
String operator = namer.operatorIs(typedef);
- boundClosureBuilder.addProperty(operator, new jsAst.LiteralBool(true));
+ boundClosureBuilder.addProperty(operator, js('true'));
});
boundClosures.add(
- js[classesCollector][mangledName].assign(
+ js('$classesCollector.$mangledName = #',
boundClosureBuilder.toObjectInitializer()));
closureClass = namer.isolateAccess(closureClassElement);
@@ -2050,16 +1990,16 @@
List<String> parameters = <String>[];
List<jsAst.Expression> arguments = <jsAst.Expression>[];
- arguments.add(js['this']);
+ arguments.add(js('this'));
arguments.add(js.string(targetName));
if (inInterceptor) {
parameters.add(extraArg);
- arguments.add(js[extraArg]);
+ arguments.add(js(extraArg));
}
jsAst.Expression getterFunction = js.fun(
parameters,
- js.return_(js[closureClass].newWith(arguments)));
+ js.return_(js(closureClass).newWith(arguments)));
defineStub(getterName, getterFunction);
}
@@ -2083,15 +2023,15 @@
jsAst.Expression buildGetter() {
if (member.isGetter()) {
String getterName = namer.getterName(member);
- return js['this'][getterName](
+ return js('this')[getterName](
isInterceptedMethod
- ? <jsAst.Expression>[js[receiverArgumentName]]
+ ? <jsAst.Expression>[js(receiverArgumentName)]
: <jsAst.Expression>[]);
} else {
String fieldName = member.hasFixedBackendName()
? member.fixedBackendName()
: namer.instanceFieldName(member);
- return js['this'][fieldName];
+ return js('this')[fieldName];
}
}
@@ -2119,7 +2059,7 @@
for (int i = 0; i < selector.argumentCount; i++) {
String name = 'arg$i';
parameters.add(new jsAst.Parameter(name));
- arguments.add(js[name]);
+ arguments.add(js(name));
}
jsAst.Fun function = js.fun(
@@ -2141,7 +2081,7 @@
compiler.withCurrentElement(element, () {
Constant initialValue = handler.getInitialValueFor(element);
jsAst.Expression init =
- js[isolateProperties][namer.getName(element)].assign(
+ js('$isolateProperties.${namer.getName(element)} = #',
constantEmitter.referenceInInitializationContext(initialValue));
buffer.write(jsAst.prettyPrint(init, compiler));
buffer.write('$N');
@@ -2168,7 +2108,7 @@
// The name is used for error reporting. The 'initial' must be a
// closure that constructs the initial value.
List<jsAst.Expression> arguments = <jsAst.Expression>[];
- arguments.add(js[isolateProperties]);
+ arguments.add(js(isolateProperties));
arguments.add(js.string(element.name.slowToString()));
arguments.add(js.string(namer.getName(element)));
arguments.add(js.string(namer.getLazyInitializerName(element)));
@@ -2177,7 +2117,7 @@
if (getter != null) {
arguments.add(getter);
}
- jsAst.Expression init = js[lazyInitializerName](arguments);
+ jsAst.Expression init = js(lazyInitializerName)(arguments);
buffer.write(jsAst.prettyPrint(init, compiler));
buffer.write("$N");
}
@@ -2210,7 +2150,7 @@
}
CodeBuffer buffer =
bufferForElement(constant.computeType(compiler).element, eagerBuffer);
- jsAst.Expression init = js[isolateProperties][name].assign(
+ jsAst.Expression init = js('$isolateProperties.$name = #',
constantInitializerExpression(constant));
buffer.write(jsAst.prettyPrint(init, compiler));
buffer.write('$N');
@@ -2401,15 +2341,15 @@
compiler.createInvocationMirrorElement);
assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD));
- jsAst.Expression expression = js['this.$noSuchMethodName'](
- [js['this'],
- js[namer.CURRENT_ISOLATE][createInvocationMirror]([
+ jsAst.Expression expression = js('this.$noSuchMethodName')(
+ [js('this'),
+ js(namer.CURRENT_ISOLATE)[createInvocationMirror]([
js.string(compiler.enableMinification ?
internalName : methodName),
js.string(internalName),
type,
new jsAst.ArrayInitializer.from(
- parameters.map((param) => js[param.name]).toList()),
+ parameters.map((param) => js(param.name)).toList()),
new jsAst.ArrayInitializer.from(argNames)])]);
parameters = backend.isInterceptedName(selector.name)
? ([new jsAst.Parameter('\$receiver')]..addAll(parameters))
@@ -2475,9 +2415,9 @@
void emitGetInterceptorMethod(CodeBuffer buffer,
String key,
- Collection<ClassElement> classes) {
+ Iterable<ClassElement> classes) {
jsAst.Statement buildReturnInterceptor(ClassElement cls) {
- return js.return_(js[namer.isolateAccess(cls)]['prototype']);
+ return js.return_(js(namer.isolateAccess(cls))['prototype']);
}
/**
@@ -2488,7 +2428,7 @@
jsAst.Expression condition;
assert(backend.isInterceptorClass(cls));
if (cls == backend.jsBoolClass) {
- condition = js['(typeof receiver) == "boolean"'];
+ condition = js('(typeof receiver) == "boolean"');
} else if (cls == backend.jsIntClass ||
cls == backend.jsDoubleClass ||
cls == backend.jsNumberClass) {
@@ -2497,13 +2437,13 @@
cls == backend.jsMutableArrayClass ||
cls == backend.jsFixedArrayClass ||
cls == backend.jsExtendableArrayClass) {
- condition = js['receiver.constructor == Array'];
+ condition = js('receiver.constructor == Array');
} else if (cls == backend.jsStringClass) {
- condition = js['(typeof receiver) == "string"'];
+ condition = js('(typeof receiver) == "string"');
} else if (cls == backend.jsNullClass) {
- condition = js['receiver == null'];
+ condition = js('receiver == null');
} else if (cls == backend.jsFunctionClass) {
- condition = js['(typeof receiver) == "function"'];
+ condition = js('(typeof receiver) == "function"');
} else {
throw 'internal error';
}
@@ -2563,7 +2503,7 @@
hasDouble ? backend.jsDoubleClass : backend.jsNumberClass);
if (hasInt) {
- jsAst.Expression isInt = js['Math.floor(receiver) == receiver'];
+ jsAst.Expression isInt = js('Math.floor(receiver) == receiver');
whenNumber = js.block([
js.if_(isInt, buildReturnInterceptor(backend.jsIntClass)),
returnNumberClass]);
@@ -2585,7 +2525,7 @@
// TypeError which is later identified as a null-error by
// [unwrapException] in js_helper.dart.
block.statements.add(js.if_('receiver == null',
- js.return_(js['receiver'])));
+ js.return_(js('receiver'))));
}
if (hasFunction) {
block.statements.add(buildInterceptorCheck(backend.jsFunctionClass));
@@ -2602,18 +2542,15 @@
if (hasNative) {
block.statements.add(
js.if_(
- js['(typeof receiver) != "object"'],
- js.return_(js['receiver'])));
+ js('(typeof receiver) != "object"'),
+ js.return_(js('receiver'))));
// if (receiver instanceof $.Object) return receiver;
// return $.getNativeInterceptor(receiver);
block.statements.add(
- js.if_(
- new jsAst.Binary(
- "instanceof",
- js['receiver'],
- js[namer.isolateAccess(compiler.objectClass)]),
- js.return_(js['receiver'])));
+ js.if_(js('receiver instanceof #',
+ js(namer.isolateAccess(compiler.objectClass))),
+ js.return_(js('receiver'))));
// TODO(sra): Fold this 'Object' check into the `getNativeInterceptor`
// check by patching `Object.prototype` with a special hook function.
@@ -2621,20 +2558,20 @@
// 'holders' are not Dart classes.
block.statements.add(
js.if_(
- js['Object.getPrototypeOf(receiver) === Object.prototype'],
+ js('Object.getPrototypeOf(receiver) === Object.prototype'),
buildReturnInterceptor(backend.jsInterceptorClass)));
block.statements.add(
js.return_(
- js[namer.isolateAccess(backend.getNativeInterceptorMethod)](
+ js(namer.isolateAccess(backend.getNativeInterceptorMethod))(
['receiver'])));
} else {
- block.statements.add(js.return_(js['receiver']));
+ block.statements.add(js.return_(js('receiver')));
}
buffer.write(jsAst.prettyPrint(
- js[isolateProperties][key].assign(js.fun(['receiver'], block)),
+ js('$isolateProperties.$key = #', js.fun(['receiver'], block)),
compiler));
buffer.write(N);
}
@@ -2645,7 +2582,7 @@
void emitGetInterceptorMethods(CodeBuffer buffer) {
var specializedGetInterceptors = backend.specializedGetInterceptors;
for (String name in specializedGetInterceptors.keys.toList()..sort()) {
- Collection<ClassElement> classes = specializedGetInterceptors[name];
+ Iterable<ClassElement> classes = specializedGetInterceptors[name];
emitGetInterceptorMethod(buffer, name, classes);
}
}
@@ -2708,21 +2645,20 @@
jsAst.Statement tryOptimizeOneShotInterceptor(Selector selector,
Set<ClassElement> classes) {
jsAst.Expression isNumber(String variable) {
- return js[variable].typeof.equals(js.string('number'));
+ return js('typeof $variable == "number"');
}
jsAst.Expression isNotObject(String variable) {
- return js[variable].typeof.equals(js.string('object')).not;
+ return js('typeof $variable != "object"');
}
jsAst.Expression isInt(String variable) {
- jsAst.Expression receiver = js[variable];
return isNumber(variable).binary('&&',
- js['Math']['floor'](receiver).equals(receiver));
+ js('Math.floor($variable) == $variable'));
}
jsAst.Expression tripleShiftZero(jsAst.Expression receiver) {
- return receiver.binary('>>>', js.toExpression(0));
+ return receiver.binary('>>>', js('0'));
}
if (selector.isOperator()) {
@@ -2735,12 +2671,10 @@
// }
// :].
List<jsAst.Statement> body = <jsAst.Statement>[];
- body.add(js.if_('receiver == null',
- js.return_(js['a0'].equals(new jsAst.LiteralNull()))));
+ body.add(js.if_('receiver == null', js.return_(js('a0 == null'))));
body.add(js.if_(
isNotObject('receiver'),
- js.return_(js['a0'].equals(new jsAst.LiteralNull()).not.binary(
- '&&', js['receiver'].strictEquals(js['a0'])))));
+ js.return_(js('a0 != null && receiver === a0'))));
return new jsAst.Block(body);
}
if (!classes.contains(backend.jsIntClass)
@@ -2752,7 +2686,7 @@
// The following operators do not map to a JavaScript
// operator.
if (name != '~/' && name != '<<' && name != '%' && name != '>>') {
- jsAst.Expression result = js['receiver'].binary(name, js['a0']);
+ jsAst.Expression result = js('receiver').binary(name, js('a0'));
if (name == '&' || name == '|' || name == '^') {
result = tripleShiftZero(result);
}
@@ -2768,15 +2702,12 @@
// operator~ does not map to a JavaScript operator.
// Unfolds to:
// [: if (typeof receiver == "number") return -receiver:].
- return js.if_(
- isNumber('receiver'),
- js.return_(new jsAst.Prefix('-', js['receiver'])));
+ return js.if_(isNumber('receiver'),
+ js.return_(js('-receiver')));
} else {
assert(name == '~');
- return js.if_(
- isInt('receiver'),
- js.return_(
- tripleShiftZero(new jsAst.Prefix(name, js['receiver']))));
+ return js.if_(isInt('receiver'),
+ js.return_(js('~receiver >>> 0')));
}
} else if (selector.isIndex() || selector.isIndexSet()) {
// For an index operation, this code generates:
@@ -2808,16 +2739,12 @@
if (!containsArray && !containsString) {
return null;
}
- jsAst.Expression receiver = js['receiver'];
- jsAst.Expression arg0 = js['a0'];
- jsAst.Expression isIntAndAboveZero =
- arg0.binary('>>>', js.toExpression(0)).strictEquals(arg0);
- jsAst.Expression belowLength = arg0.binary('<', receiver['length']);
- jsAst.Expression arrayCheck = receiver['constructor'].equals('Array');
+ jsAst.Expression isIntAndAboveZero = js('a0 >>> 0 === a0');
+ jsAst.Expression belowLength = js('a0 < receiver.length');
+ jsAst.Expression arrayCheck = js('receiver.constructor == Array');
if (selector.isIndex()) {
- jsAst.Expression stringCheck =
- receiver.typeof.equals(js.string('string'));
+ jsAst.Expression stringCheck = js('typeof receiver == "string"');
jsAst.Expression typeCheck;
if (containsArray) {
if (containsString) {
@@ -2832,13 +2759,13 @@
return js.if_(typeCheck,
js.if_(isIntAndAboveZero.binary('&&', belowLength),
- js.return_(receiver[arg0])));
+ js.return_(js('receiver[a0]'))));
} else {
jsAst.Expression isImmutableArray = arrayCheck.binary(
- '&&', receiver[r'immutable$list'].not);
+ '&&', js(r'!receiver.immutable$list'));
return js.if_(isImmutableArray.binary(
'&&', isIntAndAboveZero.binary('&&', belowLength)),
- js.return_(receiver[arg0].assign(js['a1'])));
+ js.return_(js('receiver[a0] = a1')));
}
}
return null;
@@ -2857,16 +2784,16 @@
List<jsAst.Parameter> parameters = <jsAst.Parameter>[];
List<jsAst.Expression> arguments = <jsAst.Expression>[];
parameters.add(new jsAst.Parameter('receiver'));
- arguments.add(js['receiver']);
+ arguments.add(js('receiver'));
if (selector.isSetter()) {
parameters.add(new jsAst.Parameter('value'));
- arguments.add(js['value']);
+ arguments.add(js('value'));
} else {
for (int i = 0; i < selector.argumentCount; i++) {
String argName = 'a$i';
parameters.add(new jsAst.Parameter(argName));
- arguments.add(js[argName]);
+ arguments.add(js(argName));
}
}
@@ -2879,15 +2806,13 @@
String invocationName = backend.namer.invocationName(selector);
body.add(js.return_(
- js[isolateProperties][getInterceptorName]('receiver')[invocationName](
+ js(isolateProperties)[getInterceptorName]('receiver')[invocationName](
arguments)));
- jsAst.Fun function = js.fun(parameters, body);
+ jsAst.Expression assignment =
+ js('$isolateProperties.$name = #', js.fun(parameters, body));
- jsAst.PropertyAccess property =
- js[isolateProperties][name];
-
- buffer.write(jsAst.prettyPrint(property.assign(function), compiler));
+ buffer.write(jsAst.prettyPrint(assignment, compiler));
buffer.write(N);
}
}
@@ -2902,7 +2827,6 @@
void emitInterceptedNames(CodeBuffer buffer) {
if (!compiler.enabledInvokeOn) return;
String name = backend.namer.getName(backend.interceptedNames);
- jsAst.PropertyAccess property = js[isolateProperties][name];
int index = 0;
List<jsAst.ArrayElement> elements = backend.usedInterceptors.map(
@@ -2914,13 +2838,15 @@
backend.usedInterceptors.length,
elements);
- buffer.write(jsAst.prettyPrint(property.assign(array), compiler));
+ jsAst.Expression assignment = js('$isolateProperties.$name = #', array);
+
+ buffer.write(jsAst.prettyPrint(assignment, compiler));
buffer.write(N);
}
void emitInitFunction(CodeBuffer buffer) {
jsAst.Fun fun = js.fun([], [
- js['$isolateProperties = {}'],
+ js('$isolateProperties = {}'),
]
..addAll(buildDefineClassAndFinishClassFunctionsIfNecessary())
..addAll(buildLazyInitializerFunctionIfNecessary())
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart b/sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart
index 41ec3e8..9814102 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart
@@ -67,15 +67,15 @@
return [new jsAst.FunctionDeclaration(
new jsAst.VariableDeclaration('defineClass'),
js.fun(['cls', 'constructor', 'prototype'],
- [js[r'constructor.prototype = prototype'],
- js[r'constructor.builtin$cls = cls'],
+ [js(r'constructor.prototype = prototype'),
+ js(r'constructor.builtin$cls = cls'),
js.return_('constructor')]))];
}
List buildProtoSupportCheck() {
// We don't modify the prototypes in CSP mode. Therefore we can have an
// easier prototype-check.
- return [js['var $supportsProtoName = !(!({}.__proto__))']];
+ return [js('var $supportsProtoName = !!{}.__proto__')];
}
jsAst.Expression buildConstructor(String mangledName,
@@ -83,7 +83,7 @@
return new jsAst.NamedFunction(
new jsAst.VariableDeclaration(mangledName),
js.fun(fieldNames, fieldNames.map(
- (name) => js['this.$name = $name']).toList()));
+ (name) => js('this.$name = $name')).toList()));
}
jsAst.Expression buildUnusedConstructor(String mangledName) {
@@ -104,7 +104,7 @@
jsAst.Expression buildLazyInitializedGetter(VariableElement element) {
String isolate = namer.CURRENT_ISOLATE;
String name = namer.getName(element);
- return js.fun([], js.return_(js['$isolate.$name']));
+ return js.fun([], js.return_(js('$isolate.$name')));
}
jsAst.Fun get lazyInitializerFunction {
@@ -122,25 +122,25 @@
// We also copy over old values like the prototype, and the
// isolateProperties themselves.
return js.fun('oldIsolate', [
- js['var isolateProperties = oldIsolate.${namer.isolatePropertiesName}'],
+ js('var isolateProperties = oldIsolate.${namer.isolatePropertiesName}'),
new jsAst.FunctionDeclaration(
new jsAst.VariableDeclaration('Isolate'),
js.fun([], [
- js['var hasOwnProperty = Object.prototype.hasOwnProperty'],
+ js('var hasOwnProperty = Object.prototype.hasOwnProperty'),
js.forIn('staticName', 'isolateProperties',
js.if_('hasOwnProperty.call(isolateProperties, staticName)',
- js['this[staticName] = isolateProperties[staticName]'])),
+ js('this[staticName] = isolateProperties[staticName]'))),
// Use the newly created object as prototype. In Chrome,
// this creates a hidden class for the object and makes
// sure it is fast to access.
new jsAst.FunctionDeclaration(
new jsAst.VariableDeclaration('ForceEfficientMap'),
js.fun([], [])),
- js['ForceEfficientMap.prototype = this'],
- js['new ForceEfficientMap()']])),
- js['Isolate.prototype = oldIsolate.prototype'],
- js['Isolate.prototype.constructor = Isolate'],
- js['Isolate.${namer.isolatePropertiesName} = isolateProperties'],
+ js('ForceEfficientMap.prototype = this'),
+ js('new ForceEfficientMap()')])),
+ js('Isolate.prototype = oldIsolate.prototype'),
+ js('Isolate.prototype.constructor = Isolate'),
+ js('Isolate.${namer.isolatePropertiesName} = isolateProperties'),
js.return_('Isolate')]);
}
}
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart b/sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart
index e459ba0..bfc844a 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart
@@ -108,8 +108,9 @@
suggestedGlobalNames,
usedGlobalNames,
const <String>[
- r'Object', r'$throw', r'$eq', r'S', r'ioore', r'UnsupportedError$',
- r'length', r'$sub', r'getInterceptor$JSArrayJSString', r'$add',
+ r'Object', 'wrapException', r'$eq', r'S', r'ioore',
+ r'UnsupportedError$', r'length', r'$sub',
+ r'getInterceptor$JSArrayJSString', r'$add',
r'$gt', r'$ge', r'$lt', r'$le', r'add', r'getInterceptor$JSNumber',
r'iterator', r'$index', r'iae', r'getInterceptor$JSArray',
r'ArgumentError$', r'BoundClosure', r'StateError$',
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
index 4a5623e..07c32c0 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/namer.dart
@@ -536,7 +536,7 @@
return name;
}
- String getInterceptorSuffix(Collection<ClassElement> classes) {
+ String getInterceptorSuffix(Iterable<ClassElement> classes) {
String abbreviate(ClassElement cls) {
if (cls == compiler.objectClass) return "o";
JavaScriptBackend backend = compiler.backend;
@@ -565,7 +565,7 @@
return names.join();
}
- String getInterceptorName(Element element, Collection<ClassElement> classes) {
+ String getInterceptorName(Element element, Iterable<ClassElement> classes) {
JavaScriptBackend backend = compiler.backend;
if (classes.contains(backend.jsInterceptorClass)) {
// If the base Interceptor class is in the set of intercepted classes, we
@@ -578,7 +578,7 @@
}
String getOneShotInterceptorName(Selector selector,
- Collection<ClassElement> classes) {
+ Iterable<ClassElement> classes) {
JavaScriptBackend backend = compiler.backend;
// The one-shot name is a global name derived from the invocation name. To
// avoid instability we would like the names to be unique and not clash with
@@ -635,6 +635,17 @@
return name;
}
+ /// Returns the runtime name for [element]. The result is not safe as an id.
+ String getRuntimeTypeName(Element element) {
+ if (element == compiler.intClass) {
+ return 'int';
+ } else if (element == compiler.doubleClass) {
+ return 'double';
+ } else {
+ return getName(element);
+ }
+ }
+
/**
* Returns a preferred JS-id for the given element. The returned id is
* guaranteed to be a valid JS-id. Globals and static fields are furthermore
@@ -728,7 +739,7 @@
String operatorIs(Element element) {
// TODO(erikcorry): Reduce from $isx to ix when we are minifying.
- return '${operatorIsPrefix()}${getName(element)}';
+ return '${operatorIsPrefix()}${getRuntimeTypeName(element)}';
}
/*
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
index 2c4a38f..6ef9fc3 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart
@@ -157,7 +157,7 @@
// Define interceptor class for [classElement].
String className = backend.namer.getName(classElement);
jsAst.Expression init =
- js[emitter.classesCollector][className].assign(
+ js(emitter.classesCollector)[className].assign(
builder.toObjectInitializer());
mainBuffer.write(jsAst.prettyPrint(init, compiler));
mainBuffer.write('$N$n');
@@ -175,9 +175,9 @@
if (nativeTag == 'HTMLElement') definer = defineNativeMethodsNonleafName;
jsAst.Expression definition =
- js[definer](
+ js(definer)(
[js.string(nativeTag),
- js[backend.namer.isolateAccess(classElement)]]);
+ js(backend.namer.isolateAccess(classElement))]);
nativeBuffer.add(jsAst.prettyPrint(definition, compiler));
nativeBuffer.add('$N$n');
@@ -190,7 +190,7 @@
// `Object.prototype` to avoid checking in `getInterceptor` and
// specializations.
- // jsAst.Expression call = js[defineNativeMethodsFinishName]([]);
+ // jsAst.Expression call = js(defineNativeMethodsFinishName)([]);
// nativeBuffer.add(jsAst.prettyPrint(call, compiler));
// nativeBuffer.add('$N$n');
}
@@ -221,14 +221,8 @@
// The parameter type is a function type either directly or through
// typedef(s).
int arity = type.computeArity();
-
statements.add(
- new jsAst.ExpressionStatement(
- js.assign(
- js[name],
- js[closureConverter](
- [js[name],
- new jsAst.LiteralNumber('$arity')]))));
+ js('$name = $closureConverter($name, $arity)').toStatement());
break;
}
}
@@ -277,7 +271,7 @@
arguments = argumentsBuffer.sublist(1,
indexOfLastOptionalArgumentInParameters + 1);
} else {
- receiver = new jsAst.VariableUse('this');
+ receiver = js('this');
arguments = argumentsBuffer.sublist(0,
indexOfLastOptionalArgumentInParameters + 1);
}
@@ -364,13 +358,13 @@
// don't have DAGs yet, but if the dispatch is used for mixins
// that will be a possibility.
// Re-use the previously created temporary variable.
- expressions.add(new jsAst.VariableUse(use.name));
+ expressions.add(js(use.name));
} else {
String varName = 'v${varNames.length}_${tag.name.slowToString()}';
varNames.add(varName);
varDefns[varName] = existing;
- tagDefns[tag] = new jsAst.VariableUse(varName);
- expressions.add(new jsAst.VariableUse(varName));
+ tagDefns[tag] = js(varName);
+ expressions.add(js(varName));
}
}
}
@@ -424,12 +418,7 @@
js.string(toNativeTag(cls)),
tagDefns[cls]])));
- // $.dynamicSetMetadata(table);
- statements.add(
- new jsAst.ExpressionStatement(
- new jsAst.Call(
- new jsAst.VariableUse(dynamicSetMetadataName),
- [table])));
+ statements.add(js('$dynamicSetMetadataName(#)', table).toStatement());
// (function(){statements})();
if (emitter.compiler.enableMinification) nativeBuffer.add(';');
@@ -488,42 +477,17 @@
// Add function for the is-test.
String name = backend.namer.operatorIs(element);
addProperty(name,
- js.fun([], js.return_(js['false'])));
+ js.fun([], js.return_(js('false'))));
// Add a function for the (trivial) substitution.
addProperty(backend.namer.substitutionName(element),
- js.fun([], js.return_(js['null'])));
+ js.fun([], js.return_(js('null'))));
}
}
emitIsChecks();
- jsAst.Expression makeCallOnThis(String functionName) {
- // Because we know the function is intercepted, we need an extra
- // parameter.
- return js.fun(['_'], js.return_(js['$functionName(this)']));
- }
-
if (!nativeClasses.isEmpty) {
emitDynamicDispatchMetadata();
- // In order to have the toString method on every native class,
- // we must patch the JS Object prototype with a helper method.
- String toStringName = backend.namer.publicInstanceMethodNameByArity(
- const SourceString('toString'), 0);
- addProperty(toStringName, makeCallOnThis(toStringHelperName));
-
- // Same as above, but for hashCode.
- String hashCodeName =
- backend.namer.publicGetterName(const SourceString('hashCode'));
- addProperty(hashCodeName, makeCallOnThis(hashCodeHelperName));
-
- // Same as above, but for operator==.
- String equalsName = backend.namer.publicInstanceMethodNameByArity(
- const SourceString('=='), 1);
- // Because we know the function is intercepted, we need an extra
- // parameter.
- addProperty(equalsName, js.fun(['_', 'a'],
- js.return_(js['this === a'])));
-
// If the native emitter has been asked to take care of the
// noSuchMethod handlers, we do that now.
if (handleNoSuchMethod) {
@@ -541,9 +505,9 @@
[new jsAst.VariableInitialization(
new jsAst.VariableDeclaration('key'),
null)]),
- js['table'],
+ js('table'),
new jsAst.ExpressionStatement(
- js['$defPropName(Object.prototype, key, table[key])'])))(
+ js('$defPropName(Object.prototype, key, table[key])'))))(
new jsAst.ObjectInitializer(objectProperties));
if (emitter.compiler.enableMinification) targetBuffer.add(';');
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart b/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
index d23b1e4..9c5008f 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/runtime_types.dart
@@ -52,6 +52,54 @@
classes.add(dependency);
}
+ bool usingFactoryWithTypeArguments = false;
+
+ /**
+ * Compute type arguments of classes that use one of their type variables in
+ * is-checks and add the is-checks that they imply.
+ *
+ * This function must be called after all is-checks have been registered.
+ *
+ * TODO(karlklose): move these computations into a function producing an
+ * immutable datastructure.
+ */
+ void addImplicitChecks(Universe universe,
+ Iterable<ClassElement> classesUsingChecks) {
+ // If there are no classes that use their variables in checks, there is
+ // nothing to do.
+ if (classesUsingChecks.isEmpty) return;
+ if (universe.usingFactoryWithTypeArguments) {
+ for (DartType type in universe.instantiatedTypes) {
+ if (type.kind != TypeKind.INTERFACE) continue;
+ InterfaceType interface = type;
+ for (DartType argument in interface.typeArguments) {
+ universe.isChecks.add(argument);
+ }
+ }
+ } else {
+ // Find all instantiated types that are a subtype of a class that uses
+ // one of its type arguments in an is-check and add the arguments to the
+ // set of is-checks.
+ // TODO(karlklose): replace this with code that uses a subtype lookup
+ // datastructure in the world.
+ for (DartType type in universe.instantiatedTypes) {
+ if (type.kind != TypeKind.INTERFACE) continue;
+ InterfaceType classType = type;
+ for (ClassElement cls in classesUsingChecks) {
+ // We need the type as instance of its superclass anyway, so we just
+ // try to compute the substitution; if the result is [:null:], the
+ // classes are not related.
+ InterfaceType instance = classType.asInstanceOf(cls);
+ if (instance == null) continue;
+ Link<DartType> typeArguments = instance.typeArguments;
+ for (DartType argument in typeArguments) {
+ universe.isChecks.add(argument);
+ }
+ }
+ }
+ }
+ }
+
void computeClassesNeedingRti() {
// Find the classes that need runtime type information. Such
// classes are:
@@ -88,7 +136,7 @@
}
});
// Add is-checks that result from classes using type variables in checks.
- compiler.resolverWorld.addImplicitChecks(classesUsingTypeVariableTests);
+ addImplicitChecks(compiler.resolverWorld, classesUsingTypeVariableTests);
// Add the rti dependencies that are implicit in the way the backend
// generates code: when we create a new [List], we actually create
// a JSArray in the backend and we need to add type arguments to
@@ -121,10 +169,12 @@
if (cachedRequiredChecks != null) return cachedRequiredChecks;
// Get all types used in type arguments of instantiated types.
- Set<ClassElement> instantiatedArguments = getInstantiatedArguments();
+ Set<ClassElement> instantiatedArguments =
+ getInstantiatedArguments(compiler.codegenWorld);
// Collect all type arguments used in is-checks.
- Set<ClassElement> checkedArguments = getCheckedArguments();
+ Set<ClassElement> checkedArguments =
+ getCheckedArguments(compiler.codegenWorld);
// Precompute the set of all seen type arguments for use in the emitter.
allArguments = new Set<ClassElement>.from(instantiatedArguments)
@@ -158,9 +208,9 @@
* have a type check against this supertype that includes a check against
* the type arguments.
*/
- Set<ClassElement> getInstantiatedArguments() {
+ Set<ClassElement> getInstantiatedArguments(Universe universe) {
ArgumentCollector collector = new ArgumentCollector();
- for (DartType type in instantiatedTypes) {
+ for (DartType type in universe.instantiatedTypes) {
collector.collect(type);
ClassElement cls = type.element;
for (DartType supertype in cls.allSupertypes) {
@@ -176,22 +226,14 @@
}
/// Collects all type arguments used in is-checks.
- Set<ClassElement> getCheckedArguments() {
+ Set<ClassElement> getCheckedArguments(Universe universe) {
ArgumentCollector collector = new ArgumentCollector();
- for (DartType type in isChecks) {
+ for (DartType type in universe.isChecks) {
collector.collect(type);
}
return collector.classes;
}
- Iterable<DartType> get isChecks {
- return compiler.enqueuer.resolution.universe.isChecks;
- }
-
- Iterable<DartType> get instantiatedTypes {
- return compiler.codegenWorld.instantiatedTypes;
- }
-
/// Return the unique name for the element as an unquoted string.
String getNameAsString(Element element) {
JavaScriptBackend backend = compiler.backend;
@@ -465,16 +507,6 @@
type.accept(this, false);
}
- visit(DartType type) {
- type.accept(this, true);
- }
-
- visitList(Link<DartType> types) {
- for (Link<DartType> link = types; !link.isEmpty; link = link.tail) {
- link.head.accept(this, true);
- }
- }
-
visitType(DartType type, _) {
// Do nothing.
}
@@ -487,13 +519,10 @@
if (isTypeArgument) {
classes.add(type.element);
}
- visitList(type.typeArguments);
+ type.visitChildren(this, true);
}
visitFunctionType(FunctionType type, _) {
- visit(type.returnType);
- visitList(type.parameterTypes);
- visitList(type.optionalParameterTypes);
- visitList(type.namedParameterTypes);
+ type.visitChildren(this, true);
}
}
diff --git a/sdk/lib/_internal/compiler/implementation/lib/collection_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/collection_patch.dart
index da51828..1fd94cd 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/collection_patch.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/collection_patch.dart
@@ -8,7 +8,7 @@
patch class HashMap<K, V> {
int _length = 0;
- // The hash map contents is divided into three parts: one part for
+ // The hash map contents are divided into three parts: one part for
// string keys, one for numeric keys, and one for the rest. String
// and numeric keys map directly to their values, but the rest of
// the entries are stored in bucket lists of the form:
@@ -356,10 +356,361 @@
}
}
+patch class LinkedHashMap<K, V> {
+ int _length = 0;
+
+ // The hash map contents are divided into three parts: one part for
+ // string keys, one for numeric keys, and one for the rest. String
+ // and numeric keys map directly to their linked cells, but the rest
+ // of the entries are stored in bucket lists of the form:
+ //
+ // [cell-0, cell-1, ...]
+ //
+ // where all keys in the same bucket share the same hash code.
+ var _strings;
+ var _nums;
+ var _rest;
+
+ // The keys and values are stored in cells that are linked together
+ // to form a double linked list.
+ LinkedHashMapCell _first;
+ LinkedHashMapCell _last;
+
+ // We track the number of modifications done to the key set of the
+ // hash map to be able to throw when the map is modified while being
+ // iterated over.
+ int _modifications = 0;
+
+ patch LinkedHashMap();
+
+ patch int get length => _length;
+ patch bool get isEmpty => _length == 0;
+
+ patch Iterable<K> get keys {
+ return new LinkedHashMapKeyIterable<K>(this);
+ }
+
+ patch Iterable<V> get values {
+ return keys.map((each) => this[each]);
+ }
+
+ patch bool containsKey(K key) {
+ if (_isStringKey(key)) {
+ var strings = _strings;
+ if (strings == null) return false;
+ LinkedHashMapCell cell = _getTableEntry(strings, key);
+ return cell != null;
+ } else if (_isNumericKey(key)) {
+ var nums = _nums;
+ if (nums == null) return false;
+ LinkedHashMapCell cell = _getTableEntry(nums, key);
+ return cell != null;
+ } else {
+ var rest = _rest;
+ if (rest == null) return false;
+ var bucket = _getBucket(rest, key);
+ return _findBucketIndex(bucket, key) >= 0;
+ }
+ }
+
+ patch bool containsValue(V value) {
+ return keys.any((each) => this[each] == value);
+ }
+
+ patch void addAll(Map<K, V> other) {
+ other.forEach((K key, V value) {
+ this[key] = value;
+ });
+ }
+
+ patch V operator[](K key) {
+ if (_isStringKey(key)) {
+ var strings = _strings;
+ if (strings == null) return null;
+ LinkedHashMapCell cell = _getTableEntry(strings, key);
+ return (cell == null) ? null : cell._value;
+ } else if (_isNumericKey(key)) {
+ var nums = _nums;
+ if (nums == null) return null;
+ LinkedHashMapCell cell = _getTableEntry(nums, key);
+ return (cell == null) ? null : cell._value;
+ } else {
+ var rest = _rest;
+ if (rest == null) return null;
+ var bucket = _getBucket(rest, key);
+ int index = _findBucketIndex(bucket, key);
+ if (index < 0) return null;
+ LinkedHashMapCell cell = JS('var', '#[#]', bucket, index);
+ return cell._value;
+ }
+ }
+
+ patch void operator[]=(K key, V value) {
+ if (_isStringKey(key)) {
+ var strings = _strings;
+ if (strings == null) _strings = strings = _newHashTable();
+ _addHashTableEntry(strings, key, value);
+ } else if (_isNumericKey(key)) {
+ var nums = _nums;
+ if (nums == null) _nums = nums = _newHashTable();
+ _addHashTableEntry(nums, key, value);
+ } else {
+ var rest = _rest;
+ if (rest == null) _rest = rest = _newHashTable();
+ var hash = _computeHashCode(key);
+ var bucket = JS('var', '#[#]', rest, hash);
+ if (bucket == null) {
+ LinkedHashMapCell cell = _newLinkedCell(key, value);
+ _setTableEntry(rest, hash, JS('var', '[#]', cell));
+ } else {
+ int index = _findBucketIndex(bucket, key);
+ if (index >= 0) {
+ LinkedHashMapCell cell = JS('var', '#[#]', bucket, index);
+ cell._value = value;
+ } else {
+ LinkedHashMapCell cell = _newLinkedCell(key, value);
+ JS('void', '#.push(#)', bucket, cell);
+ }
+ }
+ }
+ }
+
+ patch V putIfAbsent(K key, V ifAbsent()) {
+ if (containsKey(key)) return this[key];
+ V value = ifAbsent();
+ this[key] = value;
+ return value;
+ }
+
+ patch V remove(K key) {
+ if (_isStringKey(key)) {
+ return _removeHashTableEntry(_strings, key);
+ } else if (_isNumericKey(key)) {
+ return _removeHashTableEntry(_nums, key);
+ } else {
+ var rest = _rest;
+ if (rest == null) return null;
+ var bucket = _getBucket(rest, key);
+ int index = _findBucketIndex(bucket, key);
+ if (index < 0) return null;
+ // Use splice to remove the [cell] element at the index and
+ // unlink the cell before returning its value.
+ LinkedHashMapCell cell = JS('var', '#.splice(#, 1)[0]', bucket, index);
+ _unlinkCell(cell);
+ // TODO(kasperl): Consider getting rid of the bucket list when
+ // the length reaches zero.
+ return cell._value;
+ }
+ }
+
+ patch void clear() {
+ if (_length > 0) {
+ _strings = _nums = _rest = _first = _last = null;
+ _length = 0;
+ _modified();
+ }
+ }
+
+ patch void forEach(void action(K key, V value)) {
+ LinkedHashMapCell cell = _first;
+ int modifications = _modifications;
+ while (cell != null) {
+ action(cell._key, cell._value);
+ if (modifications != _modifications) {
+ throw new ConcurrentModificationError(this);
+ }
+ cell = cell._next;
+ }
+ }
+
+ void _addHashTableEntry(var table, K key, V value) {
+ LinkedHashMapCell cell = _getTableEntry(table, key);
+ if (cell == null) {
+ _setTableEntry(table, key, _newLinkedCell(key, value));
+ } else {
+ cell._value = value;
+ }
+ }
+
+ V _removeHashTableEntry(var table, K key) {
+ if (table == null) return null;
+ LinkedHashMapCell cell = _getTableEntry(table, key);
+ if (cell == null) return null;
+ _unlinkCell(cell);
+ _deleteTableEntry(table, key);
+ return cell._value;
+ }
+
+ void _modified() {
+ // Value cycles after 2^30 modifications. If you keep hold of an
+ // iterator for that long, you might miss a modification
+ // detection, and iteration can go sour. Don't do that.
+ _modifications = (_modifications + 1) & 0x3ffffff;
+ }
+
+ // Create a new cell and link it in as the last one in the list.
+ LinkedHashMapCell _newLinkedCell(K key, V value) {
+ LinkedHashMapCell cell = new LinkedHashMapCell(key, value);
+ if (_first == null) {
+ _first = _last = cell;
+ } else {
+ LinkedHashMapCell last = _last;
+ cell._previous = last;
+ _last = last._next = cell;
+ }
+ _length++;
+ _modified();
+ return cell;
+ }
+
+ // Unlink the given cell from the linked list of cells.
+ void _unlinkCell(LinkedHashMapCell cell) {
+ LinkedHashMapCell previous = cell._previous;
+ LinkedHashMapCell next = cell._next;
+ if (previous == null) {
+ assert(cell == _first);
+ _first = next;
+ } else {
+ previous._next = next;
+ }
+ if (next == null) {
+ assert(cell == _last);
+ _last = previous;
+ } else {
+ next._previous = previous;
+ }
+ _length--;
+ _modified();
+ }
+
+ static bool _isStringKey(var key) {
+ return key is String && key != '__proto__';
+ }
+
+ static bool _isNumericKey(var key) {
+ // Only treat unsigned 30-bit integers as numeric keys. This way,
+ // we avoid converting them to strings when we use them as keys in
+ // the JavaScript hash table object.
+ return key is num && JS('bool', '(# & 0x3ffffff) === #', key, key);
+ }
+
+ static int _computeHashCode(var key) {
+ // We force the hash codes to be unsigned 30-bit integers to avoid
+ // issues with problematic keys like '__proto__'. Another option
+ // would be to throw an exception if the hash code isn't a number.
+ return JS('int', '# & 0x3ffffff', key.hashCode);
+ }
+
+ static _getTableEntry(var table, var key) {
+ return JS('var', '#[#]', table, key);
+ }
+
+ static void _setTableEntry(var table, var key, var value) {
+ assert(value != null);
+ JS('void', '#[#] = #', table, key, value);
+ }
+
+ static void _deleteTableEntry(var table, var key) {
+ JS('void', 'delete #[#]', table, key);
+ }
+
+ static List _getBucket(var table, var key) {
+ var hash = _computeHashCode(key);
+ return JS('var', '#[#]', table, hash);
+ }
+
+ static int _findBucketIndex(var bucket, var key) {
+ if (bucket == null) return -1;
+ int length = JS('int', '#.length', bucket);
+ for (int i = 0; i < length; i++) {
+ LinkedHashMapCell cell = JS('var', '#[#]', bucket, i);
+ if (cell._key == key) return i;
+ }
+ return -1;
+ }
+
+ static _newHashTable() {
+ // Create a new JavaScript object to be used as a hash table. Use
+ // Object.create to avoid the properties on Object.prototype
+ // showing up as entries.
+ var table = JS('var', 'Object.create(null)');
+ // Attempt to force the hash table into 'dictionary' mode by
+ // adding a property to it and deleting it again.
+ var temporaryKey = '<non-identifier-key>';
+ _setTableEntry(table, temporaryKey, table);
+ _deleteTableEntry(table, temporaryKey);
+ return table;
+ }
+}
+
+class LinkedHashMapCell {
+ final _key;
+ var _value;
+
+ LinkedHashMapCell _next;
+ LinkedHashMapCell _previous;
+
+ LinkedHashMapCell(this._key, this._value);
+}
+
+class LinkedHashMapKeyIterable<E> extends Iterable<E> {
+ final _map;
+ LinkedHashMapKeyIterable(this._map);
+
+ int get length => _map._length;
+ bool get isEmpty => _map._length == 0;
+
+ Iterator<E> get iterator {
+ return new LinkedHashMapKeyIterator<E>(_map, _map._modifications);
+ }
+
+ bool contains(E element) {
+ return _map.containsKey(element);
+ }
+
+ void forEach(void f(E element)) {
+ LinkedHashMapCell cell = _map._first;
+ int modifications = _map._modifications;
+ while (cell != null) {
+ f(cell._key);
+ if (modifications != _map._modifications) {
+ throw new ConcurrentModificationError(_map);
+ }
+ cell = cell._next;
+ }
+ }
+}
+
+class LinkedHashMapKeyIterator<E> implements Iterator<E> {
+ final _map;
+ final int _modifications;
+ LinkedHashMapCell _cell;
+ E _current;
+
+ LinkedHashMapKeyIterator(this._map, this._modifications) {
+ _cell = _map._first;
+ }
+
+ E get current => _current;
+
+ bool moveNext() {
+ if (_modifications != _map._modifications) {
+ throw new ConcurrentModificationError(_map);
+ } else if (_cell == null) {
+ _current = null;
+ return false;
+ } else {
+ _current = _cell._key;
+ _cell = _cell._next;
+ return true;
+ }
+ }
+}
+
patch class HashSet<E> {
int _length = 0;
- // The hash set contents is divided into three parts: one part for
+ // The hash set contents are divided into three parts: one part for
// string elements, one for numeric elements, and one for the
// rest. String and numeric elements map directly to a sentinel
// value, but the rest of the entries are stored in bucket lists of
@@ -641,3 +992,328 @@
}
}
}
+
+patch class LinkedHashSet<E> extends _HashSetBase<E> {
+ int _length = 0;
+
+ // The hash set contents are divided into three parts: one part for
+ // string elements, one for numeric elements, and one for the
+ // rest. String and numeric elements map directly to their linked
+ // cells, but the rest of the entries are stored in bucket lists of
+ // the form:
+ //
+ // [cell-0, cell-1, ...]
+ //
+ // where all elements in the same bucket share the same hash code.
+ var _strings;
+ var _nums;
+ var _rest;
+
+ // The elements are stored in cells that are linked together
+ // to form a double linked list.
+ LinkedHashSetCell _first;
+ LinkedHashSetCell _last;
+
+ // We track the number of modifications done to the element set to
+ // be able to throw when the set is modified while being iterated
+ // over.
+ int _modifications = 0;
+
+ patch LinkedHashSet();
+
+ void _unsupported(String operation) {
+ throw 'LinkedHashSet: unsupported $operation';
+ }
+
+ // Iterable.
+ patch Iterator<E> get iterator {
+ return new LinkedHashSetIterator(this, _modifications);
+ }
+
+ patch int get length => _length;
+ patch bool get isEmpty => _length == 0;
+
+ patch bool contains(Object object) {
+ if (_isStringElement(object)) {
+ var strings = _strings;
+ if (strings == null) return false;
+ LinkedHashSetCell cell = _getTableEntry(strings, object);
+ return cell != null;
+ } else if (_isNumericElement(object)) {
+ var nums = _nums;
+ if (nums == null) return false;
+ LinkedHashSetCell cell = _getTableEntry(nums, object);
+ return cell != null;
+ } else {
+ var rest = _rest;
+ if (rest == null) return false;
+ var bucket = _getBucket(rest, object);
+ return _findBucketIndex(bucket, object) >= 0;
+ }
+ }
+
+ patch void forEach(void action(E element)) {
+ LinkedHashSetCell cell = _first;
+ int modifications = _modifications;
+ while (cell != null) {
+ action(cell._element);
+ if (modifications != _modifications) {
+ throw new ConcurrentModificationError(this);
+ }
+ cell = cell._next;
+ }
+ }
+
+ patch E get first {
+ if (_first == null) throw new StateError("No elements");
+ return _first._element;
+ }
+
+ patch E get last {
+ if (_last == null) throw new StateError("No elements");
+ return _last._element;
+ }
+
+ // Collection.
+ patch void add(E element) {
+ if (_isStringElement(element)) {
+ var strings = _strings;
+ if (strings == null) _strings = strings = _newHashTable();
+ _addHashTableEntry(strings, element);
+ } else if (_isNumericElement(element)) {
+ var nums = _nums;
+ if (nums == null) _nums = nums = _newHashTable();
+ _addHashTableEntry(nums, element);
+ } else {
+ var rest = _rest;
+ if (rest == null) _rest = rest = _newHashTable();
+ var hash = _computeHashCode(element);
+ var bucket = JS('var', '#[#]', rest, hash);
+ if (bucket == null) {
+ LinkedHashSetCell cell = _newLinkedCell(element);
+ _setTableEntry(rest, hash, JS('var', '[#]', cell));
+ } else {
+ int index = _findBucketIndex(bucket, element);
+ if (index >= 0) return;
+ LinkedHashSetCell cell = _newLinkedCell(element);
+ JS('void', '#.push(#)', bucket, cell);
+ }
+ }
+ }
+
+ patch void addAll(Iterable<E> objects) {
+ for (E object in objects) {
+ add(object);
+ }
+ }
+
+ patch bool remove(Object object) {
+ if (_isStringElement(object)) {
+ return _removeHashTableEntry(_strings, object);
+ } else if (_isNumericElement(object)) {
+ return _removeHashTableEntry(_nums, object);
+ } else {
+ var rest = _rest;
+ if (rest == null) return false;
+ var bucket = _getBucket(rest, object);
+ int index = _findBucketIndex(bucket, object);
+ if (index < 0) return false;
+ // Use splice to remove the [cell] element at the index and
+ // unlink it.
+ LinkedHashSetCell cell = JS('var', '#.splice(#, 1)[0]', bucket, index);
+ _unlinkCell(cell);
+ return true;
+ }
+ }
+
+ patch void removeAll(Iterable objectsToRemove) {
+ for (var each in objectsToRemove) {
+ remove(each);
+ }
+ }
+
+ patch void removeWhere(bool test(E element)) {
+ _filterWhere(test, true);
+ }
+
+ patch void retainWhere(bool test(E element)) {
+ _filterWhere(test, false);
+ }
+
+ void _filterWhere(bool test(E element), bool removeMatching) {
+ LinkedHashSetCell cell = _first;
+ while (cell != null) {
+ E element = cell._element;
+ LinkedHashSetCell next = cell._next;
+ int modifications = _modifications;
+ bool shouldRemove = (removeMatching == test(element));
+ if (modifications != _modifications) {
+ throw new ConcurrentModificationError(this);
+ }
+ if (shouldRemove) remove(element);
+ cell = next;
+ }
+ }
+
+ patch void clear() {
+ if (_length > 0) {
+ _strings = _nums = _rest = _first = _last = null;
+ _length = 0;
+ _modified();
+ }
+ }
+
+ void _addHashTableEntry(var table, E element) {
+ LinkedHashSetCell cell = _getTableEntry(table, element);
+ if (cell != null) return;
+ _setTableEntry(table, element, _newLinkedCell(element));
+ }
+
+ bool _removeHashTableEntry(var table, E element) {
+ if (table == null) return false;
+ LinkedHashSetCell cell = _getTableEntry(table, element);
+ if (cell == null) return false;
+ _unlinkCell(cell);
+ _deleteTableEntry(table, element);
+ return true;
+ }
+
+ void _modified() {
+ // Value cycles after 2^30 modifications. If you keep hold of an
+ // iterator for that long, you might miss a modification
+ // detection, and iteration can go sour. Don't do that.
+ _modifications = (_modifications + 1) & 0x3ffffff;
+ }
+
+ // Create a new cell and link it in as the last one in the list.
+ LinkedHashSetCell _newLinkedCell(E element) {
+ LinkedHashSetCell cell = new LinkedHashSetCell(element);
+ if (_first == null) {
+ _first = _last = cell;
+ } else {
+ LinkedHashSetCell last = _last;
+ cell._previous = last;
+ _last = last._next = cell;
+ }
+ _length++;
+ _modified();
+ return cell;
+ }
+
+ // Unlink the given cell from the linked list of cells.
+ void _unlinkCell(LinkedHashSetCell cell) {
+ LinkedHashSetCell previous = cell._previous;
+ LinkedHashSetCell next = cell._next;
+ if (previous == null) {
+ assert(cell == _first);
+ _first = next;
+ } else {
+ previous._next = next;
+ }
+ if (next == null) {
+ assert(cell == _last);
+ _last = previous;
+ } else {
+ next._previous = previous;
+ }
+ _length--;
+ _modified();
+ }
+
+ static bool _isStringElement(var element) {
+ return element is String && element != '__proto__';
+ }
+
+ static bool _isNumericElement(var element) {
+ // Only treat unsigned 30-bit integers as numeric elements. This
+ // way, we avoid converting them to strings when we use them as
+ // keys in the JavaScript hash table object.
+ return element is num &&
+ JS('bool', '(# & 0x3ffffff) === #', element, element);
+ }
+
+ static int _computeHashCode(var element) {
+ // We force the hash codes to be unsigned 30-bit integers to avoid
+ // issues with problematic elements like '__proto__'. Another
+ // option would be to throw an exception if the hash code isn't a
+ // number.
+ return JS('int', '# & 0x3ffffff', element.hashCode);
+ }
+
+ static _getTableEntry(var table, var key) {
+ return JS('var', '#[#]', table, key);
+ }
+
+ static void _setTableEntry(var table, var key, var value) {
+ assert(value != null);
+ JS('void', '#[#] = #', table, key, value);
+ }
+
+ static void _deleteTableEntry(var table, var key) {
+ JS('void', 'delete #[#]', table, key);
+ }
+
+ static List _getBucket(var table, var element) {
+ var hash = _computeHashCode(element);
+ return JS('var', '#[#]', table, hash);
+ }
+
+ static int _findBucketIndex(var bucket, var element) {
+ if (bucket == null) return -1;
+ int length = JS('int', '#.length', bucket);
+ for (int i = 0; i < length; i++) {
+ LinkedHashSetCell cell = JS('var', '#[#]', bucket, i);
+ if (cell._element == element) return i;
+ }
+ return -1;
+ }
+
+ static _newHashTable() {
+ // Create a new JavaScript object to be used as a hash table. Use
+ // Object.create to avoid the properties on Object.prototype
+ // showing up as entries.
+ var table = JS('var', 'Object.create(null)');
+ // Attempt to force the hash table into 'dictionary' mode by
+ // adding a property to it and deleting it again.
+ var temporaryKey = '<non-identifier-key>';
+ _setTableEntry(table, temporaryKey, table);
+ _deleteTableEntry(table, temporaryKey);
+ return table;
+ }
+}
+
+class LinkedHashSetCell {
+ final _element;
+
+ LinkedHashSetCell _next;
+ LinkedHashSetCell _previous;
+
+ LinkedHashSetCell(this._element);
+}
+
+// TODO(kasperl): Share this code with LinkedHashMapKeyIterator<E>?
+class LinkedHashSetIterator<E> implements Iterator<E> {
+ final _set;
+ final int _modifications;
+ LinkedHashSetCell _cell;
+ E _current;
+
+ LinkedHashSetIterator(this._set, this._modifications) {
+ _cell = _set._first;
+ }
+
+ E get current => _current;
+
+ bool moveNext() {
+ if (_modifications != _set._modifications) {
+ throw new ConcurrentModificationError(_set);
+ } else if (_cell == null) {
+ _current = null;
+ return false;
+ } else {
+ _current = _cell._element;
+ _cell = _cell._next;
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart
index ec45708..6569d60 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/core_patch.dart
@@ -298,3 +298,19 @@
throw new UnsupportedError('stackTrace');
}
}
+
+patch class Symbol {
+ final String _name;
+
+ patch const Symbol(String name) :
+ this._name = name;
+
+ patch bool operator ==(other) {
+ return other is Symbol && _name == other._name;
+ }
+
+ patch int get hashCode {
+ const arbitraryPrime = 664597;
+ return 0x1fffffff & (arbitraryPrime * _name.hashCode);
+ }
+}
diff --git a/sdk/lib/_internal/compiler/implementation/lib/io_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/io_patch.dart
index 6cd1b50..2702d9d 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/io_patch.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/io_patch.dart
@@ -78,6 +78,9 @@
patch static _delete(String path) {
throw new UnsupportedError("File._delete");
}
+ patch static _deleteLink(String path) {
+ throw new UnsupportedError("File._deleteLink");
+ }
patch static _directory(String path) {
throw new UnsupportedError("File._directory");
}
@@ -134,9 +137,9 @@
}
}
-patch class _HttpSessionManager {
- patch static Uint8List _getRandomBytes(int count) {
- throw new UnsupportedError("HttpSessionManager._getRandomBytes");
+patch class _IOCrypto {
+ patch static Uint8List getRandomBytes(int count) {
+ throw new UnsupportedError("_IOCrypto.getRandomBytes");
}
}
diff --git a/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
index 3016e78..22e13da 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
@@ -24,7 +24,7 @@
const CloseToken();
}
-class JsIsolateSink extends StreamSink<dynamic> implements IsolateSink {
+class JsIsolateSink extends EventSink<dynamic> implements IsolateSink {
bool _isClosed = false;
final SendPort _port;
JsIsolateSink.fromPort(this._port);
@@ -54,9 +54,10 @@
* Called by the compiler to support switching
* between isolates when we get a callback from the DOM.
*/
-void _callInIsolate(_IsolateContext isolate, Function function) {
- isolate.eval(function);
+_callInIsolate(_IsolateContext isolate, Function function) {
+ var result = isolate.eval(function);
_globalState.topEventLoop.run();
+ return result;
}
/**
@@ -449,7 +450,7 @@
// such as d8 and jsshell. We should move this code to a helper
// library that is only loaded when testing on those engines.
- var stack = JS('String|Null', 'new Error().stack');
+ var stack = JS('String|Null', '(new Error()).stack');
if (stack == null) {
// According to Internet Explorer documentation, the stack
// property is not set until the exception is thrown. The stack
@@ -584,7 +585,7 @@
* but you should probably not count on this.
*/
static String _getJSFunctionName(Function f) {
- return JS("String|Null", r"(#.$name || #)", f, null);
+ return JS("String|Null", r"(#['$name'] || #)", f, null);
}
/** Create a new JavaScript object instance given its constructor. */
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
index c57c15b..7a57e31 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
@@ -52,14 +52,6 @@
}
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAllList(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
void removeWhere(bool test(E element)) {
// This could, and should, be optimized.
IterableMixinWorkaround.removeWhereList(this, test);
@@ -96,8 +88,7 @@
return IterableMixinWorkaround.mapList(this, f);
}
- String join([String separator]) {
- if (separator == null) separator = "";
+ String join([String separator = ""]) {
var list = new List(this.length);
for (int i = 0; i < this.length; i++) {
list[i] = "${this[i]}";
@@ -121,8 +112,8 @@
return IterableMixinWorkaround.skipWhile(this, test);
}
- reduce(initialValue, combine(previousValue, E element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ E reduce(E combine(E value, E element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
fold(initialValue, combine(previousValue, E element)) {
@@ -165,8 +156,8 @@
}
- List<E> getRange(int start, int length) {
- return sublist(start, start + length);
+ Iterable<E> getRange(int start, int end) {
+ return IterableMixinWorkaround.getRangeList(this, start, end);
}
void insertRange(int start, int length, [E initialValue]) {
@@ -213,10 +204,6 @@
throw new StateError("More than one element");
}
- E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare);
-
- E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
-
void removeRange(int start, int length) {
checkGrowable(this, 'removeRange');
if (length == 0) {
@@ -275,7 +262,7 @@
bool get isEmpty => length == 0;
- String toString() => Collections.collectionToString(this);
+ String toString() => ToString.iterableToString(this);
List<E> toList({ bool growable: true }) =>
new List<E>.from(this, growable: growable);
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
index badbb4d..b77092f 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart
@@ -614,7 +614,7 @@
* The code in [unwrapException] deals with getting the original Dart
* object out of the wrapper again.
*/
-$throw(ex) {
+wrapException(ex) {
if (ex == null) ex = const NullThrownError();
var wrapper = new DartError(ex);
@@ -622,18 +622,28 @@
// Use V8 API for recording a "fast" stack trace (this installs a
// "stack" property getter on [wrapper]).
JS('void', r'Error.captureStackTrace(#, #)',
- wrapper, RAW_DART_FUNCTION_REF($throw));
+ wrapper, RAW_DART_FUNCTION_REF(wrapException));
} else {
// Otherwise, produce a stack trace and record it in the wrapper.
// This is a slower way to create a stack trace which works on
// some browsers, but may simply evaluate to null.
- String stackTrace = JS('', 'new Error().stack');
+ String stackTrace = JS('', '(new Error()).stack');
JS('void', '#.stack = #', wrapper, stackTrace);
}
return wrapper;
}
/**
+ * This wraps the exception and does the throw. It is possible to call this in
+ * a JS expression context, where the throw statement is not allowed. Helpers
+ * are never inlined, so we don't risk inlining the throw statement into an
+ * expression context.
+ */
+throwExpression(ex) {
+ JS('void', 'throw #', wrapException(ex));
+}
+
+/**
* Wrapper class for throwing exceptions.
*/
class DartError {
@@ -652,8 +662,8 @@
/**
* V8/Chrome installs a property getter, "stack", when calling
- * Error.captureStackTrace (see [$throw]). In [$throw], we make sure
- * that this property is always set.
+ * Error.captureStackTrace (see [wrapException]). In [wrapException], we make
+ * sure that this property is always set.
*/
String get stack => JS('', '#.stack', this);
@@ -663,7 +673,7 @@
*
* We only expect this method to be called (indirectly) by the
* browser when an uncaught exception occurs. Instance of this class
- * should never escape into Dart code (except for [$throw] above).
+ * should never escape into Dart code (except for [wrapException] above).
*/
String toString() {
// If Error.captureStackTrace is available, accessing stack from
@@ -715,7 +725,7 @@
/**
* Called from catch blocks in generated code to extract the Dart
* exception from the thrown value. The thrown value may have been
- * created by [$throw] or it may be a 'native' JS exception.
+ * created by [wrapException] or it may be a 'native' JS exception.
*
* Some native exceptions are mapped to new Dart instances, others are
* returned unmodified.
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
index d84a6a2..b986503 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
@@ -37,8 +37,7 @@
String getRuntimeTypeAsString(List runtimeType) {
String className = getConstructorName(runtimeType[0]);
- if (runtimeType.length == 1) return className;
- return '$className<${joinArguments(runtimeType, 1)}>';
+ return '$className${joinArguments(runtimeType, 1)}';
}
String getConstructorName(type) => JS('String', r'#.builtin$cls', type);
@@ -56,7 +55,9 @@
}
String joinArguments(var types, int startIndex) {
+ if (types == null) return '';
bool firstArgument = true;
+ bool allDynamic = true;
StringBuffer buffer = new StringBuffer();
for (int index = startIndex; index < types.length; index++) {
if (firstArgument) {
@@ -65,16 +66,18 @@
buffer.write(', ');
}
var argument = types[index];
+ if (argument != null) {
+ allDynamic = false;
+ }
buffer.write(runtimeTypeToString(argument));
}
- return buffer.toString();
+ return allDynamic ? '' : '<$buffer>';
}
String getRuntimeTypeString(var object) {
String className = isJsArray(object) ? 'List' : getClassName(object);
var typeInfo = JS('var', r'#.$builtinTypeInfo', object);
- if (typeInfo == null) return className;
- return "$className<${joinArguments(typeInfo, 0)}>";
+ return "$className${joinArguments(typeInfo, 0)}";
}
bool isJsFunction(var o) => JS('bool', r'typeof # == "function"', o);
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart
index 395f970..e6184c0 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart
@@ -137,7 +137,7 @@
return JS('String', r'#.trim()', this);
}
- List<int> get codeUnits => new CodeUnits(this);
+ List<int> get codeUnits => new _CodeUnits(this);
Runes get runes => new Runes(this);
@@ -211,3 +211,16 @@
return JS('String', '#[#]', this, index);
}
}
+
+/**
+ * An [Iterable] of the UTF-16 code units of a [String] in index order.
+ */
+class _CodeUnits extends UnmodifiableListBase<int> {
+ /** The string that this is the code units of. */
+ String _string;
+
+ _CodeUnits(this._string);
+
+ int get length => _string.length;
+ int operator[](int i) => _string.codeUnitAt(i);
+}
diff --git a/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
index 0baf9a8..a41e099 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/mirrors_patch.dart
@@ -68,9 +68,9 @@
return mirror;
}
- Future<InstanceMirror> invoke(String memberName,
- List<Object> positionalArguments,
- [Map<String,Object> namedArguments]) {
+ Future<InstanceMirror> invokeAsync(String memberName,
+ List<Object> positionalArguments,
+ [Map<String,Object> namedArguments]) {
if (namedArguments != null && !namedArguments.isEmpty) {
throw new UnsupportedError('Named arguments are not implemented');
}
diff --git a/sdk/lib/_internal/compiler/implementation/lib/native_helper.dart b/sdk/lib/_internal/compiler/implementation/lib/native_helper.dart
index 43e02e8..566fb58 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/native_helper.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/native_helper.dart
@@ -41,6 +41,7 @@
String typeNameInFirefox(obj) {
String name = JS('String', '#', constructorNameFallback(obj));
if (name == 'Window') return 'DOMWindow';
+ if (name == 'BeforeUnloadEvent') return 'Event';
if (name == 'CSS2Properties') return 'CSSStyleDeclaration';
if (name == 'DataTransfer') return 'Clipboard';
if (name == 'DragEvent') return 'MouseEvent';
@@ -62,6 +63,7 @@
return 'HTMLDocument';
}
if (name == 'ApplicationCache') return 'DOMApplicationCache';
+ if (name == 'BeforeUnloadEvent') return 'Event';
if (name == 'CanvasPixelArray') return 'Uint8ClampedArray';
if (name == 'DataTransfer') return 'Clipboard';
if (name == 'DragEvent') return 'MouseEvent';
diff --git a/sdk/lib/_internal/compiler/implementation/lib/typeddata_patch.dart b/sdk/lib/_internal/compiler/implementation/lib/typeddata_patch.dart
index 28d2233..ba50d05d6 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/typeddata_patch.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/typeddata_patch.dart
@@ -11,6 +11,10 @@
throw new UnsupportedError('Int8List');
}
+ patch factory Int8List.fromList(List<int> elements) {
+ throw new UnsupportedError('Int8List.fromList');
+ }
+
patch factory Int8List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Int8List.view');
@@ -23,6 +27,10 @@
throw new UnsupportedError('Uint8List');
}
+ patch factory Uint8List.fromList(List<int> elements) {
+ throw new UnsupportedError('Uint8List.fromList');
+ }
+
patch factory Uint8List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Uint8List.view');
@@ -35,6 +43,10 @@
throw new UnsupportedError('Uint8ClampedList');
}
+ patch factory Uint8ClampedList.fromList(List<int> elements) {
+ throw new UnsupportedError('Uint8ClampedList.fromList');
+ }
+
patch factory Uint8ClampedList.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Uint8ClampedList.view');
@@ -48,6 +60,10 @@
}
+ patch factory Int16List.fromList(List<int> elements) {
+ throw new UnsupportedError('Int16List.fromList');
+ }
+
patch factory Int16List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Int16List.view');
@@ -60,6 +76,10 @@
throw new UnsupportedError('Uint16List');
}
+ patch factory Uint16List.fromList(List<int> elements) {
+ throw new UnsupportedError('Uint16List.fromList');
+ }
+
patch factory Uint16List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Uint16List.view');
@@ -72,6 +92,10 @@
throw new UnsupportedError('Int32List');
}
+ patch factory Int32List.fromList(List<int> elements) {
+ throw new UnsupportedError('Int32List.fromList');
+ }
+
patch factory Int32List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Int32List.view');
@@ -84,6 +108,10 @@
throw new UnsupportedError('Uint32List');
}
+ patch factory Uint32List.fromList(List<int> elements) {
+ throw new UnsupportedError('Uint32List.fromList');
+ }
+
patch factory Uint32List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Uint32List.view');
@@ -96,6 +124,10 @@
throw new UnsupportedError('Int64List');
}
+ patch factory Int64List.fromList(List<int> elements) {
+ throw new UnsupportedError('Int64List.fromList');
+ }
+
patch factory Int64List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Int64List.view');
@@ -108,6 +140,10 @@
throw new UnsupportedError('Uint64List');
}
+ patch factory Uint64List.fromList(List<int> elements) {
+ throw new UnsupportedError('Uint64List.fromList');
+ }
+
patch factory Uint64List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Uint64List.view');
@@ -120,6 +156,10 @@
throw new UnsupportedError('Float32List');
}
+ patch factory Float32List.fromList(List<double> elements) {
+ throw new UnsupportedError('Float32List.fromList');
+ }
+
patch factory Float32List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Float32List.view');
@@ -132,6 +172,10 @@
throw new UnsupportedError('Float64List');
}
+ patch factory Float64List.fromList(List<double> elements) {
+ throw new UnsupportedError('Float64List.fromList');
+ }
+
patch factory Float64List.view(ByteBuffer buffer,
[int offsetInBytes = 0, int length]) {
throw new UnsupportedError('Float64List.view');
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
index 70114423..c86321f 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart
@@ -87,7 +87,7 @@
system.compiler.internalError("Unexpected type $type of kind ${type.kind}");
}
-Collection<Dart2JsMemberMirror> _convertElementMemberToMemberMirrors(
+Iterable<Dart2JsMemberMirror> _convertElementMemberToMemberMirrors(
Dart2JsContainerMirror library, Element element) {
if (element.isSynthesized) {
return const <Dart2JsMemberMirror>[];
@@ -216,10 +216,10 @@
new FormattingDiagnosticHandler(provider).diagnosticHandler;
}
Uri scriptUri = cwd.resolve(script.toString());
- Uri libraryUri = cwd.resolve('${libraryRoot}/');
+ Uri libraryUri = cwd.resolve(appendSlash('$libraryRoot'));
Uri packageUri = null;
if (packageRoot != null) {
- packageUri = cwd.resolve('${packageRoot}/');
+ packageUri = cwd.resolve(appendSlash('$packageRoot'));
}
return api.compile(scriptUri, libraryUri, packageUri,
provider.readStringFromUri, diagnosticHandler, options);
@@ -290,10 +290,10 @@
diagnosticHandler =
new FormattingDiagnosticHandler(provider).diagnosticHandler;
}
- Uri libraryUri = cwd.resolve('${libraryRoot}/');
+ Uri libraryUri = cwd.resolve(appendSlash('$libraryRoot'));
Uri packageUri = null;
if (packageRoot != null) {
- packageUri = cwd.resolve('${packageRoot}/');
+ packageUri = cwd.resolve(appendSlash('$packageRoot'));
}
List<Uri> librariesUri = <Uri>[];
for (Path library in libraries) {
@@ -1655,7 +1655,7 @@
int get length => _constant.length;
- Collection<String> get keys {
+ Iterable<String> get keys {
// TODO(johnniwinther): Return an unmodifiable list instead.
return new List<String>.from(_list);
}
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart
index cec6c29..dd8c70f 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart
@@ -169,7 +169,7 @@
/**
* Returns a collection containing all the keys in the map.
*/
- Collection<String> get keys;
+ Iterable<String> get keys;
/**
* Returns a future on the instance mirror of the value for the given key or
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/util.dart b/sdk/lib/_internal/compiler/implementation/mirrors/util.dart
index 3470211..7760da1 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/util.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/util.dart
@@ -45,13 +45,13 @@
return found;
}
- Collection<K> get keys {
+ Iterable<K> get keys {
var keys = <K>[];
forEach((k,_) => keys.add(k));
return keys;
}
- Collection<V> get values {
+ Iterable<V> get values {
var values = <V>[];
forEach((_,v) => values.add(v));
return values;
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index e6fd478..c8598e8 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -15,9 +15,6 @@
Selector getSelector(Send send);
Selector getGetterSelectorInComplexSendSet(SendSet node);
Selector getOperatorSelectorInComplexSendSet(SendSet node);
- Selector getIteratorSelector(ForIn node);
- Selector getMoveNextSelector(ForIn node);
- Selector getCurrentSelector(ForIn node);
DartType getType(Node node);
bool isParameterChecked(Element element);
@@ -99,34 +96,6 @@
return selectors[node.assignmentOperator];
}
- // The following methods set selectors on the "for in" node. Since
- // we're using three selectors, we need to use children of the node,
- // and we arbitrarily choose which ones.
-
- Selector setIteratorSelector(ForIn node, Selector selector) {
- selectors[node] = selector;
- }
-
- Selector getIteratorSelector(ForIn node) {
- return selectors[node];
- }
-
- Selector setMoveNextSelector(ForIn node, Selector selector) {
- selectors[node.forToken] = selector;
- }
-
- Selector getMoveNextSelector(ForIn node) {
- return selectors[node.forToken];
- }
-
- Selector setCurrentSelector(ForIn node, Selector selector) {
- selectors[node.inToken] = selector;
- }
-
- Selector getCurrentSelector(ForIn node) {
- return selectors[node.inToken];
- }
-
bool isParameterChecked(Element element) {
return checkedParameters.contains(element);
}
@@ -1555,7 +1524,12 @@
}
}
} else if (element.isTypeVariable()) {
- if (enclosingElement.isInStaticMember()) {
+ Element outer = enclosingElement.getOutermostEnclosingMemberOrTopLevel();
+ bool isInFactoryConstructor = outer != null && outer.isFactoryConstructor();
+ if (!outer.isClass()
+ && !outer.isTypedef()
+ && !isInFactoryConstructor
+ && Elements.isInStaticContext(enclosingElement)) {
compiler.backend.registerThrowRuntimeError(
// TODO(ahe): Get the TreeElements for the current element.
compiler.globalDependencies);
@@ -2477,7 +2451,11 @@
if (!inCatchBlock && node.expression == null) {
error(node, MessageKind.THROW_WITHOUT_EXPRESSION);
}
- compiler.backend.registerThrow(mapping);
+ // We don't know ahead of time whether we will need the throw in a statement
+ // context or an expression context, so we register both here, even though
+ // we may not need ThrowExpression.
+ compiler.backend.registerWrapException(mapping);
+ compiler.backend.registerThrowExpression(mapping);
visit(node.expression);
}
@@ -2538,9 +2516,11 @@
// and only declaration elements may be registered.
world.registerStaticUse(constructor.declaration);
ClassElement cls = constructor.getEnclosingClass();
- // [cls] might be the implementation element and only declaration elements
- // may be registered.
- world.registerInstantiatedType(mapping.getType(node), mapping);
+ InterfaceType type = mapping.getType(node);
+ world.registerInstantiatedType(type, mapping);
+ if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) {
+ world.registerFactoryWithTypeArguments(mapping);
+ }
if (cls.isAbstract(compiler)) {
compiler.backend.registerAbstractClassInstantiation(mapping);
}
@@ -2616,8 +2596,10 @@
listType = new InterfaceType(compiler.listClass,
new Link<DartType>.fromList([typeArgument]));
} else {
+ compiler.listClass.computeType(compiler);
listType = compiler.listClass.rawType;
}
+ mapping.setType(node, listType);
world.registerInstantiatedType(listType, mapping);
visit(node.elements);
}
@@ -2707,37 +2689,61 @@
visitForIn(ForIn node) {
LibraryElement library = enclosingElement.getLibrary();
- Selector iteratorSelector =
- new Selector.getter(const SourceString('iterator'), library);
- world.registerDynamicGetter(iteratorSelector.name, iteratorSelector);
- mapping.setIteratorSelector(node, iteratorSelector);
-
- Selector currentSelector =
- new Selector.getter(const SourceString('current'), library);
- world.registerDynamicGetter(currentSelector.name, currentSelector);
- mapping.setCurrentSelector(node, currentSelector);
-
- Selector moveNextSelector =
- new Selector.call(const SourceString('moveNext'), library, 0);
- world.registerDynamicInvocation(moveNextSelector.name, moveNextSelector);
- mapping.setMoveNextSelector(node, moveNextSelector);
+ world.registerDynamicGetter(compiler.iteratorSelector.name,
+ compiler.iteratorSelector);
+ world.registerDynamicGetter(compiler.currentSelector.name,
+ compiler.currentSelector);
+ world.registerDynamicInvocation(compiler.moveNextSelector.name,
+ compiler.moveNextSelector);
visit(node.expression);
Scope blockScope = new BlockScope(scope);
Node declaration = node.declaredIdentifier;
visitIn(declaration, blockScope);
- visitLoopBodyIn(node, node.body, blockScope);
- // TODO(lrn): Also allow a single identifier.
- if ((declaration is !Send || declaration.asSend().selector is !Identifier
- || declaration.asSend().receiver != null)
- && (declaration is !VariableDefinitions ||
- !declaration.asVariableDefinitions().definitions.nodes.tail.isEmpty))
- {
- // The variable declaration is either not an identifier, not a
- // declaration, or it's declaring more than one variable.
- error(node.declaredIdentifier, MessageKind.INVALID_FOR_IN);
+ Send send = declaration.asSend();
+ VariableDefinitions variableDefinitions =
+ declaration.asVariableDefinitions();
+ Element loopVariable;
+ Selector loopVariableSelector;
+ if (send != null) {
+ loopVariable = mapping[send];
+ Identifier identifier = send.selector.asIdentifier();
+ if (identifier == null) {
+ compiler.reportErrorCode(send.selector, MessageKind.INVALID_FOR_IN);
+ } else {
+ loopVariableSelector = new Selector.setter(identifier.source, library);
+ }
+ if (send.receiver != null) {
+ compiler.reportErrorCode(send.receiver, MessageKind.INVALID_FOR_IN);
+ }
+ } else if (variableDefinitions != null) {
+ Link<Node> nodes = variableDefinitions.definitions.nodes;
+ if (!nodes.tail.isEmpty) {
+ compiler.reportErrorCode(nodes.tail.head, MessageKind.INVALID_FOR_IN);
+ }
+ Node first = nodes.head;
+ Identifier identifier = first.asIdentifier();
+ if (identifier == null) {
+ compiler.reportErrorCode(first, MessageKind.INVALID_FOR_IN);
+ } else {
+ loopVariableSelector = new Selector.setter(identifier.source, library);
+ loopVariable = mapping[identifier];
+ }
+ } else {
+ compiler.reportErrorCode(declaration, MessageKind.INVALID_FOR_IN);
}
+ if (loopVariableSelector != null) {
+ mapping.setSelector(declaration, loopVariableSelector);
+ } else {
+ // The selector may only be null if we reported an error.
+ assert(invariant(declaration, compiler.compilationFailed));
+ }
+ if (loopVariable != null) {
+ // loopVariable may be null if it could not be resolved.
+ mapping[declaration] = loopVariable;
+ }
+ visitLoopBodyIn(node, node.body, blockScope);
}
visitLabel(Label node) {
@@ -2773,6 +2779,36 @@
}
visitLiteralMap(LiteralMap node) {
+ NodeList arguments = node.typeArguments;
+ DartType keyTypeArgument;
+ DartType valueTypeArgument;
+ if (arguments != null) {
+ Link<Node> nodes = arguments.nodes;
+ if (nodes.isEmpty) {
+ error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
+ } else {
+ keyTypeArgument = resolveTypeRequired(nodes.head);
+ nodes = nodes.tail;
+ if (nodes.isEmpty) {
+ error(arguments, MessageKind.MISSING_TYPE_ARGUMENT);
+ } else {
+ valueTypeArgument = resolveTypeRequired(nodes.head);
+ for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) {
+ error(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
+ resolveTypeRequired(nodes.head);
+ }
+ }
+ }
+ }
+ DartType mapType;
+ if (valueTypeArgument != null) {
+ mapType = new InterfaceType(compiler.mapClass,
+ new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument]));
+ } else {
+ compiler.mapClass.computeType(compiler);
+ mapType = compiler.mapClass.rawType;
+ }
+ mapping.setType(node, mapType);
world.registerInstantiatedClass(compiler.mapClass, mapping);
if (node.isConst()) {
compiler.backend.registerConstantMap(mapping);
@@ -2968,17 +3004,30 @@
if (typeNode.bound != null) {
DartType boundType = typeResolver.resolveTypeAnnotation(
typeNode.bound, scope, element, onFailure: warning);
- if (boundType != null && boundType.element == variableElement) {
- // TODO(johnniwinther): Check for more general cycles, like
- // [: <A extends B, B extends C, C extends B> :].
- warning(node, MessageKind.CYCLIC_TYPE_VARIABLE,
- {'typeVariableName': variableElement.name});
- } else if (boundType != null) {
- variableElement.bound = boundType;
- } else {
- // TODO(johnniwinther): Should be an erroneous type.
- variableElement.bound = compiler.objectClass.computeType(compiler);
+ variableElement.bound = boundType;
+
+ void checkTypeVariableBound() {
+ Link<TypeVariableElement> seenTypeVariables =
+ const Link<TypeVariableElement>();
+ seenTypeVariables = seenTypeVariables.prepend(variableElement);
+ DartType bound = boundType;
+ while (bound.element.isTypeVariable()) {
+ TypeVariableElement element = bound.element;
+ if (seenTypeVariables.contains(element)) {
+ if (identical(element, variableElement)) {
+ // Only report an error on the checked type variable to avoid
+ // generating multiple errors for the same cyclicity.
+ warning(typeNode.name, MessageKind.CYCLIC_TYPE_VARIABLE,
+ {'typeVariableName': variableElement.name});
+ }
+ break;
+ }
+ seenTypeVariables = seenTypeVariables.prepend(element);
+ bound = element.bound;
+ }
}
+ compiler.enqueuer.resolution.addPostProcessAction(
+ element, checkTypeVariableBound);
} else {
variableElement.bound = compiler.objectClass.computeType(compiler);
}
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 9eed786..d32bfb3 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -36,14 +36,14 @@
SsaBuilder builder = new SsaBuilder(constantSystem, this, work);
HGraph graph;
ElementKind kind = element.kind;
- if (identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR)) {
+ if (kind == ElementKind.GENERATIVE_CONSTRUCTOR) {
graph = compileConstructor(builder, work);
- } else if (identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR_BODY) ||
- identical(kind, ElementKind.FUNCTION) ||
- identical(kind, ElementKind.GETTER) ||
- identical(kind, ElementKind.SETTER)) {
+ } else if (kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY ||
+ kind == ElementKind.FUNCTION ||
+ kind == ElementKind.GETTER ||
+ kind == ElementKind.SETTER) {
graph = builder.buildMethod(element);
- } else if (identical(kind, ElementKind.FIELD)) {
+ } else if (kind == ElementKind.FIELD) {
graph = builder.buildLazyInitializer(element);
} else {
compiler.internalErrorOnElement(element,
@@ -110,6 +110,7 @@
}
}
+
/**
* Keeps track of locals (including parameters and phis) when building. The
* 'this' reference is treated as parameter and hence handled by this class,
@@ -440,8 +441,9 @@
}
/**
- * This function must be called before visiting any children of the loop. In
- * particular it needs to be called before executing the initializers.
+ * This function, startLoop, must be called before visiting any children of
+ * the loop. In particular it needs to be called before executing the
+ * initializers.
*
* The [LocalsHandler] will make the boxes and updates at the right moment.
* The builder just needs to call [enterLoopBody] and [enterLoopUpdates] (for
@@ -608,7 +610,7 @@
new LinkedHashMap<Element,HInstruction>();
HInstruction thisValue = null;
directLocals.forEach((Element element, HInstruction instruction) {
- if (!identical(element, closureData.thisElement)) {
+ if (element != closureData.thisElement) {
HPhi phi = new HPhi.noInputs(element);
joinedLocals[element] = phi;
joinBlock.addPhi(phi);
@@ -631,7 +633,17 @@
// If there was a "this" for the scope, add it to the new locals.
joinedLocals[closureData.thisElement] = thisValue;
}
- directLocals = joinedLocals;
+
+ // Remove locals that are not in all handlers.
+ directLocals = new LinkedHashMap<Element, HInstruction>();
+ joinedLocals.forEach((element, instruction) {
+ if (instruction is HPhi
+ && instruction.inputs.length != localsHandlers.length) {
+ joinBlock.removePhi(instruction);
+ } else {
+ directLocals[element] = instruction;
+ }
+ });
return this;
}
}
@@ -794,14 +806,28 @@
// We build the Ssa graph by simulating a stack machine.
List<HInstruction> stack;
- // The current block to add instructions to. Might be null, if we are
- // visiting dead code.
- HBasicBlock current;
- // The most recently opened block. Has the same value as [current] while
- // the block is open, but unlike [current], it isn't cleared when the current
- // block is closed.
+ /**
+ * The current block to add instructions to. Might be null, if we are
+ * visiting dead code, but see [isReachable].
+ */
+ HBasicBlock _current;
+
+ /**
+ * The most recently opened block. Has the same value as [_current] while
+ * the block is open, but unlike [_current], it isn't cleared when the
+ * current block is closed.
+ */
HBasicBlock lastOpenedBlock;
+ /**
+ * Indicates whether the current block is dead (because it has a throw or a
+ * return further up). If this is false, then [_current] may be null. If the
+ * block is dead then it may also be aborted, but for simplicity we only
+ * abort on statement boundaries, not in the middle of expressions. See
+ * isAborted.
+ */
+ bool isReachable = true;
+
final List<Element> sourceElementStack;
Element get currentElement => sourceElementStack.last.declaration;
@@ -831,6 +857,12 @@
DartType returnType;
bool inTryStatement = false;
+ HBasicBlock get current => _current;
+ void set current(c) {
+ isReachable = c != null;
+ _current = c;
+ }
+
/**
* Compiles compile-time constants. Never returns [:null:]. If the
* initial value is not a compile-time constants, it reports an
@@ -908,9 +940,8 @@
parameter, graph.addConstantNull(constantSystem)));
},
() {
- HReturn ret = new HReturn(
- graph.addConstantBool(false, constantSystem));
- close(ret).addSuccessor(graph.exit);
+ closeAndGotoExit(new HReturn(
+ graph.addConstantBool(false, constantSystem)));
},
null);
}
@@ -927,7 +958,7 @@
visit(link.head);
HInstruction value = pop();
value = potentiallyCheckType(value, variable.computeType(compiler));
- close(new HReturn(value)).addSuccessor(graph.exit);
+ closeAndGotoExit(new HReturn(value));
return closeFunction();
}
@@ -1350,9 +1381,7 @@
// closure to class mapper.
compiler.closureToClassMapper.computeClosureToClassMapping(
member, node, elements);
- sourceElementStack.add(member);
- right.accept(this);
- sourceElementStack.removeLast();
+ inlinedFrom(member, () => right.accept(this));
elements = savedElements;
value = pop();
}
@@ -1506,7 +1535,7 @@
invoke.element = body;
add(invoke);
}
- close(new HReturn(newObject)).addSuccessor(graph.exit);
+ closeAndGotoExit(new HReturn(newObject));
return closeFunction();
}
@@ -1634,7 +1663,7 @@
HGraph closeFunction() {
// TODO(kasperl): Make this goto an implicit return.
- if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit);
+ if (!isAborted()) closeAndGotoExit(new HGoto());
graph.finalize();
return graph;
}
@@ -1659,13 +1688,21 @@
return result;
}
+ HBasicBlock closeAndGotoExit(HControlFlow end) {
+ HBasicBlock result = current;
+ current.close(end);
+ current = null;
+ result.addSuccessor(graph.exit);
+ return result;
+ }
+
void goto(HBasicBlock from, HBasicBlock to) {
from.close(new HGoto());
from.addSuccessor(to);
}
bool isAborted() {
- return current == null;
+ return _current == null;
}
/**
@@ -1752,11 +1789,13 @@
}
visitBlock(Block node) {
+ assert(!isAborted());
+ if (!isReachable) return; // This can only happen when inlining.
for (Link<Node> link = node.statements.nodes;
!link.isEmpty;
link = link.tail) {
visit(link.head);
- if (isAborted()) {
+ if (!isReachable) {
// The block has been aborted by a return or a throw.
if (!stack.isEmpty) compiler.cancel('non-empty instruction stack');
return;
@@ -1771,6 +1810,7 @@
}
visitExpressionStatement(ExpressionStatement node) {
+ assert(isReachable);
visit(node.expression);
pop();
}
@@ -2049,6 +2089,7 @@
}
visitFor(For node) {
+ assert(isReachable);
assert(node.body != null);
void buildInitializer() {
if (node.initializer == null) return;
@@ -2083,6 +2124,7 @@
}
visitWhile(While node) {
+ assert(isReachable);
HInstruction buildCondition() {
visit(node.condition);
return popBoolified();
@@ -2095,6 +2137,7 @@
}
visitDoWhile(DoWhile node) {
+ assert(isReachable);
LocalsHandler savedLocals = new LocalsHandler.from(localsHandler);
localsHandler.startLoop(node);
JumpHandler jumpHandler = beginLoopHeader(node);
@@ -2257,6 +2300,7 @@
}
visitFunctionDeclaration(FunctionDeclaration node) {
+ assert(isReachable);
visit(node.function);
localsHandler.updateLocal(elements[node], pop());
}
@@ -2271,6 +2315,7 @@
}
visitIf(If node) {
+ assert(isReachable);
handleIf(node,
() => visit(node.condition),
() => visit(node.thenPart),
@@ -2452,31 +2497,38 @@
void generateInstanceSetterWithCompiledReceiver(Send send,
HInstruction receiver,
- HInstruction value) {
- assert(Elements.isInstanceSend(send, elements));
- Selector selector = elements.getSelector(send);
+ HInstruction value,
+ {Selector selector,
+ Node location}) {
+ assert(send == null || Elements.isInstanceSend(send, elements));
+ if (selector == null) {
+ assert(send != null);
+ selector = elements.getSelector(send);
+ }
+ if (location == null) {
+ assert(send != null);
+ location = send;
+ }
assert(selector.isSetter());
- SourceString setterName = selector.name;
bool hasSetter = compiler.world.hasAnyUserDefinedSetter(selector);
Set<ClassElement> interceptedClasses =
- backend.getInterceptedClassesOn(setterName);
+ backend.getInterceptedClassesOn(selector.name);
+ HInstruction instruction;
if (interceptedClasses != null) {
// If we're using an interceptor class, emit a call to the
// getInterceptor method and then the actual dynamic call on the
// interceptor object.
- HInstruction instruction =
- invokeInterceptor(interceptedClasses, receiver, send);
+ instruction = invokeInterceptor(interceptedClasses, receiver, send);
instruction = new HInvokeDynamicSetter(
selector, null, instruction, receiver, !hasSetter);
// Add the value as an argument to the setter call on the
// interceptor.
instruction.inputs.add(value);
- addWithPosition(instruction, send);
} else {
- addWithPosition(
- new HInvokeDynamicSetter(selector, null, receiver, value, !hasSetter),
- send);
+ instruction = new HInvokeDynamicSetter(
+ selector, null, receiver, value, !hasSetter);
}
+ addWithPosition(instruction, location);
stack.add(value);
}
@@ -3028,7 +3080,7 @@
node: node.argumentsNode);
}
String constructorName = backend.namer.isolateName;
- push(new HForeign(new DartString.literal("new $constructorName"),
+ push(new HForeign(new DartString.literal("new $constructorName()"),
HType.UNKNOWN,
<HInstruction>[]));
}
@@ -3357,6 +3409,9 @@
}
}
+ if (constructor.isFactoryConstructor() && !type.typeArguments.isEmpty) {
+ compiler.enqueuer.codegen.registerFactoryWithTypeArguments(elements);
+ }
HType elementType = computeType(constructor);
HInstruction newInstance = new HInvokeStatic(inputs, elementType);
pushWithPosition(newInstance, node);
@@ -3886,7 +3941,7 @@
if (!inliningStack.isEmpty) {
localsHandler.updateLocal(returnElement, value);
} else {
- close(attachPosition(new HReturn(value), node)).addSuccessor(graph.exit);
+ closeAndGotoExit(attachPosition(new HReturn(value), node));
}
}
@@ -3898,10 +3953,20 @@
compiler.internalError(
'rethrowableException should not be null', node: node);
}
- close(new HThrow(exception, isRethrow: true));
+ handleInTryStatement();
+ closeAndGotoExit(new HThrow(exception, isRethrow: true));
} else {
visit(node.expression);
- close(new HThrow(pop()));
+ handleInTryStatement();
+ if (inliningStack.isEmpty) {
+ closeAndGotoExit(new HThrow(pop()));
+ } else if (isReachable) {
+ // We don't close the block when we are inlining, because we could be
+ // inside an expression, and it is rather complicated to close the
+ // block at an arbitrary place in an expression.
+ add(new HThrowExpression(pop()));
+ isReachable = false;
+ }
}
}
@@ -3911,6 +3976,7 @@
}
visitVariableDefinitions(VariableDefinitions node) {
+ assert(isReachable);
for (Link<Node> link = node.definitions.nodes;
!link.isEmpty;
link = link.tail) {
@@ -4026,7 +4092,7 @@
// The iterator is shared between initializer, condition and body.
HInstruction iterator;
void buildInitializer() {
- Selector selector = elements.getIteratorSelector(node);
+ Selector selector = compiler.iteratorSelector;
Set<ClassElement> interceptedClasses =
backend.getInterceptedClassesOn(selector.name);
visit(node.expression);
@@ -4047,28 +4113,34 @@
add(iterator);
}
HInstruction buildCondition() {
- Selector selector = elements.getMoveNextSelector(node);
+ Selector selector = compiler.moveNextSelector;
push(new HInvokeDynamicMethod(selector, <HInstruction>[iterator]));
return popBoolified();
}
void buildBody() {
- Selector call = elements.getCurrentSelector(node);
+ Selector call = compiler.currentSelector;
bool hasGetter = compiler.world.hasAnyUserDefinedGetter(call);
push(new HInvokeDynamicGetter(call, null, iterator, !hasGetter));
- Element variable;
- if (node.declaredIdentifier.asSend() != null) {
- variable = elements[node.declaredIdentifier];
- } else {
- assert(node.declaredIdentifier.asVariableDefinitions() != null);
- VariableDefinitions variableDefinitions = node.declaredIdentifier;
- variable = elements[variableDefinitions.definitions.nodes.head];
- }
+ Element variable = elements[node.declaredIdentifier];
+ Selector selector = elements.getSelector(node.declaredIdentifier);
+
HInstruction oldVariable = pop();
- if (variable.isErroneous()) {
- generateThrowNoSuchMethod(node,
- getTargetName(variable, 'set'),
- argumentValues: <HInstruction>[oldVariable]);
+ if (Elements.isUnresolved(variable)) {
+ if (Elements.isInStaticContext(currentElement)) {
+ generateThrowNoSuchMethod(
+ node.declaredIdentifier,
+ 'set ${selector.name.slowToString()}',
+ argumentValues: <HInstruction>[oldVariable]);
+ } else {
+ // The setter may have been defined in a subclass.
+ generateInstanceSetterWithCompiledReceiver(
+ null,
+ localsHandler.readThis(),
+ oldVariable,
+ selector: selector,
+ location: node.declaredIdentifier);
+ }
pop();
} else {
localsHandler.updateLocal(variable, oldVariable);
@@ -4313,7 +4385,7 @@
if (!isAborted() && caseIterator.hasNext) {
pushInvokeHelper0(getFallThroughErrorElement, HType.UNKNOWN);
HInstruction error = pop();
- close(new HThrow(error));
+ closeAndGotoExit(new HThrow(error));
}
statements.add(
new HSubGraphBlockInformation(new SubGraph(block, lastOpenedBlock)));
@@ -4430,7 +4502,7 @@
compiler.findHelper(const SourceString("getFallThroughError"));
pushInvokeHelper0(element, HType.UNKNOWN);
HInstruction error = pop();
- close(new HThrow(error));
+ closeAndGotoExit(new HThrow(error));
}
}
@@ -4646,7 +4718,7 @@
void visitElse() {
if (link.isEmpty) {
- close(new HThrow(exception, isRethrow: true));
+ closeAndGotoExit(new HThrow(exception, isRethrow: true));
} else {
CatchBlock newBlock = link.head;
handleIf(node,
@@ -4688,9 +4760,6 @@
var last = block.last;
if (last is HExitTry) {
block.addSuccessor(successor);
- } else if (last is HTry) {
- // Skip all blocks inside this nested try/catch.
- i = last.joinBlock.id;
}
}
}
@@ -4904,9 +4973,11 @@
tooDifficult = true;
}
- void visitThrow(Node node) {
+ void visitThrow(Throw node) {
if (!registerNode()) return;
- tooDifficult = true;
+ // We can't inline rethrows and we don't want to handle throw after a return
+ // even if it is in an "if".
+ if (seenReturn || node.expression == null) tooDifficult = true;
}
}
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
index 42f055a..e201af0 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
@@ -337,11 +337,11 @@
// Register return types to the backend.
graph.exit.predecessors.forEach((HBasicBlock block) {
HInstruction last = block.last;
- assert(last is HGoto || last is HReturn);
+ assert(last is HGoto || last is HReturn || last is HThrow);
if (last is HReturn) {
backend.registerReturnType(
work.element, last.inputs[0].instructionType);
- } else {
+ } else if (last is HGoto) {
backend.registerReturnType(work.element, HType.NULL);
}
});
@@ -1743,12 +1743,24 @@
}
pushStatement(new js.LiteralStatement(code), node);
} else {
- List<js.Expression> data = <js.Expression>[];
- for (int i = 0; i < inputs.length; i++) {
- use(inputs[i]);
- data.add(pop());
+ // We can parse simple JS with the mini parser. At the moment we can't
+ // handle expression interpolation with # and we can't handle JSON
+ // literals and function literals, both of which contain "{".
+ if (!code.contains("#") && !code.contains("{")) {
+ js.Expression codeAst = js.js(code);
+ push(codeAst, node);
+ if (!inputs.isEmpty) {
+ compiler.internalError("Too many arguments to JS expression",
+ instruction: node);
+ }
+ } else {
+ List<js.Expression> data = <js.Expression>[];
+ for (int i = 0; i < inputs.length; i++) {
+ use(inputs[i]);
+ data.add(pop());
+ }
+ push(new js.LiteralExpression.withData(code, data), node);
}
- push(new js.LiteralExpression.withData(code, data), node);
}
registerForeignType(node.instructionType);
// TODO(sra): Tell world.nativeEnqueuer about the types created here.
@@ -1917,7 +1929,7 @@
use(node.inputs[0]);
pushStatement(new js.Throw(pop()), node);
} else {
- generateThrowWithHelper(r'$throw', node.inputs[0]);
+ generateThrowWithHelper('wrapException', node.inputs[0]);
}
}
@@ -1995,6 +2007,20 @@
pushStatement(new js.Throw(value));
}
+ visitThrowExpression(HThrowExpression node) {
+ HInstruction argument = node.inputs[0];
+ use(argument);
+
+ Element helper = compiler.findHelper(new SourceString("throwExpression"));
+ world.registerStaticUse(helper);
+
+ js.VariableUse jsHelper =
+ new js.VariableUse(backend.namer.isolateAccess(helper));
+ js.Call value = new js.Call(jsHelper, [pop()]);
+ attachLocation(value, argument);
+ push(value, node);
+ }
+
void visitSwitch(HSwitch node) {
// Switches are handled using [visitSwitchInfo].
}
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/nodes.dart b/sdk/lib/_internal/compiler/implementation/ssa/nodes.dart
index c1b9796..745f489 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/nodes.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/nodes.dart
@@ -64,6 +64,7 @@
R visitSwitch(HSwitch node);
R visitThis(HThis node);
R visitThrow(HThrow node);
+ R visitThrowExpression(HThrowExpression node);
R visitTry(HTry node);
R visitTypeGuard(HTypeGuard node);
R visitTypeConversion(HTypeConversion node);
@@ -339,6 +340,7 @@
visitStringify(HStringify node) => visitInstruction(node);
visitThis(HThis node) => visitParameterValue(node);
visitThrow(HThrow node) => visitControlFlow(node);
+ visitThrowExpression(HThrowExpression node) => visitInstruction(node);
visitTry(HTry node) => visitControlFlow(node);
visitTypeGuard(HTypeGuard node) => visitCheck(node);
visitIs(HIs node) => visitInstruction(node);
@@ -2018,6 +2020,13 @@
accept(HVisitor visitor) => visitor.visitReturn(this);
}
+class HThrowExpression extends HInstruction {
+ HThrowExpression(value) : super(<HInstruction>[value]);
+ toString() => 'throw expression';
+ accept(HVisitor visitor) => visitor.visitThrowExpression(this);
+ bool canThrow() => true;
+}
+
class HThrow extends HControlFlow {
final bool isRethrow;
HThrow(value, {this.isRethrow: false}) : super(<HInstruction>[value]);
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart b/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
index a44058c..65a82ca 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/optimize.dart
@@ -815,7 +815,9 @@
TypeMask receiverMask = receiverType.computeMask(compiler);
return interceptedClasses
.where((cls) => cls != compiler.objectClass)
- .map((cls) => new TypeMask.subclass(cls.rawType))
+ .map((cls) => backend.classesMixedIntoNativeClasses.contains(cls)
+ ? new TypeMask.subtype(cls.rawType)
+ : new TypeMask.subclass(cls.rawType))
.every((mask) => receiverMask.intersection(mask, compiler).isEmpty);
}
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/tracer.dart b/sdk/lib/_internal/compiler/implementation/ssa/tracer.dart
index ca58e8f..1dc573d 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/tracer.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/tracer.dart
@@ -479,6 +479,10 @@
String visitThrow(HThrow node) => "Throw ${temporaryId(node.inputs[0])}";
+ String visitThrowExpression(HThrowExpression node) {
+ return "ThrowExpression ${temporaryId(node.inputs[0])}";
+ }
+
String visitExitTry(HExitTry node) {
return "Exit try";
}
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/validate.dart b/sdk/lib/_internal/compiler/implementation/ssa/validate.dart
index 8d98afe..16de943 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/validate.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/validate.dart
@@ -44,21 +44,17 @@
if (block.last is HJump && block.successors.length != 1) {
markInvalid("Break or continue node without one successor");
}
- if (block.last is HReturn &&
+ if ((block.last is HReturn || block.last is HThrow) &&
(block.successors.length != 1 || !block.successors[0].isExitBlock())) {
- markInvalid("Return node with > 1 succesor or not going to exit-block");
+ markInvalid("Return or throw node with > 1 successor "
+ "or not going to exit-block");
}
if (block.last is HExit && !block.successors.isEmpty) {
markInvalid("Exit block with successor");
}
- if (block.last is HThrow && !block.successors.isEmpty) {
- markInvalid("Throw block with successor");
- }
- if (block.successors.isEmpty &&
- block.last is !HThrow &&
- !block.isExitBlock()) {
- markInvalid("Non-exit or throw block without successor");
+ if (block.successors.isEmpty && !block.isExitBlock()) {
+ markInvalid("Non-exit block without successor");
}
// Check that successors ids are always higher than the current one.
diff --git a/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
index f116845..4f265f0 100644
--- a/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart
@@ -398,7 +398,7 @@
if (baseType.isUnknown()) return false;
if (baseType.isNull()) continue;
ClassBaseType classType = baseType;
- if (!types.isSubtype(new InterfaceType(classType.element),
+ if (!types.isSubtype(classType.element.rawType,
parameterType)) return false;
}
return true;
diff --git a/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart b/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
index c61db0c..6c923c0 100644
--- a/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
+++ b/sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart
@@ -179,11 +179,11 @@
* of a field, these [Node] are initially discarded, and once the
* type is computed, we make sure these constraints are satisfied
* for that type. For example:
- *
+ *
* [: field++ ], or [: field += 42 :], the constraint is on the
* operator+, and we make sure that a typed selector with the found
* type returns that type.
- *
+ *
* [: field = other.field :], the constraint in on the [:field]
* getter selector, and we make sure that the getter selector
* returns that type.
@@ -265,7 +265,8 @@
recompiles++;
recomputeWatch.start();
}
- bool changed = analyze(element);
+ bool changed =
+ compiler.withCurrentElement(element, () => analyze(element));
analyzed++;
if (wasAnalyzed) {
recomputeWatch.stop();
@@ -1199,7 +1200,7 @@
if (analyzedElement.isField()) {
return visit(node.asSendSet().arguments.head);
}
-
+
FunctionElement function = analyzedElement;
FunctionSignature signature = function.computeSignature(compiler);
signature.forEachOptionalParameter((element) {
@@ -1532,46 +1533,9 @@
}
} else if (op == '=') {
// [: foo = 42 :] or [: foo.bar = 42 :].
- ArgumentsTypes arguments = new ArgumentsTypes([rhsType], null);
- if (Elements.isStaticOrTopLevelField(element)) {
- handleStaticSend(node, setterSelector, element, arguments);
- } else if (Elements.isUnresolved(element) || element.isSetter()) {
- handleDynamicSend(node, setterSelector, receiverType, arguments);
- } else if (element.isField()) {
- if (element.modifiers.isFinal()) {
- inferrer.recordFinalFieldType(
- node, outermostElement, element, rhsType);
- } else {
- locals.updateField(element, rhsType);
- if (visitingInitializers) {
- inferrer.recordNonFinalFieldElementType(node, element, rhsType);
- } else {
- handleDynamicSend(node, setterSelector, receiverType, arguments);
- }
- }
- } else if (Elements.isLocal(element)) {
- locals.update(element, rhsType);
- }
-
- if (!Elements.isLocal(element)) {
- // Recognize a constraint of the form [: field = other.field :].
- // Note that we check if the right hand side is a local to
- // recognize the situation [: var a = 42; this.a = a; :]. Our
- // constraint mechanism only works with members or top level
- // elements.
- var rhs = node.arguments.head;
- if (rhs.asSend() != null
- && rhs.isPropertyAccess
- && !Elements.isLocal(elements[rhs])
- && rhs.selector.source == node.selector.asIdentifier().source) {
- // TODO(ngeoffray): We should update selectors in the
- // element tree and find out if the typed selector still
- // applies to the receiver type.
- Selector constraint = elements.getSelector(rhs);
- inferrer.recordSetterConstraint(node, constraint);
- }
- }
- return rhsType;
+ return handlePlainAssignment(
+ node, element, setterSelector, receiverType, rhsType,
+ node.arguments.head);
} else {
// [: foo++ :] or [: foo += 1 :].
TypeMask getterType;
@@ -1622,6 +1586,55 @@
}
}
+ TypeMask handlePlainAssignment(Send node,
+ Element element,
+ Selector setterSelector,
+ TypeMask receiverType,
+ TypeMask rhsType,
+ Node rhs) {
+ ArgumentsTypes arguments = new ArgumentsTypes([rhsType], null);
+ if (Elements.isStaticOrTopLevelField(element)) {
+ handleStaticSend(node, setterSelector, element, arguments);
+ } else if (Elements.isUnresolved(element) || element.isSetter()) {
+ handleDynamicSend(node, setterSelector, receiverType, arguments);
+ } else if (element.isField()) {
+ if (element.modifiers.isFinal()) {
+ inferrer.recordFinalFieldType(
+ node, outermostElement, element, rhsType);
+ } else {
+ locals.updateField(element, rhsType);
+ if (visitingInitializers) {
+ inferrer.recordNonFinalFieldElementType(node, element, rhsType);
+ } else {
+ handleDynamicSend(node, setterSelector, receiverType, arguments);
+ }
+ }
+ } else if (Elements.isLocal(element)) {
+ locals.update(element, rhsType);
+ }
+
+ if (!Elements.isLocal(element)) {
+ // Recognize a constraint of the form [: field = other.field :].
+ // Note that we check if the right hand side is a local to
+ // recognize the situation [: var a = 42; this.a = a; :]. Our
+ // constraint mechanism only works with members or top level
+ // elements.
+ Send send = rhs.asSend();
+ if (send != null
+ && send.isPropertyAccess
+ && !Elements.isLocal(elements[rhs])
+ && send.selector.asIdentifier().source
+ == node.selector.asIdentifier().source) {
+ // TODO(ngeoffray): We should update selectors in the
+ // element tree and find out if the typed selector still
+ // applies to the receiver type.
+ Selector constraint = elements.getSelector(rhs);
+ inferrer.recordSetterConstraint(node, constraint);
+ }
+ }
+ return rhsType;
+ }
+
TypeMask visitIdentifier(Identifier node) {
if (node.isThis()) {
return thisType;
@@ -2006,24 +2019,24 @@
bool changed = false;
visit(node.expression);
if (!isThisExposed && node.expression.isThis()) {
- Selector iteratorSelector = elements.getIteratorSelector(node);
+ Selector iteratorSelector = compiler.iteratorSelector;
checkIfExposesThis(new TypedSelector(thisType, iteratorSelector));
TypeMask iteratorType = inferrer.typeOfSelector(iteratorSelector);
checkIfExposesThis(
- new TypedSelector(iteratorType, elements.getMoveNextSelector(node)));
+ new TypedSelector(iteratorType, compiler.moveNextSelector));
checkIfExposesThis(
- new TypedSelector(iteratorType, elements.getCurrentSelector(node)));
+ new TypedSelector(iteratorType, compiler.currentSelector));
}
- Element variable;
- if (node.declaredIdentifier.asSend() != null) {
- variable = elements[node.declaredIdentifier];
+ Element variable = elements[node.declaredIdentifier];
+ Selector selector = elements.getSelector(node.declaredIdentifier);
+ if (!Elements.isUnresolved(variable)) {
+ locals.update(variable, inferrer.dynamicType);
} else {
- assert(node.declaredIdentifier.asVariableDefinitions() != null);
- VariableDefinitions variableDefinitions = node.declaredIdentifier;
- variable = elements[variableDefinitions.definitions.nodes.head];
+ handlePlainAssignment(new Send(), variable, selector,
+ inferrer.dynamicType, inferrer.dynamicType,
+ node.expression);
}
- locals.update(variable, inferrer.dynamicType);
loopLevel++;
do {
LocalsHandler saved = new LocalsHandler.from(locals);
diff --git a/sdk/lib/_internal/compiler/implementation/universe/function_set.dart b/sdk/lib/_internal/compiler/implementation/universe/function_set.dart
index dc30ef1..4375528 100644
--- a/sdk/lib/_internal/compiler/implementation/universe/function_set.dart
+++ b/sdk/lib/_internal/compiler/implementation/universe/function_set.dart
@@ -73,7 +73,7 @@
// compact than a hash set. Once we get enough elements, we change
// the representation to be a set to get faster contains checks.
static const int MAX_ELEMENTS_IN_LIST = 8;
- Collection<Element> elements = <Element>[];
+ var elements = <Element>[];
bool isList = true;
FunctionSetNode(this.name);
diff --git a/sdk/lib/_internal/compiler/implementation/universe/universe.dart b/sdk/lib/_internal/compiler/implementation/universe/universe.dart
index c167c6f..76d4fb2 100644
--- a/sdk/lib/_internal/compiler/implementation/universe/universe.dart
+++ b/sdk/lib/_internal/compiler/implementation/universe/universe.dart
@@ -50,6 +50,8 @@
final Set<Element> fieldSetters;
final Set<DartType> isChecks;
+ bool usingFactoryWithTypeArguments = false;
+
Universe() : instantiatedClasses = new Set<ClassElement>(),
instantiatedTypes = new Set<DartType>(),
staticFunctionsNeedingGetter = new Set<FunctionElement>(),
@@ -89,41 +91,6 @@
bool hasFieldSetter(Element member, Compiler compiler) {
return fieldSetters.contains(member);
}
-
- /**
- * Compute type arguments of classes that use one of their type variables in
- * is-checks and add the is-checks that they imply.
- *
- * This function must be called after all is-checks have been registered.
- *
- * TODO(karlklose): move these computations into a function producing an
- * immutable datastructure.
- */
- void addImplicitChecks(Iterable<ClassElement> classesUsingChecks) {
- // If there are no classes that use their variables in checks, there is
- // nothing to do.
- if (classesUsingChecks.isEmpty) return;
- // Find all instantiated types that are a subtype of a class that uses
- // one of its type arguments in an is-check and add the arguments to the
- // set of is-checks.
- // TODO(karlklose): replace this with code that uses a subtype lookup
- // datastructure in the world.
- for (DartType type in instantiatedTypes) {
- if (type.kind != TypeKind.INTERFACE) continue;
- InterfaceType classType = type;
- for (ClassElement cls in classesUsingChecks) {
- // We need the type as instance of its superclass anyway, so we just
- // try to compute the substitution; if the result is [:null:], the
- // classes are not related.
- InterfaceType instance = classType.asInstanceOf(cls);
- if (instance == null) continue;
- Link<DartType> typeArguments = instance.typeArguments;
- for (DartType argument in typeArguments) {
- isChecks.add(argument);
- }
- }
- }
- }
}
class SelectorKind {
diff --git a/sdk/lib/_internal/compiler/implementation/warnings.dart b/sdk/lib/_internal/compiler/implementation/warnings.dart
index 2e377a4..49c112e 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -191,7 +191,7 @@
"no default class on enclosing interface '#{interfaceName}'");
static const CYCLIC_TYPE_VARIABLE = const MessageKind(
- "cyclic reference to type variable #{typeVariableName}");
+ "type variable #{typeVariableName} is a supertype of itself");
static const CLASS_NAME_EXPECTED = const MessageKind(
"class name expected");
diff --git a/sdk/lib/_internal/dartdoc/bin/dartdoc.dart b/sdk/lib/_internal/dartdoc/bin/dartdoc.dart
index ec63c06..9190f31 100644
--- a/sdk/lib/_internal/dartdoc/bin/dartdoc.dart
+++ b/sdk/lib/_internal/dartdoc/bin/dartdoc.dart
@@ -18,9 +18,11 @@
import 'dart:async';
import 'dart:io';
+import 'dart:uri';
// TODO(rnystrom): Use "package:" URL (#4968).
import '../lib/dartdoc.dart';
+import '../lib/src/dartdoc/utils.dart';
import 'package:args/args.dart';
import 'package:pathos/path.dart' as path;
@@ -39,7 +41,7 @@
final Path libPath = scriptDir.append('../../../../');
- Path packageRoot;
+ String packageRoot;
argParser.addFlag('no-code',
help: 'Do not include source code in the documentation.',
@@ -166,7 +168,7 @@
' the entrypoint.',
callback: (packageDir) {
if(packageDir != null) {
- packageRoot = new Path(packageDir);
+ packageRoot = packageDir;
}
});
@@ -175,7 +177,7 @@
help: 'Deprecated: same as --package-root.',
callback: (packageDir) {
if(packageDir != null) {
- packageRoot = new Path(packageDir);
+ packageRoot = packageDir;
}
});
@@ -188,21 +190,22 @@
exit(1);
}
- final entrypoints = <Path>[];
+ final entrypoints = <Uri>[];
try {
final option = argParser.parse(args);
// This checks to see if the root of all entrypoints is the same.
// If it is not, then we display a warning, as package imports might fail.
var entrypointRoot;
- for(final arg in option.rest) {
- var entrypoint = new Path(arg);
- entrypoints.add(entrypoint);
+ for (final entrypoint in option.rest) {
+ var uri = Uri.parse(entrypoint);
+ if (uri.scheme == '') uri = pathToFileUri(entrypoint);
+ entrypoints.add(uri);
+ if (uri.scheme != 'file') continue;
if (entrypointRoot == null) {
- entrypointRoot = entrypoint.directoryPath;
- } else if (entrypointRoot.toNativePath() !=
- entrypoint.directoryPath.toNativePath()) {
+ entrypointRoot = path.dirname(entrypoint);
+ } else if (entrypointRoot != path.dirname(entrypoint)) {
print('Warning: entrypoints are at different directories. "package:"'
' imports may fail.');
}
@@ -220,40 +223,18 @@
exit(1);
}
- if (packageRoot == null) {
- // Check if there's a `packages` directory in the entry point directory.
- var script = path.normalize(path.absolute(entrypoints[0].toNativePath()));
- var dir = path.join(path.dirname(script), 'packages/');
- if (new Directory(dir).existsSync()) {
- // TODO(amouravski): convert all of dartdoc to use pathos.
- packageRoot = new Path(dir);
- } else {
- // If there is not, then check if the entrypoint is somewhere in a `lib`
- // directory.
- dir = path.dirname(script);
- var parts = path.split(dir);
- var libDir = parts.lastIndexOf('lib');
- if (libDir > 0) {
- packageRoot = new Path(path.join(path.joinAll(parts.take(libDir)),
- 'packages'));
- }
- }
- }
+ if (packageRoot == null) packageRoot = _getPackageRoot(entrypoints);
cleanOutputDirectory(dartdoc.outputDir);
// Start the analysis and documentation.
dartdoc.documentLibraries(entrypoints, libPath, packageRoot)
- .then((_) {
- print('Copying static files...');
- Future.wait([
- // Prepare the dart2js script code and copy static resources.
- // TODO(amouravski): move compileScript out and pre-generate the client
- // scripts. This takes a long time and the js hardly ever changes.
- compileScript(dartdoc.mode, dartdoc.outputDir, libPath),
- copyDirectory(scriptDir.append('../static'), dartdoc.outputDir)
- ]);
- })
+ // Prepare the dart2js script code and copy static resources.
+ // TODO(amouravski): move compileScript out and pre-generate the client
+ // scripts. This takes a long time and the js hardly ever changes.
+ .then((_) => compileScript(dartdoc.mode, dartdoc.outputDir, libPath))
+ .then((_) => copyDirectory(scriptDir.append('../static'),
+ dartdoc.outputDir))
.then((_) {
print(dartdoc.status);
if (dartdoc.totals == 0) {
@@ -267,3 +248,25 @@
})
.whenComplete(() => dartdoc.cleanup());
}
+
+String _getPackageRoot(List<Uri> entrypoints) {
+ // Check if there's a `packages` directory in the entry point directory.
+ var fileEntrypoint = entrypoints.firstWhere(
+ (entrypoint) => entrypoint.scheme == 'file',
+ orElse: () => null);
+ if (fileEntrypoint == null) return;
+
+ var script = path.normalize(path.absolute(fileUriToPath(fileEntrypoint)));
+ var dir = path.join(path.dirname(script), 'packages/');
+ if (new Directory(dir).existsSync()) return dir;
+
+ // If there is not, then check if the entrypoint is somewhere in a `lib`
+ // directory.
+ var parts = path.split(path.dirname(script));
+ var libDir = parts.lastIndexOf('lib');
+ if (libDir > 0) {
+ return path.join(path.joinAll(parts.take(libDir)), 'packages');
+ } else {
+ return null;
+ }
+}
diff --git a/sdk/lib/_internal/dartdoc/lib/dartdoc.dart b/sdk/lib/_internal/dartdoc/lib/dartdoc.dart
index 42246b9..38d1706 100644
--- a/sdk/lib/_internal/dartdoc/lib/dartdoc.dart
+++ b/sdk/lib/_internal/dartdoc/lib/dartdoc.dart
@@ -18,15 +18,20 @@
import 'dart:async';
import 'dart:io';
+import 'dart:isolate';
import 'dart:json' as json;
import 'dart:math';
import 'dart:uri';
+import 'package:pathos/path.dart' as pathos;
+
import 'classify.dart';
import 'markdown.dart' as md;
import 'universe_serializer.dart';
import 'src/dartdoc/nav.dart';
+import 'src/dartdoc/utils.dart';
+import 'src/export_map.dart';
import 'src/json_serializer.dart' as json_serializer;
// TODO(rnystrom): Use "package:" URL (#4968).
@@ -35,8 +40,6 @@
import '../../compiler/implementation/mirrors/mirrors_util.dart';
import '../../libraries.dart';
-part 'src/dartdoc/utils.dart';
-
/**
* Generates completely static HTML containing everything you need to browse
* the docs. The only client side behavior is trivial stuff like syntax
@@ -107,6 +110,7 @@
* event loop has had a chance to pump (i.e. after `main()` has returned).
*/
Future copyDirectory(Path from, Path to) {
+ print('Copying static files...');
final completer = new Completer();
final fromDir = new Directory.fromPath(from);
fromDir.list(recursive: false).listen(
@@ -131,16 +135,38 @@
*/
Future compileScript(int mode, Path outputDir, Path libPath) {
print('Compiling client JavaScript...');
- var clientScript = (mode == MODE_STATIC) ? 'static' : 'live-nav';
- var dartPath = libPath.append(
- 'lib/_internal/dartdoc/lib/src/client/client-$clientScript.dart');
- var jsPath = outputDir.append('client-$clientScript.js');
- return dart2js.compile(dartPath, libPath,
- options: const <String>['--categories=Client,Server'])
- .then((jsCode) {
- writeString(new File.fromPath(jsPath), jsCode);
+ // TODO(nweiz): don't run this in an isolate when issue 9815 is fixed.
+ return spawnFunction(_compileScript).call({
+ 'mode': mode,
+ 'outputDir': outputDir.toNativePath(),
+ 'libPath': libPath.toNativePath()
+ }).then((result) {
+ if (result.first == 'success') return;
+ throw new AsyncError(result[1], result[2]);
+ });
+}
+
+void _compileScript() {
+ port.receive((message, replyTo) {
+ new Future.of(() {
+ var clientScript = (message['mode'] == MODE_STATIC) ?
+ 'static' : 'live-nav';
+ var dartPath = pathos.join(message['libPath'], 'lib', '_internal',
+ 'dartdoc', 'lib', 'src', 'client', 'client-$clientScript.dart');
+ var jsPath = pathos.join(message['outputDir'], 'client-$clientScript.js');
+
+ return dart2js.compile(
+ new Path(dartPath), new Path(message['libPath']),
+ options: const <String>['--categories=Client,Server']).then((jsCode) {
+ writeString(new File(jsPath), jsCode);
+ });
+ }).then((_) {
+ replyTo.send(['success']);
+ }).catchError((e) {
+ replyTo.send(['error', e.error.toString(), e.stackTrace.toString()]);
});
+ });
}
/**
@@ -261,11 +287,30 @@
/** Set this to select the libraries to exclude from the documentation. */
List<String> excludedLibraries = const <String>[];
+ /** The package root for `package:` imports. */
+ String _packageRoot;
+
+ /** The map containing all the exports for each library. */
+ ExportMap _exports;
+
/**
* This list contains the libraries sorted in by the library name.
*/
List<LibraryMirror> _sortedLibraries;
+ /** A map from absolute paths of libraries to the libraries at those paths. */
+ Map<String, LibraryMirror> _librariesByPath;
+
+ /**
+ * A map from absolute paths of hidden libraries to lists of [Export]s that
+ * export those libraries from visible libraries. This is used to determine
+ * what public library any given entity belongs to.
+ *
+ * The lists of exports are sorted so that exports that hide the fewest number
+ * of members come first.
+ */
+ Map<String, List<Export>> _hiddenLibraryExports;
+
/** The library that we're currently generating docs for. */
LibraryMirror _currentLibrary;
@@ -403,16 +448,25 @@
return content;
}
- Future documentEntryPoint(Path entrypoint, Path libPath, Path packageRoot) {
- return documentLibraries(<Path>[entrypoint], libPath, packageRoot);
- }
+ Future documentLibraries(List<Uri> libraryList, Path libPath,
+ String packageRoot) {
+ _packageRoot = packageRoot;
+ _exports = new ExportMap.parse(libraryList, packageRoot);
+ var librariesToAnalyze = _exports.allExportedFiles.toList();
+ librariesToAnalyze.addAll(libraryList.map((uri) {
+ if (uri.scheme == 'file') return fileUriToPath(uri);
+ // dart2js takes "dart:*" URIs as Path objects for some reason.
+ return uri.toString();
+ }));
- Future documentLibraries(List<Path> libraryList, Path libPath, Path packageRoot) {
+ var packageRootPath = packageRoot == null ? null : new Path(packageRoot);
+
// TODO(amouravski): make all of these print statements into logging
// statements.
print('Analyzing libraries...');
- return dart2js.analyze(libraryList, libPath, packageRoot: packageRoot,
- options: COMPILER_OPTIONS)
+ return dart2js.analyze(
+ librariesToAnalyze.map((path) => new Path(path)).toList(), libPath,
+ packageRoot: packageRootPath, options: COMPILER_OPTIONS)
.then((MirrorSystem mirrors) {
print('Generating documentation...');
_document(mirrors);
@@ -430,6 +484,16 @@
displayName(y).toUpperCase());
});
+ _librariesByPath = <String, LibraryMirror>{};
+ for (var library in mirrors.libraries.values) {
+ var path = _libraryPath(library);
+ if (path == null) continue;
+ path = pathos.normalize(pathos.absolute(path));
+ _librariesByPath[path] = library;
+ }
+
+ _hiddenLibraryExports = _generateHiddenLibraryExports();
+
// Generate the docs.
if (mode == MODE_LIVE_NAV) {
docNavigationJson();
@@ -446,6 +510,7 @@
generateAppCacheManifest();
}
+ // TODO(nweiz): properly handle exports when generating JSON.
// TODO(jacobr): handle arbitrary pub packages rather than just the system
// libraries.
var revision = '0';
@@ -484,6 +549,63 @@
_finished = true;
}
+ /**
+ * Generate [_hiddenLibraryExports] from [_exports] and [_librariesByPath].
+ */
+ Map<String, List<Export>> _generateHiddenLibraryExports() {
+ // First generate a map `exported path => exporter path => Export`. The
+ // inner map makes it easier to merge multiple exports of the same library
+ // by the same exporter.
+ var hiddenLibraryExportMaps = <String, Map<String, Export>>{};
+ _exports.exports.forEach((exporter, exports) {
+ var library = _librariesByPath[exporter];
+ // TODO(nweiz): remove this check when issue 9645 is fixed.
+ if (library == null) return;
+ if (!shouldIncludeLibrary(library)) return;
+ for (var export in exports) {
+ var library = _librariesByPath[export.path];
+ // TODO(nweiz): remove this check when issue 9645 is fixed.
+ if (library == null) continue;
+ if (shouldIncludeLibrary(library)) continue;
+
+ var hiddenExports = _exports.transitiveExports(export.path)
+ .map((transitiveExport) => export.compose(transitiveExport))
+ .toList();
+ hiddenExports.add(export);
+
+ for (var hiddenExport in hiddenExports) {
+ var exportsByExporterPath = hiddenLibraryExportMaps
+ .putIfAbsent(hiddenExport.path, () => <String, Export>{});
+ addOrMergeExport(exportsByExporterPath, exporter, hiddenExport);
+ }
+ }
+ });
+
+ // Now sort the values of the inner maps of `hiddenLibraryExportMaps` to get
+ // the final value of `_hiddenLibraryExports`.
+ var hiddenLibraryExports = <String, List<Export>>{};
+ hiddenLibraryExportMaps.forEach((exporteePath, exportsByExporterPath) {
+ int rank(Export export) {
+ if (export.show.isEmpty && export.hide.isEmpty) return 0;
+ if (export.show.isEmpty) return export.hide.length;
+ // Multiply by 1000 to ensure this sorts after an export with hides.
+ return 1000 * export.show.length;
+ }
+
+ var exports = exportsByExporterPath.values.toList();
+ exports.sort((export1, export2) {
+ var comparison = Comparable.compare(rank(export1), rank(export2));
+ if (comparison != 0) return comparison;
+
+ var library1 = _librariesByPath[export1.exporter];
+ var library2 = _librariesByPath[export2.exporter];
+ return Comparable.compare(library1.displayName, library2.displayName);
+ });
+ hiddenLibraryExports[exporteePath] = exports;
+ });
+ return hiddenLibraryExports;
+ }
+
MdnComment lookupMdnComment(Mirror mirror) => null;
void startFile(String path) {
@@ -868,6 +990,9 @@
writeln('<div class="doc">${comment.html}</div>');
}
+ // Document the visible libraries exported by this library.
+ docExports(library);
+
// Document the top-level members.
docMembers(library);
@@ -878,7 +1003,8 @@
final typedefs = <TypedefMirror>[];
final exceptions = <ClassMirror>[];
- for (ClassMirror type in orderByName(library.classes.values)) {
+ var allClasses = _libraryClasses(library);
+ for (ClassMirror type in orderByName(allClasses)) {
if (!showPrivate && type.isPrivate) continue;
if (isException(type)) {
@@ -907,7 +1033,7 @@
writeFooter();
endFile();
- for (final type in library.classes.values) {
+ for (final type in allClasses) {
if (!showPrivate && type.isPrivate) continue;
docType(type);
@@ -955,8 +1081,9 @@
final typeTitle =
'${typeName(type)} ${kind}';
- writeHeader('$typeTitle / ${displayName(type.library)} Library',
- [displayName(type.library), libraryUrl(type.library),
+ var library = _libraryFor(type);
+ writeHeader('$typeTitle / ${displayName(library)} Library',
+ [displayName(library), libraryUrl(library),
typeName(type), typeUrl(type)]);
writeln(
'''
@@ -1148,6 +1275,40 @@
return map;
}();
+ void docExports(LibraryMirror library) {
+ // TODO(nweiz): show `dart:` library exports.
+ var exportLinks = _exports.transitiveExports(_libraryPath(library))
+ .map((export) {
+ var library = _librariesByPath[export.path];
+ // TODO(nweiz): remove this check when issue 9645 is fixed.
+ if (library == null) return null;
+ // Only link to publically visible libraries.
+ if (!shouldIncludeLibrary(library)) return null;
+
+ var memberNames = export.show.isEmpty ? export.hide : export.show;
+ var memberLinks = memberNames.map((name) {
+ return md.renderToHtml([resolveNameReference(
+ name, currentLibrary: library)]);
+ }).join(', ');
+ var combinator = '';
+ if (!export.show.isEmpty) {
+ combinator = ' show $memberLinks';
+ } else if (!export.hide.isEmpty) {
+ combinator = ' hide $memberLinks';
+ }
+
+ return '<ul>${a(libraryUrl(library), displayName(library))}'
+ '$combinator</ul>';
+ }).where((link) => link != null);
+
+ if (!exportLinks.isEmpty) {
+ writeln('<h3>Exports</h3>');
+ writeln('<ul>');
+ writeln(exportLinks.join('\n'));
+ writeln('</ul>');
+ }
+ }
+
void docMembers(ContainerMirror host) {
// Collect the different kinds of members.
final staticMethods = [];
@@ -1160,8 +1321,10 @@
final instanceSetters = new Map<String,MemberMirror>();
final constructors = [];
- host.members.forEach((_, MemberMirror member) {
- if (!showPrivate && member.isPrivate) return;
+ var hostMembers = host is LibraryMirror ?
+ _libraryMembers(host) : host.members.values;
+ for (var member in hostMembers) {
+ if (!showPrivate && member.isPrivate) continue;
if (host is LibraryMirror || member.isStatic) {
if (member is MethodMirror) {
if (member.isGetter) {
@@ -1175,7 +1338,7 @@
staticGetters[member.displayName] = member;
}
}
- });
+ }
if (host is ClassMirror) {
var iterable = new HierarchyIterable(host, includeType: true);
@@ -1219,28 +1382,28 @@
if (member is MethodMirror) {
if (member.isGetter) {
instanceGetters[member.displayName] = member;
- if (member.owner == host) {
+ if (_ownerFor(member) == host) {
allPropertiesInherited = false;
}
} else if (member.isSetter) {
instanceSetters[member.displayName] = member;
- if (member.owner == host) {
+ if (_ownerFor(member) == host) {
allPropertiesInherited = false;
}
} else if (member.isOperator) {
instanceOperators.add(member);
- if (member.owner == host) {
+ if (_ownerFor(member) == host) {
allOperatorsInherited = false;
}
} else {
instanceMethods.add(member);
- if (member.owner == host) {
+ if (_ownerFor(member) == host) {
allMethodsInherited = false;
}
}
} else if (member is VariableMirror) {
instanceGetters[member.displayName] = member;
- if (member.owner == host) {
+ if (_ownerFor(member) == host) {
allPropertiesInherited = false;
}
}
@@ -1305,7 +1468,7 @@
} else {
DocComment getterComment = getMemberComment(getter);
DocComment setterComment = getMemberComment(setter);
- if (getter.owner != setter.owner ||
+ if (_ownerFor(getter) != _ownerFor(setter) ||
getterComment != null && setterComment != null) {
// Both have comments or are not declared in the same class
// => Documents separately.
@@ -1376,7 +1539,7 @@
}
bool showCode = includeSource && !isAbstract;
- bool inherited = host != member.owner;
+ bool inherited = host != member.owner && member.owner is! LibraryMirror;
writeln('<div class="method${inherited ? ' inherited': ''}">'
'<h4 id="${memberAnchor(member)}">');
@@ -1467,7 +1630,7 @@
_totalMembers++;
_currentMember = getter;
- bool inherited = host != getter.owner;
+ bool inherited = host != getter.owner && getter.owner is! LibraryMirror;
writeln('<div class="field${inherited ? ' inherited' : ''}">'
'<h4 id="${memberAnchor(getter)}">');
@@ -1674,13 +1837,13 @@
// Always get the generic type to strip off any type parameters or
// arguments. If the type isn't generic, genericType returns `this`, so it
// works for non-generic types too.
- return '${sanitize(displayName(type.library))}/'
+ return '${sanitize(displayName(_libraryFor(type)))}/'
'${type.originalDeclaration.simpleName}.html';
}
/** Gets the URL for the documentation for [member]. */
String memberUrl(MemberMirror member) {
- String url = typeUrl(member.owner);
+ String url = typeUrl(_ownerFor(member));
return '$url#${memberAnchor(member)}';
}
@@ -1705,7 +1868,7 @@
*/
annotateDynamicType(ContainerMirror enclosingType,
TypeMirror type) {
- annotateType(enclosingType, type, type.isDynamic ? 'dynamic' : null);
+ annotateType(enclosingType, type, type.isDynamic ? 'dynamic ' : null);
}
/**
@@ -1759,9 +1922,10 @@
assert(type is ClassMirror);
// Link to the type.
- if (shouldLinkToPublicApi(type.library)) {
+ var library = _libraryFor(type);
+ if (shouldLinkToPublicApi(library)) {
write('<a href="$API_LOCATION${typeUrl(type)}">${type.simpleName}</a>');
- } else if (shouldIncludeLibrary(type.library)) {
+ } else if (shouldIncludeLibrary(library)) {
write(a(typeUrl(type), type.simpleName));
} else {
write(type.simpleName);
@@ -1979,6 +2143,86 @@
return type.simpleName.endsWith('Exception') ||
type.simpleName.endsWith('Error');
}
+
+ /**
+ * Returns the absolute path to [library] on the filesystem, or `null` if the
+ * library doesn't exist on the local filesystem.
+ */
+ String _libraryPath(LibraryMirror library) =>
+ importUriToPath(library.uri, packageRoot: _packageRoot);
+
+ /**
+ * Returns a list of classes in [library], including classes it exports from
+ * hidden libraries.
+ */
+ List<ClassMirror> _libraryClasses(LibraryMirror library) =>
+ _libraryContents(library, (lib) => lib.classes.values);
+
+ /**
+ * Returns a list of top-level members in [library], including members it
+ * exports from hidden libraries.
+ */
+ List<MemberMirror> _libraryMembers(LibraryMirror library) =>
+ _libraryContents(library, (lib) => lib.members.values);
+
+
+ /**
+ * Returns a list of elements in [library], including elements it exports from
+ * hidden libraries. [fn] should return the element list for a single library,
+ * which will then be merged across all exported libraries.
+ */
+ List<DeclarationMirror> _libraryContents(LibraryMirror library,
+ List<DeclarationMirror> fn(LibraryMirror)) {
+ var contents = fn(library).toList();
+ var path = _libraryPath(library);
+ if (path == null || _exports.exports[path] == null) return contents;
+
+
+ contents.addAll(_exports.exports[path].expand((export) {
+ var exportedLibrary = _librariesByPath[export.path];
+ // TODO(nweiz): remove this check when issue 9645 is fixed.
+ if (exportedLibrary == null) return [];
+ if (shouldIncludeLibrary(exportedLibrary)) return [];
+ return fn(exportedLibrary).where((declaration) =>
+ export.isMemberVisible(declaration.displayName));
+ }));
+ return contents;
+ }
+
+ /**
+ * Returns the library in which [type] was defined. If [type] was defined in a
+ * hidden library that was exported by another library, this returns the
+ * exporter.
+ */
+ LibraryMirror _libraryFor(TypeMirror type) =>
+ _visibleLibrary(type.library, type.displayName);
+
+ /**
+ * Returns the owner of [declaration]. If [declaration]'s owner is a hidden
+ * library that was exported by another library, this returns the exporter.
+ */
+ DeclarationMirror _ownerFor(DeclarationMirror declaration) {
+ var owner = declaration.owner;
+ if (owner is! LibraryMirror) return owner;
+ return _visibleLibrary(owner, declaration.displayName);
+ }
+
+ /**
+ * Returns the best visible library that exports [name] from [library]. If
+ * [library] is public, it will be returned.
+ */
+ LibraryMirror _visibleLibrary(LibraryMirror library, String name) {
+ if (library == null) return null;
+
+ var exports = _hiddenLibraryExports[_libraryPath(library)];
+ if (exports == null) return library;
+
+ var export = exports.firstWhere(
+ (exp) => exp.isMemberVisible(name),
+ orElse: () => null);
+ if (export == null) return library;
+ return _librariesByPath[export.exporter];
+ }
}
/**
diff --git a/sdk/lib/_internal/dartdoc/lib/src/dartdoc/utils.dart b/sdk/lib/_internal/dartdoc/lib/src/dartdoc/utils.dart
index 470c9f2..02b7de7 100644
--- a/sdk/lib/_internal/dartdoc/lib/src/dartdoc/utils.dart
+++ b/sdk/lib/_internal/dartdoc/lib/src/dartdoc/utils.dart
@@ -2,9 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-part of dartdoc;
-
// Generic utility functions.
+library utils;
+
+import 'dart:io';
+import 'dart:uri';
+import 'dart:math' as math;
+
+import 'package:pathos/path.dart' as pathos;
+
+import '../../../../compiler/implementation/mirrors/mirrors.dart';
+
+import '../export_map.dart';
/** Turns [name] into something that's safe to use as a file name. */
String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_');
@@ -40,7 +49,7 @@
/** Removes up to [indentation] leading whitespace characters from [text]. */
String unindent(String text, int indentation) {
var start;
- for (start = 0; start < min(indentation, text.length); start++) {
+ for (start = 0; start < math.min(indentation, text.length); start++) {
// Stop if we hit a non-whitespace character.
if (text[start] != ' ') break;
}
@@ -77,3 +86,76 @@
randomAccessFile.writeStringSync(text);
randomAccessFile.closeSync();
}
+
+/**
+ * Converts [uri], which should come from a Dart import or export, to a local
+ * filesystem path. [basePath] is the base directory to use when converting
+ * relative URIs; without it, relative URIs will not be converted. [packageRoot]
+ * is the `packages` directory to use when converting `package:` URIs; without
+ * it, `package:` URIs will not be converted.
+ *
+ * If a URI cannot be converted, this will return `null`.
+ */
+String importUriToPath(Uri uri, {String basePath, String packageRoot}) {
+ if (uri.scheme == 'file') return fileUriToPath(uri);
+
+ if (basePath != null && uri.scheme == '') {
+ return pathos.normalize(pathos.absolute(pathos.join(basePath, uri.path)));
+ }
+
+ if (packageRoot != null && uri.scheme == 'package') {
+ return pathos.normalize(pathos.absolute(
+ pathos.join(packageRoot, uri.path)));
+ }
+
+ // Ignore unsupported schemes.
+ return null;
+}
+
+/** Converts a `file:` [Uri] to a local path string. */
+String fileUriToPath(Uri uri) {
+ if (uri.scheme != 'file') {
+ throw new ArgumentError("Uri $uri must have scheme 'file:'.");
+ }
+ if (Platform.operatingSystem != 'windows') return pathos.normalize(uri.path);
+ return pathos.normalize(uri.path.replaceFirst("/", "").replaceAll("/", "\\"));
+}
+
+/** Converts a local path string to a `file:` [Uri]. */
+Uri pathToFileUri(String path) {
+ path = pathos.absolute(path);
+ if (Platform.operatingSystem != 'windows') {
+ return Uri.parse('file://$path');
+ } else {
+ return Uri.parse('file:///${path.replaceAll("\\", "/")}');
+ }
+}
+
+/**
+ * If [map] contains an [Export] under [key], this merges that with [export].
+ * Otherwise, it sets [key] to [export].
+ */
+void addOrMergeExport(Map<String, Export> map, String key, Export export) {
+ if (map.containsKey(key)) {
+ map[key] = map[key].merge(export);
+ } else {
+ map[key] = export;
+ }
+}
+
+/// A pair of values.
+class Pair<E, F> {
+ E first;
+ F last;
+
+ Pair(this.first, this.last);
+
+ String toString() => '($first, $last)';
+
+ bool operator==(other) {
+ if (other is! Pair) return false;
+ return other.first == first && other.last == last;
+ }
+
+ int get hashCode => first.hashCode ^ last.hashCode;
+}
diff --git a/sdk/lib/_internal/dartdoc/lib/src/export_map.dart b/sdk/lib/_internal/dartdoc/lib/src/export_map.dart
new file mode 100644
index 0000000..4e892cc
--- /dev/null
+++ b/sdk/lib/_internal/dartdoc/lib/src/export_map.dart
@@ -0,0 +1,342 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// This library uses the Dart analyzer to find the exports for a set of
+/// libraries. It stores these exports in an [ExportMap]. This is used to
+/// display exported members as part of the exporting library, since dart2js
+/// doesn't provide this information itself.
+library export_map;
+
+import 'dart:io';
+import 'dart:uri';
+
+import 'package:analyzer_experimental/src/generated/ast.dart';
+import 'package:analyzer_experimental/src/generated/error.dart';
+import 'package:analyzer_experimental/src/generated/parser.dart';
+import 'package:analyzer_experimental/src/generated/scanner.dart';
+import 'package:analyzer_experimental/src/generated/source.dart';
+import 'package:pathos/path.dart' as pathos;
+
+import 'dartdoc/utils.dart';
+
+/// A class that tracks which libraries export which other libraries.
+class ExportMap {
+ /// A map from libraries to their [Export]s.
+ ///
+ /// Each key is the absolute path of a library on the filesystem, and each
+ /// value is a list of [Export]s for that library. There's guaranteed to be
+ /// only one [Export] of a given library in a given list.
+ final Map<String, List<Export>> exports;
+
+ /// A cache of the transitive exports for each library. The keys are paths to
+ /// libraries. The values are maps from the exported path to the [Export]
+ /// objects, to make it easier to merge multiple exports of the same library.
+ final _transitiveExportsByPath = <String, Map<String, Export>>{};
+
+ /// Parse an export map from a set of [libraries], which should be Dart import
+ /// [Uri]s. [packageRoot] should be the path to the `packages` directory to
+ /// use when resolving `package:` imports and libraries. Libraries that are
+ /// not available on the local machine will be ignored.
+ ///
+ /// In addition to parsing the exports in [libraries], this will parse the
+ /// exports in all libraries transitively reachable from [libraries] via
+ /// `import` or `export`.
+ factory ExportMap.parse(Iterable<Uri> libraries, String packageRoot) {
+ var exports = <String, List<Export>>{};
+
+ void traverse(String path) {
+ if (exports.containsKey(path)) return;
+
+ var importsAndExports;
+ try {
+ importsAndExports = _importsAndExportsForFile(path, packageRoot);
+ } on FileIOException catch (_) {
+ // Ignore unreadable/nonexistent files.
+ return;
+ }
+
+ var exportsForLibrary = <String, Export>{};
+ for (var export in importsAndExports.last) {
+ addOrMergeExport(exportsForLibrary, export.path, export);
+ }
+ exports[path] = new List.from(exportsForLibrary.values);
+ exports[path].map((directive) => directive.path).forEach(traverse);
+ importsAndExports.first.forEach(traverse);
+ }
+
+ for (var library in libraries) {
+ var path = importUriToPath(library, packageRoot: packageRoot);
+ if (path != null) traverse(path);
+ }
+
+ return new ExportMap._(exports);
+ }
+
+ ExportMap._(this.exports);
+
+ /// Returns a list of all the paths of exported libraries that [this] is aware
+ /// of.
+ List<String> get allExportedFiles => exports.values.expand((e) => e)
+ .map((directive) => directive.path).toList();
+
+ /// Returns a list of all exports that [library] transitively exports. This
+ /// means that if [library] exports another library that in turn exports a
+ /// third, the third library will be included in the returned list.
+ ///
+ /// This will automatically handle nested `hide` and `show` directives on the
+ /// exports, as well as merging multiple exports of the same library.
+ List<Export> transitiveExports(String library) {
+ Map<String, Export> _getTransitiveExportsByPath(String path) {
+ if (_transitiveExportsByPath.containsKey(path)) {
+ return _transitiveExportsByPath[path];
+ }
+
+ var exportsByPath = <String, Export>{};
+ _transitiveExportsByPath[path] = exportsByPath;
+ if (exports[path] == null) return exportsByPath;
+
+ for (var export in exports[path]) {
+ exportsByPath[export.path] = export;
+ }
+
+ for (var export in exports[path]) {
+ for (var subExport in _getTransitiveExportsByPath(export.path).values) {
+ subExport = export.compose(subExport);
+ if (exportsByPath.containsKey(subExport.path)) {
+ subExport = subExport.merge(exportsByPath[subExport.path]);
+ }
+ exportsByPath[subExport.path] = subExport;
+ }
+ }
+ return exportsByPath;
+ }
+
+ var path = pathos.normalize(pathos.absolute(library));
+ return _getTransitiveExportsByPath(path).values.toList();
+ }
+}
+
+/// A class that represents one library exporting another.
+class Export {
+ /// The absolute path of the library that contains this export.
+ final String exporter;
+
+ /// The absolute path of the library being exported.
+ final String path;
+
+ /// The set of identifiers that are explicitly being exported. If this is
+ /// non-empty, no identifiers other than these will be visible.
+ ///
+ /// One or both of [show] and [hide] will always be empty.
+ Set<String> get show => _show;
+ Set<String> _show;
+
+ /// The set of identifiers that are not exported.
+ ///
+ /// One or both of [show] and [hide] will always be empty.
+ Set<String> get hide => _hide;
+ Set<String> _hide;
+
+ /// Whether or not members exported are hidden by default.
+ bool get _hideByDefault => !show.isEmpty;
+
+ /// Creates a new export.
+ ///
+ /// This will normalize [show] and [hide] so that if both are non-empty, only
+ /// [show] will be set.
+ Export(this.exporter, this.path, {Iterable<String> show,
+ Iterable<String> hide}) {
+ _show = new Set<String>.from(show == null ? [] : show);
+ _hide = new Set<String>.from(hide == null ? [] : hide);
+
+ if (!_show.isEmpty) {
+ _show.removeAll(_hide);
+ _hide = new Set<String>();
+ }
+ }
+
+ /// Returns a new [Export] that represents [this] composed with [nested], as
+ /// though [this] was used to export a library that in turn exported [nested].
+ Export compose(Export nested) {
+ var show = new Set<String>();
+ var hide = new Set<String>();
+
+ if (this._hideByDefault) {
+ show.addAll(this.show);
+ if (nested._hideByDefault) {
+ show.retainAll(nested.show);
+ } else {
+ show.removeAll(nested.hide);
+ }
+ } else if (nested._hideByDefault) {
+ show.addAll(nested.show);
+ show.removeAll(this.hide);
+ } else {
+ hide.addAll(this.hide);
+ hide.addAll(nested.hide);
+ }
+
+ return new Export(this.exporter, nested.path, show: show, hide: hide);
+ }
+
+ /// Returns a new [Export] that merges [this] with [nested], as though both
+ /// exports were included in the same library.
+ ///
+ /// [this] and [other] must have the same values for [exporter] and [path].
+ Export merge(Export other) {
+ if (this.path != other.path) {
+ throw new ArgumentError("Can't merge two Exports with different paths: "
+ "export '$path' from '$exporter' and export '${other.path}' from "
+ "'${other.exporter}'.");
+ } if (this.exporter != other.exporter) {
+ throw new ArgumentError("Can't merge two Exports with different "
+ "exporters: export '$path' from '$exporter' and export "
+ "'${other.path}' from '${other.exporter}'.");
+ }
+
+ var show = new Set<String>();
+ var hide = new Set<String>();
+
+ if (this._hideByDefault) {
+ if (other._hideByDefault) {
+ show.addAll(this.show);
+ show.addAll(other.show);
+ } else {
+ hide.addAll(other.hide);
+ hide.removeAll(this.show);
+ }
+ } else {
+ hide.addAll(this.hide);
+ if (other._hideByDefault) {
+ hide.removeAll(other.show);
+ } else {
+ hide.retainAll(other.hide);
+ }
+ }
+
+ return new Export(exporter, path, show: show, hide: hide);
+ }
+
+ /// Returns whether or not a member named [name] is visible through this
+ /// import, as goverend by [show] and [hide].
+ bool isMemberVisible(String name) =>
+ _hideByDefault ? show.contains(name) : !hide.contains(name);
+
+ bool operator==(other) => other is Export && other.exporter == exporter &&
+ other.path == path && show.containsAll(other.show) &&
+ other.show.containsAll(show) && hide.containsAll(other.hide) &&
+ other.hide.containsAll(hide);
+
+ int get hashCode {
+ var hashCode = exporter.hashCode ^ path.hashCode;
+ hashCode = show.reduce(hashCode, (hash, name) => hash ^ name.hashCode);
+ return hide.reduce(hashCode, (hash, name) => hash ^ name.hashCode);
+ }
+
+ String toString() {
+ var combinator = '';
+ if (!show.isEmpty) {
+ combinator = ' show ${show.join(', ')}';
+ } else if (!hide.isEmpty) {
+ combinator = ' hide ${hide.join(', ')}';
+ }
+ return "export '$path'$combinator (from $exporter)";
+ }
+}
+
+/// Returns a list of imports and a list of exports for the dart library at
+/// [file]. [packageRoot] is used to resolve `package:` URLs.
+///
+/// The imports are a list of absolute paths, while the exports are [Export]
+/// objects.
+Pair<List<String>, List<Export>> _importsAndExportsForFile(String file,
+ String packageRoot) {
+ var collector = new _ImportExportCollector();
+ _parseFile(file).accept(collector);
+
+ var imports = collector.imports.map((import) {
+ return _pathForDirective(import, pathos.dirname(file), packageRoot);
+ }).where((import) => import != null).toList();
+
+ var exports = collector.exports.map((export) {
+ var path = _pathForDirective(export, pathos.dirname(file), packageRoot);
+ if (path == null) return null;
+
+ path = pathos.normalize(pathos.absolute(path));
+ var show = export.combinators
+ .where((combinator) => combinator is ShowCombinator)
+ .expand((combinator) => combinator.shownNames.map((name) => name.name));
+ var hide = export.combinators
+ .where((combinator) => combinator is HideCombinator)
+ .expand((combinator) =>
+ combinator.hiddenNames.map((name) => name.name));
+
+ return new Export(file, path, show: show, hide: hide);
+ }).where((export) => export != null).toList();
+
+ return new Pair<List<String>, List<Export>>(imports, exports);
+}
+
+/// Returns the absolute path to the library imported by [directive], or `null`
+/// if it doesn't refer to a file on the local filesystem.
+///
+/// [basePath] is the path from which relative imports should be resolved.
+/// [packageRoot] is the path from which `package:` imports should be resolved.
+String _pathForDirective(NamespaceDirective directive, String basePath,
+ String packageRoot) {
+ var uri = Uri.parse(_stringLiteralToString(directive.uri));
+ var path = importUriToPath(uri, basePath: basePath, packageRoot: packageRoot);
+ if (path == null) return null;
+ return pathos.normalize(pathos.absolute(path));
+}
+
+/// Parses a Dart file into an AST.
+CompilationUnit _parseFile(String path) {
+ var contents = new File(path).readAsStringSync();
+ var errorCollector = new _ErrorCollector();
+ var scanner = new StringScanner(null, contents, errorCollector);
+ var token = scanner.tokenize();
+ var parser = new Parser(null, errorCollector);
+ var unit = parser.parseCompilationUnit(token);
+ unit.lineInfo = new LineInfo(scanner.lineStarts);
+
+ if (!errorCollector.errors.isEmpty) {
+ throw new FormatException(
+ errorCollector.errors.map((e) => e.toString()).join("\n"));
+ }
+
+ return unit;
+}
+
+/// A simple error listener that collects errors into a list.
+class _ErrorCollector extends AnalysisErrorListener {
+ final errors = <AnalysisError>[];
+
+ _ErrorCollector();
+
+ void onError(AnalysisError error) => errors.add(error);
+}
+
+/// A simple visitor that collects import and export nodes.
+class _ImportExportCollector extends GeneralizingASTVisitor {
+ final imports = <ImportDirective>[];
+ final exports = <ExportDirective>[];
+
+ _ImportExportCollector();
+
+ visitImportDirective(ImportDirective node) => imports.add(node);
+ visitExportDirective(ExportDirective node) => exports.add(node);
+}
+
+// TODO(nweiz): fold this into the analyzer (issue 9781).
+/// Converts an AST node representing a string literal into a [String].
+String _stringLiteralToString(StringLiteral literal) {
+ if (literal is AdjacentStrings) {
+ return literal.strings.map(_stringLiteralToString).join();
+ } else if (literal is SimpleStringLiteral) {
+ return literal.value;
+ } else {
+ throw new ArgumentError('Unknown string type for $literal');
+ }
+}
diff --git a/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart b/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
index 882f6b2..e197b0b 100755
--- a/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
+++ b/sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart
@@ -54,7 +54,7 @@
// TODO(jacobr): this code works only because futures for mirrors return
// immediately.
for(String memberName in members) {
- var result = deprecatedFutureValue(mirror.getField(memberName));
+ var result = deprecatedFutureValue(mirror.getFieldAsync(memberName));
_serialize(memberName, result.reflectee, printer);
}
printer.endObject();
diff --git a/sdk/lib/_internal/dartdoc/pubspec.yaml b/sdk/lib/_internal/dartdoc/pubspec.yaml
index b28d984..6614786 100644
--- a/sdk/lib/_internal/dartdoc/pubspec.yaml
+++ b/sdk/lib/_internal/dartdoc/pubspec.yaml
@@ -3,6 +3,7 @@
Libraries for generating documentation from Dart source code.
dependencies:
+ analyzer_experimental: ">=0.4.5 <1.0.0"
args: ">=0.4.2 <1.0.0"
pathos: ">=0.4.2 <1.0.0"
diff --git a/sdk/lib/_internal/dartdoc/test/dartdoc_search_test.dart b/sdk/lib/_internal/dartdoc/test/dartdoc_search_test.dart
index 017633f..7731a2b 100644
--- a/sdk/lib/_internal/dartdoc/test/dartdoc_search_test.dart
+++ b/sdk/lib/_internal/dartdoc/test/dartdoc_search_test.dart
@@ -5,6 +5,7 @@
library dartdoc_search_test;
// TODO(rnystrom): Use "package:" URL (#4968).
+import '../../../../../pkg/expect/lib/expect.dart';
import '../lib/src/dartdoc/nav.dart';
import '../lib/src/client/search.dart';
diff --git a/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart b/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart
index c32c47f..60eb3ac 100644
--- a/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart
+++ b/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart
@@ -17,42 +17,6 @@
import 'markdown_test.dart';
main() {
- group('countOccurrences', () {
- test('empty text returns 0', () {
- expect(dd.countOccurrences('', 'needle'), equals(0));
- });
-
- test('one occurrence', () {
- expect(dd.countOccurrences('bananarama', 'nara'), equals(1));
- });
-
- test('multiple occurrences', () {
- expect(dd.countOccurrences('bananarama', 'a'), equals(5));
- });
-
- test('overlapping matches do not count', () {
- expect(dd.countOccurrences('bananarama', 'ana'), equals(1));
- });
- });
-
- group('repeat', () {
- test('zero times returns an empty string', () {
- expect(dd.repeat('ba', 0), isEmpty);
- });
-
- test('one time returns the string', () {
- expect(dd.repeat('ba', 1), equals('ba'));
- });
-
- test('multiple times', () {
- expect(dd.repeat('ba', 3), equals('bababa'));
- });
-
- test('multiple times with a separator', () {
- expect(dd.repeat('ba', 3, separator: ' '), equals('ba ba ba'));
- });
- });
-
group('isAbsolute', () {
final doc = new dd.Dartdoc();
diff --git a/sdk/lib/_internal/dartdoc/test/export_map_test.dart b/sdk/lib/_internal/dartdoc/test/export_map_test.dart
new file mode 100644
index 0000000..9ac4288
--- /dev/null
+++ b/sdk/lib/_internal/dartdoc/test/export_map_test.dart
@@ -0,0 +1,400 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:uri';
+
+import 'package:pathos/path.dart' as pathos;
+import 'package:unittest/unittest.dart';
+
+import '../lib/src/export_map.dart';
+import '../lib/src/dartdoc/utils.dart';
+
+String tempDir;
+
+main() {
+ group('ExportMap', () {
+ setUp(createTempDir);
+ tearDown(deleteTempDir);
+
+ test('with an empty library', () {
+ createLibrary('lib.dart');
+ var map = parse(['lib.dart']);
+
+ var expectedExports = {};
+ expectedExports[libPath('lib.dart')] = [];
+ expect(map.exports, equals(expectedExports));
+ expect(map.allExportedFiles, isEmpty);
+ expect(map.transitiveExports(libPath('lib.dart')), isEmpty);
+ expect(map.transitiveExports(libPath('nonexistent.dart')), isEmpty);
+ });
+
+ test('with one library with one export', () {
+ createLibrary('a.dart', 'export "b.dart";');
+ createLibrary('b.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'))
+ ]));
+
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'))
+ ]));
+
+ expect(map.allExportedFiles, unorderedEquals([libPath('b.dart')]));
+
+ expect(map.exports[libPath('b.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('b.dart')), isEmpty);
+ });
+
+ test('with one library with multiple exports', () {
+ createLibrary('a.dart', 'export "b.dart";\nexport "c.dart";');
+ createLibrary('b.dart');
+ createLibrary('c.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart')),
+ new Export(libPath('a.dart'), libPath('c.dart'))
+ ]));
+
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart')),
+ new Export(libPath('a.dart'), libPath('c.dart'))
+ ]));
+
+ expect(map.allExportedFiles, unorderedEquals([
+ libPath('b.dart'), libPath('c.dart')
+ ]));
+
+ expect(map.exports[libPath('b.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('b.dart')), isEmpty);
+ expect(map.exports[libPath('c.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('c.dart')), isEmpty);
+ });
+
+ test('with two libraries each with one export', () {
+ createLibrary('a.dart', 'export "a_export.dart";');
+ createLibrary('b.dart', 'export "b_export.dart";');
+ createLibrary('a_export.dart');
+ createLibrary('b_export.dart');
+ var map = parse(['a.dart', 'b.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('a_export.dart')),
+ ]));
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('a_export.dart')),
+ ]));
+
+ expect(map.transitiveExports(libPath('b.dart')), unorderedEquals([
+ new Export(libPath('b.dart'), libPath('b_export.dart')),
+ ]));
+ expect(map.exports[libPath('b.dart')], unorderedEquals([
+ new Export(libPath('b.dart'), libPath('b_export.dart'))
+ ]));
+
+ expect(map.allExportedFiles, unorderedEquals([
+ libPath('a_export.dart'), libPath('b_export.dart')
+ ]));
+
+ expect(map.exports[libPath('a_export.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('a_export.dart')), isEmpty);
+ expect(map.exports[libPath('b_export.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('b_export.dart')), isEmpty);
+ });
+
+ test('with a transitive export', () {
+ createLibrary('a.dart', 'export "b.dart";');
+ createLibrary('b.dart', 'export "c.dart";');
+ createLibrary('c.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart')),
+ ]));
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart')),
+ new Export(libPath('a.dart'), libPath('c.dart')),
+ ]));
+
+ expect(map.exports[libPath('b.dart')], unorderedEquals([
+ new Export(libPath('b.dart'), libPath('c.dart')),
+ ]));
+ expect(map.transitiveExports(libPath('b.dart')), unorderedEquals([
+ new Export(libPath('b.dart'), libPath('c.dart')),
+ ]));
+
+ expect(map.allExportedFiles, unorderedEquals([
+ libPath('b.dart'), libPath('c.dart')
+ ]));
+
+ expect(map.exports[libPath('c.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('c.dart')), isEmpty);
+ });
+
+ test('with an export through an import', () {
+ createLibrary('a.dart', 'import "b.dart";');
+ createLibrary('b.dart', 'export "c.dart";');
+ createLibrary('c.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('b.dart')], unorderedEquals([
+ new Export(libPath('b.dart'), libPath('c.dart')),
+ ]));
+ expect(map.transitiveExports(libPath('b.dart')), unorderedEquals([
+ new Export(libPath('b.dart'), libPath('c.dart')),
+ ]));
+
+ expect(map.allExportedFiles, unorderedEquals([libPath('c.dart')]));
+
+ expect(map.exports[libPath('a.dart')], isEmpty);
+ expect(map.exports[libPath('c.dart')], isEmpty);
+ expect(map.transitiveExports(libPath('a.dart')), isEmpty);
+ expect(map.transitiveExports(libPath('c.dart')), isEmpty);
+ });
+
+ test('with an export with a show combinator', () {
+ createLibrary('a.dart', 'export "b.dart" show x, y;');
+ createLibrary('b.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'), show: ['x', 'y'])
+ ]));
+ });
+
+ test('with an export with a hide combinator', () {
+ createLibrary('a.dart', 'export "b.dart" hide x, y;');
+ createLibrary('b.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'), hide: ['x', 'y'])
+ ]));
+ });
+
+ test('with an export with a show and a hide combinator', () {
+ createLibrary('a.dart', 'export "b.dart" show x, y hide y, z;');
+ createLibrary('b.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'), show: ['x'])
+ ]));
+ });
+
+ test('composes transitive exports', () {
+ createLibrary('a.dart', 'export "b.dart" hide x;');
+ createLibrary('b.dart', 'export "c.dart" hide y;');
+ createLibrary('c.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'), hide: ['x']),
+ new Export(libPath('a.dart'), libPath('c.dart'), hide: ['x', 'y'])
+ ]));
+ });
+
+ test('merges adjacent exports', () {
+ createLibrary('a.dart', '''
+ export "b.dart" show x, y;
+ export "b.dart" hide y, z;
+ ''');
+ createLibrary('b.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'), hide: ['z']),
+ ]));
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart'), hide: ['z']),
+ ]));
+ });
+
+ test('merges adjacent exports transitively', () {
+ createLibrary('a.dart', 'export "b.dart";\nexport "c.dart";');
+ createLibrary('b.dart', 'export "d.dart" show x, y;');
+ createLibrary('c.dart', 'export "d.dart" hide y, z;');
+ createLibrary('d.dart');
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart')),
+ new Export(libPath('a.dart'), libPath('c.dart')),
+ ]));
+ expect(map.transitiveExports(libPath('a.dart')), unorderedEquals([
+ new Export(libPath('a.dart'), libPath('b.dart')),
+ new Export(libPath('a.dart'), libPath('c.dart')),
+ new Export(libPath('a.dart'), libPath('d.dart'), hide: ['z']),
+ ]));
+ });
+
+ test('resolves package: exports', () {
+ createLibrary('a.dart', 'export "package:b/b.dart";');
+ var bPath = pathos.join('packages', 'b', 'b.dart');
+ createLibrary(bPath);
+ var map = parse(['a.dart']);
+
+ expect(map.exports[libPath('a.dart')], unorderedEquals([
+ new Export(libPath('a.dart'), libPath(bPath))
+ ]));
+ });
+
+ test('ignores dart: exports', () {
+ createLibrary('a.dart', 'export "dart:async";');
+ var map = parse(['a.dart']);
+ expect(map.exports[libPath('a.dart')], isEmpty);
+ });
+
+ test('.parse() resolves package: imports', () {
+ var aPath = pathos.join('packages', 'a', 'a.dart');
+ createLibrary(aPath, 'export "package:b/b.dart";');
+ var bPath = pathos.join('packages', 'b', 'b.dart');
+ createLibrary(bPath);
+ var map = new ExportMap.parse(
+ [Uri.parse('package:a/a.dart')],
+ pathos.join(tempDir, 'packages'));
+
+ expect(map.exports[libPath(aPath)], unorderedEquals([
+ new Export(libPath(aPath), libPath(bPath))
+ ]));
+ });
+
+ test('.parse() ignores dart: imports', () {
+ var map = new ExportMap.parse(
+ [Uri.parse('dart:async')],
+ pathos.join(tempDir, 'packages'));
+ expect(map.exports, isEmpty);
+ });
+ });
+
+ group('Export', () {
+ test('normalizes hide and show', () {
+ expect(new Export('', '', show: ['x', 'y'], hide: ['y', 'z']),
+ equals(new Export('', '', show: ['x'])));
+ });
+
+ test("doesn't care about the order of show or hide", () {
+ expect(new Export('', '', show: ['x', 'y']),
+ equals(new Export('', '', show: ['y', 'x'])));
+ expect(new Export('', '', hide: ['x', 'y']),
+ equals(new Export('', '', hide: ['y', 'x'])));
+ });
+
+ test('with no combinators considers anything visible', () {
+ var export = new Export('', '');
+ expect(export.isMemberVisible('x'), isTrue);
+ expect(export.isMemberVisible('y'), isTrue);
+ expect(export.isMemberVisible('z'), isTrue);
+ });
+
+ test('with hide combinators considers anything not hidden visible', () {
+ var export = new Export('', '', hide: ['x', 'y']);
+ expect(export.isMemberVisible('x'), isFalse);
+ expect(export.isMemberVisible('y'), isFalse);
+ expect(export.isMemberVisible('z'), isTrue);
+ });
+
+ test('with show combinators considers anything not shown invisible', () {
+ var export = new Export('', '', show: ['x', 'y']);
+ expect(export.isMemberVisible('x'), isTrue);
+ expect(export.isMemberVisible('y'), isTrue);
+ expect(export.isMemberVisible('z'), isFalse);
+ });
+
+ test('composing uses the parent exporter and child path', () {
+ expect(new Export('exporter1.dart', 'path1.dart')
+ .compose(new Export('exporter2.dart', 'path2.dart')),
+ equals(new Export('exporter1.dart', 'path2.dart')));
+ });
+
+ test('composing show . show takes the intersection', () {
+ expect(new Export('', '', show: ['x', 'y'])
+ .compose(new Export('', '', show: ['y', 'z'])),
+ equals(new Export('', '', show: ['y'])));
+ });
+
+ test('composing show . hide takes the difference', () {
+ expect(new Export('', '', show: ['x', 'y'])
+ .compose(new Export('', '', hide: ['y', 'z'])),
+ equals(new Export('', '', show: ['x'])));
+ });
+
+ test('composing hide . show takes the reverse difference', () {
+ expect(new Export('', '', hide: ['x', 'y'])
+ .compose(new Export('', '', show: ['y', 'z'])),
+ equals(new Export('', '', show: ['z'])));
+ });
+
+ test('composing hide . hide takes the union', () {
+ expect(new Export('', '', hide: ['x', 'y'])
+ .compose(new Export('', '', hide: ['y', 'z'])),
+ equals(new Export('', '', hide: ['x', 'y', 'z'])));
+ });
+
+ test('merging requires identical exporters and paths', () {
+ expect(() => new Export('exporter1.dart', '')
+ .merge(new Export('exporter2.dart', '')),
+ throwsA(isArgumentError));
+ expect(() => new Export('', 'path1.dart')
+ .merge(new Export('', 'path2.dart')),
+ throwsA(isArgumentError));
+ expect(new Export('', '').merge(new Export('', '')),
+ equals(new Export('', '')));
+ });
+
+ test('merging show + show takes the union', () {
+ expect(new Export('', '', show: ['x', 'y'])
+ .merge(new Export('', '', show: ['y', 'z'])),
+ equals(new Export('', '', show: ['x', 'y', 'z'])));
+ });
+
+ test('merging show + hide takes the difference', () {
+ expect(new Export('', '', show: ['x', 'y'])
+ .merge(new Export('', '', hide: ['y', 'z'])),
+ equals(new Export('', '', hide: ['z'])));
+ });
+
+ test('merging hide + show takes the difference', () {
+ expect(new Export('', '', hide: ['x', 'y'])
+ .merge(new Export('', '', show: ['y', 'z'])),
+ equals(new Export('', '', hide: ['x'])));
+ });
+
+ test('merging hide + hide takes the intersection', () {
+ expect(new Export('', '', hide: ['x', 'y'])
+ .merge(new Export('', '', hide: ['y', 'z'])),
+ equals(new Export('', '', hide: ['y'])));
+ });
+ });
+}
+
+ExportMap parse(List<String> libraries) {
+ return new ExportMap.parse(
+ libraries.map(libPath)
+ .map(pathToFileUri),
+ pathos.join(tempDir, 'packages'));
+}
+
+void createLibrary(String name, [String contents]) {
+ if (contents == null) contents = '';
+ new Directory(pathos.dirname(libPath(name))).createSync(recursive: true);
+ new File(libPath(name)).writeAsStringSync('''
+ library ${pathos.basename(name)};
+ $contents
+ ''');
+}
+
+String libPath(String name) => pathos.normalize(pathos.join(tempDir, name));
+
+void createTempDir() {
+ tempDir = new Directory('').createTempSync().path;
+ new Directory(pathos.join(tempDir, 'packages')).createSync();
+}
+
+void deleteTempDir() {
+ new Directory(tempDir).deleteSync(recursive: true);
+}
diff --git a/sdk/lib/_internal/dartdoc/test/utils_test.dart b/sdk/lib/_internal/dartdoc/test/utils_test.dart
new file mode 100644
index 0000000..fae4eec
--- /dev/null
+++ b/sdk/lib/_internal/dartdoc/test/utils_test.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:unittest/unittest.dart';
+
+import '../lib/src/dartdoc/utils.dart';
+
+void main() {
+ group('countOccurrences', () {
+ test('empty text returns 0', () {
+ expect(countOccurrences('', 'needle'), equals(0));
+ });
+
+ test('one occurrence', () {
+ expect(countOccurrences('bananarama', 'nara'), equals(1));
+ });
+
+ test('multiple occurrences', () {
+ expect(countOccurrences('bananarama', 'a'), equals(5));
+ });
+
+ test('overlapping matches do not count', () {
+ expect(countOccurrences('bananarama', 'ana'), equals(1));
+ });
+ });
+
+ group('repeat', () {
+ test('zero times returns an empty string', () {
+ expect(repeat('ba', 0), isEmpty);
+ });
+
+ test('one time returns the string', () {
+ expect(repeat('ba', 1), equals('ba'));
+ });
+
+ test('multiple times', () {
+ expect(repeat('ba', 3), equals('bababa'));
+ });
+
+ test('multiple times with a separator', () {
+ expect(repeat('ba', 3, separator: ' '), equals('ba ba ba'));
+ });
+ });
+}
diff --git a/sdk/lib/async/async.dart b/sdk/lib/async/async.dart
index c447440..7d22e8b 100644
--- a/sdk/lib/async/async.dart
+++ b/sdk/lib/async/async.dart
@@ -5,7 +5,6 @@
library dart.async;
part 'async_error.dart';
-part 'collection_sink.dart';
part 'deferred_load.dart';
part 'event_loop.dart';
part 'future.dart';
diff --git a/sdk/lib/async/async_sources.gypi b/sdk/lib/async/async_sources.gypi
index a10ee93..b39435a 100644
--- a/sdk/lib/async/async_sources.gypi
+++ b/sdk/lib/async/async_sources.gypi
@@ -8,7 +8,6 @@
'async.dart',
# The above file needs to be first as it lists the parts below.
'async_error.dart',
- 'collection_sink.dart',
'deferred_load.dart',
'event_loop.dart',
'future.dart',
diff --git a/sdk/lib/async/collection_sink.dart b/sdk/lib/async/collection_sink.dart
deleted file mode 100644
index 4ecb831..0000000
--- a/sdk/lib/async/collection_sink.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dart.async;
-
-typedef void _CollectionSinkCallback<T>(Collection<T> collection);
-typedef void _CollectionSinkErrorCallback(AsyncError error);
-
-/**
- * EventSink that stores incoming data in a collection.
- *
- * *Deprecated*.
- */
-class CollectionSink<T> extends StreamSink<T> {
- // TODO(8997): Implement EventSink instead.
- final Collection<T> collection;
- final _CollectionSinkCallback<T> _callback;
- final _CollectionSinkErrorCallback _errorCallback;
- bool _isClosed = false;
-
- /**
- * Create a sink that stores incoming values in a collection.
- *
- * The [collection] is the collection to add the values to.
- *
- * If [callback] is provided, then it's called with the collection as arugment
- * when the sink's [close] method is called.
- */
- CollectionSink(this.collection,
- { void onClose(Collection<T> collection),
- void onError(AsyncError error) })
- : this._callback = onClose,
- this._errorCallback = onError;
-
- add(T value) {
- if (_isClosed) throw new StateError("Adding to closed sink");
- collection.add(value);
- }
-
- void addError(AsyncError error) {
- if (_isClosed) throw new StateError("Adding error to closed sink");
- if (_errorCallback != null) _errorCallback(error);
- }
-
- void close() {
- if (_isClosed) throw new StateError("Closing closed sink");
- _isClosed = true;
- if (_callback != null) _callback(collection);
- }
-}
diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart
index e7a5ab6..7da4451 100644
--- a/sdk/lib/async/stream.dart
+++ b/sdk/lib/async/stream.dart
@@ -132,7 +132,7 @@
}
},
onSubscriptionStateChange: () {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
watch.start();
startPeriodicTimer();
} else {
@@ -236,7 +236,7 @@
/**
* Binds this stream as the input of the provided [StreamConsumer].
*/
- Future pipe(StreamConsumer<T, dynamic> streamConsumer) {
+ Future pipe(StreamConsumer<T> streamConsumer) {
// TODO(floitsch): switch to:
// streamConsumer.addStream(this).then((_) => streamConsumer.close());
return streamConsumer.consume(this);
@@ -253,12 +253,36 @@
/**
* Reduces a sequence of values by repeatedly applying [combine].
- *
- * *WARNING UPCOMING API-CHANGE*: This method will be changed so that
- * it doesn't take an initial value. Use [fold] instead.
*/
- Future reduce(var initialValue, combine(var previous, T element)) {
- return fold(initialValue, combine);
+ Future<T> reduce(T combine(T previous, T element)) {
+ _FutureImpl<T> result = new _FutureImpl<T>();
+ bool seenFirst = false;
+ T value;
+ StreamSubscription subscription;
+ subscription = this.listen(
+ // TODO(ahe): Restore type when feature is implemented in dart2js
+ // checked mode. http://dartbug.com/7733
+ (/* T */ element) {
+ if (seenFirst) {
+ _runUserCode(() => combine(value, element),
+ (T newValue) { value = newValue; },
+ _cancelAndError(subscription, result));
+ } else {
+ value = element;
+ seenFirst = true;
+ }
+ },
+ onError: result._setError,
+ onDone: () {
+ if (!seenFirst) {
+ result._setError(new AsyncError(new StateError("No elements")));
+ } else {
+ result._setValue(value);
+ }
+ },
+ unsubscribeOnError: true
+ );
+ return result;
}
/** Reduces a sequence of values by repeatedly applying [combine]. */
@@ -272,7 +296,7 @@
(/*T*/ element) {
_runUserCode(
() => combine(value, element),
- (result) { value = result; },
+ (newValue) { value = newValue; },
_cancelAndError(subscription, result)
);
},
@@ -286,23 +310,6 @@
return result;
}
- // Deprecated method, previously called 'pipe', retained for compatibility.
- Future pipeInto(EventSink<T> sink,
- {void onError(AsyncError error),
- bool unsubscribeOnError}) {
- _FutureImpl<T> result = new _FutureImpl<T>();
- this.listen(
- sink.add,
- onError: sink.addError,
- onDone: () {
- sink.close();
- result._setValue(null);
- },
- unsubscribeOnError: unsubscribeOnError);
- return result;
- }
-
-
/**
* Checks whether [match] occurs in the elements provided by this stream.
*
@@ -414,98 +421,6 @@
return future;
}
- /**
- * Finds the least element in the stream.
- *
- * If the stream is empty, the result is [:null:].
- * Otherwise the result is a value from the stream that is not greater
- * than any other value from the stream (according to [compare], which must
- * be a [Comparator]).
- *
- * If [compare] is omitted, it defaults to [Comparable.compare].
- *
- * *Deprecated*. Use [reduce] with a binary min method if needed.
- */
- Future<T> min([int compare(T a, T b)]) {
- if (compare == null) {
- var defaultCompare = Comparable.compare;
- compare = defaultCompare;
- }
- _FutureImpl<T> future = new _FutureImpl<T>();
- StreamSubscription subscription;
- T min = null;
- subscription = this.listen(
- // TODO(ahe): Restore type when feature is implemented in dart2js
- // checked mode. http://dartbug.com/7733
- (/*T*/ value) {
- min = value;
- subscription.onData((T value) {
- _runUserCode(
- () => compare(min, value) > 0,
- (bool foundSmaller) {
- if (foundSmaller) {
- min = value;
- }
- },
- _cancelAndError(subscription, future)
- );
- });
- },
- onError: future._setError,
- onDone: () {
- future._setValue(min);
- },
- unsubscribeOnError: true
- );
- return future;
- }
-
- /**
- * Finds the largest element in the stream.
- *
- * If the stream is empty, the result is [:null:].
- * Otherwise the result is an value from the stream that is not smaller
- * than any other value from the stream (according to [compare], which must
- * be a [Comparator]).
- *
- * If [compare] is omitted, it defaults to [Comparable.compare].
- *
- * *Deprecated*. Use [reduce] with a binary max method if needed.
- */
- Future<T> max([int compare(T a, T b)]) {
- if (compare == null) {
- var defaultCompare = Comparable.compare;
- compare = defaultCompare;
- }
- _FutureImpl<T> future = new _FutureImpl<T>();
- StreamSubscription subscription;
- T max = null;
- subscription = this.listen(
- // TODO(ahe): Restore type when feature is implemented in dart2js
- // checked mode. http://dartbug.com/7733
- (/*T*/ value) {
- max = value;
- subscription.onData((T value) {
- _runUserCode(
- () => compare(max, value) < 0,
- (bool foundGreater) {
- if (foundGreater) {
- max = value;
- }
- },
- _cancelAndError(subscription, future)
- );
- });
- },
- onError: future._setError,
- onDone: () {
- future._setValue(max);
- },
- unsubscribeOnError: true
- );
- return future;
- }
-
/** Reports whether this stream contains any elements. */
Future<bool> get isEmpty {
_FutureImpl<bool> future = new _FutureImpl<bool>();
@@ -629,8 +544,8 @@
// TODO(ahe): Restore type when feature is implemented in dart2js
// checked mode. http://dartbug.com/7733
(/*T*/ value) {
- future._setValue(value);
subscription.cancel();
+ future._setValue(value);
return;
},
onError: future._setError,
@@ -685,10 +600,10 @@
// checked mode. http://dartbug.com/7733
(/*T*/ value) {
if (foundResult) {
+ subscription.cancel();
// This is the second element we get.
Error error = new StateError("More than one element");
future._setError(new AsyncError(error));
- subscription.cancel();
return;
}
foundResult = true;
@@ -857,8 +772,8 @@
// checked mode. http://dartbug.com/7733
(/*T*/ value) {
if (index == 0) {
- future._setValue(value);
subscription.cancel();
+ future._setValue(value);
return;
}
index -= 1;
@@ -921,16 +836,6 @@
/**
- * *Deprecated*. Use [EventSink] instead.
- */
-abstract class StreamSink<T> extends EventSink<T>{
- /* TODO(8997): Remove class.*/
- /** *Deprecated*. Use [EventSink.addError] instead.*/
- void signalError(AsyncError errorEvent) { addError(errorEvent); }
-}
-
-
-/**
* An interface that abstracts creation or handling of [Stream] events.
*/
abstract class EventSink<T> {
@@ -965,8 +870,7 @@
/**
* [EventSink] wrapper that only exposes the [EventSink] interface.
*/
-class EventSinkView<T> extends StreamSink<T> {
- // TODO(8997): Implment EventSink instead.
+class EventSinkView<T> extends EventSink<T> {
final EventSink<T> _sink;
EventSinkView(this._sink);
@@ -984,10 +888,7 @@
* the resulting [Future]. The pipe should complete the future when it's
* done.
*/
-abstract class StreamConsumer<S, T> {
- // TODO(floitsch): generic types.
- // Currently not possible to add generic types, since they clash with other
- // types that have already been used.
+abstract class StreamConsumer<S> {
Future addStream(Stream<S> stream);
Future close();
@@ -995,7 +896,7 @@
/**
* Consume is deprecated. Use [addStream] followed by [close] instead.
*/
- Future<T> consume(Stream<S> stream);
+ Future consume(Stream<S> stream);
}
@@ -1066,7 +967,30 @@
const StreamEventTransformer();
Stream<T> bind(Stream<S> source) {
- return new EventTransformStream<S, T>(source, this);
+ // Hackish way of buffering data that goes out of the event-transformer.
+ // TODO(floitsch): replace this with a correct solution.
+ Stream transformingStream = new EventTransformStream<S, T>(source, this);
+ StreamController controller;
+ StreamSubscription subscription;
+ controller = new StreamController<T>(
+ onPauseStateChange: () {
+ if (controller.isPaused) {
+ subscription.pause();
+ } else {
+ subscription.resume();
+ }
+ },
+ onSubscriptionStateChange: () {
+ if (controller.hasListener) {
+ subscription = transformingStream.listen(
+ controller.add,
+ onError: controller.addError,
+ onDone: controller.close);
+ } else {
+ subscription.cancel();
+ }
+ });
+ return controller.stream;
}
/**
@@ -1135,6 +1059,8 @@
final StreamEventTransformer<S, T> _transformer;
/** Whether to unsubscribe when emitting an error. */
final bool _unsubscribeOnError;
+ /** Whether this stream has sent a done event. */
+ bool _isClosed = false;
/** Source of incoming events. */
StreamSubscription<S> _subscription;
/** Cached EventSink wrapper for this class. */
@@ -1153,19 +1079,24 @@
onDone: _handleDone);
}
+ /** Whether this subscription is still subscribed to its source. */
+ bool get _isSubscribed => _subscription != null;
+
void pause([Future pauseSignal]) {
- if (_subscription != null) _subscription.pause(pauseSignal);
+ if (_isSubscribed) _subscription.pause(pauseSignal);
}
void resume() {
- if (_subscription != null) _subscription.resume();
+ if (_isSubscribed) _subscription.resume();
}
void cancel() {
- if (_subscription != null) {
- _subscription.cancel();
+ if (_isSubscribed) {
+ StreamSubscription subscription = _subscription;
_subscription = null;
+ subscription.cancel();
}
+ _isClosed = true;
}
void _handleData(S data) {
@@ -1185,8 +1116,8 @@
}
void _handleDone() {
- _subscription = null;
try {
+ _subscription = null;
_transformer.handleDone(_sink);
} catch (e, s) {
_sendError(_asyncError(e, s));
@@ -1195,10 +1126,12 @@
// EventOutputSink interface.
void _sendData(T data) {
+ if (_isClosed) return;
_onData(data);
}
void _sendError(AsyncError error) {
+ if (_isClosed) return;
_onError(error);
if (_unsubscribeOnError) {
cancel();
@@ -1206,14 +1139,17 @@
}
void _sendDone() {
- // It's ok to cancel even if we have been unsubscribed already.
- cancel();
+ if (_isClosed) throw new StateError("Already closed.");
+ _isClosed = true;
+ if (_isSubscribed) {
+ _subscription.cancel();
+ _subscription = null;
+ }
_onDone();
}
}
-/* TODO(8997): Implement EventSink instead, */
-class _EventOutputSinkWrapper<T> extends StreamSink<T> {
+class _EventOutputSinkWrapper<T> extends EventSink<T> {
_EventOutputSink _sink;
_EventOutputSinkWrapper(this._sink);
diff --git a/sdk/lib/async/stream_controller.dart b/sdk/lib/async/stream_controller.dart
index 5097da6..24a9999 100644
--- a/sdk/lib/async/stream_controller.dart
+++ b/sdk/lib/async/stream_controller.dart
@@ -46,8 +46,7 @@
* the stream at all, and won't trigger callbacks. From the controller's point
* of view, the stream is completely inert when has completed.
*/
-class StreamController<T> extends StreamSink<T> {
- // TODO(8997): Implement EventSink instead.
+class StreamController<T> extends EventSink<T> {
final _StreamImpl<T> stream;
/**
@@ -59,7 +58,7 @@
*
* The [onSubscriptionStateChange] function is called when the stream
* receives its first listener or loses its last. The current subscription
- * state can be read from [hasSubscribers]. Ignored if [:null:].
+ * state can be read from [hasListener]. Ignored if [:null:].
*/
StreamController.broadcast({void onPauseStateChange(),
void onSubscriptionStateChange()})
@@ -78,7 +77,7 @@
*
* The [onSubscriptionStateChange] function is called when the stream
* receives its first listener or loses its last. The current subscription
- * state can be read from [hasSubscribers]. Ignored if [:null:].
+ * state can be read from [hasListener]. Ignored if [:null:].
*/
StreamController({void onPauseStateChange(),
void onSubscriptionStateChange()})
@@ -102,7 +101,7 @@
bool get isPaused => stream._isInputPaused;
/** Whether there are currently any subscribers on this [Stream]. */
- bool get hasSubscribers => stream._hasSubscribers;
+ bool get hasListener => stream._hasListener;
/**
* Send or queue a data event.
diff --git a/sdk/lib/async/stream_impl.dart b/sdk/lib/async/stream_impl.dart
index e3ebd36..e6de3d7 100644
--- a/sdk/lib/async/stream_impl.dart
+++ b/sdk/lib/async/stream_impl.dart
@@ -226,7 +226,7 @@
(_state & _STREAM_EVENT_ID ) >> _STREAM_EVENT_ID_SHIFT;
/** Whether there is currently a subscriber on this [Stream]. */
- bool get _hasSubscribers;
+ bool get _hasListener;
/** Whether the state bits allow firing. */
@@ -286,7 +286,7 @@
void _startFiring() {
assert(!_isFiring);
assert(!_isInCallback);
- assert(_hasSubscribers);
+ assert(_hasListener);
assert(!_isPaused);
// This sets the _STREAM_FIRING bit and toggles the _STREAM_EVENT_ID
// bit. All current subscribers will now have a _LISTENER_EVENT_ID
@@ -417,7 +417,7 @@
* provided one. Repeats calling callbacks as long as the call changes
* the state.
*/
- void _checkCallbacks(bool hadSubscribers, bool wasPaused) {
+ void _checkCallbacks(bool hadListener, bool wasPaused) {
assert(!_isFiring);
// Will be handled after the current callback.
if (_isInCallback) return;
@@ -426,9 +426,9 @@
}
_state |= _STREAM_CALLBACK;
while (true) {
- bool hasSubscribers = _hasSubscribers;
+ bool hasListener = _hasListener;
bool isPaused = _isInputPaused;
- if (hadSubscribers != hasSubscribers) {
+ if (hadListener != hasListener) {
_onSubscriptionStateChange();
} else if (isPaused != wasPaused) {
_onPauseStateChange();
@@ -437,7 +437,7 @@
return;
}
wasPaused = isPaused;
- hadSubscribers = hasSubscribers;
+ hadListener = hasListener;
}
}
@@ -451,7 +451,7 @@
/**
* Called when the first listener subscribes or the last unsubscribes.
*
- * Read [hasSubscribers] to see what the new state is.
+ * Read [hasListener] to see what the new state is.
*/
void _onSubscriptionStateChange() {}
@@ -489,7 +489,7 @@
_sendData(T value) {
assert(!_isPaused);
assert(!_isComplete);
- if (!_hasSubscribers) return;
+ if (!_hasListener) return;
_forEachSubscriber((subscriber) {
try {
subscriber._sendData(value);
@@ -507,7 +507,7 @@
void _sendError(AsyncError error) {
assert(!_isPaused);
assert(!_isComplete);
- if (!_hasSubscribers) return;
+ if (!_hasListener) return;
_forEachSubscriber((subscriber) {
try {
subscriber._sendError(error);
@@ -528,7 +528,7 @@
assert(!_isPaused);
assert(_isClosed);
_setComplete();
- if (!_hasSubscribers) return;
+ if (!_hasListener) return;
_forEachSubscriber((subscriber) {
_cancel(subscriber);
try {
@@ -539,7 +539,7 @@
new AsyncError(e, s).throwDelayed();
}
});
- assert(!_hasSubscribers);
+ assert(!_hasListener);
}
}
@@ -567,7 +567,7 @@
* * [_onSubscriberStateChange]: Called when receiving the first subscriber or
* when losing the last subscriber.
* * [_onPauseStateChange]: Called when entering or leaving paused mode.
- * * [_hasSubscribers]: Test whether there are currently any subscribers.
+ * * [_hasListener]: Test whether there are currently any subscribers.
* * [_isInputPaused]: Test whether the stream is currently paused.
* The user should not add new events while the stream is paused, but if it
* happens anyway, the stream will enqueue the events just as when new events
@@ -577,7 +577,7 @@
_StreamListener _subscriber = null;
/** Whether there is currently a subscriber on this [Stream]. */
- bool get _hasSubscribers => _subscriber != null;
+ bool get _hasListener => _subscriber != null;
// -------------------------------------------------------------------
// Internal implementation.
@@ -601,7 +601,7 @@
void _addListener(_StreamListener subscription) {
assert(!_isComplete);
- if (_hasSubscribers) {
+ if (_hasListener) {
throw new StateError("Stream already has subscriber.");
}
assert(_pauseCount == 1);
@@ -681,7 +681,7 @@
* * [_onSubscriptionStateChange]: Called when receiving the first subscriber or
* when losing the last subscriber.
* * [_onPauseStateChange]: Called when entering or leaving paused mode.
- * * [_hasSubscribers]: Test whether there are currently any subscribers.
+ * * [_hasListener]: Test whether there are currently any subscribers.
* * [_isPaused]: Test whether the stream is currently paused.
* The user should not add new events while the stream is paused, but if it
* happens anyway, the stream will enqueue the events just as when new events
@@ -705,7 +705,7 @@
// Helper functions that can be overridden in subclasses.
/** Whether there are currently any subscribers on this [Stream]. */
- bool get _hasSubscribers => !_InternalLinkList.isEmpty(this);
+ bool get _hasListener => !_InternalLinkList.isEmpty(this);
/**
* Create the new subscription object.
@@ -737,7 +737,7 @@
void _forEachSubscriber(
void action(_StreamListener<T> subscription)) {
assert(!_isFiring);
- if (!_hasSubscribers) return;
+ if (!_hasListener) return;
bool wasInputPaused = _isInputPaused;
_startFiring();
_InternalLink cursor = this._nextLink;
@@ -758,9 +758,9 @@
void _addListener(_StreamListener listener) {
listener._setSubscribed(_currentEventIdBit);
- bool hadSubscribers = _hasSubscribers;
+ bool hadListener = _hasListener;
_InternalLinkList.add(this, listener);
- if (!hadSubscribers && _isInactive) {
+ if (!hadListener && _isInactive) {
_checkCallbacks(false, false);
if (!_isPaused && _hasPendingEvent) {
_schedulePendingEvents();
@@ -1323,7 +1323,7 @@
* [_stream] has subscribers.
*/
void _onSubscriptionStateChange() {
- if (_hasSubscribers) {
+ if (_hasListener) {
assert(_subscription == null);
_subscription = _source.listen(this._add,
onError: this._addError,
diff --git a/sdk/lib/async/stream_pipe.dart b/sdk/lib/async/stream_pipe.dart
index f3a8ea1..aa3da2a 100644
--- a/sdk/lib/async/stream_pipe.dart
+++ b/sdk/lib/async/stream_pipe.dart
@@ -25,6 +25,8 @@
} else {
onError(new AsyncError.withCause(e, s, cause));
}
+ // onError is allowed to return. Don't execute the onSuccess below.
+ return;
}
onSuccess(result);
}
diff --git a/sdk/lib/async/timer.dart b/sdk/lib/async/timer.dart
index b321e41..8a7fdb0 100644
--- a/sdk/lib/async/timer.dart
+++ b/sdk/lib/async/timer.dart
@@ -46,10 +46,7 @@
* Runs the given [callback] asynchronously as soon as possible.
*/
static void run(void callback()) {
- // Optimizing a group of Timer.run callbacks to be executed in the
- // same Timer callback.
- _runCallbacks.add(callback);
- if (_runCallbacks.length == 1) {
+ schedule() {
new Timer(const Duration(milliseconds: 0), () {
List runCallbacks = _runCallbacks;
// Create new list to make sure we don't call newly added callbacks in
@@ -66,11 +63,17 @@
_runCallbacks.addAll(
runCallbacks.sublist(i));
_runCallbacks.addAll(newCallbacks);
+ if (!_runCallbacks.isEmpty) schedule();
throw;
}
}
});
}
+
+ // Optimizing a group of Timer.run callbacks to be executed in the
+ // same Timer callback.
+ _runCallbacks.add(callback);
+ if (_runCallbacks.length == 1) schedule();
}
/**
diff --git a/sdk/lib/collection/collection.dart b/sdk/lib/collection/collection.dart
index 4d37c77..0bbd8f2 100644
--- a/sdk/lib/collection/collection.dart
+++ b/sdk/lib/collection/collection.dart
@@ -11,9 +11,8 @@
part 'maps.dart';
part 'queue.dart';
part 'splay_tree.dart';
-part 'hash_table.dart';
part 'hash_set.dart';
part 'hash_map.dart';
-part 'linked_hash_table.dart';
+part 'list.dart';
part 'linked_hash_set.dart';
part 'linked_hash_map.dart';
diff --git a/sdk/lib/collection/collection_sources.gypi b/sdk/lib/collection/collection_sources.gypi
index 4531699..84259ef 100644
--- a/sdk/lib/collection/collection_sources.gypi
+++ b/sdk/lib/collection/collection_sources.gypi
@@ -10,11 +10,10 @@
'collections.dart',
'hash_map.dart',
'hash_set.dart',
- 'hash_table.dart',
'iterator.dart',
'linked_hash_map.dart',
'linked_hash_set.dart',
- 'linked_hash_table.dart',
+ 'list.dart',
'maps.dart',
'queue.dart',
'splay_tree.dart',
diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart
index 8729452..400ce90 100644
--- a/sdk/lib/collection/collections.dart
+++ b/sdk/lib/collection/collections.dart
@@ -9,6 +9,7 @@
*
* Once Dart receives Mixins it will be replaced with mixin classes.
*/
+@deprecated
class IterableMixinWorkaround {
static bool contains(Iterable iterable, var element) {
for (final e in iterable) {
@@ -38,9 +39,14 @@
}
static dynamic reduce(Iterable iterable,
- dynamic initialValue,
- dynamic combine(dynamic previousValue, element)) {
- return fold(iterable, initialValue, combine);
+ dynamic combine(previousValue, element)) {
+ Iterator iterator = iterable.iterator;
+ if (!iterator.moveNext()) throw new StateError("No elements");
+ var value = iterator.current;
+ while (iterator.moveNext()) {
+ value = combine(value, iterator.current);
+ }
+ return value;
}
static dynamic fold(Iterable iterable,
@@ -53,71 +59,6 @@
}
/**
- * Simple implementation for [Collection.removeAll].
- *
- * This implementation assumes that [Collection.remove] on [collection]
- * is efficient. The [:remove:] method on [List] objects is typically
- * not efficient since it requires linear search to find an element.
- */
- static void removeAll(Collection collection, Iterable elementsToRemove) {
- for (Object object in elementsToRemove) {
- collection.remove(object);
- }
- }
-
- /**
- * Implementation of [Collection.removeAll] for lists.
- *
- * This implementation assumes that [Collection.remove] is not efficient
- * (as it usually isn't on a [List]) and uses [Collection.removeMathcing]
- * instead of just repeatedly calling remove.
- */
- static void removeAllList(Collection collection, Iterable elementsToRemove) {
- Set setToRemove;
- // Assume [contains] is efficient on a Set.
- if (elementsToRemove is Set) {
- setToRemove = elementsToRemove;
- } else {
- setToRemove = elementsToRemove.toSet();
- }
- collection.removeWhere(setToRemove.contains);
- }
-
- /**
- * Simple implemenation for [Collection.retainAll].
- *
- * This implementation assumes that [Collecton.retainWhere] on [collection]
- * is efficient.
- */
- static void retainAll(Collection collection, Iterable elementsToRetain) {
- Set lookup;
- if (elementsToRetain is Set) {
- lookup = elementsToRetain;
- } else {
- lookup = elementsToRetain.toSet();
- }
- if (lookup.isEmpty) {
- collection.clear();
- return;
- }
- collection.retainWhere(lookup.contains);
- }
-
- /**
- * Simple implemenation for [Collection.removeWhere].
- *
- * This implementation assumes that [Collecton.removeAll] on [collection] is
- * efficient.
- */
- static void removeWhere(Collection collection, bool test(var element)) {
- List elementsToRemove = [];
- for (var element in collection) {
- if (test(element)) elementsToRemove.add(element);
- }
- collection.removeAll(elementsToRemove);
- }
-
- /**
* Removes elements matching [test] from [list].
*
* This is performed in two steps, to avoid exposing an inconsistent state
@@ -143,20 +84,6 @@
}
}
- /**
- * Simple implemenation for [Collection.retainWhere].
- *
- * This implementation assumes that [Collecton.removeAll] on [collection] is
- * efficient.
- */
- static void retainWhere(Collection collection, bool test(var element)) {
- List elementsToRemove = [];
- for (var element in collection) {
- if (!test(element)) elementsToRemove.add(element);
- }
- collection.removeAll(elementsToRemove);
- }
-
static bool isEmpty(Iterable iterable) {
return !iterable.iterator.moveNext();
}
@@ -181,32 +108,6 @@
return result;
}
- static dynamic min(Iterable iterable, [int compare(var a, var b)]) {
- if (compare == null) compare = Comparable.compare;
- Iterator it = iterable.iterator;
- if (!it.moveNext()) {
- return null;
- }
- var min = it.current;
- while (it.moveNext()) {
- if (compare(min, it.current) > 0) min = it.current;
- }
- return min;
- }
-
- static dynamic max(Iterable iterable, [int compare(var a, var b)]) {
- if (compare == null) compare = Comparable.compare;
- Iterator it = iterable.iterator;
- if (!it.moveNext()) {
- return null;
- }
- var max = it.current;
- while (it.moveNext()) {
- if (compare(max, it.current) < 0) max = it.current;
- }
- return max;
- }
-
static dynamic single(Iterable iterable) {
Iterator it = iterable.iterator;
if (!it.moveNext()) throw new StateError("No elements");
@@ -281,7 +182,7 @@
static String join(Iterable iterable, [String separator]) {
StringBuffer buffer = new StringBuffer();
- buffer.writeAll(iterable, separator == null ? "" : separator);
+ buffer.writeAll(iterable, separator);
return buffer.toString();
}
@@ -289,15 +190,15 @@
if (list.isEmpty) return "";
if (list.length == 1) return "${list[0]}";
StringBuffer buffer = new StringBuffer();
- if (separator == null || separator == "") {
+ if (separator.isEmpty) {
for (int i = 0; i < list.length; i++) {
- buffer.write("${list[i]}");
+ buffer.write(list[i]);
}
} else {
- buffer.write("${list[0]}");
+ buffer.write(list[0]);
for (int i = 1; i < list.length; i++) {
buffer.write(separator);
- buffer.write("${list[i]}");
+ buffer.write(list[i]);
}
}
return buffer.toString();
@@ -321,7 +222,6 @@
static Iterable takeList(List list, int n) {
// The generic type is currently lost. It will be fixed with mixins.
- // This is currently a List as well as an Iterable.
return new SubListIterable(list, 0, n);
}
@@ -332,7 +232,6 @@
static Iterable skipList(List list, int n) {
// The generic type is currently lost. It will be fixed with mixins.
- // This is currently a List as well as an Iterable.
return new SubListIterable(list, n, null);
}
@@ -359,6 +258,17 @@
return Arrays.lastIndexOf(list, element, start);
}
+ static Iterable getRangeList(List list, int start, int end) {
+ if (start < 0 || start > list.length) {
+ throw new RangeError.range(start, 0, list.length);
+ }
+ if (end < start || end > list.length) {
+ throw new RangeError.range(end, start, list.length);
+ }
+ // The generic type is currently lost. It will be fixed with mixins.
+ return new SubListIterable(list, start, end);
+ }
+
static void setRangeList(List list, int start, int length,
List from, int startFrom) {
if (length == 0) return;
@@ -417,11 +327,6 @@
}
}
-class Collections {
- static String collectionToString(Collection c)
- => ToString.collectionToString(c);
-}
-
/**
* An unmodifiable [List] view of another List.
*
diff --git a/sdk/lib/collection/hash_map.dart b/sdk/lib/collection/hash_map.dart
index 0fe3526..f5fcd85 100644
--- a/sdk/lib/collection/hash_map.dart
+++ b/sdk/lib/collection/hash_map.dart
@@ -4,22 +4,6 @@
part of dart.collection;
-class _HashMapTable<K, V> extends _HashTable<K> {
- static const int _INITIAL_CAPACITY = 8;
- static const int _VALUE_INDEX = 1;
-
- _HashMapTable() : super(_INITIAL_CAPACITY);
-
- int get _entrySize => 2;
-
- V _value(int offset) => _table[offset + _VALUE_INDEX];
- void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
-
- _copyEntry(List fromTable, int fromOffset, int toOffset) {
- _table[toOffset + _VALUE_INDEX] = fromTable[fromOffset + _VALUE_INDEX];
- }
-}
-
class HashMap<K, V> implements Map<K, V> {
external HashMap();
diff --git a/sdk/lib/collection/hash_set.dart b/sdk/lib/collection/hash_set.dart
index 977dcff..f658b52 100644
--- a/sdk/lib/collection/hash_set.dart
+++ b/sdk/lib/collection/hash_set.dart
@@ -4,7 +4,59 @@
part of dart.collection;
-class HashSet<E> extends Collection<E> implements Set<E> {
+/** Common parts of [HashSet] and [LinkedHashSet] implementations. */
+abstract class _HashSetBase<E> extends Iterable<E> implements Set<E> {
+ // Set.
+ bool containsAll(Iterable<E> other) {
+ for (E object in other) {
+ if (!this.contains(object)) return false;
+ }
+ return true;
+ }
+
+ /** Create a new Set of the same type as this. */
+ Set _newSet();
+
+ Set<E> intersection(Set<E> other) {
+ Set<E> result = _newSet();
+ if (other.length < this.length) {
+ for (E element in other) {
+ if (this.contains(element)) result.add(element);
+ }
+ } else {
+ for (E element in this) {
+ if (other.contains(element)) result.add(element);
+ }
+ }
+ return result;
+ }
+
+ Set<E> union(Set<E> other) {
+ return _newSet()..addAll(this)..addAll(other);
+ }
+
+ Set<E> difference(Set<E> other) {
+ HashSet<E> result = _newSet();
+ for (E element in this) {
+ if (!other.contains(element)) result.add(element);
+ }
+ return result;
+ }
+
+ void retainAll(Iterable objectsToRetain) {
+ Set retainSet;
+ if (objectsToRetain is Set) {
+ retainSet = objectsToRetain;
+ } else {
+ retainSet = objectsToRetain.toSet();
+ }
+ retainWhere(retainSet.contains);
+ }
+
+ String toString() => ToString.iterableToString(this);
+}
+
+class HashSet<E> extends _HashSetBase<E> {
external HashSet();
factory HashSet.from(Iterable<E> iterable) {
@@ -29,10 +81,6 @@
external void removeAll(Iterable objectsToRemove);
- void retainAll(Iterable objectsToRetain) {
- IterableMixinWorkaround.retainAll(this, objectsToRetain);
- }
-
external void removeWhere(bool test(E element));
external void retainWhere(bool test(E element));
@@ -40,33 +88,5 @@
external void clear();
// Set.
- bool isSubsetOf(Collection<E> other) {
- // Deprecated, and using old signature.
- Set otherSet;
- if (other is Set) {
- otherSet = other;
- } else {
- otherSet = other.toSet();
- }
- return IterableMixinWorkaround.setContainsAll(otherSet, this);
- }
-
- bool containsAll(Iterable<E> other) {
- return IterableMixinWorkaround.setContainsAll(this, other);
- }
-
- Set<E> intersection(Set<E> other) {
- return IterableMixinWorkaround.setIntersection(
- this, other, new HashSet<E>());
- }
-
- Set<E> union(Set<E> other) {
- return IterableMixinWorkaround.setUnion(this, other, new HashSet<E>());
- }
-
- Set<E> difference(Set<E> other) {
- return IterableMixinWorkaround.setDifference(this, other, new HashSet<E>());
- }
-
- String toString() => Collections.collectionToString(this);
+ Set<E> _newSet() => new HashSet<E>();
}
diff --git a/sdk/lib/collection/hash_table.dart b/sdk/lib/collection/hash_table.dart
deleted file mode 100644
index ececc47..0000000
--- a/sdk/lib/collection/hash_table.dart
+++ /dev/null
@@ -1,404 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dart.collection;
-
-class _DeadEntry {
- const _DeadEntry();
-}
-
-class _NullKey {
- const _NullKey();
- int get hashCode => null.hashCode;
-}
-
-const _TOMBSTONE = const _DeadEntry();
-const _NULL = const _NullKey();
-
-class _HashTable<K> {
- /**
- * Table of entries with [_entrySize] slots per entry.
- *
- * Capacity in entries must be factor of two.
- */
- List _table;
- /** Current capacity. Always equal to [:_table.length ~/ _entrySize:]. */
- int _capacity;
- /** Count of occupied entries, including deleted ones. */
- int _entryCount = 0;
- /** Count of deleted entries. */
- int _deletedCount = 0;
- /** Counter incremented when table is modified. */
- int _modificationCount = 0;
- /** If set, used as the source object for [ConcurrentModificationError]s. */
- Object _container;
-
- _HashTable(int initialCapacity) : _capacity = initialCapacity {
- _table = _createTable(initialCapacity);
- }
-
- /** Reads key from table. Converts _NULL marker to null. */
- Object _key(offset) {
- assert(!_isFree(_table[offset]));
- Object key = _table[offset];
- if (!identical(key, _NULL)) return key;
- return null;
- }
-
- /** Writes key to table. Converts null to _NULL marker. */
- void _setKey(int offset, Object key) {
- if (key == null) key = _NULL;
- _table[offset] = key;
- }
-
- int get _elementCount => _entryCount - _deletedCount;
-
- /** Size of each entry. */
- int get _entrySize => 1;
-
- void _checkModification(int expectedModificationCount) {
- if (_modificationCount != expectedModificationCount) {
- throw new ConcurrentModificationError(_container);
- }
- }
-
- void _recordModification() {
- // Value cycles after 2^30 modifications. If you keep hold of an
- // iterator for that long, you might miss a modification detection,
- // and iteration can go sour. Don't do that.
- _modificationCount = (_modificationCount + 1) & (0x3FFFFFFF);
- }
-
- /**
- * Create an empty table.
- */
- List _createTable(int capacity) {
- List table = new List(capacity * _entrySize);
- return table;
- }
-
- /** First table probe. */
- int _firstProbe(int hashCode, int capacity) {
- return hashCode & (capacity - 1);
- }
-
- /** Following table probes. */
- int _nextProbe(int previousIndex, int probeCount, int capacity) {
- // When capacity is a power of 2, this probing algorithm (the triangular
- // number sequence modulo capacity) is guaranteed to hit all indices exactly
- // once before repeating.
- return (previousIndex + probeCount) & (capacity - 1);
- }
-
- /** Whether an object is a free-marker (either tombstone or free). */
- bool _isFree(Object marker) =>
- marker == null || identical(marker, _TOMBSTONE);
-
- /**
- * Look up the offset for an object in the table.
- *
- * Finds the offset of the object in the table, if it is there,
- * or the first free offset for its hashCode.
- */
- int _probeForAdd(int hashCode, Object object) {
- int entrySize = _entrySize;
- int index = _firstProbe(hashCode, _capacity);
- int firstTombstone = -1;
- int probeCount = 0;
- while (true) {
- int offset = index * entrySize;
- Object entry = _table[offset];
- if (identical(entry, _TOMBSTONE)) {
- if (firstTombstone < 0) firstTombstone = offset;
- } else if (entry == null) {
- if (firstTombstone < 0) return offset;
- return firstTombstone;
- } else if (identical(_NULL, entry) ? _equals(null, object)
- : _equals(entry, object)) {
- return offset;
- }
- // The _nextProbe is designed so that it hits
- // every index eventually.
- index = _nextProbe(index, ++probeCount, _capacity);
- }
- }
-
- /**
- * Look up the offset for an object in the table.
- *
- * If the object is in the table, its offset is returned.
- *
- * If the object is not in the table, Otherwise a negative value is returned.
- */
- int _probeForLookup(int hashCode, Object object) {
- int entrySize = _entrySize;
- int index = _firstProbe(hashCode, _capacity);
- int probeCount = 0;
- while (true) {
- int offset = index * entrySize;
- Object entry = _table[offset];
- if (entry == null) {
- return -1;
- } else if (!identical(_TOMBSTONE, entry)) {
- if (identical(_NULL, entry) ? _equals(null, object)
- : _equals(entry, object)) {
- return offset;
- }
- }
- // The _nextProbe is designed so that it hits
- // every index eventually.
- index = _nextProbe(index, ++probeCount, _capacity);
- }
- }
-
- // Override the following two to change equality/hashCode computations
-
- /**
- * Compare two object for equality.
- *
- * The first object is the one already in the table,
- * and the second is the one being searched for.
- */
- bool _equals(Object element, Object other) {
- return element == other;
- }
-
- /**
- * Compute hash-code for an object.
- */
- int _hashCodeOf(Object object) => object.hashCode;
-
- /**
- * Ensure that the table isn't too full for its own good.
- *
- * Call this after adding an element.
- */
- int _checkCapacity() {
- // Compute everything in multiples of entrySize to avoid division.
- int freeCount = _capacity - _entryCount;
- if (freeCount * 4 < _capacity ||
- freeCount < _deletedCount) {
- // Less than 25% free or more deleted entries than free entries.
- _grow(_entryCount - _deletedCount);
- }
- }
-
- void _grow(int contentCount) {
- int capacity = _capacity;
- // Don't grow to less than twice the needed capacity.
- int minCapacity = contentCount * 2;
- while (capacity < minCapacity) {
- capacity *= 2;
- }
- // Reset to another table and add all existing elements.
- List oldTable = _table;
- _table = _createTable(capacity);
- _capacity = capacity;
- _entryCount = 0;
- _deletedCount = 0;
- _addAllEntries(oldTable);
- _recordModification();
- }
-
- /**
- * Copies all non-free entries from the old table to the new empty table.
- */
- void _addAllEntries(List oldTable) {
- for (int i = 0; i < oldTable.length; i += _entrySize) {
- Object object = oldTable[i];
- if (!_isFree(object)) {
- int toOffset = _put(object);
- _copyEntry(oldTable, i, toOffset);
- }
- }
- }
-
- /**
- * Copies everything but the key element from one entry to another.
- *
- * Called while growing the base array.
- *
- * Override this if any non-key fields need copying.
- */
- void _copyEntry(List fromTable, int fromOffset, int toOffset) {}
-
- // The following three methods are for simple get/set/remove operations.
- // They only affect the key of an entry. The remaining fields must be
- // filled by the caller.
-
- /**
- * Returns the offset of a key in [_table], or negative if it's not there.
- */
- int _get(K key) {
- return _probeForLookup(_hashCodeOf(key), key);
- }
-
- /**
- * Puts the key into the table and returns its offset into [_table].
- *
- * If [_entrySize] is greater than 1, the caller should fill the
- * remaining fields.
- *
- * Remember to call [_checkCapacity] after using this method.
- */
- int _put(K key) {
- int offset = _probeForAdd(_hashCodeOf(key), key);
- Object oldEntry = _table[offset];
- if (oldEntry == null) {
- _entryCount++;
- } else if (identical(oldEntry, _TOMBSTONE)) {
- _deletedCount--;
- } else {
- return offset;
- }
- _setKey(offset, key);
- _recordModification();
- return offset;
- }
-
- /**
- * Removes a key from the table and returns its offset into [_table].
- *
- * Returns null if the key was not in the table.
- * If [_entrySize] is greater than 1, the caller should clean up the
- * remaining fields.
- */
- int _remove(K key) {
- int offset = _probeForLookup(_hashCodeOf(key), key);
- if (offset >= 0) {
- _deleteEntry(offset);
- }
- return offset;
- }
-
- /** Clears the table completely, leaving it empty. */
- void _clear() {
- if (_elementCount == 0) return;
- for (int i = 0; i < _table.length; i++) {
- _table[i] = null;
- }
- _entryCount = _deletedCount = 0;
- _recordModification();
- }
-
- /** Clears an entry in the table. */
- void _deleteEntry(int offset) {
- assert(!_isFree(_table[offset]));
- _setKey(offset, _TOMBSTONE);
- _deletedCount++;
- _recordModification();
- }
-}
-
-/**
- * Generic iterable based on a [_HashTable].
- */
-abstract class _HashTableIterable<E> extends Iterable<E> {
- final _HashTable _hashTable;
- _HashTableIterable(this._hashTable);
-
- Iterator<E> get iterator;
-
- /**
- * Return the iterated value for a given entry.
- */
- E _valueAt(int offset, Object key);
-
- int get length => _hashTable._elementCount;
-
- bool get isEmpty => _hashTable._elementCount == 0;
-
- void forEach(void action(E element)) {
- int entrySize = _hashTable._entrySize;
- List table = _hashTable._table;
- int modificationCount = _hashTable._modificationCount;
- for (int offset = 0; offset < table.length; offset += entrySize) {
- Object entry = table[offset];
- if (!_hashTable._isFree(entry)) {
- E value = _valueAt(offset, entry);
- action(value);
- }
- _hashTable._checkModification(modificationCount);
- }
- }
-}
-
-abstract class _HashTableIterator<E> implements Iterator<E> {
- final _HashTable _hashTable;
- final int _modificationCount;
- /** Location right after last found element. */
- int _offset = 0;
- E _current = null;
-
- _HashTableIterator(_HashTable hashTable)
- : _hashTable = hashTable,
- _modificationCount = hashTable._modificationCount;
-
- bool moveNext() {
- _hashTable._checkModification(_modificationCount);
-
- List table = _hashTable._table;
- int entrySize = _hashTable._entrySize;
-
- while (_offset < table.length) {
- int currentOffset = _offset;
- Object entry = table[currentOffset];
- _offset = currentOffset + entrySize;
- if (!_hashTable._isFree(entry)) {
- _current = _valueAt(currentOffset, entry);
- return true;
- }
- }
- _current = null;
- return false;
- }
-
- E get current => _current;
-
- E _valueAt(int offset, Object key);
-}
-
-class _HashTableKeyIterable<K> extends _HashTableIterable<K> {
- _HashTableKeyIterable(_HashTable<K> hashTable) : super(hashTable);
-
- Iterator<K> get iterator => new _HashTableKeyIterator<K>(_hashTable);
-
- K _valueAt(int offset, Object key) {
- if (identical(key, _NULL)) return null;
- return key;
- }
-
- bool contains(Object value) => _hashTable._get(value) >= 0;
-}
-
-class _HashTableKeyIterator<K> extends _HashTableIterator<K> {
- _HashTableKeyIterator(_HashTable hashTable) : super(hashTable);
-
- K _valueAt(int offset, Object key) {
- if (identical(key, _NULL)) return null;
- return key;
- }
-}
-
-class _HashTableValueIterable<V> extends _HashTableIterable<V> {
- final int _entryIndex;
-
- _HashTableValueIterable(_HashTable hashTable, this._entryIndex)
- : super(hashTable);
-
- Iterator<V> get iterator {
- return new _HashTableValueIterator<V>(_hashTable, _entryIndex);
- }
-
- V _valueAt(int offset, Object key) => _hashTable._table[offset + _entryIndex];
-}
-
-class _HashTableValueIterator<V> extends _HashTableIterator<V> {
- final int _entryIndex;
-
- _HashTableValueIterator(_HashTable hashTable, this._entryIndex)
- : super(hashTable);
-
- V _valueAt(int offset, Object key) => _hashTable._table[offset + _entryIndex];
-}
diff --git a/sdk/lib/collection/linked_hash_map.dart b/sdk/lib/collection/linked_hash_map.dart
index 4dcbc060..431f7fa 100644
--- a/sdk/lib/collection/linked_hash_map.dart
+++ b/sdk/lib/collection/linked_hash_map.dart
@@ -4,135 +4,40 @@
part of dart.collection;
-class _LinkedHashMapTable<K, V> extends _LinkedHashTable<K> {
- static const int _INITIAL_CAPACITY = 8;
- static const int _VALUE_INDEX = 3;
-
- int get _entrySize => 4;
-
- _LinkedHashMapTable() : super(_INITIAL_CAPACITY);
-
- V _value(int offset) => _table[offset + _VALUE_INDEX];
- void _setValue(int offset, V value) { _table[offset + _VALUE_INDEX] = value; }
-
- _copyEntry(List oldTable, int fromOffset, int toOffset) {
- _table[toOffset + _VALUE_INDEX] = oldTable[fromOffset + _VALUE_INDEX];
- }
-}
-
/**
* A hash-based map that iterates keys and values in key insertion order.
*/
class LinkedHashMap<K, V> implements Map<K, V> {
- final _LinkedHashMapTable _hashTable;
-
- LinkedHashMap() : _hashTable = new _LinkedHashMapTable<K, V>() {
- _hashTable._container = this;
- }
+ external LinkedHashMap();
factory LinkedHashMap.from(Map<K, V> other) {
return new LinkedHashMap<K, V>()..addAll(other);
}
- bool containsKey(K key) {
- return _hashTable._get(key) >= 0;
- }
+ external bool containsKey(K key);
- bool containsValue(V value) {
- int modificationCount = _hashTable._modificationCount;
- for (int offset = _hashTable._next(_LinkedHashTable._HEAD_OFFSET);
- offset != _LinkedHashTable._HEAD_OFFSET;
- offset = _hashTable._next(offset)) {
- if (_hashTable._value(offset) == value) {
- return true;
- }
- // The == call may modify the table.
- _hashTable._checkModification(modificationCount);
- }
- return false;
- }
+ external bool containsValue(V value);
- void addAll(Map<K, V> other) {
- other.forEach((K key, V value) {
- int offset = _hashTable._put(key);
- _hashTable._setValue(offset, value);
- _hashTable._checkCapacity();
- });
- }
+ external void addAll(Map<K, V> other);
- V operator [](K key) {
- int offset = _hashTable._get(key);
- if (offset >= 0) return _hashTable._value(offset);
- return null;
- }
+ external V operator [](K key);
- void operator []=(K key, V value) {
- int offset = _hashTable._put(key);
- _hashTable._setValue(offset, value);
- _hashTable._checkCapacity();
- }
+ external void operator []=(K key, V value);
- V putIfAbsent(K key, V ifAbsent()) {
- int offset = _hashTable._probeForAdd(_hashTable._hashCodeOf(key), key);
- Object entry = _hashTable._table[offset];
- if (!_hashTable._isFree(entry)) {
- return _hashTable._value(offset);
- }
- int modificationCount = _hashTable._modificationCount;
- V value = ifAbsent();
- if (modificationCount == _hashTable._modificationCount) {
- _hashTable._setKey(offset, key);
- _hashTable._setValue(offset, value);
- _hashTable._linkLast(offset);
- if (entry == null) {
- _hashTable._entryCount++;
- _hashTable._checkCapacity();
- } else {
- assert(identical(entry, _TOMBSTONE));
- _hashTable._deletedCount--;
- }
- _hashTable._recordModification();
- } else {
- // The table might have changed, so we can't trust [offset] any more.
- // Do another lookup before setting the value.
- offset = _hashTable._put(key);
- _hashTable._setValue(offset, value);
- _hashTable._checkCapacity();
- }
- return value;
- }
+ external V putIfAbsent(K key, V ifAbsent());
- V remove(K key) {
- int offset = _hashTable._remove(key);
- if (offset < 0) return null;
- Object oldValue = _hashTable._value(offset);
- _hashTable._setValue(offset, null);
- _hashTable._checkCapacity();
- return oldValue;
- }
+ external V remove(K key);
- void clear() {
- _hashTable._clear();
- }
+ external void clear();
- void forEach(void action (K key, V value)) {
- int modificationCount = _hashTable._modificationCount;
- for (int offset = _hashTable._next(_LinkedHashTable._HEAD_OFFSET);
- offset != _LinkedHashTable._HEAD_OFFSET;
- offset = _hashTable._next(offset)) {
- action(_hashTable._key(offset), _hashTable._value(offset));
- _hashTable._checkModification(modificationCount);
- }
- }
+ external void forEach(void action (K key, V value));
- Iterable<K> get keys => new _LinkedHashTableKeyIterable<K>(_hashTable);
- Iterable<V> get values =>
- new _LinkedHashTableValueIterable<V>(_hashTable,
- _LinkedHashMapTable._VALUE_INDEX);
+ external Iterable<K> get keys;
+ external Iterable<V> get values;
- int get length => _hashTable._elementCount;
+ external int get length;
- bool get isEmpty => _hashTable._elementCount == 0;
+ external bool get isEmpty;
String toString() => Maps.mapToString(this);
}
diff --git a/sdk/lib/collection/linked_hash_set.dart b/sdk/lib/collection/linked_hash_set.dart
index 8a4d566..e866b63 100644
--- a/sdk/lib/collection/linked_hash_set.dart
+++ b/sdk/lib/collection/linked_hash_set.dart
@@ -4,159 +4,50 @@
part of dart.collection;
-class LinkedHashSet<E> extends Collection<E> implements Set<E> {
- static const int _INITIAL_CAPACITY = 8;
- _LinkedHashTable<E> _table;
+class LinkedHashSet<E> extends _HashSetBase<E> {
- LinkedHashSet() : _table = new _LinkedHashTable(_INITIAL_CAPACITY) {
- _table._container = this;
- }
+ external LinkedHashSet();
factory LinkedHashSet.from(Iterable<E> iterable) {
return new LinkedHashSet<E>()..addAll(iterable);
}
// Iterable.
- Iterator<E> get iterator => new _LinkedHashTableKeyIterator<E>(_table);
+ external Iterator<E> get iterator;
- void forEach(void action(E element)) {
- int offset = _table._next(_LinkedHashTable._HEAD_OFFSET);
- int modificationCount = _table._modificationCount;
- while (offset != _LinkedHashTable._HEAD_OFFSET) {
- E key = _table._key(offset);
- action(key);
- _table._checkModification(modificationCount);
- offset = _table._next(offset);
- }
- }
+ external int get length;
- int get length => _table._elementCount;
+ external bool get isEmpty;
- bool get isEmpty => _table._elementCount == 0;
+ external bool contains(Object object);
- bool contains(Object object) => _table._get(object) >= 0;
+ external void forEach(void action(E element));
- E get first {
- int firstOffset = _table._next(_LinkedHashTable._HEAD_OFFSET);
- if (firstOffset == _LinkedHashTable._HEAD_OFFSET) {
- throw new StateError("No elements");
- }
- return _table._key(firstOffset);
- }
+ external E get first;
- E get last {
- int lastOffset = _table._prev(_LinkedHashTable._HEAD_OFFSET);
- if (lastOffset == _LinkedHashTable._HEAD_OFFSET) {
- throw new StateError("No elements");
- }
- return _table._key(lastOffset);
- }
+ external E get last;
E get single {
- int firstOffset = _table._next(_LinkedHashTable._HEAD_OFFSET);
- if (firstOffset == _LinkedHashTable._HEAD_OFFSET) {
- throw new StateError("No elements");
- }
- int lastOffset = _table._prev(_LinkedHashTable._HEAD_OFFSET);
- if (lastOffset != firstOffset) {
- throw new StateError("Too many elements");
- }
- return _table._key(firstOffset);
+ if (length == 1) return first;
+ var message = (length == 0) ? "No Elements" : "Too many elements";
+ throw new StateError(message);
}
// Collection.
- void add(E element) {
- _table._put(element);
- _table._checkCapacity();
- }
+ external void add(E element);
- void addAll(Iterable<E> objects) {
- for (E object in objects) {
- _table._put(object);
- _table._checkCapacity();
- }
- }
+ external void addAll(Iterable<E> objects);
- bool remove(Object object) {
- int offset = _table._remove(object);
- if (offset >= 0) {
- _table._checkCapacity();
- return true;
- }
- return false;
- }
+ external bool remove(Object object);
- void removeAll(Iterable objectsToRemove) {
- for (Object object in objectsToRemove) {
- _table._remove(object);
- _table._checkCapacity();
- }
- }
+ external void removeAll(Iterable objectsToRemove);
- void retainAll(Iterable objectsToRemove) {
- IterableMixinWorkaround.retainAll(this, objectsToRemove);
- }
+ external void removeWhere(bool test(E element));
- void _filterWhere(bool test(E element), bool removeMatching) {
- int entrySize = _table._entrySize;
- int length = _table._table.length;
- int offset = _table._next(_LinkedHashTable._HEAD_OFFSET);
- while (offset != _LinkedHashTable._HEAD_OFFSET) {
- E key = _table._key(offset);
- int nextOffset = _table._next(offset);
- int modificationCount = _table._modificationCount;
- bool shouldRemove = (removeMatching == test(key));
- _table._checkModification(modificationCount);
- if (shouldRemove) {
- _table._deleteEntry(offset);
- }
- offset = nextOffset;
- }
- _table._checkCapacity();
- }
+ external void retainWhere(bool test(E element));
- void removeWhere(bool test(E element)) {
- _filterWhere(test, true);
- }
-
- void retainWhere(bool test(E element)) {
- _filterWhere(test, false);
- }
-
- void clear() {
- _table._clear();
- }
+ external void clear();
// Set.
- bool isSubsetOf(Collection<E> other) {
- // Deprecated, and using old signature.
- Set otherSet;
- if (other is Set) {
- otherSet = other;
- } else {
- otherSet = other.toSet();
- }
- return IterableMixinWorkaround.setContainsAll(otherSet, this);
- }
-
- bool containsAll(Iterable<E> other) {
- return IterableMixinWorkaround.setContainsAll(this, other);
- }
-
- Set<E> intersection(Set<E> other) {
- return IterableMixinWorkaround.setIntersection(
- this, other, new LinkedHashSet<E>());
- }
-
- Set<E> union(Set<E> other) {
- return IterableMixinWorkaround.setUnion(
- this, other, new LinkedHashSet<E>());
- }
-
- Set<E> difference(Set<E> other) {
- return IterableMixinWorkaround.setDifference(
- this, other, new LinkedHashSet<E>());
- }
-
- String toString() => Collections.collectionToString(this);
+ Set<E> _newSet() => new LinkedHashSet<E>();
}
diff --git a/sdk/lib/collection/linked_hash_table.dart b/sdk/lib/collection/linked_hash_table.dart
deleted file mode 100644
index 4b8b063..0000000
--- a/sdk/lib/collection/linked_hash_table.dart
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dart.collection;
-
-/** Unique marker object for the head of a linked list of entries. */
-class _LinkedHashTableHeadMarker {
- const _LinkedHashTableHeadMarker();
-}
-
-const _LinkedHashTableHeadMarker _HEAD_MARKER =
- const _LinkedHashTableHeadMarker();
-
-class _LinkedHashTable<K> extends _HashTable<K> {
- static const _NEXT_INDEX = 1;
- static const _PREV_INDEX = 2;
- static const _HEAD_OFFSET = 0;
-
- _LinkedHashTable(int initialCapacity) : super(initialCapacity);
-
- int get _entrySize => 3;
-
- List _createTable(int capacity) {
- List result = new List(capacity * _entrySize);
- result[_HEAD_OFFSET] = _HEAD_MARKER;
- result[_HEAD_OFFSET + _NEXT_INDEX] = _HEAD_OFFSET;
- result[_HEAD_OFFSET + _PREV_INDEX] = _HEAD_OFFSET;
- return result;
- }
-
- int _next(int offset) => _table[offset + _NEXT_INDEX];
- void _setNext(int offset, int to) { _table[offset + _NEXT_INDEX] = to; }
-
- int _prev(int offset) => _table[offset + _PREV_INDEX];
- void _setPrev(int offset, int to) { _table[offset + _PREV_INDEX] = to; }
-
- void _linkLast(int offset) {
- // Add entry at offset at end of double-linked list.
- int last = _prev(_HEAD_OFFSET);
- _setNext(offset, _HEAD_OFFSET);
- _setPrev(offset, last);
- _setNext(last, offset);
- _setPrev(_HEAD_OFFSET, offset);
- }
-
- void _unlink(int offset) {
- assert(offset != _HEAD_OFFSET);
- int next = _next(offset);
- int prev = _prev(offset);
- _setNext(offset, null);
- _setPrev(offset, null);
- _setNext(prev, next);
- _setPrev(next, prev);
- }
-
- /**
- * Copies all non-free entries from the old table to the new empty table.
- */
- void _addAllEntries(List oldTable) {
- int offset = oldTable[_HEAD_OFFSET + _NEXT_INDEX];
- while (offset != _HEAD_OFFSET) {
- Object object = oldTable[offset];
- int nextOffset = oldTable[offset + _NEXT_INDEX];
- int toOffset = _put(object);
- _copyEntry(oldTable, offset, toOffset);
- offset = nextOffset;
- }
- }
-
- void _clear() {
- if (_elementCount == 0) return;
- _setNext(_HEAD_OFFSET, _HEAD_OFFSET);
- _setPrev(_HEAD_OFFSET, _HEAD_OFFSET);
- for (int i = _entrySize; i < _table.length; i++) {
- _table[i] = null;
- }
- _entryCount = _deletedCount = 0;
- _recordModification();
- }
-
- int _put(K key) {
- int offset = _probeForAdd(_hashCodeOf(key), key);
- Object oldEntry = _table[offset];
- if (identical(oldEntry, _TOMBSTONE)) {
- _deletedCount--;
- } else if (oldEntry == null) {
- _entryCount++;
- } else {
- return offset;
- }
- _recordModification();
- _setKey(offset, key);
- _linkLast(offset);
- return offset;
- }
-
- void _deleteEntry(int offset) {
- _unlink(offset);
- _setKey(offset, _TOMBSTONE);
- _deletedCount++;
- _recordModification();
- }
-}
-
-class _LinkedHashTableKeyIterable<K> extends Iterable<K> {
- final _LinkedHashTable<K> _table;
- _LinkedHashTableKeyIterable(this._table);
- Iterator<K> get iterator => new _LinkedHashTableKeyIterator<K>(_table);
-
- bool contains(Object value) => _table._get(value) >= 0;
-
- int get length => _table._elementCount;
-}
-
-class _LinkedHashTableKeyIterator<K> extends _LinkedHashTableIterator<K> {
- _LinkedHashTableKeyIterator(_LinkedHashTable<K> hashTable): super(hashTable);
-
- K _getCurrent(int offset) => _hashTable._key(offset);
-}
-
-class _LinkedHashTableValueIterable<V> extends Iterable<V> {
- final _LinkedHashTable _hashTable;
- final int _valueIndex;
- _LinkedHashTableValueIterable(this._hashTable, this._valueIndex);
- Iterator<V> get iterator =>
- new _LinkedHashTableValueIterator<V>(_hashTable, _valueIndex);
- int get length => _hashTable._elementCount;
-}
-
-class _LinkedHashTableValueIterator<V> extends _LinkedHashTableIterator<V> {
- final int _valueIndex;
-
- _LinkedHashTableValueIterator(_LinkedHashTable hashTable, this._valueIndex)
- : super(hashTable);
-
- V _getCurrent(int offset) => _hashTable._table[offset + _valueIndex];
-}
-
-abstract class _LinkedHashTableIterator<T> implements Iterator<T> {
- final _LinkedHashTable _hashTable;
- final int _modificationCount;
- int _offset;
- T _current;
-
- _LinkedHashTableIterator(_LinkedHashTable table)
- : _hashTable = table,
- _modificationCount = table._modificationCount,
- _offset = table._next(_LinkedHashTable._HEAD_OFFSET);
-
- bool moveNext() {
- _hashTable._checkModification(_modificationCount);
- if (_offset == _LinkedHashTable._HEAD_OFFSET) {
- _current = null;
- return false;
- }
- _current = _getCurrent(_offset);
- _offset = _hashTable._next(_offset);
- return true;
- }
-
- T _getCurrent(int offset);
-
- T get current => _current;
-}
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
new file mode 100644
index 0000000..354e59e
--- /dev/null
+++ b/sdk/lib/collection/list.dart
@@ -0,0 +1,425 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.collection;
+
+/**
+ * Abstract implementation of a list.
+ *
+ * All operations are defined in terms of `length`, `operator[]`,
+ * `operator[]=` and `length=`, which need to be implemented.
+ */
+typedef ListBase<E> = Object with ListMixin<E>;
+
+/**
+ * Base implementation of a [List] class.
+ *
+ * This class can be used as a mixin.
+ *
+ * This implements all read operations using only the `length` and
+ * `operator[]` members. It implements write operations using those and
+ * `length=` and `operator[]=`
+ *
+ * A fixed-length list should mix this class in, and the [FixedLengthListMixin]
+ * as well, in that order, to overwrite the methods that modify the length.
+ *
+ * An unmodifiable list should mix [UnmodifiableListMixin] on top of this
+ * mixin to prevent all modifications.
+ */
+abstract class ListMixin<E> implements List<E> {
+ // Iterable interface.
+ Iterator<E> get iterator => new ListIterator<E>(this);
+
+ E elementAt(int index) => this[index];
+
+ void forEach(void action(E element)) {
+ int length = this.length;
+ for (int i = 0; i < length; i++) {
+ action(this[i]);
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ }
+
+ bool get isEmpty => length == 0;
+
+ E get first {
+ if (length == 0) throw new StateError("No elements");
+ return this[0];
+ }
+
+ E get last {
+ if (length == 0) throw new StateError("No elements");
+ return this[length - 1];
+ }
+
+ E get single {
+ if (length == 0) throw new StateError("No elements");
+ if (length > 1) throw new StateError("Too many elements");
+ return this[0];
+ }
+
+ bool contains(E element) {
+ int length = this.length;
+ for (int i = 0; i < length; i++) {
+ if (this[i] == element) return true;
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ return false;
+ }
+
+ bool every(bool test(E element)) {
+ int length = this.length;
+ for (int i = 0; i < length; i++) {
+ if (!test(this[i])) return false;
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ return true;
+ }
+
+ bool any(bool test(E element)) {
+ int length = this.length;
+ for (int i = 0; i < length; i++) {
+ if (test(this[i])) return true;
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ return false;
+ }
+
+ E firstWhere(bool test(E element), { E orElse() }) {
+ int length = this.length;
+ for (int i = 0; i < length; i++) {
+ E element = this[i];
+ if (test(element)) return element;
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ if (orElse != null) return orElse();
+ throw new StateError("No matching element");
+ }
+
+ E lastWhere(bool test(E element), { E orElse() }) {
+ int length = this.length;
+ for (int i = length - 1; i >= 0; i--) {
+ E element = this[i];
+ if (test(element)) return element;
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ if (orElse != null) return orElse();
+ throw new StateError("No matching element");
+ }
+
+ E singleWhere(bool test(E element)) {
+ int length = this.length;
+ E match = null;
+ bool matchFound = false;
+ for (int i = 0; i < length; i++) {
+ E element = this[i];
+ if (test(element)) {
+ if (matchFound) {
+ throw new StateError("More than one matching element");
+ }
+ matchFound = true;
+ match = element;
+ }
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ if (matchFound) return match;
+ throw new StateError("No matching element");
+ }
+
+ String join([String separator = ""]) {
+ int length = this.length;
+ if (!separator.isEmpty) {
+ if (length == 0) return "";
+ String first = "${this[0]}";
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ StringBuffer buffer = new StringBuffer(first);
+ for (int i = 1; i < length; i++) {
+ buffer.write(separator);
+ buffer.write(this[i]);
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ return buffer.toString();
+ } else {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ buffer.write(this[i]);
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
+ Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
+
+ Iterable map(f(E element)) => new MappedListIterable(this, f);
+
+ E reduce(E combine(E previousValue, E element)) {
+ if (length == 0) throw new StateError("No elements");
+ E value = this[0];
+ for (int i = 1; i < length; i++) {
+ value = combine(value, this[i]);
+ }
+ return value;
+ }
+
+ fold(var initialValue, combine(var previousValue, E element)) {
+ var value = initialValue;
+ int length = this.length;
+ for (int i = 0; i < length; i++) {
+ value = combine(value, this[i]);
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+ }
+ return value;
+ }
+
+ Iterable<E> skip(int count) => new SubListIterable(this, count, null);
+
+ Iterable<E> skipWhile(bool test(E element)) {
+ return new SkipWhileIterable<E>(this, test);
+ }
+
+ Iterable<E> take(int count) => new SubListIterable(this, 0, count);
+
+ Iterable<E> takeWhile(bool test(E element)) {
+ return new TakeWhileIterable<E>(this, test);
+ }
+
+ List<E> toList({ bool growable: true }) {
+ List<E> result;
+ if (growable) {
+ result = new List<E>()..length = length;
+ } else {
+ result = new List<E>(length);
+ }
+ for (int i = 0; i < length; i++) {
+ result[i] = this[i];
+ }
+ return result;
+ }
+
+ Set<E> toSet() {
+ Set<E> result = new Set<E>();
+ for (int i = 0; i < length; i++) {
+ result.add(this[i]);
+ }
+ return result;
+ }
+
+ // Collection interface.
+ void add(E element) {
+ this[this.length++] = element;
+ }
+
+ void addAll(Iterable<E> iterable) {
+ for (E element in iterable) {
+ this[this.length++] = element;
+ }
+ }
+
+ void remove(Object element) {
+ for (int i = 0; i < this.length; i++) {
+ if (this[i] == element) {
+ this.setRange(i, this.length - i - 1, this, i + 1);
+ this.length -= 1;
+ return;
+ }
+ }
+ }
+
+ void removeWhere(bool test(E element)) {
+ _filter(this, test, false);
+ }
+
+ void retainWhere(bool test(E element)) {
+ _filter(this, test, true);
+ }
+
+ static void _filter(List source,
+ bool test(var element),
+ bool retainMatching) {
+ List retained = [];
+ int length = source.length;
+ for (int i = 0; i < length; i++) {
+ var element = source[i];
+ if (test(element) == retainMatching) {
+ retained.add(element);
+ }
+ if (length != source.length) {
+ throw new ConcurrentModificationError(source);
+ }
+ }
+ if (retained.length != source.length) {
+ source.setRange(0, retained.length, retained);
+ source.length = retained.length;
+ }
+ }
+
+ void clear() { this.length = 0; }
+
+ // List interface.
+
+ E removeLast() {
+ if (length == 0) {
+ throw new StateError("No elements");
+ }
+ E result = this[length - 1];
+ length--;
+ return result;
+ }
+
+ void sort([Comparator<E> compare]) {
+ Sort.sort(this, compare);
+ }
+
+ Map<int, E> asMap() {
+ return new ListMapView(this);
+ }
+
+ List<E> sublist(int start, [int end]) {
+ if (end == null) end = length;
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
+ }
+ if (end < start || end > this.length) {
+ throw new RangeError.range(end, start, this.length);
+ }
+ int length = end - start;
+ List<E> result = new List<E>()..length = length;
+ for (int i = 0; i < length; i++) {
+ result[i] = this[start + i];
+ }
+ return result;
+ }
+
+ Iterable<E> getRange(int start, int end) {
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
+ }
+ if (end < start || end > this.length) {
+ throw new RangeError.range(end, start, this.length);
+ }
+ return new SubListIterable(this, start, end);
+ }
+
+ void insertRange(int start, int length, [E initialValue]) {
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
+ }
+ int oldLength = this.length;
+ int moveLength = oldLength - start;
+ this.length += length;
+ if (moveLength > 0) {
+ this.setRange(start + length, moveLength, this, start);
+ }
+ for (int i = 0; i < length; i++) {
+ this[start + i] = initialValue;
+ }
+ }
+
+ void removeRange(int start, int length) {
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
+ }
+ if (length < 0 || start + length > this.length) {
+ throw new RangeError.range(length, 0, this.length - start);
+ }
+ int end = start + length;
+ setRange(start, this.length - end, this, end);
+ this.length -= length;
+ }
+
+ void clearRange(int start, int length, [E fill]) {
+ for (int i = 0; i < length; i++) {
+ this[start + i] = fill;
+ }
+ }
+
+ void setRange(int start, int length, List<E> from, [int startFrom]) {
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
+ }
+ if (length < 0 || start + length > this.length) {
+ throw new RangeError.range(length, 0, this.length - start);
+ }
+ if (startFrom == null) {
+ startFrom = 0;
+ }
+ if (startFrom < 0 || startFrom + length > from.length) {
+ throw new RangeError.range(startFrom, 0, from.length - length);
+ }
+ if (startFrom < start) {
+ // Copy backwards to ensure correct copy if [from] is this.
+ for (int i = length - 1; i >= 0; i--) {
+ this[start + i] = from[startFrom + i];
+ }
+ } else {
+ for (int i = 0; i < length; i++) {
+ this[start + i] = from[startFrom + i];
+ }
+ }
+ }
+
+ int indexOf(E element, [int startIndex = 0]) {
+ if (startIndex >= this.length) {
+ return -1;
+ }
+ if (startIndex < 0) {
+ startIndex = 0;
+ }
+ for (int i = startIndex; i < this.length; i++) {
+ if (this[i] == element) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the last index in the list [a] of the given [element], starting
+ * the search at index [startIndex] to 0.
+ * Returns -1 if [element] is not found.
+ */
+ int lastIndexOf(E element, [int startIndex]) {
+ if (startIndex == null) {
+ startIndex = this.length - 1;
+ } else {
+ if (startIndex < 0) {
+ return -1;
+ }
+ if (startIndex >= this.length) {
+ startIndex = this.length - 1;
+ }
+ }
+ for (int i = startIndex; i >= 0; i--) {
+ if (this[i] == element) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ Iterable<E> get reversed => new ReversedListIterable(this);
+}
diff --git a/sdk/lib/collection/queue.dart b/sdk/lib/collection/queue.dart
index c6cca9f..85947d0 100644
--- a/sdk/lib/collection/queue.dart
+++ b/sdk/lib/collection/queue.dart
@@ -9,7 +9,7 @@
* can iterate over the elements of a queue through [forEach] or with
* an [Iterator].
*/
-abstract class Queue<E> implements Collection<E> {
+abstract class Queue<E> implements Iterable<E> {
/**
* Creates a queue.
@@ -160,7 +160,7 @@
*
* Can do [removeAll] and [retainAll] in linear time.
*/
-class DoubleLinkedQueue<E> extends Collection<E> implements Queue<E> {
+class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
_DoubleLinkedQueueEntrySentinel<E> _sentinel;
int _elementCount = 0;
@@ -224,33 +224,42 @@
}
}
+ void retainAll(Iterable elements) {
+ _filterIterable(elements, true);
+ }
+
void removeAll(Iterable elements) {
- // Use this method when remove is slow and removeWhere more efficient.
- IterableMixinWorkaround.removeAllList(this, elements);
+ _filterIterable(elements, false);
+ }
+
+ void _filterIterable(Iterable elements, bool retainMatching) {
+ Set elementSet;
+ if (elements is Set) {
+ elementSet = elements;
+ } else {
+ elementSet = elements.toSet();
+ }
+ _filter(elementSet.contains, retainMatching);
+ }
+
+ void _filter(bool test(E element), bool retainMatching) {
+ DoubleLinkedQueueEntry<E> entry = firstEntry();
+ while (!identical(entry, _sentinel)) {
+ DoubleLinkedQueueEntry<E> next = entry._next;
+ if (test(entry.element) != retainMatching) {
+ entry.remove();
+ _elementCount--;
+ }
+ entry = next;
+ }
}
void removeWhere(bool test(E element)) {
- DoubleLinkedQueueEntry<E> entry = firstEntry();
- while (!identical(entry, _sentinel)) {
- DoubleLinkedQueueEntry<E> next = entry._next;
- if (test(entry.element)) {
- entry.remove();
- _elementCount--;
- }
- entry = next;
- }
+ _filter(test, false);
}
void retainWhere(bool test(E element)) {
- DoubleLinkedQueueEntry<E> entry = firstEntry();
- while (!identical(entry, _sentinel)) {
- DoubleLinkedQueueEntry<E> next = entry._next;
- if (!test(entry.element)) {
- entry.remove();
- _elementCount--;
- }
- entry = next;
- }
+ _filter(test, true);
}
E get first {
@@ -301,7 +310,7 @@
}
String toString() {
- return Collections.collectionToString(this);
+ return ToString.iterableToString(this);
}
}
@@ -342,10 +351,10 @@
*
* The structure is efficient for any queue or stack usage.
*
- * Collection operations like [removeAll] and [removeWhere] are very
+ * Operations like [removeAll] and [removeWhere] are very
* inefficient. If those are needed, use a [DoubleLinkedQueue] instead.
*/
-class ListQueue<E> extends Collection<E> implements Queue<E>{
+class ListQueue<E> extends Iterable<E> implements Queue<E>{
static const int _INITIAL_CAPACITY = 8;
List<E> _table;
int _head;
@@ -481,14 +490,6 @@
_modificationCount++;
}
- void removeAll(Iterable objectsToRemove) {
- IterableMixinWorkaround.removeAllList(this, objectsToRemove);
- }
-
- void retainAll(Iterable objectsToRetain) {
- IterableMixinWorkaround.retainAll(this, objectsToRetain);
- }
-
void _filterWhere(bool test(E element), bool removeMatching) {
int index = _head;
int modificationCount = _modificationCount;
@@ -537,7 +538,7 @@
}
String toString() {
- return Collections.collectionToString(this);
+ return ToString.iterableToString(this);
}
// Queue interface.
diff --git a/sdk/lib/collection/splay_tree.dart b/sdk/lib/collection/splay_tree.dart
index 5a5db4d..3b83641 100644
--- a/sdk/lib/collection/splay_tree.dart
+++ b/sdk/lib/collection/splay_tree.dart
@@ -86,10 +86,10 @@
_SplayTreeNode<K> current = _root;
int comp;
while (true) {
- comp = current.key.compareTo(key);
+ comp = _compare(current.key, key);
if (comp > 0) {
if (current.left == null) break;
- comp = current.left.key.compareTo(key);
+ comp = _compare(current.left.key, key);
if (comp > 0) {
// Rotate right.
_SplayTreeNode<K> tmp = current.left;
@@ -104,7 +104,7 @@
current = current.left;
} else if (comp < 0) {
if (current.right == null) break;
- comp = current.right.key.compareTo(key);
+ comp = _compare(current.right.key, key);
if (comp < 0) {
// Rotate left.
_SplayTreeNode<K> tmp = current.right;
@@ -256,15 +256,18 @@
if (key == null) throw new ArgumentError(key);
if (_root != null) {
int comp = _splay(key);
- if (comp == 0) return _root.value;
+ if (comp == 0) {
+ _SplayTreeMapNode mapRoot = _root;
+ return mapRoot.value;
+ }
}
return null;
}
V remove(Object key) {
if (key is! K) return null;
- _SplayTreeMapNode root = _remove(key);
- if (root != null) return root.value;
+ _SplayTreeMapNode mapRoot = _remove(key);
+ if (mapRoot != null) return mapRoot.value;
return null;
}
@@ -274,7 +277,8 @@
// the key to the root of the tree.
int comp = _splay(key);
if (comp == 0) {
- _root.value = value;
+ _SplayTreeMapNode mapRoot = _root;
+ mapRoot.value = value;
return;
}
_addNewRoot(new _SplayTreeMapNode(key, value), comp);
@@ -284,7 +288,10 @@
V putIfAbsent(K key, V ifAbsent()) {
if (key == null) throw new ArgumentError(key);
int comp = _splay(key);
- if (comp == 0) return _root.value;
+ if (comp == 0) {
+ _SplayTreeMapNode mapRoot = _root;
+ return mapRoot.value;
+ }
int modificationCount = _modificationCount;
int splayCount = _splayCount;
V value = ifAbsent();
@@ -330,7 +337,7 @@
bool containsValue(V value) {
bool found = false;
int initialSplayCount = _splayCount;
- bool visit(_SplayTreeNode node) {
+ bool visit(_SplayTreeMapNode node) {
while (node != null) {
if (node.value == value) return true;
if (initialSplayCount != _splayCount) {
diff --git a/sdk/lib/core/collection.dart b/sdk/lib/core/collection.dart
deleted file mode 100644
index 6a725a1..0000000
--- a/sdk/lib/core/collection.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of dart.core;
-
-/**
- * A collection of individual elements.
- *
- * A [Collection] contains some elements in a structure optimized
- * for certain operations. Different collections are optimized for different
- * uses.
- *
- * A collection can be updated by adding or removing elements.
- *
- * Collections are [Iterable]. The order of iteration is defined by
- * each type of collection.
- *
- * *Deprecated*: This class is deprecated and will be removed soon.
- */
-abstract class Collection<E> extends Iterable<E> {
- const Collection();
-
- /**
- * Adds an element to this collection.
- */
- void add(E element);
-
- /**
- * Adds all of [elements] to this collection.
- *
- * Equivalent to adding each element in [elements] using [add],
- * but some collections may be able to optimize it.
- */
- void addAll(Iterable<E> elements) {
- for (E element in elements) {
- add(element);
- }
- }
-
- /**
- * Removes an instance of [element] from this collection.
- *
- * This removes only one instance of the element for collections that can
- * contain the same element more than once (e.g., [List]). Which instance
- * is removed is decided by the collection.
- *
- * Has no effect if the elements is not in this collection.
- */
- void remove(Object element);
-
- /**
- * Removes all of [elements] from this collection.
- *
- * Equivalent to calling [remove] once for each element in
- * [elements], but may be faster for some collections.
- */
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- /**
- * Removes all elements of this collection that are not
- * in [elements].
- *
- * For [Set]s, this is the intersection of the two original sets.
- */
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
- /**
- * Removes all elements of this collection that satisfy [test].
- *
- * An elements [:e:] satisfies [test] if [:test(e):] is true.
- */
- void removeWhere(bool test(E element)) {
- IterableMixinWorkaround.removeWhere(this, test);
- }
-
- /**
- * Removes all elements of this collection that fail to satisfy [test].
- *
- * An elements [:e:] satisfies [test] if [:test(e):] is true.
- */
- void retainWhere(bool test(E element)) {
- IterableMixinWorkaround.retainWhere(this, test);
- }
-
- /**
- * Removes all elements of this collection.
- */
- void clear() {
- IterableMixinWorkaround.removeWhere(this, (E e) => true);
- }
-}
diff --git a/sdk/lib/core/core.dart b/sdk/lib/core/core.dart
index dd6ee8f..df5da14 100644
--- a/sdk/lib/core/core.dart
+++ b/sdk/lib/core/core.dart
@@ -8,7 +8,6 @@
import "dart:_collection-dev";
part "bool.dart";
-part "collection.dart";
part "comparable.dart";
part "date_time.dart";
part "double.dart";
@@ -16,7 +15,6 @@
part "errors.dart";
part "exceptions.dart";
part "expando.dart";
-part "expect.dart";
part "function.dart";
part "identical.dart";
part "int.dart";
@@ -36,4 +34,5 @@
part "string.dart";
part "string_buffer.dart";
part "string_sink.dart";
+part "symbol.dart";
part "type.dart";
diff --git a/sdk/lib/core/corelib_sources.gypi b/sdk/lib/core/corelib_sources.gypi
index 290b507..10ae786 100644
--- a/sdk/lib/core/corelib_sources.gypi
+++ b/sdk/lib/core/corelib_sources.gypi
@@ -7,23 +7,21 @@
'core.dart',
# The above file needs to be first as it lists the parts below.
'bool.dart',
- 'collection.dart',
'comparable.dart',
'date_time.dart',
'double.dart',
'duration.dart',
- 'exceptions.dart',
'errors.dart',
+ 'exceptions.dart',
'expando.dart',
- 'expect.dart',
'function.dart',
'identical.dart',
'int.dart',
'invocation_mirror.dart',
'iterable.dart',
'iterator.dart',
- 'map.dart',
'list.dart',
+ 'map.dart',
'num.dart',
'object.dart',
'pattern.dart',
@@ -35,6 +33,7 @@
'string.dart',
'string_buffer.dart',
'string_sink.dart',
+ 'symbol.dart',
'type.dart',
],
}
diff --git a/sdk/lib/core/date_time.dart b/sdk/lib/core/date_time.dart
index 5b26fc8..9902b82 100644
--- a/sdk/lib/core/date_time.dart
+++ b/sdk/lib/core/date_time.dart
@@ -15,28 +15,28 @@
*/
class DateTime {
// Weekday constants that are returned by [weekday] method:
- static const int MON = 1;
- static const int TUE = 2;
- static const int WED = 3;
- static const int THU = 4;
- static const int FRI = 5;
- static const int SAT = 6;
- static const int SUN = 7;
+ static const int MONDAY = 1;
+ static const int TUESDAY = 2;
+ static const int WEDNESDAY = 3;
+ static const int THURSDAY = 4;
+ static const int FRIDAY = 5;
+ static const int SATURDAY = 6;
+ static const int SUNDAY = 7;
static const int DAYS_IN_WEEK = 7;
// Month constants that are returned by the [month] getter.
- static const int JAN = 1;
- static const int FEB = 2;
- static const int MAR = 3;
- static const int APR = 4;
+ static const int JANUARY = 1;
+ static const int FEBRUARY = 2;
+ static const int MARCH = 3;
+ static const int APRIL = 4;
static const int MAY = 5;
- static const int JUN = 6;
- static const int JUL = 7;
- static const int AUG = 8;
- static const int SEP = 9;
- static const int OCT = 10;
- static const int NOV = 11;
- static const int DEC = 12;
+ static const int JUNE = 6;
+ static const int JULY = 7;
+ static const int AUGUST = 8;
+ static const int SEPTEMBER = 9;
+ static const int OCTOBER = 10;
+ static const int NOVEMBER = 11;
+ static const int DECEMBER = 12;
/**
* The milliseconds since 1970-01-01T00:00:00Z (UTC). This value is
@@ -191,48 +191,6 @@
/**
* Returns true if [this] occurs before [other]. The comparison is independent
* of whether the time is in UTC or in the local time zone.
- *
- * *Deprecated* Use [isBefore] instead.
- */
- @deprecated
- bool operator <(DateTime other)
- => millisecondsSinceEpoch < other.millisecondsSinceEpoch;
-
- /**
- * Returns true if [this] occurs at the same time or before [other]. The
- * comparison is independent of whether the time is in UTC or in the local
- * time zone.
- *
- * *Deprecated* Use [isAfter] instead ([:!isAfter:]).
- */
- @deprecated
- bool operator <=(DateTime other)
- => millisecondsSinceEpoch <= other.millisecondsSinceEpoch;
-
- /**
- * Returns true if [this] occurs after [other]. The comparison is independent
- * of whether the time is in UTC or in the local time zone.
- *
- * *Deprecated* Use [isAfter] instead.
- */
- @deprecated
- bool operator >(DateTime other)
- => millisecondsSinceEpoch > other.millisecondsSinceEpoch;
-
- /**
- * Returns true if [this] occurs at the same time or after [other]. The
- * comparison is independent of whether the time is in UTC or in the local
- * time zone.
- *
- * *Deprecated* Use [isBefore] instead ([:!isBefore:]).
- */
- @deprecated
- bool operator >=(DateTime other)
- => millisecondsSinceEpoch >= other.millisecondsSinceEpoch;
-
- /**
- * Returns true if [this] occurs before [other]. The comparison is independent
- * of whether the time is in UTC or in the local time zone.
*/
bool isBefore(DateTime other) {
return millisecondsSinceEpoch < other.millisecondsSinceEpoch;
diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart
index 0fda6f1..d1583dc 100644
--- a/sdk/lib/core/iterable.dart
+++ b/sdk/lib/core/iterable.dart
@@ -93,22 +93,24 @@
}
/**
- * Reduce a collection to a single value by iteratively combining each element
- * of the collection with an existing value using the provided function.
- * Use [initialValue] as the initial value, and the function [combine] to
- * create a new value from the previous one and an element.
+ * Reduce a collection to a single value by iteratively combining elements
+ * of the collection using the provided function.
*
* Example of calculating the sum of an iterable:
*
- * iterable.reduce((prev, element) => prev + element);
+ * iterable.reduce((value, element) => value + element);
*
- * *UPCOMING API-CHANGE*: this method will soon be changed to not take
- * an initial value: `iterable.reduce(min)`. Use [fold] instead.
*/
- @deprecated
- dynamic reduce(var initialValue,
- dynamic combine(var previousValue, E element)) {
- return fold(initialValue, combine);
+ E reduce(E combine(E value, E element)) {
+ Iterator<E> iterator = this.iterator;
+ if (!iterator.moveNext()) {
+ throw new StateError("No elements");
+ }
+ E value = iterator.current;
+ while (iterator.moveNext()) {
+ value = combine(value, iterator.current);
+ }
+ return value;
}
/**
@@ -119,7 +121,8 @@
*
* Example of calculating the sum of an iterable:
*
- * iterable.fold(0, (prev, element) => prev + element);
+ * iterable.fold(0, (prev, element) => prev + element);
+ *
*/
dynamic fold(var initialValue,
dynamic combine(var previousValue, E element)) {
@@ -146,9 +149,9 @@
* Then concatenates the strings, optionally separated by the [separator]
* string.
*/
- String join([String separator]) {
+ String join([String separator = ""]) {
StringBuffer buffer = new StringBuffer();
- buffer.writeAll(this, separator == null ? "" : separator);
+ buffer.writeAll(this, separator);
return buffer.toString();
}
@@ -183,58 +186,6 @@
}
/**
- * Find the least element in the iterable.
- *
- * Returns null if the iterable is empty.
- * Otherwise returns an element [:x:] of this [Iterable] so that
- * [:x:] is not greater than [:y:] (that is, [:compare(x, y) <= 0:]) for all
- * other elements [:y:] in the iterable.
- *
- * The [compare] function must be a proper [Comparator<T>]. If a function is
- * not provided, [compare] defaults to [Comparable.compare].
- *
- * *Deprecated*. Use [reduce] with a binary min method if needed.
- */
- @deprecated
- E min([int compare(E a, E b)]) {
- if (compare == null) compare = Comparable.compare;
- Iterator it = iterator;
- if (!it.moveNext()) return null;
- E min = it.current;
- while (it.moveNext()) {
- E current = it.current;
- if (compare(min, current) > 0) min = current;
- }
- return min;
- }
-
- /**
- * Find the largest element in the iterable.
- *
- * Returns null if the iterable is empty.
- * Otherwise returns an element [:x:] of this [Iterable] so that
- * [:x:] is not smaller than [:y:] (that is, [:compare(x, y) >= 0:]) for all
- * other elements [:y:] in the iterable.
- *
- * The [compare] function must be a proper [Comparator<T>]. If a function is
- * not provided, [compare] defaults to [Comparable.compare].
- *
- * *Deprecated*. Use [reduce] with a binary max method if needed.
- */
- @deprecated
- E max([int compare(E a, E b)]) {
- if (compare == null) compare = Comparable.compare;
- Iterator it = iterator;
- if (!it.moveNext()) return null;
- E max = it.current;
- while (it.moveNext()) {
- E current = it.current;
- if (compare(max, current) < 0) max = current;
- }
- return max;
- }
-
- /**
* Returns true if there is no element in this collection.
*/
bool get isEmpty => !iterator.moveNext();
diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
index f144782..27a857e 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -34,7 +34,7 @@
* unmodifiableList.add(499); // throws
* unmodifiableList[0] = 87; // throws.
*/
-abstract class List<E> implements Collection<E> {
+abstract class List<E> implements Iterable<E> {
/**
* Creates a list of the given [length].
*
@@ -50,18 +50,6 @@
external factory List.filled(int length, E fill);
/**
- * *Deprecated*: Use `new List(count)` instead.
- */
- @deprecated
- factory List.fixedLength(int count, { E fill }) {
- List<E> result = new List(count);
- if (fill != null) {
- for (int i = 0; i < count; i++) result[i] = fill;
- }
- return result;
- }
-
- /**
* Creates an list with the elements of [other]. The order in
* the list will be the order provided by the iterator of [other].
*
@@ -118,6 +106,13 @@
void operator []=(int index, E value);
/**
+ * Returns the number of elements in the list.
+ *
+ * The valid indices for a list are 0 through `length - 1`.
+ */
+ int get length;
+
+ /**
* Changes the length of the list. If [newLength] is greater than
* the current [length], entries are initialized to [:null:]. Throws
* an [UnsupportedError] if the list is not extendable.
@@ -194,6 +189,13 @@
void insert(int index, E element);
/**
+ * Removes [value] from the list. Returns true if [value] was
+ * in the list. Returns false otherwise. The method has no effect
+ * if [value] value was not in the list.
+ */
+ bool remove(Object value);
+
+ /**
* Removes the element at position [index] from the list.
*
* This reduces the length of the list by one and moves all later elements
@@ -215,7 +217,21 @@
E removeLast();
/**
- * Returns a new list containing the elemenst from [start] to [end].
+ * Removes all elements of this list that satisfy [test].
+ *
+ * An elements [:e:] satisfies [test] if [:test(e):] is true.
+ */
+ void removeWhere(bool test(E element));
+
+ /**
+ * Removes all elements of this list that fail to satisfy [test].
+ *
+ * An elements [:e:] satisfies [test] if [:test(e):] is true.
+ */
+ void retainWhere(bool test(E element));
+
+ /**
+ * Returns a new list containing the elements from [start] to [end].
*
* If [end] is omitted, the [length] of the list is used.
*
@@ -225,10 +241,26 @@
List<E> sublist(int start, [int end]);
/**
- * *Deprecated*. Use [sublist] instead.
+ * Returns an [Iterable] that iterators over the elements in the range
+ * [start] to [end] (exclusive). The result of this function is backed by
+ * `this`.
+ *
+ * It is an error if [end] is before [start].
+ *
+ * It is an error if the [start] and [end] are not valid ranges at the time
+ * of the call to this method. The returned [Iterable] behaves similar to
+ * `skip(start).take(end - start)`. That is, it will not throw exceptions
+ * if `this` changes size.
+ *
+ * Example:
+ *
+ * var list = [1, 2, 3, 4, 5];
+ * var range = list.getRange(1, 4);
+ * print(range.join(', ')); // => 2, 3, 4
+ * list.length = 3;
+ * print(range.join(', ')); // => 2, 3
*/
- @deprecated
- List<E> getRange(int start, int length);
+ Iterable<E> getRange(int start, int end);
/**
* Copies [length] elements of [from], starting
diff --git a/sdk/lib/core/set.dart b/sdk/lib/core/set.dart
index 8856d41..1a8fd15 100644
--- a/sdk/lib/core/set.dart
+++ b/sdk/lib/core/set.dart
@@ -8,7 +8,7 @@
* This class is the public interface of a set. A set is a collection
* without duplicates.
*/
-abstract class Set<E> extends Collection<E> {
+abstract class Set<E> extends Iterable<E> {
factory Set() => new HashSet<E>();
/**
@@ -28,6 +28,14 @@
void add(E value);
/**
+ * Adds all of [elements] to this Set.
+ *
+ * Equivalent to adding each element in [elements] using [add],
+ * but some collections may be able to optimize it.
+ */
+ void addAll(Iterable<E> elements);
+
+ /**
* Removes [value] from the set. Returns true if [value] was
* in the set. Returns false otherwise. The method has no effect
* if [value] value was not in the set.
@@ -35,13 +43,25 @@
bool remove(Object value);
/**
- * Returns true if [other] contains all the elements of this Set.
- *
- * *Deprecated*. Use `other.containsAll(thisSet)` instead if [other]
- * is a Set, and convert `other` to a Set if it isn't.
+ * Removes all of [elements] from this set.
*/
- @deprecated
- bool isSubsetOf(Iterable<E> other);
+ void removeAll(Iterable elements);
+
+ /**
+ * Removes all elements of this set that are not
+ * in [elements].
+ */
+ void retainAll(Iterable elements);
+
+ /**
+ * Removes all elements of this set that satisfy [test].
+ */
+ void removeWhere(bool test(E element));
+
+ /**
+ * Removes all elements of this set that fail to satisfy [test].
+ */
+ void retainWhere(bool test(E element));
/**
* Returns true if this Set contains all the elements of [other].
diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart
index 34aafd1..36a2e60 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -139,12 +139,6 @@
String operator +(String other);
/**
- * *Deprecated* Use [operator+] instead.
- */
- @deprecated
- String concat(String other);
-
- /**
* Returns a slice of this string from [startIndex] to [endIndex].
*
* If [startIndex] is omitted, it defaults to the start of the string.
diff --git a/sdk/lib/core/string_buffer.dart b/sdk/lib/core/string_buffer.dart
index 6ecdc57..8ea4bf1 100644
--- a/sdk/lib/core/string_buffer.dart
+++ b/sdk/lib/core/string_buffer.dart
@@ -32,7 +32,7 @@
void writeAll(Iterable objects, [String separator = ""]) {
Iterator iterator = objects.iterator;
if (!iterator.moveNext()) return;
- if (separator == "") {
+ if (separator.isEmpty) {
do {
write(iterator.current);
} while (iterator.moveNext());
diff --git a/sdk/lib/core/symbol.dart b/sdk/lib/core/symbol.dart
new file mode 100644
index 0000000..e2b686c
--- /dev/null
+++ b/sdk/lib/core/symbol.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.core;
+
+/// Opaque name used by mirrors, invocations and [Function.apply].
+class Symbol {
+
+ /**
+ * Constructs a new Symbol.
+ *
+ * An [ArgumentError] is thrown if [name] starts with an underscore,
+ * or if [name] is not a [String]. An [ArgumentError] is thrown if
+ * [name] is not an empty string and is not a valid identifier
+ * optionally followed by [:'=':].
+ */
+ external const Symbol(String name);
+
+ external bool operator ==(other);
+
+ external int get hashCode;
+}
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index f46a08f..abb637f 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -38,7 +38,7 @@
/**
* The top-level Document object.
*/
-HtmlDocument get document => JS('Document', 'document');
+HtmlDocument get document => JS('HtmlDocument', 'document');
Element query(String selector) => document.query(selector);
List<Element> queryAll(String selector) => document.queryAll(selector);
@@ -684,10 +684,6 @@
@DomName('HTMLBodyElement')
class BodyElement extends Element native "*HTMLBodyElement" {
- @DomName('HTMLBodyElement.beforeunloadEvent')
- @DocsEditable
- static const EventStreamProvider<Event> beforeUnloadEvent = const EventStreamProvider<Event>('beforeunload');
-
@DomName('HTMLBodyElement.blurEvent')
@DocsEditable
static const EventStreamProvider<Event> blurEvent = const EventStreamProvider<Event>('blur');
@@ -740,10 +736,6 @@
@DocsEditable
factory BodyElement() => document.$dom_createElement("body");
- @DomName('HTMLBodyElement.onbeforeunload')
- @DocsEditable
- Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
-
@DomName('HTMLBodyElement.onblur')
@DocsEditable
Stream<Event> get onBlur => blurEvent.forTarget(this);
@@ -949,7 +941,7 @@
* Example usage:
*
* CanvasElement canvas = new CanvasElement();
- * var ctx = canvas.context2d
+ * var ctx = canvas.context2D
* ..fillStyle = "rgb(200,0,0)"
* ..fillRect(10, 10, 55, 50);
* var dataUrl = canvas.toDataURL("image/jpeg", 0.95);
@@ -974,7 +966,12 @@
@DocsEditable
String toDataUrl(String type, [num quality]) native;
- CanvasRenderingContext2D get context2d => getContext('2d');
+ /** An API for drawing on this canvas. */
+ CanvasRenderingContext2D get context2D =>
+ JS('Null|CanvasRenderingContext2D', '#.getContext(#)', this, '2d');
+
+ @deprecated
+ CanvasRenderingContext2D get context2d => this.context2D;
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@@ -1012,7 +1009,7 @@
* Example usage:
*
* var canvas = new CanvasElement(width: 600, height: 600);
- * var ctx = canvas.context2d;
+ * var ctx = canvas.context2D;
* ctx.clearRect(0, 0, 600, 600);
* ctx.save();
* // Create radial gradient.
@@ -1062,7 +1059,7 @@
* Example usage:
*
* var canvas = new CanvasElement(width: 600, height: 600);
- * var ctx = canvas.context2d;
+ * var ctx = canvas.context2D;
* var img = new ImageElement();
* // Image src needs to be loaded before pattern is applied.
* img.onLoad.listen((event) {
@@ -1485,7 +1482,7 @@
* will allow, the image will be clipped to fit the available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
* img.width = 100;
* img.height = 100;
@@ -1543,7 +1540,7 @@
* available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
*
* ctx.drawImage(img, 100, 100);
@@ -1578,7 +1575,7 @@
* will allow, the image will be clipped to fit the available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
* img.width = 100;
* img.height = 100;
@@ -1920,27 +1917,6 @@
@DocsEditable
-@DomName('Counter')
-class Counter native "*Counter" {
-
- @DomName('Counter.identifier')
- @DocsEditable
- final String identifier;
-
- @DomName('Counter.listStyle')
- @DocsEditable
- final String listStyle;
-
- @DomName('Counter.separator')
- @DocsEditable
- final String separator;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('Crypto')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@@ -2082,160 +2058,6 @@
@DocsEditable
-@DomName('WebKitCSSMatrix')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@SupportedBrowser(SupportedBrowser.SAFARI)
-@Experimental
-class CssMatrix native "*WebKitCSSMatrix" {
-
- @DomName('WebKitCSSMatrix.WebKitCSSMatrix')
- @DocsEditable
- factory CssMatrix([String cssValue]) {
- if (?cssValue) {
- return CssMatrix._create_1(cssValue);
- }
- return CssMatrix._create_2();
- }
- static CssMatrix _create_1(cssValue) => JS('CssMatrix', 'new WebKitCSSMatrix(#)', cssValue);
- static CssMatrix _create_2() => JS('CssMatrix', 'new WebKitCSSMatrix()');
-
- /// Checks if this type is supported on the current platform.
- static bool get supported => JS('bool', '!!(window.WebKitCSSMatrix)');
-
- @DomName('WebKitCSSMatrix.a')
- @DocsEditable
- num a;
-
- @DomName('WebKitCSSMatrix.b')
- @DocsEditable
- num b;
-
- @DomName('WebKitCSSMatrix.c')
- @DocsEditable
- num c;
-
- @DomName('WebKitCSSMatrix.d')
- @DocsEditable
- num d;
-
- @DomName('WebKitCSSMatrix.e')
- @DocsEditable
- num e;
-
- @DomName('WebKitCSSMatrix.f')
- @DocsEditable
- num f;
-
- @DomName('WebKitCSSMatrix.m11')
- @DocsEditable
- num m11;
-
- @DomName('WebKitCSSMatrix.m12')
- @DocsEditable
- num m12;
-
- @DomName('WebKitCSSMatrix.m13')
- @DocsEditable
- num m13;
-
- @DomName('WebKitCSSMatrix.m14')
- @DocsEditable
- num m14;
-
- @DomName('WebKitCSSMatrix.m21')
- @DocsEditable
- num m21;
-
- @DomName('WebKitCSSMatrix.m22')
- @DocsEditable
- num m22;
-
- @DomName('WebKitCSSMatrix.m23')
- @DocsEditable
- num m23;
-
- @DomName('WebKitCSSMatrix.m24')
- @DocsEditable
- num m24;
-
- @DomName('WebKitCSSMatrix.m31')
- @DocsEditable
- num m31;
-
- @DomName('WebKitCSSMatrix.m32')
- @DocsEditable
- num m32;
-
- @DomName('WebKitCSSMatrix.m33')
- @DocsEditable
- num m33;
-
- @DomName('WebKitCSSMatrix.m34')
- @DocsEditable
- num m34;
-
- @DomName('WebKitCSSMatrix.m41')
- @DocsEditable
- num m41;
-
- @DomName('WebKitCSSMatrix.m42')
- @DocsEditable
- num m42;
-
- @DomName('WebKitCSSMatrix.m43')
- @DocsEditable
- num m43;
-
- @DomName('WebKitCSSMatrix.m44')
- @DocsEditable
- num m44;
-
- @DomName('WebKitCSSMatrix.inverse')
- @DocsEditable
- CssMatrix inverse() native;
-
- @DomName('WebKitCSSMatrix.multiply')
- @DocsEditable
- CssMatrix multiply(CssMatrix secondMatrix) native;
-
- @DomName('WebKitCSSMatrix.rotate')
- @DocsEditable
- CssMatrix rotate(num rotX, num rotY, num rotZ) native;
-
- @DomName('WebKitCSSMatrix.rotateAxisAngle')
- @DocsEditable
- CssMatrix rotateAxisAngle(num x, num y, num z, num angle) native;
-
- @DomName('WebKitCSSMatrix.scale')
- @DocsEditable
- CssMatrix scale(num scaleX, num scaleY, num scaleZ) native;
-
- @DomName('WebKitCSSMatrix.setMatrixValue')
- @DocsEditable
- void setMatrixValue(String string) native;
-
- @DomName('WebKitCSSMatrix.skewX')
- @DocsEditable
- CssMatrix skewX(num angle) native;
-
- @DomName('WebKitCSSMatrix.skewY')
- @DocsEditable
- CssMatrix skewY(num angle) native;
-
- @DomName('WebKitCSSMatrix.toString')
- @DocsEditable
- String toString() native;
-
- @DomName('WebKitCSSMatrix.translate')
- @DocsEditable
- CssMatrix translate(num x, num y, num z) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('CSSMediaRule')
class CssMediaRule extends CssRule native "*CSSMediaRule" {
@@ -2280,154 +2102,6 @@
@DocsEditable
-@DomName('CSSPrimitiveValue')
-class CssPrimitiveValue extends CssValue native "*CSSPrimitiveValue" {
-
- static const int CSS_ATTR = 22;
-
- static const int CSS_CM = 6;
-
- static const int CSS_COUNTER = 23;
-
- static const int CSS_DEG = 11;
-
- static const int CSS_DIMENSION = 18;
-
- static const int CSS_EMS = 3;
-
- static const int CSS_EXS = 4;
-
- static const int CSS_GRAD = 13;
-
- static const int CSS_HZ = 16;
-
- static const int CSS_IDENT = 21;
-
- static const int CSS_IN = 8;
-
- static const int CSS_KHZ = 17;
-
- static const int CSS_MM = 7;
-
- static const int CSS_MS = 14;
-
- static const int CSS_NUMBER = 1;
-
- static const int CSS_PC = 10;
-
- static const int CSS_PERCENTAGE = 2;
-
- static const int CSS_PT = 9;
-
- static const int CSS_PX = 5;
-
- static const int CSS_RAD = 12;
-
- static const int CSS_RECT = 24;
-
- static const int CSS_RGBCOLOR = 25;
-
- static const int CSS_S = 15;
-
- static const int CSS_STRING = 19;
-
- static const int CSS_UNKNOWN = 0;
-
- static const int CSS_URI = 20;
-
- static const int CSS_VH = 27;
-
- static const int CSS_VMAX = 29;
-
- static const int CSS_VMIN = 28;
-
- static const int CSS_VW = 26;
-
- @DomName('CSSPrimitiveValue.primitiveType')
- @DocsEditable
- final int primitiveType;
-
- @DomName('CSSPrimitiveValue.getCounterValue')
- @DocsEditable
- Counter getCounterValue() native;
-
- @DomName('CSSPrimitiveValue.getFloatValue')
- @DocsEditable
- num getFloatValue(int unitType) native;
-
- @JSName('getRGBColorValue')
- @DomName('CSSPrimitiveValue.getRGBColorValue')
- @DocsEditable
- CssRgbColor getRgbColorValue() native;
-
- @DomName('CSSPrimitiveValue.getRectValue')
- @DocsEditable
- CssRect getRectValue() native;
-
- @DomName('CSSPrimitiveValue.getStringValue')
- @DocsEditable
- String getStringValue() native;
-
- @DomName('CSSPrimitiveValue.setFloatValue')
- @DocsEditable
- void setFloatValue(int unitType, num floatValue) native;
-
- @DomName('CSSPrimitiveValue.setStringValue')
- @DocsEditable
- void setStringValue(int stringType, String stringValue) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('Rect')
-class CssRect native "*Rect" {
-
- @DomName('Rect.bottom')
- @DocsEditable
- final CssPrimitiveValue bottom;
-
- @DomName('Rect.left')
- @DocsEditable
- final CssPrimitiveValue left;
-
- @DomName('Rect.right')
- @DocsEditable
- final CssPrimitiveValue right;
-
- @DomName('Rect.top')
- @DocsEditable
- final CssPrimitiveValue top;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('RGBColor')
-class CssRgbColor native "*RGBColor" {
-
- @DomName('RGBColor.blue')
- @DocsEditable
- final CssPrimitiveValue blue;
-
- @DomName('RGBColor.green')
- @DocsEditable
- final CssPrimitiveValue green;
-
- @DomName('RGBColor.red')
- @DocsEditable
- final CssPrimitiveValue red;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('CSSRule')
class CssRule native "*CSSRule" {
@@ -2498,11 +2172,6 @@
@DocsEditable
String _getPropertyValue(String propertyName) native;
- @JSName('getPropertyCSSValue')
- @DomName('CSSStyleDeclaration.getPropertyCSSValue')
- @DocsEditable
- CssValue getPropertyCssValue(String propertyName) native;
-
@DomName('CSSStyleDeclaration.getPropertyPriority')
@DocsEditable
String getPropertyPriority(String propertyName) native;
@@ -5774,61 +5443,6 @@
@DocsEditable
-@DomName('WebKitCSSTransformValue')
-class CssTransformValue extends _CssValueList native "*WebKitCSSTransformValue" {
-
- static const int CSS_MATRIX = 11;
-
- static const int CSS_MATRIX3D = 21;
-
- static const int CSS_PERSPECTIVE = 20;
-
- static const int CSS_ROTATE = 4;
-
- static const int CSS_ROTATE3D = 17;
-
- static const int CSS_ROTATEX = 14;
-
- static const int CSS_ROTATEY = 15;
-
- static const int CSS_ROTATEZ = 16;
-
- static const int CSS_SCALE = 5;
-
- static const int CSS_SCALE3D = 19;
-
- static const int CSS_SCALEX = 6;
-
- static const int CSS_SCALEY = 7;
-
- static const int CSS_SCALEZ = 18;
-
- static const int CSS_SKEW = 8;
-
- static const int CSS_SKEWX = 9;
-
- static const int CSS_SKEWY = 10;
-
- static const int CSS_TRANSLATE = 1;
-
- static const int CSS_TRANSLATE3D = 13;
-
- static const int CSS_TRANSLATEX = 2;
-
- static const int CSS_TRANSLATEY = 3;
-
- static const int CSS_TRANSLATEZ = 12;
-
- @DomName('WebKitCSSTransformValue.operationType')
- @DocsEditable
- final int operationType;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('CSSUnknownRule')
class CssUnknownRule extends CssRule native "*CSSUnknownRule" {
}
@@ -5836,31 +5450,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-
-@DocsEditable
-@DomName('CSSValue')
-class CssValue native "*CSSValue" {
-
- static const int CSS_CUSTOM = 3;
-
- static const int CSS_INHERIT = 0;
-
- static const int CSS_PRIMITIVE_VALUE = 1;
-
- static const int CSS_VALUE_LIST = 2;
-
- @DomName('CSSValue.cssText')
- @DocsEditable
- String cssText;
-
- @DomName('CSSValue.cssValueType')
- @DocsEditable
- final int cssValueType;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
// WARNING: Do not edit - generated code.
@@ -5957,6 +5546,22 @@
@DocsEditable
void clearData([String type]) native;
+ /**
+ * Gets the data for the specified type.
+ *
+ * The data is only available from within a drop operation (such as an
+ * [Element.onDrop] event) and will return `null` before the event is
+ * triggered.
+ *
+ * Data transfer is prohibited across domains. If a drag originates
+ * from content from another domain or protocol (HTTP vs HTTPS) then the
+ * data cannot be accessed.
+ *
+ * The [type] can have values such as:
+ *
+ * * `'Text'`
+ * * `'URL'`
+ */
@DomName('Clipboard.getData')
@DocsEditable
String getData(String type) native;
@@ -6132,44 +5737,6 @@
@DocsEditable
-@DomName('DedicatedWorkerContext')
-class DedicatedWorkerContext extends WorkerContext native "*DedicatedWorkerContext" {
-
- @DomName('DedicatedWorkerContext.messageEvent')
- @DocsEditable
- static const EventStreamProvider<MessageEvent> messageEvent = const EventStreamProvider<MessageEvent>('message');
-
- @DomName('DedicatedWorkerContext.postMessage')
- @DocsEditable
- void postMessage(/*any*/ message, [List messagePorts]) {
- if (?messagePorts) {
- var message_1 = convertDartToNative_SerializedScriptValue(message);
- _postMessage_1(message_1, messagePorts);
- return;
- }
- var message_2 = convertDartToNative_SerializedScriptValue(message);
- _postMessage_2(message_2);
- return;
- }
- @JSName('postMessage')
- @DomName('DedicatedWorkerContext.postMessage')
- @DocsEditable
- void _postMessage_1(message, List messagePorts) native;
- @JSName('postMessage')
- @DomName('DedicatedWorkerContext.postMessage')
- @DocsEditable
- void _postMessage_2(message) native;
-
- @DomName('DedicatedWorkerContext.onmessage')
- @DocsEditable
- Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('HTMLDetailsElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@@ -6411,45 +5978,6 @@
@DocsEditable
-@DomName('DirectoryEntrySync')
-class DirectoryEntrySync extends EntrySync native "*DirectoryEntrySync" {
-
- @DomName('DirectoryEntrySync.createReader')
- @DocsEditable
- DirectoryReaderSync createReader() native;
-
- @DomName('DirectoryEntrySync.getDirectory')
- @DocsEditable
- DirectoryEntrySync getDirectory(String path, Map flags) {
- var flags_1 = convertDartToNative_Dictionary(flags);
- return _getDirectory_1(path, flags_1);
- }
- @JSName('getDirectory')
- @DomName('DirectoryEntrySync.getDirectory')
- @DocsEditable
- DirectoryEntrySync _getDirectory_1(path, flags) native;
-
- @DomName('DirectoryEntrySync.getFile')
- @DocsEditable
- FileEntrySync getFile(String path, Map flags) {
- var flags_1 = convertDartToNative_Dictionary(flags);
- return _getFile_1(path, flags_1);
- }
- @JSName('getFile')
- @DomName('DirectoryEntrySync.getFile')
- @DocsEditable
- FileEntrySync _getFile_1(path, flags) native;
-
- @DomName('DirectoryEntrySync.removeRecursively')
- @DocsEditable
- void removeRecursively() native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('DirectoryReader')
class DirectoryReader native "*DirectoryReader" {
@@ -6475,21 +6003,6 @@
@DocsEditable
-@DomName('DirectoryReaderSync')
-class DirectoryReaderSync native "*DirectoryReaderSync" {
-
- @DomName('DirectoryReaderSync.readEntries')
- @DocsEditable
- @Returns('_EntryArraySync')
- @Creates('_EntryArraySync')
- List<EntrySync> readEntries() native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
/**
* Represents an HTML <div> element.
*
@@ -6620,6 +6133,10 @@
@DocsEditable
final String $dom_referrer;
+ @DomName('Document.securityPolicy')
+ @DocsEditable
+ final DomSecurityPolicy securityPolicy;
+
@JSName('selectedStylesheetSet')
@DomName('Document.selectedStylesheetSet')
@DocsEditable
@@ -7325,11 +6842,12 @@
return new FixedSizeListIterator<DomMimeType>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ DomMimeType reduce(DomMimeType combine(DomMimeType value, DomMimeType element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, DomMimeType element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -7337,7 +6855,7 @@
void forEach(void f(DomMimeType element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(DomMimeType element)) =>
@@ -7439,12 +6957,6 @@
throw new StateError("More than one element");
}
- DomMimeType min([int compare(DomMimeType a, DomMimeType b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- DomMimeType max([int compare(DomMimeType a, DomMimeType b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, DomMimeType element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -7461,14 +6973,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(DomMimeType element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -7489,17 +6993,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<DomMimeType> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<DomMimeType> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <DomMimeType>[]);
}
- List<DomMimeType> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, DomMimeType> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<DomMimeType> mixins.
@DomName('DOMMimeTypeArray.item')
@@ -7593,11 +7104,12 @@
return new FixedSizeListIterator<DomPlugin>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ DomPlugin reduce(DomPlugin combine(DomPlugin value, DomPlugin element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, DomPlugin element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -7605,7 +7117,7 @@
void forEach(void f(DomPlugin element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(DomPlugin element)) =>
@@ -7707,12 +7219,6 @@
throw new StateError("More than one element");
}
- DomPlugin min([int compare(DomPlugin a, DomPlugin b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- DomPlugin max([int compare(DomPlugin a, DomPlugin b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, DomPlugin element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -7729,14 +7235,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(DomPlugin element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -7757,17 +7255,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<DomPlugin> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<DomPlugin> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <DomPlugin>[]);
}
- List<DomPlugin> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, DomPlugin> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<DomPlugin> mixins.
@DomName('DOMPluginArray.item')
@@ -7788,29 +7293,70 @@
@DocsEditable
-@DomName('WebKitPoint')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@SupportedBrowser(SupportedBrowser.SAFARI)
-@Experimental
-class DomPoint native "*WebKitPoint" {
+@DomName('SecurityPolicy')
+class DomSecurityPolicy native "*SecurityPolicy" {
- @DomName('WebKitPoint.WebKitPoint')
+ @DomName('DOMSecurityPolicy.allowsEval')
@DocsEditable
- factory DomPoint(num x, num y) {
- return DomPoint._create_1(x, y);
- }
- static DomPoint _create_1(x, y) => JS('DomPoint', 'new WebKitPoint(#,#)', x, y);
+ final bool allowsEval;
- /// Checks if this type is supported on the current platform.
- static bool get supported => JS('bool', '!!(window.WebKitPoint)');
-
- @DomName('WebKitPoint.x')
+ @DomName('DOMSecurityPolicy.allowsInlineScript')
@DocsEditable
- num x;
+ final bool allowsInlineScript;
- @DomName('WebKitPoint.y')
+ @DomName('DOMSecurityPolicy.allowsInlineStyle')
@DocsEditable
- num y;
+ final bool allowsInlineStyle;
+
+ @DomName('DOMSecurityPolicy.isActive')
+ @DocsEditable
+ final bool isActive;
+
+ @DomName('DOMSecurityPolicy.reportURIs')
+ @DocsEditable
+ @Returns('DomStringList')
+ @Creates('DomStringList')
+ final List<String> reportURIs;
+
+ @DomName('DOMSecurityPolicy.allowsConnectionTo')
+ @DocsEditable
+ bool allowsConnectionTo(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsFontFrom')
+ @DocsEditable
+ bool allowsFontFrom(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsFormAction')
+ @DocsEditable
+ bool allowsFormAction(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsFrameFrom')
+ @DocsEditable
+ bool allowsFrameFrom(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsImageFrom')
+ @DocsEditable
+ bool allowsImageFrom(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsMediaFrom')
+ @DocsEditable
+ bool allowsMediaFrom(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsObjectFrom')
+ @DocsEditable
+ bool allowsObjectFrom(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsPluginType')
+ @DocsEditable
+ bool allowsPluginType(String type) native;
+
+ @DomName('DOMSecurityPolicy.allowsScriptFrom')
+ @DocsEditable
+ bool allowsScriptFrom(String url) native;
+
+ @DomName('DOMSecurityPolicy.allowsStyleFrom')
+ @DocsEditable
+ bool allowsStyleFrom(String url) native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -7968,11 +7514,12 @@
return new FixedSizeListIterator<String>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, String)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, String element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -7980,7 +7527,7 @@
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(String element)) =>
@@ -8082,12 +7629,6 @@
throw new StateError("More than one element");
}
- String min([int compare(String a, String b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- String max([int compare(String a, String b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, String element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -8104,14 +7645,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -8132,17 +7665,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<String> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<String> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <String>[]);
}
- List<String> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, String> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<String> mixins.
@DomName('DOMStringList.contains')
@@ -8197,7 +7737,7 @@
// TODO(jacobr): use _Lists.dart to remove some of the duplicated
// functionality.
-class _ChildrenElementList implements List {
+class _ChildrenElementList extends ListBase<Element> {
// Raw Element.
final Element _element;
final HtmlCollection _childElements;
@@ -8254,20 +7794,20 @@
return false;
}
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
+ String join([String separator = ""]) {
+ return _childElements.join(separator);
}
Iterable map(f(Element element)) {
- return IterableMixinWorkaround.mapList(this, f);
+ return _childElements.map(f);
}
Iterable<Element> where(bool f(Element element)) {
- return IterableMixinWorkaround.where(this, f);
+ return _childElements.where(f);
}
Iterable expand(Iterable f(Element element)) {
- return IterableMixinWorkaround.expand(this, f);
+ return _childElements.expand(f);
}
bool get isEmpty {
@@ -8275,31 +7815,31 @@
}
Iterable<Element> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
+ return _childElements.take(n);
}
Iterable<Element> takeWhile(bool test(Element value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
+ return _childElements.takeWhile(test);
}
Iterable<Element> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
+ return _childElements.skip(n);
}
Iterable<Element> skipWhile(bool test(Element value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
+ return _childElements.skipWhile(test);
}
Element firstWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
+ return _childElements.firstWhere(test, orElse: orElse);
}
Element lastWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
+ return _childElements.lastWhere(test, orElse: orElse);
}
Element singleWhere(bool test(Element value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
+ return _childElements.singleWhere(test);
}
Element elementAt(int index) {
@@ -8341,24 +7881,24 @@
}
Iterable<Element> get reversed {
- return IterableMixinWorkaround.reversedList(this);
+ return _childElements.reversed;
}
void sort([int compare(Element a, Element b)]) {
throw new UnsupportedError('TODO(jacobr): should we impl?');
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Element reduce(Element combine(Element value, Element element)) {
+ return _childElements.reduce(combine);
}
dynamic fold(dynamic initialValue,
dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
+ return _childElements.fold(initialValue, combine);
}
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
+ void setRange(int start, int rangeLength, List from,
+ [int startFrom = 0]) {
throw new UnimplementedError();
}
@@ -8371,20 +7911,12 @@
}
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
void removeWhere(bool test(Element element)) {
- IterableMixinWorkaround.removeWhere(this, test);
+ _childElements.removeWhere(test);
}
void retainWhere(bool test(Element element)) {
- IterableMixinWorkaround.retainWhere(this, test);
+ _childElements.retainWhere(test);
}
void removeRange(int start, int rangeLength) {
@@ -8395,14 +7927,15 @@
throw new UnimplementedError();
}
+ Iterable getRange(int start, int end) {
+ throw new UnimplementedError();
+ }
+
List sublist(int start, [int end]) {
if (end == null) end = length;
return new _FrozenElementList._wrap(Lists.getRange(this, start, end, []));
}
- List getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
int indexOf(Element element, [int start = 0]) {
return Lists.indexOf(this, element, start, this.length);
}
@@ -8462,16 +7995,15 @@
return first;
}
- Element min([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.min(this, compare);
- }
-
- Element max([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
Map<int, Element> asMap() {
- return IterableMixinWorkaround.asMapList(this);
+ return _childElements.asMap();
+ }
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
}
}
@@ -8479,96 +8011,11 @@
// a better option given that we cannot quite force NodeList to be an
// ElementList as there are valid cases where a NodeList JavaScript object
// contains Node objects that are not Elements.
-class _FrozenElementList implements List {
+class _FrozenElementList extends ListBase {
final List<Node> _nodeList;
_FrozenElementList._wrap(this._nodeList);
- bool contains(Element element) {
- for (Element el in this) {
- if (el == element) return true;
- }
- return false;
- }
-
- void forEach(void f(Element element)) {
- for (Element el in this) {
- f(el);
- }
- }
-
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
- }
-
- Iterable map(f(Element element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
- Iterable<Element> where(bool f(Element element)) {
- return IterableMixinWorkaround.where(this, f);
- }
-
- Iterable expand(Iterable f(Element element)) {
- return IterableMixinWorkaround.expand(this, f);
- }
-
- bool every(bool f(Element element)) {
- for(Element element in this) {
- if (!f(element)) {
- return false;
- }
- };
- return true;
- }
-
- bool any(bool f(Element element)) {
- for(Element element in this) {
- if (f(element)) {
- return true;
- }
- };
- return false;
- }
-
- List<Element> toList({ bool growable: true }) =>
- new List<Element>.from(this, growable: growable);
- Set<Element> toSet() => new Set<Element>.from(this);
-
- Iterable<Element> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
- }
-
- Iterable<Element> takeWhile(bool test(Element value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
-
- Iterable<Element> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
- }
-
- Iterable<Element> skipWhile(bool test(Element value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- Element firstWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- Element lastWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- Element singleWhere(bool test(Element value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- Element elementAt(int index) {
- return this[index];
- }
-
- bool get isEmpty => _nodeList.isEmpty;
-
int get length => _nodeList.length;
Element operator [](int index) => _nodeList[index];
@@ -8585,31 +8032,16 @@
throw new UnsupportedError('');
}
- Iterator<Element> get iterator => new _FrozenElementListIterator(this);
-
void addAll(Iterable<Element> iterable) {
throw new UnsupportedError('');
}
- Iterable<Element> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
void sort([int compare(Element a, Element b)]) {
throw new UnsupportedError('');
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
+ void setRange(int start, int rangeLength, List from,
+ [int startFrom = 0]) {
throw new UnsupportedError('');
}
@@ -8625,15 +8057,6 @@
return new _FrozenElementList._wrap(_nodeList.sublist(start, end));
}
- List<Element> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- int indexOf(Element element, [int start = 0]) =>
- _nodeList.indexOf(element, start);
-
- int lastIndexOf(Element element, [int start = null]) =>
- _nodeList.lastIndexOf(element, start);
-
void clear() {
throw new UnsupportedError('');
}
@@ -8650,14 +8073,6 @@
throw new UnsupportedError('');
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError('');
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError('');
- }
-
void removeWhere(bool test(Element element)) {
throw new UnsupportedError('');
}
@@ -8672,49 +8087,12 @@
Element get single => _nodeList.single;
- Element min([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.min(this, compare);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
}
-
- Element max([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
- Map<int, Element> asMap() {
- return IterableMixinWorkaround.asMapList(this);
- }
-}
-
-class _FrozenElementListIterator implements Iterator<Element> {
- final _FrozenElementList _list;
- int _index = -1;
- Element _current;
-
- _FrozenElementListIterator(this._list);
-
- /**
- * Moves to the next element. Returns true if the iterator is positioned
- * at an element. Returns false if it is positioned after the last element.
- */
- bool moveNext() {
- int nextIndex = _index + 1;
- if (nextIndex < _list.length) {
- _current = _list[nextIndex];
- _index = nextIndex;
- return true;
- }
- _index = _list.length;
- _current = null;
- return false;
- }
-
- /**
- * Returns the element the [Iterator] is positioned at.
- *
- * Return [:null:] if the iterator is positioned before the first, or
- * after the last element.
- */
- Element get current => _current;
}
class _ElementCssClassSet extends CssClassSet {
@@ -8853,7 +8231,7 @@
*/
CssClassSet get classes => new _ElementCssClassSet(this);
- void set classes(Collection<String> value) {
+ void set classes(Iterable<String> value) {
CssClassSet classSet = classes;
classSet.clear();
classSet.addAll(value);
@@ -10247,60 +9625,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-
-@DocsEditable
-@DomName('EntrySync')
-class EntrySync native "*EntrySync" {
-
- @DomName('EntrySync.filesystem')
- @DocsEditable
- final FileSystemSync filesystem;
-
- @DomName('EntrySync.fullPath')
- @DocsEditable
- final String fullPath;
-
- @DomName('EntrySync.isDirectory')
- @DocsEditable
- final bool isDirectory;
-
- @DomName('EntrySync.isFile')
- @DocsEditable
- final bool isFile;
-
- @DomName('EntrySync.name')
- @DocsEditable
- final String name;
-
- @DomName('EntrySync.copyTo')
- @DocsEditable
- EntrySync copyTo(DirectoryEntrySync parent, String name) native;
-
- @DomName('EntrySync.getMetadata')
- @DocsEditable
- Metadata getMetadata() native;
-
- @DomName('EntrySync.getParent')
- @DocsEditable
- EntrySync getParent() native;
-
- @DomName('EntrySync.moveTo')
- @DocsEditable
- EntrySync moveTo(DirectoryEntrySync parent, String name) native;
-
- @DomName('EntrySync.remove')
- @DocsEditable
- void remove() native;
-
- @JSName('toURL')
- @DomName('EntrySync.toURL')
- @DocsEditable
- String toUrl() native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
// WARNING: Do not edit - generated code.
@@ -10437,10 +9761,6 @@
@DocsEditable
final int eventPhase;
- @DomName('Event.returnValue')
- @DocsEditable
- bool returnValue;
-
EventTarget get target => _convertNativeToDart_EventTarget(this._get_target);
@JSName('target')
@DomName('Event.target')
@@ -10808,23 +10128,6 @@
@DocsEditable
-@DomName('FileEntrySync')
-class FileEntrySync extends EntrySync native "*FileEntrySync" {
-
- @DomName('FileEntrySync.createWriter')
- @DocsEditable
- FileWriterSync createWriter() native;
-
- @DomName('FileEntrySync.file')
- @DocsEditable
- File file() native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('FileError')
class FileError native "*FileError" {
@@ -10935,11 +10238,12 @@
return new FixedSizeListIterator<File>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, File)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ File reduce(File combine(File value, File element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, File)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, File element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -10947,7 +10251,7 @@
void forEach(void f(File element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(File element)) =>
@@ -11049,12 +10353,6 @@
throw new StateError("More than one element");
}
- File min([int compare(File a, File b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- File max([int compare(File a, File b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, File element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -11071,14 +10369,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(File element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -11099,17 +10389,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<File> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<File> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <File>[]);
}
- List<File> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, File> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<File> mixins.
@DomName('FileList.item')
@@ -11240,41 +10537,6 @@
@DocsEditable
-@DomName('FileReaderSync')
-class FileReaderSync native "*FileReaderSync" {
-
- @DomName('FileReaderSync.FileReaderSync')
- @DocsEditable
- factory FileReaderSync() {
- return FileReaderSync._create_1();
- }
- static FileReaderSync _create_1() => JS('FileReaderSync', 'new FileReaderSync()');
-
- @DomName('FileReaderSync.readAsArrayBuffer')
- @DocsEditable
- @Creates('ArrayBuffer')
- @Returns('ArrayBuffer|Null')
- dynamic readAsArrayBuffer(Blob blob) native;
-
- @DomName('FileReaderSync.readAsBinaryString')
- @DocsEditable
- String readAsBinaryString(Blob blob) native;
-
- @JSName('readAsDataURL')
- @DomName('FileReaderSync.readAsDataURL')
- @DocsEditable
- String readAsDataUrl(Blob blob) native;
-
- @DomName('FileReaderSync.readAsText')
- @DocsEditable
- String readAsText(Blob blob, [String encoding]) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('DOMFileSystem')
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
@@ -11305,25 +10567,6 @@
@DocsEditable
-@DomName('DOMFileSystemSync')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@Experimental
-class FileSystemSync native "*DOMFileSystemSync" {
-
- @DomName('DOMFileSystemSync.name')
- @DocsEditable
- final String name;
-
- @DomName('DOMFileSystemSync.root')
- @DocsEditable
- final DirectoryEntrySync root;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('FileWriter')
class FileWriter extends EventTarget native "*FileWriter" {
@@ -11441,35 +10684,6 @@
@DocsEditable
-@DomName('FileWriterSync')
-class FileWriterSync native "*FileWriterSync" {
-
- @DomName('FileWriterSync.length')
- @DocsEditable
- final int length;
-
- @DomName('FileWriterSync.position')
- @DocsEditable
- final int position;
-
- @DomName('FileWriterSync.seek')
- @DocsEditable
- void seek(int position) native;
-
- @DomName('FileWriterSync.truncate')
- @DocsEditable
- void truncate(int size) native;
-
- @DomName('FileWriterSync.write')
- @DocsEditable
- void write(Blob data) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('Float32Array')
class Float32Array extends ArrayBufferView implements JavaScriptIndexingBehavior, List<double> native "*Float32Array" {
@@ -11508,11 +10722,12 @@
return new FixedSizeListIterator<num>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, num)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ num reduce(num combine(num value, num element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, num element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -11520,7 +10735,7 @@
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(num element)) =>
@@ -11622,12 +10837,6 @@
throw new StateError("More than one element");
}
- num min([int compare(num a, num b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- num max([int compare(num a, num b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, num element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -11644,14 +10853,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(num element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -11672,17 +10873,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<num> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<num> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <num>[]);
}
- List<num> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, num> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<num> mixins.
@JSName('set')
@@ -11740,11 +10948,12 @@
return new FixedSizeListIterator<num>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, num)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ num reduce(num combine(num value, num element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, num element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -11752,7 +10961,7 @@
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(num element)) =>
@@ -11854,12 +11063,6 @@
throw new StateError("More than one element");
}
- num min([int compare(num a, num b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- num max([int compare(num a, num b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, num element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -11876,14 +11079,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(num element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -11904,17 +11099,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<num> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<num> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <num>[]);
}
- List<num> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, num> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<num> mixins.
@JSName('set')
@@ -12125,7 +11327,7 @@
var controller;
controller = new StreamController<Geoposition>(
onSubscriptionStateChange: () {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
assert(watchId == null);
watchId = $dom_watchPosition(
(position) {
@@ -12392,11 +11594,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -12404,7 +11607,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -12506,12 +11709,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -12528,14 +11725,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -12556,17 +11745,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('HTMLAllCollection.item')
@@ -12613,11 +11809,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -12625,7 +11822,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -12727,12 +11924,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -12749,14 +11940,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -12777,17 +11960,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('HTMLCollection.item')
@@ -12812,22 +12002,18 @@
@DocsEditable
final Element activeElement;
- @DomName('Document.body')
- BodyElement get body => document.$dom_body;
@DomName('Document.body')
- void set body(BodyElement value) {
- document.$dom_body = value;
- }
+ BodyElement body;
@DomName('Document.caretRangeFromPoint')
Range caretRangeFromPoint(int x, int y) {
- return document.$dom_caretRangeFromPoint(x, y);
+ return $dom_caretRangeFromPoint(x, y);
}
@DomName('Document.elementFromPoint')
Element elementFromPoint(int x, int y) {
- return document.$dom_elementFromPoint(x, y);
+ return $dom_elementFromPoint(x, y);
}
/**
@@ -12867,36 +12053,36 @@
@DomName('Document.getCSSCanvasContext')
CanvasRenderingContext getCssCanvasContext(String contextId, String name,
int width, int height) {
- return document.$dom_getCssCanvasContext(contextId, name, width, height);
+ return $dom_getCssCanvasContext(contextId, name, width, height);
}
@DomName('Document.head')
- HeadElement get head => document.$dom_head;
+ HeadElement get head => $dom_head;
@DomName('Document.lastModified')
- String get lastModified => document.$dom_lastModified;
+ String get lastModified => $dom_lastModified;
@DomName('Document.preferredStylesheetSet')
- String get preferredStylesheetSet => document.$dom_preferredStylesheetSet;
+ String get preferredStylesheetSet => $dom_preferredStylesheetSet;
@DomName('Document.referrer')
- String get referrer => document.$dom_referrer;
+ String get referrer => $dom_referrer;
@DomName('Document.selectedStylesheetSet')
- String get selectedStylesheetSet => document.$dom_selectedStylesheetSet;
+ String get selectedStylesheetSet => $dom_selectedStylesheetSet;
void set selectedStylesheetSet(String value) {
- document.$dom_selectedStylesheetSet = value;
+ $dom_selectedStylesheetSet = value;
}
@DomName('Document.styleSheets')
- List<StyleSheet> get styleSheets => document.$dom_styleSheets;
+ List<StyleSheet> get styleSheets => $dom_styleSheets;
@DomName('Document.title')
- String get title => document.$dom_title;
+ String get title => $dom_title;
@DomName('Document.title')
void set title(String value) {
- document.$dom_title = value;
+ $dom_title = value;
}
@DomName('Document.webkitCancelFullScreen')
@@ -12904,7 +12090,7 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void cancelFullScreen() {
- document.$dom_webkitCancelFullScreen();
+ $dom_webkitCancelFullScreen();
}
@DomName('Document.webkitExitFullscreen')
@@ -12912,7 +12098,7 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void exitFullscreen() {
- document.$dom_webkitExitFullscreen();
+ $dom_webkitExitFullscreen();
}
@DomName('Document.webkitExitPointerLock')
@@ -12920,45 +12106,45 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void exitPointerLock() {
- document.$dom_webkitExitPointerLock();
+ $dom_webkitExitPointerLock();
}
@DomName('Document.webkitFullscreenElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- Element get fullscreenElement => document.$dom_webkitFullscreenElement;
+ Element get fullscreenElement => $dom_webkitFullscreenElement;
@DomName('Document.webkitFullscreenEnabled')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get fullscreenEnabled => document.$dom_webkitFullscreenEnabled;
+ bool get fullscreenEnabled => $dom_webkitFullscreenEnabled;
@DomName('Document.webkitHidden')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get hidden => document.$dom_webkitHidden;
+ bool get hidden => $dom_webkitHidden;
@DomName('Document.webkitIsFullScreen')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get isFullScreen => document.$dom_webkitIsFullScreen;
+ bool get isFullScreen => $dom_webkitIsFullScreen;
@DomName('Document.webkitPointerLockElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Element get pointerLockElement =>
- document.$dom_webkitPointerLockElement;
+ $dom_webkitPointerLockElement;
@DomName('Document.webkitVisibilityState')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- String get visibilityState => document.$dom_webkitVisibilityState;
+ String get visibilityState => $dom_webkitVisibilityState;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -13640,6 +12826,10 @@
@DocsEditable
String sandbox;
+ @DomName('HTMLIFrameElement.seamless')
+ @DocsEditable
+ bool seamless;
+
@DomName('HTMLIFrameElement.src')
@DocsEditable
String src;
@@ -14657,11 +13847,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -14669,7 +13860,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -14771,12 +13962,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -14793,14 +13978,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -14821,17 +13998,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -14889,11 +14073,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -14901,7 +14086,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -15003,12 +14188,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -15025,14 +14204,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -15053,17 +14224,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -15121,11 +14299,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -15133,7 +14312,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -15235,12 +14414,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -15257,14 +14430,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -15285,17 +14450,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -17585,7 +16757,7 @@
* the actual child nodes of an element until strictly necessary greatly
* improving performance for the typical cases where it is not required.
*/
-class _ChildNodeListLazy implements List {
+class _ChildNodeListLazy extends ListBase<Node> {
final Node _this;
_ChildNodeListLazy(this._this);
@@ -17608,14 +16780,6 @@
return JS('Node|Null', '#.firstChild', _this);
}
- Node min([int compare(Node a, Node b)]) {
- return IterableMixinWorkaround.min(this, compare);
- }
-
- Node max([int compare(Node a, Node b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
void add(Node value) {
_this.append(value);
}
@@ -17670,20 +16834,26 @@
_this.$dom_removeChild(node);
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
+ void _filter(bool test(Node node), bool removeMatching) {
+ // This implementation of removeWhere/retainWhere is more efficient
+ // than the default in ListBase. Child nodes can be removed in constant
+ // time.
+ Node child = _this.$dom_firstChild;
+ while (child != null) {
+ Node nextChild = child.nextSibling;
+ if (test(child) == removeMatching) {
+ _this.$dom_removeChild(child);
+ }
+ child = nextChild;
+ }
}
void removeWhere(bool test(Node node)) {
- IterableMixinWorkaround.removeWhere(this, test);
+ _filter(test, true);
}
void retainWhere(bool test(Node node)) {
- IterableMixinWorkaround.retainWhere(this, test);
+ _filter(test, false);
}
void clear() {
@@ -17696,42 +16866,6 @@
Iterator<Node> get iterator => _this.$dom_childNodes.iterator;
- // TODO(jacobr): We can implement these methods much more efficiently by
- // looking up the nodeList only once instead of once per iteration.
- bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
-
- void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
-
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Node element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, Node element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
- }
-
- Iterable map(f(Node element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
- Iterable<Node> where(bool f(Node element)) {
- return IterableMixinWorkaround.where(this, f);
- }
-
- Iterable expand(Iterable f(Node element)) {
- return IterableMixinWorkaround.expand(this, f);
- }
-
- bool every(bool f(Node element)) => IterableMixinWorkaround.every(this, f);
-
- bool any(bool f(Node element)) => IterableMixinWorkaround.any(this, f);
-
List<Node> toList({ bool growable: true }) =>
new List<Node>.from(this, growable: growable);
Set<Node> toSet() => new Set<Node>.from(this);
@@ -17740,54 +16874,12 @@
// From List<Node>:
- Iterable<Node> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
- }
-
- Iterable<Node> takeWhile(bool test(Node value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
-
- Iterable<Node> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
- }
-
- Iterable<Node> skipWhile(bool test(Node value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- Node firstWhere(bool test(Node value), {Node orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- Node lastWhere(bool test(Node value), {Node orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- Node singleWhere(bool test(Node value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- Node elementAt(int index) {
- return this[index];
- }
-
- Iterable<Node> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
// TODO(jacobr): this could be implemented for child node lists.
// The exception we throw here is misleading.
void sort([int compare(Node a, Node b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(Node element, [int start = 0]) =>
- Lists.indexOf(this, element, start, this.length);
-
- int lastIndexOf(Node element, [int start = 0]) =>
- Lists.lastIndexOf(this, element, start);
-
// FIXME: implement these.
void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) {
throw new UnsupportedError(
@@ -17801,14 +16893,22 @@
throw new UnsupportedError(
"Cannot insertRange on immutable List.");
}
+
+ Iterable<Node> getRange(int start, int end) {
+ throw new UnimplementedError("NodeList.getRange");
+ }
+
List<Node> sublist(int start, [int end]) {
if (end == null) end == length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
// -- end List<Node> mixins.
// TODO(jacobr): benchmark whether this is more efficient or whether caching
@@ -17821,8 +16921,6 @@
}
Node operator[](int index) => _this.$dom_childNodes[index];
-
- Map<int, Node> asMap() => IterableMixinWorkaround.asMapList(this);
}
@DomName('Node')
@@ -17831,7 +16929,7 @@
return new _ChildNodeListLazy(this);
}
- void set nodes(Collection<Node> value) {
+ void set nodes(Iterable<Node> value) {
// Copy list first since we don't want liveness during iteration.
// TODO(jacobr): there is a better way to do this.
List copy = new List.from(value);
@@ -17974,6 +17072,12 @@
return _modelChangedStream.stream;
}
+ /**
+ * Print out a String representation of this Node.
+ */
+ String toString() => localName == null ?
+ (nodeValue == null ? super.toString() : nodeValue) : localName;
+
@JSName('childNodes')
@DomName('Node.childNodes')
@@ -17992,10 +17096,9 @@
@DocsEditable
final Node $dom_lastChild;
- @JSName('localName')
@DomName('Node.localName')
@DocsEditable
- final String $dom_localName;
+ final String localName;
@JSName('namespaceURI')
@DomName('Node.namespaceURI')
@@ -18206,11 +17309,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -18218,7 +17322,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -18320,12 +17424,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -18342,14 +17440,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -18370,17 +17460,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@JSName('item')
@@ -19596,6 +18693,10 @@
@DomName('RTCDTMFSender')
class RtcDtmfSender extends EventTarget native "*RTCDTMFSender" {
+ @DomName('RTCDTMFSender.tonechangeEvent')
+ @DocsEditable
+ static const EventStreamProvider<RtcDtmfToneChangeEvent> toneChangeEvent = const EventStreamProvider<RtcDtmfToneChangeEvent>('tonechange');
+
@JSName('canInsertDTMF')
@DomName('RTCDTMFSender.canInsertDTMF')
@DocsEditable
@@ -19635,6 +18736,10 @@
@DomName('RTCDTMFSender.removeEventListener')
@DocsEditable
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native;
+
+ @DomName('RTCDTMFSender.ontonechange')
+ @DocsEditable
+ Stream<RtcDtmfToneChangeEvent> get onToneChange => toneChangeEvent.forTarget(this);
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -19754,6 +18859,10 @@
@DocsEditable
static const EventStreamProvider<RtcIceCandidateEvent> iceCandidateEvent = const EventStreamProvider<RtcIceCandidateEvent>('icecandidate');
+ @DomName('RTCPeerConnection.iceconnectionstatechangeEvent')
+ @DocsEditable
+ static const EventStreamProvider<Event> iceConnectionStateChangeEvent = const EventStreamProvider<Event>('iceconnectionstatechange');
+
@DomName('RTCPeerConnection.negotiationneededEvent')
@DocsEditable
static const EventStreamProvider<Event> negotiationNeededEvent = const EventStreamProvider<Event>('negotiationneeded');
@@ -19762,6 +18871,10 @@
@DocsEditable
static const EventStreamProvider<MediaStreamEvent> removeStreamEvent = const EventStreamProvider<MediaStreamEvent>('removestream');
+ @DomName('RTCPeerConnection.signalingstatechangeEvent')
+ @DocsEditable
+ static const EventStreamProvider<Event> signalingStateChangeEvent = const EventStreamProvider<Event>('signalingstatechange');
+
@DomName('RTCPeerConnection.iceConnectionState')
@DocsEditable
final String iceConnectionState;
@@ -19981,6 +19094,10 @@
@DocsEditable
Stream<RtcIceCandidateEvent> get onIceCandidate => iceCandidateEvent.forTarget(this);
+ @DomName('RTCPeerConnection.oniceconnectionstatechange')
+ @DocsEditable
+ Stream<Event> get onIceConnectionStateChange => iceConnectionStateChangeEvent.forTarget(this);
+
@DomName('RTCPeerConnection.onnegotiationneeded')
@DocsEditable
Stream<Event> get onNegotiationNeeded => negotiationNeededEvent.forTarget(this);
@@ -19989,6 +19106,10 @@
@DocsEditable
Stream<MediaStreamEvent> get onRemoveStream => removeStreamEvent.forTarget(this);
+ @DomName('RTCPeerConnection.onsignalingstatechange')
+ @DocsEditable
+ Stream<Event> get onSignalingStateChange => signalingStateChangeEvent.forTarget(this);
+
}
@@ -20160,6 +19281,10 @@
@DocsEditable
String htmlFor;
+ @DomName('HTMLScriptElement.nonce')
+ @DocsEditable
+ String nonce;
+
@DomName('HTMLScriptElement.src')
@DocsEditable
String src;
@@ -20244,6 +19369,49 @@
// BSD-style license that can be found in the LICENSE file.
+@DocsEditable
+@DomName('SecurityPolicyViolationEvent')
+class SecurityPolicyViolationEvent extends Event native "*SecurityPolicyViolationEvent" {
+
+ @JSName('blockedURI')
+ @DomName('SecurityPolicyViolationEvent.blockedURI')
+ @DocsEditable
+ final String blockedUri;
+
+ @JSName('documentURI')
+ @DomName('SecurityPolicyViolationEvent.documentURI')
+ @DocsEditable
+ final String documentUri;
+
+ @DomName('SecurityPolicyViolationEvent.effectiveDirective')
+ @DocsEditable
+ final String effectiveDirective;
+
+ @DomName('SecurityPolicyViolationEvent.lineNumber')
+ @DocsEditable
+ final int lineNumber;
+
+ @DomName('SecurityPolicyViolationEvent.originalPolicy')
+ @DocsEditable
+ final String originalPolicy;
+
+ @DomName('SecurityPolicyViolationEvent.referrer')
+ @DocsEditable
+ final String referrer;
+
+ @DomName('SecurityPolicyViolationEvent.sourceFile')
+ @DocsEditable
+ final String sourceFile;
+
+ @DomName('SecurityPolicyViolationEvent.violatedDirective')
+ @DocsEditable
+ final String violatedDirective;
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
@DomName('HTMLSelectElement')
class SelectElement extends Element native "*HTMLSelectElement" {
@@ -20436,51 +19604,6 @@
@DocsEditable
-@DomName('SharedWorker')
-class SharedWorker extends AbstractWorker native "*SharedWorker" {
-
- @DomName('SharedWorker.SharedWorker')
- @DocsEditable
- factory SharedWorker(String scriptURL, [String name]) {
- if (?name) {
- return SharedWorker._create_1(scriptURL, name);
- }
- return SharedWorker._create_2(scriptURL);
- }
- static SharedWorker _create_1(scriptURL, name) => JS('SharedWorker', 'new SharedWorker(#,#)', scriptURL, name);
- static SharedWorker _create_2(scriptURL) => JS('SharedWorker', 'new SharedWorker(#)', scriptURL);
-
- @DomName('SharedWorker.port')
- @DocsEditable
- final MessagePort port;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SharedWorkerContext')
-class SharedWorkerContext extends WorkerContext native "*SharedWorkerContext" {
-
- @DomName('SharedWorkerContext.connectEvent')
- @DocsEditable
- static const EventStreamProvider<Event> connectEvent = const EventStreamProvider<Event>('connect');
-
- @DomName('SharedWorkerContext.name')
- @DocsEditable
- final String name;
-
- @DomName('SharedWorkerContext.onconnect')
- @DocsEditable
- Stream<Event> get onConnect => connectEvent.forTarget(this);
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('SourceBuffer')
class SourceBuffer native "*SourceBuffer" {
@@ -20530,11 +19653,12 @@
return new FixedSizeListIterator<SourceBuffer>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SourceBuffer reduce(SourceBuffer combine(SourceBuffer value, SourceBuffer element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SourceBuffer element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -20542,7 +19666,7 @@
void forEach(void f(SourceBuffer element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SourceBuffer element)) =>
@@ -20644,12 +19768,6 @@
throw new StateError("More than one element");
}
- SourceBuffer min([int compare(SourceBuffer a, SourceBuffer b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SourceBuffer max([int compare(SourceBuffer a, SourceBuffer b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SourceBuffer element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -20666,14 +19784,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SourceBuffer element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -20694,17 +19804,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SourceBuffer> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SourceBuffer> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SourceBuffer>[]);
}
- List<SourceBuffer> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SourceBuffer> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SourceBuffer> mixins.
@JSName('addEventListener')
@@ -20824,11 +19941,12 @@
return new FixedSizeListIterator<SpeechGrammar>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SpeechGrammar reduce(SpeechGrammar combine(SpeechGrammar value, SpeechGrammar element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SpeechGrammar element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -20836,7 +19954,7 @@
void forEach(void f(SpeechGrammar element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SpeechGrammar element)) =>
@@ -20938,12 +20056,6 @@
throw new StateError("More than one element");
}
- SpeechGrammar min([int compare(SpeechGrammar a, SpeechGrammar b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SpeechGrammar max([int compare(SpeechGrammar a, SpeechGrammar b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SpeechGrammar element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -20960,14 +20072,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SpeechGrammar element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -20988,17 +20092,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SpeechGrammar> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SpeechGrammar> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SpeechGrammar>[]);
}
- List<SpeechGrammar> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SpeechGrammar> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SpeechGrammar> mixins.
@DomName('SpeechGrammarList.addFromString')
@@ -21348,13 +20459,13 @@
}
}
- Collection<String> get keys {
+ Iterable<String> get keys {
final keys = [];
forEach((k, v) => keys.add(k));
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
final values = [];
forEach((k, v) => values.add(v));
return values;
@@ -22281,11 +21392,12 @@
return new FixedSizeListIterator<TextTrackCue>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ TextTrackCue reduce(TextTrackCue combine(TextTrackCue value, TextTrackCue element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, TextTrackCue element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -22293,7 +21405,7 @@
void forEach(void f(TextTrackCue element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(TextTrackCue element)) =>
@@ -22395,12 +21507,6 @@
throw new StateError("More than one element");
}
- TextTrackCue min([int compare(TextTrackCue a, TextTrackCue b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- TextTrackCue max([int compare(TextTrackCue a, TextTrackCue b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, TextTrackCue element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -22417,14 +21523,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(TextTrackCue element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -22445,17 +21543,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<TextTrackCue> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<TextTrackCue> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <TextTrackCue>[]);
}
- List<TextTrackCue> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, TextTrackCue> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<TextTrackCue> mixins.
@DomName('TextTrackCueList.getCueById')
@@ -22500,11 +21605,12 @@
return new FixedSizeListIterator<TextTrack>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ TextTrack reduce(TextTrack combine(TextTrack value, TextTrack element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, TextTrack element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -22512,7 +21618,7 @@
void forEach(void f(TextTrack element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(TextTrack element)) =>
@@ -22614,12 +21720,6 @@
throw new StateError("More than one element");
}
- TextTrack min([int compare(TextTrack a, TextTrack b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- TextTrack max([int compare(TextTrack a, TextTrack b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, TextTrack element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -22636,14 +21736,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(TextTrack element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -22664,17 +21756,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<TextTrack> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<TextTrack> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <TextTrack>[]);
}
- List<TextTrack> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, TextTrack> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<TextTrack> mixins.
@JSName('addEventListener')
@@ -22945,11 +22044,12 @@
return new FixedSizeListIterator<Touch>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Touch)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Touch reduce(Touch combine(Touch value, Touch element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Touch)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Touch element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -22957,7 +22057,7 @@
void forEach(void f(Touch element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Touch element)) =>
@@ -23059,12 +22159,6 @@
throw new StateError("More than one element");
}
- Touch min([int compare(Touch a, Touch b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Touch max([int compare(Touch a, Touch b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Touch element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -23081,14 +22175,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Touch element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -23109,17 +22195,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Touch> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Touch> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Touch>[]);
}
- List<Touch> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Touch> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Touch> mixins.
@DomName('TouchList.item')
@@ -23427,11 +22520,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -23439,7 +22533,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -23541,12 +22635,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -23563,14 +22651,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -23591,17 +22671,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -23659,11 +22746,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -23671,7 +22759,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -23773,12 +22861,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -23795,14 +22877,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -23823,17 +22897,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -23891,11 +22972,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -23903,7 +22985,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -24005,12 +23087,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -24027,14 +23103,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -24055,17 +23123,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -24120,11 +23195,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -24132,7 +23208,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -24234,12 +23310,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -24256,14 +23326,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -24284,17 +23346,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@JSName('set')
@@ -24508,52 +23577,6 @@
@DocsEditable
-@DomName('WebKitCSSFilterValue')
-class WebKitCssFilterValue extends _CssValueList native "*WebKitCSSFilterValue" {
-
- static const int CSS_FILTER_BLUR = 10;
-
- static const int CSS_FILTER_BRIGHTNESS = 8;
-
- static const int CSS_FILTER_CONTRAST = 9;
-
- static const int CSS_FILTER_CUSTOM = 12;
-
- static const int CSS_FILTER_DROP_SHADOW = 11;
-
- static const int CSS_FILTER_GRAYSCALE = 2;
-
- static const int CSS_FILTER_HUE_ROTATE = 5;
-
- static const int CSS_FILTER_INVERT = 6;
-
- static const int CSS_FILTER_OPACITY = 7;
-
- static const int CSS_FILTER_REFERENCE = 1;
-
- static const int CSS_FILTER_SATURATE = 4;
-
- static const int CSS_FILTER_SEPIA = 3;
-
- @DomName('WebKitCSSFilterValue.operationType')
- @DocsEditable
- final int operationType;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('WebKitCSSMixFunctionValue')
-class WebKitCssMixFunctionValue extends _CssValueList native "*WebKitCSSMixFunctionValue" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('WebKitNamedFlow')
class WebKitNamedFlow extends EventTarget native "*WebKitNamedFlow" {
@@ -25211,20 +24234,42 @@
* lasting storage. This storage cannot be freed without the user's
* permission. Returns a [Future] whose value stores a reference to the
* sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
+ * applications cannot access file systems created in other web pages.
*/
Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
return _requestFileSystem(persistent? 1 : 0, size);
}
+ @DomName('DOMWindow.convertPointFromNodeToPage')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.SAFARI)
+ @Experimental
+ Point convertPointFromNodeToPage(Node node, Point point) {
+ var result = _convertPointFromNodeToPage(node,
+ new _DomPoint(point.x, point.y));
+ return new Point(result.x, result.y);
+ }
+
+ @DomName('DOMWindow.convertPointFromPageToNode')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.SAFARI)
+ @Experimental
+ Point convertPointFromPageToNode(Node node, Point point) {
+ var result = _convertPointFromPageToNode(node,
+ new _DomPoint(point.x, point.y));
+ return new Point(result.x, result.y);
+ }
+
+ /**
+ * Checks whether [convertPointFromNodeToPage] and
+ * [convertPointFromPageToNode] are supported on the current platform.
+ */
+ static bool get supportsPointConversions => _DomPoint.supported;
+
@DomName('DOMWindow.DOMContentLoadedEvent')
@DocsEditable
static const EventStreamProvider<Event> contentLoadedEvent = const EventStreamProvider<Event>('DOMContentLoaded');
- @DomName('DOMWindow.beforeunloadEvent')
- @DocsEditable
- static const EventStreamProvider<Event> beforeUnloadEvent = const EventStreamProvider<Event>('beforeunload');
-
@DomName('DOMWindow.devicemotionEvent')
@DocsEditable
static const EventStreamProvider<DeviceMotionEvent> deviceMotionEvent = const EventStreamProvider<DeviceMotionEvent>('devicemotion');
@@ -25582,7 +24627,6 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
@Creates('SqlDatabase')
- @Creates('SqlDatabaseSync')
SqlDatabase openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native;
@DomName('DOMWindow.postMessage')
@@ -25663,7 +24707,7 @@
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- DomPoint convertPointFromNodeToPage(Node node, DomPoint p) native;
+ _DomPoint _convertPointFromNodeToPage(Node node, _DomPoint p) native;
@JSName('webkitConvertPointFromPageToNode')
@DomName('DOMWindow.webkitConvertPointFromPageToNode')
@@ -25671,7 +24715,7 @@
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- DomPoint convertPointFromPageToNode(Node node, DomPoint p) native;
+ _DomPoint _convertPointFromPageToNode(Node node, _DomPoint p) native;
@JSName('webkitRequestFileSystem')
@DomName('DOMWindow.webkitRequestFileSystem')
@@ -25721,10 +24765,6 @@
@DocsEditable
Stream<Event> get onAbort => Element.abortEvent.forTarget(this);
- @DomName('DOMWindow.onbeforeunload')
- @DocsEditable
- Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
-
@DomName('DOMWindow.onblur')
@DocsEditable
Stream<Event> get onBlur => Element.blurEvent.forTarget(this);
@@ -25929,6 +24969,70 @@
@DocsEditable
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
+
+ @DomName('DOMWindow.beforeunloadEvent')
+ @DocsEditable
+ static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
+ const _BeforeUnloadEventStreamProvider('beforeunload');
+
+ @DomName('DOMWindow.onbeforeunload')
+ @DocsEditable
+ Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
+}
+
+/**
+ * Event object that is fired before the window is closed.
+ *
+ * The standard window close behavior can be prevented by setting the
+ * [returnValue]. This will display a dialog to the user confirming that they
+ * want to close the page.
+ */
+abstract class BeforeUnloadEvent implements Event {
+ /**
+ * If set to a non-null value, a dialog will be presented to the user
+ * confirming that they want to close the page.
+ */
+ String returnValue;
+}
+
+class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent {
+ String _returnValue;
+
+ _BeforeUnloadEvent(Event base): super(base);
+
+ String get returnValue => _returnValue;
+
+ void set returnValue(String value) {
+ _returnValue = value;
+ // FF and IE use the value as the return value, Chrome will return this from
+ // the event callback function.
+ if (JS('bool', '("returnValue" in #)', _base)) {
+ JS('void', '#.returnValue = #', _base, value);
+ }
+ }
+}
+
+class _BeforeUnloadEventStreamProvider implements
+ EventStreamProvider<BeforeUnloadEvent> {
+ final String _eventType;
+
+ const _BeforeUnloadEventStreamProvider(this._eventType);
+
+ Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) {
+ var controller = new StreamController.broadcast();
+ var stream = new _EventStream(e, _eventType, useCapture);
+ stream.listen((event) {
+ var wrapped = new _BeforeUnloadEvent(event);
+ controller.add(wrapped);
+ return wrapped.returnValue;
+ });
+
+ return controller.stream;
+ }
+
+ String getEventType(EventTarget target) {
+ return _eventType;
+ }
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -25937,6 +25041,10 @@
@DocsEditable
@DomName('Worker')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.FIREFOX)
+@SupportedBrowser(SupportedBrowser.IE, '10')
+@SupportedBrowser(SupportedBrowser.SAFARI)
class Worker extends AbstractWorker native "*Worker" {
@DomName('Worker.messageEvent')
@@ -25950,26 +25058,12 @@
}
static Worker _create_1(scriptUrl) => JS('Worker', 'new Worker(#)', scriptUrl);
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => JS('bool', '(typeof window.Worker != "undefined")');
+
@DomName('Worker.postMessage')
@DocsEditable
- void postMessage(/*SerializedScriptValue*/ message, [List messagePorts]) {
- if (?messagePorts) {
- var message_1 = convertDartToNative_SerializedScriptValue(message);
- _postMessage_1(message_1, messagePorts);
- return;
- }
- var message_2 = convertDartToNative_SerializedScriptValue(message);
- _postMessage_2(message_2);
- return;
- }
- @JSName('postMessage')
- @DomName('Worker.postMessage')
- @DocsEditable
- void _postMessage_1(message, List messagePorts) native;
- @JSName('postMessage')
- @DomName('Worker.postMessage')
- @DocsEditable
- void _postMessage_2(message) native;
+ void postMessage(/*SerializedScriptValue*/ message, [List messagePorts]) native;
@DomName('Worker.terminate')
@DocsEditable
@@ -25979,313 +25073,6 @@
@DocsEditable
Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
}
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DomName('WorkerContext')
-class WorkerContext extends EventTarget native "*WorkerContext" {
- /**
- * Gets an instance of the Indexed DB factory to being using Indexed DB.
- *
- * Use [IdbFactory.supported] to check if Indexed DB is supported on the
- * current platform.
- */
- @SupportedBrowser(SupportedBrowser.CHROME, '23.0')
- @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
- @SupportedBrowser(SupportedBrowser.IE, '10.0')
- @Experimental
- IdbFactory get indexedDB =>
- JS('IdbFactory',
- '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
- this, this, this);
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. Returns a [Future] whose value stores a reference to the
- * sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystem')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
- return _requestFileSystem(persistent? 1 : 0, size);
- }
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. This call will block until a reference to the synchronous file
- * system API has been obtained. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystemSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- FileSystemSync requestFileSystemSync(int size, {bool persistent: false}) {
- return _requestFileSystemSync(persistent? 1 : 0, size);
- }
-
- @DomName('WorkerContext.errorEvent')
- @DocsEditable
- static const EventStreamProvider<Event> errorEvent = const EventStreamProvider<Event>('error');
-
- static const int PERSISTENT = 1;
-
- static const int TEMPORARY = 0;
-
- @DomName('WorkerContext.location')
- @DocsEditable
- final WorkerLocation location;
-
- @DomName('WorkerContext.navigator')
- @DocsEditable
- final WorkerNavigator navigator;
-
- @DomName('WorkerContext.self')
- @DocsEditable
- final WorkerContext self;
-
- @JSName('webkitNotifications')
- @DomName('WorkerContext.webkitNotifications')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- final NotificationCenter notifications;
-
- @JSName('addEventListener')
- @DomName('WorkerContext.addEventListener')
- @DocsEditable
- void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) native;
-
- @DomName('WorkerContext.clearInterval')
- @DocsEditable
- void clearInterval(int handle) native;
-
- @DomName('WorkerContext.clearTimeout')
- @DocsEditable
- void clearTimeout(int handle) native;
-
- @DomName('WorkerContext.close')
- @DocsEditable
- void close() native;
-
- @DomName('WorkerContext.dispatchEvent')
- @DocsEditable
- bool dispatchEvent(Event evt) native;
-
- @DomName('WorkerContext.importScripts')
- @DocsEditable
- void importScripts() native;
-
- @DomName('WorkerContext.openDatabase')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- SqlDatabase openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native;
-
- @DomName('WorkerContext.openDatabaseSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- SqlDatabaseSync openDatabaseSync(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native;
-
- @JSName('removeEventListener')
- @DomName('WorkerContext.removeEventListener')
- @DocsEditable
- void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native;
-
- @DomName('WorkerContext.setInterval')
- @DocsEditable
- int setInterval(Object handler, int timeout) native;
-
- @DomName('WorkerContext.setTimeout')
- @DocsEditable
- int setTimeout(Object handler, int timeout) native;
-
- @JSName('webkitRequestFileSystem')
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. Returns a [Future] whose value stores a reference to the
- * sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystem')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- void __requestFileSystem(int type, int size, [_FileSystemCallback successCallback, _ErrorCallback errorCallback]) native;
-
- @JSName('webkitRequestFileSystem')
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. Returns a [Future] whose value stores a reference to the
- * sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystem')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- Future<FileSystem> _requestFileSystem(int type, int size) {
- var completer = new Completer<FileSystem>();
- __requestFileSystem(type, size,
- (value) { completer.complete(value); },
- (error) { completer.completeError(error); });
- return completer.future;
- }
-
- @JSName('webkitRequestFileSystemSync')
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. This call will block until a reference to the synchronous file
- * system API has been obtained. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystemSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- FileSystemSync _requestFileSystemSync(int type, int size) native;
-
- @JSName('webkitResolveLocalFileSystemSyncURL')
- @DomName('WorkerContext.webkitResolveLocalFileSystemSyncURL')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- EntrySync resolveLocalFileSystemSyncUrl(String url) native;
-
- @JSName('webkitResolveLocalFileSystemURL')
- @DomName('WorkerContext.webkitResolveLocalFileSystemURL')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- void _resolveLocalFileSystemUrl(String url, _EntryCallback successCallback, [_ErrorCallback errorCallback]) native;
-
- @JSName('webkitResolveLocalFileSystemURL')
- @DomName('WorkerContext.webkitResolveLocalFileSystemURL')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- Future<Entry> resolveLocalFileSystemUrl(String url) {
- var completer = new Completer<Entry>();
- _resolveLocalFileSystemUrl(url,
- (value) { completer.complete(value); },
- (error) { completer.completeError(error); });
- return completer.future;
- }
-
- @DomName('WorkerContext.onerror')
- @DocsEditable
- Stream<Event> get onError => errorEvent.forTarget(this);
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('WorkerLocation')
-class WorkerLocation native "*WorkerLocation" {
-
- @DomName('WorkerLocation.hash')
- @DocsEditable
- final String hash;
-
- @DomName('WorkerLocation.host')
- @DocsEditable
- final String host;
-
- @DomName('WorkerLocation.hostname')
- @DocsEditable
- final String hostname;
-
- @DomName('WorkerLocation.href')
- @DocsEditable
- final String href;
-
- @DomName('WorkerLocation.pathname')
- @DocsEditable
- final String pathname;
-
- @DomName('WorkerLocation.port')
- @DocsEditable
- final String port;
-
- @DomName('WorkerLocation.protocol')
- @DocsEditable
- final String protocol;
-
- @DomName('WorkerLocation.search')
- @DocsEditable
- final String search;
-
- @DomName('WorkerLocation.toString')
- @DocsEditable
- String toString() native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('WorkerNavigator')
-class WorkerNavigator native "*WorkerNavigator" {
-
- @DomName('WorkerNavigator.appName')
- @DocsEditable
- final String appName;
-
- @DomName('WorkerNavigator.appVersion')
- @DocsEditable
- final String appVersion;
-
- @DomName('WorkerNavigator.onLine')
- @DocsEditable
- final bool onLine;
-
- @DomName('WorkerNavigator.platform')
- @DocsEditable
- final String platform;
-
- @DomName('WorkerNavigator.userAgent')
- @DocsEditable
- final String userAgent;
-
- @JSName('webkitPersistentStorage')
- @DomName('WorkerNavigator.webkitPersistentStorage')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- final StorageQuota persistentStorage;
-
- @JSName('webkitTemporaryStorage')
- @DomName('WorkerNavigator.webkitTemporaryStorage')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- final StorageQuota temporaryStorage;
-}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -26509,6 +25296,24 @@
@DocsEditable
DocumentFragment transformToFragment(Node source, Document docVal) native;
}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('CSSPrimitiveValue')
+abstract class _CSSPrimitiveValue extends _CSSValue native "*CSSPrimitiveValue" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('CSSValue')
+abstract class _CSSValue native "*CSSValue" {
+}
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -26664,11 +25469,12 @@
return new FixedSizeListIterator<Rect>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Rect)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Rect reduce(Rect combine(Rect value, Rect element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Rect)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Rect element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -26676,7 +25482,7 @@
void forEach(void f(Rect element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Rect element)) =>
@@ -26778,12 +25584,6 @@
throw new StateError("More than one element");
}
- Rect min([int compare(Rect a, Rect b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Rect max([int compare(Rect a, Rect b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Rect element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -26800,14 +25600,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Rect element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -26828,17 +25620,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Rect> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Rect> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Rect>[]);
}
- List<Rect> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Rect> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Rect> mixins.
@DomName('ClientRectList.item')
@@ -26851,6 +25650,15 @@
@DocsEditable
+@DomName('Counter')
+abstract class _Counter native "*Counter" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
@DomName('CSSRuleList')
class _CssRuleList implements JavaScriptIndexingBehavior, List<CssRule> native "*CSSRuleList" {
@@ -26875,11 +25683,12 @@
return new FixedSizeListIterator<CssRule>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ CssRule reduce(CssRule combine(CssRule value, CssRule element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, CssRule element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -26887,7 +25696,7 @@
void forEach(void f(CssRule element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(CssRule element)) =>
@@ -26989,12 +25798,6 @@
throw new StateError("More than one element");
}
- CssRule min([int compare(CssRule a, CssRule b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- CssRule max([int compare(CssRule a, CssRule b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, CssRule element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -27011,14 +25814,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(CssRule element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -27039,17 +25834,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<CssRule> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<CssRule> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <CssRule>[]);
}
- List<CssRule> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, CssRule> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<CssRule> mixins.
@DomName('CSSRuleList.item')
@@ -27063,103 +25865,104 @@
@DocsEditable
@DomName('CSSValueList')
-class _CssValueList extends CssValue implements List<CssValue>, JavaScriptIndexingBehavior native "*CSSValueList" {
+class _CssValueList extends _CSSValue implements JavaScriptIndexingBehavior, List<_CSSValue> native "*CSSValueList" {
@DomName('CSSValueList.length')
@DocsEditable
int get length => JS("int", "#.length", this);
- CssValue operator[](int index) => JS("CssValue", "#[#]", this, index);
+ _CSSValue operator[](int index) => JS("_CSSValue", "#[#]", this, index);
- void operator[]=(int index, CssValue value) {
+ void operator[]=(int index, _CSSValue value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
- // -- start List<CssValue> mixins.
- // CssValue is the element type.
+ // -- start List<_CSSValue> mixins.
+ // _CSSValue is the element type.
- // From Iterable<CssValue>:
+ // From Iterable<_CSSValue>:
- Iterator<CssValue> get iterator {
+ Iterator<_CSSValue> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
- return new FixedSizeListIterator<CssValue>(this);
+ return new FixedSizeListIterator<_CSSValue>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ _CSSValue reduce(_CSSValue combine(_CSSValue value, _CSSValue element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, _CSSValue element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
- bool contains(CssValue element) => IterableMixinWorkaround.contains(this, element);
+ bool contains(_CSSValue element) => IterableMixinWorkaround.contains(this, element);
- void forEach(void f(CssValue element)) => IterableMixinWorkaround.forEach(this, f);
+ void forEach(void f(_CSSValue element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
- Iterable map(f(CssValue element)) =>
+ Iterable map(f(_CSSValue element)) =>
IterableMixinWorkaround.mapList(this, f);
- Iterable<CssValue> where(bool f(CssValue element)) =>
+ Iterable<_CSSValue> where(bool f(_CSSValue element)) =>
IterableMixinWorkaround.where(this, f);
- Iterable expand(Iterable f(CssValue element)) =>
+ Iterable expand(Iterable f(_CSSValue element)) =>
IterableMixinWorkaround.expand(this, f);
- bool every(bool f(CssValue element)) => IterableMixinWorkaround.every(this, f);
+ bool every(bool f(_CSSValue element)) => IterableMixinWorkaround.every(this, f);
- bool any(bool f(CssValue element)) => IterableMixinWorkaround.any(this, f);
+ bool any(bool f(_CSSValue element)) => IterableMixinWorkaround.any(this, f);
- List<CssValue> toList({ bool growable: true }) =>
- new List<CssValue>.from(this, growable: growable);
+ List<_CSSValue> toList({ bool growable: true }) =>
+ new List<_CSSValue>.from(this, growable: growable);
- Set<CssValue> toSet() => new Set<CssValue>.from(this);
+ Set<_CSSValue> toSet() => new Set<_CSSValue>.from(this);
bool get isEmpty => this.length == 0;
- Iterable<CssValue> take(int n) => IterableMixinWorkaround.takeList(this, n);
+ Iterable<_CSSValue> take(int n) => IterableMixinWorkaround.takeList(this, n);
- Iterable<CssValue> takeWhile(bool test(CssValue value)) {
+ Iterable<_CSSValue> takeWhile(bool test(_CSSValue value)) {
return IterableMixinWorkaround.takeWhile(this, test);
}
- Iterable<CssValue> skip(int n) => IterableMixinWorkaround.skipList(this, n);
+ Iterable<_CSSValue> skip(int n) => IterableMixinWorkaround.skipList(this, n);
- Iterable<CssValue> skipWhile(bool test(CssValue value)) {
+ Iterable<_CSSValue> skipWhile(bool test(_CSSValue value)) {
return IterableMixinWorkaround.skipWhile(this, test);
}
- CssValue firstWhere(bool test(CssValue value), { CssValue orElse() }) {
+ _CSSValue firstWhere(bool test(_CSSValue value), { _CSSValue orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
- CssValue lastWhere(bool test(CssValue value), {CssValue orElse()}) {
+ _CSSValue lastWhere(bool test(_CSSValue value), {_CSSValue orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
- CssValue singleWhere(bool test(CssValue value)) {
+ _CSSValue singleWhere(bool test(_CSSValue value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
- CssValue elementAt(int index) {
+ _CSSValue elementAt(int index) {
return this[index];
}
- // From Collection<CssValue>:
+ // From Collection<_CSSValue>:
- void add(CssValue value) {
+ void add(_CSSValue value) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- void addAll(Iterable<CssValue> iterable) {
+ void addAll(Iterable<_CSSValue> iterable) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- // From List<CssValue>:
+ // From List<_CSSValue>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
}
@@ -27168,53 +25971,47 @@
throw new UnsupportedError("Cannot clear immutable List.");
}
- Iterable<CssValue> get reversed {
+ Iterable<_CSSValue> get reversed {
return IterableMixinWorkaround.reversedList(this);
}
- void sort([int compare(CssValue a, CssValue b)]) {
+ void sort([int compare(_CSSValue a, _CSSValue b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(CssValue element, [int start = 0]) =>
+ int indexOf(_CSSValue element, [int start = 0]) =>
Lists.indexOf(this, element, start, this.length);
- int lastIndexOf(CssValue element, [int start]) {
+ int lastIndexOf(_CSSValue element, [int start]) {
if (start == null) start = length - 1;
return Lists.lastIndexOf(this, element, start);
}
- CssValue get first {
+ _CSSValue get first {
if (this.length > 0) return this[0];
throw new StateError("No elements");
}
- CssValue get last {
+ _CSSValue get last {
if (this.length > 0) return this[this.length - 1];
throw new StateError("No elements");
}
- CssValue get single {
+ _CSSValue get single {
if (length == 1) return this[0];
if (length == 0) throw new StateError("No elements");
throw new StateError("More than one element");
}
- CssValue min([int compare(CssValue a, CssValue b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- CssValue max([int compare(CssValue a, CssValue b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
- void insert(int index, CssValue element) {
+ void insert(int index, _CSSValue element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- CssValue removeAt(int pos) {
+ _CSSValue removeAt(int pos) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- CssValue removeLast() {
+ _CSSValue removeLast() {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -27222,23 +26019,15 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
+ void removeWhere(bool test(_CSSValue element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void retainAll(Iterable elements) {
+ void retainWhere(bool test(_CSSValue element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeWhere(bool test(CssValue element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainWhere(bool test(CssValue element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void setRange(int start, int rangeLength, List<CssValue> from, [int startFrom]) {
+ void setRange(int start, int rangeLength, List<_CSSValue> from, [int startFrom]) {
throw new UnsupportedError("Cannot setRange on immutable List.");
}
@@ -27246,26 +26035,101 @@
throw new UnsupportedError("Cannot removeRange on immutable List.");
}
- void insertRange(int start, int rangeLength, [CssValue initialValue]) {
+ void insertRange(int start, int rangeLength, [_CSSValue initialValue]) {
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
- List<CssValue> sublist(int start, [int end]) {
+ Iterable<_CSSValue> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
+ List<_CSSValue> sublist(int start, [int end]) {
if (end == null) end = length;
- return Lists.getRange(this, start, end, <CssValue>[]);
+ return Lists.getRange(this, start, end, <_CSSValue>[]);
}
- List<CssValue> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- Map<int, CssValue> asMap() =>
+ Map<int, _CSSValue> asMap() =>
IterableMixinWorkaround.asMapList(this);
- // -- end List<CssValue> mixins.
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
+ // -- end List<_CSSValue> mixins.
@DomName('CSSValueList.item')
@DocsEditable
- CssValue item(int index) native;
+ _CSSValue item(int index) native;
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('DOMFileSystemSync')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@Experimental
+abstract class _DOMFileSystemSync native "*DOMFileSystemSync" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('DedicatedWorkerContext')
+abstract class _DedicatedWorkerContext extends _WorkerContext native "*DedicatedWorkerContext" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('DirectoryEntrySync')
+abstract class _DirectoryEntrySync extends _EntrySync native "*DirectoryEntrySync" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('DirectoryReaderSync')
+abstract class _DirectoryReaderSync native "*DirectoryReaderSync" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('WebKitPoint')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.SAFARI)
+@Experimental
+class _DomPoint native "*WebKitPoint" {
+
+ @DomName('WebKitPoint.WebKitPoint')
+ @DocsEditable
+ factory _DomPoint(num x, num y) {
+ return _DomPoint._create_1(x, y);
+ }
+ static _DomPoint _create_1(x, y) => JS('_DomPoint', 'new WebKitPoint(#,#)', x, y);
+
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => JS('bool', '!!(window.WebKitPoint)');
+
+ @DomName('WebKitPoint.x')
+ @DocsEditable
+ num x;
+
+ @DomName('WebKitPoint.y')
+ @DocsEditable
+ num y;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27297,11 +26161,12 @@
return new FixedSizeListIterator<Entry>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Entry)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Entry reduce(Entry combine(Entry value, Entry element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Entry)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Entry element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -27309,7 +26174,7 @@
void forEach(void f(Entry element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Entry element)) =>
@@ -27411,12 +26276,6 @@
throw new StateError("More than one element");
}
- Entry min([int compare(Entry a, Entry b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Entry max([int compare(Entry a, Entry b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Entry element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -27433,14 +26292,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Entry element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -27461,17 +26312,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Entry> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Entry> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Entry>[]);
}
- List<Entry> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Entry> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Entry> mixins.
@DomName('EntryArray.item')
@@ -27485,103 +26343,104 @@
@DocsEditable
@DomName('EntryArraySync')
-class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> native "*EntryArraySync" {
+class _EntryArraySync implements JavaScriptIndexingBehavior, List<_EntrySync> native "*EntryArraySync" {
@DomName('EntryArraySync.length')
@DocsEditable
int get length => JS("int", "#.length", this);
- EntrySync operator[](int index) => JS("EntrySync", "#[#]", this, index);
+ _EntrySync operator[](int index) => JS("_EntrySync", "#[#]", this, index);
- void operator[]=(int index, EntrySync value) {
+ void operator[]=(int index, _EntrySync value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
- // -- start List<EntrySync> mixins.
- // EntrySync is the element type.
+ // -- start List<_EntrySync> mixins.
+ // _EntrySync is the element type.
- // From Iterable<EntrySync>:
+ // From Iterable<_EntrySync>:
- Iterator<EntrySync> get iterator {
+ Iterator<_EntrySync> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
- return new FixedSizeListIterator<EntrySync>(this);
+ return new FixedSizeListIterator<_EntrySync>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ _EntrySync reduce(_EntrySync combine(_EntrySync value, _EntrySync element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, _EntrySync element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
- bool contains(EntrySync element) => IterableMixinWorkaround.contains(this, element);
+ bool contains(_EntrySync element) => IterableMixinWorkaround.contains(this, element);
- void forEach(void f(EntrySync element)) => IterableMixinWorkaround.forEach(this, f);
+ void forEach(void f(_EntrySync element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
- Iterable map(f(EntrySync element)) =>
+ Iterable map(f(_EntrySync element)) =>
IterableMixinWorkaround.mapList(this, f);
- Iterable<EntrySync> where(bool f(EntrySync element)) =>
+ Iterable<_EntrySync> where(bool f(_EntrySync element)) =>
IterableMixinWorkaround.where(this, f);
- Iterable expand(Iterable f(EntrySync element)) =>
+ Iterable expand(Iterable f(_EntrySync element)) =>
IterableMixinWorkaround.expand(this, f);
- bool every(bool f(EntrySync element)) => IterableMixinWorkaround.every(this, f);
+ bool every(bool f(_EntrySync element)) => IterableMixinWorkaround.every(this, f);
- bool any(bool f(EntrySync element)) => IterableMixinWorkaround.any(this, f);
+ bool any(bool f(_EntrySync element)) => IterableMixinWorkaround.any(this, f);
- List<EntrySync> toList({ bool growable: true }) =>
- new List<EntrySync>.from(this, growable: growable);
+ List<_EntrySync> toList({ bool growable: true }) =>
+ new List<_EntrySync>.from(this, growable: growable);
- Set<EntrySync> toSet() => new Set<EntrySync>.from(this);
+ Set<_EntrySync> toSet() => new Set<_EntrySync>.from(this);
bool get isEmpty => this.length == 0;
- Iterable<EntrySync> take(int n) => IterableMixinWorkaround.takeList(this, n);
+ Iterable<_EntrySync> take(int n) => IterableMixinWorkaround.takeList(this, n);
- Iterable<EntrySync> takeWhile(bool test(EntrySync value)) {
+ Iterable<_EntrySync> takeWhile(bool test(_EntrySync value)) {
return IterableMixinWorkaround.takeWhile(this, test);
}
- Iterable<EntrySync> skip(int n) => IterableMixinWorkaround.skipList(this, n);
+ Iterable<_EntrySync> skip(int n) => IterableMixinWorkaround.skipList(this, n);
- Iterable<EntrySync> skipWhile(bool test(EntrySync value)) {
+ Iterable<_EntrySync> skipWhile(bool test(_EntrySync value)) {
return IterableMixinWorkaround.skipWhile(this, test);
}
- EntrySync firstWhere(bool test(EntrySync value), { EntrySync orElse() }) {
+ _EntrySync firstWhere(bool test(_EntrySync value), { _EntrySync orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
- EntrySync lastWhere(bool test(EntrySync value), {EntrySync orElse()}) {
+ _EntrySync lastWhere(bool test(_EntrySync value), {_EntrySync orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
- EntrySync singleWhere(bool test(EntrySync value)) {
+ _EntrySync singleWhere(bool test(_EntrySync value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
- EntrySync elementAt(int index) {
+ _EntrySync elementAt(int index) {
return this[index];
}
- // From Collection<EntrySync>:
+ // From Collection<_EntrySync>:
- void add(EntrySync value) {
+ void add(_EntrySync value) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- void addAll(Iterable<EntrySync> iterable) {
+ void addAll(Iterable<_EntrySync> iterable) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- // From List<EntrySync>:
+ // From List<_EntrySync>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
}
@@ -27590,53 +26449,47 @@
throw new UnsupportedError("Cannot clear immutable List.");
}
- Iterable<EntrySync> get reversed {
+ Iterable<_EntrySync> get reversed {
return IterableMixinWorkaround.reversedList(this);
}
- void sort([int compare(EntrySync a, EntrySync b)]) {
+ void sort([int compare(_EntrySync a, _EntrySync b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(EntrySync element, [int start = 0]) =>
+ int indexOf(_EntrySync element, [int start = 0]) =>
Lists.indexOf(this, element, start, this.length);
- int lastIndexOf(EntrySync element, [int start]) {
+ int lastIndexOf(_EntrySync element, [int start]) {
if (start == null) start = length - 1;
return Lists.lastIndexOf(this, element, start);
}
- EntrySync get first {
+ _EntrySync get first {
if (this.length > 0) return this[0];
throw new StateError("No elements");
}
- EntrySync get last {
+ _EntrySync get last {
if (this.length > 0) return this[this.length - 1];
throw new StateError("No elements");
}
- EntrySync get single {
+ _EntrySync get single {
if (length == 1) return this[0];
if (length == 0) throw new StateError("No elements");
throw new StateError("More than one element");
}
- EntrySync min([int compare(EntrySync a, EntrySync b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- EntrySync max([int compare(EntrySync a, EntrySync b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
- void insert(int index, EntrySync element) {
+ void insert(int index, _EntrySync element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- EntrySync removeAt(int pos) {
+ _EntrySync removeAt(int pos) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- EntrySync removeLast() {
+ _EntrySync removeLast() {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -27644,23 +26497,15 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
+ void removeWhere(bool test(_EntrySync element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void retainAll(Iterable elements) {
+ void retainWhere(bool test(_EntrySync element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeWhere(bool test(EntrySync element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainWhere(bool test(EntrySync element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void setRange(int start, int rangeLength, List<EntrySync> from, [int startFrom]) {
+ void setRange(int start, int rangeLength, List<_EntrySync> from, [int startFrom]) {
throw new UnsupportedError("Cannot setRange on immutable List.");
}
@@ -27668,26 +26513,76 @@
throw new UnsupportedError("Cannot removeRange on immutable List.");
}
- void insertRange(int start, int rangeLength, [EntrySync initialValue]) {
+ void insertRange(int start, int rangeLength, [_EntrySync initialValue]) {
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
- List<EntrySync> sublist(int start, [int end]) {
+ Iterable<_EntrySync> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
+ List<_EntrySync> sublist(int start, [int end]) {
if (end == null) end = length;
- return Lists.getRange(this, start, end, <EntrySync>[]);
+ return Lists.getRange(this, start, end, <_EntrySync>[]);
}
- List<EntrySync> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- Map<int, EntrySync> asMap() =>
+ Map<int, _EntrySync> asMap() =>
IterableMixinWorkaround.asMapList(this);
- // -- end List<EntrySync> mixins.
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
+ // -- end List<_EntrySync> mixins.
@DomName('EntryArraySync.item')
@DocsEditable
- EntrySync item(int index) native;
+ _EntrySync item(int index) native;
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('EntrySync')
+abstract class _EntrySync native "*EntrySync" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('FileEntrySync')
+abstract class _FileEntrySync extends _EntrySync native "*FileEntrySync" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('FileReaderSync')
+abstract class _FileReaderSync native "*FileReaderSync" {
+
+ @DomName('FileReaderSync.FileReaderSync')
+ @DocsEditable
+ factory _FileReaderSync() {
+ return _FileReaderSync._create_1();
+ }
+ static _FileReaderSync _create_1() => JS('_FileReaderSync', 'new FileReaderSync()');
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('FileWriterSync')
+abstract class _FileWriterSync native "*FileWriterSync" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27719,11 +26614,12 @@
return new FixedSizeListIterator<Gamepad>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Gamepad reduce(Gamepad combine(Gamepad value, Gamepad element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Gamepad element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -27731,7 +26627,7 @@
void forEach(void f(Gamepad element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Gamepad element)) =>
@@ -27833,12 +26729,6 @@
throw new StateError("More than one element");
}
- Gamepad min([int compare(Gamepad a, Gamepad b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Gamepad max([int compare(Gamepad a, Gamepad b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Gamepad element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -27855,14 +26745,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Gamepad element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -27883,17 +26765,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Gamepad> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Gamepad> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Gamepad>[]);
}
- List<Gamepad> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Gamepad> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Gamepad> mixins.
@DomName('GamepadList.item')
@@ -27907,7 +26796,7 @@
@DocsEditable
@DomName('HTMLAppletElement')
-class _HTMLAppletElement extends Element native "*HTMLAppletElement" {
+abstract class _HTMLAppletElement extends Element native "*HTMLAppletElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27916,7 +26805,7 @@
@DocsEditable
@DomName('HTMLBaseFontElement')
-class _HTMLBaseFontElement extends Element native "*HTMLBaseFontElement" {
+abstract class _HTMLBaseFontElement extends Element native "*HTMLBaseFontElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27925,7 +26814,7 @@
@DocsEditable
@DomName('HTMLDirectoryElement')
-class _HTMLDirectoryElement extends Element native "*HTMLDirectoryElement" {
+abstract class _HTMLDirectoryElement extends Element native "*HTMLDirectoryElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27934,7 +26823,7 @@
@DocsEditable
@DomName('HTMLFontElement')
-class _HTMLFontElement extends Element native "*HTMLFontElement" {
+abstract class _HTMLFontElement extends Element native "*HTMLFontElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27943,7 +26832,7 @@
@DocsEditable
@DomName('HTMLFrameElement')
-class _HTMLFrameElement extends Element native "*HTMLFrameElement" {
+abstract class _HTMLFrameElement extends Element native "*HTMLFrameElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27952,7 +26841,7 @@
@DocsEditable
@DomName('HTMLFrameSetElement')
-class _HTMLFrameSetElement extends Element native "*HTMLFrameSetElement" {
+abstract class _HTMLFrameSetElement extends Element native "*HTMLFrameSetElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27961,7 +26850,7 @@
@DocsEditable
@DomName('HTMLMarqueeElement')
-class _HTMLMarqueeElement extends Element native "*HTMLMarqueeElement" {
+abstract class _HTMLMarqueeElement extends Element native "*HTMLMarqueeElement" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27993,11 +26882,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -28005,7 +26895,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -28107,12 +26997,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -28129,14 +27013,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -28157,17 +27033,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('NamedNodeMap.getNamedItem')
@@ -28204,6 +27087,53 @@
@DocsEditable
+@DomName('RGBColor')
+abstract class _RGBColor native "*RGBColor" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('Rect')
+abstract class _Rect native "*Rect" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SharedWorker')
+abstract class _SharedWorker extends AbstractWorker native "*SharedWorker" {
+
+ @DomName('SharedWorker.SharedWorker')
+ @DocsEditable
+ factory _SharedWorker(String scriptURL, [String name]) {
+ if (?name) {
+ return _SharedWorker._create_1(scriptURL, name);
+ }
+ return _SharedWorker._create_2(scriptURL);
+ }
+ static _SharedWorker _create_1(scriptURL, name) => JS('_SharedWorker', 'new SharedWorker(#,#)', scriptURL, name);
+ static _SharedWorker _create_2(scriptURL) => JS('_SharedWorker', 'new SharedWorker(#)', scriptURL);
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SharedWorkerContext')
+abstract class _SharedWorkerContext extends _WorkerContext native "*SharedWorkerContext" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
@DomName('SpeechInputResultList')
class _SpeechInputResultList implements JavaScriptIndexingBehavior, List<SpeechInputResult> native "*SpeechInputResultList" {
@@ -28228,11 +27158,12 @@
return new FixedSizeListIterator<SpeechInputResult>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SpeechInputResult reduce(SpeechInputResult combine(SpeechInputResult value, SpeechInputResult element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SpeechInputResult element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -28240,7 +27171,7 @@
void forEach(void f(SpeechInputResult element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SpeechInputResult element)) =>
@@ -28342,12 +27273,6 @@
throw new StateError("More than one element");
}
- SpeechInputResult min([int compare(SpeechInputResult a, SpeechInputResult b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SpeechInputResult max([int compare(SpeechInputResult a, SpeechInputResult b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SpeechInputResult element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -28364,14 +27289,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SpeechInputResult element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -28392,17 +27309,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SpeechInputResult> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SpeechInputResult> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SpeechInputResult>[]);
}
- List<SpeechInputResult> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SpeechInputResult> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SpeechInputResult> mixins.
@DomName('SpeechInputResultList.item')
@@ -28439,11 +27363,12 @@
return new FixedSizeListIterator<SpeechRecognitionResult>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SpeechRecognitionResult reduce(SpeechRecognitionResult combine(SpeechRecognitionResult value, SpeechRecognitionResult element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SpeechRecognitionResult element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -28451,7 +27376,7 @@
void forEach(void f(SpeechRecognitionResult element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SpeechRecognitionResult element)) =>
@@ -28553,12 +27478,6 @@
throw new StateError("More than one element");
}
- SpeechRecognitionResult min([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SpeechRecognitionResult max([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SpeechRecognitionResult element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -28575,14 +27494,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SpeechRecognitionResult element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -28603,17 +27514,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SpeechRecognitionResult> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SpeechRecognitionResult> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SpeechRecognitionResult>[]);
}
- List<SpeechRecognitionResult> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SpeechRecognitionResult> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SpeechRecognitionResult> mixins.
@DomName('SpeechRecognitionResultList.item')
@@ -28650,11 +27568,12 @@
return new FixedSizeListIterator<StyleSheet>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ StyleSheet reduce(StyleSheet combine(StyleSheet value, StyleSheet element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, StyleSheet element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -28662,7 +27581,7 @@
void forEach(void f(StyleSheet element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(StyleSheet element)) =>
@@ -28764,12 +27683,6 @@
throw new StateError("More than one element");
}
- StyleSheet min([int compare(StyleSheet a, StyleSheet b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- StyleSheet max([int compare(StyleSheet a, StyleSheet b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, StyleSheet element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -28786,14 +27699,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(StyleSheet element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -28814,17 +27719,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<StyleSheet> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<StyleSheet> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <StyleSheet>[]);
}
- List<StyleSheet> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, StyleSheet> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<StyleSheet> mixins.
@DomName('StyleSheetList.item')
@@ -28836,6 +27748,56 @@
// BSD-style license that can be found in the LICENSE file.
+@DocsEditable
+@DomName('WebKitCSSFilterValue')
+abstract class _WebKitCSSFilterValue extends _CssValueList native "*WebKitCSSFilterValue" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('WebKitCSSMatrix')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.SAFARI)
+@Experimental
+abstract class _WebKitCSSMatrix native "*WebKitCSSMatrix" {
+
+ @DomName('WebKitCSSMatrix.WebKitCSSMatrix')
+ @DocsEditable
+ factory _WebKitCSSMatrix([String cssValue]) {
+ if (?cssValue) {
+ return _WebKitCSSMatrix._create_1(cssValue);
+ }
+ return _WebKitCSSMatrix._create_2();
+ }
+ static _WebKitCSSMatrix _create_1(cssValue) => JS('_WebKitCSSMatrix', 'new WebKitCSSMatrix(#)', cssValue);
+ static _WebKitCSSMatrix _create_2() => JS('_WebKitCSSMatrix', 'new WebKitCSSMatrix()');
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('WebKitCSSMixFunctionValue')
+abstract class _WebKitCSSMixFunctionValue extends _CssValueList native "*WebKitCSSMixFunctionValue" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('WebKitCSSTransformValue')
+abstract class _WebKitCSSTransformValue extends _CssValueList native "*WebKitCSSTransformValue" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
// This class maps WebKitTransitionEvent to TransitionEvent for older Chrome
// browser versions.
@DomName('WebKitTransitionEvent')
@@ -28858,6 +27820,33 @@
// BSD-style license that can be found in the LICENSE file.
+@DocsEditable
+@DomName('WorkerContext')
+abstract class _WorkerContext extends EventTarget native "*WorkerContext" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('WorkerLocation')
+abstract class _WorkerLocation native "*WorkerLocation" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('WorkerNavigator')
+abstract class _WorkerNavigator native "*WorkerNavigator" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
abstract class _AttributeMap implements Map<String, String> {
final Element _element;
@@ -28892,19 +27881,19 @@
}
}
- Collection<String> get keys {
+ Iterable<String> get keys {
// TODO: generate a lazy collection instead.
var attributes = _element.$dom_attributes;
var keys = new List<String>();
for (int i = 0, len = attributes.length; i < len; i++) {
if (_matches(attributes[i])) {
- keys.add(attributes[i].$dom_localName);
+ keys.add(attributes[i].localName);
}
}
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
// TODO: generate a lazy collection instead.
var attributes = _element.$dom_attributes;
var values = new List<String>();
@@ -29045,7 +28034,7 @@
});
}
- Collection<String> get keys {
+ Iterable<String> get keys {
final keys = new List<String>();
$dom_attributes.forEach((String key, String value) {
if (_matches(key)) {
@@ -29055,7 +28044,7 @@
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
final values = new List<String>();
$dom_attributes.forEach((String key, String value) {
if (_matches(key)) {
@@ -29280,7 +28269,7 @@
readClasses().forEach(f);
}
- String join([String separator]) => readClasses().join(separator);
+ String join([String separator = ""]) => readClasses().join(separator);
Iterable map(f(String element)) => readClasses().map(f);
@@ -29296,9 +28285,8 @@
int get length => readClasses().length;
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, String element)) {
- return readClasses().reduce(initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return readClasses().reduce(combine);
}
dynamic fold(dynamic initialValue,
@@ -29387,9 +28375,6 @@
_modify((s) => s.retainWhere(test));
}
- bool isSubsetOf(Collection<String> collection) =>
- readClasses().isSubsetOf(collection);
-
bool containsAll(Iterable<String> collection) =>
readClasses().containsAll(collection);
@@ -29408,10 +28393,6 @@
List<String> toList({ bool growable: true }) =>
readClasses().toList(growable: growable);
Set<String> toSet() => readClasses().toSet();
- String min([int compare(String a, String b)]) =>
- readClasses().min(compare);
- String max([int compare(String a, String b)]) =>
- readClasses().max(compare);
Iterable<String> take(int n) => readClasses().take(n);
Iterable<String> takeWhile(bool test(String value)) =>
readClasses().takeWhile(test);
@@ -29465,7 +28446,7 @@
// BSD-style license that can be found in the LICENSE file.
-typedef void EventListener(Event event);
+typedef EventListener(Event event);
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -31703,6 +30684,59 @@
/**
+ * Helper class to implement custom events which wrap DOM events.
+ */
+class _WrappedEvent implements Event {
+ final Event wrapped;
+ _WrappedEvent(this.wrapped);
+
+ bool get bubbles => wrapped.bubbles;
+
+ bool get cancelBubble => wrapped.bubbles;
+ void set cancelBubble(bool value) {
+ wrapped.cancelBubble = value;
+ }
+
+ bool get cancelable => wrapped.cancelable;
+
+ DataTransfer get clipboardData => wrapped.clipboardData;
+
+ EventTarget get currentTarget => wrapped.currentTarget;
+
+ bool get defaultPrevented => wrapped.defaultPrevented;
+
+ int get eventPhase => wrapped.eventPhase;
+
+ EventTarget get target => wrapped.target;
+
+ int get timeStamp => wrapped.timeStamp;
+
+ String get type => wrapped.type;
+
+ void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
+ bool cancelableArg) {
+ throw new UnsupportedError(
+ 'Cannot initialize this Event.');
+ }
+
+ void preventDefault() {
+ wrapped.preventDefault();
+ }
+
+ void stopImmediatePropagation() {
+ wrapped.stopImmediatePropagation();
+ }
+
+ void stopPropagation() {
+ wrapped.stopPropagation();
+ }
+}
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+/**
* A list which just wraps another list, for either intercepting list calls or
* retyping the list (for example, from List<A> to List<B> where B extends A).
*/
@@ -31725,15 +30759,15 @@
void forEach(void f(E element)) { _list.forEach(f); }
- dynamic reduce(initialValue, combine(previousValue, E element)) =>
- _list.reduce(initialValue, combine);
+ E reduce(E combine(E value, E element)) =>
+ _list.reduce(combine);
dynamic fold(initialValue, combine(previousValue, E element)) =>
_list.fold(initialValue, combine);
bool every(bool f(E element)) => _list.every(f);
- String join([String separator]) => _list.join(separator);
+ String join([String separator = ""]) => _list.join(separator);
bool any(bool f(E element)) => _list.any(f);
@@ -31744,10 +30778,6 @@
int get length => _list.length;
- E min([int compare(E a, E b)]) => _list.min(compare);
-
- E max([int compare(E a, E b)]) => _list.max(compare);
-
bool get isEmpty => _list.isEmpty;
Iterable<E> take(int n) => _list.take(n);
@@ -31782,10 +30812,6 @@
void remove(Object element) { _list.remove(element); }
- void removeAll(Iterable elements) { _list.removeAll(elements); }
-
- void retainAll(Iterable elements) { _list.retainAll(elements); }
-
void removeWhere(bool test(E element)) { _list.removeWhere(test); }
void retainWhere(bool test(E element)) { _list.retainWhere(test); }
@@ -31816,7 +30842,7 @@
List<E> sublist(int start, [int end]) => _list.sublist(start, end);
- List<E> getRange(int start, int length) => sublist(start, start + length);
+ Iterable<E> getRange(int start, int end) => _list.getRange(start, end);
void setRange(int start, int length, List<E> from, [int startFrom]) {
_list.setRange(start, length, from, startFrom);
@@ -31828,7 +30854,14 @@
_list.insertRange(start, length, fill);
}
- Map<int, E> asMap() => IterableMixinWorkaround.asMapList(_list);
+ Map<int, E> asMap() => _list.asMap();
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
}
/**
@@ -32096,7 +31129,7 @@
* on how we can make this class work with as many international keyboards as
* possible. Bugs welcome!
*/
-class KeyEvent implements KeyboardEvent {
+class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
KeyboardEvent _parent;
@@ -32131,7 +31164,7 @@
bool get _realAltKey => JS('int', '#.altKey', _parent);
/** Construct a KeyEvent with [parent] as the event we're emulating. */
- KeyEvent(KeyboardEvent parent) {
+ KeyEvent(KeyboardEvent parent): super(parent) {
_parent = parent;
_shadowAltKey = _realAltKey;
_shadowCharCode = _realCharCode;
@@ -32152,22 +31185,11 @@
/** True if the altGraphKey is pressed during this event. */
bool get altGraphKey => _parent.altGraphKey;
- bool get bubbles => _parent.bubbles;
- /** True if this event can be cancelled. */
- bool get cancelable => _parent.cancelable;
- bool get cancelBubble => _parent.cancelBubble;
- void set cancelBubble(bool cancel) {
- _parent.cancelBubble = cancel;
- }
/** Accessor to the clipboardData available for this event. */
DataTransfer get clipboardData => _parent.clipboardData;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
- /** Accessor to the target this event is listening to for changes. */
- EventTarget get currentTarget => _parent.currentTarget;
- bool get defaultPrevented => _parent.defaultPrevented;
int get detail => _parent.detail;
- int get eventPhase => _parent.eventPhase;
/**
* Accessor to the part of the keyboard that the key was pressed from (one of
* KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
@@ -32178,35 +31200,17 @@
/** True if the Meta (or Mac command) key is pressed during this event. */
bool get metaKey => _parent.metaKey;
Point get page => _parent.page;
- bool get returnValue => _parent.returnValue;
- void set returnValue(bool value) {
- _parent.returnValue = value;
- }
/** True if the shift key was pressed during this event. */
bool get shiftKey => _parent.shiftKey;
- int get timeStamp => _parent.timeStamp;
- /**
- * The type of key event that occurred. One of "keydown", "keyup", or
- * "keypress".
- */
- String get type => _parent.type;
Window get view => _parent.view;
- void preventDefault() => _parent.preventDefault();
- void stopImmediatePropagation() => _parent.stopImmediatePropagation();
- void stopPropagation() => _parent.stopPropagation();
void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
Window view, int detail) {
throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
}
- void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
- bool cancelableArg) {
- throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
- }
String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent);
int get $dom_charCode => charCode;
int get $dom_keyCode => keyCode;
- EventTarget get target => _parent.target;
String get $dom_keyIdentifier {
throw new UnsupportedError("keyIdentifier is unsupported.");
}
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index c2165db..181104f 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -829,10 +829,6 @@
class BodyElement extends _Element_Merged {
BodyElement.internal() : super.internal();
- @DomName('HTMLBodyElement.beforeunloadEvent')
- @DocsEditable
- static const EventStreamProvider<Event> beforeUnloadEvent = const EventStreamProvider<Event>('beforeunload');
-
@DomName('HTMLBodyElement.blurEvent')
@DocsEditable
static const EventStreamProvider<Event> blurEvent = const EventStreamProvider<Event>('blur');
@@ -885,10 +881,6 @@
@DocsEditable
factory BodyElement() => document.$dom_createElement("body");
- @DomName('HTMLBodyElement.onbeforeunload')
- @DocsEditable
- Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
-
@DomName('HTMLBodyElement.onblur')
@DocsEditable
Stream<Event> get onBlur => blurEvent.forTarget(this);
@@ -1137,7 +1129,7 @@
* Example usage:
*
* CanvasElement canvas = new CanvasElement();
- * var ctx = canvas.context2d
+ * var ctx = canvas.context2D
* ..fillStyle = "rgb(200,0,0)"
* ..fillRect(10, 10, 55, 50);
* var dataUrl = canvas.toDataURL("image/jpeg", 0.95);
@@ -1162,7 +1154,11 @@
@DocsEditable
String toDataUrl(String type, [num quality]) native "HTMLCanvasElement_toDataURL_Callback";
- CanvasRenderingContext2D get context2d => getContext('2d');
+ /** An API for drawing on this canvas. */
+ CanvasRenderingContext2D get context2D => getContext('2d');
+
+ @deprecated
+ CanvasRenderingContext2D get context2d => this.context2D;
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@@ -1202,7 +1198,7 @@
* Example usage:
*
* var canvas = new CanvasElement(width: 600, height: 600);
- * var ctx = canvas.context2d;
+ * var ctx = canvas.context2D;
* ctx.clearRect(0, 0, 600, 600);
* ctx.save();
* // Create radial gradient.
@@ -1256,7 +1252,7 @@
* Example usage:
*
* var canvas = new CanvasElement(width: 600, height: 600);
- * var ctx = canvas.context2d;
+ * var ctx = canvas.context2D;
* var img = new ImageElement();
* // Image src needs to be loaded before pattern is applied.
* img.onLoad.listen((event) {
@@ -1871,7 +1867,7 @@
* will allow, the image will be clipped to fit the available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
* img.width = 100;
* img.height = 100;
@@ -1929,7 +1925,7 @@
* available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
*
* ctx.drawImage(img, 100, 100);
@@ -1965,7 +1961,7 @@
* will allow, the image will be clipped to fit the available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
* img.width = 100;
* img.height = 100;
@@ -2336,31 +2332,6 @@
@DocsEditable
-@DomName('Counter')
-class Counter extends NativeFieldWrapperClass1 {
- Counter.internal();
-
- @DomName('Counter.identifier')
- @DocsEditable
- String get identifier native "Counter_identifier_Getter";
-
- @DomName('Counter.listStyle')
- @DocsEditable
- String get listStyle native "Counter_listStyle_Getter";
-
- @DomName('Counter.separator')
- @DocsEditable
- String get separator native "Counter_separator_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('Crypto')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@@ -2536,250 +2507,6 @@
@DocsEditable
-@DomName('WebKitCSSMatrix')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@SupportedBrowser(SupportedBrowser.SAFARI)
-@Experimental
-class CssMatrix extends NativeFieldWrapperClass1 {
- CssMatrix.internal();
-
- @DomName('WebKitCSSMatrix.WebKitCSSMatrix')
- @DocsEditable
- factory CssMatrix([String cssValue]) {
- return CssMatrix._create_1(cssValue);
- }
-
- @DocsEditable
- static CssMatrix _create_1(cssValue) native "WebKitCSSMatrix__create_1constructorCallback";
-
- /// Checks if this type is supported on the current platform.
- static bool get supported => true;
-
- @DomName('WebKitCSSMatrix.a')
- @DocsEditable
- num get a native "WebKitCSSMatrix_a_Getter";
-
- @DomName('WebKitCSSMatrix.a')
- @DocsEditable
- void set a(num value) native "WebKitCSSMatrix_a_Setter";
-
- @DomName('WebKitCSSMatrix.b')
- @DocsEditable
- num get b native "WebKitCSSMatrix_b_Getter";
-
- @DomName('WebKitCSSMatrix.b')
- @DocsEditable
- void set b(num value) native "WebKitCSSMatrix_b_Setter";
-
- @DomName('WebKitCSSMatrix.c')
- @DocsEditable
- num get c native "WebKitCSSMatrix_c_Getter";
-
- @DomName('WebKitCSSMatrix.c')
- @DocsEditable
- void set c(num value) native "WebKitCSSMatrix_c_Setter";
-
- @DomName('WebKitCSSMatrix.d')
- @DocsEditable
- num get d native "WebKitCSSMatrix_d_Getter";
-
- @DomName('WebKitCSSMatrix.d')
- @DocsEditable
- void set d(num value) native "WebKitCSSMatrix_d_Setter";
-
- @DomName('WebKitCSSMatrix.e')
- @DocsEditable
- num get e native "WebKitCSSMatrix_e_Getter";
-
- @DomName('WebKitCSSMatrix.e')
- @DocsEditable
- void set e(num value) native "WebKitCSSMatrix_e_Setter";
-
- @DomName('WebKitCSSMatrix.f')
- @DocsEditable
- num get f native "WebKitCSSMatrix_f_Getter";
-
- @DomName('WebKitCSSMatrix.f')
- @DocsEditable
- void set f(num value) native "WebKitCSSMatrix_f_Setter";
-
- @DomName('WebKitCSSMatrix.m11')
- @DocsEditable
- num get m11 native "WebKitCSSMatrix_m11_Getter";
-
- @DomName('WebKitCSSMatrix.m11')
- @DocsEditable
- void set m11(num value) native "WebKitCSSMatrix_m11_Setter";
-
- @DomName('WebKitCSSMatrix.m12')
- @DocsEditable
- num get m12 native "WebKitCSSMatrix_m12_Getter";
-
- @DomName('WebKitCSSMatrix.m12')
- @DocsEditable
- void set m12(num value) native "WebKitCSSMatrix_m12_Setter";
-
- @DomName('WebKitCSSMatrix.m13')
- @DocsEditable
- num get m13 native "WebKitCSSMatrix_m13_Getter";
-
- @DomName('WebKitCSSMatrix.m13')
- @DocsEditable
- void set m13(num value) native "WebKitCSSMatrix_m13_Setter";
-
- @DomName('WebKitCSSMatrix.m14')
- @DocsEditable
- num get m14 native "WebKitCSSMatrix_m14_Getter";
-
- @DomName('WebKitCSSMatrix.m14')
- @DocsEditable
- void set m14(num value) native "WebKitCSSMatrix_m14_Setter";
-
- @DomName('WebKitCSSMatrix.m21')
- @DocsEditable
- num get m21 native "WebKitCSSMatrix_m21_Getter";
-
- @DomName('WebKitCSSMatrix.m21')
- @DocsEditable
- void set m21(num value) native "WebKitCSSMatrix_m21_Setter";
-
- @DomName('WebKitCSSMatrix.m22')
- @DocsEditable
- num get m22 native "WebKitCSSMatrix_m22_Getter";
-
- @DomName('WebKitCSSMatrix.m22')
- @DocsEditable
- void set m22(num value) native "WebKitCSSMatrix_m22_Setter";
-
- @DomName('WebKitCSSMatrix.m23')
- @DocsEditable
- num get m23 native "WebKitCSSMatrix_m23_Getter";
-
- @DomName('WebKitCSSMatrix.m23')
- @DocsEditable
- void set m23(num value) native "WebKitCSSMatrix_m23_Setter";
-
- @DomName('WebKitCSSMatrix.m24')
- @DocsEditable
- num get m24 native "WebKitCSSMatrix_m24_Getter";
-
- @DomName('WebKitCSSMatrix.m24')
- @DocsEditable
- void set m24(num value) native "WebKitCSSMatrix_m24_Setter";
-
- @DomName('WebKitCSSMatrix.m31')
- @DocsEditable
- num get m31 native "WebKitCSSMatrix_m31_Getter";
-
- @DomName('WebKitCSSMatrix.m31')
- @DocsEditable
- void set m31(num value) native "WebKitCSSMatrix_m31_Setter";
-
- @DomName('WebKitCSSMatrix.m32')
- @DocsEditable
- num get m32 native "WebKitCSSMatrix_m32_Getter";
-
- @DomName('WebKitCSSMatrix.m32')
- @DocsEditable
- void set m32(num value) native "WebKitCSSMatrix_m32_Setter";
-
- @DomName('WebKitCSSMatrix.m33')
- @DocsEditable
- num get m33 native "WebKitCSSMatrix_m33_Getter";
-
- @DomName('WebKitCSSMatrix.m33')
- @DocsEditable
- void set m33(num value) native "WebKitCSSMatrix_m33_Setter";
-
- @DomName('WebKitCSSMatrix.m34')
- @DocsEditable
- num get m34 native "WebKitCSSMatrix_m34_Getter";
-
- @DomName('WebKitCSSMatrix.m34')
- @DocsEditable
- void set m34(num value) native "WebKitCSSMatrix_m34_Setter";
-
- @DomName('WebKitCSSMatrix.m41')
- @DocsEditable
- num get m41 native "WebKitCSSMatrix_m41_Getter";
-
- @DomName('WebKitCSSMatrix.m41')
- @DocsEditable
- void set m41(num value) native "WebKitCSSMatrix_m41_Setter";
-
- @DomName('WebKitCSSMatrix.m42')
- @DocsEditable
- num get m42 native "WebKitCSSMatrix_m42_Getter";
-
- @DomName('WebKitCSSMatrix.m42')
- @DocsEditable
- void set m42(num value) native "WebKitCSSMatrix_m42_Setter";
-
- @DomName('WebKitCSSMatrix.m43')
- @DocsEditable
- num get m43 native "WebKitCSSMatrix_m43_Getter";
-
- @DomName('WebKitCSSMatrix.m43')
- @DocsEditable
- void set m43(num value) native "WebKitCSSMatrix_m43_Setter";
-
- @DomName('WebKitCSSMatrix.m44')
- @DocsEditable
- num get m44 native "WebKitCSSMatrix_m44_Getter";
-
- @DomName('WebKitCSSMatrix.m44')
- @DocsEditable
- void set m44(num value) native "WebKitCSSMatrix_m44_Setter";
-
- @DomName('WebKitCSSMatrix.inverse')
- @DocsEditable
- CssMatrix inverse() native "WebKitCSSMatrix_inverse_Callback";
-
- @DomName('WebKitCSSMatrix.multiply')
- @DocsEditable
- CssMatrix multiply(CssMatrix secondMatrix) native "WebKitCSSMatrix_multiply_Callback";
-
- @DomName('WebKitCSSMatrix.rotate')
- @DocsEditable
- CssMatrix rotate(num rotX, num rotY, num rotZ) native "WebKitCSSMatrix_rotate_Callback";
-
- @DomName('WebKitCSSMatrix.rotateAxisAngle')
- @DocsEditable
- CssMatrix rotateAxisAngle(num x, num y, num z, num angle) native "WebKitCSSMatrix_rotateAxisAngle_Callback";
-
- @DomName('WebKitCSSMatrix.scale')
- @DocsEditable
- CssMatrix scale(num scaleX, num scaleY, num scaleZ) native "WebKitCSSMatrix_scale_Callback";
-
- @DomName('WebKitCSSMatrix.setMatrixValue')
- @DocsEditable
- void setMatrixValue(String string) native "WebKitCSSMatrix_setMatrixValue_Callback";
-
- @DomName('WebKitCSSMatrix.skewX')
- @DocsEditable
- CssMatrix skewX(num angle) native "WebKitCSSMatrix_skewX_Callback";
-
- @DomName('WebKitCSSMatrix.skewY')
- @DocsEditable
- CssMatrix skewY(num angle) native "WebKitCSSMatrix_skewY_Callback";
-
- @DomName('WebKitCSSMatrix.toString')
- @DocsEditable
- String toString() native "WebKitCSSMatrix_toString_Callback";
-
- @DomName('WebKitCSSMatrix.translate')
- @DocsEditable
- CssMatrix translate(num x, num y, num z) native "WebKitCSSMatrix_translate_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('CSSMediaRule')
class CssMediaRule extends CssRule {
CssMediaRule.internal() : super.internal();
@@ -2834,165 +2561,6 @@
@DocsEditable
-@DomName('CSSPrimitiveValue')
-class CssPrimitiveValue extends CssValue {
- CssPrimitiveValue.internal() : super.internal();
-
- static const int CSS_ATTR = 22;
-
- static const int CSS_CM = 6;
-
- static const int CSS_COUNTER = 23;
-
- static const int CSS_DEG = 11;
-
- static const int CSS_DIMENSION = 18;
-
- static const int CSS_EMS = 3;
-
- static const int CSS_EXS = 4;
-
- static const int CSS_GRAD = 13;
-
- static const int CSS_HZ = 16;
-
- static const int CSS_IDENT = 21;
-
- static const int CSS_IN = 8;
-
- static const int CSS_KHZ = 17;
-
- static const int CSS_MM = 7;
-
- static const int CSS_MS = 14;
-
- static const int CSS_NUMBER = 1;
-
- static const int CSS_PC = 10;
-
- static const int CSS_PERCENTAGE = 2;
-
- static const int CSS_PT = 9;
-
- static const int CSS_PX = 5;
-
- static const int CSS_RAD = 12;
-
- static const int CSS_RECT = 24;
-
- static const int CSS_RGBCOLOR = 25;
-
- static const int CSS_S = 15;
-
- static const int CSS_STRING = 19;
-
- static const int CSS_UNKNOWN = 0;
-
- static const int CSS_URI = 20;
-
- static const int CSS_VH = 27;
-
- static const int CSS_VMAX = 29;
-
- static const int CSS_VMIN = 28;
-
- static const int CSS_VW = 26;
-
- @DomName('CSSPrimitiveValue.primitiveType')
- @DocsEditable
- int get primitiveType native "CSSPrimitiveValue_primitiveType_Getter";
-
- @DomName('CSSPrimitiveValue.getCounterValue')
- @DocsEditable
- Counter getCounterValue() native "CSSPrimitiveValue_getCounterValue_Callback";
-
- @DomName('CSSPrimitiveValue.getFloatValue')
- @DocsEditable
- num getFloatValue(int unitType) native "CSSPrimitiveValue_getFloatValue_Callback";
-
- @DomName('CSSPrimitiveValue.getRGBColorValue')
- @DocsEditable
- CssRgbColor getRgbColorValue() native "CSSPrimitiveValue_getRGBColorValue_Callback";
-
- @DomName('CSSPrimitiveValue.getRectValue')
- @DocsEditable
- CssRect getRectValue() native "CSSPrimitiveValue_getRectValue_Callback";
-
- @DomName('CSSPrimitiveValue.getStringValue')
- @DocsEditable
- String getStringValue() native "CSSPrimitiveValue_getStringValue_Callback";
-
- @DomName('CSSPrimitiveValue.setFloatValue')
- @DocsEditable
- void setFloatValue(int unitType, num floatValue) native "CSSPrimitiveValue_setFloatValue_Callback";
-
- @DomName('CSSPrimitiveValue.setStringValue')
- @DocsEditable
- void setStringValue(int stringType, String stringValue) native "CSSPrimitiveValue_setStringValue_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('Rect')
-class CssRect extends NativeFieldWrapperClass1 {
- CssRect.internal();
-
- @DomName('Rect.bottom')
- @DocsEditable
- CssPrimitiveValue get bottom native "Rect_bottom_Getter";
-
- @DomName('Rect.left')
- @DocsEditable
- CssPrimitiveValue get left native "Rect_left_Getter";
-
- @DomName('Rect.right')
- @DocsEditable
- CssPrimitiveValue get right native "Rect_right_Getter";
-
- @DomName('Rect.top')
- @DocsEditable
- CssPrimitiveValue get top native "Rect_top_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('RGBColor')
-class CssRgbColor extends NativeFieldWrapperClass1 {
- CssRgbColor.internal();
-
- @DomName('RGBColor.blue')
- @DocsEditable
- CssPrimitiveValue get blue native "RGBColor_blue_Getter";
-
- @DomName('RGBColor.green')
- @DocsEditable
- CssPrimitiveValue get green native "RGBColor_green_Getter";
-
- @DomName('RGBColor.red')
- @DocsEditable
- CssPrimitiveValue get red native "RGBColor_red_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('CSSRule')
class CssRule extends NativeFieldWrapperClass1 {
CssRule.internal();
@@ -3073,10 +2641,6 @@
@DocsEditable
String _getPropertyValue(String propertyName) native "CSSStyleDeclaration__getPropertyValue_Callback";
- @DomName('CSSStyleDeclaration.getPropertyCSSValue')
- @DocsEditable
- CssValue getPropertyCssValue(String propertyName) native "CSSStyleDeclaration_getPropertyCSSValue_Callback";
-
@DomName('CSSStyleDeclaration.getPropertyPriority')
@DocsEditable
String getPropertyPriority(String propertyName) native "CSSStyleDeclaration_getPropertyPriority_Callback";
@@ -6356,65 +5920,6 @@
@DocsEditable
-@DomName('WebKitCSSTransformValue')
-class CssTransformValue extends _CssValueList {
- CssTransformValue.internal() : super.internal();
-
- static const int CSS_MATRIX = 11;
-
- static const int CSS_MATRIX3D = 21;
-
- static const int CSS_PERSPECTIVE = 20;
-
- static const int CSS_ROTATE = 4;
-
- static const int CSS_ROTATE3D = 17;
-
- static const int CSS_ROTATEX = 14;
-
- static const int CSS_ROTATEY = 15;
-
- static const int CSS_ROTATEZ = 16;
-
- static const int CSS_SCALE = 5;
-
- static const int CSS_SCALE3D = 19;
-
- static const int CSS_SCALEX = 6;
-
- static const int CSS_SCALEY = 7;
-
- static const int CSS_SCALEZ = 18;
-
- static const int CSS_SKEW = 8;
-
- static const int CSS_SKEWX = 9;
-
- static const int CSS_SKEWY = 10;
-
- static const int CSS_TRANSLATE = 1;
-
- static const int CSS_TRANSLATE3D = 13;
-
- static const int CSS_TRANSLATEX = 2;
-
- static const int CSS_TRANSLATEY = 3;
-
- static const int CSS_TRANSLATEZ = 12;
-
- @DomName('WebKitCSSTransformValue.operationType')
- @DocsEditable
- int get operationType native "WebKitCSSTransformValue_operationType_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('CSSUnknownRule')
class CssUnknownRule extends CssRule {
CssUnknownRule.internal() : super.internal();
@@ -6427,39 +5932,6 @@
// WARNING: Do not edit - generated code.
-@DocsEditable
-@DomName('CSSValue')
-class CssValue extends NativeFieldWrapperClass1 {
- CssValue.internal();
-
- static const int CSS_CUSTOM = 3;
-
- static const int CSS_INHERIT = 0;
-
- static const int CSS_PRIMITIVE_VALUE = 1;
-
- static const int CSS_VALUE_LIST = 2;
-
- @DomName('CSSValue.cssText')
- @DocsEditable
- String get cssText native "CSSValue_cssText_Getter";
-
- @DomName('CSSValue.cssText')
- @DocsEditable
- void set cssText(String value) native "CSSValue_cssText_Setter";
-
- @DomName('CSSValue.cssValueType')
- @DocsEditable
- int get cssValueType native "CSSValue_cssValueType_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
@DomName('CustomEvent')
class CustomEvent extends Event {
factory CustomEvent(String type,
@@ -6570,6 +6042,22 @@
@DocsEditable
void clearData([String type]) native "Clipboard_clearData_Callback";
+ /**
+ * Gets the data for the specified type.
+ *
+ * The data is only available from within a drop operation (such as an
+ * [Element.onDrop] event) and will return `null` before the event is
+ * triggered.
+ *
+ * Data transfer is prohibited across domains. If a drag originates
+ * from content from another domain or protocol (HTTP vs HTTPS) then the
+ * data cannot be accessed.
+ *
+ * The [type] can have values such as:
+ *
+ * * `'Text'`
+ * * `'URL'`
+ */
@DomName('Clipboard.getData')
@DocsEditable
String getData(String type) native "Clipboard_getData_Callback";
@@ -6904,31 +6392,6 @@
@DocsEditable
-@DomName('DedicatedWorkerContext')
-class DedicatedWorkerContext extends WorkerContext {
- DedicatedWorkerContext.internal() : super.internal();
-
- @DomName('DedicatedWorkerContext.messageEvent')
- @DocsEditable
- static const EventStreamProvider<MessageEvent> messageEvent = const EventStreamProvider<MessageEvent>('message');
-
- @DomName('DedicatedWorkerContext.postMessage')
- @DocsEditable
- void postMessage(Object message, [List messagePorts]) native "DedicatedWorkerContext_postMessage_Callback";
-
- @DomName('DedicatedWorkerContext.onmessage')
- @DocsEditable
- Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('HTMLDetailsElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@@ -7105,35 +6568,6 @@
@DocsEditable
-@DomName('DirectoryEntrySync')
-class DirectoryEntrySync extends EntrySync {
- DirectoryEntrySync.internal() : super.internal();
-
- @DomName('DirectoryEntrySync.createReader')
- @DocsEditable
- DirectoryReaderSync createReader() native "DirectoryEntrySync_createReader_Callback";
-
- @DomName('DirectoryEntrySync.getDirectory')
- @DocsEditable
- DirectoryEntrySync getDirectory(String path, Map flags) native "DirectoryEntrySync_getDirectory_Callback";
-
- @DomName('DirectoryEntrySync.getFile')
- @DocsEditable
- FileEntrySync getFile(String path, Map flags) native "DirectoryEntrySync_getFile_Callback";
-
- @DomName('DirectoryEntrySync.removeRecursively')
- @DocsEditable
- void removeRecursively() native "DirectoryEntrySync_removeRecursively_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('DirectoryReader')
class DirectoryReader extends NativeFieldWrapperClass1 {
DirectoryReader.internal();
@@ -7159,23 +6593,6 @@
@DocsEditable
-@DomName('DirectoryReaderSync')
-class DirectoryReaderSync extends NativeFieldWrapperClass1 {
- DirectoryReaderSync.internal();
-
- @DomName('DirectoryReaderSync.readEntries')
- @DocsEditable
- List<EntrySync> readEntries() native "DirectoryReaderSync_readEntries_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
/**
* Represents an HTML <div> element.
*
@@ -7313,6 +6730,10 @@
@DocsEditable
String get $dom_referrer native "Document_referrer_Getter";
+ @DomName('Document.securityPolicy')
+ @DocsEditable
+ DomSecurityPolicy get securityPolicy native "Document_securityPolicy_Getter";
+
@DomName('Document.selectedStylesheetSet')
@DocsEditable
String get $dom_selectedStylesheetSet native "Document_selectedStylesheetSet_Getter";
@@ -7992,11 +7413,12 @@
return new FixedSizeListIterator<DomMimeType>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ DomMimeType reduce(DomMimeType combine(DomMimeType value, DomMimeType element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, DomMimeType element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -8004,7 +7426,7 @@
void forEach(void f(DomMimeType element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(DomMimeType element)) =>
@@ -8106,12 +7528,6 @@
throw new StateError("More than one element");
}
- DomMimeType min([int compare(DomMimeType a, DomMimeType b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- DomMimeType max([int compare(DomMimeType a, DomMimeType b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, DomMimeType element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -8128,14 +7544,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(DomMimeType element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -8156,17 +7564,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<DomMimeType> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<DomMimeType> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <DomMimeType>[]);
}
- List<DomMimeType> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, DomMimeType> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<DomMimeType> mixins.
@DomName('DOMMimeTypeArray.item')
@@ -8274,11 +7689,12 @@
return new FixedSizeListIterator<DomPlugin>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ DomPlugin reduce(DomPlugin combine(DomPlugin value, DomPlugin element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, DomPlugin element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -8286,7 +7702,7 @@
void forEach(void f(DomPlugin element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(DomPlugin element)) =>
@@ -8388,12 +7804,6 @@
throw new StateError("More than one element");
}
- DomPlugin min([int compare(DomPlugin a, DomPlugin b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- DomPlugin max([int compare(DomPlugin a, DomPlugin b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, DomPlugin element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -8410,14 +7820,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(DomPlugin element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -8438,17 +7840,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<DomPlugin> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<DomPlugin> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <DomPlugin>[]);
}
- List<DomPlugin> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, DomPlugin> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<DomPlugin> mixins.
@DomName('DOMPluginArray.item')
@@ -8472,35 +7881,69 @@
@DocsEditable
-@DomName('WebKitPoint')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@SupportedBrowser(SupportedBrowser.SAFARI)
-@Experimental
-class DomPoint extends NativeFieldWrapperClass1 {
- DomPoint.internal();
- factory DomPoint(num x, num y) => _create(x, y);
+@DomName('SecurityPolicy')
+class DomSecurityPolicy extends NativeFieldWrapperClass1 {
+ DomSecurityPolicy.internal();
+ @DomName('DOMSecurityPolicy.allowsEval')
@DocsEditable
- static DomPoint _create(x, y) native "WebKitPoint_constructorCallback";
+ bool get allowsEval native "DOMSecurityPolicy_allowsEval_Getter";
- /// Checks if this type is supported on the current platform.
- static bool get supported => true;
-
- @DomName('WebKitPoint.x')
+ @DomName('DOMSecurityPolicy.allowsInlineScript')
@DocsEditable
- num get x native "WebKitPoint_x_Getter";
+ bool get allowsInlineScript native "DOMSecurityPolicy_allowsInlineScript_Getter";
- @DomName('WebKitPoint.x')
+ @DomName('DOMSecurityPolicy.allowsInlineStyle')
@DocsEditable
- void set x(num value) native "WebKitPoint_x_Setter";
+ bool get allowsInlineStyle native "DOMSecurityPolicy_allowsInlineStyle_Getter";
- @DomName('WebKitPoint.y')
+ @DomName('DOMSecurityPolicy.isActive')
@DocsEditable
- num get y native "WebKitPoint_y_Getter";
+ bool get isActive native "DOMSecurityPolicy_isActive_Getter";
- @DomName('WebKitPoint.y')
+ @DomName('DOMSecurityPolicy.reportURIs')
@DocsEditable
- void set y(num value) native "WebKitPoint_y_Setter";
+ List<String> get reportURIs native "DOMSecurityPolicy_reportURIs_Getter";
+
+ @DomName('DOMSecurityPolicy.allowsConnectionTo')
+ @DocsEditable
+ bool allowsConnectionTo(String url) native "DOMSecurityPolicy_allowsConnectionTo_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsFontFrom')
+ @DocsEditable
+ bool allowsFontFrom(String url) native "DOMSecurityPolicy_allowsFontFrom_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsFormAction')
+ @DocsEditable
+ bool allowsFormAction(String url) native "DOMSecurityPolicy_allowsFormAction_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsFrameFrom')
+ @DocsEditable
+ bool allowsFrameFrom(String url) native "DOMSecurityPolicy_allowsFrameFrom_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsImageFrom')
+ @DocsEditable
+ bool allowsImageFrom(String url) native "DOMSecurityPolicy_allowsImageFrom_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsMediaFrom')
+ @DocsEditable
+ bool allowsMediaFrom(String url) native "DOMSecurityPolicy_allowsMediaFrom_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsObjectFrom')
+ @DocsEditable
+ bool allowsObjectFrom(String url) native "DOMSecurityPolicy_allowsObjectFrom_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsPluginType')
+ @DocsEditable
+ bool allowsPluginType(String type) native "DOMSecurityPolicy_allowsPluginType_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsScriptFrom')
+ @DocsEditable
+ bool allowsScriptFrom(String url) native "DOMSecurityPolicy_allowsScriptFrom_Callback";
+
+ @DomName('DOMSecurityPolicy.allowsStyleFrom')
+ @DocsEditable
+ bool allowsStyleFrom(String url) native "DOMSecurityPolicy_allowsStyleFrom_Callback";
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -8674,11 +8117,12 @@
return new FixedSizeListIterator<String>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, String)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, String element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -8686,7 +8130,7 @@
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(String element)) =>
@@ -8788,12 +8232,6 @@
throw new StateError("More than one element");
}
- String min([int compare(String a, String b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- String max([int compare(String a, String b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, String element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -8810,14 +8248,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -8838,17 +8268,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<String> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<String> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <String>[]);
}
- List<String> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, String> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<String> mixins.
@DomName('DOMStringList.contains')
@@ -8924,7 +8361,7 @@
// TODO(jacobr): use _Lists.dart to remove some of the duplicated
// functionality.
-class _ChildrenElementList implements List {
+class _ChildrenElementList extends ListBase<Element> {
// Raw Element.
final Element _element;
final HtmlCollection _childElements;
@@ -8981,20 +8418,20 @@
return false;
}
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
+ String join([String separator = ""]) {
+ return _childElements.join(separator);
}
Iterable map(f(Element element)) {
- return IterableMixinWorkaround.mapList(this, f);
+ return _childElements.map(f);
}
Iterable<Element> where(bool f(Element element)) {
- return IterableMixinWorkaround.where(this, f);
+ return _childElements.where(f);
}
Iterable expand(Iterable f(Element element)) {
- return IterableMixinWorkaround.expand(this, f);
+ return _childElements.expand(f);
}
bool get isEmpty {
@@ -9002,31 +8439,31 @@
}
Iterable<Element> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
+ return _childElements.take(n);
}
Iterable<Element> takeWhile(bool test(Element value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
+ return _childElements.takeWhile(test);
}
Iterable<Element> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
+ return _childElements.skip(n);
}
Iterable<Element> skipWhile(bool test(Element value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
+ return _childElements.skipWhile(test);
}
Element firstWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
+ return _childElements.firstWhere(test, orElse: orElse);
}
Element lastWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
+ return _childElements.lastWhere(test, orElse: orElse);
}
Element singleWhere(bool test(Element value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
+ return _childElements.singleWhere(test);
}
Element elementAt(int index) {
@@ -9068,24 +8505,24 @@
}
Iterable<Element> get reversed {
- return IterableMixinWorkaround.reversedList(this);
+ return _childElements.reversed;
}
void sort([int compare(Element a, Element b)]) {
throw new UnsupportedError('TODO(jacobr): should we impl?');
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Element reduce(Element combine(Element value, Element element)) {
+ return _childElements.reduce(combine);
}
dynamic fold(dynamic initialValue,
dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
+ return _childElements.fold(initialValue, combine);
}
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
+ void setRange(int start, int rangeLength, List from,
+ [int startFrom = 0]) {
throw new UnimplementedError();
}
@@ -9098,20 +8535,12 @@
}
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
void removeWhere(bool test(Element element)) {
- IterableMixinWorkaround.removeWhere(this, test);
+ _childElements.removeWhere(test);
}
void retainWhere(bool test(Element element)) {
- IterableMixinWorkaround.retainWhere(this, test);
+ _childElements.retainWhere(test);
}
void removeRange(int start, int rangeLength) {
@@ -9122,14 +8551,15 @@
throw new UnimplementedError();
}
+ Iterable getRange(int start, int end) {
+ throw new UnimplementedError();
+ }
+
List sublist(int start, [int end]) {
if (end == null) end = length;
return new _FrozenElementList._wrap(Lists.getRange(this, start, end, []));
}
- List getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
int indexOf(Element element, [int start = 0]) {
return Lists.indexOf(this, element, start, this.length);
}
@@ -9189,16 +8619,15 @@
return first;
}
- Element min([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.min(this, compare);
- }
-
- Element max([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
Map<int, Element> asMap() {
- return IterableMixinWorkaround.asMapList(this);
+ return _childElements.asMap();
+ }
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
}
}
@@ -9206,96 +8635,11 @@
// a better option given that we cannot quite force NodeList to be an
// ElementList as there are valid cases where a NodeList JavaScript object
// contains Node objects that are not Elements.
-class _FrozenElementList implements List {
+class _FrozenElementList extends ListBase {
final List<Node> _nodeList;
_FrozenElementList._wrap(this._nodeList);
- bool contains(Element element) {
- for (Element el in this) {
- if (el == element) return true;
- }
- return false;
- }
-
- void forEach(void f(Element element)) {
- for (Element el in this) {
- f(el);
- }
- }
-
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
- }
-
- Iterable map(f(Element element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
- Iterable<Element> where(bool f(Element element)) {
- return IterableMixinWorkaround.where(this, f);
- }
-
- Iterable expand(Iterable f(Element element)) {
- return IterableMixinWorkaround.expand(this, f);
- }
-
- bool every(bool f(Element element)) {
- for(Element element in this) {
- if (!f(element)) {
- return false;
- }
- };
- return true;
- }
-
- bool any(bool f(Element element)) {
- for(Element element in this) {
- if (f(element)) {
- return true;
- }
- };
- return false;
- }
-
- List<Element> toList({ bool growable: true }) =>
- new List<Element>.from(this, growable: growable);
- Set<Element> toSet() => new Set<Element>.from(this);
-
- Iterable<Element> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
- }
-
- Iterable<Element> takeWhile(bool test(Element value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
-
- Iterable<Element> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
- }
-
- Iterable<Element> skipWhile(bool test(Element value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- Element firstWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- Element lastWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- Element singleWhere(bool test(Element value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- Element elementAt(int index) {
- return this[index];
- }
-
- bool get isEmpty => _nodeList.isEmpty;
-
int get length => _nodeList.length;
Element operator [](int index) => _nodeList[index];
@@ -9312,31 +8656,16 @@
throw new UnsupportedError('');
}
- Iterator<Element> get iterator => new _FrozenElementListIterator(this);
-
void addAll(Iterable<Element> iterable) {
throw new UnsupportedError('');
}
- Iterable<Element> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
void sort([int compare(Element a, Element b)]) {
throw new UnsupportedError('');
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
+ void setRange(int start, int rangeLength, List from,
+ [int startFrom = 0]) {
throw new UnsupportedError('');
}
@@ -9352,15 +8681,6 @@
return new _FrozenElementList._wrap(_nodeList.sublist(start, end));
}
- List<Element> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- int indexOf(Element element, [int start = 0]) =>
- _nodeList.indexOf(element, start);
-
- int lastIndexOf(Element element, [int start = null]) =>
- _nodeList.lastIndexOf(element, start);
-
void clear() {
throw new UnsupportedError('');
}
@@ -9377,14 +8697,6 @@
throw new UnsupportedError('');
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError('');
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError('');
- }
-
void removeWhere(bool test(Element element)) {
throw new UnsupportedError('');
}
@@ -9399,49 +8711,12 @@
Element get single => _nodeList.single;
- Element min([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.min(this, compare);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
}
-
- Element max([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
- Map<int, Element> asMap() {
- return IterableMixinWorkaround.asMapList(this);
- }
-}
-
-class _FrozenElementListIterator implements Iterator<Element> {
- final _FrozenElementList _list;
- int _index = -1;
- Element _current;
-
- _FrozenElementListIterator(this._list);
-
- /**
- * Moves to the next element. Returns true if the iterator is positioned
- * at an element. Returns false if it is positioned after the last element.
- */
- bool moveNext() {
- int nextIndex = _index + 1;
- if (nextIndex < _list.length) {
- _current = _list[nextIndex];
- _index = nextIndex;
- return true;
- }
- _index = _list.length;
- _current = null;
- return false;
- }
-
- /**
- * Returns the element the [Iterator] is positioned at.
- *
- * Return [:null:] if the iterator is positioned before the first, or
- * after the last element.
- */
- Element get current => _current;
}
class _ElementCssClassSet extends CssClassSet {
@@ -9580,7 +8855,7 @@
*/
CssClassSet get classes => new _ElementCssClassSet(this);
- void set classes(Collection<String> value) {
+ void set classes(Iterable<String> value) {
CssClassSet classSet = classes;
classSet.clear();
classSet.addAll(value);
@@ -10883,63 +10158,6 @@
// WARNING: Do not edit - generated code.
-@DocsEditable
-@DomName('EntrySync')
-class EntrySync extends NativeFieldWrapperClass1 {
- EntrySync.internal();
-
- @DomName('EntrySync.filesystem')
- @DocsEditable
- FileSystemSync get filesystem native "EntrySync_filesystem_Getter";
-
- @DomName('EntrySync.fullPath')
- @DocsEditable
- String get fullPath native "EntrySync_fullPath_Getter";
-
- @DomName('EntrySync.isDirectory')
- @DocsEditable
- bool get isDirectory native "EntrySync_isDirectory_Getter";
-
- @DomName('EntrySync.isFile')
- @DocsEditable
- bool get isFile native "EntrySync_isFile_Getter";
-
- @DomName('EntrySync.name')
- @DocsEditable
- String get name native "EntrySync_name_Getter";
-
- @DomName('EntrySync.copyTo')
- @DocsEditable
- EntrySync copyTo(DirectoryEntrySync parent, String name) native "EntrySync_copyTo_Callback";
-
- @DomName('EntrySync.getMetadata')
- @DocsEditable
- Metadata getMetadata() native "EntrySync_getMetadata_Callback";
-
- @DomName('EntrySync.getParent')
- @DocsEditable
- EntrySync getParent() native "EntrySync_getParent_Callback";
-
- @DomName('EntrySync.moveTo')
- @DocsEditable
- EntrySync moveTo(DirectoryEntrySync parent, String name) native "EntrySync_moveTo_Callback";
-
- @DomName('EntrySync.remove')
- @DocsEditable
- void remove() native "EntrySync_remove_Callback";
-
- @DomName('EntrySync.toURL')
- @DocsEditable
- String toUrl() native "EntrySync_toURL_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
typedef void _ErrorCallback(FileError error);
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -11078,14 +10296,6 @@
@DocsEditable
int get eventPhase native "Event_eventPhase_Getter";
- @DomName('Event.returnValue')
- @DocsEditable
- bool get returnValue native "Event_returnValue_Getter";
-
- @DomName('Event.returnValue')
- @DocsEditable
- void set returnValue(bool value) native "Event_returnValue_Setter";
-
@DomName('Event.target')
@DocsEditable
EventTarget get target native "Event_target_Getter";
@@ -11459,27 +10669,6 @@
@DocsEditable
-@DomName('FileEntrySync')
-class FileEntrySync extends EntrySync {
- FileEntrySync.internal() : super.internal();
-
- @DomName('FileEntrySync.createWriter')
- @DocsEditable
- FileWriterSync createWriter() native "FileEntrySync_createWriter_Callback";
-
- @DomName('FileEntrySync.file')
- @DocsEditable
- File file() native "FileEntrySync_file_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('FileError')
class FileError extends NativeFieldWrapperClass1 {
FileError.internal();
@@ -11599,11 +10788,12 @@
return new FixedSizeListIterator<File>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, File)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ File reduce(File combine(File value, File element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, File)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, File element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -11611,7 +10801,7 @@
void forEach(void f(File element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(File element)) =>
@@ -11713,12 +10903,6 @@
throw new StateError("More than one element");
}
- File min([int compare(File a, File b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- File max([int compare(File a, File b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, File element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -11735,14 +10919,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(File element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -11763,17 +10939,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<File> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<File> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <File>[]);
}
- List<File> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, File> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<File> mixins.
@DomName('FileList.item')
@@ -11922,55 +11105,6 @@
@DocsEditable
-@DomName('FileReaderSync')
-class FileReaderSync extends NativeFieldWrapperClass1 {
- FileReaderSync.internal();
-
- @DomName('FileReaderSync.FileReaderSync')
- @DocsEditable
- factory FileReaderSync() {
- return FileReaderSync._create_1();
- }
-
- @DocsEditable
- static FileReaderSync _create_1() native "FileReaderSync__create_1constructorCallback";
-
- @DomName('FileReaderSync.readAsArrayBuffer')
- @DocsEditable
- dynamic readAsArrayBuffer(Blob blob) native "FileReaderSync_readAsArrayBuffer_Callback";
-
- @DomName('FileReaderSync.readAsBinaryString')
- @DocsEditable
- String readAsBinaryString(Blob blob) native "FileReaderSync_readAsBinaryString_Callback";
-
- @DomName('FileReaderSync.readAsDataURL')
- @DocsEditable
- String readAsDataUrl(Blob blob) native "FileReaderSync_readAsDataURL_Callback";
-
- String readAsText(Blob blob, [String encoding]) {
- if (?encoding) {
- return _readAsText_1(blob, encoding);
- }
- return _readAsText_2(blob);
- }
-
- @DomName('FileReaderSync._readAsText_1')
- @DocsEditable
- String _readAsText_1(blob, encoding) native "FileReaderSync__readAsText_1_Callback";
-
- @DomName('FileReaderSync._readAsText_2')
- @DocsEditable
- String _readAsText_2(blob) native "FileReaderSync__readAsText_2_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('DOMFileSystem')
@SupportedBrowser(SupportedBrowser.CHROME)
@Experimental
@@ -12005,29 +11139,6 @@
@DocsEditable
-@DomName('DOMFileSystemSync')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@Experimental
-class FileSystemSync extends NativeFieldWrapperClass1 {
- FileSystemSync.internal();
-
- @DomName('DOMFileSystemSync.name')
- @DocsEditable
- String get name native "DOMFileSystemSync_name_Getter";
-
- @DomName('DOMFileSystemSync.root')
- @DocsEditable
- DirectoryEntrySync get root native "DOMFileSystemSync_root_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('FileWriter')
class FileWriter extends EventTarget {
FileWriter.internal() : super.internal();
@@ -12147,39 +11258,6 @@
@DocsEditable
-@DomName('FileWriterSync')
-class FileWriterSync extends NativeFieldWrapperClass1 {
- FileWriterSync.internal();
-
- @DomName('FileWriterSync.length')
- @DocsEditable
- int get length native "FileWriterSync_length_Getter";
-
- @DomName('FileWriterSync.position')
- @DocsEditable
- int get position native "FileWriterSync_position_Getter";
-
- @DomName('FileWriterSync.seek')
- @DocsEditable
- void seek(int position) native "FileWriterSync_seek_Callback";
-
- @DomName('FileWriterSync.truncate')
- @DocsEditable
- void truncate(int size) native "FileWriterSync_truncate_Callback";
-
- @DomName('FileWriterSync.write')
- @DocsEditable
- void write(Blob data) native "FileWriterSync_write_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('Float32Array')
class Float32Array extends ArrayBufferView implements List<double> {
Float32Array.internal() : super.internal();
@@ -12224,11 +11302,12 @@
return new FixedSizeListIterator<num>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, num)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ num reduce(num combine(num value, num element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, num element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -12236,7 +11315,7 @@
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(num element)) =>
@@ -12338,12 +11417,6 @@
throw new StateError("More than one element");
}
- num min([int compare(num a, num b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- num max([int compare(num a, num b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, num element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -12360,14 +11433,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(num element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -12388,17 +11453,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<num> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<num> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <num>[]);
}
- List<num> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, num> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<num> mixins.
@DomName('Float32Array.setElements')
@@ -12473,11 +11545,12 @@
return new FixedSizeListIterator<num>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, num)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ num reduce(num combine(num value, num element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, num element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -12485,7 +11558,7 @@
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(num element)) =>
@@ -12587,12 +11660,6 @@
throw new StateError("More than one element");
}
- num min([int compare(num a, num b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- num max([int compare(num a, num b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, num element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -12609,14 +11676,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(num element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -12637,17 +11696,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<num> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<num> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <num>[]);
}
- List<num> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, num> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<num> mixins.
@DomName('Float64Array.setElements')
@@ -12910,7 +11976,7 @@
var controller;
controller = new StreamController<Geoposition>(
onSubscriptionStateChange: () {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
assert(watchId == null);
watchId = $dom_watchPosition(
(position) {
@@ -13171,11 +12237,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -13183,7 +12250,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -13285,12 +12352,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -13307,14 +12368,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -13335,17 +12388,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('HTMLAllCollection.item')
@@ -13394,11 +12454,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -13406,7 +12467,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -13508,12 +12569,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -13530,14 +12585,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -13558,17 +12605,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('HTMLCollection.item')
@@ -13595,22 +12649,23 @@
@DocsEditable
Element get activeElement native "HTMLDocument_activeElement_Getter";
+
@DomName('Document.body')
- BodyElement get body => document.$dom_body;
+ BodyElement get body => $dom_body;
@DomName('Document.body')
void set body(BodyElement value) {
- document.$dom_body = value;
+ $dom_body = value;
}
@DomName('Document.caretRangeFromPoint')
Range caretRangeFromPoint(int x, int y) {
- return document.$dom_caretRangeFromPoint(x, y);
+ return $dom_caretRangeFromPoint(x, y);
}
@DomName('Document.elementFromPoint')
Element elementFromPoint(int x, int y) {
- return document.$dom_elementFromPoint(x, y);
+ return $dom_elementFromPoint(x, y);
}
/**
@@ -13649,36 +12704,36 @@
@DomName('Document.getCSSCanvasContext')
CanvasRenderingContext getCssCanvasContext(String contextId, String name,
int width, int height) {
- return document.$dom_getCssCanvasContext(contextId, name, width, height);
+ return $dom_getCssCanvasContext(contextId, name, width, height);
}
@DomName('Document.head')
- HeadElement get head => document.$dom_head;
+ HeadElement get head => $dom_head;
@DomName('Document.lastModified')
- String get lastModified => document.$dom_lastModified;
+ String get lastModified => $dom_lastModified;
@DomName('Document.preferredStylesheetSet')
- String get preferredStylesheetSet => document.$dom_preferredStylesheetSet;
+ String get preferredStylesheetSet => $dom_preferredStylesheetSet;
@DomName('Document.referrer')
- String get referrer => document.$dom_referrer;
+ String get referrer => $dom_referrer;
@DomName('Document.selectedStylesheetSet')
- String get selectedStylesheetSet => document.$dom_selectedStylesheetSet;
+ String get selectedStylesheetSet => $dom_selectedStylesheetSet;
void set selectedStylesheetSet(String value) {
- document.$dom_selectedStylesheetSet = value;
+ $dom_selectedStylesheetSet = value;
}
@DomName('Document.styleSheets')
- List<StyleSheet> get styleSheets => document.$dom_styleSheets;
+ List<StyleSheet> get styleSheets => $dom_styleSheets;
@DomName('Document.title')
- String get title => document.$dom_title;
+ String get title => $dom_title;
@DomName('Document.title')
void set title(String value) {
- document.$dom_title = value;
+ $dom_title = value;
}
@DomName('Document.webkitCancelFullScreen')
@@ -13686,7 +12741,7 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void cancelFullScreen() {
- document.$dom_webkitCancelFullScreen();
+ $dom_webkitCancelFullScreen();
}
@DomName('Document.webkitExitFullscreen')
@@ -13694,7 +12749,7 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void exitFullscreen() {
- document.$dom_webkitExitFullscreen();
+ $dom_webkitExitFullscreen();
}
@DomName('Document.webkitExitPointerLock')
@@ -13702,45 +12757,45 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void exitPointerLock() {
- document.$dom_webkitExitPointerLock();
+ $dom_webkitExitPointerLock();
}
@DomName('Document.webkitFullscreenElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- Element get fullscreenElement => document.$dom_webkitFullscreenElement;
+ Element get fullscreenElement => $dom_webkitFullscreenElement;
@DomName('Document.webkitFullscreenEnabled')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get fullscreenEnabled => document.$dom_webkitFullscreenEnabled;
+ bool get fullscreenEnabled => $dom_webkitFullscreenEnabled;
@DomName('Document.webkitHidden')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get hidden => document.$dom_webkitHidden;
+ bool get hidden => $dom_webkitHidden;
@DomName('Document.webkitIsFullScreen')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get isFullScreen => document.$dom_webkitIsFullScreen;
+ bool get isFullScreen => $dom_webkitIsFullScreen;
@DomName('Document.webkitPointerLockElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Element get pointerLockElement =>
- document.$dom_webkitPointerLockElement;
+ $dom_webkitPointerLockElement;
@DomName('Document.webkitVisibilityState')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- String get visibilityState => document.$dom_webkitVisibilityState;
+ String get visibilityState => $dom_webkitVisibilityState;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -14479,6 +13534,14 @@
@DocsEditable
void set sandbox(String value) native "HTMLIFrameElement_sandbox_Setter";
+ @DomName('HTMLIFrameElement.seamless')
+ @DocsEditable
+ bool get seamless native "HTMLIFrameElement_seamless_Getter";
+
+ @DomName('HTMLIFrameElement.seamless')
+ @DocsEditable
+ void set seamless(bool value) native "HTMLIFrameElement_seamless_Setter";
+
@DomName('HTMLIFrameElement.src')
@DocsEditable
String get src native "HTMLIFrameElement_src_Getter";
@@ -15764,11 +14827,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -15776,7 +14840,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -15878,12 +14942,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -15900,14 +14958,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -15928,17 +14978,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Int16Array.setElements')
@@ -16013,11 +15070,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -16025,7 +15083,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -16127,12 +15185,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -16149,14 +15201,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -16177,17 +15221,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Int32Array.setElements')
@@ -16262,11 +15313,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -16274,7 +15326,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -16376,12 +15428,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -16398,14 +15444,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -16426,17 +15464,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Int8Array.setElements')
@@ -19020,7 +18065,7 @@
* the actual child nodes of an element until strictly necessary greatly
* improving performance for the typical cases where it is not required.
*/
-class _ChildNodeListLazy implements List {
+class _ChildNodeListLazy extends ListBase<Node> {
final Node _this;
_ChildNodeListLazy(this._this);
@@ -19043,14 +18088,6 @@
return _this.$dom_firstChild;
}
- Node min([int compare(Node a, Node b)]) {
- return IterableMixinWorkaround.min(this, compare);
- }
-
- Node max([int compare(Node a, Node b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
void add(Node value) {
_this.append(value);
}
@@ -19105,20 +18142,26 @@
_this.$dom_removeChild(node);
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
+ void _filter(bool test(Node node), bool removeMatching) {
+ // This implementation of removeWhere/retainWhere is more efficient
+ // than the default in ListBase. Child nodes can be removed in constant
+ // time.
+ Node child = _this.$dom_firstChild;
+ while (child != null) {
+ Node nextChild = child.nextSibling;
+ if (test(child) == removeMatching) {
+ _this.$dom_removeChild(child);
+ }
+ child = nextChild;
+ }
}
void removeWhere(bool test(Node node)) {
- IterableMixinWorkaround.removeWhere(this, test);
+ _filter(test, true);
}
void retainWhere(bool test(Node node)) {
- IterableMixinWorkaround.retainWhere(this, test);
+ _filter(test, false);
}
void clear() {
@@ -19131,42 +18174,6 @@
Iterator<Node> get iterator => _this.$dom_childNodes.iterator;
- // TODO(jacobr): We can implement these methods much more efficiently by
- // looking up the nodeList only once instead of once per iteration.
- bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
-
- void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
-
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Node element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, Node element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
- }
-
- Iterable map(f(Node element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
- Iterable<Node> where(bool f(Node element)) {
- return IterableMixinWorkaround.where(this, f);
- }
-
- Iterable expand(Iterable f(Node element)) {
- return IterableMixinWorkaround.expand(this, f);
- }
-
- bool every(bool f(Node element)) => IterableMixinWorkaround.every(this, f);
-
- bool any(bool f(Node element)) => IterableMixinWorkaround.any(this, f);
-
List<Node> toList({ bool growable: true }) =>
new List<Node>.from(this, growable: growable);
Set<Node> toSet() => new Set<Node>.from(this);
@@ -19175,54 +18182,12 @@
// From List<Node>:
- Iterable<Node> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
- }
-
- Iterable<Node> takeWhile(bool test(Node value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
-
- Iterable<Node> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
- }
-
- Iterable<Node> skipWhile(bool test(Node value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- Node firstWhere(bool test(Node value), {Node orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- Node lastWhere(bool test(Node value), {Node orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- Node singleWhere(bool test(Node value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- Node elementAt(int index) {
- return this[index];
- }
-
- Iterable<Node> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
// TODO(jacobr): this could be implemented for child node lists.
// The exception we throw here is misleading.
void sort([int compare(Node a, Node b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(Node element, [int start = 0]) =>
- Lists.indexOf(this, element, start, this.length);
-
- int lastIndexOf(Node element, [int start = 0]) =>
- Lists.lastIndexOf(this, element, start);
-
// FIXME: implement these.
void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) {
throw new UnsupportedError(
@@ -19236,14 +18201,22 @@
throw new UnsupportedError(
"Cannot insertRange on immutable List.");
}
+
+ Iterable<Node> getRange(int start, int end) {
+ throw new UnimplementedError("NodeList.getRange");
+ }
+
List<Node> sublist(int start, [int end]) {
if (end == null) end == length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
// -- end List<Node> mixins.
// TODO(jacobr): benchmark whether this is more efficient or whether caching
@@ -19256,8 +18229,6 @@
}
Node operator[](int index) => _this.$dom_childNodes[index];
-
- Map<int, Node> asMap() => IterableMixinWorkaround.asMapList(this);
}
@DomName('Node')
@@ -19266,7 +18237,7 @@
return new _ChildNodeListLazy(this);
}
- void set nodes(Collection<Node> value) {
+ void set nodes(Iterable<Node> value) {
// Copy list first since we don't want liveness during iteration.
// TODO(jacobr): there is a better way to do this.
List copy = new List.from(value);
@@ -19408,6 +18379,12 @@
return _modelChangedStream.stream;
}
+ /**
+ * Print out a String representation of this Node.
+ */
+ String toString() => localName == null ?
+ (nodeValue == null ? super.toString() : nodeValue) : localName;
+
Node.internal() : super.internal();
@DomName('Node.childNodes')
@@ -19424,7 +18401,7 @@
@DomName('Node.localName')
@DocsEditable
- String get $dom_localName native "Node_localName_Getter";
+ String get localName native "Node_localName_Getter";
@DomName('Node.namespaceURI')
@DocsEditable
@@ -19638,11 +18615,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -19650,7 +18628,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -19752,12 +18730,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -19774,14 +18746,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -19802,17 +18766,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('NodeList.item')
@@ -21258,6 +20229,10 @@
class RtcDtmfSender extends EventTarget {
RtcDtmfSender.internal() : super.internal();
+ @DomName('RTCDTMFSender.tonechangeEvent')
+ @DocsEditable
+ static const EventStreamProvider<RtcDtmfToneChangeEvent> toneChangeEvent = const EventStreamProvider<RtcDtmfToneChangeEvent>('tonechange');
+
@DomName('RTCDTMFSender.canInsertDTMF')
@DocsEditable
bool get canInsertDtmf native "RTCDTMFSender_canInsertDTMF_Getter";
@@ -21315,6 +20290,10 @@
@DocsEditable
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native "RTCDTMFSender_removeEventListener_Callback";
+ @DomName('RTCDTMFSender.ontonechange')
+ @DocsEditable
+ Stream<RtcDtmfToneChangeEvent> get onToneChange => toneChangeEvent.forTarget(this);
+
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -21430,6 +20409,10 @@
@DocsEditable
static const EventStreamProvider<RtcIceCandidateEvent> iceCandidateEvent = const EventStreamProvider<RtcIceCandidateEvent>('icecandidate');
+ @DomName('RTCPeerConnection.iceconnectionstatechangeEvent')
+ @DocsEditable
+ static const EventStreamProvider<Event> iceConnectionStateChangeEvent = const EventStreamProvider<Event>('iceconnectionstatechange');
+
@DomName('RTCPeerConnection.negotiationneededEvent')
@DocsEditable
static const EventStreamProvider<Event> negotiationNeededEvent = const EventStreamProvider<Event>('negotiationneeded');
@@ -21438,6 +20421,10 @@
@DocsEditable
static const EventStreamProvider<MediaStreamEvent> removeStreamEvent = const EventStreamProvider<MediaStreamEvent>('removestream');
+ @DomName('RTCPeerConnection.signalingstatechangeEvent')
+ @DocsEditable
+ static const EventStreamProvider<Event> signalingStateChangeEvent = const EventStreamProvider<Event>('signalingstatechange');
+
@DomName('RTCPeerConnection.RTCPeerConnection')
@DocsEditable
factory RtcPeerConnection(Map rtcIceServers, [Map mediaConstraints]) {
@@ -21567,6 +20554,10 @@
@DocsEditable
Stream<RtcIceCandidateEvent> get onIceCandidate => iceCandidateEvent.forTarget(this);
+ @DomName('RTCPeerConnection.oniceconnectionstatechange')
+ @DocsEditable
+ Stream<Event> get onIceConnectionStateChange => iceConnectionStateChangeEvent.forTarget(this);
+
@DomName('RTCPeerConnection.onnegotiationneeded')
@DocsEditable
Stream<Event> get onNegotiationNeeded => negotiationNeededEvent.forTarget(this);
@@ -21575,6 +20566,10 @@
@DocsEditable
Stream<MediaStreamEvent> get onRemoveStream => removeStreamEvent.forTarget(this);
+ @DomName('RTCPeerConnection.onsignalingstatechange')
+ @DocsEditable
+ Stream<Event> get onSignalingStateChange => signalingStateChangeEvent.forTarget(this);
+
}
@@ -21793,6 +20788,14 @@
@DocsEditable
void set htmlFor(String value) native "HTMLScriptElement_htmlFor_Setter";
+ @DomName('HTMLScriptElement.nonce')
+ @DocsEditable
+ String get nonce native "HTMLScriptElement_nonce_Getter";
+
+ @DomName('HTMLScriptElement.nonce')
+ @DocsEditable
+ void set nonce(String value) native "HTMLScriptElement_nonce_Setter";
+
@DomName('HTMLScriptElement.src')
@DocsEditable
String get src native "HTMLScriptElement_src_Getter";
@@ -21892,6 +20895,51 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SecurityPolicyViolationEvent')
+class SecurityPolicyViolationEvent extends Event {
+ SecurityPolicyViolationEvent.internal() : super.internal();
+
+ @DomName('SecurityPolicyViolationEvent.blockedURI')
+ @DocsEditable
+ String get blockedUri native "SecurityPolicyViolationEvent_blockedURI_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.documentURI')
+ @DocsEditable
+ String get documentUri native "SecurityPolicyViolationEvent_documentURI_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.effectiveDirective')
+ @DocsEditable
+ String get effectiveDirective native "SecurityPolicyViolationEvent_effectiveDirective_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.lineNumber')
+ @DocsEditable
+ int get lineNumber native "SecurityPolicyViolationEvent_lineNumber_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.originalPolicy')
+ @DocsEditable
+ String get originalPolicy native "SecurityPolicyViolationEvent_originalPolicy_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.referrer')
+ @DocsEditable
+ String get referrer native "SecurityPolicyViolationEvent_referrer_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.sourceFile')
+ @DocsEditable
+ String get sourceFile native "SecurityPolicyViolationEvent_sourceFile_Getter";
+
+ @DomName('SecurityPolicyViolationEvent.violatedDirective')
+ @DocsEditable
+ String get violatedDirective native "SecurityPolicyViolationEvent_violatedDirective_Getter";
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
@DomName('HTMLSelectElement')
class SelectElement extends _Element_Merged {
@@ -22136,57 +21184,6 @@
@DocsEditable
-@DomName('SharedWorker')
-class SharedWorker extends AbstractWorker {
- SharedWorker.internal() : super.internal();
-
- @DomName('SharedWorker.SharedWorker')
- @DocsEditable
- factory SharedWorker(String scriptURL, [String name]) {
- return SharedWorker._create_1(scriptURL, name);
- }
-
- @DocsEditable
- static SharedWorker _create_1(scriptURL, name) native "SharedWorker__create_1constructorCallback";
-
- @DomName('SharedWorker.port')
- @DocsEditable
- MessagePort get port native "SharedWorker_port_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SharedWorkerContext')
-class SharedWorkerContext extends WorkerContext {
- SharedWorkerContext.internal() : super.internal();
-
- @DomName('SharedWorkerContext.connectEvent')
- @DocsEditable
- static const EventStreamProvider<Event> connectEvent = const EventStreamProvider<Event>('connect');
-
- @DomName('SharedWorkerContext.name')
- @DocsEditable
- String get name native "SharedWorkerContext_name_Getter";
-
- @DomName('SharedWorkerContext.onconnect')
- @DocsEditable
- Stream<Event> get onConnect => connectEvent.forTarget(this);
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('SourceBuffer')
class SourceBuffer extends NativeFieldWrapperClass1 {
SourceBuffer.internal();
@@ -22245,11 +21242,12 @@
return new FixedSizeListIterator<SourceBuffer>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SourceBuffer reduce(SourceBuffer combine(SourceBuffer value, SourceBuffer element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SourceBuffer element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -22257,7 +21255,7 @@
void forEach(void f(SourceBuffer element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SourceBuffer element)) =>
@@ -22359,12 +21357,6 @@
throw new StateError("More than one element");
}
- SourceBuffer min([int compare(SourceBuffer a, SourceBuffer b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SourceBuffer max([int compare(SourceBuffer a, SourceBuffer b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SourceBuffer element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -22381,14 +21373,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SourceBuffer element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -22409,17 +21393,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SourceBuffer> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SourceBuffer> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SourceBuffer>[]);
}
- List<SourceBuffer> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SourceBuffer> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SourceBuffer> mixins.
@DomName('SourceBufferList.addEventListener')
@@ -22577,11 +21568,12 @@
return new FixedSizeListIterator<SpeechGrammar>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SpeechGrammar reduce(SpeechGrammar combine(SpeechGrammar value, SpeechGrammar element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SpeechGrammar element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -22589,7 +21581,7 @@
void forEach(void f(SpeechGrammar element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SpeechGrammar element)) =>
@@ -22691,12 +21683,6 @@
throw new StateError("More than one element");
}
- SpeechGrammar min([int compare(SpeechGrammar a, SpeechGrammar b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SpeechGrammar max([int compare(SpeechGrammar a, SpeechGrammar b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SpeechGrammar element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -22713,14 +21699,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SpeechGrammar element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -22741,17 +21719,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SpeechGrammar> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SpeechGrammar> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SpeechGrammar>[]);
}
- List<SpeechGrammar> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SpeechGrammar> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SpeechGrammar> mixins.
void addFromString(String string, [num weight]) {
@@ -23175,13 +22160,13 @@
}
}
- Collection<String> get keys {
+ Iterable<String> get keys {
final keys = [];
forEach((k, v) => keys.add(k));
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
final values = [];
forEach((k, v) => values.add(v));
return values;
@@ -24324,11 +23309,12 @@
return new FixedSizeListIterator<TextTrackCue>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ TextTrackCue reduce(TextTrackCue combine(TextTrackCue value, TextTrackCue element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, TextTrackCue element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -24336,7 +23322,7 @@
void forEach(void f(TextTrackCue element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(TextTrackCue element)) =>
@@ -24438,12 +23424,6 @@
throw new StateError("More than one element");
}
- TextTrackCue min([int compare(TextTrackCue a, TextTrackCue b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- TextTrackCue max([int compare(TextTrackCue a, TextTrackCue b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, TextTrackCue element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -24460,14 +23440,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(TextTrackCue element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -24488,17 +23460,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<TextTrackCue> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<TextTrackCue> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <TextTrackCue>[]);
}
- List<TextTrackCue> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, TextTrackCue> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<TextTrackCue> mixins.
@DomName('TextTrackCueList.getCueById')
@@ -24547,11 +23526,12 @@
return new FixedSizeListIterator<TextTrack>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ TextTrack reduce(TextTrack combine(TextTrack value, TextTrack element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, TextTrack element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -24559,7 +23539,7 @@
void forEach(void f(TextTrack element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(TextTrack element)) =>
@@ -24661,12 +23641,6 @@
throw new StateError("More than one element");
}
- TextTrack min([int compare(TextTrack a, TextTrack b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- TextTrack max([int compare(TextTrack a, TextTrack b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, TextTrack element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -24683,14 +23657,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(TextTrack element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -24711,17 +23677,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<TextTrack> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<TextTrack> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <TextTrack>[]);
}
- List<TextTrack> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, TextTrack> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<TextTrack> mixins.
@DomName('TextTrackList.addEventListener')
@@ -24987,11 +23960,12 @@
return new FixedSizeListIterator<Touch>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Touch)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Touch reduce(Touch combine(Touch value, Touch element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Touch)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Touch element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -24999,7 +23973,7 @@
void forEach(void f(Touch element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Touch element)) =>
@@ -25101,12 +24075,6 @@
throw new StateError("More than one element");
}
- Touch min([int compare(Touch a, Touch b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Touch max([int compare(Touch a, Touch b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Touch element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -25123,14 +24091,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Touch element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -25151,17 +24111,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Touch> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Touch> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Touch>[]);
}
- List<Touch> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Touch> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Touch> mixins.
@DomName('TouchList.item')
@@ -25510,11 +24477,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -25522,7 +24490,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -25624,12 +24592,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -25646,14 +24608,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -25674,17 +24628,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Uint16Array.setElements')
@@ -25759,11 +24720,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -25771,7 +24733,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -25873,12 +24835,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -25895,14 +24851,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -25923,17 +24871,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Uint32Array.setElements')
@@ -26008,11 +24963,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -26020,7 +24976,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -26122,12 +25078,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -26144,14 +25094,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -26172,17 +25114,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Uint8Array.setElements')
@@ -26255,11 +25204,12 @@
return new FixedSizeListIterator<int>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, int)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ int reduce(int combine(int value, int element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, int element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -26267,7 +25217,7 @@
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(int element)) =>
@@ -26369,12 +25319,6 @@
throw new StateError("More than one element");
}
- int min([int compare(int a, int b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- int max([int compare(int a, int b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, int element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -26391,14 +25335,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(int element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -26419,17 +25355,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<int> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<int> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <int>[]);
}
- List<int> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, int> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<int> mixins.
@DomName('Uint8ClampedArray.setElements')
@@ -26695,60 +25638,6 @@
@DocsEditable
-@DomName('WebKitCSSFilterValue')
-class WebKitCssFilterValue extends _CssValueList {
- WebKitCssFilterValue.internal() : super.internal();
-
- static const int CSS_FILTER_BLUR = 10;
-
- static const int CSS_FILTER_BRIGHTNESS = 8;
-
- static const int CSS_FILTER_CONTRAST = 9;
-
- static const int CSS_FILTER_CUSTOM = 12;
-
- static const int CSS_FILTER_DROP_SHADOW = 11;
-
- static const int CSS_FILTER_GRAYSCALE = 2;
-
- static const int CSS_FILTER_HUE_ROTATE = 5;
-
- static const int CSS_FILTER_INVERT = 6;
-
- static const int CSS_FILTER_OPACITY = 7;
-
- static const int CSS_FILTER_REFERENCE = 1;
-
- static const int CSS_FILTER_SATURATE = 4;
-
- static const int CSS_FILTER_SEPIA = 3;
-
- @DomName('WebKitCSSFilterValue.operationType')
- @DocsEditable
- int get operationType native "WebKitCSSFilterValue_operationType_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('WebKitCSSMixFunctionValue')
-class WebKitCssMixFunctionValue extends _CssValueList {
- WebKitCssMixFunctionValue.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('WebKitNamedFlow')
class WebKitNamedFlow extends EventTarget {
WebKitNamedFlow.internal() : super.internal();
@@ -27151,21 +26040,43 @@
* lasting storage. This storage cannot be freed without the user's
* permission. Returns a [Future] whose value stores a reference to the
* sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
+ * applications cannot access file systems created in other web pages.
*/
Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
return _requestFileSystem(persistent? 1 : 0, size);
}
+
+ @DomName('DOMWindow.convertPointFromNodeToPage')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.SAFARI)
+ @Experimental
+ Point convertPointFromNodeToPage(Node node, Point point) {
+ var result = _convertPointFromNodeToPage(node,
+ new _DomPoint(point.x, point.y));
+ return new Point(result.x, result.y);
+ }
+
+ @DomName('DOMWindow.convertPointFromPageToNode')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.SAFARI)
+ @Experimental
+ Point convertPointFromPageToNode(Node node, Point point) {
+ var result = _convertPointFromPageToNode(node,
+ new _DomPoint(point.x, point.y));
+ return new Point(result.x, result.y);
+ }
+
+ /**
+ * Checks whether [convertPointFromNodeToPage] and
+ * [convertPointFromPageToNode] are supported on the current platform.
+ */
+ static bool get supportsPointConversions => _DomPoint.supported;
Window.internal() : super.internal();
@DomName('DOMWindow.DOMContentLoadedEvent')
@DocsEditable
static const EventStreamProvider<Event> contentLoadedEvent = const EventStreamProvider<Event>('DOMContentLoaded');
- @DomName('DOMWindow.beforeunloadEvent')
- @DocsEditable
- static const EventStreamProvider<Event> beforeUnloadEvent = const EventStreamProvider<Event>('beforeunload');
-
@DomName('DOMWindow.devicemotionEvent')
@DocsEditable
static const EventStreamProvider<DeviceMotionEvent> deviceMotionEvent = const EventStreamProvider<DeviceMotionEvent>('devicemotion');
@@ -27604,14 +26515,14 @@
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- DomPoint convertPointFromNodeToPage(Node node, DomPoint p) native "DOMWindow_webkitConvertPointFromNodeToPage_Callback";
+ _DomPoint _convertPointFromNodeToPage(Node node, _DomPoint p) native "DOMWindow_webkitConvertPointFromNodeToPage_Callback";
@DomName('DOMWindow.webkitConvertPointFromPageToNode')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- DomPoint convertPointFromPageToNode(Node node, DomPoint p) native "DOMWindow_webkitConvertPointFromPageToNode_Callback";
+ _DomPoint _convertPointFromPageToNode(Node node, _DomPoint p) native "DOMWindow_webkitConvertPointFromPageToNode_Callback";
@DomName('DOMWindow.webkitRequestFileSystem')
@DocsEditable
@@ -27649,10 +26560,6 @@
@DocsEditable
Stream<Event> get onAbort => Element.abortEvent.forTarget(this);
- @DomName('DOMWindow.onbeforeunload')
- @DocsEditable
- Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
-
@DomName('DOMWindow.onblur')
@DocsEditable
Stream<Event> get onBlur => Element.blurEvent.forTarget(this);
@@ -27857,6 +26764,65 @@
@DocsEditable
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
+
+ @DomName('DOMWindow.beforeunloadEvent')
+ @DocsEditable
+ static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
+ const _BeforeUnloadEventStreamProvider('beforeunload');
+
+ @DomName('DOMWindow.onbeforeunload')
+ @DocsEditable
+ Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
+}
+
+/**
+ * Event object that is fired before the window is closed.
+ *
+ * The standard window close behavior can be prevented by setting the
+ * [returnValue]. This will display a dialog to the user confirming that they
+ * want to close the page.
+ */
+abstract class BeforeUnloadEvent implements Event {
+ /**
+ * If set to a non-null value, a dialog will be presented to the user
+ * confirming that they want to close the page.
+ */
+ String returnValue;
+}
+
+class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent {
+ String _returnValue;
+
+ _BeforeUnloadEvent(Event base): super(base);
+
+ String get returnValue => _returnValue;
+
+ void set returnValue(String value) {
+ _returnValue = value;
+ }
+}
+
+class _BeforeUnloadEventStreamProvider implements
+ EventStreamProvider<BeforeUnloadEvent> {
+ final String _eventType;
+
+ const _BeforeUnloadEventStreamProvider(this._eventType);
+
+ Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) {
+ var controller = new StreamController.broadcast();
+ var stream = new _EventStream(e, _eventType, useCapture);
+ stream.listen((event) {
+ var wrapped = new _BeforeUnloadEvent(event);
+ controller.add(wrapped);
+ return wrapped.returnValue;
+ });
+
+ return controller.stream;
+ }
+
+ String getEventType(EventTarget target) {
+ return _eventType;
+ }
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -27867,6 +26833,10 @@
@DocsEditable
@DomName('Worker')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.FIREFOX)
+@SupportedBrowser(SupportedBrowser.IE, '10')
+@SupportedBrowser(SupportedBrowser.SAFARI)
class Worker extends AbstractWorker {
Worker.internal() : super.internal();
@@ -27883,6 +26853,9 @@
@DocsEditable
static Worker _create_1(scriptUrl) native "Worker__create_1constructorCallback";
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => true;
+
@DomName('Worker.postMessage')
@DocsEditable
void postMessage(/*SerializedScriptValue*/ message, [List messagePorts]) native "Worker_postMessage_Callback";
@@ -27896,289 +26869,6 @@
Stream<MessageEvent> get onMessage => messageEvent.forTarget(this);
}
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DomName('WorkerContext')
-class WorkerContext extends EventTarget {
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. Returns a [Future] whose value stores a reference to the
- * sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystem')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
- return _requestFileSystem(persistent? 1 : 0, size);
- }
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. This call will block until a reference to the synchronous file
- * system API has been obtained. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystemSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- FileSystemSync requestFileSystemSync(int size, {bool persistent: false}) {
- return _requestFileSystemSync(persistent? 1 : 0, size);
- }
- WorkerContext.internal() : super.internal();
-
- @DomName('WorkerContext.errorEvent')
- @DocsEditable
- static const EventStreamProvider<Event> errorEvent = const EventStreamProvider<Event>('error');
-
- static const int PERSISTENT = 1;
-
- static const int TEMPORARY = 0;
-
- @DomName('WorkerContext.indexedDB')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.FIREFOX, '15')
- @SupportedBrowser(SupportedBrowser.IE, '10')
- @Experimental
- IdbFactory get indexedDB native "WorkerContext_indexedDB_Getter";
-
- @DomName('WorkerContext.location')
- @DocsEditable
- WorkerLocation get location native "WorkerContext_location_Getter";
-
- @DomName('WorkerContext.navigator')
- @DocsEditable
- WorkerNavigator get navigator native "WorkerContext_navigator_Getter";
-
- @DomName('WorkerContext.self')
- @DocsEditable
- WorkerContext get self native "WorkerContext_self_Getter";
-
- @DomName('WorkerContext.webkitNotifications')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- NotificationCenter get notifications native "WorkerContext_webkitNotifications_Getter";
-
- @DomName('WorkerContext.addEventListener')
- @DocsEditable
- void $dom_addEventListener(String type, EventListener listener, [bool useCapture]) native "WorkerContext_addEventListener_Callback";
-
- @DomName('WorkerContext.clearInterval')
- @DocsEditable
- void clearInterval(int handle) native "WorkerContext_clearInterval_Callback";
-
- @DomName('WorkerContext.clearTimeout')
- @DocsEditable
- void clearTimeout(int handle) native "WorkerContext_clearTimeout_Callback";
-
- @DomName('WorkerContext.close')
- @DocsEditable
- void close() native "WorkerContext_close_Callback";
-
- @DomName('WorkerContext.dispatchEvent')
- @DocsEditable
- bool dispatchEvent(Event evt) native "WorkerContext_dispatchEvent_Callback";
-
- @DomName('WorkerContext.importScripts')
- @DocsEditable
- void importScripts() native "WorkerContext_importScripts_Callback";
-
- @DomName('WorkerContext.openDatabase')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- SqlDatabase openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native "WorkerContext_openDatabase_Callback";
-
- @DomName('WorkerContext.openDatabaseSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- SqlDatabaseSync openDatabaseSync(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback]) native "WorkerContext_openDatabaseSync_Callback";
-
- @DomName('WorkerContext.removeEventListener')
- @DocsEditable
- void $dom_removeEventListener(String type, EventListener listener, [bool useCapture]) native "WorkerContext_removeEventListener_Callback";
-
- @DomName('WorkerContext.setInterval')
- @DocsEditable
- int setInterval(Object handler, int timeout) native "WorkerContext_setInterval_Callback";
-
- @DomName('WorkerContext.setTimeout')
- @DocsEditable
- int setTimeout(Object handler, int timeout) native "WorkerContext_setTimeout_Callback";
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. Returns a [Future] whose value stores a reference to the
- * sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystem')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- void __requestFileSystem(int type, int size, [_FileSystemCallback successCallback, _ErrorCallback errorCallback]) native "WorkerContext_webkitRequestFileSystem_Callback";
-
- Future<FileSystem> _requestFileSystem(int type, int size) {
- var completer = new Completer<FileSystem>();
- __requestFileSystem(type, size,
- (value) { completer.complete(value); },
- (error) { completer.completeError(error); });
- return completer.future;
- }
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. This call will block until a reference to the synchronous file
- * system API has been obtained. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystemSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- FileSystemSync _requestFileSystemSync(int type, int size) native "WorkerContext_webkitRequestFileSystemSync_Callback";
-
- @DomName('WorkerContext.webkitResolveLocalFileSystemSyncURL')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- EntrySync resolveLocalFileSystemSyncUrl(String url) native "WorkerContext_webkitResolveLocalFileSystemSyncURL_Callback";
-
- @DomName('WorkerContext.webkitResolveLocalFileSystemURL')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- void _resolveLocalFileSystemUrl(String url, _EntryCallback successCallback, [_ErrorCallback errorCallback]) native "WorkerContext_webkitResolveLocalFileSystemURL_Callback";
-
- Future<Entry> resolveLocalFileSystemUrl(String url) {
- var completer = new Completer<Entry>();
- _resolveLocalFileSystemUrl(url,
- (value) { completer.complete(value); },
- (error) { completer.completeError(error); });
- return completer.future;
- }
-
- @DomName('WorkerContext.onerror')
- @DocsEditable
- Stream<Event> get onError => errorEvent.forTarget(this);
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('WorkerLocation')
-class WorkerLocation extends NativeFieldWrapperClass1 {
- WorkerLocation.internal();
-
- @DomName('WorkerLocation.hash')
- @DocsEditable
- String get hash native "WorkerLocation_hash_Getter";
-
- @DomName('WorkerLocation.host')
- @DocsEditable
- String get host native "WorkerLocation_host_Getter";
-
- @DomName('WorkerLocation.hostname')
- @DocsEditable
- String get hostname native "WorkerLocation_hostname_Getter";
-
- @DomName('WorkerLocation.href')
- @DocsEditable
- String get href native "WorkerLocation_href_Getter";
-
- @DomName('WorkerLocation.pathname')
- @DocsEditable
- String get pathname native "WorkerLocation_pathname_Getter";
-
- @DomName('WorkerLocation.port')
- @DocsEditable
- String get port native "WorkerLocation_port_Getter";
-
- @DomName('WorkerLocation.protocol')
- @DocsEditable
- String get protocol native "WorkerLocation_protocol_Getter";
-
- @DomName('WorkerLocation.search')
- @DocsEditable
- String get search native "WorkerLocation_search_Getter";
-
- @DomName('WorkerLocation.toString')
- @DocsEditable
- String toString() native "WorkerLocation_toString_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('WorkerNavigator')
-class WorkerNavigator extends NativeFieldWrapperClass1 {
- WorkerNavigator.internal();
-
- @DomName('WorkerNavigator.appName')
- @DocsEditable
- String get appName native "WorkerNavigator_appName_Getter";
-
- @DomName('WorkerNavigator.appVersion')
- @DocsEditable
- String get appVersion native "WorkerNavigator_appVersion_Getter";
-
- @DomName('WorkerNavigator.onLine')
- @DocsEditable
- bool get onLine native "WorkerNavigator_onLine_Getter";
-
- @DomName('WorkerNavigator.platform')
- @DocsEditable
- String get platform native "WorkerNavigator_platform_Getter";
-
- @DomName('WorkerNavigator.userAgent')
- @DocsEditable
- String get userAgent native "WorkerNavigator_userAgent_Getter";
-
- @DomName('WorkerNavigator.webkitPersistentStorage')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- StorageQuota get persistentStorage native "WorkerNavigator_webkitPersistentStorage_Getter";
-
- @DomName('WorkerNavigator.webkitTemporaryStorage')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @SupportedBrowser(SupportedBrowser.SAFARI)
- @Experimental
- StorageQuota get temporaryStorage native "WorkerNavigator_webkitTemporaryStorage_Getter";
-
-}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -28435,6 +27125,32 @@
DocumentFragment transformToFragment(Node source, Document docVal) native "XSLTProcessor_transformToFragment_Callback";
}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('CSSPrimitiveValue')
+abstract class _CSSPrimitiveValue extends _CSSValue {
+ _CSSPrimitiveValue.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('CSSValue')
+abstract class _CSSValue extends NativeFieldWrapperClass1 {
+ _CSSValue.internal();
+
+}
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -28594,11 +27310,12 @@
return new FixedSizeListIterator<Rect>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Rect)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Rect reduce(Rect combine(Rect value, Rect element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Rect)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Rect element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -28606,7 +27323,7 @@
void forEach(void f(Rect element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Rect element)) =>
@@ -28708,12 +27425,6 @@
throw new StateError("More than one element");
}
- Rect min([int compare(Rect a, Rect b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Rect max([int compare(Rect a, Rect b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Rect element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -28730,14 +27441,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Rect element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -28758,17 +27461,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Rect> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Rect> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Rect>[]);
}
- List<Rect> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Rect> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Rect> mixins.
@DomName('ClientRectList.item')
@@ -28784,6 +27494,19 @@
@DocsEditable
+@DomName('Counter')
+abstract class _Counter extends NativeFieldWrapperClass1 {
+ _Counter.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
@DomName('CSSRuleList')
class _CssRuleList extends NativeFieldWrapperClass1 implements List<CssRule> {
_CssRuleList.internal();
@@ -28809,11 +27532,12 @@
return new FixedSizeListIterator<CssRule>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ CssRule reduce(CssRule combine(CssRule value, CssRule element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, CssRule element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -28821,7 +27545,7 @@
void forEach(void f(CssRule element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(CssRule element)) =>
@@ -28923,12 +27647,6 @@
throw new StateError("More than one element");
}
- CssRule min([int compare(CssRule a, CssRule b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- CssRule max([int compare(CssRule a, CssRule b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, CssRule element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -28945,14 +27663,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(CssRule element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -28973,17 +27683,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<CssRule> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<CssRule> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <CssRule>[]);
}
- List<CssRule> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, CssRule> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<CssRule> mixins.
@DomName('CSSRuleList.item')
@@ -29000,104 +27717,105 @@
@DocsEditable
@DomName('CSSValueList')
-class _CssValueList extends CssValue implements List<CssValue> {
+class _CssValueList extends _CSSValue implements List<_CSSValue> {
_CssValueList.internal() : super.internal();
@DomName('CSSValueList.length')
@DocsEditable
int get length native "CSSValueList_length_Getter";
- CssValue operator[](int index) native "CSSValueList_item_Callback";
+ _CSSValue operator[](int index) native "CSSValueList_item_Callback";
- void operator[]=(int index, CssValue value) {
+ void operator[]=(int index, _CSSValue value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
- // -- start List<CssValue> mixins.
- // CssValue is the element type.
+ // -- start List<_CSSValue> mixins.
+ // _CSSValue is the element type.
- // From Iterable<CssValue>:
+ // From Iterable<_CSSValue>:
- Iterator<CssValue> get iterator {
+ Iterator<_CSSValue> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
- return new FixedSizeListIterator<CssValue>(this);
+ return new FixedSizeListIterator<_CSSValue>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ _CSSValue reduce(_CSSValue combine(_CSSValue value, _CSSValue element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, _CSSValue element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
- bool contains(CssValue element) => IterableMixinWorkaround.contains(this, element);
+ bool contains(_CSSValue element) => IterableMixinWorkaround.contains(this, element);
- void forEach(void f(CssValue element)) => IterableMixinWorkaround.forEach(this, f);
+ void forEach(void f(_CSSValue element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
- Iterable map(f(CssValue element)) =>
+ Iterable map(f(_CSSValue element)) =>
IterableMixinWorkaround.mapList(this, f);
- Iterable<CssValue> where(bool f(CssValue element)) =>
+ Iterable<_CSSValue> where(bool f(_CSSValue element)) =>
IterableMixinWorkaround.where(this, f);
- Iterable expand(Iterable f(CssValue element)) =>
+ Iterable expand(Iterable f(_CSSValue element)) =>
IterableMixinWorkaround.expand(this, f);
- bool every(bool f(CssValue element)) => IterableMixinWorkaround.every(this, f);
+ bool every(bool f(_CSSValue element)) => IterableMixinWorkaround.every(this, f);
- bool any(bool f(CssValue element)) => IterableMixinWorkaround.any(this, f);
+ bool any(bool f(_CSSValue element)) => IterableMixinWorkaround.any(this, f);
- List<CssValue> toList({ bool growable: true }) =>
- new List<CssValue>.from(this, growable: growable);
+ List<_CSSValue> toList({ bool growable: true }) =>
+ new List<_CSSValue>.from(this, growable: growable);
- Set<CssValue> toSet() => new Set<CssValue>.from(this);
+ Set<_CSSValue> toSet() => new Set<_CSSValue>.from(this);
bool get isEmpty => this.length == 0;
- Iterable<CssValue> take(int n) => IterableMixinWorkaround.takeList(this, n);
+ Iterable<_CSSValue> take(int n) => IterableMixinWorkaround.takeList(this, n);
- Iterable<CssValue> takeWhile(bool test(CssValue value)) {
+ Iterable<_CSSValue> takeWhile(bool test(_CSSValue value)) {
return IterableMixinWorkaround.takeWhile(this, test);
}
- Iterable<CssValue> skip(int n) => IterableMixinWorkaround.skipList(this, n);
+ Iterable<_CSSValue> skip(int n) => IterableMixinWorkaround.skipList(this, n);
- Iterable<CssValue> skipWhile(bool test(CssValue value)) {
+ Iterable<_CSSValue> skipWhile(bool test(_CSSValue value)) {
return IterableMixinWorkaround.skipWhile(this, test);
}
- CssValue firstWhere(bool test(CssValue value), { CssValue orElse() }) {
+ _CSSValue firstWhere(bool test(_CSSValue value), { _CSSValue orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
- CssValue lastWhere(bool test(CssValue value), {CssValue orElse()}) {
+ _CSSValue lastWhere(bool test(_CSSValue value), {_CSSValue orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
- CssValue singleWhere(bool test(CssValue value)) {
+ _CSSValue singleWhere(bool test(_CSSValue value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
- CssValue elementAt(int index) {
+ _CSSValue elementAt(int index) {
return this[index];
}
- // From Collection<CssValue>:
+ // From Collection<_CSSValue>:
- void add(CssValue value) {
+ void add(_CSSValue value) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- void addAll(Iterable<CssValue> iterable) {
+ void addAll(Iterable<_CSSValue> iterable) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- // From List<CssValue>:
+ // From List<_CSSValue>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
}
@@ -29106,53 +27824,47 @@
throw new UnsupportedError("Cannot clear immutable List.");
}
- Iterable<CssValue> get reversed {
+ Iterable<_CSSValue> get reversed {
return IterableMixinWorkaround.reversedList(this);
}
- void sort([int compare(CssValue a, CssValue b)]) {
+ void sort([int compare(_CSSValue a, _CSSValue b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(CssValue element, [int start = 0]) =>
+ int indexOf(_CSSValue element, [int start = 0]) =>
Lists.indexOf(this, element, start, this.length);
- int lastIndexOf(CssValue element, [int start]) {
+ int lastIndexOf(_CSSValue element, [int start]) {
if (start == null) start = length - 1;
return Lists.lastIndexOf(this, element, start);
}
- CssValue get first {
+ _CSSValue get first {
if (this.length > 0) return this[0];
throw new StateError("No elements");
}
- CssValue get last {
+ _CSSValue get last {
if (this.length > 0) return this[this.length - 1];
throw new StateError("No elements");
}
- CssValue get single {
+ _CSSValue get single {
if (length == 1) return this[0];
if (length == 0) throw new StateError("No elements");
throw new StateError("More than one element");
}
- CssValue min([int compare(CssValue a, CssValue b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- CssValue max([int compare(CssValue a, CssValue b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
- void insert(int index, CssValue element) {
+ void insert(int index, _CSSValue element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- CssValue removeAt(int pos) {
+ _CSSValue removeAt(int pos) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- CssValue removeLast() {
+ _CSSValue removeLast() {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -29160,23 +27872,15 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
+ void removeWhere(bool test(_CSSValue element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void retainAll(Iterable elements) {
+ void retainWhere(bool test(_CSSValue element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeWhere(bool test(CssValue element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainWhere(bool test(CssValue element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void setRange(int start, int rangeLength, List<CssValue> from, [int startFrom]) {
+ void setRange(int start, int rangeLength, List<_CSSValue> from, [int startFrom]) {
throw new UnsupportedError("Cannot setRange on immutable List.");
}
@@ -29184,26 +27888,126 @@
throw new UnsupportedError("Cannot removeRange on immutable List.");
}
- void insertRange(int start, int rangeLength, [CssValue initialValue]) {
+ void insertRange(int start, int rangeLength, [_CSSValue initialValue]) {
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
- List<CssValue> sublist(int start, [int end]) {
+ Iterable<_CSSValue> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
+ List<_CSSValue> sublist(int start, [int end]) {
if (end == null) end = length;
- return Lists.getRange(this, start, end, <CssValue>[]);
+ return Lists.getRange(this, start, end, <_CSSValue>[]);
}
- List<CssValue> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- Map<int, CssValue> asMap() =>
+ Map<int, _CSSValue> asMap() =>
IterableMixinWorkaround.asMapList(this);
- // -- end List<CssValue> mixins.
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
+ // -- end List<_CSSValue> mixins.
@DomName('CSSValueList.item')
@DocsEditable
- CssValue item(int index) native "CSSValueList_item_Callback";
+ _CSSValue item(int index) native "CSSValueList_item_Callback";
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('DOMFileSystemSync')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@Experimental
+abstract class _DOMFileSystemSync extends NativeFieldWrapperClass1 {
+ _DOMFileSystemSync.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('DedicatedWorkerContext')
+abstract class _DedicatedWorkerContext extends _WorkerContext {
+ _DedicatedWorkerContext.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('DirectoryEntrySync')
+abstract class _DirectoryEntrySync extends _EntrySync {
+ _DirectoryEntrySync.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('DirectoryReaderSync')
+abstract class _DirectoryReaderSync extends NativeFieldWrapperClass1 {
+ _DirectoryReaderSync.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WebKitPoint')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.SAFARI)
+@Experimental
+class _DomPoint extends NativeFieldWrapperClass1 {
+ _DomPoint.internal();
+ factory _DomPoint(num x, num y) => _create(x, y);
+
+ @DocsEditable
+ static _DomPoint _create(x, y) native "WebKitPoint_constructorCallback";
+
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => true;
+
+ @DomName('WebKitPoint.x')
+ @DocsEditable
+ num get x native "WebKitPoint_x_Getter";
+
+ @DomName('WebKitPoint.x')
+ @DocsEditable
+ void set x(num value) native "WebKitPoint_x_Setter";
+
+ @DomName('WebKitPoint.y')
+ @DocsEditable
+ num get y native "WebKitPoint_y_Getter";
+
+ @DomName('WebKitPoint.y')
+ @DocsEditable
+ void set y(num value) native "WebKitPoint_y_Setter";
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -29382,11 +28186,12 @@
return new FixedSizeListIterator<Entry>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Entry)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Entry reduce(Entry combine(Entry value, Entry element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Entry)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Entry element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -29394,7 +28199,7 @@
void forEach(void f(Entry element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Entry element)) =>
@@ -29496,12 +28301,6 @@
throw new StateError("More than one element");
}
- Entry min([int compare(Entry a, Entry b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Entry max([int compare(Entry a, Entry b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Entry element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -29518,14 +28317,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Entry element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -29546,17 +28337,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Entry> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Entry> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Entry>[]);
}
- List<Entry> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Entry> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Entry> mixins.
@DomName('EntryArray.item')
@@ -29573,104 +28371,105 @@
@DocsEditable
@DomName('EntryArraySync')
-class _EntryArraySync extends NativeFieldWrapperClass1 implements List<EntrySync> {
+class _EntryArraySync extends NativeFieldWrapperClass1 implements List<_EntrySync> {
_EntryArraySync.internal();
@DomName('EntryArraySync.length')
@DocsEditable
int get length native "EntryArraySync_length_Getter";
- EntrySync operator[](int index) native "EntryArraySync_item_Callback";
+ _EntrySync operator[](int index) native "EntryArraySync_item_Callback";
- void operator[]=(int index, EntrySync value) {
+ void operator[]=(int index, _EntrySync value) {
throw new UnsupportedError("Cannot assign element of immutable List.");
}
- // -- start List<EntrySync> mixins.
- // EntrySync is the element type.
+ // -- start List<_EntrySync> mixins.
+ // _EntrySync is the element type.
- // From Iterable<EntrySync>:
+ // From Iterable<_EntrySync>:
- Iterator<EntrySync> get iterator {
+ Iterator<_EntrySync> get iterator {
// Note: NodeLists are not fixed size. And most probably length shouldn't
// be cached in both iterator _and_ forEach method. For now caching it
// for consistency.
- return new FixedSizeListIterator<EntrySync>(this);
+ return new FixedSizeListIterator<_EntrySync>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ _EntrySync reduce(_EntrySync combine(_EntrySync value, _EntrySync element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, _EntrySync element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
- bool contains(EntrySync element) => IterableMixinWorkaround.contains(this, element);
+ bool contains(_EntrySync element) => IterableMixinWorkaround.contains(this, element);
- void forEach(void f(EntrySync element)) => IterableMixinWorkaround.forEach(this, f);
+ void forEach(void f(_EntrySync element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
- Iterable map(f(EntrySync element)) =>
+ Iterable map(f(_EntrySync element)) =>
IterableMixinWorkaround.mapList(this, f);
- Iterable<EntrySync> where(bool f(EntrySync element)) =>
+ Iterable<_EntrySync> where(bool f(_EntrySync element)) =>
IterableMixinWorkaround.where(this, f);
- Iterable expand(Iterable f(EntrySync element)) =>
+ Iterable expand(Iterable f(_EntrySync element)) =>
IterableMixinWorkaround.expand(this, f);
- bool every(bool f(EntrySync element)) => IterableMixinWorkaround.every(this, f);
+ bool every(bool f(_EntrySync element)) => IterableMixinWorkaround.every(this, f);
- bool any(bool f(EntrySync element)) => IterableMixinWorkaround.any(this, f);
+ bool any(bool f(_EntrySync element)) => IterableMixinWorkaround.any(this, f);
- List<EntrySync> toList({ bool growable: true }) =>
- new List<EntrySync>.from(this, growable: growable);
+ List<_EntrySync> toList({ bool growable: true }) =>
+ new List<_EntrySync>.from(this, growable: growable);
- Set<EntrySync> toSet() => new Set<EntrySync>.from(this);
+ Set<_EntrySync> toSet() => new Set<_EntrySync>.from(this);
bool get isEmpty => this.length == 0;
- Iterable<EntrySync> take(int n) => IterableMixinWorkaround.takeList(this, n);
+ Iterable<_EntrySync> take(int n) => IterableMixinWorkaround.takeList(this, n);
- Iterable<EntrySync> takeWhile(bool test(EntrySync value)) {
+ Iterable<_EntrySync> takeWhile(bool test(_EntrySync value)) {
return IterableMixinWorkaround.takeWhile(this, test);
}
- Iterable<EntrySync> skip(int n) => IterableMixinWorkaround.skipList(this, n);
+ Iterable<_EntrySync> skip(int n) => IterableMixinWorkaround.skipList(this, n);
- Iterable<EntrySync> skipWhile(bool test(EntrySync value)) {
+ Iterable<_EntrySync> skipWhile(bool test(_EntrySync value)) {
return IterableMixinWorkaround.skipWhile(this, test);
}
- EntrySync firstWhere(bool test(EntrySync value), { EntrySync orElse() }) {
+ _EntrySync firstWhere(bool test(_EntrySync value), { _EntrySync orElse() }) {
return IterableMixinWorkaround.firstWhere(this, test, orElse);
}
- EntrySync lastWhere(bool test(EntrySync value), {EntrySync orElse()}) {
+ _EntrySync lastWhere(bool test(_EntrySync value), {_EntrySync orElse()}) {
return IterableMixinWorkaround.lastWhereList(this, test, orElse);
}
- EntrySync singleWhere(bool test(EntrySync value)) {
+ _EntrySync singleWhere(bool test(_EntrySync value)) {
return IterableMixinWorkaround.singleWhere(this, test);
}
- EntrySync elementAt(int index) {
+ _EntrySync elementAt(int index) {
return this[index];
}
- // From Collection<EntrySync>:
+ // From Collection<_EntrySync>:
- void add(EntrySync value) {
+ void add(_EntrySync value) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- void addAll(Iterable<EntrySync> iterable) {
+ void addAll(Iterable<_EntrySync> iterable) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- // From List<EntrySync>:
+ // From List<_EntrySync>:
void set length(int value) {
throw new UnsupportedError("Cannot resize immutable List.");
}
@@ -29679,53 +28478,47 @@
throw new UnsupportedError("Cannot clear immutable List.");
}
- Iterable<EntrySync> get reversed {
+ Iterable<_EntrySync> get reversed {
return IterableMixinWorkaround.reversedList(this);
}
- void sort([int compare(EntrySync a, EntrySync b)]) {
+ void sort([int compare(_EntrySync a, _EntrySync b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(EntrySync element, [int start = 0]) =>
+ int indexOf(_EntrySync element, [int start = 0]) =>
Lists.indexOf(this, element, start, this.length);
- int lastIndexOf(EntrySync element, [int start]) {
+ int lastIndexOf(_EntrySync element, [int start]) {
if (start == null) start = length - 1;
return Lists.lastIndexOf(this, element, start);
}
- EntrySync get first {
+ _EntrySync get first {
if (this.length > 0) return this[0];
throw new StateError("No elements");
}
- EntrySync get last {
+ _EntrySync get last {
if (this.length > 0) return this[this.length - 1];
throw new StateError("No elements");
}
- EntrySync get single {
+ _EntrySync get single {
if (length == 1) return this[0];
if (length == 0) throw new StateError("No elements");
throw new StateError("More than one element");
}
- EntrySync min([int compare(EntrySync a, EntrySync b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- EntrySync max([int compare(EntrySync a, EntrySync b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
- void insert(int index, EntrySync element) {
+ void insert(int index, _EntrySync element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
- EntrySync removeAt(int pos) {
+ _EntrySync removeAt(int pos) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- EntrySync removeLast() {
+ _EntrySync removeLast() {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -29733,23 +28526,15 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
+ void removeWhere(bool test(_EntrySync element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void retainAll(Iterable elements) {
+ void retainWhere(bool test(_EntrySync element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeWhere(bool test(EntrySync element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainWhere(bool test(EntrySync element)) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void setRange(int start, int rangeLength, List<EntrySync> from, [int startFrom]) {
+ void setRange(int start, int rangeLength, List<_EntrySync> from, [int startFrom]) {
throw new UnsupportedError("Cannot setRange on immutable List.");
}
@@ -29757,26 +28542,94 @@
throw new UnsupportedError("Cannot removeRange on immutable List.");
}
- void insertRange(int start, int rangeLength, [EntrySync initialValue]) {
+ void insertRange(int start, int rangeLength, [_EntrySync initialValue]) {
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
- List<EntrySync> sublist(int start, [int end]) {
+ Iterable<_EntrySync> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
+ List<_EntrySync> sublist(int start, [int end]) {
if (end == null) end = length;
- return Lists.getRange(this, start, end, <EntrySync>[]);
+ return Lists.getRange(this, start, end, <_EntrySync>[]);
}
- List<EntrySync> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- Map<int, EntrySync> asMap() =>
+ Map<int, _EntrySync> asMap() =>
IterableMixinWorkaround.asMapList(this);
- // -- end List<EntrySync> mixins.
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
+ // -- end List<_EntrySync> mixins.
@DomName('EntryArraySync.item')
@DocsEditable
- EntrySync item(int index) native "EntryArraySync_item_Callback";
+ _EntrySync item(int index) native "EntryArraySync_item_Callback";
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('EntrySync')
+abstract class _EntrySync extends NativeFieldWrapperClass1 {
+ _EntrySync.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('FileEntrySync')
+abstract class _FileEntrySync extends _EntrySync {
+ _FileEntrySync.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('FileReaderSync')
+abstract class _FileReaderSync extends NativeFieldWrapperClass1 {
+ _FileReaderSync.internal();
+
+ @DomName('FileReaderSync.FileReaderSync')
+ @DocsEditable
+ factory _FileReaderSync() {
+ return _FileReaderSync._create_1();
+ }
+
+ @DocsEditable
+ static _FileReaderSync _create_1() native "FileReaderSync__create_1constructorCallback";
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('FileWriterSync')
+abstract class _FileWriterSync extends NativeFieldWrapperClass1 {
+ _FileWriterSync.internal();
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -29812,11 +28665,12 @@
return new FixedSizeListIterator<Gamepad>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Gamepad reduce(Gamepad combine(Gamepad value, Gamepad element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Gamepad element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -29824,7 +28678,7 @@
void forEach(void f(Gamepad element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Gamepad element)) =>
@@ -29926,12 +28780,6 @@
throw new StateError("More than one element");
}
- Gamepad min([int compare(Gamepad a, Gamepad b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Gamepad max([int compare(Gamepad a, Gamepad b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Gamepad element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -29948,14 +28796,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Gamepad element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -29976,17 +28816,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Gamepad> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Gamepad> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Gamepad>[]);
}
- List<Gamepad> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Gamepad> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Gamepad> mixins.
@DomName('GamepadList.item')
@@ -30003,7 +28850,7 @@
@DocsEditable
@DomName('HTMLAppletElement')
-class _HTMLAppletElement extends _Element_Merged {
+abstract class _HTMLAppletElement extends _Element_Merged {
_HTMLAppletElement.internal() : super.internal();
}
@@ -30016,7 +28863,7 @@
@DocsEditable
@DomName('HTMLBaseFontElement')
-class _HTMLBaseFontElement extends _Element_Merged {
+abstract class _HTMLBaseFontElement extends _Element_Merged {
_HTMLBaseFontElement.internal() : super.internal();
}
@@ -30029,7 +28876,7 @@
@DocsEditable
@DomName('HTMLDirectoryElement')
-class _HTMLDirectoryElement extends _Element_Merged {
+abstract class _HTMLDirectoryElement extends _Element_Merged {
_HTMLDirectoryElement.internal() : super.internal();
}
@@ -30042,7 +28889,7 @@
@DocsEditable
@DomName('HTMLFontElement')
-class _HTMLFontElement extends _Element_Merged {
+abstract class _HTMLFontElement extends _Element_Merged {
_HTMLFontElement.internal() : super.internal();
}
@@ -30055,7 +28902,7 @@
@DocsEditable
@DomName('HTMLFrameElement')
-class _HTMLFrameElement extends _Element_Merged {
+abstract class _HTMLFrameElement extends _Element_Merged {
_HTMLFrameElement.internal() : super.internal();
}
@@ -30068,7 +28915,7 @@
@DocsEditable
@DomName('HTMLFrameSetElement')
-class _HTMLFrameSetElement extends _Element_Merged {
+abstract class _HTMLFrameSetElement extends _Element_Merged {
_HTMLFrameSetElement.internal() : super.internal();
}
@@ -30081,7 +28928,7 @@
@DocsEditable
@DomName('HTMLMarqueeElement')
-class _HTMLMarqueeElement extends _Element_Merged {
+abstract class _HTMLMarqueeElement extends _Element_Merged {
_HTMLMarqueeElement.internal() : super.internal();
}
@@ -30118,11 +28965,12 @@
return new FixedSizeListIterator<Node>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Node)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Node reduce(Node combine(Node value, Node element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Node element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -30130,7 +28978,7 @@
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Node element)) =>
@@ -30232,12 +29080,6 @@
throw new StateError("More than one element");
}
- Node min([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Node max([int compare(Node a, Node b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Node element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -30254,14 +29096,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Node element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -30282,17 +29116,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Node> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Node> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Node> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Node> mixins.
@DomName('NamedNodeMap.getNamedItem')
@@ -30332,6 +29173,67 @@
@DocsEditable
+@DomName('RGBColor')
+abstract class _RGBColor extends NativeFieldWrapperClass1 {
+ _RGBColor.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('Rect')
+abstract class _Rect extends NativeFieldWrapperClass1 {
+ _Rect.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SharedWorker')
+abstract class _SharedWorker extends AbstractWorker {
+ _SharedWorker.internal() : super.internal();
+
+ @DomName('SharedWorker.SharedWorker')
+ @DocsEditable
+ factory _SharedWorker(String scriptURL, [String name]) {
+ return _SharedWorker._create_1(scriptURL, name);
+ }
+
+ @DocsEditable
+ static _SharedWorker _create_1(scriptURL, name) native "SharedWorker__create_1constructorCallback";
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SharedWorkerContext')
+abstract class _SharedWorkerContext extends _WorkerContext {
+ _SharedWorkerContext.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
@DomName('SpeechInputResultList')
class _SpeechInputResultList extends NativeFieldWrapperClass1 implements List<SpeechInputResult> {
_SpeechInputResultList.internal();
@@ -30357,11 +29259,12 @@
return new FixedSizeListIterator<SpeechInputResult>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SpeechInputResult reduce(SpeechInputResult combine(SpeechInputResult value, SpeechInputResult element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SpeechInputResult element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -30369,7 +29272,7 @@
void forEach(void f(SpeechInputResult element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SpeechInputResult element)) =>
@@ -30471,12 +29374,6 @@
throw new StateError("More than one element");
}
- SpeechInputResult min([int compare(SpeechInputResult a, SpeechInputResult b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SpeechInputResult max([int compare(SpeechInputResult a, SpeechInputResult b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SpeechInputResult element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -30493,14 +29390,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SpeechInputResult element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -30521,17 +29410,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SpeechInputResult> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SpeechInputResult> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SpeechInputResult>[]);
}
- List<SpeechInputResult> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SpeechInputResult> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SpeechInputResult> mixins.
@DomName('SpeechInputResultList.item')
@@ -30572,11 +29468,12 @@
return new FixedSizeListIterator<SpeechRecognitionResult>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ SpeechRecognitionResult reduce(SpeechRecognitionResult combine(SpeechRecognitionResult value, SpeechRecognitionResult element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, SpeechRecognitionResult element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -30584,7 +29481,7 @@
void forEach(void f(SpeechRecognitionResult element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(SpeechRecognitionResult element)) =>
@@ -30686,12 +29583,6 @@
throw new StateError("More than one element");
}
- SpeechRecognitionResult min([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- SpeechRecognitionResult max([int compare(SpeechRecognitionResult a, SpeechRecognitionResult b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, SpeechRecognitionResult element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -30708,14 +29599,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(SpeechRecognitionResult element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -30736,17 +29619,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<SpeechRecognitionResult> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<SpeechRecognitionResult> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <SpeechRecognitionResult>[]);
}
- List<SpeechRecognitionResult> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, SpeechRecognitionResult> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<SpeechRecognitionResult> mixins.
@DomName('SpeechRecognitionResultList.item')
@@ -30787,11 +29677,12 @@
return new FixedSizeListIterator<StyleSheet>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ StyleSheet reduce(StyleSheet combine(StyleSheet value, StyleSheet element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, StyleSheet element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -30799,7 +29690,7 @@
void forEach(void f(StyleSheet element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(StyleSheet element)) =>
@@ -30901,12 +29792,6 @@
throw new StateError("More than one element");
}
- StyleSheet min([int compare(StyleSheet a, StyleSheet b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- StyleSheet max([int compare(StyleSheet a, StyleSheet b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, StyleSheet element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -30923,14 +29808,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(StyleSheet element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -30951,17 +29828,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<StyleSheet> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<StyleSheet> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <StyleSheet>[]);
}
- List<StyleSheet> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, StyleSheet> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<StyleSheet> mixins.
@DomName('StyleSheetList.item')
@@ -30973,6 +29857,70 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WebKitCSSFilterValue')
+abstract class _WebKitCSSFilterValue extends _CssValueList {
+ _WebKitCSSFilterValue.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WebKitCSSMatrix')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.SAFARI)
+@Experimental
+abstract class _WebKitCSSMatrix extends NativeFieldWrapperClass1 {
+ _WebKitCSSMatrix.internal();
+
+ @DomName('WebKitCSSMatrix.WebKitCSSMatrix')
+ @DocsEditable
+ factory _WebKitCSSMatrix([String cssValue]) {
+ return _WebKitCSSMatrix._create_1(cssValue);
+ }
+
+ @DocsEditable
+ static _WebKitCSSMatrix _create_1(cssValue) native "WebKitCSSMatrix__create_1constructorCallback";
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WebKitCSSMixFunctionValue')
+abstract class _WebKitCSSMixFunctionValue extends _CssValueList {
+ _WebKitCSSMixFunctionValue.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WebKitCSSTransformValue')
+abstract class _WebKitCSSTransformValue extends _CssValueList {
+ _WebKitCSSTransformValue.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
// This class maps WebKitTransitionEvent to TransitionEvent for older Chrome
// browser versions.
@@ -30996,6 +29944,45 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WorkerContext')
+abstract class _WorkerContext extends EventTarget {
+ _WorkerContext.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WorkerLocation')
+abstract class _WorkerLocation extends NativeFieldWrapperClass1 {
+ _WorkerLocation.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('WorkerNavigator')
+abstract class _WorkerNavigator extends NativeFieldWrapperClass1 {
+ _WorkerNavigator.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
abstract class _AttributeMap implements Map<String, String> {
final Element _element;
@@ -31031,19 +30018,19 @@
}
}
- Collection<String> get keys {
+ Iterable<String> get keys {
// TODO: generate a lazy collection instead.
var attributes = _element.$dom_attributes;
var keys = new List<String>();
for (int i = 0, len = attributes.length; i < len; i++) {
if (_matches(attributes[i])) {
- keys.add(attributes[i].$dom_localName);
+ keys.add(attributes[i].localName);
}
}
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
// TODO: generate a lazy collection instead.
var attributes = _element.$dom_attributes;
var values = new List<String>();
@@ -31184,7 +30171,7 @@
});
}
- Collection<String> get keys {
+ Iterable<String> get keys {
final keys = new List<String>();
$dom_attributes.forEach((String key, String value) {
if (_matches(key)) {
@@ -31194,7 +30181,7 @@
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
final values = new List<String>();
$dom_attributes.forEach((String key, String value) {
if (_matches(key)) {
@@ -31419,7 +30406,7 @@
readClasses().forEach(f);
}
- String join([String separator]) => readClasses().join(separator);
+ String join([String separator = ""]) => readClasses().join(separator);
Iterable map(f(String element)) => readClasses().map(f);
@@ -31435,9 +30422,8 @@
int get length => readClasses().length;
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, String element)) {
- return readClasses().reduce(initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return readClasses().reduce(combine);
}
dynamic fold(dynamic initialValue,
@@ -31526,9 +30512,6 @@
_modify((s) => s.retainWhere(test));
}
- bool isSubsetOf(Collection<String> collection) =>
- readClasses().isSubsetOf(collection);
-
bool containsAll(Iterable<String> collection) =>
readClasses().containsAll(collection);
@@ -31547,10 +30530,6 @@
List<String> toList({ bool growable: true }) =>
readClasses().toList(growable: growable);
Set<String> toSet() => readClasses().toSet();
- String min([int compare(String a, String b)]) =>
- readClasses().min(compare);
- String max([int compare(String a, String b)]) =>
- readClasses().max(compare);
Iterable<String> take(int n) => readClasses().take(n);
Iterable<String> takeWhile(bool test(String value)) =>
readClasses().takeWhile(test);
@@ -31604,7 +30583,7 @@
// BSD-style license that can be found in the LICENSE file.
-typedef void EventListener(Event event);
+typedef EventListener(Event event);
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -33260,6 +32239,59 @@
/**
+ * Helper class to implement custom events which wrap DOM events.
+ */
+class _WrappedEvent implements Event {
+ final Event wrapped;
+ _WrappedEvent(this.wrapped);
+
+ bool get bubbles => wrapped.bubbles;
+
+ bool get cancelBubble => wrapped.bubbles;
+ void set cancelBubble(bool value) {
+ wrapped.cancelBubble = value;
+ }
+
+ bool get cancelable => wrapped.cancelable;
+
+ DataTransfer get clipboardData => wrapped.clipboardData;
+
+ EventTarget get currentTarget => wrapped.currentTarget;
+
+ bool get defaultPrevented => wrapped.defaultPrevented;
+
+ int get eventPhase => wrapped.eventPhase;
+
+ EventTarget get target => wrapped.target;
+
+ int get timeStamp => wrapped.timeStamp;
+
+ String get type => wrapped.type;
+
+ void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
+ bool cancelableArg) {
+ throw new UnsupportedError(
+ 'Cannot initialize this Event.');
+ }
+
+ void preventDefault() {
+ wrapped.preventDefault();
+ }
+
+ void stopImmediatePropagation() {
+ wrapped.stopImmediatePropagation();
+ }
+
+ void stopPropagation() {
+ wrapped.stopPropagation();
+ }
+}
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+/**
* A list which just wraps another list, for either intercepting list calls or
* retyping the list (for example, from List<A> to List<B> where B extends A).
*/
@@ -33282,15 +32314,15 @@
void forEach(void f(E element)) { _list.forEach(f); }
- dynamic reduce(initialValue, combine(previousValue, E element)) =>
- _list.reduce(initialValue, combine);
+ E reduce(E combine(E value, E element)) =>
+ _list.reduce(combine);
dynamic fold(initialValue, combine(previousValue, E element)) =>
_list.fold(initialValue, combine);
bool every(bool f(E element)) => _list.every(f);
- String join([String separator]) => _list.join(separator);
+ String join([String separator = ""]) => _list.join(separator);
bool any(bool f(E element)) => _list.any(f);
@@ -33301,10 +32333,6 @@
int get length => _list.length;
- E min([int compare(E a, E b)]) => _list.min(compare);
-
- E max([int compare(E a, E b)]) => _list.max(compare);
-
bool get isEmpty => _list.isEmpty;
Iterable<E> take(int n) => _list.take(n);
@@ -33339,10 +32367,6 @@
void remove(Object element) { _list.remove(element); }
- void removeAll(Iterable elements) { _list.removeAll(elements); }
-
- void retainAll(Iterable elements) { _list.retainAll(elements); }
-
void removeWhere(bool test(E element)) { _list.removeWhere(test); }
void retainWhere(bool test(E element)) { _list.retainWhere(test); }
@@ -33373,7 +32397,7 @@
List<E> sublist(int start, [int end]) => _list.sublist(start, end);
- List<E> getRange(int start, int length) => sublist(start, start + length);
+ Iterable<E> getRange(int start, int end) => _list.getRange(start, end);
void setRange(int start, int length, List<E> from, [int startFrom]) {
_list.setRange(start, length, from, startFrom);
@@ -33385,7 +32409,14 @@
_list.insertRange(start, length, fill);
}
- Map<int, E> asMap() => IterableMixinWorkaround.asMapList(_list);
+ Map<int, E> asMap() => _list.asMap();
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
}
/**
@@ -33492,7 +32523,7 @@
* on how we can make this class work with as many international keyboards as
* possible. Bugs welcome!
*/
-class KeyEvent implements KeyboardEvent {
+class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
KeyboardEvent _parent;
@@ -33527,7 +32558,7 @@
bool get _realAltKey => _parent.altKey;
/** Construct a KeyEvent with [parent] as the event we're emulating. */
- KeyEvent(KeyboardEvent parent) {
+ KeyEvent(KeyboardEvent parent): super(parent) {
_parent = parent;
_shadowAltKey = _realAltKey;
_shadowCharCode = _realCharCode;
@@ -33546,22 +32577,9 @@
/** True if the altGraphKey is pressed during this event. */
bool get altGraphKey => _parent.altGraphKey;
- bool get bubbles => _parent.bubbles;
- /** True if this event can be cancelled. */
- bool get cancelable => _parent.cancelable;
- bool get cancelBubble => _parent.cancelBubble;
- void set cancelBubble(bool cancel) {
- _parent.cancelBubble = cancel;
- }
- /** Accessor to the clipboardData available for this event. */
- DataTransfer get clipboardData => _parent.clipboardData;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
- /** Accessor to the target this event is listening to for changes. */
- EventTarget get currentTarget => _parent.currentTarget;
- bool get defaultPrevented => _parent.defaultPrevented;
int get detail => _parent.detail;
- int get eventPhase => _parent.eventPhase;
/**
* Accessor to the part of the keyboard that the key was pressed from (one of
* KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
@@ -33572,35 +32590,17 @@
/** True if the Meta (or Mac command) key is pressed during this event. */
bool get metaKey => _parent.metaKey;
Point get page => _parent.page;
- bool get returnValue => _parent.returnValue;
- void set returnValue(bool value) {
- _parent.returnValue = value;
- }
/** True if the shift key was pressed during this event. */
bool get shiftKey => _parent.shiftKey;
- int get timeStamp => _parent.timeStamp;
- /**
- * The type of key event that occurred. One of "keydown", "keyup", or
- * "keypress".
- */
- String get type => _parent.type;
Window get view => _parent.view;
- void preventDefault() => _parent.preventDefault();
- void stopImmediatePropagation() => _parent.stopImmediatePropagation();
- void stopPropagation() => _parent.stopPropagation();
void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
Window view, int detail) {
throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
}
- void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
- bool cancelableArg) {
- throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
- }
String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier;
int get $dom_charCode => charCode;
int get $dom_keyCode => keyCode;
- EventTarget get target => _parent.target;
String get $dom_keyIdentifier {
throw new UnsupportedError("keyIdentifier is unsupported.");
}
@@ -34472,8 +33472,8 @@
String remove(String key) native "DOMStringMap_remove_Callback";
void clear() => Maps.clear(this);
void forEach(void f(String key, String value)) => Maps.forEach(this, f);
- Collection<String> get keys native "DOMStringMap_getKeys_Callback";
- Collection<String> get values => Maps.getValues(this);
+ Iterable<String> get keys native "DOMStringMap_getKeys_Callback";
+ Iterable<String> get values => Maps.getValues(this);
int get length => Maps.length(this);
bool get isEmpty => Maps.isEmpty(this);
}
diff --git a/sdk/lib/html/html_common/filtered_element_list.dart b/sdk/lib/html/html_common/filtered_element_list.dart
index 43d004d..bb253e6 100644
--- a/sdk/lib/html/html_common/filtered_element_list.dart
+++ b/sdk/lib/html/html_common/filtered_element_list.dart
@@ -8,7 +8,7 @@
* An indexable collection of a node's descendants in the document tree,
* filtered so that only elements are in the collection.
*/
-class FilteredElementList implements List {
+class FilteredElementList extends ListBase<Element> {
final Node _node;
final List<Node> _childNodes;
@@ -49,7 +49,7 @@
removeRange(newLength, len - newLength);
}
- String join([String separator]) => _filtered.join(separator);
+ String join([String separator = ""]) => _filtered.join(separator);
void add(Element value) {
_childNodes.add(value);
@@ -122,33 +122,14 @@
}
}
- // Operations defined in terms of [Collections]' [remove].
- void removeAll(Iterable elements) {
- // This should be optimized to not use [remove] directly.
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
- void removeWhere(bool test(Element element)) {
- IterableMixinWorkaround.removeWhere(this, test);
- }
-
- void retainWhere(bool test(Element element)) {
- IterableMixinWorkaround.retainWhere(this, test);
- }
-
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Element reduce(Element combine(Element value, Element element)) {
+ return _filtered.reduce(combine);
}
dynamic fold(dynamic initialValue,
dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
+ return _filtered.fold(initialValue, combine);
}
bool every(bool f(Element element)) => _filtered.every(f);
@@ -178,8 +159,8 @@
Iterator<Element> get iterator => _filtered.iterator;
List<Element> sublist(int start, [int end]) =>
_filtered.sublist(start, end);
- List<Element> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
+ Iterable<Element> getRange(int start, int end) =>
+ _filtered.getRange(start, end);
int indexOf(Element element, [int start = 0]) =>
_filtered.indexOf(element, start);
diff --git a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
index 79a467c..a6d84a6 100644
--- a/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
+++ b/sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart
@@ -1014,7 +1014,7 @@
controller.close();
} else {
controller.add(cursor);
- if (autoAdvance == true && controller.hasSubscribers) {
+ if (autoAdvance == true && controller.hasListener) {
cursor.next();
}
}
@@ -1243,5 +1243,5 @@
@DocsEditable
@DomName('IDBAny')
-class _IDBAny native "*IDBAny" {
+abstract class _IDBAny native "*IDBAny" {
}
diff --git a/sdk/lib/indexed_db/dartium/indexed_db_dartium.dart b/sdk/lib/indexed_db/dartium/indexed_db_dartium.dart
index 0c150df..6fad318 100644
--- a/sdk/lib/indexed_db/dartium/indexed_db_dartium.dart
+++ b/sdk/lib/indexed_db/dartium/indexed_db_dartium.dart
@@ -1073,7 +1073,7 @@
controller.close();
} else {
controller.add(cursor);
- if (autoAdvance == true && controller.hasSubscribers) {
+ if (autoAdvance == true && controller.hasListener) {
cursor.next();
}
}
@@ -1307,7 +1307,7 @@
@DocsEditable
@DomName('IDBAny')
-class _IDBAny extends NativeFieldWrapperClass1 {
+abstract class _IDBAny extends NativeFieldWrapperClass1 {
_IDBAny.internal();
}
diff --git a/sdk/lib/io/common.dart b/sdk/lib/io/common.dart
index d74105b..f4d6907 100644
--- a/sdk/lib/io/common.dart
+++ b/sdk/lib/io/common.dart
@@ -97,3 +97,7 @@
// a user defined List type.
external static bool _isBuiltinList(List buffer);
}
+
+class _IOCrypto {
+ external static Uint8List getRandomBytes(int count);
+}
diff --git a/sdk/lib/io/directory.dart b/sdk/lib/io/directory.dart
index f9bcff5..8c0ad5a 100644
--- a/sdk/lib/io/directory.dart
+++ b/sdk/lib/io/directory.dart
@@ -87,10 +87,16 @@
/**
* Deletes this directory.
*
- * If [recursive] is false, the directory must be empty.
+ * If [recursive] is false, the directory must be empty. Only directories
+ * and links to directories will be deleted.
*
* If [recursive] is true, this directory and all sub-directories
- * and files in the directories are deleted.
+ * and files in the directories are deleted. Links are not followed
+ * when deleting recursively. Only the link is deleted, not its target.
+ *
+ * If [recursive] is true, the target is deleted even if it is a file, or
+ * a link to a file, not only if it is a directory. This behavior allows
+ * [delete] to be used to unconditionally delete any file system object.
*
* Returns a [:Future<Directory>:] that completes with this
* directory when the deletion is done. If the directory cannot be
@@ -104,7 +110,12 @@
* If [recursive] is false, the directory must be empty.
*
* If [recursive] is true, this directory and all sub-directories
- * and files in the directories are deleted.
+ * and files in the directories are deleted. Links are not followed
+ * when deleting recursively. Only the link is deleted, not its target.
+ *
+ * If [recursive] is true, the target is deleted even if it is a file, or
+ * a link to a file, not only if it is a directory. This behavior allows
+ * [delete] to be used to unconditionally delete any file system object.
*
* Throws an exception if the directory cannot be deleted.
*/
@@ -135,9 +146,18 @@
* Optionally recurses into sub-directories.
*
* If [followLinks] is false, then any symbolic links found
- * are reported as links, rather than as directories or files,
+ * are reported as [Link] objects, rather than as directories or files,
* and are not recursed into.
*
+ * If [followLinks] is true, then working links are reported as
+ * directories or files, depending on
+ * their type, and links to directories are recursed into.
+ * Broken links are reported as [Link] objects.
+ * If a symbolic link makes a loop in the file system, then a recursive
+ * listing will not follow a link twice in the
+ * same recursive descent, but will report it as a [Link]
+ * the second time it is seen.
+ *
* The result is a stream of [FileSystemEntity] objects
* for the directories, files, and links.
*/
@@ -149,9 +169,18 @@
* Optionally recurses into sub-directories.
*
* If [followLinks] is false, then any symbolic links found
- * are reported as links, rather than as directories or files,
+ * are reported as [Link] objects, rather than as directories or files,
* and are not recursed into.
*
+ * If [followLinks] is true, then working links are reported as
+ * directories or files, depending on
+ * their type, and links to directories are recursed into.
+ * Broken links are reported as [Link] objects.
+ * If a link makes a loop in the file system, then a recursive
+ * listing will not follow a link twice in the
+ * same recursive descent, but will report it as a [Link]
+ * the second time it is seen.
+ *
* Returns a [List] containing [FileSystemEntity] objects for the
* directories, files, and links.
*/
diff --git a/sdk/lib/io/file.dart b/sdk/lib/io/file.dart
index 85aa1b3..4ebaa70 100644
--- a/sdk/lib/io/file.dart
+++ b/sdk/lib/io/file.dart
@@ -15,6 +15,9 @@
final int _mode;
}
+const READ = FileMode.READ;
+const WRITE = FileMode.WRITE;
+const APPEND = FileMode.APPEND;
/**
* [File] objects are references to files.
@@ -76,12 +79,14 @@
/**
* Delete the file. Returns a [:Future<File>:] that completes with
- * the file when it has been deleted.
+ * the file when it has been deleted. Only a file or a link to a file
+ * can be deleted with this method, not a directory or a broken link.
*/
Future<File> delete();
/**
- * Synchronously delete the file.
+ * Synchronously delete the file. Only a file or a link to a file
+ * can be deleted with this method, not a directory or a broken link.
*
* Throws a [FileIOException] if the operation fails.
*/
diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart
index 57b8cd1..65f7adf 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -130,7 +130,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
_start();
} else {
_unsubscribed = true;
@@ -147,11 +147,10 @@
}
}
-class _FileStreamConsumer extends StreamConsumer<List<int>, File> {
+class _FileStreamConsumer extends StreamConsumer<List<int>> {
File _file;
Future<RandomAccessFile> _openFuture;
StreamSubscription _subscription;
-
_FileStreamConsumer(File this._file, FileMode mode) {
_openFuture = _file.open(mode: mode);
@@ -220,6 +219,8 @@
const int _READ_REQUEST = 16;
const int _READ_LIST_REQUEST = 17;
const int _WRITE_LIST_REQUEST = 18;
+const int _CREATE_LINK_REQUEST = 19;
+const int _DELETE_LINK_REQUEST = 20;
// Base class for _File and _RandomAccessFile with shared functions.
class _FileBase {
@@ -324,6 +325,8 @@
external static _delete(String path);
+ external static _deleteLink(String path);
+
void deleteSync() {
var result = _delete(_path);
throwIfError(result, "Cannot delete file '$_path'");
@@ -554,7 +557,7 @@
{FileMode mode: FileMode.WRITE}) {
try {
IOSink<File> sink = openWrite(mode: mode);
- sink.writeBytes(bytes);
+ sink.add(bytes);
sink.close();
return sink.done.then((_) => this);;
} catch (e) {
diff --git a/sdk/lib/io/http.dart b/sdk/lib/io/http.dart
index 9a54af2..72fd67c 100644
--- a/sdk/lib/io/http.dart
+++ b/sdk/lib/io/http.dart
@@ -688,17 +688,17 @@
* will be determined from the "charset" parameter of the
* "Content-Type" header.
*
- * HttpResponse response = ...
- * response.headers.contentType
- * = new ContentType("application", "json", charset: "utf-8");
- * response.write(...); // Strings written will be UTF-8 encoded.
+ * HttpResponse response = ...
+ * response.headers.contentType
+ * = new ContentType("application", "json", charset: "utf-8");
+ * response.write(...); // Strings written will be UTF-8 encoded.
*
* If no charset is provided the default of ISO-8859-1 (Latin 1) will
* be used.
*
- * HttpResponse response = ...
- * response.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
- * response.write(...); // Strings written will be ISO-8859-1 encoded.
+ * HttpResponse response = ...
+ * response.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
+ * response.write(...); // Strings written will be ISO-8859-1 encoded.
*
* If an unsupported encoding is used an exception will be thrown if
* using one of the write methods taking a string.
@@ -762,13 +762,59 @@
/**
- * HTTP client factory. The [HttpClient] handles all the sockets associated
- * with the [HttpClientConnection]s and when the endpoint supports it, it will
- * try to reuse opened sockets for several requests to support HTTP 1.1
- * persistent connections. This means that sockets will be kept open for some
- * time after a requests have completed, unless HTTP procedures indicate that it
- * must be closed as part of completing the request. Use [:HttpClient.close:]
- * to force close the idle sockets.
+ * The [HttpClient] class implements the client side of the HTTP
+ * protocol. It contains a number of methods to send a HTTP request
+ * to a HTTP server and receive a HTTP response back.
+ *
+ * This is a two-step process, triggered by two futures. When the
+ * first future completes with a [HttpClientRequest] the underlying
+ * network connection has been established, but no data has yet been
+ * sent. The HTTP headers and body can be set on the request, and
+ * [:close:] is called to sent it to the server.
+ *
+ * The second future, which is returned by [:close:], completes with
+ * an [HttpClientResponse] object when the response is received from
+ * the server. This object contains the headers and body of the
+ * response.
+
+ * The future for [HttpClientRequest] is created by methods such as
+ * [getUrl] and [open].
+ *
+ * When the HTTP response is ready a [HttpClientResponse] object is
+ * provided which provides access to the headers and body of the response.
+ *
+ * HttpClient client = new HttpClient();
+ * client.getUrl(new Uri.fromString("http://www.example.com/"))
+ * .then((HttpClientRequest request) {
+ * // Prepare the request then call close on it to send it.
+ * return request.close();
+ * })
+ * .then((HttpClientResponse response) {
+ * // Process the response.
+ * });
+ *
+ * All [HttpClient] requests set the following header by default:
+ *
+ * Accept-Encoding: gzip
+ *
+ * This allows the HTTP server to use gzip compression for the body if
+ * possible. If this behavior is not desired set the
+ * "Accept-Encoding" header to something else.
+ *
+ * The [HttpClient] supports persistent connections and caches network
+ * connections to reuse then for multiple requests whenever
+ * possible. This means that network connections can be kept open for
+ * some time after a request have completed. Use [:HttpClient.close:]
+ * to force shut down the [HttpClient] object and close the idle
+ * network connections.
+ *
+ * By default the HttpClient uses the proxy configuration available
+ * from the environment, see [findProxyFromEnvironment]. To turn off
+ * the use of proxies all together set the [findProxy] property to
+ * [:null:].
+ *
+ * HttpClient client = new HttpClient();
+ * client.findProxy = null;
*/
abstract class HttpClient {
static const int DEFAULT_HTTP_PORT = 80;
@@ -906,17 +952,17 @@
* To activate this way of resolving proxies assign this function to
* the [findProxy] property on the [HttpClient].
*
- * HttpClient client = new HttpClient();
- * client.findProxy = HttpClient.findProxyFromEnvironment;
+ * HttpClient client = new HttpClient();
+ * client.findProxy = HttpClient.findProxyFromEnvironment;
*
* If you don't want to use the system environment you can use a
* different one by wrapping the function.
*
- * HttpClient client = new HttpClient();
- * client.findProxy = (url) {
- * return HttpClient.findProxyFromEnvironment(
- * url, {"http_proxy": ..., "no_proxy": ...});
- * }
+ * HttpClient client = new HttpClient();
+ * client.findProxy = (url) {
+ * return HttpClient.findProxyFromEnvironment(
+ * url, {"http_proxy": ..., "no_proxy": ...});
+ * }
*/
static String findProxyFromEnvironment(Uri url,
{Map<String, String> environment}) {
@@ -951,23 +997,23 @@
* encoding used will be determined from the "charset" parameter of
* the "Content-Type" header.
*
- * HttpClientRequest request = ...
- * request.headers.contentType
- * = new ContentType("application", "json", charset: "utf-8");
- * request.write(...); // Strings written will be UTF-8 encoded.
+ * HttpClientRequest request = ...
+ * request.headers.contentType
+ * = new ContentType("application", "json", charset: "utf-8");
+ * request.write(...); // Strings written will be UTF-8 encoded.
*
* If no charset is provided the default of ISO-8859-1 (Latin 1) will
* be used.
*
- * HttpClientRequest request = ...
- * request.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
- * request.write(...); // Strings written will be ISO-8859-1 encoded.
+ * HttpClientRequest request = ...
+ * request.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
+ * request.write(...); // Strings written will be ISO-8859-1 encoded.
*
* If an unsupported encoding is used an exception will be thrown if
* using one of the write methods taking a string.
*/
abstract class HttpClientRequest
- implements IOSink<HttpClientRequest> {
+ implements IOSink<HttpClientResponse> {
/**
* Gets and sets the content length of the request. If the size of
* the request is not known in advance set content length to -1,
@@ -996,10 +1042,10 @@
* available. If an error occurs before the response is available, this
* future will complete with an error.
*/
- Future<HttpClientResponse> get response;
+ Future<HttpClientResponse> get done;
/**
- * Close the request for input. Returns the value of [response].
+ * Close the request for input. Returns the value of [done].
*/
Future<HttpClientResponse> close();
diff --git a/sdk/lib/io/http_body.dart b/sdk/lib/io/http_body.dart
new file mode 100644
index 0000000..809075e
--- /dev/null
+++ b/sdk/lib/io/http_body.dart
@@ -0,0 +1,139 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.io;
+
+
+/**
+ * [HttpBodyHandler] is a helper class for parsing and collecting HTTP message
+ * data in an easy-to-use [HttpBody] object. The content body is parsed,
+ * depending on the 'Content-Type' header field.
+ *
+ * To use with the [HttpServer] for request messages, [HttpBodyHandler] can be
+ * used as either a [StreamTransformer] or as a per-request handler (see
+ * [processRequest]).
+ *
+ * HttpServer server = ...
+ * server.transform(new HttpBodyHandler())
+ * .listen((HttpRequestBody body) {
+ * ...
+ * });
+ *
+ * To use with the [HttpClient] for response messages, [HttpBodyHandler] can be
+ * used as a per-request handler (see [processResponse]).
+ *
+ * HttpClient client = ...
+ * client.get(...)
+ * .then((HttpClientRequest response) => response.close())
+ * .then(HttpBodyHandler.processResponse)
+ * .then((HttpClientResponseBody body) {
+ * ...
+ * });
+ *
+ * The following mime-types will be handled specially:
+ * - text/\*
+ * - application/json
+ *
+ * All other mime-types will be returned as [List<int>].
+ */
+class HttpBodyHandler
+ implements StreamTransformer<HttpRequest, HttpRequestBody> {
+ factory HttpBodyHandler() => new _HttpBodyHandler();
+
+ /**
+ * Process and parse an incoming [HttpRequest]. The returned [HttpRequestBody]
+ * contains a [response] field for accessing the [HttpResponse].
+ */
+ static Future<HttpRequestBody> processRequest(HttpRequest request) {
+ return _HttpBodyHandler.processRequest(request);
+ }
+
+ /**
+ * Process and parse an incoming [HttpClientResponse].
+ */
+ static Future<HttpClientResponseBody> processResponse(
+ HttpClientResponse response) {
+ return _HttpBodyHandler.processResponse(response);
+ }
+}
+
+
+/**
+ * A HTTP content body produced by [HttpBodyHandler] for either [HttpRequest]
+ * or [HttpClientResponse].
+ */
+abstract class HttpBody {
+ /**
+ * The content type e.g. application/json, application/octet-stream,
+ * application/x-www-form-urlencoded, text/plain.
+ */
+ String get mimeType;
+
+ /**
+ * A high-level type value, that reflects how the body was parsed, e.g.
+ * "text", "binary" and "json".
+ */
+ String get type;
+
+ /**
+ * The actual body. The type depends on [type].
+ */
+ dynamic get body;
+}
+
+
+/**
+ * The [HttpBody] of a [HttpClientResponse] will be of type
+ * [HttpClientResponseBody]. It contains the [HttpClientResponse] object
+ * for access to the headers.
+ */
+abstract class HttpClientResponseBody extends HttpBody {
+ /**
+ * Returns the status code.
+ */
+ int get statusCode;
+
+ /**
+ * Returns the reason phrase associated with the status code.
+ */
+ String get reasonPhrase;
+
+ /**
+ * Returns the response headers.
+ */
+ HttpHeaders get headers;
+
+ /**
+ * The [HttpClientResponse] of the HTTP body.
+ */
+ HttpClientResponse get response;
+}
+
+
+/**
+ * The [HttpBody] of a [HttpRequest] will be of type [HttpRequestBody]. It
+ * contains the fields used to read all request header information and
+ * responding to the client.
+ */
+abstract class HttpRequestBody extends HttpBody {
+ /**
+ * Returns the method for the request.
+ */
+ String get method;
+
+ /**
+ * Returns the URI for the request.
+ */
+ Uri get uri;
+
+ /**
+ * Returns the request headers.
+ */
+ HttpHeaders get headers;
+
+ /**
+ * The [HttpResponse] used for responding to the client.
+ */
+ HttpResponse get response;
+}
diff --git a/sdk/lib/io/http_body_impl.dart b/sdk/lib/io/http_body_impl.dart
new file mode 100644
index 0000000..4bd9f81
--- /dev/null
+++ b/sdk/lib/io/http_body_impl.dart
@@ -0,0 +1,119 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.io;
+
+class _HttpBodyHandlerTransformer
+ extends StreamEventTransformer<HttpRequest, HttpRequestBody> {
+ void handleData(HttpRequest request, EventSink<HttpRequestBody> sink) {
+ HttpBodyHandler.processRequest(request)
+ .then(sink.add, onError: sink.addError);
+ }
+}
+
+class _HttpBodyHandler implements HttpBodyHandler {
+ Stream<HttpRequestBody> bind(Stream<HttpRequest> stream) {
+ return new _HttpBodyHandlerTransformer().bind(stream);
+ }
+
+ static Future<HttpRequestBody> processRequest(HttpRequest request) {
+ return process(request, request.headers)
+ .then((body) => new _HttpRequestBody(request, body),
+ onError: (error) {
+ // Try to send BAD_REQUEST response.
+ request.response.statusCode = HttpStatus.BAD_REQUEST;
+ request.response.close();
+ request.response.done.catchError((_) {});
+ throw error;
+ });
+ }
+
+ static Future<HttpClientResponseBody> processResponse(
+ HttpClientResponse response) {
+ return process(response, response.headers)
+ .then((body) => new _HttpClientResponseBody(response, body));
+ }
+
+ static Future<HttpBody> process(Stream<List<int>> stream,
+ HttpHeaders headers) {
+ return stream.fold(
+ new _BufferList(),
+ (buffer, data) {
+ // TODO(ajohnsen): Add limit for POST data.
+ buffer.add(data);
+ return buffer;
+ })
+ .then((list) {
+ dynamic content = list.readBytes();
+ String type = "binary";
+ String mimeType = headers.contentType.toString();
+ String asText(Encoding defaultEncoding) {
+ var encoding;
+ var charset = headers.contentType.charset;
+ if (charset != null) encoding = Encoding.fromName(charset);
+ if (encoding == null) encoding = defaultEncoding;
+ return _decodeString(content, encoding);
+ }
+ switch (headers.contentType.primaryType) {
+ case "text":
+ type = "text";
+ content = asText(Encoding.ASCII);
+ break;
+
+ case "application":
+ switch (headers.contentType.subType) {
+ case "json":
+ content = JSON.parse(asText(Encoding.UTF_8));
+ type = "json";
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return new _HttpBody(mimeType, type, content);
+ });
+ }
+}
+
+class _HttpBody implements HttpBody {
+ final String mimeType;
+ final String type;
+ final dynamic body;
+
+ _HttpBody(String this.mimeType,
+ String this.type,
+ dynamic this.body);
+}
+
+class _HttpRequestBody extends _HttpBody implements HttpRequestBody {
+ final String method;
+ final Uri uri;
+ final HttpHeaders headers;
+ final HttpResponse response;
+
+ _HttpRequestBody(HttpRequest request, HttpBody body)
+ : super(body.mimeType, body.type, body.body),
+ method = request.method,
+ uri = request.uri,
+ headers = request.headers,
+ response = request.response;
+}
+
+class _HttpClientResponseBody
+ extends _HttpBody implements HttpClientResponseBody {
+ final int statusCode;
+ final String reasonPhrase;
+ final HttpHeaders headers;
+
+ _HttpClientResponseBody(HttpClientResponse response, HttpBody body)
+ : super(body.mimeType, body.type, body.body),
+ statusCode = response.statusCode,
+ reasonPhrase = response.reasonPhrase,
+ headers = response.headers;
+}
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 6fc339a..cea3e11 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -234,10 +234,14 @@
{void onError(AsyncError error),
void onDone(),
bool unsubscribeOnError}) {
- return _incoming.listen(onData,
- onError: onError,
- onDone: onDone,
- unsubscribeOnError: unsubscribeOnError);
+ var stream = _incoming;
+ if (headers.value(HttpHeaders.CONTENT_ENCODING) == "gzip") {
+ stream = stream.transform(new ZLibInflater());
+ }
+ return stream.listen(onData,
+ onError: onError,
+ onDone: onDone,
+ unsubscribeOnError: unsubscribeOnError);
}
Future<Socket> detachSocket() {
@@ -381,7 +385,7 @@
if (isFirst) {
isFirst = false;
} else {
- if (separator != "") write(separator);
+ if (!separator.isEmpty) write(separator);
}
write(obj);
}
@@ -396,10 +400,15 @@
write(new String.fromCharCode(charCode));
}
- void writeBytes(List<int> data) {
+ void add(List<int> data) {
_writeHeaders();
if (data.length == 0) return;
- _ioSink.writeBytes(data);
+ _ioSink.add(data);
+ }
+
+ void addError(AsyncError error) {
+ _writeHeaders();
+ _ioSink.addError(error);
}
Future<T> consume(Stream<List<int>> stream) {
@@ -623,7 +632,7 @@
// Write headers.
headers._write(buffer);
writeCRLF();
- _ioSink.writeBytes(buffer.readBytes());
+ _ioSink.add(buffer.readBytes());
}
String _findReasonPhrase(int statusCode) {
@@ -683,7 +692,7 @@
}
-class _HttpClientRequest extends _HttpOutboundMessage<HttpClientRequest>
+class _HttpClientRequest extends _HttpOutboundMessage<HttpClientResponse>
implements HttpClientRequest {
final String method;
final Uri uri;
@@ -698,6 +707,8 @@
final bool _usingProxy;
+ Future<HttpClientResponse> _response;
+
// TODO(ajohnsen): Get default value from client?
bool _followRedirects = true;
@@ -718,11 +729,22 @@
}
}
- Future<HttpClientResponse> get response => _responseCompleter.future;
+ Future<HttpClientResponse> get done {
+ if (_response == null) {
+ _response = Future.wait([_responseCompleter.future, super.done])
+ .then((list) => list[0]);
+ }
+ return _response;
+ }
+
+ Future<HttpClientResponse> consume(Stream<List<int>> stream) {
+ super.consume(stream);
+ return done;
+ }
Future<HttpClientResponse> close() {
super.close();
- return response;
+ return done;
}
int get maxRedirects => _maxRedirects;
@@ -815,7 +837,7 @@
// Write headers.
headers._write(buffer);
writeCRLF();
- _ioSink.writeBytes(buffer.readBytes());
+ _ioSink.add(buffer.readBytes());
}
}
@@ -890,7 +912,7 @@
// Extends StreamConsumer as this is an internal type, only used to pipe to.
-class _HttpOutgoing implements StreamConsumer<List<int>, dynamic> {
+class _HttpOutgoing implements StreamConsumer<List<int>> {
Function _onStream;
final Completer _consumeCompleter = new Completer();
@@ -971,6 +993,7 @@
this);
request.headers.host = uri.domain;
request.headers.port = port;
+ request.headers.set(HttpHeaders.ACCEPT_ENCODING, "gzip");
if (uri.userInfo != null && !uri.userInfo.isEmpty) {
// If the URL contains user information use that for basic
// authorization
@@ -988,51 +1011,47 @@
// data).
_httpParser.responseToMethod = method;
_streamFuture = outgoing.onStream((stream) {
- // Sending request, set up response completer.
- _nextResponseCompleter = new Completer();
+ return _socket.writeStream(stream)
+ .then((s) {
+ // Request sent, set up response completer.
+ _nextResponseCompleter = new Completer();
- var requestFuture = _socket.writeStream(stream)
- .catchError((e) {
- destroy();
- throw e;
- });
-
- // Listen for response.
- _nextResponseCompleter.future
- .then((incoming) {
- incoming.dataDone.then((_) {
- if (incoming.headers.persistentConnection &&
- request.persistentConnection) {
- // Be sure we have written the full request.
- requestFuture
- .then((_) {
+ // Listen for response.
+ _nextResponseCompleter.future
+ .then((incoming) {
+ incoming.dataDone.then((_) {
+ if (incoming.headers.persistentConnection &&
+ request.persistentConnection) {
// Return connection, now we are done.
_httpClient._returnConnection(this);
_subscription.resume();
- },
- onError: (_) {
- // Already handled.
- });
- } else {
- destroy();
- }
- });
- request._onIncoming(incoming);
- })
- // If we see a state error, we failed to get the 'first' element.
- // Transform the error to a HttpParserException, for consistency.
- .catchError((error) {
- throw new HttpParserException(
- "Connection closed before data was received");
- }, test: (error) => error is StateError)
- .catchError((error) {
- // We are done with the socket.
+ } else {
+ destroy();
+ }
+ });
+ request._onIncoming(incoming);
+ })
+ // If we see a state error, we failed to get the 'first'
+ // element.
+ // Transform the error to a HttpParserException, for
+ // consistency.
+ .catchError((error) {
+ throw new HttpParserException(
+ "Connection closed before data was received");
+ }, test: (error) => error is StateError)
+ .catchError((error) {
+ // We are done with the socket.
+ destroy();
+ request._onError(error);
+ });
+
+ // Resume the parser now we have a handler.
+ _subscription.resume();
+ return s;
+ }, onError: (e) {
destroy();
- request._onError(error);
+ throw e;
});
- // Resume the parser now we have a handler.
- _subscription.resume();
- return requestFuture;
});
return request;
}
@@ -1071,13 +1090,13 @@
static const int DEFAULT_EVICTION_TIMEOUT = 60000;
bool _closing = false;
- final Map<String, Queue<_HttpClientConnection>> _idleConnections
- = new Map<String, Queue<_HttpClientConnection>>();
+ final Map<String, Set<_HttpClientConnection>> _idleConnections
+ = new Map<String, Set<_HttpClientConnection>>();
final Set<_HttpClientConnection> _activeConnections
= new Set<_HttpClientConnection>();
final List<_Credentials> _credentials = [];
Function _authenticate;
- Function _findProxy;
+ Function _findProxy = HttpClient.findProxyFromEnvironment;
Future<HttpClientRequest> open(String method,
String host,
@@ -1210,9 +1229,9 @@
}
// TODO(ajohnsen): Listen for socket close events.
if (!_idleConnections.containsKey(connection.key)) {
- _idleConnections[connection.key] = new Queue();
+ _idleConnections[connection.key] = new Set();
}
- _idleConnections[connection.key].addLast(connection);
+ _idleConnections[connection.key].add(connection);
}
// Remove a closed connnection from the active set.
@@ -1241,7 +1260,8 @@
int port = proxy.isDirect ? uriPort: proxy.port;
String key = isSecure ? "ssh:$host:$port" : "$host:$port";
if (_idleConnections.containsKey(key)) {
- var connection = _idleConnections[key].removeFirst();
+ var connection = _idleConnections[key].first;
+ _idleConnections[key].remove(connection);
if (_idleConnections[key].isEmpty) {
_idleConnections.remove(key);
}
@@ -1667,7 +1687,9 @@
_socket.writeAll(objects, separator);
}
- void writeBytes(List<int> bytes) => _socket.writeBytes(bytes);
+ void add(List<int> bytes) => _socket.add(bytes);
+
+ void addError(AsyncError error) => _socket.addError(error);
Future<Socket> consume(Stream<List<int>> stream) {
return _socket.consume(stream);
diff --git a/sdk/lib/io/http_parser.dart b/sdk/lib/io/http_parser.dart
index 7d098d0..dd55494 100644
--- a/sdk/lib/io/http_parser.dart
+++ b/sdk/lib/io/http_parser.dart
@@ -166,7 +166,7 @@
}
void onSubscriptionStateChange() {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
resume();
} else {
subscription.cancel();
@@ -197,7 +197,7 @@
*/
class _HttpParser
extends Stream<_HttpIncoming>
- implements StreamConsumer<List<int>, _HttpParser> {
+ implements StreamConsumer<List<int>> {
factory _HttpParser.requestParser() {
return new _HttpParser._(true);
@@ -912,7 +912,7 @@
}
void _bodySubscriptionStateChange() {
- if (_incoming != null && !_bodyController.hasSubscribers) {
+ if (_incoming != null && !_bodyController.hasListener) {
_closeIncoming();
} else {
_updateParsePauseState();
@@ -921,13 +921,13 @@
void _updateParsePauseState() {
if (_bodyController != null) {
- if (_bodyController.hasSubscribers && !_bodyController.isPaused) {
+ if (_bodyController.hasListener && !_bodyController.isPaused) {
_continueParsing();
} else {
_pauseParsing();
}
} else {
- if (_controller.hasSubscribers && !_controller.isPaused) {
+ if (_controller.hasListener && !_controller.isPaused) {
_continueParsing();
} else {
_pauseParsing();
diff --git a/sdk/lib/io/http_session.dart b/sdk/lib/io/http_session.dart
index 4cde1be..2b7e164 100644
--- a/sdk/lib/io/http_session.dart
+++ b/sdk/lib/io/http_session.dart
@@ -72,7 +72,7 @@
String createSessionId() {
const int _KEY_LENGTH = 16; // 128 bits.
- var data = _getRandomBytes(_KEY_LENGTH);
+ var data = _IOCrypto.getRandomBytes(_KEY_LENGTH);
return CryptoUtils.bytesToHex(data);
}
@@ -172,7 +172,5 @@
_HttpSession _head;
_HttpSession _tail;
Timer _timer;
-
- external static Uint8List _getRandomBytes(int count);
}
diff --git a/sdk/lib/io/io.dart b/sdk/lib/io/io.dart
index 9b1c418..ecaf427 100644
--- a/sdk/lib/io/io.dart
+++ b/sdk/lib/io/io.dart
@@ -18,6 +18,7 @@
DoubleLinkedQueueEntry;
import 'dart:crypto';
import 'dart:isolate';
+import 'dart:json' as JSON;
import 'dart:math';
import 'dart:uri';
import 'dart:utf';
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart
index 4ee7b4f..df3a7da 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -5,18 +5,19 @@
part of dart.io;
/**
- * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide
+ * Helper class to wrap a [StreamConsumer<List<int>>] and provide
* utility functions for writing to the StreamConsumer directly. The
* [IOSink] buffers the input given by [write], [writeAll], [writeln],
- * [writeCharCode] and [writeBytes] and will delay a [consume] or
+ * [writeCharCode] and [add] and will delay a [consume] or
* [writeStream] until the buffer is flushed.
*
* When the [IOSink] is bound to a stream (through either [consume]
* or [writeStream]) any call to the [IOSink] will throw a
* [StateError].
*/
-abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
- factory IOSink(StreamConsumer<List<int>, T> target,
+abstract class IOSink<T>
+ implements StreamConsumer<List<int>>, StringSink, EventSink<List<int>> {
+ factory IOSink(StreamConsumer<List<int>> target,
{Encoding encoding: Encoding.UTF_8})
=> new _IOSinkImpl(target, encoding);
@@ -29,7 +30,12 @@
/**
* Writes the bytes uninterpreted to the consumer.
*/
- void writeBytes(List<int> data);
+ void add(List<int> data);
+
+ /**
+ * Writes an error to the consumer.
+ */
+ void addError(AsyncError error);
/**
* Provide functionality for piping to the [IOSink].
@@ -64,7 +70,7 @@
class _IOSinkImpl<T> implements IOSink<T> {
- final StreamConsumer<List<int>, T> _target;
+ final StreamConsumer<List<int>> _target;
Completer _writeStreamCompleter;
StreamController<List<int>> _controllerInstance;
@@ -73,7 +79,7 @@
bool _paused = true;
bool _encodingMutable = true;
- _IOSinkImpl(StreamConsumer<List<int>, T> this._target, this._encoding);
+ _IOSinkImpl(StreamConsumer<List<int>> this._target, this._encoding);
Encoding _encoding;
@@ -100,13 +106,13 @@
}
}
if (string.isEmpty) return;
- writeBytes(_encodeString(string, _encoding));
+ add(_encodeString(string, _encoding));
}
void writeAll(Iterable objects, [String separator = ""]) {
Iterator iterator = objects.iterator;
if (!iterator.moveNext()) return;
- if (separator == "") {
+ if (separator.isEmpty) {
do {
write(iterator.current);
} while (iterator.moveNext());
@@ -128,13 +134,20 @@
write(new String.fromCharCode(charCode));
}
- void writeBytes(List<int> data) {
+ void add(List<int> data) {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
}
_controller.add(data);
}
+ void addError(AsyncError error) {
+ if (_isBound) {
+ throw new StateError("IOSink is already bound to a stream");
+ }
+ _controller.addError(error);
+ }
+
Future<T> consume(Stream<List<int>> stream) {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
@@ -223,7 +236,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
_paused = false;
_resume();
} else {
diff --git a/sdk/lib/io/iolib_sources.gypi b/sdk/lib/io/iolib_sources.gypi
index 5f5692a..f2d61f5 100644
--- a/sdk/lib/io/iolib_sources.gypi
+++ b/sdk/lib/io/iolib_sources.gypi
@@ -15,6 +15,8 @@
'file_impl.dart',
'file_system_entity.dart',
'http.dart',
+ 'http_body.dart',
+ 'http_body_impl.dart',
'http_headers.dart',
'http_impl.dart',
'http_parser.dart',
diff --git a/sdk/lib/io/link.dart b/sdk/lib/io/link.dart
index fee4f97..347ae1f 100644
--- a/sdk/lib/io/link.dart
+++ b/sdk/lib/io/link.dart
@@ -34,13 +34,17 @@
/**
* Creates a symbolic link. Returns a [:Future<Link>:] that completes with
- * the link when it has been created. If the link exists, the function
+ * the link when it has been created. If the link exists,
* the future will complete with an error.
*
* On the Windows platform, this will only work with directories, and the
* target directory must exist. The link will be created as a Junction.
* Only absolute links will be created, and relative paths to the target
* will be converted to absolute paths.
+ *
+ * On other platforms, the posix symlink() call is used to make a symbolic
+ * link containing the string [target]. If [target] is a relative path,
+ * it will be interpreted relative to the directory containing the link.
*/
Future<Link> create(String target);
@@ -52,6 +56,10 @@
* target directory must exist. The link will be created as a Junction.
* Only absolute links will be created, and relative paths to the target
* will be converted to absolute paths.
+ *
+ * On other platforms, the posix symlink() call is used to make a symbolic
+ * link containing the string [target]. If [target] is a relative path,
+ * it will be interpreted relative to the directory containing the link.
*/
void createSync(String target);
@@ -70,14 +78,18 @@
/**
* Deletes the link. Returns a [:Future<Link>:] that completes with
- * the link when it has been deleted. This does not delete, or otherwise
- * affect, the target of the link.
+ * the link when it has been deleted. This does not delete, or otherwise
+ * affect, the target of the link. It also works on broken links, but if
+ * the link does not exist or is not actually a link, it completes the
+ * future with a LinkIOException.
*/
Future<Link> delete();
/**
* Synchronously deletes the link. This does not delete, or otherwise
- * affect, the target of the link.
+ * affect, the target of the link. It also works on broken links, but if
+ * the link does not exist or is not actually a link, it throws a
+ * LinkIOException.
*/
void deleteSync();
@@ -108,6 +120,8 @@
class _Link extends FileSystemEntity implements Link {
final String path;
+ SendPort _fileService;
+
_Link(String this.path);
_Link.fromPath(Path inputPath) : path = inputPath.toNativePath();
@@ -122,9 +136,19 @@
bool existsSync() => FileSystemEntity.isLinkSync(path);
Future<Link> create(String target) {
- // TODO(whesse): Replace with asynchronous version.
- return new Future.of(() {
- createSync(target);
+ _ensureFileService();
+ if (Platform.operatingSystem == 'windows') {
+ target = _makeWindowsLinkTarget(target);
+ }
+ List request = new List(3);
+ request[0] = _CREATE_LINK_REQUEST;
+ request[1] = path;
+ request[2] = target;
+ return _fileService.call(request).then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(response,
+ "Cannot create link '$path' to target '$target'");
+ }
return this;
});
}
@@ -134,9 +158,7 @@
target = _makeWindowsLinkTarget(target);
}
var result = _File._createLink(path, target);
- if (result is OSError) {
- throw new LinkIOException("Error in Link.createSync", result);
- }
+ throwIfError(result, "Cannot create link '$path'");
}
// Put target into the form "\??\C:\my\target\dir".
@@ -164,11 +186,21 @@
}
Future<Link> delete() {
- return new File(path).delete().then((_) => this);
+ _ensureFileService();
+ List request = new List(2);
+ request[0] = _DELETE_LINK_REQUEST;
+ request[1] = path;
+ return _fileService.call(request).then((response) {
+ if (_isErrorResponse(response)) {
+ throw _exceptionFromResponse(response, "Cannot delete link '$path'");
+ }
+ return this;
+ });
}
void deleteSync() {
- new File(path).deleteSync();
+ var result = _File._deleteLink(path);
+ throwIfError(result, "Cannot delete link '$path'");
}
Future<String> target() {
@@ -178,11 +210,39 @@
String targetSync() {
var result = _File._linkTarget(path);
- if (result is OSError) {
- throw new LinkIOException("Error in Link.targetSync", result);
- }
+ throwIfError(result, "Cannot read link '$path'");
return result;
}
+
+ static throwIfError(Object result, String msg) {
+ if (result is OSError) {
+ throw new LinkIOException(msg, result);
+ }
+ }
+
+ bool _isErrorResponse(response) {
+ return response is List && response[0] != _SUCCESS_RESPONSE;
+ }
+
+ void _ensureFileService() {
+ if (_fileService == null) {
+ _fileService = _FileUtils._newServicePort();
+ }
+ }
+
+ _exceptionFromResponse(response, String message) {
+ assert(_isErrorResponse(response));
+ switch (response[_ERROR_RESPONSE_ERROR_TYPE]) {
+ case _ILLEGAL_ARGUMENT_RESPONSE:
+ return new ArgumentError();
+ case _OSERROR_RESPONSE:
+ var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
+ response[_OSERROR_RESPONSE_ERROR_CODE]);
+ return new LinkIOException(message, err);
+ default:
+ return new Exception("Unknown error");
+ }
+ }
}
diff --git a/sdk/lib/io/process.dart b/sdk/lib/io/process.dart
index 8ceb41d..1c9fddb 100644
--- a/sdk/lib/io/process.dart
+++ b/sdk/lib/io/process.dart
@@ -46,7 +46,11 @@
* in a isolate while it is blocked in a [sleep] call.
*/
void sleep(Duration duration) {
- _ProcessUtils._sleep(duration.inMilliseconds);
+ int milliseconds = duration.inMilliseconds;
+ if (milliseconds < 0) {
+ throw new ArgumentError("sleep: duration cannot be negative");
+ }
+ _ProcessUtils._sleep(milliseconds);
}
/**
diff --git a/sdk/lib/io/secure_server_socket.dart b/sdk/lib/io/secure_server_socket.dart
index bcbc731..166b0f2 100644
--- a/sdk/lib/io/secure_server_socket.dart
+++ b/sdk/lib/io/secure_server_socket.dart
@@ -222,7 +222,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
_subscription = _socket.listen(_onData,
onDone: _onDone,
onError: _onError);
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index 41fdf59..197e87d 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -391,7 +391,7 @@
void set writeEventsEnabled(bool value) {
if (value &&
- _controller.hasSubscribers &&
+ _controller.hasListener &&
_secureFilter != null &&
_secureFilter.buffers[WRITE_PLAINTEXT].free > 0) {
Timer.run(() => _controller.add(RawSocketEvent.WRITE));
@@ -501,7 +501,7 @@
_secureHandshake();
} catch (e) { _reportError(e, "RawSecureSocket error"); }
} else if (_status == CONNECTED &&
- _controller.hasSubscribers &&
+ _controller.hasListener &&
_writeEventsEnabled &&
_secureFilter.buffers[WRITE_PLAINTEXT].free > 0) {
// Reset the one-shot handler.
@@ -628,7 +628,7 @@
}
void _onSubscriptionStateChange() {
- if (_controller.hasSubscribers) {
+ if (_controller.hasListener) {
// TODO(ajohnsen): Do something here?
}
}
diff --git a/sdk/lib/io/socket.dart b/sdk/lib/io/socket.dart
index 1680f6b..ac3444c 100644
--- a/sdk/lib/io/socket.dart
+++ b/sdk/lib/io/socket.dart
@@ -125,7 +125,7 @@
*/
abstract class RawSocket implements Stream<RawSocketEvent> {
/**
- * Creats a new socket connection to the host and port and returns a [Future]
+ * Creates a new socket connection to the host and port and returns a [Future]
* that will complete with either a [RawSocket] once connected or an error
* if the host-lookup or connection failed.
*/
@@ -216,7 +216,7 @@
IOSink<Socket> {
/**
* Creats a new socket connection to the host and port and returns a [Future]
- * that will complete with either a [RawSocket] once connected or an error
+ * that will complete with either a [Socket] once connected or an error
* if the host-lookup or connection failed.
*/
external static Future<Socket> connect(String host, int port);
diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart
index 1ed157e..5cad1f0 100644
--- a/sdk/lib/io/stdio.dart
+++ b/sdk/lib/io/stdio.dart
@@ -10,6 +10,44 @@
const int _STDIO_HANDLE_TYPE_SOCKET = 3;
const int _STDIO_HANDLE_TYPE_OTHER = 4;
+class _StdStream extends Stream<List<int>> {
+ final Stream<List<int>> _stream;
+
+ _StdStream(Stream<List<int>> this._stream);
+
+ StreamSubscription<List<int>> listen(void onData(List<int> event),
+ {void onError(AsyncError error),
+ void onDone(),
+ bool unsubscribeOnError}) {
+ return _stream.listen(
+ onData,
+ onError: onError,
+ onDone: onDone,
+ unsubscribeOnError: unsubscribeOnError);
+ }
+}
+
+class _StdSink implements IOSink {
+ final IOSink _sink;
+
+ _StdSink(IOSink this._sink);
+
+ Encoding get encoding => _sink.encoding;
+ void set encoding(Encoding encoding) {
+ _sink.encoding = encoding;
+ }
+ void write(object) => _sink.write(object);
+ void writeln([object = "" ]) => _sink.writeln(object);
+ void writeAll(objects, [sep = ""]) => _sink.writeAll(objects, sep);
+ void add(List<int> data) => _sink.add(data);
+ void addError(AsyncError error) => _sink.addError(error);
+ void writeCharCode(int charCode) => _sink.writeCharCode(charCode);
+ Future consume(Stream<List<int>> stream) => _sink.consume(stream);
+ Future addStream(Stream<List<int>> stream) => _sink.addStream(stream);
+ Future writeStream(Stream<List<int>> stream) => _sink.writeStream(stream);
+ Future close() => _sink.close();
+ Future get done => _sink.done;
+}
class StdioType {
static const StdioType TERMINAL = const StdioType._("terminal");
@@ -52,6 +90,11 @@
StdioType stdioType(object) {
+ if (object is _StdStream) {
+ object = object._stream;
+ } else if (object is _StdSink) {
+ object = object._sink;
+ }
if (object is _FileStream) {
return StdioType.FILE;
}
diff --git a/sdk/lib/io/string_transformer.dart b/sdk/lib/io/string_transformer.dart
index 7cc9bc0..4a70f44 100644
--- a/sdk/lib/io/string_transformer.dart
+++ b/sdk/lib/io/string_transformer.dart
@@ -12,6 +12,12 @@
static const Encoding ISO_8859_1 = const Encoding._internal("iso-8859-1");
static const Encoding ASCII = const Encoding._internal("us-ascii");
+ /**
+ * SYSTEM encoding is the current code page on Windows and UTF-8 on
+ * Linux and Mac.
+ */
+ static const Encoding SYSTEM = const Encoding._internal("system");
+
// All aliasses (in lowercase) of supported encoding from
// http://www.iana.org/assignments/character-sets/character-sets.xml.
static Map<String, Encoding> _nameToEncoding = <String, Encoding> {
@@ -67,14 +73,12 @@
*/
final String name;
- /**
- * SYSTEM encoding is the current code page on Windows and UTF-8 on
- * Linux and Mac.
- */
- static const Encoding SYSTEM = const Encoding._internal("system");
const Encoding._internal(String this.name);
}
+const UTF_8 = Encoding.UTF_8;
+const ISO_8859_1 = Encoding.ISO_8859_1;
+const ASCII = Encoding.ASCII;
/**
* Stream transformer that can decode a stream of bytes into a stream of
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart
index fcbe1ca..bd21220 100644
--- a/sdk/lib/io/websocket_impl.dart
+++ b/sdk/lib/io/websocket_impl.dart
@@ -50,7 +50,9 @@
static const int CLOSED = 5;
static const int FAILURE = 6;
- _WebSocketProtocolTransformer() {
+ bool _serverSide;
+
+ _WebSocketProtocolTransformer([bool this._serverSide = false]) {
_prepareForNextFrame();
_currentMessageType = _WebSocketMessageType.NONE;
}
@@ -223,9 +225,15 @@
void _lengthDone(EventSink sink) {
if (_masked) {
+ if (!_serverSide) {
+ throw new WebSocketException("Received masked frame from server");
+ }
_state = MASK;
_remainingMaskingKeyBytes = 4;
} else {
+ if (_serverSide) {
+ throw new WebSocketException("Received unmasked frame from client");
+ }
_remainingPayloadBytes = _len;
_startPayload(sink);
}
@@ -392,7 +400,7 @@
response.headers.add("Sec-WebSocket-Accept", accept);
response.headers.contentLength = 0;
return response.detachSocket()
- .then((socket) => new _WebSocketImpl._fromSocket(socket));
+ .then((socket) => new _WebSocketImpl._fromSocket(socket, true));
}
static bool _isUpgradeRequest(HttpRequest request) {
@@ -428,6 +436,7 @@
final StreamController _controller = new StreamController();
final Socket _socket;
+ final bool _serverSide;
int _readyState = WebSocket.CONNECTING;
bool _writeClosed = false;
int _closeCode;
@@ -505,11 +514,12 @@
});
}
- _WebSocketImpl._fromSocket(Socket this._socket) {
+ _WebSocketImpl._fromSocket(Socket this._socket,
+ [bool this._serverSide = false]) {
_readyState = WebSocket.OPEN;
bool closed = false;
- var transformer = new _WebSocketProtocolTransformer();
+ var transformer = new _WebSocketProtocolTransformer(_serverSide);
_socket.transform(transformer).listen(
(data) {
_controller.add(data);
@@ -631,7 +641,7 @@
void _sendFrame(int opcode, [List<int> data]) {
if (_writeClosed) return;
- bool mask = false; // Masking not implemented for server.
+ bool mask = !_serverSide; // Masking not implemented for server.
int dataLength = data == null ? 0 : data.length;
// Determine the header size.
int headerSize = (mask) ? 6 : 2;
@@ -658,11 +668,24 @@
for (int i = 0; i < lengthBytes; i++) {
header[index++] = dataLength >> (((lengthBytes - 1) - i) * 8) & 0xFF;
}
+ if (mask) {
+ header[1] |= 1 << 7;
+ var maskBytes = _IOCrypto.getRandomBytes(4);
+ header.setRange(index, 4, maskBytes);
+ index += 4;
+ if (data != null) {
+ var list = new Uint8List(data.length);
+ for (int i = 0; i < data.length; i++) {
+ list[i] = data[i] ^ maskBytes[i % 4];
+ }
+ data = list;
+ }
+ }
assert(index == headerSize);
try {
- _socket.writeBytes(header);
+ _socket.add(header);
if (data != null) {
- _socket.writeBytes(data);
+ _socket.add(data);
}
} catch (_) {
// The socket can be closed before _socket.done have a chance
diff --git a/sdk/lib/isolate/isolate_stream.dart b/sdk/lib/isolate/isolate_stream.dart
index a48c44d..37db4e5 100644
--- a/sdk/lib/isolate/isolate_stream.dart
+++ b/sdk/lib/isolate/isolate_stream.dart
@@ -38,7 +38,7 @@
class IsolateStream extends Stream<dynamic> {
bool _isClosed = false;
final ReceivePort _port;
- StreamController _controller = new StreamController.broadcast();
+ StreamController _controller = new StreamController();
IsolateStream._fromOriginalReceivePort(this._port) {
_port.receive((message, replyTo) {
@@ -94,8 +94,7 @@
*
* [IsolateSink]s can be transmitted to other isolates.
*/
-abstract class IsolateSink extends StreamSink<dynamic> {
- // TODO(8997): Implement EventSink instead.
+abstract class IsolateSink extends EventSink<dynamic> {
// TODO(floitsch): Actually it should be a StreamSink (being able to flow-
// control).
diff --git a/sdk/lib/mirrors/mirrors.dart b/sdk/lib/mirrors/mirrors.dart
index 70c523e..9813a0d 100644
--- a/sdk/lib/mirrors/mirrors.dart
+++ b/sdk/lib/mirrors/mirrors.dart
@@ -174,32 +174,34 @@
abstract class ObjectMirror implements Mirror {
/**
* Invokes the named function and returns a mirror on the result.
- *
- * TODO(turnidge): Properly document.
+ * The arguments must be instances of [InstanceMirror], [num],
+ * [String] or [bool].
+ */
+ /* TODO(turnidge): Properly document.
* TODO(turnidge): Handle ambiguous names.
* TODO(turnidge): Handle optional & named arguments.
*/
- Future<InstanceMirror> invoke(String memberName,
- List<Object> positionalArguments,
- [Map<String,Object> namedArguments]);
+ Future<InstanceMirror> invokeAsync(String memberName,
+ List<Object> positionalArguments,
+ [Map<String,Object> namedArguments]);
/**
* Invokes a getter and returns a mirror on the result. The getter
* can be the implicit getter for a field or a user-defined getter
* method.
- *
- * TODO(turnidge): Handle ambiguous names.
*/
- Future<InstanceMirror> getField(String fieldName);
+ /* TODO(turnidge): Handle ambiguous names.*/
+ Future<InstanceMirror> getFieldAsync(String fieldName);
/**
* Invokes a setter and returns a mirror on the result. The setter
* may be either the implicit setter for a non-final field or a
* user-defined setter method.
- *
- * TODO(turnidge): Handle ambiguous names.
+ * The argument must be an instance of either [InstanceMirror], [num],
+ * [String] or [bool].
*/
- Future<InstanceMirror> setField(String fieldName, Object value);
+ /* TODO(turnidge): Handle ambiguous names.*/
+ Future<InstanceMirror> setFieldAsync(String fieldName, Object value);
}
/**
@@ -256,17 +258,12 @@
String get source;
/**
- * Executes the closure. The arguments given in the descriptor need to
- * be InstanceMirrors or simple values.
- *
- * A value is simple if one of the following holds:
- * - the value is null
- * - the value is of type [num]
- * - the value is of type [bool]
- * - the value is of type [String]
+ * Executes the closure.
+ * The arguments must be instances of [InstanceMirror], [num],
+ * [String] or [bool].
*/
- Future<InstanceMirror> apply(List<Object> positionalArguments,
- [Map<String,Object> namedArguments]);
+ Future<InstanceMirror> applyAsync(List<Object> positionalArguments,
+ [Map<String,Object> namedArguments]);
/**
* Looks up the value of a name in the scope of the closure. The
@@ -436,12 +433,12 @@
/**
* Invokes the named constructor and returns a mirror on the result.
- *
- * TODO(turnidge): Properly document.
+ * The arguments must be instances of [InstanceMirror], [num],
*/
- Future<InstanceMirror> newInstance(String constructorName,
- List<Object> positionalArguments,
- [Map<String,Object> namedArguments]);
+ /* TODO(turnidge): Properly document.*/
+ Future<InstanceMirror> newInstanceAsync(String constructorName,
+ List<Object> positionalArguments,
+ [Map<String,Object> namedArguments]);
/**
* Does this mirror represent a class?
diff --git a/sdk/lib/svg/dart2js/svg_dart2js.dart b/sdk/lib/svg/dart2js/svg_dart2js.dart
index feeb745..570e29c 100644
--- a/sdk/lib/svg/dart2js/svg_dart2js.dart
+++ b/sdk/lib/svg/dart2js/svg_dart2js.dart
@@ -738,45 +738,6 @@
@DocsEditable
-@DomName('SVGColor')
-class Color extends CssValue native "*SVGColor" {
-
- static const int SVG_COLORTYPE_CURRENTCOLOR = 3;
-
- static const int SVG_COLORTYPE_RGBCOLOR = 1;
-
- static const int SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
-
- static const int SVG_COLORTYPE_UNKNOWN = 0;
-
- @DomName('SVGColor.colorType')
- @DocsEditable
- final int colorType;
-
- @DomName('SVGColor.rgbColor')
- @DocsEditable
- final CssRgbColor rgbColor;
-
- @DomName('SVGColor.setColor')
- @DocsEditable
- void setColor(int colorType, String rgbColor, String iccColor) native;
-
- @JSName('setRGBColor')
- @DomName('SVGColor.setRGBColor')
- @DocsEditable
- void setRgbColor(String rgbColor) native;
-
- @JSName('setRGBColorICCColor')
- @DomName('SVGColor.setRGBColorICCColor')
- @DocsEditable
- void setRgbColorIccColor(String rgbColor, String iccColor) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('SVGDefsElement')
class DefsElement extends StyledElement implements Transformable, Tests, ExternalResourcesRequired, LangSpace native "*SVGDefsElement" {
@@ -3069,11 +3030,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Length)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Length reduce(Length combine(Length value, Length element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Length)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Length element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -3081,7 +3043,7 @@
void forEach(void f(Length element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Length element)) =>
@@ -3181,12 +3143,6 @@
throw new StateError("More than one element");
}
- Length min([int compare(Length a, Length b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Length max([int compare(Length a, Length b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Length element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -3203,14 +3159,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Length element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -3231,17 +3179,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Length> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Length> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Length>[]);
}
- List<Length> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Length> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Length> mixins.
@DomName('SVGLengthList.appendItem')
@@ -3376,7 +3331,7 @@
@DocsEditable
@DomName('SVGLinearGradientElement')
-class LinearGradientElement extends _SVGGradientElement native "*SVGLinearGradientElement" {
+class LinearGradientElement extends _GradientElement native "*SVGLinearGradientElement" {
@DomName('SVGLinearGradientElement.SVGLinearGradientElement')
@DocsEditable
@@ -3707,11 +3662,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Number)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Number reduce(Number combine(Number value, Number element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Number)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Number element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -3719,7 +3675,7 @@
void forEach(void f(Number element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Number element)) =>
@@ -3819,12 +3775,6 @@
throw new StateError("More than one element");
}
- Number min([int compare(Number a, Number b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Number max([int compare(Number a, Number b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Number element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -3841,14 +3791,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Number element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -3869,17 +3811,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Number> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Number> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Number>[]);
}
- List<Number> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Number> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Number> mixins.
@DomName('SVGNumberList.appendItem')
@@ -3916,51 +3865,6 @@
@DocsEditable
-@DomName('SVGPaint')
-class Paint extends Color native "*SVGPaint" {
-
- static const int SVG_PAINTTYPE_CURRENTCOLOR = 102;
-
- static const int SVG_PAINTTYPE_NONE = 101;
-
- static const int SVG_PAINTTYPE_RGBCOLOR = 1;
-
- static const int SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
-
- static const int SVG_PAINTTYPE_UNKNOWN = 0;
-
- static const int SVG_PAINTTYPE_URI = 107;
-
- static const int SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
-
- static const int SVG_PAINTTYPE_URI_NONE = 103;
-
- static const int SVG_PAINTTYPE_URI_RGBCOLOR = 105;
-
- static const int SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
-
- @DomName('SVGPaint.paintType')
- @DocsEditable
- final int paintType;
-
- @DomName('SVGPaint.uri')
- @DocsEditable
- final String uri;
-
- @DomName('SVGPaint.setPaint')
- @DocsEditable
- void setPaint(int paintType, String uri, String rgbColor, String iccColor) native;
-
- @DomName('SVGPaint.setUri')
- @DocsEditable
- void setUri(String uri) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('SVGPathElement')
class PathElement extends StyledElement implements Transformable, Tests, ExternalResourcesRequired, LangSpace native "*SVGPathElement" {
@@ -4621,11 +4525,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, PathSeg)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ PathSeg reduce(PathSeg combine(PathSeg value, PathSeg element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, PathSeg)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, PathSeg element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -4633,7 +4538,7 @@
void forEach(void f(PathSeg element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(PathSeg element)) =>
@@ -4733,12 +4638,6 @@
throw new StateError("More than one element");
}
- PathSeg min([int compare(PathSeg a, PathSeg b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- PathSeg max([int compare(PathSeg a, PathSeg b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, PathSeg element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -4755,14 +4654,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(PathSeg element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -4783,17 +4674,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<PathSeg> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<PathSeg> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <PathSeg>[]);
}
- List<PathSeg> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, PathSeg> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<PathSeg> mixins.
@DomName('SVGPathSegList.appendItem')
@@ -5241,7 +5139,7 @@
@DocsEditable
@DomName('SVGRadialGradientElement')
-class RadialGradientElement extends _SVGGradientElement native "*SVGRadialGradientElement" {
+class RadialGradientElement extends _GradientElement native "*SVGRadialGradientElement" {
@DomName('SVGRadialGradientElement.SVGRadialGradientElement')
@DocsEditable
@@ -5520,11 +5418,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, String)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, String element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -5532,7 +5431,7 @@
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(String element)) =>
@@ -5632,12 +5531,6 @@
throw new StateError("More than one element");
}
- String min([int compare(String a, String b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- String max([int compare(String a, String b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, String element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -5654,14 +5547,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -5682,17 +5567,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<String> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<String> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <String>[]);
}
- List<String> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, String> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<String> mixins.
@DomName('SVGStringList.appendItem')
@@ -5779,10 +5671,6 @@
// Use implementation from Element.
// final CssStyleDeclaration style;
-
- @DomName('SVGStyledElement.getPresentationAttribute')
- @DocsEditable
- CssValue getPresentationAttribute(String name) native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -6696,11 +6584,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Transform)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Transform reduce(Transform combine(Transform value, Transform element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Transform)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Transform element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -6708,7 +6597,7 @@
void forEach(void f(Transform element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Transform element)) =>
@@ -6808,12 +6697,6 @@
throw new StateError("More than one element");
}
- Transform min([int compare(Transform a, Transform b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Transform max([int compare(Transform a, Transform b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Transform element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -6830,14 +6713,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Transform element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -6858,17 +6733,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Transform> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Transform> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Transform>[]);
}
- List<Transform> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Transform> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Transform> mixins.
@DomName('SVGTransformList.appendItem')
@@ -7227,11 +7109,12 @@
return new FixedSizeListIterator<ElementInstance>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, ElementInstance)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ ElementInstance reduce(ElementInstance combine(ElementInstance value, ElementInstance element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, ElementInstance)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, ElementInstance element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -7239,7 +7122,7 @@
void forEach(void f(ElementInstance element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(ElementInstance element)) =>
@@ -7341,12 +7224,6 @@
throw new StateError("More than one element");
}
- ElementInstance min([int compare(ElementInstance a, ElementInstance b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- ElementInstance max([int compare(ElementInstance a, ElementInstance b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, ElementInstance element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -7363,14 +7240,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(ElementInstance element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -7391,17 +7260,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<ElementInstance> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<ElementInstance> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <ElementInstance>[]);
}
- List<ElementInstance> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, ElementInstance> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<ElementInstance> mixins.
@DomName('SVGElementInstanceList.item')
@@ -7414,300 +7290,8 @@
@DocsEditable
-@DomName('SVGAltGlyphDefElement')
-class _SVGAltGlyphDefElement extends SvgElement native "*SVGAltGlyphDefElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGAltGlyphItemElement')
-class _SVGAltGlyphItemElement extends SvgElement native "*SVGAltGlyphItemElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGAnimateColorElement')
-class _SVGAnimateColorElement extends AnimationElement native "*SVGAnimateColorElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGComponentTransferFunctionElement')
-class _SVGComponentTransferFunctionElement extends SvgElement native "*SVGComponentTransferFunctionElement" {
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0;
-
- @DomName('SVGComponentTransferFunctionElement.amplitude')
- @DocsEditable
- final AnimatedNumber amplitude;
-
- @DomName('SVGComponentTransferFunctionElement.exponent')
- @DocsEditable
- final AnimatedNumber exponent;
-
- @DomName('SVGComponentTransferFunctionElement.intercept')
- @DocsEditable
- final AnimatedNumber intercept;
-
- @JSName('offset')
- @DomName('SVGComponentTransferFunctionElement.offset')
- @DocsEditable
- final AnimatedNumber gradientOffset;
-
- @DomName('SVGComponentTransferFunctionElement.slope')
- @DocsEditable
- final AnimatedNumber slope;
-
- @DomName('SVGComponentTransferFunctionElement.tableValues')
- @DocsEditable
- final AnimatedNumberList tableValues;
-
- @DomName('SVGComponentTransferFunctionElement.type')
- @DocsEditable
- final AnimatedEnumeration type;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGCursorElement')
-class _SVGCursorElement extends SvgElement implements UriReference, Tests, ExternalResourcesRequired native "*SVGCursorElement" {
-
- @DomName('SVGCursorElement.SVGCursorElement')
- @DocsEditable
- factory _SVGCursorElement() => _SvgElementFactoryProvider.createSvgElement_tag("cursor");
-
- /// Checks if this type is supported on the current platform.
- static bool get supported => SvgElement.isTagSupported('cursor') && (new SvgElement.tag('cursor') is _SVGCursorElement);
-
- @DomName('SVGCursorElement.x')
- @DocsEditable
- final AnimatedLength x;
-
- @DomName('SVGCursorElement.y')
- @DocsEditable
- final AnimatedLength y;
-
- // From SVGExternalResourcesRequired
-
- @DomName('SVGCursorElement.externalResourcesRequired')
- @DocsEditable
- final AnimatedBoolean externalResourcesRequired;
-
- // From SVGTests
-
- @DomName('SVGCursorElement.requiredExtensions')
- @DocsEditable
- final StringList requiredExtensions;
-
- @DomName('SVGCursorElement.requiredFeatures')
- @DocsEditable
- final StringList requiredFeatures;
-
- @DomName('SVGCursorElement.systemLanguage')
- @DocsEditable
- final StringList systemLanguage;
-
- @DomName('SVGCursorElement.hasExtension')
- @DocsEditable
- bool hasExtension(String extension) native;
-
- // From SVGURIReference
-
- @DomName('SVGCursorElement.href')
- @DocsEditable
- final AnimatedString href;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFEDropShadowElement')
-class _SVGFEDropShadowElement extends StyledElement implements FilterPrimitiveStandardAttributes native "*SVGFEDropShadowElement" {
-
- @DomName('SVGFEDropShadowElement.dx')
- @DocsEditable
- final AnimatedNumber dx;
-
- @DomName('SVGFEDropShadowElement.dy')
- @DocsEditable
- final AnimatedNumber dy;
-
- @DomName('SVGFEDropShadowElement.in1')
- @DocsEditable
- final AnimatedString in1;
-
- @DomName('SVGFEDropShadowElement.stdDeviationX')
- @DocsEditable
- final AnimatedNumber stdDeviationX;
-
- @DomName('SVGFEDropShadowElement.stdDeviationY')
- @DocsEditable
- final AnimatedNumber stdDeviationY;
-
- @DomName('SVGFEDropShadowElement.setStdDeviation')
- @DocsEditable
- void setStdDeviation(num stdDeviationX, num stdDeviationY) native;
-
- // From SVGFilterPrimitiveStandardAttributes
-
- @DomName('SVGFEDropShadowElement.height')
- @DocsEditable
- final AnimatedLength height;
-
- @DomName('SVGFEDropShadowElement.result')
- @DocsEditable
- final AnimatedString result;
-
- @DomName('SVGFEDropShadowElement.width')
- @DocsEditable
- final AnimatedLength width;
-
- @DomName('SVGFEDropShadowElement.x')
- @DocsEditable
- final AnimatedLength x;
-
- @DomName('SVGFEDropShadowElement.y')
- @DocsEditable
- final AnimatedLength y;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFontElement')
-class _SVGFontElement extends SvgElement native "*SVGFontElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFontFaceElement')
-class _SVGFontFaceElement extends SvgElement native "*SVGFontFaceElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFontFaceFormatElement')
-class _SVGFontFaceFormatElement extends SvgElement native "*SVGFontFaceFormatElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFontFaceNameElement')
-class _SVGFontFaceNameElement extends SvgElement native "*SVGFontFaceNameElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFontFaceSrcElement')
-class _SVGFontFaceSrcElement extends SvgElement native "*SVGFontFaceSrcElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGFontFaceUriElement')
-class _SVGFontFaceUriElement extends SvgElement native "*SVGFontFaceUriElement" {
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGGlyphElement')
-class _SVGGlyphElement extends SvgElement native "*SVGGlyphElement" {
-
- @DomName('SVGGlyphElement.SVGGlyphElement')
- @DocsEditable
- factory _SVGGlyphElement() => _SvgElementFactoryProvider.createSvgElement_tag("glyph");
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
-@DomName('SVGGlyphRefElement')
-class _SVGGlyphRefElement extends StyledElement implements UriReference native "*SVGGlyphRefElement" {
-
- @DomName('SVGGlyphRefElement.dx')
- @DocsEditable
- num dx;
-
- @DomName('SVGGlyphRefElement.dy')
- @DocsEditable
- num dy;
-
- @DomName('SVGGlyphRefElement.format')
- @DocsEditable
- String format;
-
- @DomName('SVGGlyphRefElement.glyphRef')
- @DocsEditable
- String glyphRef;
-
- @DomName('SVGGlyphRefElement.x')
- @DocsEditable
- num x;
-
- @DomName('SVGGlyphRefElement.y')
- @DocsEditable
- num y;
-
- // From SVGURIReference
-
- @DomName('SVGGlyphRefElement.href')
- @DocsEditable
- final AnimatedString href;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('SVGGradientElement')
-class _SVGGradientElement extends StyledElement implements UriReference, ExternalResourcesRequired native "*SVGGradientElement" {
+class _GradientElement extends StyledElement implements UriReference, ExternalResourcesRequired native "*SVGGradientElement" {
static const int SVG_SPREADMETHOD_PAD = 1;
@@ -7747,8 +7331,167 @@
@DocsEditable
+@DomName('SVGAltGlyphDefElement')
+abstract class _SVGAltGlyphDefElement extends SvgElement native "*SVGAltGlyphDefElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGAltGlyphItemElement')
+abstract class _SVGAltGlyphItemElement extends SvgElement native "*SVGAltGlyphItemElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGAnimateColorElement')
+abstract class _SVGAnimateColorElement extends AnimationElement native "*SVGAnimateColorElement" {
+}
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+// Hack because the baseclass is private in dart:html, and we want to omit this
+// type entirely but can't.
+@DocsEditable
+@DomName('SVGColor')
+class _SVGColor native "*SVGColor" {
+ _SVGColor.internal();
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGComponentTransferFunctionElement')
+abstract class _SVGComponentTransferFunctionElement extends SvgElement native "*SVGComponentTransferFunctionElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGCursorElement')
+abstract class _SVGCursorElement extends SvgElement implements UriReference, Tests, ExternalResourcesRequired native "*SVGCursorElement" {
+
+ @DomName('SVGCursorElement.SVGCursorElement')
+ @DocsEditable
+ factory _SVGCursorElement() => _SvgElementFactoryProvider.createSvgElement_tag("cursor");
+
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => SvgElement.isTagSupported('cursor') && (new SvgElement.tag('cursor') is _SVGCursorElement);
+
+ // From SVGExternalResourcesRequired
+
+ // From SVGTests
+
+ // From SVGURIReference
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFEDropShadowElement')
+abstract class _SVGFEDropShadowElement extends StyledElement implements FilterPrimitiveStandardAttributes native "*SVGFEDropShadowElement" {
+
+ // From SVGFilterPrimitiveStandardAttributes
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFontElement')
+abstract class _SVGFontElement extends SvgElement native "*SVGFontElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFontFaceElement')
+abstract class _SVGFontFaceElement extends SvgElement native "*SVGFontFaceElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFontFaceFormatElement')
+abstract class _SVGFontFaceFormatElement extends SvgElement native "*SVGFontFaceFormatElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFontFaceNameElement')
+abstract class _SVGFontFaceNameElement extends SvgElement native "*SVGFontFaceNameElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFontFaceSrcElement')
+abstract class _SVGFontFaceSrcElement extends SvgElement native "*SVGFontFaceSrcElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGFontFaceUriElement')
+abstract class _SVGFontFaceUriElement extends SvgElement native "*SVGFontFaceUriElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGGlyphElement')
+abstract class _SVGGlyphElement extends SvgElement native "*SVGGlyphElement" {
+
+ @DomName('SVGGlyphElement.SVGGlyphElement')
+ @DocsEditable
+ factory _SVGGlyphElement() => _SvgElementFactoryProvider.createSvgElement_tag("glyph");
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGGlyphRefElement')
+abstract class _SVGGlyphRefElement extends StyledElement implements UriReference native "*SVGGlyphRefElement" {
+
+ // From SVGURIReference
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
@DomName('SVGHKernElement')
-class _SVGHKernElement extends SvgElement native "*SVGHKernElement" {
+abstract class _SVGHKernElement extends SvgElement native "*SVGHKernElement" {
@DomName('SVGHKernElement.SVGHKernElement')
@DocsEditable
@@ -7761,7 +7504,7 @@
@DocsEditable
@DomName('SVGMPathElement')
-class _SVGMPathElement extends SvgElement implements UriReference, ExternalResourcesRequired native "*SVGMPathElement" {
+abstract class _SVGMPathElement extends SvgElement implements UriReference, ExternalResourcesRequired native "*SVGMPathElement" {
@DomName('SVGMPathElement.SVGMPathElement')
@DocsEditable
@@ -7769,15 +7512,7 @@
// From SVGExternalResourcesRequired
- @DomName('SVGMPathElement.externalResourcesRequired')
- @DocsEditable
- final AnimatedBoolean externalResourcesRequired;
-
// From SVGURIReference
-
- @DomName('SVGMPathElement.href')
- @DocsEditable
- final AnimatedString href;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -7786,7 +7521,16 @@
@DocsEditable
@DomName('SVGMissingGlyphElement')
-class _SVGMissingGlyphElement extends StyledElement native "*SVGMissingGlyphElement" {
+abstract class _SVGMissingGlyphElement extends StyledElement native "*SVGMissingGlyphElement" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
+@DomName('SVGPaint')
+abstract class _SVGPaint extends _SVGColor native "*SVGPaint" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -7795,17 +7539,13 @@
@DocsEditable
@DomName('SVGTRefElement')
-class _SVGTRefElement extends TextPositioningElement implements UriReference native "*SVGTRefElement" {
+abstract class _SVGTRefElement extends TextPositioningElement implements UriReference native "*SVGTRefElement" {
@DomName('SVGTRefElement.SVGTRefElement')
@DocsEditable
factory _SVGTRefElement() => _SvgElementFactoryProvider.createSvgElement_tag("tref");
// From SVGURIReference
-
- @DomName('SVGTRefElement.href')
- @DocsEditable
- final AnimatedString href;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -7814,7 +7554,7 @@
@DocsEditable
@DomName('SVGVKernElement')
-class _SVGVKernElement extends SvgElement native "*SVGVKernElement" {
+abstract class _SVGVKernElement extends SvgElement native "*SVGVKernElement" {
@DomName('SVGVKernElement.SVGVKernElement')
@DocsEditable
diff --git a/sdk/lib/svg/dartium/svg_dartium.dart b/sdk/lib/svg/dartium/svg_dartium.dart
index a665e68..e9532a9 100644
--- a/sdk/lib/svg/dartium/svg_dartium.dart
+++ b/sdk/lib/svg/dartium/svg_dartium.dart
@@ -839,47 +839,6 @@
@DocsEditable
-@DomName('SVGColor')
-class Color extends CssValue {
- Color.internal() : super.internal();
-
- static const int SVG_COLORTYPE_CURRENTCOLOR = 3;
-
- static const int SVG_COLORTYPE_RGBCOLOR = 1;
-
- static const int SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
-
- static const int SVG_COLORTYPE_UNKNOWN = 0;
-
- @DomName('SVGColor.colorType')
- @DocsEditable
- int get colorType native "SVGColor_colorType_Getter";
-
- @DomName('SVGColor.rgbColor')
- @DocsEditable
- CssRgbColor get rgbColor native "SVGColor_rgbColor_Getter";
-
- @DomName('SVGColor.setColor')
- @DocsEditable
- void setColor(int colorType, String rgbColor, String iccColor) native "SVGColor_setColor_Callback";
-
- @DomName('SVGColor.setRGBColor')
- @DocsEditable
- void setRgbColor(String rgbColor) native "SVGColor_setRGBColor_Callback";
-
- @DomName('SVGColor.setRGBColorICCColor')
- @DocsEditable
- void setRgbColorIccColor(String rgbColor, String iccColor) native "SVGColor_setRGBColorICCColor_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('SVGDefsElement')
class DefsElement extends StyledElement implements Transformable, Tests, ExternalResourcesRequired, LangSpace {
DefsElement.internal() : super.internal();
@@ -3332,11 +3291,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Length)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Length reduce(Length combine(Length value, Length element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Length)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Length element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -3344,7 +3304,7 @@
void forEach(void f(Length element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Length element)) =>
@@ -3444,12 +3404,6 @@
throw new StateError("More than one element");
}
- Length min([int compare(Length a, Length b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Length max([int compare(Length a, Length b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Length element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -3466,14 +3420,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Length element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -3494,17 +3440,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Length> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Length> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Length>[]);
}
- List<Length> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Length> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Length> mixins.
@DomName('SVGLengthList.appendItem')
@@ -3642,7 +3595,7 @@
@DocsEditable
@DomName('SVGLinearGradientElement')
-class LinearGradientElement extends _SVGGradientElement {
+class LinearGradientElement extends _GradientElement {
LinearGradientElement.internal() : super.internal();
@DomName('SVGLinearGradientElement.SVGLinearGradientElement')
@@ -4047,11 +4000,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Number)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Number reduce(Number combine(Number value, Number element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Number)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Number element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -4059,7 +4013,7 @@
void forEach(void f(Number element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Number element)) =>
@@ -4159,12 +4113,6 @@
throw new StateError("More than one element");
}
- Number min([int compare(Number a, Number b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Number max([int compare(Number a, Number b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Number element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -4181,14 +4129,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Number element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -4209,17 +4149,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Number> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Number> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Number>[]);
}
- List<Number> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Number> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Number> mixins.
@DomName('SVGNumberList.appendItem')
@@ -4259,55 +4206,6 @@
@DocsEditable
-@DomName('SVGPaint')
-class Paint extends Color {
- Paint.internal() : super.internal();
-
- static const int SVG_PAINTTYPE_CURRENTCOLOR = 102;
-
- static const int SVG_PAINTTYPE_NONE = 101;
-
- static const int SVG_PAINTTYPE_RGBCOLOR = 1;
-
- static const int SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
-
- static const int SVG_PAINTTYPE_UNKNOWN = 0;
-
- static const int SVG_PAINTTYPE_URI = 107;
-
- static const int SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
-
- static const int SVG_PAINTTYPE_URI_NONE = 103;
-
- static const int SVG_PAINTTYPE_URI_RGBCOLOR = 105;
-
- static const int SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
-
- @DomName('SVGPaint.paintType')
- @DocsEditable
- int get paintType native "SVGPaint_paintType_Getter";
-
- @DomName('SVGPaint.uri')
- @DocsEditable
- String get uri native "SVGPaint_uri_Getter";
-
- @DomName('SVGPaint.setPaint')
- @DocsEditable
- void setPaint(int paintType, String uri, String rgbColor, String iccColor) native "SVGPaint_setPaint_Callback";
-
- @DomName('SVGPaint.setUri')
- @DocsEditable
- void setUri(String uri) native "SVGPaint_setUri_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('SVGPathElement')
class PathElement extends StyledElement implements Transformable, Tests, ExternalResourcesRequired, LangSpace {
PathElement.internal() : super.internal();
@@ -5238,11 +5136,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, PathSeg)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ PathSeg reduce(PathSeg combine(PathSeg value, PathSeg element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, PathSeg)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, PathSeg element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -5250,7 +5149,7 @@
void forEach(void f(PathSeg element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(PathSeg element)) =>
@@ -5350,12 +5249,6 @@
throw new StateError("More than one element");
}
- PathSeg min([int compare(PathSeg a, PathSeg b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- PathSeg max([int compare(PathSeg a, PathSeg b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, PathSeg element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -5372,14 +5265,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(PathSeg element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -5400,17 +5285,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<PathSeg> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<PathSeg> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <PathSeg>[]);
}
- List<PathSeg> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, PathSeg> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<PathSeg> mixins.
@DomName('SVGPathSegList.appendItem')
@@ -5915,7 +5807,7 @@
@DocsEditable
@DomName('SVGRadialGradientElement')
-class RadialGradientElement extends _SVGGradientElement {
+class RadialGradientElement extends _GradientElement {
RadialGradientElement.internal() : super.internal();
@DomName('SVGRadialGradientElement.SVGRadialGradientElement')
@@ -6234,11 +6126,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, String)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, String element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -6246,7 +6139,7 @@
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(String element)) =>
@@ -6346,12 +6239,6 @@
throw new StateError("More than one element");
}
- String min([int compare(String a, String b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- String max([int compare(String a, String b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, String element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -6368,14 +6255,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(String element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -6396,17 +6275,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<String> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<String> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <String>[]);
}
- List<String> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, String> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<String> mixins.
@DomName('SVGStringList.appendItem')
@@ -6523,10 +6409,6 @@
@DocsEditable
CssStyleDeclaration get style native "SVGStyledElement_style_Getter";
- @DomName('SVGStyledElement.getPresentationAttribute')
- @DocsEditable
- CssValue getPresentationAttribute(String name) native "SVGStyledElement_getPresentationAttribute_Callback";
-
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -7499,11 +7381,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Transform)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Transform reduce(Transform combine(Transform value, Transform element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Transform)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Transform element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -7511,7 +7394,7 @@
void forEach(void f(Transform element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Transform element)) =>
@@ -7611,12 +7494,6 @@
throw new StateError("More than one element");
}
- Transform min([int compare(Transform a, Transform b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Transform max([int compare(Transform a, Transform b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Transform element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -7633,14 +7510,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Transform element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -7661,17 +7530,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Transform> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Transform> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Transform>[]);
}
- List<Transform> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Transform> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Transform> mixins.
@DomName('SVGTransformList.appendItem')
@@ -8084,11 +7960,12 @@
return new FixedSizeListIterator<ElementInstance>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, ElementInstance)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ ElementInstance reduce(ElementInstance combine(ElementInstance value, ElementInstance element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, ElementInstance)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, ElementInstance element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -8096,7 +7973,7 @@
void forEach(void f(ElementInstance element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(ElementInstance element)) =>
@@ -8198,12 +8075,6 @@
throw new StateError("More than one element");
}
- ElementInstance min([int compare(ElementInstance a, ElementInstance b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- ElementInstance max([int compare(ElementInstance a, ElementInstance b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, ElementInstance element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -8220,14 +8091,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(ElementInstance element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -8248,17 +8111,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<ElementInstance> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<ElementInstance> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <ElementInstance>[]);
}
- List<ElementInstance> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, ElementInstance> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<ElementInstance> mixins.
@DomName('SVGElementInstanceList.item')
@@ -8274,370 +8144,9 @@
@DocsEditable
-@DomName('SVGAltGlyphDefElement')
-class _SVGAltGlyphDefElement extends SvgElement {
- _SVGAltGlyphDefElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGAltGlyphItemElement')
-class _SVGAltGlyphItemElement extends SvgElement {
- _SVGAltGlyphItemElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGAnimateColorElement')
-class _SVGAnimateColorElement extends AnimationElement {
- _SVGAnimateColorElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGComponentTransferFunctionElement')
-class _SVGComponentTransferFunctionElement extends SvgElement {
- _SVGComponentTransferFunctionElement.internal() : super.internal();
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2;
-
- static const int SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0;
-
- @DomName('SVGComponentTransferFunctionElement.amplitude')
- @DocsEditable
- AnimatedNumber get amplitude native "SVGComponentTransferFunctionElement_amplitude_Getter";
-
- @DomName('SVGComponentTransferFunctionElement.exponent')
- @DocsEditable
- AnimatedNumber get exponent native "SVGComponentTransferFunctionElement_exponent_Getter";
-
- @DomName('SVGComponentTransferFunctionElement.intercept')
- @DocsEditable
- AnimatedNumber get intercept native "SVGComponentTransferFunctionElement_intercept_Getter";
-
- @DomName('SVGComponentTransferFunctionElement.offset')
- @DocsEditable
- AnimatedNumber get gradientOffset native "SVGComponentTransferFunctionElement_offset_Getter";
-
- @DomName('SVGComponentTransferFunctionElement.slope')
- @DocsEditable
- AnimatedNumber get slope native "SVGComponentTransferFunctionElement_slope_Getter";
-
- @DomName('SVGComponentTransferFunctionElement.tableValues')
- @DocsEditable
- AnimatedNumberList get tableValues native "SVGComponentTransferFunctionElement_tableValues_Getter";
-
- @DomName('SVGComponentTransferFunctionElement.type')
- @DocsEditable
- AnimatedEnumeration get type native "SVGComponentTransferFunctionElement_type_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGCursorElement')
-class _SVGCursorElement extends SvgElement implements UriReference, Tests, ExternalResourcesRequired {
- _SVGCursorElement.internal() : super.internal();
-
- @DomName('SVGCursorElement.SVGCursorElement')
- @DocsEditable
- factory _SVGCursorElement() => _SvgElementFactoryProvider.createSvgElement_tag("cursor");
-
- /// Checks if this type is supported on the current platform.
- static bool get supported => true;
-
- @DomName('SVGCursorElement.x')
- @DocsEditable
- AnimatedLength get x native "SVGCursorElement_x_Getter";
-
- @DomName('SVGCursorElement.y')
- @DocsEditable
- AnimatedLength get y native "SVGCursorElement_y_Getter";
-
- @DomName('SVGCursorElement.externalResourcesRequired')
- @DocsEditable
- AnimatedBoolean get externalResourcesRequired native "SVGCursorElement_externalResourcesRequired_Getter";
-
- @DomName('SVGCursorElement.requiredExtensions')
- @DocsEditable
- StringList get requiredExtensions native "SVGCursorElement_requiredExtensions_Getter";
-
- @DomName('SVGCursorElement.requiredFeatures')
- @DocsEditable
- StringList get requiredFeatures native "SVGCursorElement_requiredFeatures_Getter";
-
- @DomName('SVGCursorElement.systemLanguage')
- @DocsEditable
- StringList get systemLanguage native "SVGCursorElement_systemLanguage_Getter";
-
- @DomName('SVGCursorElement.hasExtension')
- @DocsEditable
- bool hasExtension(String extension) native "SVGCursorElement_hasExtension_Callback";
-
- @DomName('SVGCursorElement.href')
- @DocsEditable
- AnimatedString get href native "SVGCursorElement_href_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFEDropShadowElement')
-class _SVGFEDropShadowElement extends StyledElement implements FilterPrimitiveStandardAttributes {
- _SVGFEDropShadowElement.internal() : super.internal();
-
- @DomName('SVGFEDropShadowElement.dx')
- @DocsEditable
- AnimatedNumber get dx native "SVGFEDropShadowElement_dx_Getter";
-
- @DomName('SVGFEDropShadowElement.dy')
- @DocsEditable
- AnimatedNumber get dy native "SVGFEDropShadowElement_dy_Getter";
-
- @DomName('SVGFEDropShadowElement.in1')
- @DocsEditable
- AnimatedString get in1 native "SVGFEDropShadowElement_in1_Getter";
-
- @DomName('SVGFEDropShadowElement.stdDeviationX')
- @DocsEditable
- AnimatedNumber get stdDeviationX native "SVGFEDropShadowElement_stdDeviationX_Getter";
-
- @DomName('SVGFEDropShadowElement.stdDeviationY')
- @DocsEditable
- AnimatedNumber get stdDeviationY native "SVGFEDropShadowElement_stdDeviationY_Getter";
-
- @DomName('SVGFEDropShadowElement.setStdDeviation')
- @DocsEditable
- void setStdDeviation(num stdDeviationX, num stdDeviationY) native "SVGFEDropShadowElement_setStdDeviation_Callback";
-
- @DomName('SVGFEDropShadowElement.height')
- @DocsEditable
- AnimatedLength get height native "SVGFEDropShadowElement_height_Getter";
-
- @DomName('SVGFEDropShadowElement.result')
- @DocsEditable
- AnimatedString get result native "SVGFEDropShadowElement_result_Getter";
-
- @DomName('SVGFEDropShadowElement.width')
- @DocsEditable
- AnimatedLength get width native "SVGFEDropShadowElement_width_Getter";
-
- @DomName('SVGFEDropShadowElement.x')
- @DocsEditable
- AnimatedLength get x native "SVGFEDropShadowElement_x_Getter";
-
- @DomName('SVGFEDropShadowElement.y')
- @DocsEditable
- AnimatedLength get y native "SVGFEDropShadowElement_y_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFontElement')
-class _SVGFontElement extends SvgElement {
- _SVGFontElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFontFaceElement')
-class _SVGFontFaceElement extends SvgElement {
- _SVGFontFaceElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFontFaceFormatElement')
-class _SVGFontFaceFormatElement extends SvgElement {
- _SVGFontFaceFormatElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFontFaceNameElement')
-class _SVGFontFaceNameElement extends SvgElement {
- _SVGFontFaceNameElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFontFaceSrcElement')
-class _SVGFontFaceSrcElement extends SvgElement {
- _SVGFontFaceSrcElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGFontFaceUriElement')
-class _SVGFontFaceUriElement extends SvgElement {
- _SVGFontFaceUriElement.internal() : super.internal();
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGGlyphElement')
-class _SVGGlyphElement extends SvgElement {
- _SVGGlyphElement.internal() : super.internal();
-
- @DomName('SVGGlyphElement.SVGGlyphElement')
- @DocsEditable
- factory _SVGGlyphElement() => _SvgElementFactoryProvider.createSvgElement_tag("glyph");
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
-@DomName('SVGGlyphRefElement')
-class _SVGGlyphRefElement extends StyledElement implements UriReference {
- _SVGGlyphRefElement.internal() : super.internal();
-
- @DomName('SVGGlyphRefElement.dx')
- @DocsEditable
- num get dx native "SVGGlyphRefElement_dx_Getter";
-
- @DomName('SVGGlyphRefElement.dx')
- @DocsEditable
- void set dx(num value) native "SVGGlyphRefElement_dx_Setter";
-
- @DomName('SVGGlyphRefElement.dy')
- @DocsEditable
- num get dy native "SVGGlyphRefElement_dy_Getter";
-
- @DomName('SVGGlyphRefElement.dy')
- @DocsEditable
- void set dy(num value) native "SVGGlyphRefElement_dy_Setter";
-
- @DomName('SVGGlyphRefElement.format')
- @DocsEditable
- String get format native "SVGGlyphRefElement_format_Getter";
-
- @DomName('SVGGlyphRefElement.format')
- @DocsEditable
- void set format(String value) native "SVGGlyphRefElement_format_Setter";
-
- @DomName('SVGGlyphRefElement.glyphRef')
- @DocsEditable
- String get glyphRef native "SVGGlyphRefElement_glyphRef_Getter";
-
- @DomName('SVGGlyphRefElement.glyphRef')
- @DocsEditable
- void set glyphRef(String value) native "SVGGlyphRefElement_glyphRef_Setter";
-
- @DomName('SVGGlyphRefElement.x')
- @DocsEditable
- num get x native "SVGGlyphRefElement_x_Getter";
-
- @DomName('SVGGlyphRefElement.x')
- @DocsEditable
- void set x(num value) native "SVGGlyphRefElement_x_Setter";
-
- @DomName('SVGGlyphRefElement.y')
- @DocsEditable
- num get y native "SVGGlyphRefElement_y_Getter";
-
- @DomName('SVGGlyphRefElement.y')
- @DocsEditable
- void set y(num value) native "SVGGlyphRefElement_y_Setter";
-
- @DomName('SVGGlyphRefElement.href')
- @DocsEditable
- AnimatedString get href native "SVGGlyphRefElement_href_Getter";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('SVGGradientElement')
-class _SVGGradientElement extends StyledElement implements UriReference, ExternalResourcesRequired {
- _SVGGradientElement.internal() : super.internal();
+class _GradientElement extends StyledElement implements UriReference, ExternalResourcesRequired {
+ _GradientElement.internal() : super.internal();
static const int SVG_SPREADMETHOD_PAD = 1;
@@ -8676,8 +8185,213 @@
@DocsEditable
+@DomName('SVGAltGlyphDefElement')
+abstract class _SVGAltGlyphDefElement extends SvgElement {
+ _SVGAltGlyphDefElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGAltGlyphItemElement')
+abstract class _SVGAltGlyphItemElement extends SvgElement {
+ _SVGAltGlyphItemElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGAnimateColorElement')
+abstract class _SVGAnimateColorElement extends AnimationElement {
+ _SVGAnimateColorElement.internal() : super.internal();
+
+}
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+// Hack because the baseclass is private in dart:html, and we want to omit this
+// type entirely but can't.
+@DocsEditable
+@DomName('SVGColor')
+class _SVGColor {
+ _SVGColor.internal();
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGComponentTransferFunctionElement')
+abstract class _SVGComponentTransferFunctionElement extends SvgElement {
+ _SVGComponentTransferFunctionElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGCursorElement')
+abstract class _SVGCursorElement extends SvgElement implements UriReference, Tests, ExternalResourcesRequired {
+ _SVGCursorElement.internal() : super.internal();
+
+ @DomName('SVGCursorElement.SVGCursorElement')
+ @DocsEditable
+ factory _SVGCursorElement() => _SvgElementFactoryProvider.createSvgElement_tag("cursor");
+
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => true;
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFEDropShadowElement')
+abstract class _SVGFEDropShadowElement extends StyledElement implements FilterPrimitiveStandardAttributes {
+ _SVGFEDropShadowElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFontElement')
+abstract class _SVGFontElement extends SvgElement {
+ _SVGFontElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFontFaceElement')
+abstract class _SVGFontFaceElement extends SvgElement {
+ _SVGFontFaceElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFontFaceFormatElement')
+abstract class _SVGFontFaceFormatElement extends SvgElement {
+ _SVGFontFaceFormatElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFontFaceNameElement')
+abstract class _SVGFontFaceNameElement extends SvgElement {
+ _SVGFontFaceNameElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFontFaceSrcElement')
+abstract class _SVGFontFaceSrcElement extends SvgElement {
+ _SVGFontFaceSrcElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGFontFaceUriElement')
+abstract class _SVGFontFaceUriElement extends SvgElement {
+ _SVGFontFaceUriElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGGlyphElement')
+abstract class _SVGGlyphElement extends SvgElement {
+ _SVGGlyphElement.internal() : super.internal();
+
+ @DomName('SVGGlyphElement.SVGGlyphElement')
+ @DocsEditable
+ factory _SVGGlyphElement() => _SvgElementFactoryProvider.createSvgElement_tag("glyph");
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
+@DomName('SVGGlyphRefElement')
+abstract class _SVGGlyphRefElement extends StyledElement implements UriReference {
+ _SVGGlyphRefElement.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
@DomName('SVGHKernElement')
-class _SVGHKernElement extends SvgElement {
+abstract class _SVGHKernElement extends SvgElement {
_SVGHKernElement.internal() : super.internal();
@DomName('SVGHKernElement.SVGHKernElement')
@@ -8694,21 +8408,13 @@
@DocsEditable
@DomName('SVGMPathElement')
-class _SVGMPathElement extends SvgElement implements UriReference, ExternalResourcesRequired {
+abstract class _SVGMPathElement extends SvgElement implements UriReference, ExternalResourcesRequired {
_SVGMPathElement.internal() : super.internal();
@DomName('SVGMPathElement.SVGMPathElement')
@DocsEditable
factory _SVGMPathElement() => _SvgElementFactoryProvider.createSvgElement_tag("mpath");
- @DomName('SVGMPathElement.externalResourcesRequired')
- @DocsEditable
- AnimatedBoolean get externalResourcesRequired native "SVGMPathElement_externalResourcesRequired_Getter";
-
- @DomName('SVGMPathElement.href')
- @DocsEditable
- AnimatedString get href native "SVGMPathElement_href_Getter";
-
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -8719,7 +8425,7 @@
@DocsEditable
@DomName('SVGMissingGlyphElement')
-class _SVGMissingGlyphElement extends StyledElement {
+abstract class _SVGMissingGlyphElement extends StyledElement {
_SVGMissingGlyphElement.internal() : super.internal();
}
@@ -8731,18 +8437,27 @@
@DocsEditable
+@DomName('SVGPaint')
+abstract class _SVGPaint extends _SVGColor {
+ _SVGPaint.internal() : super.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
@DomName('SVGTRefElement')
-class _SVGTRefElement extends TextPositioningElement implements UriReference {
+abstract class _SVGTRefElement extends TextPositioningElement implements UriReference {
_SVGTRefElement.internal() : super.internal();
@DomName('SVGTRefElement.SVGTRefElement')
@DocsEditable
factory _SVGTRefElement() => _SvgElementFactoryProvider.createSvgElement_tag("tref");
- @DomName('SVGTRefElement.href')
- @DocsEditable
- AnimatedString get href native "SVGTRefElement_href_Getter";
-
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -8753,7 +8468,7 @@
@DocsEditable
@DomName('SVGVKernElement')
-class _SVGVKernElement extends SvgElement {
+abstract class _SVGVKernElement extends SvgElement {
_SVGVKernElement.internal() : super.internal();
@DomName('SVGVKernElement.SVGVKernElement')
diff --git a/sdk/lib/typeddata/typeddata.dart b/sdk/lib/typeddata/typeddata.dart
index 773d3cc..7a39f22 100644
--- a/sdk/lib/typeddata/typeddata.dart
+++ b/sdk/lib/typeddata/typeddata.dart
@@ -5,6 +5,7 @@
library dart.typeddata;
import 'dart:collection';
+import 'dart:_collection-dev';
/**
* A sequence of bytes underlying a typed data object.
@@ -327,6 +328,12 @@
external factory Int8List(int length);
/**
+ * Creates a [Int8List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int8List.fromList(List<int> elements);
+
+ /**
* Creates an [Int8List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int8List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -358,6 +365,12 @@
external factory Uint8List(int length);
/**
+ * Creates a [Uint8List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint8List.fromList(List<int> elements);
+
+ /**
* Creates a [Uint8List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Uint8List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -390,6 +403,12 @@
external factory Uint8ClampedList(int length);
/**
+ * Creates a [Uint8ClampedList] of the same size as the [elements]
+ * list and copies over the values clamping when needed.
+ */
+ external factory Uint8ClampedList.fromList(List<int> elements);
+
+ /**
* Creates a [Uint8ClampedList] _view_ of the specified region in the
* specified byte [buffer]. Changes in the [Uint8List] will be visible in the
* byte buffer and vice versa. If the [offsetInBytes] index of the region is
@@ -421,6 +440,12 @@
external factory Int16List(int length);
/**
+ * Creates a [Int16List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int16List.fromList(List<int> elements);
+
+ /**
* Creates an [Int16List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int16List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -455,6 +480,12 @@
external factory Uint16List(int length);
/**
+ * Creates a [Uint16List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint16List.fromList(List<int> elements);
+
+ /**
* Creates a [Uint16List] _view_ of the specified region in
* the specified byte buffer. Changes in the [Uint16List] will be
* visible in the byte buffer and vice versa. If the [offsetInBytes] index
@@ -489,6 +520,12 @@
external factory Int32List(int length);
/**
+ * Creates a [Int32List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int32List.fromList(List<int> elements);
+
+ /**
* Creates an [Int32List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int32List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -523,6 +560,12 @@
external factory Uint32List(int length);
/**
+ * Creates a [Uint32List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint32List.fromList(List<int> elements);
+
+ /**
* Creates a [Uint32List] _view_ of the specified region in
* the specified byte buffer. Changes in the [Uint32] will be
* visible in the byte buffer and vice versa. If the [offsetInBytes] index
@@ -557,6 +600,12 @@
external factory Int64List(int length);
/**
+ * Creates a [Int64List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Int64List.fromList(List<int> elements);
+
+ /**
* Creates an [Int64List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Int64List] will be visible in the byte buffer
* and vice versa. If the [offsetInBytes] index of the region is not
@@ -591,6 +640,12 @@
external factory Uint64List(int length);
/**
+ * Creates a [Uint64List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Uint64List.fromList(List<int> elements);
+
+ /**
* Creates an [Uint64List] _view_ of the specified region in
* the specified byte buffer. Changes in the [Uint64List] will be
* visible in the byte buffer and vice versa. If the [offsetInBytes]
@@ -627,6 +682,12 @@
external factory Float32List(int length);
/**
+ * Creates a [Float32List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Float32List.fromList(List<double> elements);
+
+ /**
* Creates a [Float32List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Float32List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
@@ -662,6 +723,12 @@
external factory Float64List(int length);
/**
+ * Creates a [Float64List] with the same size as the [elements] list
+ * and copies over the elements.
+ */
+ external factory Float64List.fromList(List<double> elements);
+
+ /**
* Creates a [Float64List] _view_ of the specified region in the specified
* byte buffer. Changes in the [Float64List] will be visible in the byte
* buffer and vice versa. If the [offsetInBytes] index of the region is not
diff --git a/sdk/lib/utf/utf.dart b/sdk/lib/utf/utf.dart
index 2031e62..1c8c95c 100644
--- a/sdk/lib/utf/utf.dart
+++ b/sdk/lib/utf/utf.dart
@@ -21,6 +21,8 @@
/**
* Generate a string from the provided Unicode codepoints.
+ *
+ * *Deprecated* Use [String.fromCharCodes] instead.
*/
String codepointsToString(List<int> codepoints) {
return new String.fromCharCodes(codepoints);
diff --git a/sdk/lib/utf/utf32.dart b/sdk/lib/utf/utf32.dart
index 1e43f01..5ddf7a7 100644
--- a/sdk/lib/utf/utf32.dart
+++ b/sdk/lib/utf/utf32.dart
@@ -57,7 +57,7 @@
*/
String decodeUtf32(List<int> bytes, [int offset = 0, int length,
int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
- return codepointsToString((new Utf32BytesDecoder(bytes, offset, length,
+ return new String.fromCharCodes((new Utf32BytesDecoder(bytes, offset, length,
replacementCodepoint)).decodeRest());
}
/**
@@ -70,8 +70,8 @@
String decodeUtf32be(
List<int> bytes, [int offset = 0, int length, bool stripBom = true,
int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) =>
- codepointsToString((new Utf32beBytesDecoder(bytes, offset, length, stripBom,
- replacementCodepoint)).decodeRest());
+ new String.fromCharCodes((new Utf32beBytesDecoder(bytes, offset, length,
+ stripBom, replacementCodepoint)).decodeRest());
/**
* Produce a String from a sequence of UTF-32LE encoded bytes. The parameters
@@ -83,8 +83,8 @@
String decodeUtf32le(
List<int> bytes, [int offset = 0, int length, bool stripBom = true,
int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) =>
- codepointsToString((new Utf32leBytesDecoder(bytes, offset, length, stripBom,
- replacementCodepoint)).decodeRest());
+ new String.fromCharCodes((new Utf32leBytesDecoder(bytes, offset, length,
+ stripBom, replacementCodepoint)).decodeRest());
/**
* Produce a list of UTF-32 encoded bytes. This method prefixes the resulting
diff --git a/sdk/lib/utf/utf8.dart b/sdk/lib/utf/utf8.dart
index b44cbe4..893cf0f 100644
--- a/sdk/lib/utf/utf8.dart
+++ b/sdk/lib/utf/utf8.dart
@@ -43,7 +43,7 @@
*/
String decodeUtf8(List<int> bytes, [int offset = 0, int length,
int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
- return codepointsToString(
+ return new String.fromCharCodes(
(new Utf8Decoder(bytes, offset, length, replacementCodepoint))
.decodeRest());
}
diff --git a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
index ee3553b..1a36a9f 100644
--- a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
+++ b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
@@ -827,7 +827,7 @@
if (_eventStream == null) {
var controller = new StreamController();
var callback = (audioData) {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
// This stream is a strange combination of broadcast and single
// subscriber streams. We only allow one listener, but if there is
// no listener, we don't queue up events, we just drop them on the
diff --git a/sdk/lib/web_audio/dartium/web_audio_dartium.dart b/sdk/lib/web_audio/dartium/web_audio_dartium.dart
index 4b410d1..3743a5d 100644
--- a/sdk/lib/web_audio/dartium/web_audio_dartium.dart
+++ b/sdk/lib/web_audio/dartium/web_audio_dartium.dart
@@ -1096,7 +1096,7 @@
if (_eventStream == null) {
var controller = new StreamController();
var callback = (audioData) {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
// This stream is a strange combination of broadcast and single
// subscriber streams. We only allow one listener, but if there is
// no listener, we don't queue up events, we just drop them on the
diff --git a/sdk/lib/web_sql/dart2js/web_sql_dart2js.dart b/sdk/lib/web_sql/dart2js/web_sql_dart2js.dart
index 00a5947..eee01a0 100644
--- a/sdk/lib/web_sql/dart2js/web_sql_dart2js.dart
+++ b/sdk/lib/web_sql/dart2js/web_sql_dart2js.dart
@@ -67,14 +67,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// WARNING: Do not edit - generated code.
-
-
-typedef void SqlTransactionSyncCallback(SqlTransactionSync transaction);
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
@DocsEditable
@DomName('Database')
@@ -120,38 +112,6 @@
@DocsEditable
-@DomName('DatabaseSync')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@SupportedBrowser(SupportedBrowser.SAFARI)
-@Experimental
-class SqlDatabaseSync native "*DatabaseSync" {
-
- @DomName('DatabaseSync.lastErrorMessage')
- @DocsEditable
- final String lastErrorMessage;
-
- @DomName('DatabaseSync.version')
- @DocsEditable
- final String version;
-
- @DomName('DatabaseSync.changeVersion')
- @DocsEditable
- void changeVersion(String oldVersion, String newVersion, [SqlTransactionSyncCallback callback]) native;
-
- @DomName('DatabaseSync.readTransaction')
- @DocsEditable
- void readTransaction(SqlTransactionSyncCallback callback) native;
-
- @DomName('DatabaseSync.transaction')
- @DocsEditable
- void transaction(SqlTransactionSyncCallback callback) native;
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-@DocsEditable
@DomName('SQLError')
class SqlError native "*SQLError" {
@@ -263,11 +223,12 @@
return new FixedSizeListIterator<Map>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Map)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Map reduce(Map combine(Map value, Map element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Map)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Map element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -275,7 +236,7 @@
void forEach(void f(Map element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Map element)) =>
@@ -377,12 +338,6 @@
throw new StateError("More than one element");
}
- Map min([int compare(Map a, Map b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Map max([int compare(Map a, Map b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Map element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -399,14 +354,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Map element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -427,17 +374,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Map> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Map> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Map>[]);
}
- List<Map> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Map> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Map> mixins.
@DomName('SQLResultSetRowList.item')
@@ -474,13 +428,21 @@
@DocsEditable
+@DomName('DatabaseSync')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.SAFARI)
+@Experimental
+abstract class _DatabaseSync native "*DatabaseSync" {
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+
+@DocsEditable
@DomName('SQLTransactionSync')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
-class SqlTransactionSync native "*SQLTransactionSync" {
-
- @DomName('SQLTransactionSync.executeSql')
- @DocsEditable
- SqlResultSet executeSql(String sqlStatement, List arguments) native;
+abstract class _SQLTransactionSync native "*SQLTransactionSync" {
}
diff --git a/sdk/lib/web_sql/dartium/web_sql_dartium.dart b/sdk/lib/web_sql/dartium/web_sql_dartium.dart
index 2fca22d..2a71887 100644
--- a/sdk/lib/web_sql/dartium/web_sql_dartium.dart
+++ b/sdk/lib/web_sql/dartium/web_sql_dartium.dart
@@ -69,14 +69,6 @@
// WARNING: Do not edit - generated code.
-typedef void SqlTransactionSyncCallback(SqlTransactionSync transaction);
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
@DocsEditable
@DomName('Database')
@SupportedBrowser(SupportedBrowser.CHROME)
@@ -125,42 +117,6 @@
@DocsEditable
-@DomName('DatabaseSync')
-@SupportedBrowser(SupportedBrowser.CHROME)
-@SupportedBrowser(SupportedBrowser.SAFARI)
-@Experimental
-class SqlDatabaseSync extends NativeFieldWrapperClass1 {
- SqlDatabaseSync.internal();
-
- @DomName('DatabaseSync.lastErrorMessage')
- @DocsEditable
- String get lastErrorMessage native "DatabaseSync_lastErrorMessage_Getter";
-
- @DomName('DatabaseSync.version')
- @DocsEditable
- String get version native "DatabaseSync_version_Getter";
-
- @DomName('DatabaseSync.changeVersion')
- @DocsEditable
- void changeVersion(String oldVersion, String newVersion, [SqlTransactionSyncCallback callback]) native "DatabaseSync_changeVersion_Callback";
-
- @DomName('DatabaseSync.readTransaction')
- @DocsEditable
- void readTransaction(SqlTransactionSyncCallback callback) native "DatabaseSync_readTransaction_Callback";
-
- @DomName('DatabaseSync.transaction')
- @DocsEditable
- void transaction(SqlTransactionSyncCallback callback) native "DatabaseSync_transaction_Callback";
-
-}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// WARNING: Do not edit - generated code.
-
-
-@DocsEditable
@DomName('SQLError')
class SqlError extends NativeFieldWrapperClass1 {
SqlError.internal();
@@ -285,11 +241,12 @@
return new FixedSizeListIterator<Map>(this);
}
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, Map)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Map reduce(Map combine(Map value, Map element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, Map)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, Map element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -297,7 +254,7 @@
void forEach(void f(Map element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f(Map element)) =>
@@ -399,12 +356,6 @@
throw new StateError("More than one element");
}
- Map min([int compare(Map a, Map b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- Map max([int compare(Map a, Map b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, Map element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -421,14 +372,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test(Map element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -449,17 +392,24 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<Map> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<Map> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <Map>[]);
}
- List<Map> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, Map> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<Map> mixins.
@DomName('SQLResultSetRowList.item')
@@ -495,15 +445,27 @@
@DocsEditable
+@DomName('DatabaseSync')
+@SupportedBrowser(SupportedBrowser.CHROME)
+@SupportedBrowser(SupportedBrowser.SAFARI)
+@Experimental
+abstract class _DatabaseSync extends NativeFieldWrapperClass1 {
+ _DatabaseSync.internal();
+
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// WARNING: Do not edit - generated code.
+
+
+@DocsEditable
@DomName('SQLTransactionSync')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
-class SqlTransactionSync extends NativeFieldWrapperClass1 {
- SqlTransactionSync.internal();
-
- @DomName('SQLTransactionSync.executeSql')
- @DocsEditable
- SqlResultSet executeSql(String sqlStatement, List arguments) native "SQLTransactionSync_executeSql_Callback";
+abstract class _SQLTransactionSync extends NativeFieldWrapperClass1 {
+ _SQLTransactionSync.internal();
}
diff --git a/tests/benchmark_smoke/benchmark_smoke_test.dart b/tests/benchmark_smoke/benchmark_smoke_test.dart
index 2e45827..53b1dac 100644
--- a/tests/benchmark_smoke/benchmark_smoke_test.dart
+++ b/tests/benchmark_smoke/benchmark_smoke_test.dart
@@ -8,6 +8,7 @@
import 'benchmark_lib.dart';
import 'dart:async';
import 'dart:html';
+import '../../pkg/expect/lib/expect.dart';
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
diff --git a/tests/co19/co19-compiler.status b/tests/co19/co19-compiler.status
index e6f59d8..fa01ccd 100644
--- a/tests/co19/co19-compiler.status
+++ b/tests/co19/co19-compiler.status
@@ -168,6 +168,50 @@
LibTest/core/Date/weekday_A01_t01: Fail # Renamed Date to DateTime (issue 373, 374)
LibTest/core/Date/year_A01_t01: Fail # Renamed Date to DateTime (issue 373, 374)
+Language/15_Reference/1_Lexical_Rules/2_Comments_A04_t03: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromMillisecondsSinceEpoch_A02_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/compareTo_A03_t01: Fail # Uses deprecated Expect class, issue 398
+Language/07_Classes/6_Constructors/1_Generative_Constructors_A17_t04: Fail # Uses deprecated Expect class, issue 398
+Language/07_Classes/6_Constructors/2_Factories_A06_t01: Fail # Uses deprecated Expect class, issue 398
+Language/07_Classes/6_Constructors/2_Factories_A06_t02: Fail # Uses deprecated Expect class, issue 398
+Language/07_Classes/6_Constructors/2_Factories_A06_t03: Fail # Uses deprecated Expect class, issue 398
+Language/07_Classes/6_Constructors/2_Factories_A06_t04: Fail # Uses deprecated Expect class, issue 398
+Language/09_Generics/09_Generics_A05_t01: Fail # Uses deprecated Expect class, issue 398
+Language/09_Generics/09_Generics_A05_t02: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/04_Booleans/1_Boolean_Conversion_A01_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/04_Booleans/1_Boolean_Conversion_A02_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/06_Lists_A09_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/14_Function_Invocation/2_Binding_Actuals_to_Formals_A02_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/14_Function_Invocation/2_Binding_Actuals_to_Formals_A03_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/18_Assignment_A02_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/18_Assignment_A04_t06: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/18_Assignment_A06_t01: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/19_Conditional_A02_t03: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/19_Conditional_A02_t04: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/19_Conditional_A04_t03: Fail # Uses deprecated Expect class, issue 398
+Language/11_Expressions/27_Unary_Expressions_A02_t03: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/03_Variable_Declaration_A01_t01: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/03_Variable_Declaration_A01_t02: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/05_If_A02_t01: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/05_If_A02_t02: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/10_Try_A01_t01: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/11_Return_A03_t02: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/11_Return_A04_t01: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/15_Assert_A03_t03: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/15_Assert_A03_t08: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/15_Assert_A03_t09: Fail # Uses deprecated Expect class, issue 398
+Language/12_Statements/15_Assert_A04_t02: Fail # Uses deprecated Expect class, issue 398
+Language/14_Types/2_Dynamic_Type_System_A01_t01: Fail # Uses deprecated Expect class, issue 398
+Language/14_Types/7_Type_Void_A04_t02: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/AssertionError/toString_A01_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/List/every_A01_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/List/getRange_A06_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/List/indexOf_A06_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/List/insertRange_A08_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/List/operator_subscript_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/List/operator_subscripted_assignment_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Map/putIfAbsent_A01_t04: Fail # Uses deprecated Expect class, issue 398
+
LibTest/core/int/operator_division_A01_t01: Fail # truncate/ceil/floor/round returns ints, issue 389
Language/11_Expressions/06_Lists_A06_t01: Fail # Issue 397
@@ -177,5 +221,28 @@
LibTest/core/List/addLast_A02_t01: Fail # Issue 397
LibTest/core/List/filter_A03_t01: Fail # Issue 397
+LibTest/collection/Queue/Queue.from_A01_t01: fail # Issue 400
+LibTest/core/List/List.from_A01_t01: fail # Issue 400
+LibTest/core/List/operator_subscript_A01_t02: fail # Issue 400
+LibTest/core/Match/pattern_A01_t01: fail # Issue 400
+LibTest/core/Match/str_A01_t01: fail # Issue 400
+LibTest/core/RegExp/allMatches_A01_t01: fail # Issue 400
+LibTest/core/Set/intersection_A01_t02: fail # Issue 400
+LibTest/core/String/String_class_A01_t01: fail # Issue 400
+LibTest/core/String/concat_A01_t01: fail # Issue 400
+LibTest/core/String/concat_A02_t01: fail # Issue 400
+LibTest/core/String/hashCode_A01_t01: fail # Issue 400
+LibTest/core/List/List.fixedLength_A01_t01: fail # Issue 400
+LibTest/core/List/addAll_A02_t01: fail # Issue 400
+LibTest/core/List/add_A02_t01: fail # Issue 400
+LibTest/core/List/clear_A02_t01: fail # Issue 400
+LibTest/core/List/insertRange_A02_t01: fail # Issue 400
+LibTest/core/List/length_A04_t01: fail # Issue 400
+LibTest/core/List/removeLast_A02_t01: fail # Issue 400
+LibTest/core/List/removeRange_A02_t01: fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t01: fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t02: fail # Issue 400
+LibTest/core/List/operator_subscript_A01_t02: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+
[ $runtime == drt && $compiler == none ]
*: Skip
diff --git a/tests/co19/co19-dart2dart.status b/tests/co19/co19-dart2dart.status
index f3f373d..49253a8 100644
--- a/tests/co19/co19-dart2dart.status
+++ b/tests/co19/co19-dart2dart.status
@@ -333,7 +333,6 @@
Language/12_Statements/04_Local_Function_Declaration_A01_t01: Fail # Inherited from dart2js
Language/12_Statements/04_Local_Function_Declaration_A02_t02: Fail # Inherited from dart2js
Language/12_Statements/06_For_A01_t11: Fail # Inherited from dart2js
-Language/12_Statements/06_For_A01_t12: Fail # Inherited from dart2js
Language/12_Statements/09_Switch_A01_t02: Fail # Inherited from VM (switch case with several labels).
Language/12_Statements/09_Switch_A02_t01: Fail # Inherited from dart2js
Language/12_Statements/09_Switch_A02_t02: Fail # Inherited from dart2js
@@ -399,6 +398,7 @@
LibTest/core/int/toRadixString_A01_t01: Fail # inherited from VM
LibTest/isolate/ReceivePort/receive_A01_t02: Fail, OK # co19 issue 276
LibTest/isolate/isolate_api/port_A01_t01: Skip # Times out.
+LibTest/isolate/isolate_api/spawnFunction_A02_t01: Fail # Inherited from VM.
LibTest/isolate/isolate_api/spawnUri_A01_t01: Fail, OK # Problems with the test: encoded file name
LibTest/isolate/isolate_api/spawnUri_A01_t02: Fail, OK # Problems with the test: encoded file name
LibTest/isolate/isolate_api/spawnUri_A01_t03: Fail, OK # Problems with the test: encoded file name
@@ -509,6 +509,14 @@
Language/11_Expressions/05_Strings/1_String_Interpolation_A03_t01: Fail # StringBuffer renamed add to write. co19 issue 388.
Language/11_Expressions/05_Strings/1_String_Interpolation_A04_t01: Fail # StringBuffer renamed add to write. co19 issue 388.
+Language/15_Reference/1_Lexical_Rules/2_Comments_A04_t03: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromMillisecondsSinceEpoch_A02_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromString_A04_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/add_A06_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/compareTo_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/difference_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/subtract_A06_t01: Fail # Uses deprecated Expect class, issue 398
+
LibTest/core/double/ceil_A01_t03: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/ceil_A01_t04: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/floor_A01_t03: Fail # truncate/ceil/floor/round returns ints, issue 389
@@ -518,7 +526,10 @@
LibTest/core/double/truncate_A01_t03: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/truncate_A01_t04: Fail # truncate/ceil/floor/round returns ints, issue 389
-LibTest/core/List/getRange_A02_t01: Fail # issue 391
+LibTest/core/List/getRange_A02_t01: Fail # issue 391, and Issue 399
+LibTest/core/List/getRange_A01_t01: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/getRange_A04_t01: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/operator_subscript_A01_t02: Fail # getRange now takes end-argument and returns Iterable. Issue 399
Language/11_Expressions/05_Strings/1_String_Interpolation_A03_t02: Fail # Issue 397
Language/11_Expressions/05_Strings/1_String_Interpolation_A04_t02: Fail # Issue 397
@@ -529,3 +540,14 @@
LibTest/core/List/addLast_A01_t01: Fail # Issue 397
LibTest/core/List/addLast_A01_t03: Fail # Issue 397
LibTest/core/List/addLast_A02_t01: Fail # Issue 397
+
+LibTest/core/List/List.fixedLength_A01_t01: Fail # Issue 400
+LibTest/core/List/addAll_A02_t01: Fail # Issue 400
+LibTest/core/List/add_A02_t01: Fail # Issue 400
+LibTest/core/List/clear_A02_t01: Fail # Issue 400
+LibTest/core/List/insertRange_A02_t01: Fail # Issue 400
+LibTest/core/List/length_A04_t01: Fail # Issue 400
+LibTest/core/List/removeLast_A02_t01: Fail # Issue 400
+LibTest/core/List/removeRange_A02_t01: Fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t01: Fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t02: Fail # Issue 400
diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status
index ccd55df..91c422c 100644
--- a/tests/co19/co19-dart2js.status
+++ b/tests/co19/co19-dart2js.status
@@ -82,8 +82,6 @@
Language/12_Statements/03_Variable_Declaration_A04_t08: Fail # TODO(ahe): Please triage this failure.
Language/12_Statements/04_Local_Function_Declaration_A01_t01: Fail # TODO(ahe): Please triage this failure.
Language/12_Statements/04_Local_Function_Declaration_A02_t02: Fail # TODO(ahe): Please triage this failure.
-Language/12_Statements/06_For_A01_t11: Fail # TODO(ahe): Please triage this failure.
-Language/12_Statements/06_For_A01_t12: Fail # TODO(ahe): Please triage this failure.
Language/12_Statements/09_Switch_A02_t01: Fail # TODO(ahe): Please triage this failure.
Language/12_Statements/09_Switch_A02_t02: Fail # TODO(ahe): Please triage this failure.
Language/12_Statements/09_Switch_A03_t01: Fail # TODO(ahe): Please triage this failure.
@@ -295,8 +293,6 @@
Language/11_Expressions/11_Instance_Creation/1_New_A12_t02: Fail # http://dartbug.com/3970
-Language/13_Libraries_and_Scripts/3_Parts_A02_t03: Fail # http://dartbug.com/5022
-Language/13_Libraries_and_Scripts/3_Parts_A03_t01: Fail # http://dartbug.com/5022
Language/14_Types/3_Type_Declarations/1_Typedef_A01_t01: Fail # http://dartbug.com/5022
LibTest/core/List/operator_subscript_A03_t01: Fail # http://dartbug.com/9228
@@ -369,6 +365,17 @@
# can understand so he can file a bug later.
#
[ $compiler == dart2js ]
+LibTest/core/List/List.fixedLength_A01_t01: fail # Issue 400
+LibTest/core/List/addAll_A02_t01: fail # Issue 400
+LibTest/core/List/add_A02_t01: fail # Issue 400
+LibTest/core/List/clear_A02_t01: fail # Issue 400
+LibTest/core/List/insertRange_A02_t01: fail # Issue 400
+LibTest/core/List/length_A04_t01: fail # Issue 400
+LibTest/core/List/removeLast_A02_t01: fail # Issue 400
+LibTest/core/List/removeRange_A02_t01: fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t01: fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t02: fail # Issue 400
+
Language/11_Expressions/11_Instance_Creation/1_New_A01_t04: Fail, OK # co19 issue 241
Language/11_Expressions/22_Equality_A01_t01: Fail, OK # Function declaration takes precedence over function expression.
@@ -461,6 +468,14 @@
Language/11_Expressions/05_Strings/1_String_Interpolation_A03_t01: Fail # StringBuffer renamed add to write. co19 issue 388.
Language/11_Expressions/05_Strings/1_String_Interpolation_A04_t01: Fail # StringBuffer renamed add to write. co19 issue 388.
+Language/15_Reference/1_Lexical_Rules/2_Comments_A04_t03: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromMillisecondsSinceEpoch_A02_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromString_A04_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/add_A06_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/compareTo_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/difference_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/subtract_A06_t01: Fail # Uses deprecated Expect class, issue 398
+
LibTest/core/double/ceil_A01_t03: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/ceil_A01_t04: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/floor_A01_t03: Fail # truncate/ceil/floor/round returns ints, issue 389
@@ -470,8 +485,6 @@
LibTest/core/double/truncate_A01_t03: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/truncate_A01_t04: Fail # truncate/ceil/floor/round returns ints, issue 389
-LibTest/core/List/getRange_A02_t01: Fail # issue 391
-
Language/11_Expressions/05_Strings/1_String_Interpolation_A03_t02: Fail # Issue 397
Language/11_Expressions/05_Strings/1_String_Interpolation_A04_t02: Fail # Issue 397
Language/11_Expressions/11_Instance_Creation/1_New_A08_t01: Fail # Issue 397
@@ -482,12 +495,23 @@
LibTest/core/List/addLast_A01_t03: Fail # Issue 397
LibTest/core/List/addLast_A02_t01: Fail # Issue 397
+LibTest/core/List/getRange_A02_t01: Fail # issue 391, and Issue 399
+LibTest/core/List/getRange_A01_t01: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/getRange_A04_t01: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/operator_subscript_A01_t02: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+
# Issues with co19 test suite in checked mode.
[ $compiler == dart2js && $checked ]
LibTest/core/Set/intersection_A01_t01: Fail # issue 390
LibTest/core/Set/intersection_A01_t02: Fail # issue 390
LibTest/core/Set/intersection_A01_t03: Fail # issue 390
+LibTest/core/List/List.from_A01_t01: fail # Issue 400
+LibTest/core/List/every_A01_t01: fail # Issue 400
+LibTest/collection/Queue/Queue.from_A01_t01: Fail # Issue 400
+LibTest/collection/Queue/Queue.from_A01_t02: Fail # Issue 400
+
+
# Issues with co19 test suite in browsers.
[ $compiler == dart2js && $browser ]
@@ -546,6 +570,9 @@
Language/11_Expressions/22_Equality_A05_t01: Fail # != cannot be called on super
Language/11_Expressions/30_Identifier_Reference_A02_t01: Fail # Pseudo keyword "abstract".
+Language/12_Statements/06_For_A01_t11: Fail # http://dartbug.com/9824
+
+
[ $compiler == dart2js && $jscl ]
LibTest/core/Date/Date.fromString_A03_t01: Pass # Issue co19 - 121 (currently passing due to co19 issues 373 and 374)
LibTest/core/RegExp/Pattern_semantics/firstMatch_CharacterEscape_A06_t02: Fail # IllegalJSRegExpException: '\c(' 'SyntaxError: Invalid regular expression: /\c(/: Unterminated group'
@@ -556,6 +583,8 @@
Language/11_Expressions/06_Lists_A07_t02: Fail # generic type information is lost during canonicalization.
Language/11_Expressions/07_Maps_A06_t02: Fail # generic type information is lost during canonicalization.
+
+
#
# The following tests may be broken, but require further review.
#
diff --git a/tests/co19/co19-runtime.status b/tests/co19/co19-runtime.status
index c1845be..caf1431 100644
--- a/tests/co19/co19-runtime.status
+++ b/tests/co19/co19-runtime.status
@@ -2,11 +2,9 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-
[ $runtime == vm ]
Language/11_Expressions/33_Argument_Definition_Test_A02_t02: Crash, Pass # http://dartbug.com/9597
-
[ $compiler == none && $runtime == vm && $unchecked ]
Language/11_Expressions/11_Instance_Creation_A05_t02: Fail # TODO(vm-team): Please triage this failure.
@@ -188,6 +186,14 @@
LibTest/core/double/round_A01_t02: Fail # truncate/ceil/floor/round returns ints, issue 389
LibTest/core/double/round_A01_t04: Fail # truncate/ceil/floor/round returns ints, issue 389
+Language/15_Reference/1_Lexical_Rules/2_Comments_A04_t03: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromMillisecondsSinceEpoch_A02_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/Date.fromString_A04_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/add_A06_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/compareTo_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/difference_A03_t01: Fail # Uses deprecated Expect class, issue 398
+LibTest/core/Date/subtract_A06_t01: Fail # Uses deprecated Expect class, issue 398
+
LibTest/core/Date/operator_equality_A01_t01: Fail # DateTime.== now looks at timezone, co19 issue 379
Language/06_Functions/2_Formal_Parameters/2_Optional_Formals_A03_t03: Fail # issue 6085
@@ -308,6 +314,9 @@
Language/07_Classes/07_Classes_A02_t31: Fail
Language/11_Expressions/05_Strings_A20_t01: Fail
LibTest/isolate/ReceivePort/receive_A01_t02: Fail
+LibTest/isolate/isolate_api/spawnFunction_A02_t01: Fail
+LibTest/isolate/isolate_api/spawnUri_A02_t02: Fail
+LibTest/isolate/isolate_api/spawnUri_A02_t03: Fail
LibTest/core/StringBuffer/isEmpty_A01_t01: Fail, OK # co19 issue 355
@@ -395,8 +404,6 @@
Language/11_Expressions/05_Strings/1_String_Interpolation_A03_t01: Fail # StringBuffer renamed add to write. co19 issue 388.
Language/11_Expressions/05_Strings/1_String_Interpolation_A04_t01: Fail # StringBuffer renamed add to write. co19 issue 388.
-LibTest/core/List/getRange_A02_t01: Fail # issue 391
-
Language/11_Expressions/05_Strings/1_String_Interpolation_A03_t02: Fail # Issue 397
Language/11_Expressions/05_Strings/1_String_Interpolation_A04_t02: Fail # Issue 397
Language/11_Expressions/11_Instance_Creation/1_New_A08_t01: Fail # Issue 397
@@ -407,11 +414,32 @@
LibTest/core/List/addLast_A01_t03: Fail # Issue 397
LibTest/core/List/addLast_A02_t01: Fail # Issue 397
+LibTest/core/List/getRange_A02_t01: Fail # issue 391, and Issue 399
+LibTest/core/List/getRange_A01_t01: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/getRange_A04_t01: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/operator_subscript_A01_t02: Fail # getRange now takes end-argument and returns Iterable. Issue 399
+LibTest/core/List/List.fixedLength_A01_t01: fail # Issue 400
+LibTest/core/List/addAll_A02_t01: fail # Issue 400
+LibTest/core/List/add_A02_t01: fail # Issue 400
+LibTest/core/List/clear_A02_t01: fail # Issue 400
+LibTest/core/List/insertRange_A02_t01: fail # Issue 400
+LibTest/core/List/length_A04_t01: fail # Issue 400
+LibTest/core/List/removeLast_A02_t01: fail # Issue 400
+LibTest/core/List/removeRange_A02_t01: fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t01: fail # Issue 400
+LibTest/core/Set/isSubsetOf_A01_t02: fail # Issue 400
[ $compiler == none && $runtime == vm && $checked ]
LibTest/core/Set/intersection_A01_t01: Fail # issue 390
LibTest/core/Set/intersection_A01_t02: Fail # issue 390
LibTest/core/Set/intersection_A01_t03: Fail # issue 390
+LibTest/collection/Queue/Queue.from_A01_t01: fail # Issue 400
+LibTest/collection/Queue/Queue.from_A01_t02: fail # Issue 400
+LibTest/core/List/List.from_A01_t01: fail # Issue 400
+LibTest/core/List/every_A01_t01: fail # Issue 400
+LibTest/core/Match/pattern_A01_t01: fail # Issue 400
+LibTest/core/Match/str_A01_t01: fail # Issue 400
+LibTest/core/RegExp/allMatches_A01_t01: fail # Issue 400
[ $compiler == none && $arch == simarm ]
diff --git a/tests/compiler/dart2js/analyze_all_test.dart b/tests/compiler/dart2js/analyze_all_test.dart
index c972f82..439019d 100644
--- a/tests/compiler/dart2js/analyze_all_test.dart
+++ b/tests/compiler/dart2js/analyze_all_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String SOURCE = """
diff --git a/tests/compiler/dart2js/analyze_api_test.dart b/tests/compiler/dart2js/analyze_api_test.dart
index 7c086a5..3c92012 100644
--- a/tests/compiler/dart2js/analyze_api_test.dart
+++ b/tests/compiler/dart2js/analyze_api_test.dart
@@ -4,6 +4,7 @@
library analyze_api;
+import "package:expect/expect.dart";
import 'dart:uri';
import 'dart:io';
import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
diff --git a/tests/compiler/dart2js/analyze_only_test.dart b/tests/compiler/dart2js/analyze_only_test.dart
index ffbc7a5..394fe0d 100644
--- a/tests/compiler/dart2js/analyze_only_test.dart
+++ b/tests/compiler/dart2js/analyze_only_test.dart
@@ -5,6 +5,7 @@
// Smoke test of the dart2js compiler API.
library analyze_only;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:uri';
diff --git a/tests/compiler/dart2js/array_static_intercept_test.dart b/tests/compiler/dart2js/array_static_intercept_test.dart
index a5b343a..ca50ccf 100644
--- a/tests/compiler/dart2js/array_static_intercept_test.dart
+++ b/tests/compiler/dart2js/array_static_intercept_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/backend_htype_list_test.dart b/tests/compiler/dart2js/backend_htype_list_test.dart
index 93d37a4..7b44059 100644
--- a/tests/compiler/dart2js/backend_htype_list_test.dart
+++ b/tests/compiler/dart2js/backend_htype_list_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart';
import '../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart';
diff --git a/tests/compiler/dart2js/bad_loop_test.dart b/tests/compiler/dart2js/bad_loop_test.dart
new file mode 100644
index 0000000..aedbfc0
--- /dev/null
+++ b/tests/compiler/dart2js/bad_loop_test.dart
@@ -0,0 +1,66 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+import 'memory_source_file_helper.dart';
+
+import '../../../sdk/lib/_internal/compiler/compiler.dart'
+ show Diagnostic;
+
+main() {
+ Uri cwd = getCurrentDirectory();
+ Uri script = cwd.resolve(nativeToUriPath(new Options().script));
+ Uri libraryRoot = script.resolve('../../../sdk/');
+ Uri packageRoot = script.resolve('./packages/');
+
+ MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
+ var provider = new MemorySourceFileProvider();
+ int warningCount = 0;
+ int errorCount = 0;
+ void diagnosticHandler(Uri uri, int begin, int end,
+ String message, Diagnostic kind) {
+ if (kind == Diagnostic.VERBOSE_INFO) {
+ return;
+ }
+ if (kind == Diagnostic.ERROR) {
+ errorCount++;
+ } else if (kind == Diagnostic.WARNING) {
+ warningCount++;
+ } else {
+ throw 'unexpected diagnostic $kind: $message';
+ }
+ }
+
+ Compiler compiler = new Compiler(provider.readStringFromUri,
+ (name, extension) => null,
+ diagnosticHandler,
+ libraryRoot,
+ packageRoot,
+ ['--analyze-only']);
+ compiler.run(new Uri('memory:main.dart'));
+ Expect.isTrue(compiler.compilationFailed);
+ Expect.equals(5, errorCount);
+ Expect.equals(1, warningCount);
+}
+
+const Map MEMORY_SOURCE_FILES = const {
+ 'main.dart': """
+main() {
+ for (var x, y in []) {
+ }
+
+ for (var x = 10 in []) {
+ }
+
+ for (x.y in []) { // Also causes a warning "x unresolved".
+ }
+
+ for ((){}() in []) {
+ }
+
+ for (1 in []) {
+ }
+}
+"""
+};
diff --git a/tests/compiler/dart2js/begin_end_token_test.dart b/tests/compiler/dart2js/begin_end_token_test.dart
index b5af596..fe8c910 100644
--- a/tests/compiler/dart2js/begin_end_token_test.dart
+++ b/tests/compiler/dart2js/begin_end_token_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'parser_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
diff --git a/tests/compiler/dart2js/boolified_operator_test.dart b/tests/compiler/dart2js/boolified_operator_test.dart
index 1758146..5ec4c83 100644
--- a/tests/compiler/dart2js/boolified_operator_test.dart
+++ b/tests/compiler/dart2js/boolified_operator_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library boolified_operator_test;
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_EQUAL = r"""
diff --git a/tests/compiler/dart2js/boolify_test.dart b/tests/compiler/dart2js/boolify_test.dart
index a1db3bb..d029379 100644
--- a/tests/compiler/dart2js/boolify_test.dart
+++ b/tests/compiler/dart2js/boolify_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library boolified_operator_test;
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST = r"""
diff --git a/tests/compiler/dart2js/builtin_equals_test.dart b/tests/compiler/dart2js/builtin_equals_test.dart
index a2e7cda..3b1807a 100644
--- a/tests/compiler/dart2js/builtin_equals_test.dart
+++ b/tests/compiler/dart2js/builtin_equals_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST = r"""
diff --git a/tests/compiler/dart2js/builtin_interceptor_test.dart b/tests/compiler/dart2js/builtin_interceptor_test.dart
index 219da55..d26f97f 100644
--- a/tests/compiler/dart2js/builtin_interceptor_test.dart
+++ b/tests/compiler/dart2js/builtin_interceptor_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/call_site_simple_type_inferer_test.dart b/tests/compiler/dart2js/call_site_simple_type_inferer_test.dart
index 50be62e..b9c2b23 100644
--- a/tests/compiler/dart2js/call_site_simple_type_inferer_test.dart
+++ b/tests/compiler/dart2js/call_site_simple_type_inferer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
show TypeMask;
diff --git a/tests/compiler/dart2js/call_site_type_inferer_static_test.dart b/tests/compiler/dart2js/call_site_type_inferer_static_test.dart
index cd049c8..2081157 100644
--- a/tests/compiler/dart2js/call_site_type_inferer_static_test.dart
+++ b/tests/compiler/dart2js/call_site_type_inferer_static_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart";
import "../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart";
diff --git a/tests/compiler/dart2js/call_site_type_inferer_test.dart b/tests/compiler/dart2js/call_site_type_inferer_test.dart
index 483ff78..5587405 100644
--- a/tests/compiler/dart2js/call_site_type_inferer_test.dart
+++ b/tests/compiler/dart2js/call_site_type_inferer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart';
import '../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart';
diff --git a/tests/compiler/dart2js/class_codegen2_test.dart b/tests/compiler/dart2js/class_codegen2_test.dart
index 730a59a..99e329d 100644
--- a/tests/compiler/dart2js/class_codegen2_test.dart
+++ b/tests/compiler/dart2js/class_codegen2_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/class_codegen_test.dart b/tests/compiler/dart2js/class_codegen_test.dart
index 7a978ff..676682e 100644
--- a/tests/compiler/dart2js/class_codegen_test.dart
+++ b/tests/compiler/dart2js/class_codegen_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/class_order_test.dart b/tests/compiler/dart2js/class_order_test.dart
index fcdf17a..a4cc29e 100644
--- a/tests/compiler/dart2js/class_order_test.dart
+++ b/tests/compiler/dart2js/class_order_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/closure_codegen_test.dart b/tests/compiler/dart2js/closure_codegen_test.dart
index 944446b..b4399a8 100644
--- a/tests/compiler/dart2js/closure_codegen_test.dart
+++ b/tests/compiler/dart2js/closure_codegen_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/code_motion_test.dart b/tests/compiler/dart2js/code_motion_test.dart
index d14cc69..0259492 100644
--- a/tests/compiler/dart2js/code_motion_test.dart
+++ b/tests/compiler/dart2js/code_motion_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/compiler_helper.dart b/tests/compiler/dart2js/compiler_helper.dart
index c816160..fff3a5b 100644
--- a/tests/compiler/dart2js/compiler_helper.dart
+++ b/tests/compiler/dart2js/compiler_helper.dart
@@ -5,6 +5,7 @@
library compiler_helper;
+import "package:expect/expect.dart";
import 'dart:uri';
export 'dart:uri' show Uri;
@@ -77,9 +78,12 @@
MockCompiler compilerFor(String code, Uri uri,
{bool analyzeAll: false,
+ bool analyzeOnly: false,
String coreSource: DEFAULT_CORELIB}) {
MockCompiler compiler = new MockCompiler(
- analyzeAll: analyzeAll, coreSource: coreSource);
+ analyzeAll: analyzeAll,
+ analyzeOnly: analyzeOnly,
+ coreSource: coreSource);
compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code);
return compiler;
}
diff --git a/tests/compiler/dart2js/compiler_test.dart b/tests/compiler/dart2js/compiler_test.dart
index 642f7be..e9ba024 100644
--- a/tests/compiler/dart2js/compiler_test.dart
+++ b/tests/compiler/dart2js/compiler_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart";
import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution.dart";
diff --git a/tests/compiler/dart2js/concrete_type_inference_test.dart b/tests/compiler/dart2js/concrete_type_inference_test.dart
index b2a83d5..6a748c6 100644
--- a/tests/compiler/dart2js/concrete_type_inference_test.dart
+++ b/tests/compiler/dart2js/concrete_type_inference_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/constant_folding_test.dart b/tests/compiler/dart2js/constant_folding_test.dart
index 0721bbd..44f2e06 100644
--- a/tests/compiler/dart2js/constant_folding_test.dart
+++ b/tests/compiler/dart2js/constant_folding_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test constant folding on numbers.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String NUMBER_FOLDING = """
diff --git a/tests/compiler/dart2js/constant_namer_test.dart b/tests/compiler/dart2js/constant_namer_test.dart
index 0816c8b..dd78c63 100644
--- a/tests/compiler/dart2js/constant_namer_test.dart
+++ b/tests/compiler/dart2js/constant_namer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/cpa_inference_test.dart b/tests/compiler/dart2js/cpa_inference_test.dart
index 922bc50..98d743e 100644
--- a/tests/compiler/dart2js/cpa_inference_test.dart
+++ b/tests/compiler/dart2js/cpa_inference_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart';
import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart';
@@ -162,7 +163,7 @@
E operator [](int index);
void operator []=(int index, E value);
}
- abstract class Map {}
+ abstract class Map<K, V> {}
class Closure {}
class Null {}
class Type {}
@@ -1087,16 +1088,16 @@
// we don't create any D on purpose
new B(); new BB(); new C();
- var a = JS('', '');
- var b = JS('Object', '');
- var c = JS('=List', '');
- var d = JS('String', '');
- var e = JS('int', '');
- var f = JS('double', '');
- var g = JS('num', '');
- var h = JS('bool', '');
- var i = JS('A', '');
- var j = JS('X', '');
+ var a = JS('', '1');
+ var b = JS('Object', '1');
+ var c = JS('=List', '1');
+ var d = JS('String', '1');
+ var e = JS('int', '1');
+ var f = JS('double', '1');
+ var g = JS('num', '1');
+ var h = JS('bool', '1');
+ var i = JS('A', '1');
+ var j = JS('X', '1');
a; b; c; d; e; f; g; h; i; j;
}
""";
diff --git a/tests/compiler/dart2js/dart_backend_test.dart b/tests/compiler/dart2js/dart_backend_test.dart
index 23f830d..3a4c2fc 100644
--- a/tests/compiler/dart2js/dart_backend_test.dart
+++ b/tests/compiler/dart2js/dart_backend_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:uri';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/dead_bailout_target_test.dart b/tests/compiler/dart2js/dead_bailout_target_test.dart
index c4d55db..d482467 100644
--- a/tests/compiler/dart2js/dead_bailout_target_test.dart
+++ b/tests/compiler/dart2js/dead_bailout_target_test.dart
@@ -5,6 +5,7 @@
// This unit test of dart2js checks that a SSA bailout target
// instruction gets removed from the graph when it's not used.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
String TEST = r'''
diff --git a/tests/compiler/dart2js/dead_phi_eliminator_test.dart b/tests/compiler/dart2js/dead_phi_eliminator_test.dart
index 8ba3387..4551e34 100644
--- a/tests/compiler/dart2js/dead_phi_eliminator_test.dart
+++ b/tests/compiler/dart2js/dead_phi_eliminator_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/deferred_load_graph_segmentation_test.dart b/tests/compiler/dart2js/deferred_load_graph_segmentation_test.dart
index 61a1e65..20d6e90 100644
--- a/tests/compiler/dart2js/deferred_load_graph_segmentation_test.dart
+++ b/tests/compiler/dart2js/deferred_load_graph_segmentation_test.dart
@@ -6,46 +6,19 @@
// to determine which elements can be deferred and which libraries
// much be included in the initial download (loaded eagerly).
-import 'dart:async' show Future;
-import 'dart:uri' show Uri;
-import 'dart:io';
-
-import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart'
- show Compiler;
+import 'package:expect/expect.dart';
+import 'memory_source_file_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
as dart2js;
-import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'
- show getCurrentDirectory, nativeToUriPath;
-
-import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'
- show SourceFile;
-
-import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.dart'
- show FormattingDiagnosticHandler,
- SourceFileProvider;
-
-class MemorySourceFileProvider extends SourceFileProvider {
- Future<String> readStringFromUri(Uri resourceUri) {
- if (resourceUri.scheme != 'memory') {
- return super.readStringFromUri(resourceUri);
- }
- String source = MEMORY_SOURCE_FILES[resourceUri.path];
- // TODO(ahe): Return new Future.immediateError(...) ?
- if (source == null) throw 'No such file $resourceUri';
- String resourceName = '$resourceUri';
- this.sourceFiles[resourceName] = new SourceFile(resourceName, source);
- return new Future.immediate(source);
- }
-}
-
void main() {
Uri cwd = getCurrentDirectory();
Uri script = cwd.resolve(nativeToUriPath(new Options().script));
Uri libraryRoot = script.resolve('../../../sdk/');
Uri packageRoot = script.resolve('./packages/');
+ MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES;
var provider = new MemorySourceFileProvider();
var handler = new FormattingDiagnosticHandler(provider);
@@ -86,7 +59,7 @@
main() {
lazy.load().then((_) {
- Expect.equals(42, new MyClass().foo(87));
+ if (42 != new MyClass().foo(87)) throw "not equal";
});
}
diff --git a/tests/compiler/dart2js/deprecated_features_test.dart b/tests/compiler/dart2js/deprecated_features_test.dart
index b2aafa2..bb884bf 100644
--- a/tests/compiler/dart2js/deprecated_features_test.dart
+++ b/tests/compiler/dart2js/deprecated_features_test.dart
@@ -4,6 +4,7 @@
// Test that deprecated language features are diagnosed correctly.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:uri';
diff --git a/tests/compiler/dart2js/emit_const_fields_test.dart b/tests/compiler/dart2js/emit_const_fields_test.dart
index 290c50a..d539d89 100644
--- a/tests/compiler/dart2js/emit_const_fields_test.dart
+++ b/tests/compiler/dart2js/emit_const_fields_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that unused static consts are not emitted.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_GUIDE = r"""
diff --git a/tests/compiler/dart2js/erroneous_element_test.dart b/tests/compiler/dart2js/erroneous_element_test.dart
index 97078356..4a588e1 100644
--- a/tests/compiler/dart2js/erroneous_element_test.dart
+++ b/tests/compiler/dart2js/erroneous_element_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/field_codegen_test.dart b/tests/compiler/dart2js/field_codegen_test.dart
index 948b4cd..d9a8aec 100644
--- a/tests/compiler/dart2js/field_codegen_test.dart
+++ b/tests/compiler/dart2js/field_codegen_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/field_type_inferer_test.dart b/tests/compiler/dart2js/field_type_inferer_test.dart
index ee5cb28..901b06e 100644
--- a/tests/compiler/dart2js/field_type_inferer_test.dart
+++ b/tests/compiler/dart2js/field_type_inferer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart';
import '../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart';
import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart';
diff --git a/tests/compiler/dart2js/field_type_simple_inferer_test.dart b/tests/compiler/dart2js/field_type_simple_inferer_test.dart
index 47dc130..eae9261 100644
--- a/tests/compiler/dart2js/field_type_simple_inferer_test.dart
+++ b/tests/compiler/dart2js/field_type_simple_inferer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
show TypeMask;
diff --git a/tests/compiler/dart2js/find_my_name_test.dart b/tests/compiler/dart2js/find_my_name_test.dart
index 605524f..1c24d17 100644
--- a/tests/compiler/dart2js/find_my_name_test.dart
+++ b/tests/compiler/dart2js/find_my_name_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart";
import "mock_compiler.dart";
import "parser_helper.dart";
diff --git a/tests/compiler/dart2js/for_in_test.dart b/tests/compiler/dart2js/for_in_test.dart
index edf59b2..4ded809 100644
--- a/tests/compiler/dart2js/for_in_test.dart
+++ b/tests/compiler/dart2js/for_in_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/gvn_dynamic_field_get_test.dart b/tests/compiler/dart2js/gvn_dynamic_field_get_test.dart
index 9d42462..739645b 100644
--- a/tests/compiler/dart2js/gvn_dynamic_field_get_test.dart
+++ b/tests/compiler/dart2js/gvn_dynamic_field_get_test.dart
@@ -4,6 +4,7 @@
// Test that dart2js gvns dynamic getters that don't have side
// effects.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/identity_test.dart b/tests/compiler/dart2js/identity_test.dart
index 1e47d58..50c768b5 100644
--- a/tests/compiler/dart2js/identity_test.dart
+++ b/tests/compiler/dart2js/identity_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/interceptor_test.dart b/tests/compiler/dart2js/interceptor_test.dart
index cc965b1..5f7caa6 100644
--- a/tests/compiler/dart2js/interceptor_test.dart
+++ b/tests/compiler/dart2js/interceptor_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/interpolation_folding_test.dart b/tests/compiler/dart2js/interpolation_folding_test.dart
index 3734fd9..1cfc4af 100644
--- a/tests/compiler/dart2js/interpolation_folding_test.dart
+++ b/tests/compiler/dart2js/interpolation_folding_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
// Tests for
diff --git a/tests/compiler/dart2js/is_inference2_test.dart b/tests/compiler/dart2js/is_inference2_test.dart
index 36e39ba..2ce07d5 100644
--- a/tests/compiler/dart2js/is_inference2_test.dart
+++ b/tests/compiler/dart2js/is_inference2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_IF_BOOL_FIRST_INSTRUCTION = r"""
diff --git a/tests/compiler/dart2js/is_inference_test.dart b/tests/compiler/dart2js/is_inference_test.dart
index e282a86..7bb12fb 100644
--- a/tests/compiler/dart2js/is_inference_test.dart
+++ b/tests/compiler/dart2js/is_inference_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_IF = r"""
diff --git a/tests/compiler/dart2js/js_parser_test.dart b/tests/compiler/dart2js/js_parser_test.dart
index 3bd6559..0bfc6bc 100644
--- a/tests/compiler/dart2js/js_parser_test.dart
+++ b/tests/compiler/dart2js/js_parser_test.dart
@@ -2,12 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'mock_compiler.dart';
import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' as jsAst;
import '../../../sdk/lib/_internal/compiler/implementation/js/js.dart' show js;
void testExpression(String expression, [String expect = ""]) {
- jsAst.Node node = js[expression];
+ jsAst.Node node = js(expression);
MockCompiler compiler = new MockCompiler();
String jsText =
jsAst.prettyPrint(node,
@@ -25,7 +26,7 @@
Expect.isTrue(exception.toString().contains(expect));
return true;
}
- Expect.throws(() => js[expression], doCheck);
+ Expect.throws(() => js(expression), doCheck);
}
@@ -36,9 +37,14 @@
testExpression('var a = ""');
// Parse and print will normalize whitespace.
testExpression(' var a = "" ', 'var a = ""');
- // *We don't do operator prescedence.
- testError('x = a + b * c', 'Mixed + and *');
- // But we can chain binary operators (with left associativity).
+ // Operator precedence.
+ testExpression('x = a + b * c');
+ testExpression('x = a * b + c');
+ testExpression('x = a + b * c + d');
+ testExpression('x = a * b + c * d');
+ testExpression('remaining = (remaining / 88) | 0',
+ 'remaining = remaining / 88 | 0');
+ // Binary operators have left associativity.
testExpression('x = a + b + c');
// We can cope with relational operators and non-relational.
testExpression('a + b == c + d');
@@ -47,8 +53,13 @@
// We can handle () for calls.
testExpression('foo(bar)');
testExpression('foo(bar, baz)');
- // *But we can't handle chained calls without parentheses.
- testError('foo(bar)(baz)');
+ // Chained calls without parentheses.
+ testExpression('foo(bar)(baz)');
+ // Chaned calls with and without new.
+ testExpression('new foo(bar)(baz)');
+ testExpression('new foo.bar(bar)(baz)');
+ testExpression('foo.bar(bar)(baz)');
+ testExpression('constructor = new Function(str)()');
// The prettyprinter understands chained calls without extra parentheses.
testExpression('(foo(bar))(baz)', 'foo(bar)(baz)');
// Chains of dotting and calls.
@@ -65,6 +76,10 @@
testExpression('new Foo()');
// New with dotted access.
testExpression('new Frobinator.frobinate()');
+ // *We don't handle dot after 'new' because we group 'new' with regular calls
+ // instead of having it together with the dot operator but with opposite
+ // associativity.
+ testError('new Frobinator().frobinate()', "DOT");
// The prettyprinter is smarter than we are.
testExpression('(new Frobinator()).frobinate()',
'new Frobinator().frobinate()');
@@ -77,8 +92,8 @@
testError('a <=> b', 'Unknown operator');
// Typeof.
testExpression('typeof foo == "number"');
- // *Strange relation.
- testError('a < b < c', 'RELATION');
+ // Strange relation.
+ testExpression('a < b < c');
// Chained var.
testExpression('var x = 0, y = 1.2, z = 42');
// Empty object literal.
@@ -90,7 +105,8 @@
// *We should really throw here.
testExpression('var false = 42');
testExpression('var new = 42');
- testExpression('var typeof = 42');
+ // Bad keyword.
+ testError('var typeof = 42', "Expected ALPHA");
// Malformed decimal
testError('var x = 42.', "Unparseable number");
testError('var x = 1.1.1', "Unparseable number");
@@ -100,10 +116,15 @@
testExpression('var foo = void 0');
testExpression('delete foo.bar');
testExpression('delete foo');
+ testExpression('x in y');
+ testExpression('x instanceof y');
+ testExpression('a * b in c * d');
+ testExpression('a * b instanceof c * d');
testError('x typeof y', 'Unparsed junk');
testExpression('x &= ~mask');
// Adjacent tokens.
testExpression('foo[x[bar]]');
+ testExpression('foo[[bar]]');
// Prefix ++ etc.
testExpression("++x");
testExpression("++foo.bar");
@@ -123,9 +144,10 @@
testExpression("++foo.bar++");
testExpression("--x--");
testExpression("--foo.bar--");
- // *We can't handle stacked unary operators.
+ // *We can't handle stacked unary operators (apart from !).
testError("x++ ++");
testError("++ typeof x");
+ testExpression(r"var $supportsProtoName = !!{}.__proto__");
// ++ used as a binary operator.
testError("x++ ++ 42");
// Shift operators.
diff --git a/tests/compiler/dart2js/link_test.dart b/tests/compiler/dart2js/link_test.dart
index b050ee8..55d6ae3 100644
--- a/tests/compiler/dart2js/link_test.dart
+++ b/tests/compiler/dart2js/link_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart';
import '../../../sdk/lib/_internal/compiler/implementation/util/util_implementation.dart';
diff --git a/tests/compiler/dart2js/literal_list_test.dart b/tests/compiler/dart2js/literal_list_test.dart
index 105790e..efb146d 100644
--- a/tests/compiler/dart2js/literal_list_test.dart
+++ b/tests/compiler/dart2js/literal_list_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/literal_map_test.dart b/tests/compiler/dart2js/literal_map_test.dart
index 88be94d..0e30d4e 100644
--- a/tests/compiler/dart2js/literal_map_test.dart
+++ b/tests/compiler/dart2js/literal_map_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import "compiler_helper.dart";
const String TEST = """
diff --git a/tests/compiler/dart2js/loop_test.dart b/tests/compiler/dart2js/loop_test.dart
index 0412b10..9be7195 100644
--- a/tests/compiler/dart2js/loop_test.dart
+++ b/tests/compiler/dart2js/loop_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/memory_source_file_helper.dart b/tests/compiler/dart2js/memory_source_file_helper.dart
new file mode 100644
index 0000000..16cccf3
--- /dev/null
+++ b/tests/compiler/dart2js/memory_source_file_helper.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart2js.test.memory_source_file_helper;
+
+import 'dart:async' show Future;
+import 'dart:uri' show Uri;
+export 'dart:uri' show Uri;
+import 'dart:io';
+export 'dart:io' show Options;
+
+export '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart'
+ show Compiler;
+
+export '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'
+ show getCurrentDirectory, nativeToUriPath;
+
+import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'
+ show SourceFile;
+
+import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.dart'
+ show SourceFileProvider;
+
+export '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.dart'
+ show FormattingDiagnosticHandler;
+
+class MemorySourceFileProvider extends SourceFileProvider {
+ static Map MEMORY_SOURCE_FILES;
+ Future<String> readStringFromUri(Uri resourceUri) {
+ if (resourceUri.scheme != 'memory') {
+ return super.readStringFromUri(resourceUri);
+ }
+ String source = MEMORY_SOURCE_FILES[resourceUri.path];
+ // TODO(ahe): Return new Future.immediateError(...) ?
+ if (source == null) throw 'No such file $resourceUri';
+ String resourceName = '$resourceUri';
+ this.sourceFiles[resourceName] = new SourceFile(resourceName, source);
+ return new Future.immediate(source);
+ }
+}
diff --git a/tests/compiler/dart2js/metadata_test.dart b/tests/compiler/dart2js/metadata_test.dart
index c0a521c..c40d9a7 100644
--- a/tests/compiler/dart2js/metadata_test.dart
+++ b/tests/compiler/dart2js/metadata_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/minify_many_locals_test.dart b/tests/compiler/dart2js/minify_many_locals_test.dart
index dadd15c..5252816 100644
--- a/tests/compiler/dart2js/minify_many_locals_test.dart
+++ b/tests/compiler/dart2js/minify_many_locals_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
main() {
diff --git a/tests/compiler/dart2js/mirrors_metadata_test.dart b/tests/compiler/dart2js/mirrors_metadata_test.dart
index 7fd8589..5b42947 100644
--- a/tests/compiler/dart2js/mirrors_metadata_test.dart
+++ b/tests/compiler/dart2js/mirrors_metadata_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'dart:async';
import 'dart:io';
import 'dart:uri';
diff --git a/tests/compiler/dart2js/mirrors_test.dart b/tests/compiler/dart2js/mirrors_test.dart
index f32e36e..2c056ba 100644
--- a/tests/compiler/dart2js/mirrors_test.dart
+++ b/tests/compiler/dart2js/mirrors_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart';
import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart';
import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart';
diff --git a/tests/compiler/dart2js/mock_compiler.dart b/tests/compiler/dart2js/mock_compiler.dart
index f340a47..5a7952e 100644
--- a/tests/compiler/dart2js/mock_compiler.dart
+++ b/tests/compiler/dart2js/mock_compiler.dart
@@ -4,6 +4,7 @@
library mock_compiler;
+import "package:expect/expect.dart";
import 'dart:collection';
import 'dart:uri';
@@ -38,7 +39,7 @@
}
const String DEFAULT_HELPERLIB = r'''
- $throw(x) { return x; }
+ wrapException(x) { return x; }
iae(x) { throw x; } ioore(x) { throw x; }
guard$array(x) { return x; }
guard$num(x) { return x; }
@@ -235,7 +236,8 @@
}
void reportWarning(Node node, var message) {
- warnings.add(new WarningMessage(node, message.message));
+ if (message is! Message) message = message.message;
+ warnings.add(new WarningMessage(node, message));
}
void reportError(Node node, var message) {
@@ -243,7 +245,8 @@
// TODO(ahe): Fix the MockCompiler to not have this problem.
return;
}
- errors.add(new WarningMessage(node, message.message));
+ if (message is! Message) message = message.message;
+ errors.add(new WarningMessage(node, message));
}
void reportMessage(SourceSpan span, var message, api.Diagnostic kind) {
diff --git a/tests/compiler/dart2js/no_constructor_body_test.dart b/tests/compiler/dart2js/no_constructor_body_test.dart
index 4d25d01..0036e24 100644
--- a/tests/compiler/dart2js/no_constructor_body_test.dart
+++ b/tests/compiler/dart2js/no_constructor_body_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST = r"""
diff --git a/tests/compiler/dart2js/null_type_test.dart b/tests/compiler/dart2js/null_type_test.dart
index 0abc65f..a413027 100644
--- a/tests/compiler/dart2js/null_type_test.dart
+++ b/tests/compiler/dart2js/null_type_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/parser_helper.dart b/tests/compiler/dart2js/parser_helper.dart
index dd797ca..ec96f0e 100644
--- a/tests/compiler/dart2js/parser_helper.dart
+++ b/tests/compiler/dart2js/parser_helper.dart
@@ -4,6 +4,7 @@
library parser_helper;
+import "package:expect/expect.dart";
import "dart:uri";
import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart";
diff --git a/tests/compiler/dart2js/parser_test.dart b/tests/compiler/dart2js/parser_test.dart
index bb78175..d70fcb4 100644
--- a/tests/compiler/dart2js/parser_test.dart
+++ b/tests/compiler/dart2js/parser_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'parser_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
diff --git a/tests/compiler/dart2js/part_of_test.dart b/tests/compiler/dart2js/part_of_test.dart
index d80b8dc..aec3c73 100644
--- a/tests/compiler/dart2js/part_of_test.dart
+++ b/tests/compiler/dart2js/part_of_test.dart
@@ -4,6 +4,7 @@
library part_of_test;
+import "package:expect/expect.dart";
import 'dart:uri';
import 'mock_compiler.dart';
import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
diff --git a/tests/compiler/dart2js/partial_parser_test.dart b/tests/compiler/dart2js/partial_parser_test.dart
index 0539dfd..120b6a6 100644
--- a/tests/compiler/dart2js/partial_parser_test.dart
+++ b/tests/compiler/dart2js/partial_parser_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'parser_helper.dart';
void main() {
diff --git a/tests/compiler/dart2js/patch_test.dart b/tests/compiler/dart2js/patch_test.dart
index 529c716..42bfc60 100644
--- a/tests/compiler/dart2js/patch_test.dart
+++ b/tests/compiler/dart2js/patch_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart";
import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart";
diff --git a/tests/compiler/dart2js/pretty_parameter_test.dart b/tests/compiler/dart2js/pretty_parameter_test.dart
index 28c8d1f..ffd8cd4 100644
--- a/tests/compiler/dart2js/pretty_parameter_test.dart
+++ b/tests/compiler/dart2js/pretty_parameter_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Test that parameters keep their names in the output.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String FOO = r"""
diff --git a/tests/compiler/dart2js/redundant_phi_eliminator_test.dart b/tests/compiler/dart2js/redundant_phi_eliminator_test.dart
index 63d8b8b..de35f7e 100644
--- a/tests/compiler/dart2js/redundant_phi_eliminator_test.dart
+++ b/tests/compiler/dart2js/redundant_phi_eliminator_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/reexport_handled_test.dart b/tests/compiler/dart2js/reexport_handled_test.dart
index 766d1a7..8a1ca82 100644
--- a/tests/compiler/dart2js/reexport_handled_test.dart
+++ b/tests/compiler/dart2js/reexport_handled_test.dart
@@ -4,6 +4,7 @@
library reexport_handled_test;
+import "package:expect/expect.dart";
import 'dart:uri';
import 'mock_compiler.dart';
import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart'
diff --git a/tests/compiler/dart2js/resolution_test.dart b/tests/compiler/dart2js/resolution_test.dart
index cd588bd..9382159 100644
--- a/tests/compiler/dart2js/resolution_test.dart
+++ b/tests/compiler/dart2js/resolution_test.dart
@@ -5,6 +5,7 @@
// Test that resolution does not resolve things we know will not be
// needed by the backend.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index e1cbda1..01e0205 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:collection';
import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution.dart";
diff --git a/tests/compiler/dart2js/return_type_inferer_test.dart b/tests/compiler/dart2js/return_type_inferer_test.dart
index ae7ce7e..7f50c98 100644
--- a/tests/compiler/dart2js/return_type_inferer_test.dart
+++ b/tests/compiler/dart2js/return_type_inferer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart';
import 'compiler_helper.dart';
diff --git a/tests/compiler/dart2js/scanner_offset_length_test.dart b/tests/compiler/dart2js/scanner_offset_length_test.dart
index bf22baf..6f8db24 100644
--- a/tests/compiler/dart2js/scanner_offset_length_test.dart
+++ b/tests/compiler/dart2js/scanner_offset_length_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart';
import '../../../sdk/lib/_internal/compiler/implementation/scanner/scanner_implementation.dart';
diff --git a/tests/compiler/dart2js/scanner_test.dart b/tests/compiler/dart2js/scanner_test.dart
index 72401f2..28c01b0 100644
--- a/tests/compiler/dart2js/scanner_test.dart
+++ b/tests/compiler/dart2js/scanner_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:utf';
import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart';
import '../../../sdk/lib/_internal/compiler/implementation/scanner/scanner_implementation.dart';
diff --git a/tests/compiler/dart2js/simple_inferrer_and_or_test.dart b/tests/compiler/dart2js/simple_inferrer_and_or_test.dart
index 8b34146..ae7cfd3 100644
--- a/tests/compiler/dart2js/simple_inferrer_and_or_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_and_or_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
const String TEST = """
diff --git a/tests/compiler/dart2js/simple_inferrer_closure_test.dart b/tests/compiler/dart2js/simple_inferrer_closure_test.dart
index c3f9a9a..c54bdce 100644
--- a/tests/compiler/dart2js/simple_inferrer_closure_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_closure_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
const String TEST = """
diff --git a/tests/compiler/dart2js/simple_inferrer_final_field2_test.dart b/tests/compiler/dart2js/simple_inferrer_final_field2_test.dart
index 92e80e49..e563e16 100644
--- a/tests/compiler/dart2js/simple_inferrer_final_field2_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_final_field2_test.dart
@@ -5,6 +5,7 @@
// Test that a non-used generative constructor does not prevent
// infering types for fields.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/simple_inferrer_final_field3_test.dart b/tests/compiler/dart2js/simple_inferrer_final_field3_test.dart
index de30794..6853374 100644
--- a/tests/compiler/dart2js/simple_inferrer_final_field3_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_final_field3_test.dart
@@ -4,6 +4,7 @@
// Test that we are analyzing field parameters correctly.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/simple_inferrer_final_field_test.dart b/tests/compiler/dart2js/simple_inferrer_final_field_test.dart
index b525e3f..d3b6107 100644
--- a/tests/compiler/dart2js/simple_inferrer_final_field_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_final_field_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/simple_inferrer_postfix_prefix_test.dart b/tests/compiler/dart2js/simple_inferrer_postfix_prefix_test.dart
index 6e029f6..4a15908 100644
--- a/tests/compiler/dart2js/simple_inferrer_postfix_prefix_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_postfix_prefix_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
import 'parser_helper.dart';
diff --git a/tests/compiler/dart2js/simple_inferrer_test.dart b/tests/compiler/dart2js/simple_inferrer_test.dart
index 3e1e86f..35efedb 100644
--- a/tests/compiler/dart2js/simple_inferrer_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import
'../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
show TypeMask;
diff --git a/tests/compiler/dart2js/simple_inferrer_try_catch_test.dart b/tests/compiler/dart2js/simple_inferrer_try_catch_test.dart
index 3370dbe..257bdd3 100644
--- a/tests/compiler/dart2js/simple_inferrer_try_catch_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_try_catch_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
show TypeMask;
diff --git a/tests/compiler/dart2js/size_test.dart b/tests/compiler/dart2js/size_test.dart
index 9b39765..ccf0556 100644
--- a/tests/compiler/dart2js/size_test.dart
+++ b/tests/compiler/dart2js/size_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import "compiler_helper.dart";
const String TEST = "main() => [];";
diff --git a/tests/compiler/dart2js/source_mapping_test.dart b/tests/compiler/dart2js/source_mapping_test.dart
index fea3363..043665f 100644
--- a/tests/compiler/dart2js/source_mapping_test.dart
+++ b/tests/compiler/dart2js/source_mapping_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:uri';
import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
diff --git a/tests/compiler/dart2js/static_closure_test.dart b/tests/compiler/dart2js/static_closure_test.dart
index 75a412e..cbb53e1 100644
--- a/tests/compiler/dart2js/static_closure_test.dart
+++ b/tests/compiler/dart2js/static_closure_test.dart
@@ -4,6 +4,7 @@
// Test that static functions are closurized as expected.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
main() {
diff --git a/tests/compiler/dart2js/string_escapes_test.dart b/tests/compiler/dart2js/string_escapes_test.dart
index d62dbf6..d47f7f1 100644
--- a/tests/compiler/dart2js/string_escapes_test.dart
+++ b/tests/compiler/dart2js/string_escapes_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
// Test that the compiler handles string literals containing line terminators.
diff --git a/tests/compiler/dart2js/string_interpolation_test.dart b/tests/compiler/dart2js/string_interpolation_test.dart
index 1fa3a33..f6e3bca 100644
--- a/tests/compiler/dart2js/string_interpolation_test.dart
+++ b/tests/compiler/dart2js/string_interpolation_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
main() {
diff --git a/tests/compiler/dart2js/strip_comment_test.dart b/tests/compiler/dart2js/strip_comment_test.dart
index c233ba8..3808ad8 100644
--- a/tests/compiler/dart2js/strip_comment_test.dart
+++ b/tests/compiler/dart2js/strip_comment_test.dart
@@ -4,6 +4,7 @@
library strip_comment_test;
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart';
testComment(String strippedText, String commentText) {
diff --git a/tests/compiler/dart2js/subtype_test.dart b/tests/compiler/dart2js/subtype_test.dart
index 11534ce..db53398 100644
--- a/tests/compiler/dart2js/subtype_test.dart
+++ b/tests/compiler/dart2js/subtype_test.dart
@@ -4,6 +4,7 @@
library subtype_test;
+import 'package:expect/expect.dart';
import 'type_test_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart"
@@ -18,6 +19,7 @@
testTypedefSubtypingOptional();
testFunctionSubtypingNamed();
testTypedefSubtypingNamed();
+ testTypeVariableSubtype();
}
void testInterfaceSubtype() {
@@ -492,3 +494,220 @@
// Test ({int a,int b,int c})->void <: ({int c})->void.
expect(true, 'void___a_int_b_int_c_int', 'void___c_int');
}
+
+void testTypeVariableSubtype() {
+ var env = new TypeEnvironment(r"""
+ class A<T> {}
+ class B<T extends Object> {}
+ class C<T extends num> {}
+ class D<T extends int> {}
+ class E<T extends S, S extends num> {}
+ class F<T extends num, S extends T> {}
+ class G<T extends T> {}
+ class H<T extends S, S extends T> {}
+ class I<T extends S, S extends U, U extends T> {}
+ class J<T extends S, S extends U, U extends S> {}
+ """);
+
+ void expect(bool value, DartType T, DartType S) {
+ Expect.equals(value, env.isSubtype(T, S), '$T <: $S');
+ }
+
+ ClassElement A = env.getElement('A');
+ TypeVariableType A_T = A.thisType.typeArguments.head;
+ ClassElement B = env.getElement('B');
+ TypeVariableType B_T = B.thisType.typeArguments.head;
+ ClassElement C = env.getElement('C');
+ TypeVariableType C_T = C.thisType.typeArguments.head;
+ ClassElement D = env.getElement('D');
+ TypeVariableType D_T = D.thisType.typeArguments.head;
+ ClassElement E = env.getElement('E');
+ TypeVariableType E_T = E.thisType.typeArguments.head;
+ TypeVariableType E_S = E.thisType.typeArguments.tail.head;
+ ClassElement F = env.getElement('F');
+ TypeVariableType F_T = F.thisType.typeArguments.head;
+ TypeVariableType F_S = F.thisType.typeArguments.tail.head;
+ ClassElement G = env.getElement('G');
+ TypeVariableType G_T = G.thisType.typeArguments.head;
+ ClassElement H = env.getElement('H');
+ TypeVariableType H_T = H.thisType.typeArguments.head;
+ TypeVariableType H_S = H.thisType.typeArguments.tail.head;
+ ClassElement I = env.getElement('I');
+ TypeVariableType I_T = I.thisType.typeArguments.head;
+ TypeVariableType I_S = I.thisType.typeArguments.tail.head;
+ TypeVariableType I_U = I.thisType.typeArguments.tail.tail.head;
+ ClassElement J = env.getElement('J');
+ TypeVariableType J_T = J.thisType.typeArguments.head;
+ TypeVariableType J_S = J.thisType.typeArguments.tail.head;
+ TypeVariableType J_U = J.thisType.typeArguments.tail.tail.head;
+
+ DartType Object_ = env['Object'];
+ DartType num_ = env['num'];
+ DartType int_ = env['int'];
+ DartType String_ = env['String'];
+ DartType dynamic_ = env['dynamic'];
+
+ // class A<T> {}
+ expect(true, A_T, Object_);
+ expect(false, A_T, num_);
+ expect(false, A_T, int_);
+ expect(false, A_T, String_);
+ expect(true, A_T, dynamic_);
+ expect(true, A_T, A_T);
+ expect(false, A_T, B_T);
+
+ // class B<T extends Object> {}
+ expect(true, B_T, Object_);
+ expect(false, B_T, num_);
+ expect(false, B_T, int_);
+ expect(false, B_T, String_);
+ expect(true, B_T, dynamic_);
+ expect(true, B_T, B_T);
+ expect(false, B_T, A_T);
+
+ // class C<T extends num> {}
+ expect(true, C_T, Object_);
+ expect(true, C_T, num_);
+ expect(false, C_T, int_);
+ expect(false, C_T, String_);
+ expect(true, C_T, dynamic_);
+ expect(true, C_T, C_T);
+ expect(false, C_T, A_T);
+
+ // class D<T extends int> {}
+ expect(true, D_T, Object_);
+ expect(true, D_T, num_);
+ expect(true, D_T, int_);
+ expect(false, D_T, String_);
+ expect(true, D_T, dynamic_);
+ expect(true, D_T, D_T);
+ expect(false, D_T, A_T);
+
+ // class E<T extends S, S extends num> {}
+ expect(true, E_T, Object_);
+ expect(true, E_T, num_);
+ expect(false, E_T, int_);
+ expect(false, E_T, String_);
+ expect(true, E_T, dynamic_);
+ expect(true, E_T, E_T);
+ expect(true, E_T, E_S);
+ expect(false, E_T, A_T);
+
+ expect(true, E_S, Object_);
+ expect(true, E_S, num_);
+ expect(false, E_S, int_);
+ expect(false, E_S, String_);
+ expect(true, E_S, dynamic_);
+ expect(false, E_S, E_T);
+ expect(true, E_S, E_S);
+ expect(false, E_S, A_T);
+
+ // class F<T extends num, S extends T> {}
+ expect(true, F_T, Object_);
+ expect(true, F_T, num_);
+ expect(false, F_T, int_);
+ expect(false, F_T, String_);
+ expect(true, F_T, dynamic_);
+ expect(false, F_T, F_S);
+ expect(true, F_T, F_T);
+ expect(false, F_T, A_T);
+
+ expect(true, F_S, Object_);
+ expect(true, F_S, num_);
+ expect(false, F_S, int_);
+ expect(false, F_S, String_);
+ expect(true, F_S, dynamic_);
+ expect(true, F_S, F_S);
+ expect(true, F_S, F_T);
+ expect(false, F_S, A_T);
+
+ // class G<T extends T> {}
+ expect(true, G_T, Object_);
+ expect(false, G_T, num_);
+ expect(false, G_T, int_);
+ expect(false, G_T, String_);
+ expect(true, G_T, dynamic_);
+ expect(true, G_T, G_T);
+ expect(false, G_T, A_T);
+
+ // class H<T extends S, S extends T> {}
+ expect(true, H_T, Object_);
+ expect(false, H_T, num_);
+ expect(false, H_T, int_);
+ expect(false, H_T, String_);
+ expect(true, H_T, dynamic_);
+ expect(true, H_T, H_T);
+ expect(true, H_T, H_S);
+ expect(false, H_T, A_T);
+
+ expect(true, H_S, Object_);
+ expect(false, H_S, num_);
+ expect(false, H_S, int_);
+ expect(false, H_S, String_);
+ expect(true, H_S, dynamic_);
+ expect(true, H_S, H_T);
+ expect(true, H_S, H_S);
+ expect(false, H_S, A_T);
+
+ // class I<T extends S, S extends U, U extends T> {}
+ expect(true, I_T, Object_);
+ expect(false, I_T, num_);
+ expect(false, I_T, int_);
+ expect(false, I_T, String_);
+ expect(true, I_T, dynamic_);
+ expect(true, I_T, I_T);
+ expect(true, I_T, I_S);
+ expect(true, I_T, I_U);
+ expect(false, I_T, A_T);
+
+ expect(true, I_S, Object_);
+ expect(false, I_S, num_);
+ expect(false, I_S, int_);
+ expect(false, I_S, String_);
+ expect(true, I_S, dynamic_);
+ expect(true, I_S, I_T);
+ expect(true, I_S, I_S);
+ expect(true, I_S, I_U);
+ expect(false, I_S, A_T);
+
+ expect(true, I_U, Object_);
+ expect(false, I_U, num_);
+ expect(false, I_U, int_);
+ expect(false, I_U, String_);
+ expect(true, I_U, dynamic_);
+ expect(true, I_U, I_T);
+ expect(true, I_U, I_S);
+ expect(true, I_U, I_U);
+ expect(false, I_U, A_T);
+
+ // class J<T extends S, S extends U, U extends S> {}
+ expect(true, J_T, Object_);
+ expect(false, J_T, num_);
+ expect(false, J_T, int_);
+ expect(false, J_T, String_);
+ expect(true, J_T, dynamic_);
+ expect(true, J_T, J_T);
+ expect(true, J_T, J_S);
+ expect(true, J_T, J_U);
+ expect(false, J_T, A_T);
+
+ expect(true, J_S, Object_);
+ expect(false, J_S, num_);
+ expect(false, J_S, int_);
+ expect(false, J_S, String_);
+ expect(true, J_S, dynamic_);
+ expect(false, J_S, J_T);
+ expect(true, J_S, J_S);
+ expect(true, J_S, J_U);
+ expect(false, J_S, A_T);
+
+ expect(true, J_U, Object_);
+ expect(false, J_U, num_);
+ expect(false, J_U, int_);
+ expect(false, J_U, String_);
+ expect(true, J_U, dynamic_);
+ expect(false, J_U, J_T);
+ expect(true, J_U, J_S);
+ expect(true, J_U, J_U);
+ expect(false, J_U, A_T);
+}
\ No newline at end of file
diff --git a/tests/compiler/dart2js/tag_mapping_test.dart b/tests/compiler/dart2js/tag_mapping_test.dart
index c9b5a82..a669a20 100644
--- a/tests/compiler/dart2js/tag_mapping_test.dart
+++ b/tests/compiler/dart2js/tag_mapping_test.dart
@@ -4,6 +4,7 @@
// Test of import tag to library mapping.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
const MAIN_CODE = """
diff --git a/tests/compiler/dart2js/tree_shaking_test.dart b/tests/compiler/dart2js/tree_shaking_test.dart
index 1517258..5158015 100644
--- a/tests/compiler/dart2js/tree_shaking_test.dart
+++ b/tests/compiler/dart2js/tree_shaking_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST = r"""
diff --git a/tests/compiler/dart2js/type_checker_test.dart b/tests/compiler/dart2js/type_checker_test.dart
index b6200eb..855a865 100644
--- a/tests/compiler/dart2js/type_checker_test.dart
+++ b/tests/compiler/dart2js/type_checker_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart';
import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart';
diff --git a/tests/compiler/dart2js/type_combination_test.dart b/tests/compiler/dart2js/type_combination_test.dart
index 246a7fa..8a23071 100644
--- a/tests/compiler/dart2js/type_combination_test.dart
+++ b/tests/compiler/dart2js/type_combination_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "compiler_helper.dart";
import "parser_helper.dart";
import "../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart";
diff --git a/tests/compiler/dart2js/type_equals_test.dart b/tests/compiler/dart2js/type_equals_test.dart
index 4da86a6..adf43c0 100644
--- a/tests/compiler/dart2js/type_equals_test.dart
+++ b/tests/compiler/dart2js/type_equals_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
import "compiler_helper.dart";
import "parser_helper.dart";
@@ -84,7 +85,8 @@
void main() {}
""",
- uri);
+ uri,
+ analyzeAll: true, analyzeOnly: true);
compiler.runCompiler(uri);
test(compiler, "void1", "void2", expect: true);
diff --git a/tests/compiler/dart2js/type_guard_unuser_test.dart b/tests/compiler/dart2js/type_guard_unuser_test.dart
index c4922ab..d26d8c6 100644
--- a/tests/compiler/dart2js/type_guard_unuser_test.dart
+++ b/tests/compiler/dart2js/type_guard_unuser_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/type_inference3_test.dart b/tests/compiler/dart2js/type_inference3_test.dart
index 0cec9cd..e3fcf5a 100644
--- a/tests/compiler/dart2js/type_inference3_test.dart
+++ b/tests/compiler/dart2js/type_inference3_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/type_inference4_test.dart b/tests/compiler/dart2js/type_inference4_test.dart
index 2ef4404..92e51d1 100644
--- a/tests/compiler/dart2js/type_inference4_test.dart
+++ b/tests/compiler/dart2js/type_inference4_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/type_inference5_test.dart b/tests/compiler/dart2js/type_inference5_test.dart
index 1d9af41..647ea7d 100644
--- a/tests/compiler/dart2js/type_inference5_test.dart
+++ b/tests/compiler/dart2js/type_inference5_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/type_inference_test.dart b/tests/compiler/dart2js/type_inference_test.dart
index 4ab87ad..cf3f59f 100644
--- a/tests/compiler/dart2js/type_inference_test.dart
+++ b/tests/compiler/dart2js/type_inference_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const String TEST_ONE = r"""
diff --git a/tests/compiler/dart2js/type_representation_test.dart b/tests/compiler/dart2js/type_representation_test.dart
index 2edf644..132d3a7 100644
--- a/tests/compiler/dart2js/type_representation_test.dart
+++ b/tests/compiler/dart2js/type_representation_test.dart
@@ -4,6 +4,7 @@
library subtype_test;
+import 'package:expect/expect.dart';
import 'type_test_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart'
diff --git a/tests/compiler/dart2js/type_substitution_test.dart b/tests/compiler/dart2js/type_substitution_test.dart
index e54b628..7f2d9df 100644
--- a/tests/compiler/dart2js/type_substitution_test.dart
+++ b/tests/compiler/dart2js/type_substitution_test.dart
@@ -4,6 +4,7 @@
library type_substitution_test;
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
import "compiler_helper.dart";
import "parser_helper.dart";
diff --git a/tests/compiler/dart2js/type_test_helper.dart b/tests/compiler/dart2js/type_test_helper.dart
index 586af02..c253aa9 100644
--- a/tests/compiler/dart2js/type_test_helper.dart
+++ b/tests/compiler/dart2js/type_test_helper.dart
@@ -4,6 +4,7 @@
library type_test_helper;
+import "package:expect/expect.dart";
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
import "parser_helper.dart" show SourceString;
import "compiler_helper.dart";
@@ -26,7 +27,9 @@
MockCompiler compiler = compilerFor('''
main() {}
$source''',
- uri);
+ uri,
+ analyzeAll: true,
+ analyzeOnly: true);
compiler.runCompiler(uri);
return new TypeEnvironment._(compiler);
}
diff --git a/tests/compiler/dart2js/type_variable_bound_test.dart b/tests/compiler/dart2js/type_variable_bound_test.dart
new file mode 100644
index 0000000..6dd38a8
--- /dev/null
+++ b/tests/compiler/dart2js/type_variable_bound_test.dart
@@ -0,0 +1,116 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'compiler_helper.dart';
+import "package:expect/expect.dart";
+
+compile(String source) {
+ Uri uri = new Uri('test:code');
+ var compiler = compilerFor(source, uri);
+ compiler.runCompiler(uri);
+ return compiler;
+}
+
+test1() {
+ var compiler = compile(r"""
+class A<T extends T> {}
+
+void main() {
+ new A();
+}
+""");
+
+ Expect.isFalse(compiler.compilationFailed);
+ Expect.isTrue(compiler.errors.isEmpty,
+ 'unexpected errors: ${compiler.errors}');
+ Expect.equals(1, compiler.warnings.length,
+ 'expected exactly one warning, but got ${compiler.warnings}');
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[0].message.kind);
+ Expect.equals("T", compiler.warnings[0].node.toString());
+}
+
+test2() {
+ var compiler = compile(r"""
+class B<T extends S, S extends T> {}
+
+void main() {
+ new B();
+}
+""");
+
+ Expect.isFalse(compiler.compilationFailed);
+ print(compiler.errors);
+ Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors');
+ Expect.equals(2, compiler.warnings.length,
+ 'expected exactly one error, but got ${compiler.warnings}');
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[0].message.kind);
+ Expect.equals("T", compiler.warnings[0].node.toString());
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[1].message.kind);
+ Expect.equals("S", compiler.warnings[1].node.toString());
+}
+
+test3() {
+ var compiler = compile(r"""
+class C<T extends S, S extends U, U extends T> {}
+
+void main() {
+ new C();
+}
+""");
+
+ Expect.isFalse(compiler.compilationFailed);
+ print(compiler.errors);
+ Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors');
+ Expect.equals(3, compiler.warnings.length,
+ 'expected exactly one error, but got ${compiler.warnings}');
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[0].message.kind);
+ Expect.equals("T", compiler.warnings[0].node.toString());
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[1].message.kind);
+ Expect.equals("S", compiler.warnings[1].node.toString());
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[2].message.kind);
+ Expect.equals("U", compiler.warnings[2].node.toString());
+}
+
+test4() {
+ var compiler = compile(r"""
+class D<T extends S, S extends U, U extends S> {}
+
+void main() {
+ new D();
+}
+""");
+
+ Expect.isFalse(compiler.compilationFailed);
+ print(compiler.errors);
+ Expect.isTrue(compiler.errors.isEmpty, 'unexpected errors');
+ Expect.equals(2, compiler.warnings.length,
+ 'expected exactly one error, but got ${compiler.warnings}');
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[0].message.kind);
+ Expect.equals("S", compiler.warnings[0].node.toString());
+
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE,
+ compiler.warnings[1].message.kind);
+ Expect.equals("U", compiler.warnings[1].node.toString());
+}
+
+main() {
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/tests/compiler/dart2js/type_variable_occurrence_test.dart b/tests/compiler/dart2js/type_variable_occurrence_test.dart
index 51f6282..c9a28b9 100644
--- a/tests/compiler/dart2js/type_variable_occurrence_test.dart
+++ b/tests/compiler/dart2js/type_variable_occurrence_test.dart
@@ -4,6 +4,7 @@
library subtype_test;
+import 'package:expect/expect.dart';
import 'type_test_helper.dart';
import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dart"
diff --git a/tests/compiler/dart2js/types_of_captured_variables_test.dart b/tests/compiler/dart2js/types_of_captured_variables_test.dart
index 77c9e25..3376b65 100644
--- a/tests/compiler/dart2js/types_of_captured_variables_test.dart
+++ b/tests/compiler/dart2js/types_of_captured_variables_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'compiler_helper.dart';
const String TEST1 = r"""
diff --git a/tests/compiler/dart2js/unparser2_test.dart b/tests/compiler/dart2js/unparser2_test.dart
index 78bb05f..e2eb006 100644
--- a/tests/compiler/dart2js/unparser2_test.dart
+++ b/tests/compiler/dart2js/unparser2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.dart";
import "../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart";
diff --git a/tests/compiler/dart2js/unparser_test.dart b/tests/compiler/dart2js/unparser_test.dart
index a6bb634..936b60e 100644
--- a/tests/compiler/dart2js/unparser_test.dart
+++ b/tests/compiler/dart2js/unparser_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:uri';
import 'parser_helper.dart';
import 'mock_compiler.dart';
diff --git a/tests/compiler/dart2js/uri_extras_test.dart b/tests/compiler/dart2js/uri_extras_test.dart
index ed20990..0d224bc0 100644
--- a/tests/compiler/dart2js/uri_extras_test.dart
+++ b/tests/compiler/dart2js/uri_extras_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:uri';
import '../../../sdk/lib/_internal/compiler/implementation/util/uri_extras.dart';
diff --git a/tests/compiler/dart2js/value_range2_test.dart b/tests/compiler/dart2js/value_range2_test.dart
index 1c24f97..7b8cc8b 100644
--- a/tests/compiler/dart2js/value_range2_test.dart
+++ b/tests/compiler/dart2js/value_range2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart";
import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
import "../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart";
diff --git a/tests/compiler/dart2js/value_range_test.dart b/tests/compiler/dart2js/value_range_test.dart
index 1f03e88..5913d94 100644
--- a/tests/compiler/dart2js/value_range_test.dart
+++ b/tests/compiler/dart2js/value_range_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'compiler_helper.dart';
const int REMOVED = 0;
diff --git a/tests/compiler/dart2js_extra/bailout_aborting_if_test.dart b/tests/compiler/dart2js_extra/bailout_aborting_if_test.dart
index 5eac791..9020f26 100644
--- a/tests/compiler/dart2js_extra/bailout_aborting_if_test.dart
+++ b/tests/compiler/dart2js_extra/bailout_aborting_if_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
bar() => {'bar' : 21};
foo() => 'bar';
diff --git a/tests/compiler/dart2js_extra/bailout_on_break_test.dart b/tests/compiler/dart2js_extra/bailout_on_break_test.dart
index d73f935..ff09790 100644
--- a/tests/compiler/dart2js_extra/bailout_on_break_test.dart
+++ b/tests/compiler/dart2js_extra/bailout_on_break_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
operator+(arg) => 42;
}
diff --git a/tests/compiler/dart2js_extra/bailout_on_continue_test.dart b/tests/compiler/dart2js_extra/bailout_on_continue_test.dart
index 917f353..ca0377a 100644
--- a/tests/compiler/dart2js_extra/bailout_on_continue_test.dart
+++ b/tests/compiler/dart2js_extra/bailout_on_continue_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
operator+(arg) => 42;
}
diff --git a/tests/compiler/dart2js_extra/bailout_test.dart b/tests/compiler/dart2js_extra/bailout_test.dart
index cbc42ae..52b02a1 100644
--- a/tests/compiler/dart2js_extra/bailout_test.dart
+++ b/tests/compiler/dart2js_extra/bailout_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var myString;
String ifBailout(test) {
diff --git a/tests/compiler/dart2js_extra/break_test.dart b/tests/compiler/dart2js_extra/break_test.dart
index 34895a1..96b0481 100644
--- a/tests/compiler/dart2js_extra/break_test.dart
+++ b/tests/compiler/dart2js_extra/break_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
break1(int x, int y, int ew, int ez) {
int w = 1;
int z = 0;
diff --git a/tests/compiler/dart2js_extra/checked_accessor_test.dart b/tests/compiler/dart2js_extra/checked_accessor_test.dart
index f20091f..38e4b38 100644
--- a/tests/compiler/dart2js_extra/checked_accessor_test.dart
+++ b/tests/compiler/dart2js_extra/checked_accessor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class E {
missingType field;
}
diff --git a/tests/compiler/dart2js_extra/closure2_test.dart b/tests/compiler/dart2js_extra/closure2_test.dart
index a6a2b7d..942f324 100644
--- a/tests/compiler/dart2js_extra/closure2_test.dart
+++ b/tests/compiler/dart2js_extra/closure2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
// A closure will be implemented as a class. Make sure everything is set up
// correctly when no other class is generated. In particular we need
diff --git a/tests/compiler/dart2js_extra/closure3_test.dart b/tests/compiler/dart2js_extra/closure3_test.dart
index 119bcb6..cab801f 100644
--- a/tests/compiler/dart2js_extra/closure3_test.dart
+++ b/tests/compiler/dart2js_extra/closure3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var f = fun({a: 3, b: 8}) {
return a + b;
diff --git a/tests/compiler/dart2js_extra/closure4_test.dart b/tests/compiler/dart2js_extra/closure4_test.dart
index f52a858..6ef0c8c 100644
--- a/tests/compiler/dart2js_extra/closure4_test.dart
+++ b/tests/compiler/dart2js_extra/closure4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
var f = fib(i) {
if (i < 2) return i;
diff --git a/tests/compiler/dart2js_extra/closure5_test.dart b/tests/compiler/dart2js_extra/closure5_test.dart
index b88f5ef..f135346 100644
--- a/tests/compiler/dart2js_extra/closure5_test.dart
+++ b/tests/compiler/dart2js_extra/closure5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo() => 499;
bar({a: 1, b: 7, c: 99}) => a + b + c;
diff --git a/tests/compiler/dart2js_extra/closure6_test.dart b/tests/compiler/dart2js_extra/closure6_test.dart
index fd63888..a49b187 100644
--- a/tests/compiler/dart2js_extra/closure6_test.dart
+++ b/tests/compiler/dart2js_extra/closure6_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var foo;
bar() => foo(3, 99);
diff --git a/tests/compiler/dart2js_extra/closure7_test.dart b/tests/compiler/dart2js_extra/closure7_test.dart
index 6003c43..f7b966d 100644
--- a/tests/compiler/dart2js_extra/closure7_test.dart
+++ b/tests/compiler/dart2js_extra/closure7_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var foo;
bar() => foo(3, 99);
gee(f) => foo(fun: f);
diff --git a/tests/compiler/dart2js_extra/closure_capture2_test.dart b/tests/compiler/dart2js_extra/closure_capture2_test.dart
index 21f91e4..6c13143 100644
--- a/tests/compiler/dart2js_extra/closure_capture2_test.dart
+++ b/tests/compiler/dart2js_extra/closure_capture2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
// f and g will both capture a variable named 'x'. If we use the original
// name in the (shared) box then there will be troubles.
diff --git a/tests/compiler/dart2js_extra/closure_capture3_test.dart b/tests/compiler/dart2js_extra/closure_capture3_test.dart
index d38b715..6044a2a 100644
--- a/tests/compiler/dart2js_extra/closure_capture3_test.dart
+++ b/tests/compiler/dart2js_extra/closure_capture3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Closure {
var x;
Closure(val) : this.x = val;
diff --git a/tests/compiler/dart2js_extra/closure_capture4_test.dart b/tests/compiler/dart2js_extra/closure_capture4_test.dart
index 7a4a170..e19a37b 100644
--- a/tests/compiler/dart2js_extra/closure_capture4_test.dart
+++ b/tests/compiler/dart2js_extra/closure_capture4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
var input = [1, 2, 3];
var fs = [];
diff --git a/tests/compiler/dart2js_extra/closure_capture5_test.dart b/tests/compiler/dart2js_extra/closure_capture5_test.dart
index df387bb..8689cdc 100644
--- a/tests/compiler/dart2js_extra/closure_capture5_test.dart
+++ b/tests/compiler/dart2js_extra/closure_capture5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
var fs = [];
for (var x = 1; x <= 3; x++) {
diff --git a/tests/compiler/dart2js_extra/closure_capture_test.dart b/tests/compiler/dart2js_extra/closure_capture_test.dart
index 5ead071..f76b024 100644
--- a/tests/compiler/dart2js_extra/closure_capture_test.dart
+++ b/tests/compiler/dart2js_extra/closure_capture_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
var x = 499;
// TODO(floitsch): remove name from functions.
diff --git a/tests/compiler/dart2js_extra/closure_test.dart b/tests/compiler/dart2js_extra/closure_test.dart
index d5d5519..fad942f 100644
--- a/tests/compiler/dart2js_extra/closure_test.dart
+++ b/tests/compiler/dart2js_extra/closure_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
closure0() {
// TODO(floitsch): remove name from functions.
var f = fun() { return 499; };
diff --git a/tests/compiler/dart2js_extra/compile_time_constant4_test.dart b/tests/compiler/dart2js_extra/compile_time_constant4_test.dart
index bcdfaa7..2a7e55a 100644
--- a/tests/compiler/dart2js_extra/compile_time_constant4_test.dart
+++ b/tests/compiler/dart2js_extra/compile_time_constant4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const x = "foo";
const y = "foo";
const g1 = x
diff --git a/tests/compiler/dart2js_extra/compound_operator_index_test.dart b/tests/compiler/dart2js_extra/compound_operator_index_test.dart
index e4d108f..67d30d0 100644
--- a/tests/compiler/dart2js_extra/compound_operator_index_test.dart
+++ b/tests/compiler/dart2js_extra/compound_operator_index_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
List<int> list;
A(int a, int b) : list = <int>[a, b];
diff --git a/tests/compiler/dart2js_extra/conditional_test.dart b/tests/compiler/dart2js_extra/conditional_test.dart
index 6ecb67b..c1e30b9 100644
--- a/tests/compiler/dart2js_extra/conditional_test.dart
+++ b/tests/compiler/dart2js_extra/conditional_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
getZero() { return 0; }
main() {
diff --git a/tests/compiler/dart2js_extra/conflict_index_test.dart b/tests/compiler/dart2js_extra/conflict_index_test.dart
index 22cf620..46c74ea 100644
--- a/tests/compiler/dart2js_extra/conflict_index_test.dart
+++ b/tests/compiler/dart2js_extra/conflict_index_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
foo(true, [0]);
foo(false, "bar");
diff --git a/tests/compiler/dart2js_extra/constant_fold_number_dart2_j_s_test.dart b/tests/compiler/dart2js_extra/constant_fold_number_dart2_j_s_test.dart
index c80d54b..aab61d7 100644
--- a/tests/compiler/dart2js_extra/constant_fold_number_dart2_j_s_test.dart
+++ b/tests/compiler/dart2js_extra/constant_fold_number_dart2_j_s_test.dart
@@ -4,6 +4,8 @@
// This test is making sure we don't try to constant fold numbers
// where the semantics differ at compile-time (Dart) and runtime (JS).
+import "package:expect/expect.dart";
+
foo() => 0.0;
bar() => 0;
diff --git a/tests/compiler/dart2js_extra/constant_javascript_semantics2_test.dart b/tests/compiler/dart2js_extra/constant_javascript_semantics2_test.dart
index 5790fe3..13f0a93 100644
--- a/tests/compiler/dart2js_extra/constant_javascript_semantics2_test.dart
+++ b/tests/compiler/dart2js_extra/constant_javascript_semantics2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Make sure we use JavaScript semantics when compiling compile-time constants.
// In this case we test that the value-range analysis uses JavaScript semantics
// too.
diff --git a/tests/compiler/dart2js_extra/constant_javascript_semantics3_test.dart b/tests/compiler/dart2js_extra/constant_javascript_semantics3_test.dart
index 0fba325..4fd4128 100644
--- a/tests/compiler/dart2js_extra/constant_javascript_semantics3_test.dart
+++ b/tests/compiler/dart2js_extra/constant_javascript_semantics3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Make sure we use JavaScript semantics when compiling compile-time constants.
// In this case we test that the value-range analysis uses JavaScript semantics
// too.
diff --git a/tests/compiler/dart2js_extra/constant_javascript_semantics_test.dart b/tests/compiler/dart2js_extra/constant_javascript_semantics_test.dart
index dbea323..49dcb36 100644
--- a/tests/compiler/dart2js_extra/constant_javascript_semantics_test.dart
+++ b/tests/compiler/dart2js_extra/constant_javascript_semantics_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Make sure we use JavaScript semantics when compiling compile-time constants.
const x = 12345678901234567891;
diff --git a/tests/compiler/dart2js_extra/dart2js_extra.status b/tests/compiler/dart2js_extra/dart2js_extra.status
index b95b7af..181014f 100644
--- a/tests/compiler/dart2js_extra/dart2js_extra.status
+++ b/tests/compiler/dart2js_extra/dart2js_extra.status
@@ -31,6 +31,7 @@
[ $compiler == dart2js && $minified ]
to_string_test: Fail # Issue 7179.
+runtime_type_test: Fail, OK # Tests extected output of Type.toString().
# Mirrors do not work with minification.
mirror_test: Fail # Issue 6490.
diff --git a/tests/compiler/dart2js_extra/deferred/deferred_class_test.dart b/tests/compiler/dart2js_extra/deferred/deferred_class_test.dart
index 1486e75..4eaa40d 100644
--- a/tests/compiler/dart2js_extra/deferred/deferred_class_test.dart
+++ b/tests/compiler/dart2js_extra/deferred/deferred_class_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
@lazy import 'deferred_class_library.dart';
diff --git a/tests/compiler/dart2js_extra/deferred/deferred_constant_test.dart b/tests/compiler/dart2js_extra/deferred/deferred_constant_test.dart
index 0cbe262..f27bf45 100644
--- a/tests/compiler/dart2js_extra/deferred/deferred_constant_test.dart
+++ b/tests/compiler/dart2js_extra/deferred/deferred_constant_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
@lazy import 'deferred_class_library.dart';
diff --git a/tests/compiler/dart2js_extra/deferred/deferred_function_test.dart b/tests/compiler/dart2js_extra/deferred/deferred_function_test.dart
index 08eb6ac..c5980fb 100644
--- a/tests/compiler/dart2js_extra/deferred/deferred_function_test.dart
+++ b/tests/compiler/dart2js_extra/deferred/deferred_function_test.dart
@@ -5,6 +5,7 @@
// Test that loading of a library (with top-level functions only) can
// be deferred.
+import "package:expect/expect.dart";
import 'dart:async';
@lazy import 'deferred_function_library.dart';
diff --git a/tests/compiler/dart2js_extra/do_test.dart b/tests/compiler/dart2js_extra/do_test.dart
index 84327f1..04d8d87 100644
--- a/tests/compiler/dart2js_extra/do_test.dart
+++ b/tests/compiler/dart2js_extra/do_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void do1() {
bool cond = true;
var result = 0;
diff --git a/tests/compiler/dart2js_extra/factory_test.dart b/tests/compiler/dart2js_extra/factory_test.dart
index 0a10399..0d3e59b 100644
--- a/tests/compiler/dart2js_extra/factory_test.dart
+++ b/tests/compiler/dart2js_extra/factory_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
factory A() {
return 1;
diff --git a/tests/compiler/dart2js_extra/field_in_constructor_test.dart b/tests/compiler/dart2js_extra/field_in_constructor_test.dart
index 6b2f13c..29d1d66 100644
--- a/tests/compiler/dart2js_extra/field_in_constructor_test.dart
+++ b/tests/compiler/dart2js_extra/field_in_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var a;
A() {
diff --git a/tests/compiler/dart2js_extra/field_initializer_test.dart b/tests/compiler/dart2js_extra/field_initializer_test.dart
index 655298e..43dbe3a 100644
--- a/tests/compiler/dart2js_extra/field_initializer_test.dart
+++ b/tests/compiler/dart2js_extra/field_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static var a;
static var b = c;
diff --git a/tests/compiler/dart2js_extra/fields_test.dart b/tests/compiler/dart2js_extra/fields_test.dart
index 2c01a3b..0debb28 100644
--- a/tests/compiler/dart2js_extra/fields_test.dart
+++ b/tests/compiler/dart2js_extra/fields_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
A() {
}
diff --git a/tests/compiler/dart2js_extra/first_class_types_hashcode_test.dart b/tests/compiler/dart2js_extra/first_class_types_hashcode_test.dart
index 26b5c13..06e43bd 100644
--- a/tests/compiler/dart2js_extra/first_class_types_hashcode_test.dart
+++ b/tests/compiler/dart2js_extra/first_class_types_hashcode_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Check that Type instances work with maps. This behavior is not required by
// the specification.
diff --git a/tests/compiler/dart2js_extra/for_in_test.dart b/tests/compiler/dart2js_extra/for_in_test.dart
index 6aa8c51..39d45d9 100644
--- a/tests/compiler/dart2js_extra/for_in_test.dart
+++ b/tests/compiler/dart2js_extra/for_in_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test foreach (aka. for-in) functionality.
testIterator(List expect, Iterable input) {
diff --git a/tests/compiler/dart2js_extra/for_test.dart b/tests/compiler/dart2js_extra/for_test.dart
index 6f97f91..068b4b4 100644
--- a/tests/compiler/dart2js_extra/for_test.dart
+++ b/tests/compiler/dart2js_extra/for_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void for1() {
var cond = true;
var result = 0;
diff --git a/tests/compiler/dart2js_extra/generics_factories_test.dart b/tests/compiler/dart2js_extra/generics_factories_test.dart
index 2de7501..5ca2d59 100644
--- a/tests/compiler/dart2js_extra/generics_factories_test.dart
+++ b/tests/compiler/dart2js_extra/generics_factories_test.dart
@@ -4,6 +4,8 @@
// Test that factories are marked as needing rti.
+import "package:expect/expect.dart";
+
class A<T> {
foo(o) => o is T;
factory A.c() => new B<T>();
diff --git a/tests/compiler/dart2js_extra/generics_is_check1_test.dart b/tests/compiler/dart2js_extra/generics_is_check1_test.dart
index c616c7c..24d01e5 100644
--- a/tests/compiler/dart2js_extra/generics_is_check1_test.dart
+++ b/tests/compiler/dart2js_extra/generics_is_check1_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Hest<X> {}
main() {
diff --git a/tests/compiler/dart2js_extra/getter_element_test.dart b/tests/compiler/dart2js_extra/getter_element_test.dart
index 284395c..9238e8f 100644
--- a/tests/compiler/dart2js_extra/getter_element_test.dart
+++ b/tests/compiler/dart2js_extra/getter_element_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static main() {
testOther();
diff --git a/tests/compiler/dart2js_extra/getters_setters_test.dart b/tests/compiler/dart2js_extra/getters_setters_test.dart
index fcca96c..2e41649 100644
--- a/tests/compiler/dart2js_extra/getters_setters_test.dart
+++ b/tests/compiler/dart2js_extra/getters_setters_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class GettersSettersTest {
static int foo;
diff --git a/tests/compiler/dart2js_extra/hash_code_test.dart b/tests/compiler/dart2js_extra/hash_code_test.dart
index 869c60b..6e25fed 100644
--- a/tests/compiler/dart2js_extra/hash_code_test.dart
+++ b/tests/compiler/dart2js_extra/hash_code_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// dart2js specific test to make sure hashCode on intercepted types behaves as
// intended.
diff --git a/tests/compiler/dart2js_extra/if_in_loop.dart b/tests/compiler/dart2js_extra/if_in_loop.dart
index 03977427..2eef63d 100644
--- a/tests/compiler/dart2js_extra/if_in_loop.dart
+++ b/tests/compiler/dart2js_extra/if_in_loop.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for bug in code generation of if-with-aborting-branch-inside-loop.
foo(p, q) {
diff --git a/tests/compiler/dart2js_extra/if_test.dart b/tests/compiler/dart2js_extra/if_test.dart
index fcc4fc6..d2c8ad8 100644
--- a/tests/compiler/dart2js_extra/if_test.dart
+++ b/tests/compiler/dart2js_extra/if_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int if1() {
if (true) {
return 499;
diff --git a/tests/compiler/dart2js_extra/index_test.dart b/tests/compiler/dart2js_extra/index_test.dart
index 74dad76..890d71a 100644
--- a/tests/compiler/dart2js_extra/index_test.dart
+++ b/tests/compiler/dart2js_extra/index_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a = [0];
Expect.equals(0, a[0]);
diff --git a/tests/compiler/dart2js_extra/interface_type_optimization_test.dart b/tests/compiler/dart2js_extra/interface_type_optimization_test.dart
index a031447..0beb4f4 100644
--- a/tests/compiler/dart2js_extra/interface_type_optimization_test.dart
+++ b/tests/compiler/dart2js_extra/interface_type_optimization_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a = new A();
Expect.equals(42, a.foo(42));
diff --git a/tests/compiler/dart2js_extra/invoke_dynamic_test.dart b/tests/compiler/dart2js_extra/invoke_dynamic_test.dart
index a3558fd..b76c59b 100644
--- a/tests/compiler/dart2js_extra/invoke_dynamic_test.dart
+++ b/tests/compiler/dart2js_extra/invoke_dynamic_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo() { return 499; }
bar(x) { return x + 499; }
diff --git a/tests/compiler/dart2js_extra/is_operator_test.dart b/tests/compiler/dart2js_extra/is_operator_test.dart
index d59fc02..e3a88ca 100644
--- a/tests/compiler/dart2js_extra/is_operator_test.dart
+++ b/tests/compiler/dart2js_extra/is_operator_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
}
diff --git a/tests/compiler/dart2js_extra/list_factory_test.dart b/tests/compiler/dart2js_extra/list_factory_test.dart
index e774573..b58c925 100644
--- a/tests/compiler/dart2js_extra/list_factory_test.dart
+++ b/tests/compiler/dart2js_extra/list_factory_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a = new List(4);
Expect.equals(4, a.length);
diff --git a/tests/compiler/dart2js_extra/literal_string_juxtaposition_test.dart b/tests/compiler/dart2js_extra/literal_string_juxtaposition_test.dart
index a4b6e4c..03d4725 100644
--- a/tests/compiler/dart2js_extra/literal_string_juxtaposition_test.dart
+++ b/tests/compiler/dart2js_extra/literal_string_juxtaposition_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
{
// Generates identical compile time constants.
diff --git a/tests/compiler/dart2js_extra/logical_and_test.dart b/tests/compiler/dart2js_extra/logical_and_test.dart
index 5e9a111..6337969 100644
--- a/tests/compiler/dart2js_extra/logical_and_test.dart
+++ b/tests/compiler/dart2js_extra/logical_and_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void and1() {
var b = true;
b = b && b;
diff --git a/tests/compiler/dart2js_extra/logical_or_test.dart b/tests/compiler/dart2js_extra/logical_or_test.dart
index 7d9fffd..c7848bc 100644
--- a/tests/compiler/dart2js_extra/logical_or_test.dart
+++ b/tests/compiler/dart2js_extra/logical_or_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void or1() {
var b = true;
b = b || b;
diff --git a/tests/compiler/dart2js_extra/loop_if_phi_test.dart b/tests/compiler/dart2js_extra/loop_if_phi_test.dart
index ed76859..044c40a 100644
--- a/tests/compiler/dart2js_extra/loop_if_phi_test.dart
+++ b/tests/compiler/dart2js_extra/loop_if_phi_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void main() {
var prev = -1;
for (int i = 0; i < 2; i++) {
diff --git a/tests/compiler/dart2js_extra/math_lib_prefix_test.dart b/tests/compiler/dart2js_extra/math_lib_prefix_test.dart
index 7d8720b..e8b63ef 100644
--- a/tests/compiler/dart2js_extra/math_lib_prefix_test.dart
+++ b/tests/compiler/dart2js_extra/math_lib_prefix_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library math_lib_prefix_test;
+import "package:expect/expect.dart";
import 'dart:math' as foo;
main() {
diff --git a/tests/compiler/dart2js_extra/math_lib_test.dart b/tests/compiler/dart2js_extra/math_lib_test.dart
index aec45b8..14fd022 100644
--- a/tests/compiler/dart2js_extra/math_lib_test.dart
+++ b/tests/compiler/dart2js_extra/math_lib_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library math_lib_test;
+import "package:expect/expect.dart";
import 'dart:math';
main() {
diff --git a/tests/compiler/dart2js_extra/member_namespace_test.dart b/tests/compiler/dart2js_extra/member_namespace_test.dart
index 3b310db..ff65d20 100644
--- a/tests/compiler/dart2js_extra/member_namespace_test.dart
+++ b/tests/compiler/dart2js_extra/member_namespace_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static int a;
A();
diff --git a/tests/compiler/dart2js_extra/mirror_test.dart b/tests/compiler/dart2js_extra/mirror_test.dart
index 0cc6b01..79de2b8 100644
--- a/tests/compiler/dart2js_extra/mirror_test.dart
+++ b/tests/compiler/dart2js_extra/mirror_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:mirrors';
import 'async_helper.dart';
@@ -13,8 +14,8 @@
print('mirror.type: ${mirror.type}');
print('now.toUtc(): ${now.toUtc()}');
- mirror.invoke("toUtc", []).then((value) {
- print('mirror.invoke("toUtc", []): $value');
+ mirror.invokeAsync("toUtc", []).then((value) {
+ print('mirror.invokeAsync("toUtc", []): $value');
Expect.isTrue(value.hasReflectee);
Expect.equals(now.toUtc(), value.reflectee);
onDone(true);
diff --git a/tests/compiler/dart2js_extra/named_parameter_for_static_test.dart b/tests/compiler/dart2js_extra/named_parameter_for_static_test.dart
index 252c6ad..4efa524 100644
--- a/tests/compiler/dart2js_extra/named_parameter_for_static_test.dart
+++ b/tests/compiler/dart2js_extra/named_parameter_for_static_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
oneOptionalArgument(a, {b}) {
Expect.equals(1, a);
Expect.equals(2, b);
diff --git a/tests/compiler/dart2js_extra/named_parameter_test.dart b/tests/compiler/dart2js_extra/named_parameter_test.dart
index af09e39..a5f0cf8 100644
--- a/tests/compiler/dart2js_extra/named_parameter_test.dart
+++ b/tests/compiler/dart2js_extra/named_parameter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo({a, b}) {
Expect.equals(0, a);
diff --git a/tests/compiler/dart2js_extra/nan_negate_test.dart b/tests/compiler/dart2js_extra/nan_negate_test.dart
index 1d86387..f5acd16 100644
--- a/tests/compiler/dart2js_extra/nan_negate_test.dart
+++ b/tests/compiler/dart2js_extra/nan_negate_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Don't convert !(a op b) to (a neg-op b) when a or b might be NaN.
test(double n) {
// Force known type to double, preserves NaN.
diff --git a/tests/compiler/dart2js_extra/no_such_method_test.dart b/tests/compiler/dart2js_extra/no_such_method_test.dart
index 0a0ac6b..dc28e07 100644
--- a/tests/compiler/dart2js_extra/no_such_method_test.dart
+++ b/tests/compiler/dart2js_extra/no_such_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class NoSuchMethodInfo {
Object receiver;
String name;
diff --git a/tests/compiler/dart2js_extra/not_test.dart b/tests/compiler/dart2js_extra/not_test.dart
index 0f6d97f..e75f2ca 100644
--- a/tests/compiler/dart2js_extra/not_test.dart
+++ b/tests/compiler/dart2js_extra/not_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void not1() {
var x = !true;
Expect.equals(false, x);
diff --git a/tests/compiler/dart2js_extra/null_test.dart b/tests/compiler/dart2js_extra/null_test.dart
index bfec4df..317c124 100644
--- a/tests/compiler/dart2js_extra/null_test.dart
+++ b/tests/compiler/dart2js_extra/null_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
null1() {
return; // implicit null;
}
diff --git a/tests/compiler/dart2js_extra/operator2_test.dart b/tests/compiler/dart2js_extra/operator2_test.dart
index 32abdca..34f2a60 100644
--- a/tests/compiler/dart2js_extra/operator2_test.dart
+++ b/tests/compiler/dart2js_extra/operator2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int zero() { return 0; }
int one() { return 1; }
int minus1() { return 0 - 1; }
diff --git a/tests/compiler/dart2js_extra/operator3_test.dart b/tests/compiler/dart2js_extra/operator3_test.dart
index 00926e9..5ad4460 100644
--- a/tests/compiler/dart2js_extra/operator3_test.dart
+++ b/tests/compiler/dart2js_extra/operator3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int zero() { return 0; }
int one() { return 1; }
int minus1() { return 0 - 1; }
diff --git a/tests/compiler/dart2js_extra/operator_equals_test.dart b/tests/compiler/dart2js_extra/operator_equals_test.dart
index 0368271..becbdd3 100644
--- a/tests/compiler/dart2js_extra/operator_equals_test.dart
+++ b/tests/compiler/dart2js_extra/operator_equals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class AlwaysTrue {
operator ==(a) => true;
}
diff --git a/tests/compiler/dart2js_extra/operator_test.dart b/tests/compiler/dart2js_extra/operator_test.dart
index bda18f8..225976f 100644
--- a/tests/compiler/dart2js_extra/operator_test.dart
+++ b/tests/compiler/dart2js_extra/operator_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int zero() { return 0; }
int one() { return 1; }
int minus1() { return 0 - 1; }
diff --git a/tests/compiler/dart2js_extra/optional_parameter_test.dart b/tests/compiler/dart2js_extra/optional_parameter_test.dart
index 4fd5ac8..bb9ac6f 100644
--- a/tests/compiler/dart2js_extra/optional_parameter_test.dart
+++ b/tests/compiler/dart2js_extra/optional_parameter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo([a]) {
return a;
diff --git a/tests/compiler/dart2js_extra/panda_test.dart b/tests/compiler/dart2js_extra/panda_test.dart
index 3b39953..793a5ab 100644
--- a/tests/compiler/dart2js_extra/panda_test.dart
+++ b/tests/compiler/dart2js_extra/panda_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library panda_test;
+import "package:expect/expect.dart";
import 'panda_lib.dart' as p;
void main() {
diff --git a/tests/compiler/dart2js_extra/phi_elimination_test.dart b/tests/compiler/dart2js_extra/phi_elimination_test.dart
index 5e6430a..ed2fb07 100644
--- a/tests/compiler/dart2js_extra/phi_elimination_test.dart
+++ b/tests/compiler/dart2js_extra/phi_elimination_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void bar() {
var a = 0;
var c = 0;
diff --git a/tests/compiler/dart2js_extra/phi_gvn_test.dart b/tests/compiler/dart2js_extra/phi_gvn_test.dart
index 81511d3..703834f 100644
--- a/tests/compiler/dart2js_extra/phi_gvn_test.dart
+++ b/tests/compiler/dart2js_extra/phi_gvn_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(x) { }
main() {
diff --git a/tests/compiler/dart2js_extra/phi_test.dart b/tests/compiler/dart2js_extra/phi_test.dart
index 23c10be..14ca2be 100644
--- a/tests/compiler/dart2js_extra/phi_test.dart
+++ b/tests/compiler/dart2js_extra/phi_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void phi1() {
var x = 42;
if (true) {
diff --git a/tests/compiler/dart2js_extra/regress/4492_test.dart b/tests/compiler/dart2js_extra/regress/4492_test.dart
index f77d29d..a80ae98 100644
--- a/tests/compiler/dart2js_extra/regress/4492_test.dart
+++ b/tests/compiler/dart2js_extra/regress/4492_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
x(p1, p2) {
print(p1 * p2);
diff --git a/tests/compiler/dart2js_extra/regress/4515_1_test.dart b/tests/compiler/dart2js_extra/regress/4515_1_test.dart
index 6d8b136..8c758b0 100644
--- a/tests/compiler/dart2js_extra/regress/4515_1_test.dart
+++ b/tests/compiler/dart2js_extra/regress/4515_1_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
a(x) => x + 1;
}
diff --git a/tests/compiler/dart2js_extra/regress/4515_2_test.dart b/tests/compiler/dart2js_extra/regress/4515_2_test.dart
index 8ddc8de..3411648 100644
--- a/tests/compiler/dart2js_extra/regress/4515_2_test.dart
+++ b/tests/compiler/dart2js_extra/regress/4515_2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
a(x) => x + 1;
}
diff --git a/tests/compiler/dart2js_extra/regress/4515_3_test.dart b/tests/compiler/dart2js_extra/regress/4515_3_test.dart
index 319eb0c..f224d70 100644
--- a/tests/compiler/dart2js_extra/regress/4515_3_test.dart
+++ b/tests/compiler/dart2js_extra/regress/4515_3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
a(x) => x + 1;
}
diff --git a/tests/compiler/dart2js_extra/regress/4639_test.dart b/tests/compiler/dart2js_extra/regress/4639_test.dart
index cc6c5be..2aa9308 100644
--- a/tests/compiler/dart2js_extra/regress/4639_test.dart
+++ b/tests/compiler/dart2js_extra/regress/4639_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
bool contains(x, y) => true;
}
diff --git a/tests/compiler/dart2js_extra/regress/4740_test.dart b/tests/compiler/dart2js_extra/regress/4740_test.dart
index f04c711..a32a7b9 100644
--- a/tests/compiler/dart2js_extra/regress/4740_test.dart
+++ b/tests/compiler/dart2js_extra/regress/4740_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
import '4740_library.dart';
main() {
diff --git a/tests/compiler/dart2js_extra/regression_2913_test.dart b/tests/compiler/dart2js_extra/regression_2913_test.dart
index 0099a6a..85b0916 100644
--- a/tests/compiler/dart2js_extra/regression_2913_test.dart
+++ b/tests/compiler/dart2js_extra/regression_2913_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a = 10;
var b = 11;
diff --git a/tests/compiler/dart2js_extra/return_setter_test.dart b/tests/compiler/dart2js_extra/return_setter_test.dart
index bc2192f..a938b71 100644
--- a/tests/compiler/dart2js_extra/return_setter_test.dart
+++ b/tests/compiler/dart2js_extra/return_setter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int foo;
diff --git a/tests/compiler/dart2js_extra/runtime_type_int_test.dart b/tests/compiler/dart2js_extra/runtime_type_int_test.dart
index efb3861..d98484a 100644
--- a/tests/compiler/dart2js_extra/runtime_type_int_test.dart
+++ b/tests/compiler/dart2js_extra/runtime_type_int_test.dart
@@ -5,6 +5,8 @@
// Test that in dart2js, the constant system matches the runtime
// handling of numbers.
+import "package:expect/expect.dart";
+
main() {
var x = 10000000000000000;
var y = [x][0];
diff --git a/tests/compiler/dart2js_extra/runtime_type_isolate.dart b/tests/compiler/dart2js_extra/runtime_type_isolate.dart
index 9be80f5..75815b8 100644
--- a/tests/compiler/dart2js_extra/runtime_type_isolate.dart
+++ b/tests/compiler/dart2js_extra/runtime_type_isolate.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:isolate';
class Bar {}
diff --git a/tests/compiler/dart2js_extra/runtime_type_test.dart b/tests/compiler/dart2js_extra/runtime_type_test.dart
new file mode 100644
index 0000000..8f0b0f4
--- /dev/null
+++ b/tests/compiler/dart2js_extra/runtime_type_test.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that Type.toString returns nice strings for native classes with
+// reserved names and for raw types.
+
+import "package:expect/expect.dart";
+
+class C<T> {}
+
+class D<X, Y, Z> {}
+
+class Class$With$Dollar {}
+
+void main() {
+ Expect.equals('C', new C().runtimeType.toString());
+ Expect.equals('C<int>', new C<int>().runtimeType.toString());
+ Expect.equals('C<double>', new C<double>().runtimeType.toString());
+ Expect.equals('C<num>', new C<num>().runtimeType.toString());
+ Expect.equals('C<bool>', new C<bool>().runtimeType.toString());
+ Expect.equals('D', new D().runtimeType.toString());
+ Expect.equals('D<dynamic, int, dynamic>',
+ new D<dynamic, int, dynamic>().runtimeType.toString());
+ D d = new D<dynamic, D, D<dynamic, dynamic, int>>();
+ Expect.equals('D<dynamic, D, D<dynamic, dynamic, int>>',
+ d.runtimeType.toString());
+ Expect.equals(r'C<Class$With$Dollar>',
+ new C<Class$With$Dollar>().runtimeType.toString());
+}
diff --git a/tests/compiler/dart2js_extra/simple_string_constant_test.dart b/tests/compiler/dart2js_extra/simple_string_constant_test.dart
index d1de74a..746e4d2 100644
--- a/tests/compiler/dart2js_extra/simple_string_constant_test.dart
+++ b/tests/compiler/dart2js_extra/simple_string_constant_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const String m = "\u{21}";
main() {
diff --git a/tests/compiler/dart2js_extra/static_field2_test.dart b/tests/compiler/dart2js_extra/static_field2_test.dart
index 337e74b..d2f5cc7 100644
--- a/tests/compiler/dart2js_extra/static_field2_test.dart
+++ b/tests/compiler/dart2js_extra/static_field2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static int b;
}
diff --git a/tests/compiler/dart2js_extra/static_field_test.dart b/tests/compiler/dart2js_extra/static_field_test.dart
index 12214f9..63c96af 100644
--- a/tests/compiler/dart2js_extra/static_field_test.dart
+++ b/tests/compiler/dart2js_extra/static_field_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static int b;
diff --git a/tests/compiler/dart2js_extra/static_method2_test.dart b/tests/compiler/dart2js_extra/static_method2_test.dart
index 49b2518..ab6517f 100644
--- a/tests/compiler/dart2js_extra/static_method2_test.dart
+++ b/tests/compiler/dart2js_extra/static_method2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static foo(res) {
return res;
diff --git a/tests/compiler/dart2js_extra/static_method_test.dart b/tests/compiler/dart2js_extra/static_method_test.dart
index 5f0a4f0..a65e0b6 100644
--- a/tests/compiler/dart2js_extra/static_method_test.dart
+++ b/tests/compiler/dart2js_extra/static_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
static foo(res) {
return res;
diff --git a/tests/compiler/dart2js_extra/static_var_no_initializer_test.dart b/tests/compiler/dart2js_extra/static_var_no_initializer_test.dart
index 58def5c..e6cb720 100644
--- a/tests/compiler/dart2js_extra/static_var_no_initializer_test.dart
+++ b/tests/compiler/dart2js_extra/static_var_no_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int one;
int x;
diff --git a/tests/compiler/dart2js_extra/static_var_test.dart b/tests/compiler/dart2js_extra/static_var_test.dart
index 3144a9b..1b3a9fc 100644
--- a/tests/compiler/dart2js_extra/static_var_test.dart
+++ b/tests/compiler/dart2js_extra/static_var_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int one = 1;
int x = 5;
diff --git a/tests/compiler/dart2js_extra/string_escape_test.dart b/tests/compiler/dart2js_extra/string_escape_test.dart
index 6094469..04bd109 100644
--- a/tests/compiler/dart2js_extra/string_escape_test.dart
+++ b/tests/compiler/dart2js_extra/string_escape_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that string escapes work correctly.
testSingleCharacterEscapes() {
diff --git a/tests/compiler/dart2js_extra/string_interpolation_test.dart b/tests/compiler/dart2js_extra/string_interpolation_test.dart
index 70357dc..7552214 100644
--- a/tests/compiler/dart2js_extra/string_interpolation_test.dart
+++ b/tests/compiler/dart2js_extra/string_interpolation_test.dart
Binary files differ
diff --git a/tests/compiler/dart2js_extra/super_call_test.dart b/tests/compiler/dart2js_extra/super_call_test.dart
index 7c28f44..c9f777f 100644
--- a/tests/compiler/dart2js_extra/super_call_test.dart
+++ b/tests/compiler/dart2js_extra/super_call_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo() => "A.foo${baz()}";
baz() => "A.baz";
diff --git a/tests/compiler/dart2js_extra/super_constructor1_test.dart b/tests/compiler/dart2js_extra/super_constructor1_test.dart
index 49ce5c5..c6fcb01 100644
--- a/tests/compiler/dart2js_extra/super_constructor1_test.dart
+++ b/tests/compiler/dart2js_extra/super_constructor1_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
String message;
class A {
diff --git a/tests/compiler/dart2js_extra/super_constructor2_test.dart b/tests/compiler/dart2js_extra/super_constructor2_test.dart
index 4c5f302..73ac20a 100644
--- a/tests/compiler/dart2js_extra/super_constructor2_test.dart
+++ b/tests/compiler/dart2js_extra/super_constructor2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int x;
A() : x = 27;
diff --git a/tests/compiler/dart2js_extra/switch_test.dart b/tests/compiler/dart2js_extra/switch_test.dart
index 7d0876b..c6190e4 100644
--- a/tests/compiler/dart2js_extra/switch_test.dart
+++ b/tests/compiler/dart2js_extra/switch_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
switcher(val) {
var x = 0;
switch (val) {
diff --git a/tests/compiler/dart2js_extra/this_phi_elimination_test.dart b/tests/compiler/dart2js_extra/this_phi_elimination_test.dart
index f678b8f..80f7bb0 100644
--- a/tests/compiler/dart2js_extra/this_phi_elimination_test.dart
+++ b/tests/compiler/dart2js_extra/this_phi_elimination_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo(a) {
while (false) {
diff --git a/tests/compiler/dart2js_extra/this_redirecting_constructor_test.dart b/tests/compiler/dart2js_extra/this_redirecting_constructor_test.dart
index 6962716..068d62f 100644
--- a/tests/compiler/dart2js_extra/this_redirecting_constructor_test.dart
+++ b/tests/compiler/dart2js_extra/this_redirecting_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Confirm that redirecting named constructors are properly resolved.
//
// Note that this test may become invalid due to http://dartbug.com/5940.
@@ -16,4 +18,4 @@
main() {
var c = new C.redirecting();
Expect.equals(c.x, 2);
-}
\ No newline at end of file
+}
diff --git a/tests/compiler/dart2js_extra/this_test.dart b/tests/compiler/dart2js_extra/this_test.dart
index e979497..18cf323 100644
--- a/tests/compiler/dart2js_extra/this_test.dart
+++ b/tests/compiler/dart2js_extra/this_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int x;
getX() => this.x;
diff --git a/tests/compiler/dart2js_extra/to_string_test.dart b/tests/compiler/dart2js_extra/to_string_test.dart
index 0227534..6324a78 100644
--- a/tests/compiler/dart2js_extra/to_string_test.dart
+++ b/tests/compiler/dart2js_extra/to_string_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A extends Object {
}
diff --git a/tests/compiler/dart2js_extra/type_argument_factory_crash_test.dart b/tests/compiler/dart2js_extra/type_argument_factory_crash_test.dart
index e49f4d6..2ed0db6 100644
--- a/tests/compiler/dart2js_extra/type_argument_factory_crash_test.dart
+++ b/tests/compiler/dart2js_extra/type_argument_factory_crash_test.dart
@@ -4,6 +4,7 @@
// A regression test for a dart2js crash.
library type.argument.factory.crash.test;
+import "package:expect/expect.dart";
import 'dart:collection' show LinkedHashMap;
void main() {
diff --git a/tests/compiler/dart2js_extra/type_argument_factory_nocrash_test.dart b/tests/compiler/dart2js_extra/type_argument_factory_nocrash_test.dart
index 975a067..7ddb90c 100644
--- a/tests/compiler/dart2js_extra/type_argument_factory_nocrash_test.dart
+++ b/tests/compiler/dart2js_extra/type_argument_factory_nocrash_test.dart
@@ -4,6 +4,7 @@
// A regression test for a dart2js crash.
library type.argument.factory.nocrash.test;
+import "package:expect/expect.dart";
import 'dart:collection' show LinkedHashMap;
void main() {
diff --git a/tests/compiler/dart2js_extra/typevariable_factory_test.dart b/tests/compiler/dart2js_extra/typevariable_factory_test.dart
index 5618cae..2f977cf 100644
--- a/tests/compiler/dart2js_extra/typevariable_factory_test.dart
+++ b/tests/compiler/dart2js_extra/typevariable_factory_test.dart
@@ -4,6 +4,8 @@
// Regression test to ensure that we can use type variable in factories.
+import "package:expect/expect.dart";
+
class A<T> {
factory A.foo(o) {
Expect.isTrue(o is A<T>);
diff --git a/tests/compiler/dart2js_extra/typevariable_substitution_test.dart b/tests/compiler/dart2js_extra/typevariable_substitution_test.dart
index 8a40a82..dd5e75f 100644
--- a/tests/compiler/dart2js_extra/typevariable_substitution_test.dart
+++ b/tests/compiler/dart2js_extra/typevariable_substitution_test.dart
@@ -4,6 +4,8 @@
// Regression test to ensure that we substitute type variables in is-tests.
+import "package:expect/expect.dart";
+
class A<T> {
A.foo(o) {
Expect.isTrue(o is A<T>);
diff --git a/tests/compiler/dart2js_extra/while_test.dart b/tests/compiler/dart2js_extra/while_test.dart
index c41d7ca..4ac3ec3 100644
--- a/tests/compiler/dart2js_extra/while_test.dart
+++ b/tests/compiler/dart2js_extra/while_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void while1() {
bool cond = true;
var result = 0;
diff --git a/tests/compiler/dart2js_foreign/foreign_test.dart b/tests/compiler/dart2js_foreign/foreign_test.dart
index a23e1e2..1e7dddb 100644
--- a/tests/compiler/dart2js_foreign/foreign_test.dart
+++ b/tests/compiler/dart2js_foreign/foreign_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
foreign1(var a, var b) {
diff --git a/tests/compiler/dart2js_foreign/native_call_arity1_test.dart b/tests/compiler/dart2js_foreign/native_call_arity1_test.dart
index 2ae3917..1476be5 100644
--- a/tests/compiler/dart2js_foreign/native_call_arity1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_call_arity1_test.dart
@@ -10,6 +10,7 @@
// * Named arguments are passed in the correct position, so require preceding
// arguments to be passed.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_call_arity2_test.dart b/tests/compiler/dart2js_foreign/native_call_arity2_test.dart
index b28e99e..acb0f71 100644
--- a/tests/compiler/dart2js_foreign/native_call_arity2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_call_arity2_test.dart
@@ -5,6 +5,7 @@
// This is a similar test to NativeCallArity1FrogTest, but makes sure
// that subclasses also get the right number of arguments.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_call_arity3_test.dart b/tests/compiler/dart2js_foreign/native_call_arity3_test.dart
index fb2e00b..172119c 100644
--- a/tests/compiler/dart2js_foreign/native_call_arity3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_call_arity3_test.dart
@@ -6,6 +6,7 @@
// parameters set to null. These parameters should be treated as if they
// do not have a default value for the native methods.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart b/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart
index f6e169b..29bbefe 100644
--- a/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart
@@ -4,6 +4,7 @@
// Test that type checks occur on native methods.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_checked_fields_test.dart b/tests/compiler/dart2js_foreign/native_checked_fields_test.dart
index 15851b8..91406f3 100644
--- a/tests/compiler/dart2js_foreign/native_checked_fields_test.dart
+++ b/tests/compiler/dart2js_foreign/native_checked_fields_test.dart
@@ -4,6 +4,7 @@
// Test that type checks occur on assignment to fields of native methods.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart b/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart
index 170d6e2..7ff5cb1 100644
--- a/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart
@@ -4,6 +4,7 @@
// Test that hidden native class names are not used by generated code.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*B")
diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart
index 0aae881..b3d9632 100644
--- a/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart
@@ -7,6 +7,7 @@
// superclass caches the method in the prototype, so shadowing the dispatcher
// stored on Object.prototype.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
// Version 1: It might be possible to call foo directly.
diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart
index 77f24c3..da23d5f 100644
--- a/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart
@@ -7,6 +7,7 @@
// superclass caches the method in the prototype, so shadowing the dispatcher
// stored on Object.prototype.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart
index c3a085f..73794c8 100644
--- a/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart
@@ -6,6 +6,7 @@
// interferes with subsequent resolving of the method. This might happen if the
// noSuchMethod is cached on Object.prototype.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A1")
diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart
index b7a8c67..f128515 100644
--- a/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart
@@ -6,6 +6,7 @@
// inheritance, the superclass method must not be reached by a call on the
// subclass.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart b/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart
index ee73eae..5c4ca64 100644
--- a/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart
@@ -4,6 +4,7 @@
// Test for correct simple is-checks on hidden native classes.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
interface I {
diff --git a/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart b/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart
index 464e593..b6e63bb 100644
--- a/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart
@@ -4,6 +4,7 @@
// Test for correct simple is-checks on hidden native classes.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
interface J {
diff --git a/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart b/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart
index 963263e..09ec690 100644
--- a/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart
+++ b/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart
@@ -4,6 +4,7 @@
// Additional Dart code may be 'placed on' hidden native classes.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_closure_identity_test.dart b/tests/compiler/dart2js_foreign/native_closure_identity_test.dart
index 1ba6c2f..cca3588 100644
--- a/tests/compiler/dart2js_foreign/native_closure_identity_test.dart
+++ b/tests/compiler/dart2js_foreign/native_closure_identity_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
typedef void MyFunctionType();
diff --git a/tests/compiler/dart2js_foreign/native_exceptions1_test.dart b/tests/compiler/dart2js_foreign/native_exceptions1_test.dart
index 40f5b9e..25ca222 100644
--- a/tests/compiler/dart2js_foreign/native_exceptions1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_exceptions1_test.dart
@@ -13,6 +13,7 @@
// is no place in the Dart language to communicate (3). So we use the following
// fake body technique.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
// The exception type.
diff --git a/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart b/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart
index e8ae45c..a7b7f51 100644
--- a/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart
@@ -6,6 +6,7 @@
// fields. However, native fields keep their name. The implication: a getter
// for the field must be based on the field's name, not the field's jsname.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart b/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart
index 34eaacb..55efc6c 100644
--- a/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart
@@ -6,6 +6,7 @@
// fields. However, native fields keep their name. The implication: a getter
// for the field must be based on the field's name, not the field's jsname.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
interface I {
diff --git a/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart b/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart
index c3bddda..90ad5d2 100644
--- a/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart
+++ b/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart
@@ -5,6 +5,7 @@
// Test for correct hidden native class when interface has same name.
library main;
+import "package:expect/expect.dart";
import 'native_library_same_name_used_lib1.dart';
import 'native_metadata.dart';
diff --git a/tests/compiler/dart2js_foreign/native_literal_class_test.dart b/tests/compiler/dart2js_foreign/native_literal_class_test.dart
index 86e9fd0..9bb3ec2 100644
--- a/tests/compiler/dart2js_foreign/native_literal_class_test.dart
+++ b/tests/compiler/dart2js_foreign/native_literal_class_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("= {log: function() { return 42 } }")
diff --git a/tests/compiler/dart2js_foreign/native_method_rename1_test.dart b/tests/compiler/dart2js_foreign/native_method_rename1_test.dart
index 485fb5f5..9e229a8 100644
--- a/tests/compiler/dart2js_foreign/native_method_rename1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_method_rename1_test.dart
@@ -4,6 +4,7 @@
// Test the feature where the native string declares the native method's name.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_method_rename2_test.dart b/tests/compiler/dart2js_foreign/native_method_rename2_test.dart
index 767f61b..9258aa6 100644
--- a/tests/compiler/dart2js_foreign/native_method_rename2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_method_rename2_test.dart
@@ -4,6 +4,7 @@
// Test the feature where the native string declares the native method's name.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_method_rename3_test.dart b/tests/compiler/dart2js_foreign/native_method_rename3_test.dart
index bceaf9f..e0f5c71 100644
--- a/tests/compiler/dart2js_foreign/native_method_rename3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_method_rename3_test.dart
@@ -5,6 +5,7 @@
// Test the feature where the native string declares the native method's name.
// #3. The name does not get
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart b/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart
index 6a15512..3786647 100644
--- a/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart
+++ b/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart
@@ -4,6 +4,7 @@
// Make sure we can have a native with a name that is a JavaScript keyword.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_missing_method1_test.dart b/tests/compiler/dart2js_foreign/native_missing_method1_test.dart
index f81b9a8..d87878f 100644
--- a/tests/compiler/dart2js_foreign/native_missing_method1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_missing_method1_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_missing_method2_test.dart b/tests/compiler/dart2js_foreign/native_missing_method2_test.dart
index fb99986..bd6bae4 100644
--- a/tests/compiler/dart2js_foreign/native_missing_method2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_missing_method2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart b/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart
index 4c6704b..d00a779 100644
--- a/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart
@@ -4,6 +4,7 @@
// Hidden native class wwith named constructors and static methods.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart b/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart
index 18bba8e..0921f6e 100644
--- a/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart
@@ -5,6 +5,7 @@
// Hidden native class with factory constructors and NO static methods.
// Regression test.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart
index 65f9517..894a462 100644
--- a/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart
index 4aadd1b..1c50a0a 100644
--- a/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart
index b68e078..182cbc6 100644
--- a/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart
+++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart
index abb3961..15c9cad 100644
--- a/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart
+++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart
index ee9d30e..7459441 100644
--- a/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart
+++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_null_closure_test.dart b/tests/compiler/dart2js_foreign/native_null_closure_test.dart
index 7762d1c..b6ac177 100644
--- a/tests/compiler/dart2js_foreign/native_null_closure_test.dart
+++ b/tests/compiler/dart2js_foreign/native_null_closure_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
typedef void MyFunctionType();
diff --git a/tests/compiler/dart2js_foreign/native_null_test.dart b/tests/compiler/dart2js_foreign/native_null_test.dart
index 77db080..540d994 100644
--- a/tests/compiler/dart2js_foreign/native_null_test.dart
+++ b/tests/compiler/dart2js_foreign/native_null_test.dart
@@ -5,6 +5,7 @@
// Test that parameters in native methods are not mangled. This test is needed
// until we change all libraries to using the JS foreign element.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_parameter_names_test.dart b/tests/compiler/dart2js_foreign/native_parameter_names_test.dart
index 466b226..4bf7084 100644
--- a/tests/compiler/dart2js_foreign/native_parameter_names_test.dart
+++ b/tests/compiler/dart2js_foreign/native_parameter_names_test.dart
@@ -5,6 +5,7 @@
// Test that parameters in native methods are not mangled. This test is needed
// until we change all libraries to using the JS foreign element.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_property_test.dart b/tests/compiler/dart2js_foreign/native_property_test.dart
index 4aa85ea..e7abbda8 100644
--- a/tests/compiler/dart2js_foreign/native_property_test.dart
+++ b/tests/compiler/dart2js_foreign/native_property_test.dart
@@ -4,6 +4,7 @@
// Properties on hidden native classes.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_to_string_test.dart b/tests/compiler/dart2js_foreign/native_to_string_test.dart
index 959b2ca..69bcc8b 100644
--- a/tests/compiler/dart2js_foreign/native_to_string_test.dart
+++ b/tests/compiler/dart2js_foreign/native_to_string_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*A")
diff --git a/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart b/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart
index b57e267..cc1d668 100644
--- a/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart
+++ b/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart
@@ -5,6 +5,7 @@
// Test that we put native names and not Dart names into the dynamic
// dispatch table.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
@Native("*NativeA")
diff --git a/tests/compiler/dart2js_foreign/native_window1_test.dart b/tests/compiler/dart2js_foreign/native_window1_test.dart
index ecd0b8e..1f1ee85 100644
--- a/tests/compiler/dart2js_foreign/native_window1_test.dart
+++ b/tests/compiler/dart2js_foreign/native_window1_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
interface Window {
diff --git a/tests/compiler/dart2js_foreign/native_window2_test.dart b/tests/compiler/dart2js_foreign/native_window2_test.dart
index 414ede5..328601b 100644
--- a/tests/compiler/dart2js_foreign/native_window2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_window2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
interface Window {
diff --git a/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart b/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart
index a123a1f..90e8caa 100644
--- a/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart
+++ b/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
typedef void Callback0();
diff --git a/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart b/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart
index e341171..3b994d0 100644
--- a/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart
+++ b/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
typedef void Callback0();
diff --git a/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart b/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart
index 5da4248..ec2057e 100644
--- a/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart
+++ b/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'native_metadata.dart';
typedef void Callback0();
diff --git a/tests/compiler/dart2js_native/core_type_check_native_test.dart b/tests/compiler/dart2js_native/core_type_check_native_test.dart
index 17a6a438..cdfc737 100644
--- a/tests/compiler/dart2js_native/core_type_check_native_test.dart
+++ b/tests/compiler/dart2js_native/core_type_check_native_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
check(value, expectComparable, expectPattern) {
Expect.equals(expectComparable, value is Comparable);
Expect.equals(expectPattern, value is Pattern);
diff --git a/tests/compiler/dart2js_native/dart2js_native.status b/tests/compiler/dart2js_native/dart2js_native.status
index a69582f..9af392c 100644
--- a/tests/compiler/dart2js_native/dart2js_native.status
+++ b/tests/compiler/dart2js_native/dart2js_native.status
@@ -7,8 +7,5 @@
[ $compiler == dart2js ]
native_null_closure_frog_test: Fail
-native_mixin_test: Fail # Issue 9629
-native_mixin_field_test: Fail # Issue 9629
-native_mixin_multiple_test: Fail # Issue 9629
native_no_such_method_exception4_frog_test: Fail # Issue 9631
native_no_such_method_exception5_frog_test: Fail # Issue 9631
diff --git a/tests/compiler/dart2js_native/downcast_test.dart b/tests/compiler/dart2js_native/downcast_test.dart
index c2960bf..31202055 100644
--- a/tests/compiler/dart2js_native/downcast_test.dart
+++ b/tests/compiler/dart2js_native/downcast_test.dart
@@ -4,6 +4,8 @@
// Test for downcasts on native classes.
+import "package:expect/expect.dart";
+
interface J {
}
diff --git a/tests/compiler/dart2js_native/field_type_test.dart b/tests/compiler/dart2js_native/field_type_test.dart
index 9de1cfb..0ea5711 100644
--- a/tests/compiler/dart2js_native/field_type_test.dart
+++ b/tests/compiler/dart2js_native/field_type_test.dart
@@ -6,6 +6,8 @@
// This regression test verifies that compiler accounts for hidden constructor
// when analysing field values.
+import "package:expect/expect.dart";
+
class Node native "*Node" {
final Node parentNode;
diff --git a/tests/compiler/dart2js_native/foreign_test.dart b/tests/compiler/dart2js_native/foreign_test.dart
index f7fd7c6d..dcefa26 100644
--- a/tests/compiler/dart2js_native/foreign_test.dart
+++ b/tests/compiler/dart2js_native/foreign_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:_foreign_helper' show JS;
foreign1(var a, var b) {
diff --git a/tests/compiler/dart2js_native/hash_code_test.dart b/tests/compiler/dart2js_native/hash_code_test.dart
index 0c50d21..1cd9da7 100644
--- a/tests/compiler/dart2js_native/hash_code_test.dart
+++ b/tests/compiler/dart2js_native/hash_code_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {}
makeA() native;
diff --git a/tests/compiler/dart2js_native/is_check_test.dart b/tests/compiler/dart2js_native/is_check_test.dart
index f0ae311..0f70722 100644
--- a/tests/compiler/dart2js_native/is_check_test.dart
+++ b/tests/compiler/dart2js_native/is_check_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {}
main() {
diff --git a/tests/compiler/dart2js_native/issue9182_test.dart b/tests/compiler/dart2js_native/issue9182_test.dart
index 8cbd17a..b8ae713 100644
--- a/tests/compiler/dart2js_native/issue9182_test.dart
+++ b/tests/compiler/dart2js_native/issue9182_test.dart
@@ -5,6 +5,8 @@
// Regression test for Issue 9182. The generative constructor body function
// should not have the interceptor calling convention.
+import "package:expect/expect.dart";
+
class Foo native "*A" {
factory Foo() => makeA();
// Ensure the instance method 'Bar' uses interceptor convention.
diff --git a/tests/compiler/dart2js_native/native_call_arity1_frog_test.dart b/tests/compiler/dart2js_native/native_call_arity1_frog_test.dart
index 8558b22..6f398b4 100644
--- a/tests/compiler/dart2js_native/native_call_arity1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_call_arity1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that native methods with unnamed* optional arguments are called with the
// number of arguments in the call site. This is necessary because native
// methods can dispatch on the number of arguments. Passing null or undefined
diff --git a/tests/compiler/dart2js_native/native_call_arity2_frog_test.dart b/tests/compiler/dart2js_native/native_call_arity2_frog_test.dart
index f292ad1..0014b00 100644
--- a/tests/compiler/dart2js_native/native_call_arity2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_call_arity2_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This is a similar test to NativeCallArity1FrogTest, but makes sure
// that subclasses also get the right number of arguments.
diff --git a/tests/compiler/dart2js_native/native_call_arity3_frog_test.dart b/tests/compiler/dart2js_native/native_call_arity3_frog_test.dart
index 8a45c05..ff59e31 100644
--- a/tests/compiler/dart2js_native/native_call_arity3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_call_arity3_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test similar to NativeCallArity1FrogTest, but with default values to
// parameters set to null. These parameters should be treated as if they
// do not have a default value for the native methods.
diff --git a/tests/compiler/dart2js_native/native_checked_arguments1_frog_test.dart b/tests/compiler/dart2js_native/native_checked_arguments1_frog_test.dart
index 9922665..7874dcd 100644
--- a/tests/compiler/dart2js_native/native_checked_arguments1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_checked_arguments1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that type checks occur on native methods.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_checked_fields_frog_test.dart b/tests/compiler/dart2js_native/native_checked_fields_frog_test.dart
index 0b08f46..a63674c 100644
--- a/tests/compiler/dart2js_native/native_checked_fields_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_checked_fields_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that type checks occur on assignment to fields of native methods.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_class_avoids_hidden_name_frog_test.dart b/tests/compiler/dart2js_native/native_class_avoids_hidden_name_frog_test.dart
index ff4be42..dc7877f 100644
--- a/tests/compiler/dart2js_native/native_class_avoids_hidden_name_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_avoids_hidden_name_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that hidden native class names are not used by generated code.
class A native "*B" {
diff --git a/tests/compiler/dart2js_native/native_class_fields_2_test.dart b/tests/compiler/dart2js_native/native_class_fields_2_test.dart
index 1612371..00ca28b 100644
--- a/tests/compiler/dart2js_native/native_class_fields_2_test.dart
+++ b/tests/compiler/dart2js_native/native_class_fields_2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Verify that methods are not renamed to clash with native field names
// that are known from the DOM (like x, y, z).
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_class_fields_3_test.dart b/tests/compiler/dart2js_native/native_class_fields_3_test.dart
index a884dbf..1af5d67 100644
--- a/tests/compiler/dart2js_native/native_class_fields_3_test.dart
+++ b/tests/compiler/dart2js_native/native_class_fields_3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Verify that we can have fields with names that start with g and s even
// though those names are reserved for getters and setters in minified mode.
@@ -84,4 +86,3 @@
Expect.equals(6, foo.gettersCalled);
Expect.equals(6, foo.settersCalled);
}
-
diff --git a/tests/compiler/dart2js_native/native_class_fields_test.dart b/tests/compiler/dart2js_native/native_class_fields_test.dart
index 8221eec..4bd0aa6 100644
--- a/tests/compiler/dart2js_native/native_class_fields_test.dart
+++ b/tests/compiler/dart2js_native/native_class_fields_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Verify that native fields on classes are not renamed by the minifier.
class A native "*A" {
int myLongPropertyName;
diff --git a/tests/compiler/dart2js_native/native_class_inheritance1_frog_test.dart b/tests/compiler/dart2js_native/native_class_inheritance1_frog_test.dart
index 07a8ff1..9c37eba 100644
--- a/tests/compiler/dart2js_native/native_class_inheritance1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_inheritance1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to see if resolving a hidden native class's method interferes with
// subsequent resolving the subclass's method. This might happen if the
// superclass caches the method in the prototype, so shadowing the dispatcher
diff --git a/tests/compiler/dart2js_native/native_class_inheritance2_frog_test.dart b/tests/compiler/dart2js_native/native_class_inheritance2_frog_test.dart
index 9dec57b..27819c4 100644
--- a/tests/compiler/dart2js_native/native_class_inheritance2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_inheritance2_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to see if resolving a hidden native class's method interferes with
// subsequent resolving the subclass's method. This might happen if the
// superclass caches the method in the prototype, so shadowing the dispatcher
diff --git a/tests/compiler/dart2js_native/native_class_inheritance3_frog_test.dart b/tests/compiler/dart2js_native/native_class_inheritance3_frog_test.dart
index 5b7dd69..2f93bd2 100644
--- a/tests/compiler/dart2js_native/native_class_inheritance3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_inheritance3_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to see if resolving a hidden native class's method to noSuchMethod
// interferes with subsequent resolving of the method. This might happen if the
// noSuchMethod is cached on Object.prototype.
diff --git a/tests/compiler/dart2js_native/native_class_inheritance4_frog_test.dart b/tests/compiler/dart2js_native/native_class_inheritance4_frog_test.dart
index 4e77ffe..70f2282 100644
--- a/tests/compiler/dart2js_native/native_class_inheritance4_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_inheritance4_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Additional Dart code may be 'placed on' hidden native classes. With
// inheritance, the superclass method must not be reached by a call on the
// subclass.
diff --git a/tests/compiler/dart2js_native/native_class_is_check1_frog_test.dart b/tests/compiler/dart2js_native/native_class_is_check1_frog_test.dart
index 535dcec..49dde38 100644
--- a/tests/compiler/dart2js_native/native_class_is_check1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_is_check1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for correct simple is-checks on hidden native classes.
interface I {
diff --git a/tests/compiler/dart2js_native/native_class_is_check3_frog_test.dart b/tests/compiler/dart2js_native/native_class_is_check3_frog_test.dart
index afd6e32..b1f5f64 100644
--- a/tests/compiler/dart2js_native/native_class_is_check3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_is_check3_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for correct simple is-checks on hidden native classes.
interface J {
diff --git a/tests/compiler/dart2js_native/native_class_with_dart_methods_frog_test.dart b/tests/compiler/dart2js_native/native_class_with_dart_methods_frog_test.dart
index 17dc60e..e595936 100644
--- a/tests/compiler/dart2js_native/native_class_with_dart_methods_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_class_with_dart_methods_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Additional Dart code may be 'placed on' hidden native classes.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_closure_identity_frog_test.dart b/tests/compiler/dart2js_native/native_closure_identity_frog_test.dart
index 26c7d4e..0f699b8 100644
--- a/tests/compiler/dart2js_native/native_closure_identity_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_closure_identity_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
typedef void MyFunctionType();
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_constructor_name_test.dart b/tests/compiler/dart2js_native/native_constructor_name_test.dart
index bbf8b5c..9ea1b2d 100644
--- a/tests/compiler/dart2js_native/native_constructor_name_test.dart
+++ b/tests/compiler/dart2js_native/native_constructor_name_test.dart
@@ -8,6 +8,8 @@
// This could be done by renaming the Dart constructor or by being able to check
// that objects are Dart classes.
+import "package:expect/expect.dart";
+
class A {
}
diff --git a/tests/compiler/dart2js_native/native_equals_frog_test.dart b/tests/compiler/dart2js_native/native_equals_frog_test.dart
index bc38935..58829c8 100644
--- a/tests/compiler/dart2js_native/native_equals_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_equals_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {}
makeA() native;
diff --git a/tests/compiler/dart2js_native/native_exceptions1_frog_test.dart b/tests/compiler/dart2js_native/native_exceptions1_frog_test.dart
index b2d978b..2d17069 100644
--- a/tests/compiler/dart2js_native/native_exceptions1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_exceptions1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that hidden native exception classes can be marked as existing.
//
// To infer which native hidden types exist, we need
diff --git a/tests/compiler/dart2js_native/native_field_name_test.dart b/tests/compiler/dart2js_native/native_field_name_test.dart
index 5d1e7bc..e73df5c 100644
--- a/tests/compiler/dart2js_native/native_field_name_test.dart
+++ b/tests/compiler/dart2js_native/native_field_name_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Check that native fields are not incorrectly renamed.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_field_rename_1_frog_test.dart b/tests/compiler/dart2js_native/native_field_rename_1_frog_test.dart
index 4d70d50..6bd1fc0 100644
--- a/tests/compiler/dart2js_native/native_field_rename_1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_field_rename_1_frog_test.dart
@@ -6,6 +6,7 @@
// fields. However, native fields keep their name. The implication: a getter
// for the field must be based on the field's name, not the field's jsname.
+import "package:expect/expect.dart";
import 'dart:_js_helper' show JSName;
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_field_rename_2_frog_test.dart b/tests/compiler/dart2js_native/native_field_rename_2_frog_test.dart
index 4b27c16..a26dd1c 100644
--- a/tests/compiler/dart2js_native/native_field_rename_2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_field_rename_2_frog_test.dart
@@ -6,6 +6,7 @@
// fields. However, native fields keep their name. The implication: a getter
// for the field must be based on the field's name, not the field's jsname.
+import "package:expect/expect.dart";
import 'dart:_js_helper' show JSName;
interface I {
diff --git a/tests/compiler/dart2js_native/native_library_same_name_used_frog_test.dart b/tests/compiler/dart2js_native/native_library_same_name_used_frog_test.dart
index 1480dfe..4909259 100644
--- a/tests/compiler/dart2js_native/native_library_same_name_used_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_library_same_name_used_frog_test.dart
@@ -5,6 +5,7 @@
// Test for correct hidden native class when interface has same name.
library main;
+import "package:expect/expect.dart";
import 'native_library_same_name_used_lib1.dart';
void setup() native """
diff --git a/tests/compiler/dart2js_native/native_method_inlining_test.dart b/tests/compiler/dart2js_native/native_method_inlining_test.dart
index f9d34e8..b6da43a 100644
--- a/tests/compiler/dart2js_native/native_method_inlining_test.dart
+++ b/tests/compiler/dart2js_native/native_method_inlining_test.dart
@@ -5,6 +5,8 @@
// Test that native methods with unnamed optional arguments are called with the
// number of arguments in the call site AND the call site is inlined.
+import "package:expect/expect.dart";
+
class A native "*A" {
int foo([x, y, z]) native;
}
diff --git a/tests/compiler/dart2js_native/native_method_rename1_frog_test.dart b/tests/compiler/dart2js_native/native_method_rename1_frog_test.dart
index 93724f4..08df659 100644
--- a/tests/compiler/dart2js_native/native_method_rename1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_method_rename1_frog_test.dart
@@ -4,6 +4,7 @@
// Test the feature where the native string declares the native method's name.
+import "package:expect/expect.dart";
import 'dart:_js_helper' show JSName;
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_method_rename2_frog_test.dart b/tests/compiler/dart2js_native/native_method_rename2_frog_test.dart
index c9908b9..b79f91b 100644
--- a/tests/compiler/dart2js_native/native_method_rename2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_method_rename2_frog_test.dart
@@ -4,6 +4,7 @@
// Test the feature where the native string declares the native method's name.
+import "package:expect/expect.dart";
import 'dart:_js_helper' show JSName;
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_method_rename3_frog_test.dart b/tests/compiler/dart2js_native/native_method_rename3_frog_test.dart
index 10aa736..28329c4 100644
--- a/tests/compiler/dart2js_native/native_method_rename3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_method_rename3_frog_test.dart
@@ -5,6 +5,7 @@
// Test the feature where the native string declares the native method's name.
// #3. The name does not get
+import "package:expect/expect.dart";
import 'dart:_js_helper' show JSName;
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_method_with_keyword_name_test.dart b/tests/compiler/dart2js_native/native_method_with_keyword_name_test.dart
index 3e9ac55..b9a8975 100644
--- a/tests/compiler/dart2js_native/native_method_with_keyword_name_test.dart
+++ b/tests/compiler/dart2js_native/native_method_with_keyword_name_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Make sure we can have a native with a name that is a JavaScript keyword.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_missing_method1_frog_test.dart b/tests/compiler/dart2js_native/native_missing_method1_frog_test.dart
index af8e24b..6f58acd 100644
--- a/tests/compiler/dart2js_native/native_missing_method1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_missing_method1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {
}
diff --git a/tests/compiler/dart2js_native/native_missing_method2_frog_test.dart b/tests/compiler/dart2js_native/native_missing_method2_frog_test.dart
index 89b51dd..fa28fce 100644
--- a/tests/compiler/dart2js_native/native_missing_method2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_missing_method2_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {
}
diff --git a/tests/compiler/dart2js_native/native_mixin_field_test.dart b/tests/compiler/dart2js_native/native_mixin_field_test.dart
index 4cf361e..d17ff62 100644
--- a/tests/compiler/dart2js_native/native_mixin_field_test.dart
+++ b/tests/compiler/dart2js_native/native_mixin_field_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that native classes can use ordinary Dart classes with fields
// as mixins.
diff --git a/tests/compiler/dart2js_native/native_mixin_multiple_test.dart b/tests/compiler/dart2js_native/native_mixin_multiple_test.dart
index bd917cb..fa38c52 100644
--- a/tests/compiler/dart2js_native/native_mixin_multiple_test.dart
+++ b/tests/compiler/dart2js_native/native_mixin_multiple_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that native classes can use ordinary Dart classes as mixins.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_mixin_test.dart b/tests/compiler/dart2js_native/native_mixin_test.dart
index 7dfdd5d..ba36b32 100644
--- a/tests/compiler/dart2js_native/native_mixin_test.dart
+++ b/tests/compiler/dart2js_native/native_mixin_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that native classes can use ordinary Dart classes as mixins.
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_mixin_with_plain_test.dart b/tests/compiler/dart2js_native/native_mixin_with_plain_test.dart
new file mode 100644
index 0000000..da38cb4
--- /dev/null
+++ b/tests/compiler/dart2js_native/native_mixin_with_plain_test.dart
@@ -0,0 +1,105 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Test that native classes and ordinary Dart classes can both use the same
+// ordinary Dart classes as a mixin.
+
+class A native "*A" {
+ final String aa;
+ foo() => "A-foo $aa";
+ baz() => "A-baz $aa";
+}
+
+class B extends A with M native "*B" {
+ bar() => 'B-bar -> ${baz()}';
+ get mm => 'B.mm($aa)';
+}
+
+class M {
+ foo() => "M-foo ${this.mm}";
+ bar() => "M-bar ${this.mm}";
+ get mm => 'M.mm';
+}
+
+class C {
+ final String cc = 'cc';
+ foo() => 'C-foo $cc';
+ baz() => 'C-baz $cc';
+}
+
+class D extends C with M {
+ bar() => 'D-bar -> ${baz()}';
+ get mm => 'D.mm($cc)';
+}
+
+
+makeA() native;
+makeB() native;
+
+void setup() native """
+function A() {this.aa = 'aa'}
+function B() {this.aa = 'bb'}
+makeA = function(){return new A;};
+makeB = function(){return new B;};
+""";
+
+main() {
+ setup();
+ var things = [makeA, makeB, () => new C(), () => new D(), () => new M()]
+ .map((f)=>f())
+ .toList();
+ var a = things[0];
+ var b = things[1];
+ var c = things[2];
+ var d = things[3];
+ var m = things[4];
+
+ Expect.equals("M-foo M.mm", m.foo());
+ Expect.equals("M-bar M.mm", m.bar());
+ Expect.throws(() => m.baz(), (error) => error is NoSuchMethodError);
+ Expect.isFalse(m is A);
+ Expect.isFalse(m is B);
+ Expect.isFalse(m is C);
+ Expect.isFalse(m is D);
+ Expect.isTrue(m is M);
+
+ Expect.equals("A-foo aa", a.foo());
+ Expect.throws(() => a.bar(), (error) => error is NoSuchMethodError);
+ Expect.equals("A-baz aa", a.baz());
+ Expect.isTrue(a is A);
+ Expect.isFalse(a is B);
+ Expect.isFalse(a is C);
+ Expect.isFalse(a is D);
+ Expect.isFalse(a is M);
+
+ Expect.equals("M-foo B.mm(bb)", b.foo());
+ Expect.equals("B-bar -> A-baz bb", b.bar());
+ Expect.equals("A-baz bb", b.baz());
+ Expect.isTrue(b is A);
+ Expect.isTrue(b is B);
+ Expect.isFalse(b is C);
+ Expect.isFalse(b is D);
+ Expect.isTrue(b is M);
+
+ Expect.equals("C-foo cc", c.foo());
+ Expect.throws(() => c.bar(), (error) => error is NoSuchMethodError);
+ Expect.equals("C-baz cc", c.baz());
+ Expect.isFalse(c is A);
+ Expect.isFalse(c is B);
+ Expect.isTrue(c is C);
+ Expect.isFalse(c is D);
+ Expect.isFalse(c is M);
+
+ Expect.equals("M-foo D.mm(cc)", d.foo());
+ Expect.equals("D-bar -> C-baz cc", d.bar());
+ Expect.equals("C-baz cc", d.baz());
+ Expect.isFalse(d is A);
+ Expect.isFalse(d is B);
+ Expect.isTrue(d is C);
+ Expect.isTrue(d is D);
+ Expect.isTrue(d is M);
+
+}
diff --git a/tests/compiler/dart2js_native/native_named_constructors2_frog_test.dart b/tests/compiler/dart2js_native/native_named_constructors2_frog_test.dart
index 964b5c7..f3926d5 100644
--- a/tests/compiler/dart2js_native/native_named_constructors2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_named_constructors2_frog_test.dart
@@ -2,7 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// Native class wwith named constructors and static methods.
+import "package:expect/expect.dart";
+
+// Native class with named constructors and static methods.
+
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_named_constructors3_frog_test.dart b/tests/compiler/dart2js_native/native_named_constructors3_frog_test.dart
index 8148db3..1312f60 100644
--- a/tests/compiler/dart2js_native/native_named_constructors3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_named_constructors3_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Hidden native class with factory constructors and NO static methods.
// Regression test.
diff --git a/tests/compiler/dart2js_native/native_no_such_method_exception2_frog_test.dart b/tests/compiler/dart2js_native/native_no_such_method_exception2_frog_test.dart
index 439efb7..9b980fd 100644
--- a/tests/compiler/dart2js_native/native_no_such_method_exception2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_no_such_method_exception2_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {
}
diff --git a/tests/compiler/dart2js_native/native_no_such_method_exception3_frog_test.dart b/tests/compiler/dart2js_native/native_no_such_method_exception3_frog_test.dart
index bdae2c8..1ea9de0 100644
--- a/tests/compiler/dart2js_native/native_no_such_method_exception3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_no_such_method_exception3_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class GetName {
foo(x, y, [z]) => "foo";
}
diff --git a/tests/compiler/dart2js_native/native_no_such_method_exception4_frog_test.dart b/tests/compiler/dart2js_native/native_no_such_method_exception4_frog_test.dart
index e9621bb..aff196e 100644
--- a/tests/compiler/dart2js_native/native_no_such_method_exception4_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_no_such_method_exception4_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class GetName {
foo(x, y) => "foo";
baz(x, y, z) => "baz";
diff --git a/tests/compiler/dart2js_native/native_no_such_method_exception5_frog_test.dart b/tests/compiler/dart2js_native/native_no_such_method_exception5_frog_test.dart
index 2a44809..26fe5c8 100644
--- a/tests/compiler/dart2js_native/native_no_such_method_exception5_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_no_such_method_exception5_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class GetName {
foo(x, [y]) => "foo";
baz(x, y, z) => "baz";
diff --git a/tests/compiler/dart2js_native/native_no_such_method_exception_frog_test.dart b/tests/compiler/dart2js_native/native_no_such_method_exception_frog_test.dart
index f9be7de..952a4ac 100644
--- a/tests/compiler/dart2js_native/native_no_such_method_exception_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_no_such_method_exception_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {
bar() => 42;
}
diff --git a/tests/compiler/dart2js_native/native_novel_html_test.dart b/tests/compiler/dart2js_native/native_novel_html_test.dart
index 485d2f6..5a29c8f 100644
--- a/tests/compiler/dart2js_native/native_novel_html_test.dart
+++ b/tests/compiler/dart2js_native/native_novel_html_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to see if novel HTML tags are interpreted as HTMLElement.
class Element native "*HTMLElement" {
diff --git a/tests/compiler/dart2js_native/native_null_closure_frog_test.dart b/tests/compiler/dart2js_native/native_null_closure_frog_test.dart
index 53ac384..fbd5d0d 100644
--- a/tests/compiler/dart2js_native/native_null_closure_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_null_closure_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
typedef void MyFunctionType();
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_null_frog_test.dart b/tests/compiler/dart2js_native/native_null_frog_test.dart
index 71066b6..8dde95e 100644
--- a/tests/compiler/dart2js_native/native_null_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_null_frog_test.dart
@@ -2,8 +2,11 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for values of some basic types.
+
class A native "*A" {
returnNull() native;
returnUndefined() native;
diff --git a/tests/compiler/dart2js_native/native_property_frog_test.dart b/tests/compiler/dart2js_native/native_property_frog_test.dart
index cf076b3..e3a647a 100644
--- a/tests/compiler/dart2js_native/native_property_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_property_frog_test.dart
@@ -4,6 +4,7 @@
// Properties on hidden native classes.
+import "package:expect/expect.dart";
import 'dart:_foreign_helper' show JS;
class A native "*A" {
diff --git a/tests/compiler/dart2js_native/native_to_string_frog_test.dart b/tests/compiler/dart2js_native/native_to_string_frog_test.dart
index a21ff2e..1931ed6 100644
--- a/tests/compiler/dart2js_native/native_to_string_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_to_string_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A native "*A" {}
makeA() native;
diff --git a/tests/compiler/dart2js_native/native_use_native_name_in_table_frog_test.dart b/tests/compiler/dart2js_native/native_use_native_name_in_table_frog_test.dart
index d3a81bd..e24cef3 100644
--- a/tests/compiler/dart2js_native/native_use_native_name_in_table_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_use_native_name_in_table_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that we put native names and not Dart names into the dynamic
// dispatch table.
diff --git a/tests/compiler/dart2js_native/native_window1_frog_test.dart b/tests/compiler/dart2js_native/native_window1_frog_test.dart
index e2cdf6e..553f924 100644
--- a/tests/compiler/dart2js_native/native_window1_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_window1_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
interface Window {
final int document;
}
diff --git a/tests/compiler/dart2js_native/native_window2_frog_test.dart b/tests/compiler/dart2js_native/native_window2_frog_test.dart
index bf0d6f0..a58450c 100644
--- a/tests/compiler/dart2js_native/native_window2_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_window2_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
interface Window {
final int document;
}
diff --git a/tests/compiler/dart2js_native/native_wrapping_function3_frog_test.dart b/tests/compiler/dart2js_native/native_wrapping_function3_frog_test.dart
index 335dc01..5350048 100644
--- a/tests/compiler/dart2js_native/native_wrapping_function3_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_wrapping_function3_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
typedef void Callback0();
typedef void Callback1(arg1);
typedef void Callback2(arg1, arg2);
diff --git a/tests/compiler/dart2js_native/native_wrapping_function_frog_test.dart b/tests/compiler/dart2js_native/native_wrapping_function_frog_test.dart
index 0495a5a..b89d515 100644
--- a/tests/compiler/dart2js_native/native_wrapping_function_frog_test.dart
+++ b/tests/compiler/dart2js_native/native_wrapping_function_frog_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
typedef void Callback0();
typedef void Callback1(arg1);
typedef void Callback2(arg1, arg2);
diff --git a/tests/compiler/dart2js_native/undefined_bailout_test.dart b/tests/compiler/dart2js_native/undefined_bailout_test.dart
index d55fe7d..8819be1 100644
--- a/tests/compiler/dart2js_native/undefined_bailout_test.dart
+++ b/tests/compiler/dart2js_native/undefined_bailout_test.dart
@@ -18,6 +18,7 @@
// comparison does not work for undefined, which the DOM sometimes
// returns.
+import "package:expect/expect.dart";
import 'dart:_foreign_helper' show JS;
var a = 42;
diff --git a/tests/corelib/apply2_test.dart b/tests/corelib/apply2_test.dart
index 71c1488..e733a24 100644
--- a/tests/corelib/apply2_test.dart
+++ b/tests/corelib/apply2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
apply(Function function, ArgumentDescriptor args) {
return Function.apply(
function, args.positionalArguments, args.namedArguments);
diff --git a/tests/corelib/apply_test.dart b/tests/corelib/apply_test.dart
index 060d432..71e87b9 100644
--- a/tests/corelib/apply_test.dart
+++ b/tests/corelib/apply_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Testing Function.apply calls correctly.
// This test is not testing error handling, only that correct parameters
// cause a correct call.
diff --git a/tests/corelib/big_integer_vm_test.dart b/tests/corelib/big_integer_vm_test.dart
index 02ee00a..12be55e 100644
--- a/tests/corelib/big_integer_vm_test.dart
+++ b/tests/corelib/big_integer_vm_test.dart
@@ -5,6 +5,7 @@
// TODO(srdjan): Make sure the numbers are Bigint and not Mint or Smi.
library big_integer_test;
+import "package:expect/expect.dart";
class BigIntegerTest {
diff --git a/tests/corelib/bool_hashcode_test.dart b/tests/corelib/bool_hashcode_test.dart
index 63dbcb5..d33b14a 100644
--- a/tests/corelib/bool_hashcode_test.dart
+++ b/tests/corelib/bool_hashcode_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class BoolHashCodeTest {
static testMain() {
Expect.notEquals(true.hashCode, false.hashCode);
diff --git a/tests/corelib/collection_from_test.dart b/tests/corelib/collection_from_test.dart
index 75dbe71..2766887 100644
--- a/tests/corelib/collection_from_test.dart
+++ b/tests/corelib/collection_from_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library collection.from.test;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue;
class CollectionFromTest {
@@ -20,7 +21,7 @@
}
- static check(Collection initial, Collection other) {
+ static check(Iterable initial, Iterable other) {
Expect.equals(3, initial.length);
Expect.equals(initial.length, other.length);
diff --git a/tests/corelib/collection_length_test.dart b/tests/corelib/collection_length_test.dart
index 487884a..01a8061 100644
--- a/tests/corelib/collection_length_test.dart
+++ b/tests/corelib/collection_length_test.dart
@@ -33,7 +33,7 @@
testLength(map.values, n);
}
-void testCollection(Collection collection, n) {
+void testCollection(var collection, n) {
for (int i = 0; i < n; i++) {
collection.add(i);
}
diff --git a/tests/corelib/collection_removes_test.dart b/tests/corelib/collection_removes_test.dart
index 7d04483..47e143d 100644
--- a/tests/corelib/collection_removes_test.dart
+++ b/tests/corelib/collection_removes_test.dart
@@ -2,7 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-testRemove(Collection base) {
+import 'dart:collection';
+import "package:expect/expect.dart";
+
+testRemove(base) {
int length = base.length;
for (int i = 0; i < length; i++) {
Expect.isFalse(base.isEmpty);
@@ -11,7 +14,7 @@
Expect.isTrue(base.isEmpty);
}
-testRemoveAll(Collection base, Iterable removes) {
+testRemoveAll(base, Iterable removes) {
Set retained = new Set();
for (var element in base) {
if (!removes.contains(element)) {
@@ -28,7 +31,7 @@
}
}
-testRetainAll(Collection base, Iterable retains) {
+testRetainAll(base, Iterable retains) {
Set retained = new Set();
for (var element in base) {
if (retains.contains(element)) {
@@ -45,7 +48,7 @@
}
}
-testRemoveWhere(Collection base, bool test(value)) {
+testRemoveWhere(base, bool test(value)) {
Set retained = new Set();
for (var element in base) {
if (!test(element)) {
@@ -62,7 +65,7 @@
}
}
-testRetainWhere(Collection base, bool test(value)) {
+testRetainWhere(base, bool test(value)) {
Set retained = new Set();
for (var element in base) {
if (test(element)) {
@@ -90,13 +93,9 @@
testRemove(base.toSet());
var deltaSet = delta.toSet();
- testRemoveAll(base.toList(), delta);
- testRemoveAll(base.toList(), deltaSet);
- testRetainAll(base.toList(), delta);
- testRetainAll(base.toList(), deltaSet);
testRemoveWhere(base.toList(), deltaSet.contains);
testRetainWhere(base.toList(),
- (e) => !deltaSet.contains(e));
+ (e) => !deltaSet.contains(e));
testRemoveAll(base.toSet(), delta);
testRemoveAll(base.toSet(), deltaSet);
@@ -104,7 +103,21 @@
testRetainAll(base.toSet(), deltaSet);
testRemoveWhere(base.toSet(), deltaSet.contains);
testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e));
+
+ // Test the ListBase class's List implementation.
+ testRemoveWhere(new MyList(base.toList()), deltaSet.contains);
+ testRetainWhere(new MyList(base.toList()),
+ (e) => !deltaSet.contains(e));
+
}
}
}
+class MyList<E> extends ListBase<E> {
+ List<E> _source;
+ MyList(this._source);
+ int get length => _source.length;
+ void set length(int length) { _source.length = length; }
+ E operator[](int index) => _source[index];
+ void operator[]=(int index, E value) { _source[index] = value; }
+}
diff --git a/tests/corelib/collection_test.dart b/tests/corelib/collection_test.dart
index 86f1114..680e20a 100644
--- a/tests/corelib/collection_test.dart
+++ b/tests/corelib/collection_test.dart
@@ -4,16 +4,17 @@
library collection_test;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue;
class CollectionTest {
- CollectionTest(Collection collection) {
- testFold(collection);
+ CollectionTest(Iterable iterable) {
+ testFold(iterable);
}
- void testFold(Collection collection) {
- Expect.equals(28, collection.fold(0, (prev, element) => prev + element));
- Expect.equals(3024, collection.fold(1, (prev, element) => prev * element));
+ void testFold(Iterable iterable) {
+ Expect.equals(28, iterable.fold(0, (prev, element) => prev + element));
+ Expect.equals(3024, iterable.fold(1, (prev, element) => prev * element));
}
}
diff --git a/tests/corelib/collection_to_string_test.dart b/tests/corelib/collection_to_string_test.dart
index cbac852..35fd8f3 100644
--- a/tests/corelib/collection_to_string_test.dart
+++ b/tests/corelib/collection_to_string_test.dart
@@ -8,6 +8,7 @@
library collection_to_string;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue, LinkedHashMap;
import 'dart:math' as Math;
@@ -206,8 +207,8 @@
* and will not contain a collection with ill-defined iteration order
* (i.e., a HashSet or HashMap).
*/
-Collection populateRandomCollection(int size, bool exact,
- StringBuffer stringRep, List beingMade, Collection coll) {
+populateRandomCollection(int size, bool exact,
+ StringBuffer stringRep, List beingMade, var coll) {
beingMade.add(coll);
stringRep.write(coll is List ? '[' : '{');
diff --git a/tests/corelib/compare_to2_test.dart b/tests/corelib/compare_to2_test.dart
index 3d1353c..9946b3f 100644
--- a/tests/corelib/compare_to2_test.dart
+++ b/tests/corelib/compare_to2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing Math.min and Math.max.
+import "package:expect/expect.dart";
+
negate(x) => -x;
main() {
diff --git a/tests/corelib/compare_to_test.dart b/tests/corelib/compare_to_test.dart
index 9c10cf6..35d8f63 100644
--- a/tests/corelib/compare_to_test.dart
+++ b/tests/corelib/compare_to_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing Math.min and Math.max.
+import "package:expect/expect.dart";
+
negate(x) => -x;
main() {
diff --git a/tests/corelib/const_list_literal_test.dart b/tests/corelib/const_list_literal_test.dart
index 31e859e..918503d 100644
--- a/tests/corelib/const_list_literal_test.dart
+++ b/tests/corelib/const_list_literal_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that a final list literal is not expandable nor modifiable.
class ConstListLiteralTest {
diff --git a/tests/corelib/const_list_remove_range_test.dart b/tests/corelib/const_list_remove_range_test.dart
index db38336..cff8a47 100644
--- a/tests/corelib/const_list_remove_range_test.dart
+++ b/tests/corelib/const_list_remove_range_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
testImmutable(const []);
testImmutable(const [1]);
diff --git a/tests/corelib/const_list_set_range_test.dart b/tests/corelib/const_list_set_range_test.dart
index 08062c6..5523844 100644
--- a/tests/corelib/const_list_set_range_test.dart
+++ b/tests/corelib/const_list_set_range_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
testImmutable(const []);
testImmutable(const [1]);
diff --git a/tests/corelib/core_runtime_types_test.dart b/tests/corelib/core_runtime_types_test.dart
index 4c06009..a86b800 100644
--- a/tests/corelib/core_runtime_types_test.dart
+++ b/tests/corelib/core_runtime_types_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
/**
* A test of simple runtime behavior on numbers, strings and lists with
* a focus on both correct behavior and runtime errors.
diff --git a/tests/corelib/corelib.status b/tests/corelib/corelib.status
index 9bc31d7..f83568c 100644
--- a/tests/corelib/corelib.status
+++ b/tests/corelib/corelib.status
@@ -9,6 +9,11 @@
*dartc_test: Skip
compare_to2_test: Fail # Bug 4018
+symbol_test/01: Fail
+symbol_test/02: Fail
+symbol_test/03: Fail
+
+
[ $runtime == ff || $runtime == ie9 || $runtime == jsshell ]
unicode_test: Fail
@@ -49,6 +54,15 @@
string_replace_func_test: Skip # Bug 6554 - doesn't terminate.
+symbol_test/none: Fail
+symbol_test/02: Fail
+symbol_test/03: Fail
+
+
+[ $compiler == dart2js && $unchecked ]
+symbol_test/01: Fail # This passes for the wrong reason in checked mode.
+
+
[ $compiler == dart2js && $runtime == none ]
*: Fail, Pass # TODO(ahe): Triage these tests.
@@ -61,6 +75,11 @@
compare_to2_test: Fail # inherited from VM
unicode_test: Fail # inherited from VM
+symbol_test/01: Fail
+symbol_test/02: Fail
+symbol_test/03: Fail
+
+
# Library changes
[ $compiler == none || $compiler == dart2js || $compiler == dart2dart ]
map_keys2_test: Fail # Generic types aren't right.
@@ -74,6 +93,12 @@
iterable_to_list_test: Fail
iterable_to_set_test: Fail
+[ $compiler == dartc || $compiler == dartanalyzer ]
+symbol_test/01: Fail
+symbol_test/02: Fail
+symbol_test/03: Fail
+
+
[ $arch == arm ]
*: Skip
diff --git a/tests/corelib/date_time2_test.dart b/tests/corelib/date_time2_test.dart
index f179e4d..6a0bb87 100644
--- a/tests/corelib/date_time2_test.dart
+++ b/tests/corelib/date_time2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for DateTime's hashCode.
main() {
diff --git a/tests/corelib/date_time3_test.dart b/tests/corelib/date_time3_test.dart
index c61363f..557eede 100644
--- a/tests/corelib/date_time3_test.dart
+++ b/tests/corelib/date_time3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// At some point dart was emitting a bad padding 0 for Dates where the ms were
// ending with 10.
diff --git a/tests/corelib/date_time4_test.dart b/tests/corelib/date_time4_test.dart
index d536037..7e936ff 100644
--- a/tests/corelib/date_time4_test.dart
+++ b/tests/corelib/date_time4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test fromString with 6 digits after the decimal point.
main() {
diff --git a/tests/corelib/date_time5_test.dart b/tests/corelib/date_time5_test.dart
index 10448e9..abf893d 100644
--- a/tests/corelib/date_time5_test.dart
+++ b/tests/corelib/date_time5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test DateTime constructor with optional arguments.
main() {
diff --git a/tests/corelib/date_time6_test.dart b/tests/corelib/date_time6_test.dart
index 0b6418c..c065705 100644
--- a/tests/corelib/date_time6_test.dart
+++ b/tests/corelib/date_time6_test.dart
@@ -2,28 +2,30 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test DateTime comparison operators.
main() {
var d = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
var d2 = new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true);
- Expect.isTrue(d < d2);
- Expect.isTrue(d <= d2);
- Expect.isTrue(d2 > d);
- Expect.isTrue(d2 >= d);
- Expect.isFalse(d2 < d);
- Expect.isFalse(d2 <= d);
- Expect.isFalse(d > d2);
- Expect.isFalse(d >= d2);
+ Expect.isTrue(d.isBefore(d2));
+ Expect.isTrue(!d.isAfter(d2));
+ Expect.isTrue(d2.isAfter(d));
+ Expect.isTrue(!d2.isBefore(d));
+ Expect.isFalse(d2.isBefore(d));
+ Expect.isFalse(!d2.isAfter(d));
+ Expect.isFalse(d.isAfter(d2));
+ Expect.isFalse(!d.isBefore(d2));
d = new DateTime.fromMillisecondsSinceEpoch(-1, isUtc: true);
d2 = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
- Expect.isTrue(d < d2);
- Expect.isTrue(d <= d2);
- Expect.isTrue(d2 > d);
- Expect.isTrue(d2 >= d);
- Expect.isFalse(d2 < d);
- Expect.isFalse(d2 <= d);
- Expect.isFalse(d > d2);
- Expect.isFalse(d >= d2);
+ Expect.isTrue(d.isBefore(d2));
+ Expect.isTrue(!d.isAfter(d2));
+ Expect.isTrue(d2.isAfter(d));
+ Expect.isTrue(!d2.isBefore(d));
+ Expect.isFalse(d2.isBefore(d));
+ Expect.isFalse(!d2.isAfter(d));
+ Expect.isFalse(d.isAfter(d2));
+ Expect.isFalse(!d.isBefore(d2));
}
diff --git a/tests/corelib/date_time7_test.dart b/tests/corelib/date_time7_test.dart
index 1be867d..b14eb7d 100644
--- a/tests/corelib/date_time7_test.dart
+++ b/tests/corelib/date_time7_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test DateTime timeZoneName and timeZoneOffset getters.
testUtc() {
diff --git a/tests/corelib/date_time8_test.dart b/tests/corelib/date_time8_test.dart
index 2e9ac98..85d573f 100644
--- a/tests/corelib/date_time8_test.dart
+++ b/tests/corelib/date_time8_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Make sure the year 0 is correctly printed.
testUtc() {
diff --git a/tests/corelib/date_time_parse_test.dart b/tests/corelib/date_time_parse_test.dart
index 0df517a..9f0ad76 100644
--- a/tests/corelib/date_time_parse_test.dart
+++ b/tests/corelib/date_time_parse_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
check(DateTime expected, String str) {
DateTime actual = DateTime.parse(str);
Expect.equals(expected, actual); // Only checks if they are at the same time.
diff --git a/tests/corelib/date_time_test.dart b/tests/corelib/date_time_test.dart
index 6150065..805d5c6 100644
--- a/tests/corelib/date_time_test.dart
+++ b/tests/corelib/date_time_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for DateTime.
class DateTest {
@@ -780,32 +782,32 @@
static void testWeekday() {
// 2011-10-06 is Summertime.
var d = new DateTime(2011, 10, 6, 0, 45, 37, 0);
- Expect.equals(DateTime.THU, d.weekday);
+ Expect.equals(DateTime.THURSDAY, d.weekday);
d = new DateTime.utc(2011, 10, 6, 0, 45, 37, 0);
- Expect.equals(DateTime.THU, d.weekday);
+ Expect.equals(DateTime.THURSDAY, d.weekday);
d = new DateTime(2011, 10, 5, 23, 45, 37, 0);
- Expect.equals(DateTime.WED, d.weekday);
+ Expect.equals(DateTime.WEDNESDAY, d.weekday);
d = new DateTime.utc(2011, 10, 5, 23, 45, 37, 0);
- Expect.equals(DateTime.WED, d.weekday);
+ Expect.equals(DateTime.WEDNESDAY, d.weekday);
// 1970-01-01 is Wintertime.
d = new DateTime(1970, 1, 1, 0, 0, 0, 1);
- Expect.equals(DateTime.THU, d.weekday);
+ Expect.equals(DateTime.THURSDAY, d.weekday);
d = new DateTime.utc(1970, 1, 1, 0, 0, 0, 1);
- Expect.equals(DateTime.THU, d.weekday);
+ Expect.equals(DateTime.THURSDAY, d.weekday);
d = new DateTime.utc(1969, 12, 31, 23, 59, 59, 999);
- Expect.equals(DateTime.WED, d.weekday);
+ Expect.equals(DateTime.WEDNESDAY, d.weekday);
d = new DateTime(1969, 12, 31, 23, 59, 59, 999);
- Expect.equals(DateTime.WED, d.weekday);
+ Expect.equals(DateTime.WEDNESDAY, d.weekday);
d = new DateTime(2011, 10, 4, 23, 45, 37, 0);
- Expect.equals(DateTime.TUE, d.weekday);
+ Expect.equals(DateTime.TUESDAY, d.weekday);
d = new DateTime(2011, 10, 3, 23, 45, 37, 0);
- Expect.equals(DateTime.MON, d.weekday);
+ Expect.equals(DateTime.MONDAY, d.weekday);
d = new DateTime(2011, 10, 2, 23, 45, 37, 0);
- Expect.equals(DateTime.SUN, d.weekday);
+ Expect.equals(DateTime.SUNDAY, d.weekday);
d = new DateTime(2011, 10, 1, 23, 45, 37, 0);
- Expect.equals(DateTime.SAT, d.weekday);
+ Expect.equals(DateTime.SATURDAY, d.weekday);
d = new DateTime(2011, 9, 30, 23, 45, 37, 0);
- Expect.equals(DateTime.FRI, d.weekday);
+ Expect.equals(DateTime.FRIDAY, d.weekday);
}
static void testMain() {
diff --git a/tests/corelib/double_ceil2_test.dart b/tests/corelib/double_ceil2_test.dart
index 12d4412..eab3dca 100644
--- a/tests/corelib/double_ceil2_test.dart
+++ b/tests/corelib/double_ceil2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.throws(() => double.INFINITY.ceil(), (e) => e is UnsupportedError);
Expect.throws(() => double.NEGATIVE_INFINITY.ceil(),
diff --git a/tests/corelib/double_ceil_test.dart b/tests/corelib/double_ceil_test.dart
index cb52287..66e83c2 100644
--- a/tests/corelib/double_ceil_test.dart
+++ b/tests/corelib/double_ceil_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.0.ceil());
Expect.equals(1, double.MIN_POSITIVE.ceil());
diff --git a/tests/corelib/double_ceil_to_double_test.dart b/tests/corelib/double_ceil_to_double_test.dart
index 40b2c7d..7400464 100644
--- a/tests/corelib/double_ceil_to_double_test.dart
+++ b/tests/corelib/double_ceil_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.0.ceilToDouble());
Expect.equals(1.0, double.MIN_POSITIVE.ceilToDouble());
diff --git a/tests/corelib/double_compare_test.dart b/tests/corelib/double_compare_test.dart
index 32d50ae..287baac 100644
--- a/tests/corelib/double_compare_test.dart
+++ b/tests/corelib/double_compare_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing 'compare' on doubles.
void main() {
diff --git a/tests/corelib/double_floor2_test.dart b/tests/corelib/double_floor2_test.dart
index b17a375..417d465 100644
--- a/tests/corelib/double_floor2_test.dart
+++ b/tests/corelib/double_floor2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.throws(() => double.INFINITY.floor(), (e) => e is UnsupportedError);
Expect.throws(() => double.NEGATIVE_INFINITY.floor(),
diff --git a/tests/corelib/double_floor_test.dart b/tests/corelib/double_floor_test.dart
index cafc159..c59f411 100644
--- a/tests/corelib/double_floor_test.dart
+++ b/tests/corelib/double_floor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.0.floor());
Expect.equals(0, double.MIN_POSITIVE.floor());
diff --git a/tests/corelib/double_floor_to_double_test.dart b/tests/corelib/double_floor_to_double_test.dart
index cfcc908..e87f6e2 100644
--- a/tests/corelib/double_floor_to_double_test.dart
+++ b/tests/corelib/double_floor_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.0.floorToDouble());
Expect.equals(0.0, double.MIN_POSITIVE.floorToDouble());
diff --git a/tests/corelib/double_round2_test.dart b/tests/corelib/double_round2_test.dart
index 09978ab..2135191 100644
--- a/tests/corelib/double_round2_test.dart
+++ b/tests/corelib/double_round2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.throws(() => double.INFINITY.round(), (e) => e is UnsupportedError);
Expect.throws(() => double.NEGATIVE_INFINITY.round(),
diff --git a/tests/corelib/double_round3_test.dart b/tests/corelib/double_round3_test.dart
index cd1b0a6..5564640 100644
--- a/tests/corelib/double_round3_test.dart
+++ b/tests/corelib/double_round3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.49999999999999994.round());
Expect.equals(0, (-0.49999999999999994).round());
diff --git a/tests/corelib/double_round4_test.dart b/tests/corelib/double_round4_test.dart
index ab546ae..4818bae 100644
--- a/tests/corelib/double_round4_test.dart
+++ b/tests/corelib/double_round4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
diff --git a/tests/corelib/double_round_test.dart b/tests/corelib/double_round_test.dart
index b63887c..ae7fe94 100644
--- a/tests/corelib/double_round_test.dart
+++ b/tests/corelib/double_round_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.0.round());
Expect.equals(0, double.MIN_POSITIVE.round());
diff --git a/tests/corelib/double_round_to_double2_test.dart b/tests/corelib/double_round_to_double2_test.dart
index 9d5d11e..e2ed44a 100644
--- a/tests/corelib/double_round_to_double2_test.dart
+++ b/tests/corelib/double_round_to_double2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.49999999999999994.roundToDouble());
Expect.equals(0.0, (-0.49999999999999994).roundToDouble());
diff --git a/tests/corelib/double_round_to_double3_test.dart b/tests/corelib/double_round_to_double3_test.dart
index 6183ed0..660c7b6 100644
--- a/tests/corelib/double_round_to_double3_test.dart
+++ b/tests/corelib/double_round_to_double3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
// The following numbers are on the border of 52 bits.
// For example: 4503599627370499 + 0.5 => 4503599627370500.
diff --git a/tests/corelib/double_round_to_double_test.dart b/tests/corelib/double_round_to_double_test.dart
index a678248..bedfe18 100644
--- a/tests/corelib/double_round_to_double_test.dart
+++ b/tests/corelib/double_round_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.0.roundToDouble());
Expect.equals(0.0, double.MIN_POSITIVE.roundToDouble());
diff --git a/tests/corelib/double_truncate2_test.dart b/tests/corelib/double_truncate2_test.dart
index 08355b4..675980a 100644
--- a/tests/corelib/double_truncate2_test.dart
+++ b/tests/corelib/double_truncate2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.throws(() => double.INFINITY.truncate(), (e) => e is UnsupportedError);
Expect.throws(() => double.NEGATIVE_INFINITY.truncate(),
diff --git a/tests/corelib/double_truncate_test.dart b/tests/corelib/double_truncate_test.dart
index 8a27ff5..f4f0e79 100644
--- a/tests/corelib/double_truncate_test.dart
+++ b/tests/corelib/double_truncate_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.0.truncate());
Expect.equals(0, double.MIN_POSITIVE.truncate());
diff --git a/tests/corelib/double_truncate_to_double_test.dart b/tests/corelib/double_truncate_to_double_test.dart
index 5689aba..34f0179 100644
--- a/tests/corelib/double_truncate_to_double_test.dart
+++ b/tests/corelib/double_truncate_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.0.truncateToDouble());
Expect.equals(0.0, double.MIN_POSITIVE.truncateToDouble());
diff --git a/tests/corelib/duration_test.dart b/tests/corelib/duration_test.dart
index 51d65c3..6111615 100644
--- a/tests/corelib/duration_test.dart
+++ b/tests/corelib/duration_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
Duration d;
d = new Duration(days: 1);
diff --git a/tests/corelib/exception_implementation_test.dart b/tests/corelib/exception_implementation_test.dart
index d30a392..5df26a7 100644
--- a/tests/corelib/exception_implementation_test.dart
+++ b/tests/corelib/exception_implementation_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library exception_implementation_test;
+import "package:expect/expect.dart";
main() {
final msg = 1;
diff --git a/tests/corelib/expando_test.dart b/tests/corelib/expando_test.dart
index c6b65d8..3bff957 100644
--- a/tests/corelib/expando_test.dart
+++ b/tests/corelib/expando_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ExpandoTest {
static Expando<int> visits;
diff --git a/tests/corelib/expression_test.dart b/tests/corelib/expression_test.dart
index 910a0c2..8a9ced6 100644
--- a/tests/corelib/expression_test.dart
+++ b/tests/corelib/expression_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests basic expressions. Does not attempt to validate the details of arithmetic, coercion, and
// so forth.
class ExpressionTest {
diff --git a/tests/corelib/for_in_test.dart b/tests/corelib/for_in_test.dart
index ea53727..82ea7b9 100644
--- a/tests/corelib/for_in_test.dart
+++ b/tests/corelib/for_in_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ForInTest {
static testMain() {
testSimple();
diff --git a/tests/corelib/has_next_iterator_test.dart b/tests/corelib/has_next_iterator_test.dart
index 299e11d..bd8a0f3 100644
--- a/tests/corelib/has_next_iterator_test.dart
+++ b/tests/corelib/has_next_iterator_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library hasNextIterator.test;
+import "package:expect/expect.dart";
import 'dart:collection';
main() {
diff --git a/tests/corelib/hash_map2_test.dart b/tests/corelib/hash_map2_test.dart
index 9f81c9f..cc4ed3e 100644
--- a/tests/corelib/hash_map2_test.dart
+++ b/tests/corelib/hash_map2_test.dart
@@ -6,6 +6,7 @@
// modification errors.
library hash_map2_test;
+import "package:expect/expect.dart";
import 'dart:collection';
testMap(Map newMap(), Map newMapFrom(Map map)) {
diff --git a/tests/corelib/hash_map_test.dart b/tests/corelib/hash_map_test.dart
index 8d92047..1bdc7be 100644
--- a/tests/corelib/hash_map_test.dart
+++ b/tests/corelib/hash_map_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test program for the HashMap class.
class HashMapTest {
diff --git a/tests/corelib/hash_set_test.dart b/tests/corelib/hash_set_test.dart
index 68a0844..ee4bd16 100644
--- a/tests/corelib/hash_set_test.dart
+++ b/tests/corelib/hash_set_test.dart
@@ -6,6 +6,7 @@
// modification errors.
library hash_map2_test;
+import "package:expect/expect.dart";
import 'dart:collection';
testSet(Set newSet(), Set newSetFrom(Set from)) {
@@ -187,6 +188,34 @@
Expect.equals(127, set.length);
Expect.isFalse(set.contains(null));
}
+
+ { // Check that addAll and clear works.
+ Set set = newSet();
+ set.addAll([]);
+ Expect.isTrue(set.isEmpty);
+ set.addAll([1, 3, 2]);
+ Expect.equals(3, set.length);
+ Expect.isTrue(set.contains(1));
+ Expect.isTrue(set.contains(3));
+ Expect.isTrue(set.contains(2));
+ Expect.isFalse(set.contains(4));
+ set.clear();
+ Expect.isTrue(set.isEmpty);
+ }
+
+ { // Check that removeWhere and retainWhere work.
+ Set set = newSetFrom([1, 2, 3]);
+ set.removeWhere((each) => each == 2);
+ Expect.equals(2, set.length);
+ Expect.isTrue(set.contains(1));
+ Expect.isFalse(set.contains(2));
+ Expect.isTrue(set.contains(3));
+ set.retainWhere((each) => each == 3);
+ Expect.equals(1, set.length);
+ Expect.isFalse(set.contains(1));
+ Expect.isFalse(set.contains(2));
+ Expect.isTrue(set.contains(3));
+ }
}
void main() {
diff --git a/tests/corelib/indexed_list_access_test.dart b/tests/corelib/indexed_list_access_test.dart
index 2feab1e..4cbc645 100644
--- a/tests/corelib/indexed_list_access_test.dart
+++ b/tests/corelib/indexed_list_access_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Check that indexed access to lists throws correct exception if index
// is not int.
diff --git a/tests/corelib/int_ceil_test.dart b/tests/corelib/int_ceil_test.dart
index ab10766..9b6a4de 100644
--- a/tests/corelib/int_ceil_test.dart
+++ b/tests/corelib/int_ceil_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.ceil());
Expect.equals(1, 1.ceil());
diff --git a/tests/corelib/int_ceil_to_double_test.dart b/tests/corelib/int_ceil_to_double_test.dart
index 0c0e097..c5220e6 100644
--- a/tests/corelib/int_ceil_to_double_test.dart
+++ b/tests/corelib/int_ceil_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.ceilToDouble());
Expect.equals(1.0, 1.ceilToDouble());
diff --git a/tests/corelib/int_floor_test.dart b/tests/corelib/int_floor_test.dart
index 2f6bc53..3e0cf21 100644
--- a/tests/corelib/int_floor_test.dart
+++ b/tests/corelib/int_floor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.floor());
Expect.equals(1, 1.floor());
diff --git a/tests/corelib/int_floor_to_double_test.dart b/tests/corelib/int_floor_to_double_test.dart
index 506092a..478e0e6 100644
--- a/tests/corelib/int_floor_to_double_test.dart
+++ b/tests/corelib/int_floor_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.floorToDouble());
Expect.equals(1.0, 1.floorToDouble());
diff --git a/tests/corelib/int_parse_radix_test.dart b/tests/corelib/int_parse_radix_test.dart
index a59ee60..e934651 100644
--- a/tests/corelib/int_parse_radix_test.dart
+++ b/tests/corelib/int_parse_radix_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void main() {
bool checkedMode = false;
assert(checkedMode = true);
diff --git a/tests/corelib/int_round_test.dart b/tests/corelib/int_round_test.dart
index c2edc73..df71b3c 100644
--- a/tests/corelib/int_round_test.dart
+++ b/tests/corelib/int_round_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.round());
Expect.equals(1, 1.round());
diff --git a/tests/corelib/int_round_to_double_test.dart b/tests/corelib/int_round_to_double_test.dart
index 39122a4..cc2a4ca 100644
--- a/tests/corelib/int_round_to_double_test.dart
+++ b/tests/corelib/int_round_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.roundToDouble());
Expect.equals(1.0, 1.roundToDouble());
diff --git a/tests/corelib/int_to_int_test.dart b/tests/corelib/int_to_int_test.dart
index 7a16e4a..4e7e93b 100644
--- a/tests/corelib/int_to_int_test.dart
+++ b/tests/corelib/int_to_int_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.toInt());
Expect.equals(1, 1.toInt());
diff --git a/tests/corelib/int_truncate_test.dart b/tests/corelib/int_truncate_test.dart
index 67bdef6..9610253 100644
--- a/tests/corelib/int_truncate_test.dart
+++ b/tests/corelib/int_truncate_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0, 0.truncate());
Expect.equals(1, 1.truncate());
diff --git a/tests/corelib/int_truncate_to_double_test.dart b/tests/corelib/int_truncate_to_double_test.dart
index 628fa8a..3ec2d61 100644
--- a/tests/corelib/int_truncate_to_double_test.dart
+++ b/tests/corelib/int_truncate_to_double_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
Expect.equals(0.0, 0.truncateToDouble());
Expect.equals(1.0, 1.truncateToDouble());
diff --git a/tests/corelib/integer_to_radix_string_test.dart b/tests/corelib/integer_to_radix_string_test.dart
index a8cafb5..34db6fb 100644
--- a/tests/corelib/integer_to_radix_string_test.dart
+++ b/tests/corelib/integer_to_radix_string_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
// Test that we accept radix 2 to 36 and that we use lower-case
// letters.
diff --git a/tests/corelib/is_operator_basic_types_test.dart b/tests/corelib/is_operator_basic_types_test.dart
index 662b2a4..4c0aea9 100644
--- a/tests/corelib/is_operator_basic_types_test.dart
+++ b/tests/corelib/is_operator_basic_types_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for the "is" type test operator.
+import "package:expect/expect.dart";
+
check(args) {
var list = args[0];
var string = args[1];
@@ -10,14 +12,12 @@
Expect.isTrue(list is Object);
Expect.isTrue(list is List);
- Expect.isTrue(list is Collection);
Expect.isTrue(list is Iterable);
Expect.isFalse(list is Comparable);
Expect.isFalse(list is Pattern);
Expect.isFalse(list is String);
Expect.isFalse(list is !List);
- Expect.isFalse(list is !Collection);
Expect.isFalse(list is !Iterable);
Expect.isTrue(list is !Comparable);
Expect.isTrue(list is !Pattern);
@@ -25,14 +25,12 @@
Expect.isTrue(string is Object);
Expect.isFalse(string is List);
- Expect.isFalse(string is Collection);
Expect.isFalse(string is Iterable);
Expect.isTrue(string is Comparable);
Expect.isTrue(string is Pattern);
Expect.isTrue(string is String);
Expect.isTrue(string is !List);
- Expect.isTrue(string is !Collection);
Expect.isTrue(string is !Iterable);
Expect.isFalse(string is !Comparable);
Expect.isFalse(string is !Pattern);
@@ -40,14 +38,12 @@
Expect.isTrue(nullObject is Object);
Expect.isFalse(nullObject is List);
- Expect.isFalse(nullObject is Collection);
Expect.isFalse(nullObject is Iterable);
Expect.isFalse(nullObject is Comparable);
Expect.isFalse(nullObject is Pattern);
Expect.isFalse(nullObject is String);
Expect.isTrue(nullObject is !List);
- Expect.isTrue(nullObject is !Collection);
Expect.isTrue(nullObject is !Iterable);
Expect.isTrue(nullObject is !Comparable);
Expect.isTrue(nullObject is !Pattern);
diff --git a/tests/corelib/collection_contains_test.dart b/tests/corelib/iterable_contains_test.dart
similarity index 97%
rename from tests/corelib/collection_contains_test.dart
rename to tests/corelib/iterable_contains_test.dart
index 168855b..bfb7038 100644
--- a/tests/corelib/collection_contains_test.dart
+++ b/tests/corelib/iterable_contains_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests for the contains methods on lists.
test(list, notInList) {
diff --git a/tests/corelib/iterable_element_at_test.dart b/tests/corelib/iterable_element_at_test.dart
index 2dd6920..5f46958 100644
--- a/tests/corelib/iterable_element_at_test.dart
+++ b/tests/corelib/iterable_element_at_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
diff --git a/tests/corelib/iterable_expand_test.dart b/tests/corelib/iterable_expand_test.dart
index 67aaf5b..5737a9b 100644
--- a/tests/corelib/iterable_expand_test.dart
+++ b/tests/corelib/iterable_expand_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
test(expectation, iterable) {
Expect.listEquals(expectation, iterable.toList());
diff --git a/tests/corelib/iterable_first_test.dart b/tests/corelib/iterable_first_test.dart
index 44945a5..0ccd036 100644
--- a/tests/corelib/iterable_first_test.dart
+++ b/tests/corelib/iterable_first_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_first_where_test.dart b/tests/corelib/iterable_first_where_test.dart
index 2b70053..d8ee32c 100644
--- a/tests/corelib/iterable_first_where_test.dart
+++ b/tests/corelib/iterable_first_where_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_join_test.dart b/tests/corelib/iterable_join_test.dart
index 96922a9..e374be4 100644
--- a/tests/corelib/iterable_join_test.dart
+++ b/tests/corelib/iterable_join_test.dart
@@ -2,13 +2,19 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class IC {
int count = 0;
String toString() => "${count++}";
}
-testJoin(String expect, Iterable iterable, [String separator]) {
- Expect.equals(expect, iterable.join(separator));
+testJoin(String expect, Iterable iterable, [String separator = ""]) {
+ if (?separator) {
+ Expect.equals(expect, iterable.join(separator));
+ } else {
+ Expect.equals(expect, iterable.join());
+ }
}
testCollections() {
diff --git a/tests/corelib/iterable_last_test.dart b/tests/corelib/iterable_last_test.dart
index 24539bf..dd9f0da 100644
--- a/tests/corelib/iterable_last_test.dart
+++ b/tests/corelib/iterable_last_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_last_where_test.dart b/tests/corelib/iterable_last_where_test.dart
index 5544cd3..98c3daf 100644
--- a/tests/corelib/iterable_last_where_test.dart
+++ b/tests/corelib/iterable_last_where_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
diff --git a/tests/corelib/iterable_length_test.dart b/tests/corelib/iterable_length_test.dart
index e70f82f..225d398 100644
--- a/tests/corelib/iterable_length_test.dart
+++ b/tests/corelib/iterable_length_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A extends Iterable {
int count;
A(this.count);
diff --git a/tests/corelib/iterable_mapping_test.dart b/tests/corelib/iterable_mapping_test.dart
index eae0a2d..0830a7d 100644
--- a/tests/corelib/iterable_mapping_test.dart
+++ b/tests/corelib/iterable_mapping_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_min_max_test.dart b/tests/corelib/iterable_min_max_test.dart
deleted file mode 100644
index 1a8c4fd..0000000
--- a/tests/corelib/iterable_min_max_test.dart
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library iterable_min_max_test;
-
-import "dart:collection";
-
-class C {
- final x;
- const C(this.x);
- int get hashCode => x.hashCode;
- bool operator==(var other) => other is C && x == other.x;
-}
-
-const inf = double.INFINITY;
-
-var intList = const [0, 1, -1, -5, 5, -1000, 1000, -7, 7];
-var doubleList = const [-0.0, 0.0, -1.0, 1.0, -1000.0, 1000.0, -inf, inf];
-var stringList = const ["bbb", "bba", "bab", "abb", "bbc", "bcb", "cbb", "bb"];
-var cList = const [const C(5), const C(3), const C(8),
- const C(0), const C(10), const C(6)];
-int compareC(C a, C b) => a.x.compareTo(b.x);
-
-
-testMinMax(iterable, min, max) {
- Expect.equals(min, iterable.min());
- Expect.equals(min, iterable.min(Comparable.compare));
- Expect.equals(min, IterableMixinWorkaround.min(iterable));
- Expect.equals(min, IterableMixinWorkaround.min(iterable, Comparable.compare));
- Expect.equals(max, iterable.min((a, b) => Comparable.compare(b, a)));
-
- Expect.equals(max, iterable.max());
- Expect.equals(max, iterable.max(Comparable.compare));
- Expect.equals(max, IterableMixinWorkaround.max(iterable));
- Expect.equals(max, IterableMixinWorkaround.max(iterable, Comparable.compare));
- Expect.equals(min, iterable.max((a, b) => Comparable.compare(b, a)));
-}
-
-
-main() {
- testMinMax(const [], null, null);
- testMinMax([], null, null);
- testMinMax(new Set(), null, null);
-
- testMinMax(intList, -1000, 1000); // Const list.
- testMinMax(new List.from(intList), -1000, 1000); // Non-const list.
- testMinMax(new Set.from(intList), -1000, 1000); // Set.
-
- testMinMax(doubleList, -inf, inf);
- testMinMax(new List.from(doubleList), -inf, inf);
- testMinMax(new Set.from(doubleList), -inf, inf);
-
- testMinMax(stringList, "abb", "cbb");
- testMinMax(new List.from(stringList), "abb", "cbb");
- testMinMax(new Set.from(stringList), "abb", "cbb");
-
- // Objects that are not Comparable.
- Expect.equals(const C(0), cList.min(compareC));
- Expect.equals(const C(0), IterableMixinWorkaround.min(cList, compareC));
- Expect.equals(const C(0), new List.from(cList).min(compareC));
- Expect.equals(const C(0), IterableMixinWorkaround.min(new List.from(cList), compareC));
- Expect.equals(const C(0), new Set.from(cList).min(compareC));
- Expect.equals(const C(0), IterableMixinWorkaround.min(new Set.from(cList), compareC));
-
- Expect.equals(const C(10), cList.max(compareC));
- Expect.equals(const C(10), IterableMixinWorkaround.max(cList, compareC));
- Expect.equals(const C(10), new List.from(cList).max(compareC));
- Expect.equals(const C(10), IterableMixinWorkaround.max(new List.from(cList), compareC));
- Expect.equals(const C(10), new Set.from(cList).max(compareC));
- Expect.equals(const C(10), IterableMixinWorkaround.max(new Set.from(cList), compareC));
-
- bool checkedMode = false;
- assert(checkedMode = true);
- Expect.throws(cList.min, (e) => checkedMode ? e is TypeError
- : e is NoSuchMethodError);
- Expect.throws(cList.max, (e) => checkedMode ? e is TypeError
- : e is NoSuchMethodError);
-}
-
diff --git a/tests/corelib/iterable_single_test.dart b/tests/corelib/iterable_single_test.dart
index 9c3b09a..7efe645 100644
--- a/tests/corelib/iterable_single_test.dart
+++ b/tests/corelib/iterable_single_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1a = <int>[1];
List<int> list1b = <int>[1, 2, 3];
diff --git a/tests/corelib/iterable_single_where_test.dart b/tests/corelib/iterable_single_where_test.dart
index ded576b..e6fe7d9 100644
--- a/tests/corelib/iterable_single_where_test.dart
+++ b/tests/corelib/iterable_single_where_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5, 6];
diff --git a/tests/corelib/iterable_skip_test.dart b/tests/corelib/iterable_skip_test.dart
index b02e72a..2910d3b 100644
--- a/tests/corelib/iterable_skip_test.dart
+++ b/tests/corelib/iterable_skip_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_skip_while_test.dart b/tests/corelib/iterable_skip_while_test.dart
index 4ddc5fa..d812300 100644
--- a/tests/corelib/iterable_skip_while_test.dart
+++ b/tests/corelib/iterable_skip_while_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_take_test.dart b/tests/corelib/iterable_take_test.dart
index 3910769..eda953a 100644
--- a/tests/corelib/iterable_take_test.dart
+++ b/tests/corelib/iterable_take_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_take_while_test.dart b/tests/corelib/iterable_take_while_test.dart
index 6fbc08d..3fb615e 100644
--- a/tests/corelib/iterable_take_while_test.dart
+++ b/tests/corelib/iterable_take_while_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_test.dart b/tests/corelib/iterable_test.dart
index 6b8fe13..51e363d 100644
--- a/tests/corelib/iterable_test.dart
+++ b/tests/corelib/iterable_test.dart
@@ -5,6 +5,8 @@
// Regression test for dart2js where [List.addAll] was not typed
// correctly.
+import "package:expect/expect.dart";
+
class MyIterable implements Iterable {
get iterator => [].iterator;
}
diff --git a/tests/corelib/iterable_to_list_test.dart b/tests/corelib/iterable_to_list_test.dart
index 6cb3c52..6a5c454 100644
--- a/tests/corelib/iterable_to_list_test.dart
+++ b/tests/corelib/iterable_to_list_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 5];
diff --git a/tests/corelib/iterable_to_set_test.dart b/tests/corelib/iterable_to_set_test.dart
index a8188b8..ee1bcfd 100644
--- a/tests/corelib/iterable_to_set_test.dart
+++ b/tests/corelib/iterable_to_set_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
List<int> list1 = <int>[1, 2, 3];
List<int> list2 = const <int>[4, 4];
diff --git a/tests/corelib/json_test.dart b/tests/corelib/json_test.dart
index 5a36d99..f22cb98 100644
--- a/tests/corelib/json_test.dart
+++ b/tests/corelib/json_test.dart
@@ -4,6 +4,7 @@
library json_test;
+import "package:expect/expect.dart";
import "dart:json";
bool badFormat(e) => e is FormatException;
diff --git a/tests/corelib/linked_hash_map_test.dart b/tests/corelib/linked_hash_map_test.dart
index 54eddeb..dfefca4 100644
--- a/tests/corelib/linked_hash_map_test.dart
+++ b/tests/corelib/linked_hash_map_test.dart
@@ -4,6 +4,7 @@
// Dart test for linked hash-maps.
library linkedHashMap.test;
+import "package:expect/expect.dart";
import 'dart:collection' show LinkedHashMap;
class LinkedHashMapTest {
diff --git a/tests/corelib/list_as_map_test.dart b/tests/corelib/list_as_map_test.dart
index 03f5540..51e637f 100644
--- a/tests/corelib/list_as_map_test.dart
+++ b/tests/corelib/list_as_map_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void testListMapCorrespondence(List list, Map map) {
Expect.equals(list.length, map.length);
for (int i = 0; i < list.length; i++) {
diff --git a/tests/corelib/list_first_test.dart b/tests/corelib/list_first_test.dart
index c0795a4..74be981 100644
--- a/tests/corelib/list_first_test.dart
+++ b/tests/corelib/list_first_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void test(List list) {
if (list.isEmpty) {
Expect.throws(() => list.first, (e) => e is StateError);
diff --git a/tests/corelib/list_fixed_test.dart b/tests/corelib/list_fixed_test.dart
index c29d8ea..5950ec3 100644
--- a/tests/corelib/list_fixed_test.dart
+++ b/tests/corelib/list_fixed_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a;
diff --git a/tests/corelib/list_get_range_test.dart b/tests/corelib/list_get_range_test.dart
index 07ffa56..221931c 100644
--- a/tests/corelib/list_get_range_test.dart
+++ b/tests/corelib/list_get_range_test.dart
@@ -2,55 +2,71 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-main() {
- Expect.listEquals([], [].sublist(0, 0));
- Expect.listEquals([], const [].sublist(0, 0));
+import "package:expect/expect.dart";
+testGetRange(list, start, end, bool isModifiable) {
+ expectRE(() { list.getRange(-1, 0); });
+ expectRE(() { list.getRange(0, -1); });
+ expectRE(() { list.getRange(1, 0); });
+ expectRE(() { list.getRange(0, list.length + 1); });
+ expectRE(() { list.getRange(list.length + 1, list.length + 1); });
+ Iterable iterable = list.getRange(start, end);
+ Expect.isFalse(iterable is List);
+ if (start == end) {
+ Expect.isTrue(iterable.isEmpty);
+ return;
+ }
- Expect.listEquals([1, 2], [1, 2].sublist(0, 2));
- Expect.listEquals([1, 2], const [1, 2].sublist(0, 2));
+ var iterator = iterable.iterator;
+ for (int i = start; i < end; i++) {
+ Expect.isTrue(iterator.moveNext());
+ Expect.equals(iterator.current, list[i]);
+ }
+ Expect.isFalse(iterator.moveNext());
- Expect.listEquals([1], [1, 2].sublist(0, 1));
- Expect.listEquals([1], const [1, 2].sublist(0, 1));
+ if (isModifiable) {
+ for (int i = 0; i < list.length; i++) {
+ list[i]++;
+ }
- Expect.listEquals([2], [1, 2].sublist(1, 2));
- Expect.listEquals([2], const [1, 2].sublist(1, 2));
-
- Expect.listEquals([], [1, 2].sublist(0, 0));
- Expect.listEquals([], const [1, 2].sublist(0, 0));
-
- Expect.listEquals([2, 3], [1, 2, 3, 4].sublist(1, 3));
- Expect.listEquals([2, 3], const [1, 2, 3, 4].sublist(1, 3));
-
- Expect.listEquals([2, 3], [1, 2, 3, 4].sublist(1, 3));
- Expect.listEquals([2, 3], const [1, 2, 3, 4].sublist(1, 3));
-
- expectAE(() => [].sublist(-1, null));
- expectAE(() => const [].sublist(-1, null));
- expectAE(() => [].sublist(-1, 0));
- expectAE(() => const [].sublist(-1, 0));
- expectAE(() => [].sublist(-1, -1));
- expectAE(() => const [].sublist(-1, -1));
- expectAE(() => [].sublist(-1, 1));
- expectAE(() => const [].sublist(-1, 1));
- expectAE(() => [].sublist(0, -1));
- expectAE(() => const [].sublist(0, -1));
- expectAE(() => [].sublist(0, 1));
- expectAE(() => const [].sublist(0, 1));
- expectAE(() => [].sublist(1, null));
- expectAE(() => const [].sublist(1, null));
- expectAE(() => [].sublist(1, 0));
- expectAE(() => const [].sublist(1, 0));
- expectAE(() => [].sublist(1, -1));
- expectAE(() => const [].sublist(1, -1));
- expectAE(() => [].sublist(1, 1));
- expectAE(() => const [].sublist(1, 1));
-
- expectAE(() => [1].sublist(0, 2));
- expectAE(() => [1].sublist(1, 2));
- expectAE(() => [1].sublist(1, 0));
+ iterator = iterable.iterator;
+ for (int i = start; i < end; i++) {
+ Expect.isTrue(iterator.moveNext());
+ Expect.equals(iterator.current, list[i]);
+ }
+ }
}
-void expectAE(Function f) {
- Expect.throws(f, (e) => e is ArgumentError);
+main() {
+ testGetRange([1, 2], 0, 1, true);
+ testGetRange([], 0, 0, true);
+ testGetRange([1, 2, 3], 0, 0, true);
+ testGetRange([1, 2, 3], 1, 3, true);
+ testGetRange(const [1, 2], 0, 1, false);
+ testGetRange(const [], 0, 0, false);
+ testGetRange(const [1, 2, 3], 0, 0, false);
+ testGetRange(const [1, 2, 3], 1, 3, false);
+ testGetRange("abcd".codeUnits, 0, 1, false);
+ testGetRange("abcd".codeUnits, 0, 0, false);
+ testGetRange("abcd".codeUnits, 1, 3, false);
+
+ expectRE(() => [1].getRange(-1, 1));
+ expectRE(() => [3].getRange(0, -1));
+ expectRE(() => [4].getRange(1, 0));
+
+ var list = [1, 2, 3, 4];
+ var iterable = list.getRange(1, 3);
+ Expect.equals(2, iterable.first);
+ Expect.equals(3, iterable.last);
+ list.length = 1;
+ Expect.isTrue(iterable.isEmpty);
+ list.add(99);
+ Expect.equals(99, iterable.single);
+ list.add(499);
+ Expect.equals(499, iterable.last);
+ Expect.equals(2, iterable.length);
+}
+
+void expectRE(Function f) {
+ Expect.throws(f, (e) => e is RangeError);
}
diff --git a/tests/corelib/list_growable_test.dart b/tests/corelib/list_growable_test.dart
index 563f187..7ce723e 100644
--- a/tests/corelib/list_growable_test.dart
+++ b/tests/corelib/list_growable_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a;
a = new List();
diff --git a/tests/corelib/list_index_of_test.dart b/tests/corelib/list_index_of_test.dart
index ca8ab4c..4641adc 100644
--- a/tests/corelib/list_index_of_test.dart
+++ b/tests/corelib/list_index_of_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ListIndexOfTest {
static testMain() {
test(new List<int>(5));
diff --git a/tests/corelib/list_insert_range_test.dart b/tests/corelib/list_insert_range_test.dart
index 26e48cf..8670c62 100644
--- a/tests/corelib/list_insert_range_test.dart
+++ b/tests/corelib/list_insert_range_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var list = [];
list.insertRange(-1, 0);
diff --git a/tests/corelib/list_insert_test.dart b/tests/corelib/list_insert_test.dart
index 7d3a722..adfd677 100644
--- a/tests/corelib/list_insert_test.dart
+++ b/tests/corelib/list_insert_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
void main() {
// Normal modifiable list.
var l1 = [0, 1, 2, 3, 4];
diff --git a/tests/corelib/list_iterators_test.dart b/tests/corelib/list_iterators_test.dart
index e7ed128..092082e 100644
--- a/tests/corelib/list_iterators_test.dart
+++ b/tests/corelib/list_iterators_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ListIteratorsTest {
static void checkListIterator(List a) {
Iterator it = a.iterator;
diff --git a/tests/corelib/list_last_test.dart b/tests/corelib/list_last_test.dart
index 4d9b53a..0733335 100644
--- a/tests/corelib/list_last_test.dart
+++ b/tests/corelib/list_last_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void test(List list) {
if (list.isEmpty) {
Expect.throws(() => list.last, (e) => e is StateError);
diff --git a/tests/corelib/list_literal_is_growable_test.dart b/tests/corelib/list_literal_is_growable_test.dart
index 5721eb7..061a72d 100644
--- a/tests/corelib/list_literal_is_growable_test.dart
+++ b/tests/corelib/list_literal_is_growable_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var l = [];
l.add(1);
diff --git a/tests/corelib/list_literal_test.dart b/tests/corelib/list_literal_test.dart
index 9a4f1bc..c333b8f 100644
--- a/tests/corelib/list_literal_test.dart
+++ b/tests/corelib/list_literal_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that a list literal is expandable and modifiable.
class ListLiteralTest {
diff --git a/tests/corelib/list_map_test.dart b/tests/corelib/list_map_test.dart
index 31d3439..8bd05eb 100644
--- a/tests/corelib/list_map_test.dart
+++ b/tests/corelib/list_map_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
main() {
testOperations();
@@ -113,9 +114,7 @@
testOp((i) => i.any((n) => n < 10), "any<10");
testOp((i) => i.every((n) => n < 5), "every<5");
testOp((i) => i.every((n) => n < 10), "every<10");
- testOp((i) => i.max(), "max");
- testOp((i) => i.min(), "min");
- testOp((i) => i.reduce(0, (a, b) => a + b), "reduce-sum");
+ testOp((i) => i.reduce((a, b) => a + b), "reduce-sum");
testOp((i) => i.fold(0, (a, b) => a + b), "fold-sum");
testOp((i) => i.join("-"), "join-");
testOp((i) => i.join(""), "join");
diff --git a/tests/corelib/list_remove_range_test.dart b/tests/corelib/list_remove_range_test.dart
index 4e41ef6..b4fa04f 100644
--- a/tests/corelib/list_remove_range_test.dart
+++ b/tests/corelib/list_remove_range_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var list = [];
list.removeRange(0, 0);
diff --git a/tests/corelib/list_removeat_test.dart b/tests/corelib/list_removeat_test.dart
index d6a9b28..d8dbf88 100644
--- a/tests/corelib/list_removeat_test.dart
+++ b/tests/corelib/list_removeat_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void main() {
// Normal modifiable list.
var l1 = [0, 1, 2, 3, 4];
diff --git a/tests/corelib/list_reversed_test.dart b/tests/corelib/list_reversed_test.dart
index 99f7b99..ea1e780 100644
--- a/tests/corelib/list_reversed_test.dart
+++ b/tests/corelib/list_reversed_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
testOperations();
@@ -104,9 +106,7 @@
testOp((i) => i.any((n) => n < 10), "any<10");
testOp((i) => i.every((n) => n < 5), "every<5");
testOp((i) => i.every((n) => n < 10), "every<10");
- testOp((i) => i.max(), "max");
- testOp((i) => i.min(), "min");
- testOp((i) => i.reduce(0, (a, b) => a + b), "reduce-sum");
+ testOp((i) => i.reduce((a, b) => a + b), "reduce-sum");
testOp((i) => i.fold(0, (a, b) => a + b), "fold-sum");
testOp((i) => i.join("-"), "join-");
testOp((i) => i.join(""), "join");
diff --git a/tests/corelib/list_set_range_test.dart b/tests/corelib/list_set_range_test.dart
index f96ede5..a693584 100644
--- a/tests/corelib/list_set_range_test.dart
+++ b/tests/corelib/list_set_range_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var list = [];
list.setRange(0, 0, const []);
diff --git a/tests/corelib/list_sublist_test.dart b/tests/corelib/list_sublist_test.dart
new file mode 100644
index 0000000..0581473
--- /dev/null
+++ b/tests/corelib/list_sublist_test.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+main() {
+ Expect.listEquals([], [].sublist(0, 0));
+ Expect.listEquals([], const [].sublist(0, 0));
+
+
+ Expect.listEquals([1, 2], [1, 2].sublist(0, 2));
+ Expect.listEquals([1, 2], const [1, 2].sublist(0, 2));
+
+ Expect.listEquals([1], [1, 2].sublist(0, 1));
+ Expect.listEquals([1], const [1, 2].sublist(0, 1));
+
+ Expect.listEquals([2], [1, 2].sublist(1, 2));
+ Expect.listEquals([2], const [1, 2].sublist(1, 2));
+
+ Expect.listEquals([], [1, 2].sublist(0, 0));
+ Expect.listEquals([], const [1, 2].sublist(0, 0));
+
+ Expect.listEquals([2, 3], [1, 2, 3, 4].sublist(1, 3));
+ Expect.listEquals([2, 3], const [1, 2, 3, 4].sublist(1, 3));
+
+ Expect.listEquals([2, 3], [1, 2, 3, 4].sublist(1, 3));
+ Expect.listEquals([2, 3], const [1, 2, 3, 4].sublist(1, 3));
+
+ expectAE(() => [].sublist(-1, null));
+ expectAE(() => const [].sublist(-1, null));
+ expectAE(() => [].sublist(-1, 0));
+ expectAE(() => const [].sublist(-1, 0));
+ expectAE(() => [].sublist(-1, -1));
+ expectAE(() => const [].sublist(-1, -1));
+ expectAE(() => [].sublist(-1, 1));
+ expectAE(() => const [].sublist(-1, 1));
+ expectAE(() => [].sublist(0, -1));
+ expectAE(() => const [].sublist(0, -1));
+ expectAE(() => [].sublist(0, 1));
+ expectAE(() => const [].sublist(0, 1));
+ expectAE(() => [].sublist(1, null));
+ expectAE(() => const [].sublist(1, null));
+ expectAE(() => [].sublist(1, 0));
+ expectAE(() => const [].sublist(1, 0));
+ expectAE(() => [].sublist(1, -1));
+ expectAE(() => const [].sublist(1, -1));
+ expectAE(() => [].sublist(1, 1));
+ expectAE(() => const [].sublist(1, 1));
+
+ expectAE(() => [1].sublist(0, 2));
+ expectAE(() => [1].sublist(1, 2));
+ expectAE(() => [1].sublist(1, 0));
+}
+
+void expectAE(Function f) {
+ Expect.throws(f, (e) => e is ArgumentError);
+}
diff --git a/tests/corelib/list_test.dart b/tests/corelib/list_test.dart
index 9a88a9f..932d4ca 100644
--- a/tests/corelib/list_test.dart
+++ b/tests/corelib/list_test.dart
@@ -2,151 +2,160 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-class ListTest {
+import "dart:collection";
+import "package:expect/expect.dart";
- static testMain() {
- testList();
- testExpandableList();
+void main() {
+ testFixedLengthList(new List(4));
+ // ListBase implementation of List.
+ testFixedLengthList(new MyFixedList(new List(4)));
+
+ testGrowableList(new List());
+ testGrowableList([]);
+ testGrowableList(new MyList([]));
+}
+
+void expectValues(list, val1, val2, val3, val4) {
+ Expect.isFalse(list.isEmpty);
+ Expect.equals(4, list.length);
+ Expect.equals(list[0], val1);
+ Expect.equals(list[1], val2);
+ Expect.equals(list[2], val3);
+ Expect.equals(list[3], val4);
+}
+
+void testClosures(List list) {
+ testMap(val) {return val * 2 + 10; }
+ List mapped = list.map(testMap).toList();
+ Expect.equals(mapped.length, list.length);
+ for (var i = 0; i < list.length; i++) {
+ Expect.equals(mapped[i], list[i]*2 + 10);
}
- static void expectValues(list, val1, val2, val3, val4) {
- Expect.equals(true, list.length == 4);
- Expect.equals(true, list.length == 4);
- Expect.equals(true, !list.isEmpty);
- Expect.equals(list[0], val1);
- Expect.equals(list[1], val2);
- Expect.equals(list[2], val3);
- Expect.equals(list[3], val4);
+ testFilter(val) { return val == 3; }
+ Iterable filtered = list.where(testFilter);
+ Expect.equals(filtered.length, 1);
+
+ testEvery(val) { return val != 11; }
+ bool test = list.every(testEvery);
+ Expect.isTrue(test);
+
+ testSome(val) { return val == 1; }
+ test = list.any(testSome);
+ Expect.isTrue(test);
+
+ testSomeFirst(val) { return val == 0; }
+ test = list.any(testSomeFirst);
+ Expect.isTrue(test);
+
+ testSomeLast(val) { return val == (list.length - 1); }
+ test = list.any(testSomeLast);
+ Expect.isTrue(test);
+}
+
+void testFixedLengthList(List list) {
+ Expect.equals(list.length, 4);
+ list[0] = 4;
+ expectValues(list, 4, null, null, null);
+ String val = "fisk";
+ list[1] = val;
+ expectValues(list, 4, val, null, null);
+ double d = 2.0;
+ list[3] = d;
+ expectValues(list, 4, val, null, d);
+
+ for (int i = 0; i < list.length; i++) {
+ list[i] = i;
}
- static void testClosures(List list) {
- testMap(val) {return val * 2 + 10; }
- List mapped = list.map(testMap).toList();
- Expect.equals(mapped.length, list.length);
- for (var i = 0; i < list.length; i++) {
- Expect.equals(mapped[i], list[i]*2 + 10);
- }
-
- testFilter(val) { return val == 3; }
- Iterable filtered = list.where(testFilter);
- Expect.equals(filtered.length, 1);
-
- testEvery(val) { return val != 11; }
- bool test = list.every(testEvery);
- Expect.equals(true, test);
-
- testSome(val) { return val == 1; }
- test = list.any(testSome);
- Expect.equals(true, test);
-
- testSomeFirst(val) { return val == 0; }
- test = list.any(testSomeFirst);
- Expect.equals(true, test);
-
- testSomeLast(val) { return val == (list.length - 1); }
- test = list.any(testSomeLast);
- Expect.equals(true, test);
+ for (int i = 0; i < 4; i++) {
+ Expect.equals(i, list[i]);
+ Expect.equals(i, list.indexOf(i));
+ Expect.equals(i, list.lastIndexOf(i));
}
- static void testList() {
- List list = new List(4);
- Expect.equals(list.length, 4);
- list[0] = 4;
- expectValues(list, 4, null, null, null);
- String val = "fisk";
- list[1] = val;
- expectValues(list, 4, val, null, null);
- double d = 2.0;
- list[3] = d;
- expectValues(list, 4, val, null, d);
+ Expect.equals(-1, list.indexOf(100));
+ Expect.equals(-1, list.lastIndexOf(100));
+ list[2] = new Yes();
+ Expect.equals(2, list.indexOf(100));
+ Expect.equals(2, list.lastIndexOf(100));
+ list[3] = new Yes();
+ Expect.equals(2, list.indexOf(100));
+ Expect.equals(3, list.lastIndexOf(100));
+ list[2] = 2;
+ Expect.equals(3, list.indexOf(100));
+ Expect.equals(3, list.lastIndexOf(100));
+ list[3] = 3;
+ Expect.equals(-1, list.indexOf(100));
+ Expect.equals(-1, list.lastIndexOf(100));
- for (int i = 0; i < list.length; i++) {
- list[i] = i;
- }
+ testClosures(list);
- for (int i = 0; i < 4; i++) {
- Expect.equals(i, list[i]);
- Expect.equals(i, list.indexOf(i));
- Expect.equals(i, list.lastIndexOf(i));
- }
+ Expect.throws(list.clear, (e) => e is UnsupportedError);
+}
- Expect.equals(-1, list.indexOf(100));
- Expect.equals(-1, list.lastIndexOf(100));
- list[2] = new Yes();
- Expect.equals(2, list.indexOf(100));
- Expect.equals(2, list.lastIndexOf(100));
- list[3] = new Yes();
- Expect.equals(2, list.indexOf(100));
- Expect.equals(3, list.lastIndexOf(100));
- list[2] = 2;
- Expect.equals(3, list.indexOf(100));
- Expect.equals(3, list.lastIndexOf(100));
- list[3] = 3;
- Expect.equals(-1, list.indexOf(100));
- Expect.equals(-1, list.lastIndexOf(100));
+void testGrowableList(List list) {
+ Expect.isTrue(list.isEmpty);
+ Expect.equals(list.length, 0);
+ list.add(4);
+ Expect.equals(1, list.length);
+ Expect.isTrue(!list.isEmpty);
+ Expect.equals(list.length, 1);
+ Expect.equals(list.length, 1);
+ Expect.equals(list.removeLast(), 4);
- testClosures(list);
-
- var exception = null;
- try {
- list.clear();
- } on UnsupportedError catch (e) {
- exception = e;
- }
- Expect.equals(true, exception != null);
+ for (int i = 0; i < 10; i++) {
+ list.add(i);
}
- static void testExpandableList() {
- List list = new List();
- Expect.equals(true, list.isEmpty);
- Expect.equals(list.length, 0);
- list.add(4);
- Expect.equals(1, list.length);
- Expect.equals(true, !list.isEmpty);
- Expect.equals(list.length, 1);
- Expect.equals(list.length, 1);
- Expect.equals(list.removeLast(), 4);
-
- for (int i = 0; i < 10; i++) {
- list.add(i);
- }
-
- Expect.equals(list.length, 10);
- for (int i = 0; i < 10; i++) {
- Expect.equals(i, list[i]);
- Expect.equals(i, list.indexOf(i));
- Expect.equals(i, list.lastIndexOf(i));
- }
-
- Expect.equals(-1, list.indexOf(100));
- Expect.equals(-1, list.lastIndexOf(100));
- list[2] = new Yes();
- Expect.equals(2, list.indexOf(100));
- Expect.equals(2, list.lastIndexOf(100));
- list[3] = new Yes();
- Expect.equals(2, list.indexOf(100));
- Expect.equals(3, list.lastIndexOf(100));
- list[2] = 2;
- Expect.equals(3, list.indexOf(100));
- Expect.equals(3, list.lastIndexOf(100));
- list[3] = 3;
- Expect.equals(-1, list.indexOf(100));
- Expect.equals(-1, list.lastIndexOf(100));
-
- testClosures(list);
-
- Expect.equals(list.removeLast(), 9);
- list.clear();
- Expect.equals(list.length, 0);
- Expect.equals(list.length, 0);
- Expect.equals(true, list.isEmpty);
+ Expect.equals(list.length, 10);
+ for (int i = 0; i < 10; i++) {
+ Expect.equals(i, list[i]);
+ Expect.equals(i, list.indexOf(i));
+ Expect.equals(i, list.lastIndexOf(i));
}
+
+ Expect.equals(-1, list.indexOf(100));
+ Expect.equals(-1, list.lastIndexOf(100));
+ list[2] = new Yes();
+ Expect.equals(2, list.indexOf(100));
+ Expect.equals(2, list.lastIndexOf(100));
+ list[3] = new Yes();
+ Expect.equals(2, list.indexOf(100));
+ Expect.equals(3, list.lastIndexOf(100));
+ list[2] = 2;
+ Expect.equals(3, list.indexOf(100));
+ Expect.equals(3, list.lastIndexOf(100));
+ list[3] = 3;
+ Expect.equals(-1, list.indexOf(100));
+ Expect.equals(-1, list.lastIndexOf(100));
+
+ testClosures(list);
+
+ Expect.equals(9, list.removeLast());
+ list.clear();
+ Expect.equals(0, list.length);
+ Expect.isTrue(list.isEmpty);
}
class Yes {
operator ==(var other) => true;
}
-main() {
- ListTest.testMain();
+class MyList<E> extends ListBase<E> {
+ List<E> _source;
+ MyList(this._source);
+ int get length => _source.length;
+ void set length(int length) { _source.length = length; }
+ E operator[](int index) => _source[index];
+ void operator[]=(int index, E value) { _source[index] = value; }
+}
+
+class MyFixedList<E> extends ListBase<E> {
+ List<E> _source;
+ MyFixedList(this._source);
+ int get length => _source.length;
+ void set length(int length) { throw new UnsupportedError("Fixed length!"); }
+ E operator[](int index) => _source[index];
+ void operator[]=(int index, E value) { _source[index] = value; }
}
diff --git a/tests/corelib/map_from_test.dart b/tests/corelib/map_from_test.dart
index b43a45d..21597fb 100644
--- a/tests/corelib/map_from_test.dart
+++ b/tests/corelib/map_from_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library map.from.test;
+import "package:expect/expect.dart";
import 'dart:collection';
main() {
diff --git a/tests/corelib/map_keys2_test.dart b/tests/corelib/map_keys2_test.dart
index 5cb051f..8d623eb 100644
--- a/tests/corelib/map_keys2_test.dart
+++ b/tests/corelib/map_keys2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var map1 = { "foo": 42, "bar": 499 };
var map2 = {};
diff --git a/tests/corelib/map_keys_test.dart b/tests/corelib/map_keys_test.dart
index 8b3a833..5e02336 100644
--- a/tests/corelib/map_keys_test.dart
+++ b/tests/corelib/map_keys_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var map1 = { "foo": 42, "bar": 499 };
var map2 = {};
diff --git a/tests/corelib/map_test.dart b/tests/corelib/map_test.dart
index 9fb2bca..a5bbbda7f 100644
--- a/tests/corelib/map_test.dart
+++ b/tests/corelib/map_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library map_test;
+import "package:expect/expect.dart";
import 'dart:collection';
void main() {
diff --git a/tests/corelib/map_values2_test.dart b/tests/corelib/map_values2_test.dart
index 08b426a..8efc532 100644
--- a/tests/corelib/map_values2_test.dart
+++ b/tests/corelib/map_values2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var map1 = <String, int>{ "foo": 42, "bar": 499 };
var map2 = <String, int>{};
diff --git a/tests/corelib/map_values_test.dart b/tests/corelib/map_values_test.dart
index dee7e23..cd3f366 100644
--- a/tests/corelib/map_values_test.dart
+++ b/tests/corelib/map_values_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var map1 = { "foo": 42, "bar": 499 };
var map2 = {};
diff --git a/tests/corelib/maps_test.dart b/tests/corelib/maps_test.dart
index 6d51939..91849a8 100644
--- a/tests/corelib/maps_test.dart
+++ b/tests/corelib/maps_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library maps_test;
+import "package:expect/expect.dart";
import 'dart:collection';
main() {
diff --git a/tests/corelib/nan_infinity_test.dart b/tests/corelib/nan_infinity_test.dart
index 35bad82..83e9455 100644
--- a/tests/corelib/nan_infinity_test.dart
+++ b/tests/corelib/nan_infinity_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing NaN and Infinity.
void main() {
diff --git a/tests/corelib/null_nosuchmethod_test.dart b/tests/corelib/null_nosuchmethod_test.dart
index 7ae7540..57cda7f 100644
--- a/tests/corelib/null_nosuchmethod_test.dart
+++ b/tests/corelib/null_nosuchmethod_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that Null's noSuchMethod can be closurized and called directly.
main() {
diff --git a/tests/corelib/null_test.dart b/tests/corelib/null_test.dart
index 8f30e6c..994ca40 100644
--- a/tests/corelib/null_test.dart
+++ b/tests/corelib/null_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that Null inherits properties from Object.
main() {
diff --git a/tests/corelib/num_clamp_test.dart b/tests/corelib/num_clamp_test.dart
index 662cab8..f848677f8 100644
--- a/tests/corelib/num_clamp_test.dart
+++ b/tests/corelib/num_clamp_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test num.clamp.
+import "package:expect/expect.dart";
+
testIntClamp() {
Expect.equals(2, 2.clamp(1, 3));
Expect.equals(1, 0.clamp(1, 3));
diff --git a/tests/corelib/queue_first_test.dart b/tests/corelib/queue_first_test.dart
index 93bc265..15664d2 100644
--- a/tests/corelib/queue_first_test.dart
+++ b/tests/corelib/queue_first_test.dart
@@ -4,6 +4,7 @@
library queue.first.test;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue;
main() {
diff --git a/tests/corelib/queue_iterator_test.dart b/tests/corelib/queue_iterator_test.dart
index 3b7e3a9..af0458b 100644
--- a/tests/corelib/queue_iterator_test.dart
+++ b/tests/corelib/queue_iterator_test.dart
@@ -4,6 +4,7 @@
library queue.iterator.test;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue;
class QueueIteratorTest {
diff --git a/tests/corelib/queue_last_test.dart b/tests/corelib/queue_last_test.dart
index 58096d9..3361395 100644
--- a/tests/corelib/queue_last_test.dart
+++ b/tests/corelib/queue_last_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library queue.last.test;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue;
main() {
diff --git a/tests/corelib/queue_single_test.dart b/tests/corelib/queue_single_test.dart
index 533cde6..22f8048 100644
--- a/tests/corelib/queue_single_test.dart
+++ b/tests/corelib/queue_single_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library queue.single.test;
+import "package:expect/expect.dart";
import 'dart:collection' show Queue;
main() {
diff --git a/tests/corelib/queue_test.dart b/tests/corelib/queue_test.dart
index 51356e7..e36ab42 100644
--- a/tests/corelib/queue_test.dart
+++ b/tests/corelib/queue_test.dart
@@ -4,6 +4,7 @@
library queue.test;
+import "package:expect/expect.dart";
import 'dart:collection';
abstract class QueueTest {
@@ -224,19 +225,15 @@
queue.remove(10);
testLength(29, queue);
- queue.removeAll([4, 6]);
- testLength(23, queue);
-
- queue.retainAll([1, 3, 5, 7, 9, 10]); // Remove 2 and 8.
- testLength(17, queue);
-
queue.removeWhere((x) => x == 7);
- testLength(14, queue);
+ testLength(26, queue);
queue.retainWhere((x) => x != 3);
- testLength(11, queue);
+ testLength(23, queue);
- Expect.listEquals([9, 1, 5, 9, 10, 1, 5, 9, 10, 1, 5], queue.toList());
+ Expect.listEquals(
+ [6, 8, 9, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5],
+ queue.toList());
}
void testLarge() {
@@ -270,13 +267,10 @@
}
Expect.equals(N - 1000, queue.length);
- queue.retainAll(set);
- Expect.equals(N - 1000, queue.length);
-
queue.remove(N >> 1);
Expect.equals(N - 1001, queue.length);
- queue.removeAll(set);
+ queue.clear();
Expect.equals(0, queue.length);
Expect.isTrue(queue.isEmpty);
diff --git a/tests/corelib/range_error_test.dart b/tests/corelib/range_error_test.dart
index e83bd30..2fdf90f 100644
--- a/tests/corelib/range_error_test.dart
+++ b/tests/corelib/range_error_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test for testing out of range exceptions on arrays.
class RangeErrorTest {
diff --git a/tests/corelib/reg_exp1_test.dart b/tests/corelib/reg_exp1_test.dart
index 50cd4af..88e3b0a 100644
--- a/tests/corelib/reg_exp1_test.dart
+++ b/tests/corelib/reg_exp1_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
+import "package:expect/expect.dart";
+
class RegExp1Test {
static testMain() {
RegExp exp1 = new RegExp("bar|foo");
diff --git a/tests/corelib/reg_exp4_test.dart b/tests/corelib/reg_exp4_test.dart
index bef3397..f8f63c1 100644
--- a/tests/corelib/reg_exp4_test.dart
+++ b/tests/corelib/reg_exp4_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
+import "package:expect/expect.dart";
+
main() {
try {
RegExp ex = new RegExp(null);
diff --git a/tests/corelib/reg_exp5_test.dart b/tests/corelib/reg_exp5_test.dart
index 3a1aa7f..f67cd6d 100644
--- a/tests/corelib/reg_exp5_test.dart
+++ b/tests/corelib/reg_exp5_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
+import "package:expect/expect.dart";
+
main() {
String str = "";
try {
diff --git a/tests/corelib/reg_exp_all_matches_test.dart b/tests/corelib/reg_exp_all_matches_test.dart
index 3e85114..72a2344 100644
--- a/tests/corelib/reg_exp_all_matches_test.dart
+++ b/tests/corelib/reg_exp_all_matches_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for RegExp.allMatches.
class RegExpAllMatchesTest {
diff --git a/tests/corelib/reg_exp_first_match_test.dart b/tests/corelib/reg_exp_first_match_test.dart
index 23a0f3b..40e38fa 100644
--- a/tests/corelib/reg_exp_first_match_test.dart
+++ b/tests/corelib/reg_exp_first_match_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for RegExp.firstMatch.
class RegExpFirstMatchTest {
diff --git a/tests/corelib/reg_exp_group_test.dart b/tests/corelib/reg_exp_group_test.dart
index a335e44..1bf4af3 100644
--- a/tests/corelib/reg_exp_group_test.dart
+++ b/tests/corelib/reg_exp_group_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for RegExp.group.
class RegExpGroupTest {
diff --git a/tests/corelib/reg_exp_groups_test.dart b/tests/corelib/reg_exp_groups_test.dart
index 549b690..70386d0 100644
--- a/tests/corelib/reg_exp_groups_test.dart
+++ b/tests/corelib/reg_exp_groups_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for RegExp.groups.
class RegExpGroupsTest {
diff --git a/tests/corelib/reg_exp_has_match_test.dart b/tests/corelib/reg_exp_has_match_test.dart
index 9cd3caa..6ff2744 100644
--- a/tests/corelib/reg_exp_has_match_test.dart
+++ b/tests/corelib/reg_exp_has_match_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for RegExp.hasMatch.
class RegExpHasMatchTest {
diff --git a/tests/corelib/reg_exp_start_end_test.dart b/tests/corelib/reg_exp_start_end_test.dart
index 18a7337..e905275a 100644
--- a/tests/corelib/reg_exp_start_end_test.dart
+++ b/tests/corelib/reg_exp_start_end_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var matches =
new RegExp("(a(b)((c|de)+))").allMatches("abcde abcde abcde");
diff --git a/tests/corelib/reg_exp_string_match_test.dart b/tests/corelib/reg_exp_string_match_test.dart
index fa4efa7..05978dd 100644
--- a/tests/corelib/reg_exp_string_match_test.dart
+++ b/tests/corelib/reg_exp_string_match_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for RegExp.stringMatch.
class RegExpStringMatchTest {
diff --git a/tests/corelib/safe_to_string_test.dart b/tests/corelib/safe_to_string_test.dart
index dd80be1..10be1f7 100644
--- a/tests/corelib/safe_to_string_test.dart
+++ b/tests/corelib/safe_to_string_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
Expect.stringEquals('1', Error.safeToString(1));
Expect.stringEquals('0.5', Error.safeToString(0.5));
diff --git a/tests/corelib/set_iterator_test.dart b/tests/corelib/set_iterator_test.dart
index d6ec16e..d2193ad 100644
--- a/tests/corelib/set_iterator_test.dart
+++ b/tests/corelib/set_iterator_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class FixedHashCode {
final int _hashCode;
const FixedHashCode(this._hashCode);
diff --git a/tests/corelib/set_test.dart b/tests/corelib/set_test.dart
index 940e427..5acb8a5 100644
--- a/tests/corelib/set_test.dart
+++ b/tests/corelib/set_test.dart
@@ -4,6 +4,8 @@
library set_test;
+
+import 'package:expect/expect.dart';
import "dart:collection";
void testMain(Set create()) {
@@ -45,7 +47,6 @@
set.forEach(testForEach);
Expect.equals(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1, sum);
- Expect.isTrue(set.isSubsetOf(set));
Expect.isTrue(set.containsAll(set));
// Test Set.map.
@@ -96,7 +97,6 @@
Expect.equals(1 + 3 + 5 + 7 + 9, sum);
Expect.isTrue(set.containsAll(filtered));
- Expect.isTrue(filtered.isSubsetOf(set));
// Test Set.every.
testEvery(int val) {
@@ -136,8 +136,6 @@
Expect.isTrue(set.containsAll(intersection));
Expect.isTrue(filtered.containsAll(intersection));
- Expect.isTrue(intersection.isSubsetOf(set));
- Expect.isTrue(intersection.isSubsetOf(filtered));
// Test Set.union.
Set twice = create()..addAll([0, 2, 4, 6, 8, 10, 12, 14]);
@@ -157,7 +155,7 @@
Expect.isTrue(twice.difference(thrice).difference(twice).isEmpty);
// Test Set.addAll.
- List list = new List.fixedLength(10);
+ List list = new List(10);
for (int i = 0; i < 10; i++) {
list[i] = i + 10;
}
diff --git a/tests/corelib/sort_helper.dart b/tests/corelib/sort_helper.dart
index e378097..23f45cf 100644
--- a/tests/corelib/sort_helper.dart
+++ b/tests/corelib/sort_helper.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library sort_helper;
+import "package:expect/expect.dart";
class SortHelper {
diff --git a/tests/corelib/sort_test.dart b/tests/corelib/sort_test.dart
index a421e2b..9327363 100644
--- a/tests/corelib/sort_test.dart
+++ b/tests/corelib/sort_test.dart
@@ -4,6 +4,7 @@
// Dart test for sort routines.
library sort_test;
+import "package:expect/expect.dart";
import 'sort_helper.dart';
main() {
diff --git a/tests/corelib/splay_tree_test.dart b/tests/corelib/splay_tree_test.dart
index 337cf8c..ae112d4 100644
--- a/tests/corelib/splay_tree_test.dart
+++ b/tests/corelib/splay_tree_test.dart
@@ -4,6 +4,7 @@
// Dart test for Splaytrees.
library splay_tree_test;
+import "package:expect/expect.dart";
import 'dart:collection';
diff --git a/tests/corelib/stopwatch2_test.dart b/tests/corelib/stopwatch2_test.dart
index 25d1120..a95db46 100644
--- a/tests/corelib/stopwatch2_test.dart
+++ b/tests/corelib/stopwatch2_test.dart
@@ -4,6 +4,8 @@
// Dart test program for elapsed getters in stopwatch support.
+import "package:expect/expect.dart";
+
main() {
Stopwatch sw = new Stopwatch()..start();
while (sw.elapsedMilliseconds < 2) {
diff --git a/tests/corelib/stopwatch_test.dart b/tests/corelib/stopwatch_test.dart
index 535b495..28ec48b 100644
--- a/tests/corelib/stopwatch_test.dart
+++ b/tests/corelib/stopwatch_test.dart
@@ -5,6 +5,7 @@
// Dart test program for testing stopwatch support.
library stopwatch_test;
+import "package:expect/expect.dart";
class StopwatchTest {
static bool checkTicking(Stopwatch sw) {
diff --git a/tests/corelib/string_base_vm_test.dart b/tests/corelib/string_base_vm_test.dart
index 5e6f682..e8922fe9 100644
--- a/tests/corelib/string_base_vm_test.dart
+++ b/tests/corelib/string_base_vm_test.dart
@@ -4,6 +4,7 @@
// Dart test program for testing class 'StringBase' (currently VM specific).
library string_base_test;
+import "package:expect/expect.dart";
class StringBaseTest {
diff --git a/tests/corelib/string_buffer_test.dart b/tests/corelib/string_buffer_test.dart
index 68c5301..093c7ad 100644
--- a/tests/corelib/string_buffer_test.dart
+++ b/tests/corelib/string_buffer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// TODO(srdjan): Move StringBuffer to visible names.
void testConstructor() {
diff --git a/tests/corelib/string_case_test.dart b/tests/corelib/string_case_test.dart
index ba2f07d..6ba535c 100644
--- a/tests/corelib/string_case_test.dart
+++ b/tests/corelib/string_case_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class StringCaseTest {
static testMain() {
diff --git a/tests/corelib/string_codeunits_test.dart b/tests/corelib/string_codeunits_test.dart
index 28b9df4..46db21f 100644
--- a/tests/corelib/string_codeunits_test.dart
+++ b/tests/corelib/string_codeunits_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
test(String s) {
Iterable<int> units = s.codeUnits;
diff --git a/tests/corelib/string_from_list_test.dart b/tests/corelib/string_from_list_test.dart
index e58b677..de6b1f7 100644
--- a/tests/corelib/string_from_list_test.dart
+++ b/tests/corelib/string_from_list_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void main() {
Expect.equals("", new String.fromCharCodes(new List(0)));
Expect.equals("", new String.fromCharCodes([]));
diff --git a/tests/corelib/string_fromcharcode_test.dart b/tests/corelib/string_fromcharcode_test.dart
index 7f0fd20..c653fa8 100644
--- a/tests/corelib/string_fromcharcode_test.dart
+++ b/tests/corelib/string_fromcharcode_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("A", new String.fromCharCode(65));
Expect.equals("B", new String.fromCharCode(66));
diff --git a/tests/corelib/string_pattern_test.dart b/tests/corelib/string_pattern_test.dart
index 6ab5e95..46b4e75 100644
--- a/tests/corelib/string_pattern_test.dart
+++ b/tests/corelib/string_pattern_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing String.allMatches.
+import "package:expect/expect.dart";
+
String str = "this is a string with hello here and hello there";
main() {
diff --git a/tests/corelib/string_replace_all_test.dart b/tests/corelib/string_replace_all_test.dart
index ab24657..299d56a 100644
--- a/tests/corelib/string_replace_all_test.dart
+++ b/tests/corelib/string_replace_all_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
testReplaceAll() {
Expect.equals(
"aXXcaXXdae", "abcabdae".replaceAll("b", "XX"));
diff --git a/tests/corelib/string_replace_dollar_test.dart b/tests/corelib/string_replace_dollar_test.dart
index 107821c..6a684f0 100644
--- a/tests/corelib/string_replace_dollar_test.dart
+++ b/tests/corelib/string_replace_dollar_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
String jsText = r"""'$'
""";
diff --git a/tests/corelib/string_replace_test.dart b/tests/corelib/string_replace_test.dart
index 171af37..136cc96 100644
--- a/tests/corelib/string_replace_test.dart
+++ b/tests/corelib/string_replace_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class StringReplaceTest {
static testMain() {
Expect.equals(
diff --git a/tests/corelib/string_runes_test.dart b/tests/corelib/string_runes_test.dart
index 9929581..f0dbd54 100644
--- a/tests/corelib/string_runes_test.dart
+++ b/tests/corelib/string_runes_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
test(String s, List<int> expectedRunes) {
Runes runes = s.runes;
diff --git a/tests/corelib/string_slice_test.dart b/tests/corelib/string_slice_test.dart
index 5f0f4a3..b003a42 100644
--- a/tests/corelib/string_slice_test.dart
+++ b/tests/corelib/string_slice_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Short string.
var s = "0123456789";
// Long string.
diff --git a/tests/corelib/string_split_reg_exp_test.dart b/tests/corelib/string_split_reg_exp_test.dart
index bd52cf7..f742128 100644
--- a/tests/corelib/string_split_reg_exp_test.dart
+++ b/tests/corelib/string_split_reg_exp_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var list = "a b c".split(new RegExp(" "));
Expect.equals(3, list.length);
diff --git a/tests/corelib/string_split_test.dart b/tests/corelib/string_split_test.dart
index 7cacc7c..9eee525 100644
--- a/tests/corelib/string_split_test.dart
+++ b/tests/corelib/string_split_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class StringSplitTest {
static testMain() {
var list = "a b c".split(" ");
diff --git a/tests/corelib/string_substring_test.dart b/tests/corelib/string_substring_test.dart
index 0cdac66..7fd9091 100644
--- a/tests/corelib/string_substring_test.dart
+++ b/tests/corelib/string_substring_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
// Test that not providing an optional argument goes to the end.
Expect.equals("".substring(0), "");
diff --git a/tests/corelib/string_test.dart b/tests/corelib/string_test.dart
index d0879bd..fd73fea 100644
--- a/tests/corelib/string_test.dart
+++ b/tests/corelib/string_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// TODO(ngeoffray): test String methods with null arguments.
class StringTest {
diff --git a/tests/corelib/string_trim_test.dart b/tests/corelib/string_trim_test.dart
index ab54484..6049af9 100644
--- a/tests/corelib/string_trim_test.dart
+++ b/tests/corelib/string_trim_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class StringTrimTest {
static testMain() {
Expect.equals("", " ".trim());
diff --git a/tests/corelib/strings_test.dart b/tests/corelib/strings_test.dart
index 16630f2..11490d2 100644
--- a/tests/corelib/strings_test.dart
+++ b/tests/corelib/strings_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing class 'Strings'.
class StringsTest {
diff --git a/tests/corelib/symbol_test.dart b/tests/corelib/symbol_test.dart
new file mode 100644
index 0000000..b3604c4
--- /dev/null
+++ b/tests/corelib/symbol_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Basic test of Symbol class.
+
+main() {
+ var x;
+ print(x = const Symbol('fisk'));
+
+ try {
+ print(const Symbol(0)); /// 01: compile-time error
+ } on ArgumentError {
+ print('Caught ArgumentError');
+ } on TypeError {
+ print('Caught TypeError');
+ }
+
+ try {
+ print(const Symbol('0')); /// 02: compile-time error
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ try {
+ print(const Symbol('_')); /// 03: compile-time error
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ try {
+ var y = 0;
+ print(new Symbol(y));
+ throw 'Expected an ArgumentError or a TypeError';
+ } on ArgumentError {
+ print('Caught ArgumentError');
+ } on TypeError {
+ print('Caught TypeError');
+ }
+
+ try {
+ print(new Symbol('0'));
+ throw 'Expected an ArgumentError';
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ try {
+ print(new Symbol('_'));
+ throw 'Expected an ArgumentError';
+ } on ArgumentError catch (e) {
+ print('Caught $e');
+ }
+
+ if (!identical(const Symbol('fisk'), x)) {
+ throw 'Symbol constant is not canonicalized';
+ }
+
+ if (const Symbol('fisk') != x) {
+ throw 'Symbol constant is not equal to itself';
+ }
+
+ if (const Symbol('fisk') != new Symbol('fisk')) {
+ throw 'Symbol constant is not equal to its non-const equivalent';
+ }
+
+ if (new Symbol('fisk') != new Symbol('fisk')) {
+ throw 'new Symbol is not equal to its equivalent';
+ }
+
+ if (new Symbol('fisk') == new Symbol('hest')) {
+ throw 'unrelated Symbols are equal';
+ }
+
+ if (new Symbol('fisk') == new Object()) {
+ throw 'unrelated objects are equal';
+ }
+
+ x.hashCode as int;
+
+ new Symbol('fisk').hashCode as int;
+
+ if (new Symbol('fisk').hashCode != x.hashCode) {
+ throw "non-const Symbol's hashCode not equal to its const equivalent";
+ }
+}
diff --git a/tests/corelib/unicode_test.dart b/tests/corelib/unicode_test.dart
index ea420f9..32cddb5 100644
--- a/tests/corelib/unicode_test.dart
+++ b/tests/corelib/unicode_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class UnicodeTest {
static testMain() {
diff --git a/tests/html/canvas_test.dart b/tests/html/canvas_test.dart
index 6d95d3a..f343b32 100644
--- a/tests/html/canvas_test.dart
+++ b/tests/html/canvas_test.dart
@@ -12,7 +12,7 @@
canvas = new CanvasElement(width:width, height:height);
document.body.nodes.add(canvas);
- context = canvas.context2d;
+ context = canvas.context2D;
useHtmlConfiguration();
test('CreateImageData', () {
@@ -30,7 +30,7 @@
test('toDataUrl', () {
var canvas = new CanvasElement(width: 100, height: 100);
- var context = canvas.context2d;
+ var context = canvas.context2D;
context.fillStyle = 'red';
context.fill();
diff --git a/tests/html/canvasrenderingcontext2d_test.dart b/tests/html/canvasrenderingcontext2d_test.dart
index 7e82241..8de0001 100644
--- a/tests/html/canvasrenderingcontext2d_test.dart
+++ b/tests/html/canvasrenderingcontext2d_test.dart
@@ -26,14 +26,14 @@
canvas.width = 100;
canvas.height = 100;
- context = canvas.context2d;
+ context = canvas.context2D;
}
void createOtherCanvas() {
otherCanvas = new CanvasElement();
otherCanvas.width = 10;
otherCanvas.height = 10;
- otherContext = otherCanvas.context2d;
+ otherContext = otherCanvas.context2D;
otherContext.fillStyle = "red";
otherContext.fillRect(0, 0, otherCanvas.width, otherCanvas.height);
}
diff --git a/tests/html/css_test.dart b/tests/html/css_test.dart
index 13418f3..b335d65 100644
--- a/tests/html/css_test.dart
+++ b/tests/html/css_test.dart
@@ -6,33 +6,16 @@
main() {
useHtmlIndividualConfiguration();
- group('supported_CssMatrix', () {
+ group('supportsPointConversions', () {
test('supported', () {
- expect(CssMatrix.supported, true);
- });
- });
-
- group('supported_DomPoint', () {
- test('supported', () {
- expect(DomPoint.supported, true);
+ expect(Window.supportsPointConversions, true);
});
});
group('functional', () {
- test('CssMatrix', () {
- var expectation = CssMatrix.supported ? returnsNormally : throws;
- expect(() {
- CssMatrix matrix1 = new CssMatrix();
- expect(matrix1.m11.round(), equals(1));
- expect(matrix1.m12.round(), isZero);
-
- CssMatrix matrix2 = new CssMatrix('matrix(1, 0, 0, 1, -835, 0)');
- expect(matrix2.a.round(), equals(1));
- expect(matrix2.e.round(), equals(-835));
- }, expectation);
- });
test('DomPoint', () {
- var expectation = DomPoint.supported ? returnsNormally : throws;
+ var expectation = Window.supportsPointConversions ?
+ returnsNormally : throws;
expect(() {
Element element = new Element.tag('div');
element.attributes['style'] =
@@ -47,10 +30,10 @@
''';
document.body.nodes.add(element);
- DomPoint point = new DomPoint(5, 2);
+ Point point = new Point(5, 2);
checkPoint(5, 2, point);
checkPoint(255, 102, window.convertPointFromNodeToPage(element, point));
- point.y = 100;
+ point = new Point(5, 100);
checkPoint(5, 100, point);
checkPoint(255, 200, window.convertPointFromNodeToPage(element, point));
}, expectation);
@@ -58,7 +41,7 @@
});
}
-void checkPoint(expectedX, expectedY, DomPoint point) {
+void checkPoint(expectedX, expectedY, Point point) {
expect(point.x.round(), equals(expectedX), reason: 'Wrong point.x');
expect(point.y.round(), equals(expectedY), reason: 'Wrong point.y');
}
diff --git a/tests/html/documentfragment_test.dart b/tests/html/documentfragment_test.dart
index 326fa41..8146e1f 100644
--- a/tests/html/documentfragment_test.dart
+++ b/tests/html/documentfragment_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library DocumentFragmentTest;
+import "package:expect/expect.dart";
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'util.dart';
diff --git a/tests/html/element_classes_test.dart b/tests/html/element_classes_test.dart
index f499916c..83bb86c 100644
--- a/tests/html/element_classes_test.dart
+++ b/tests/html/element_classes_test.dart
@@ -150,13 +150,6 @@
expect(classes, orderedEquals(['baz', 'qux', 'quux']));
});
- test('isSubsetOf', () {
- final classes = makeClassSet();
- expect(classes.isSubsetOf(['foo', 'bar', 'baz'].toSet()), isTrue);
- expect(classes.isSubsetOf(['foo', 'bar', 'baz', 'qux'].toSet()), isTrue);
- expect(classes.isSubsetOf(['foo', 'bar', 'qux'].toSet()), isFalse);
- });
-
test('containsAll', () {
final classes = makeClassSet();
expect(classes.containsAll(['foo', 'baz'].toSet()), isTrue);
diff --git a/tests/html/element_test.dart b/tests/html/element_test.dart
index 53a743c..449a0b8 100644
--- a/tests/html/element_test.dart
+++ b/tests/html/element_test.dart
@@ -616,6 +616,13 @@
});
group('functional', () {
+ test('toString', () {
+ final elems = makeElementWithChildren().children;
+ expect(elems.toString(), "[br, img, input]");
+ final elem = makeElement().children;
+ expect(elem.toString(), '[]');
+ });
+
test('scrollIntoView', () {
var child = new DivElement();
document.body.append(child);
diff --git a/tests/html/event_customevent_test.dart b/tests/html/event_customevent_test.dart
index 4e0ed48..73ae1d9 100644
--- a/tests/html/event_customevent_test.dart
+++ b/tests/html/event_customevent_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library EventCustomEventTest;
+import "package:expect/expect.dart";
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
diff --git a/tests/html/event_test.dart b/tests/html/event_test.dart
index c196e64..df0fe1c 100644
--- a/tests/html/event_test.dart
+++ b/tests/html/event_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library EventTest;
+import "package:expect/expect.dart";
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
diff --git a/tests/html/html.status b/tests/html/html.status
index 8d0d460..dde8605 100644
--- a/tests/html/html.status
+++ b/tests/html/html.status
@@ -59,18 +59,19 @@
native_gc_test: Fail, Pass # BUG(7774): Untriaged.
serialized_script_value_test: Fail
storage_test: Fail, Pass
+transferables_test: Fail # Issue 9846
websocket_test/websocket: Fail # TODO(efortuna): Issue 7875.
window_open_test: Skip
canvasrenderingcontext2d_test/drawImage_video_element: Fail # IE does not support drawImage w/ video element
canvasrenderingcontext2d_test/drawImage_video_element_dataUrl: Fail # IE does not support drawImage w/ video element
+worker_test/functional: Fail # IE uses incorrect security context for Blob URIs.
# IE10 Feature support statuses-
# All changes should be accompanied by platform support annotation changes.
audiobuffersourcenode_test/supported: Fail
audiocontext_test/supported: Fail
crypto_test/supported: Fail
-css_test/supported_CssMatrix: Fail
-css_test/supported_DomPoint: Fail
+css_test/supportsPointConversions: Fail
document_test/supports_cssCanvasContext: Fail
element_types_test/supported_content: Fail
element_types_test/supported_details: Fail
@@ -130,8 +131,7 @@
audiocontext_test/supported: Fail
cache_test/supported: Fail
crypto_test/supported: Fail
-css_test/supported_CssMatrix: Fail
-css_test/supported_DomPoint: Fail
+css_test/supportsPointConversions: Fail
document_test/supports_cssCanvasContext: Fail
element_types_test/supported_content: Fail
element_types_test/supported_datalist: Fail
@@ -203,6 +203,7 @@
webgl_1_test/supported: Fail
websocket_test/supported: Fail
websql_test/supported: Fail
+worker_test/supported: Fail
xhr_cross_origin_test/supported: Fail
xhr_test/supported_HttpRequestProgressEvent: Fail
xhr_test/supported_onLoadEnd: Fail
@@ -274,8 +275,7 @@
audiobuffersourcenode_test/supported: Fail
audiocontext_test/supported: Fail
crypto_test/supported: Fail
-css_test/supported_CssMatrix: Fail
-css_test/supported_DomPoint: Fail
+css_test/supportsPointConversions: Fail
document_test/supports_cssCanvasContext: Fail
indexeddb_1_test/supported: Fail
indexeddb_1_test/supportsDatabaseNames: Fail
@@ -299,8 +299,7 @@
audiobuffersourcenode_test/supported: Fail
audiocontext_test/supported: Fail
crypto_test/supported: Fail
-css_test/supported_CssMatrix: Fail
-css_test/supported_DomPoint: Fail
+css_test/supportsPointConversions: Fail
document_test/supports_cssCanvasContext: Fail
element_types_test/supported_content: Fail
element_types_test/supported_details: Fail
diff --git a/tests/html/node_test.dart b/tests/html/node_test.dart
index 7b4b17d..b2c8399 100644
--- a/tests/html/node_test.dart
+++ b/tests/html/node_test.dart
@@ -26,6 +26,15 @@
predicate((x) => x is InputElement, 'is an InputElement');
group('functional', () {
+ test('toString', () {
+ final nodes = makeNodeWithChildren();
+ // TODO(efortuna): Update this test when you have actual toString methods
+ // for the items in the node List as well.
+ expect(nodes.nodes.toString(), "[Foo, br, baz]");
+ final node = makeNode();
+ expect(node.nodes.toString(), '[]');
+ });
+
test('replaceWith', () {
final node = makeNodeWithChildren();
final subnode = node.nodes[1];
diff --git a/tests/html/streams_test.dart b/tests/html/streams_test.dart
index 3d3f16c..b0feb5e 100644
--- a/tests/html/streams_test.dart
+++ b/tests/html/streams_test.dart
@@ -191,7 +191,7 @@
});
test('reduce', () {
- stream.reduce(null, (a, b) => null).then((_) {});
+ stream.reduce((a, b) => null).then((_) {});
});
test('fold', () {
@@ -214,14 +214,6 @@
stream.length.then((_) {});
});
- test('min', () {
- stream.min((a, b) => 0).then((_) {});
- });
-
- test('max', () {
- stream.max((a, b) => 0).then((_) {});
- });
-
test('isEmpty', () {
stream.isEmpty.then((_) {});
});
diff --git a/tests/html/svg_test.dart b/tests/html/svg_test.dart
index 0c60712..ee327bf 100644
--- a/tests/html/svg_test.dart
+++ b/tests/html/svg_test.dart
@@ -153,7 +153,6 @@
'is an svg.AnimatedTransformList');
var isCssStyleDeclaration =
predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration');
- var isCssValue = predicate((x) => x is CssValue, 'is a CssValue');
/// Verifies that [e] supports the operations on the svg.Tests interface.
checkSvgTests(e) {
diff --git a/tests/html/svgelement_test.dart b/tests/html/svgelement_test.dart
index 52787a2..c5134cf 100644
--- a/tests/html/svgelement_test.dart
+++ b/tests/html/svgelement_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library SvgElementTest;
+import "package:expect/expect.dart";
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_individual_config.dart';
import 'dart:html';
@@ -14,7 +15,7 @@
var isSvgSvgElement =
predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
- Collection<String> _nodeStrings(Collection<Node> input) {
+ List<String> _nodeStrings(Iterable<Node> input) {
final out = new List<String>();
for (Node n in input) {
if (n is Element) {
diff --git a/tests/html/url_test.dart b/tests/html/url_test.dart
index fec1d44..a4d8e4d 100644
--- a/tests/html/url_test.dart
+++ b/tests/html/url_test.dart
@@ -15,7 +15,7 @@
canvas.width = 100;
canvas.height = 100;
- var context = canvas.context2d;
+ var context = canvas.context2D;
context.fillStyle = 'red';
context.fillRect(0, 0, canvas.width, canvas.height);
diff --git a/tests/html/window_nosuchmethod_test.dart b/tests/html/window_nosuchmethod_test.dart
index 7b8c0ef..0027d1e 100644
--- a/tests/html/window_nosuchmethod_test.dart
+++ b/tests/html/window_nosuchmethod_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library WindowNSMETest;
+import "package:expect/expect.dart";
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html' as dom;
diff --git a/tests/html/worker_test.dart b/tests/html/worker_test.dart
new file mode 100644
index 0000000..81b8558
--- /dev/null
+++ b/tests/html/worker_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library worker_test;
+import '../../pkg/unittest/lib/unittest.dart';
+import '../../pkg/unittest/lib/html_individual_config.dart';
+import 'dart:html';
+
+main() {
+ useHtmlIndividualConfiguration();
+
+ group('supported', () {
+ test('supported', () {
+ expect(Worker.supported, isTrue);
+ });
+ });
+
+ var workerScript = '''postMessage('WorkerMessage');''';
+
+ group('functional', () {
+
+ test('unsupported', () {
+ var expectation = Worker.supported ? returnsNormally : throws;
+
+ expect(() {
+ new Worker('worker.js');
+ }, expectation);
+ });
+
+ if (!Worker.supported) {
+ return;
+ }
+
+ test('works', () {
+ // Use Blob to make a local URL so we don't have to have a separate file.
+ var blob = new Blob([workerScript], 'text/javascript');
+ var url = Url.createObjectUrl(blob);
+ var worker = new Worker(url);
+ return worker.onMessage.first.then((e) {
+ expect(e.data, 'WorkerMessage');
+ });
+ });
+ });
+}
+
diff --git a/tests/isolate/global_error_handler2_test.dart b/tests/isolate/global_error_handler2_test.dart
index 7b6e876..72f0d6d 100644
--- a/tests/isolate/global_error_handler2_test.dart
+++ b/tests/isolate/global_error_handler2_test.dart
@@ -4,6 +4,7 @@
library test;
+import 'package:expect/expect.dart';
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/isolate/global_error_handler_stream2_test.dart b/tests/isolate/global_error_handler_stream2_test.dart
index db07be7..ef079d0 100644
--- a/tests/isolate/global_error_handler_stream2_test.dart
+++ b/tests/isolate/global_error_handler_stream2_test.dart
@@ -4,6 +4,7 @@
library test;
+import 'package:expect/expect.dart';
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/isolate/global_error_handler_stream_test.dart b/tests/isolate/global_error_handler_stream_test.dart
index 5c09487..4fcd8bf 100644
--- a/tests/isolate/global_error_handler_stream_test.dart
+++ b/tests/isolate/global_error_handler_stream_test.dart
@@ -19,7 +19,7 @@
}
}
-void startTest(StreamSink finishSink) {
+void startTest(EventSink finishSink) {
firstFunction = () { throw new RuntimeError("ignore exception"); };
finishFunction = () { finishSink.add("done"); finishSink.close(); };
new Timer(Duration.ZERO, runFunctions);
@@ -36,7 +36,7 @@
main() {
var box = new MessageBox();
var timer;
- StreamSink otherIsolate = streamSpawnFunction(runTest, globalErrorHandler);
+ EventSink otherIsolate = streamSpawnFunction(runTest, globalErrorHandler);
otherIsolate.add(box.sink);
otherIsolate.close();
box.stream.single.then((msg) {
diff --git a/tests/isolate/illegal_msg_stream_test.dart b/tests/isolate/illegal_msg_stream_test.dart
index 663572b..bcc9135 100644
--- a/tests/isolate/illegal_msg_stream_test.dart
+++ b/tests/isolate/illegal_msg_stream_test.dart
@@ -4,6 +4,7 @@
library test;
+import 'package:expect/expect.dart';
import 'dart:isolate';
funcFoo(x) => x + 2;
diff --git a/tests/isolate/illegal_msg_test.dart b/tests/isolate/illegal_msg_test.dart
index 51b442c..434edc3 100644
--- a/tests/isolate/illegal_msg_test.dart
+++ b/tests/isolate/illegal_msg_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library illegal_msg_tests;
+import "package:expect/expect.dart";
import 'dart:isolate';
funcFoo(x) => x + 2;
diff --git a/tests/isolate/isolate_negative_test.dart b/tests/isolate/isolate_negative_test.dart
index 5fe9e30..7f753f2 100644
--- a/tests/isolate/isolate_negative_test.dart
+++ b/tests/isolate/isolate_negative_test.dart
@@ -5,6 +5,7 @@
// Dart test program for testing that isolates are spawned.
library IsolateNegativeTest;
+import "package:expect/expect.dart";
import 'dart:isolate';
import '../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/isolate/port_test.dart b/tests/isolate/port_test.dart
index 8799af7..1de2c3c 100644
--- a/tests/isolate/port_test.dart
+++ b/tests/isolate/port_test.dart
@@ -7,6 +7,7 @@
// here. To keep things simple, we don't use the unittest library here.
library PortTest;
+import "package:expect/expect.dart";
import 'dart:isolate';
import '../../pkg/unittest/lib/matcher.dart';
diff --git a/tests/isolate/serialization_test.dart b/tests/isolate/serialization_test.dart
index c69042d..8a8cc25 100644
--- a/tests/isolate/serialization_test.dart
+++ b/tests/isolate/serialization_test.dart
@@ -9,6 +9,7 @@
// Serialization test.
// ---------------------------------------------------------------------------
library SerializationTest;
+import "package:expect/expect.dart";
import 'dart:isolate';
main() {
diff --git a/tests/isolate/stream_mangling_test.dart b/tests/isolate/stream_mangling_test.dart
index 824d3ae..232a084 100644
--- a/tests/isolate/stream_mangling_test.dart
+++ b/tests/isolate/stream_mangling_test.dart
@@ -4,6 +4,7 @@
library stream_mangling_test;
+import "package:expect/expect.dart";
import 'dart:isolate';
import '../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/json/json_test.dart b/tests/json/json_test.dart
index 1fe74e5..af68004 100644
--- a/tests/json/json_test.dart
+++ b/tests/json/json_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library json_tests;
+import "package:expect/expect.dart";
import 'dart:json' as json;
import 'dart:html';
import '../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/language/abstract_getter_test.dart b/tests/language/abstract_getter_test.dart
index a745e35..7befb6c 100644
--- a/tests/language/abstract_getter_test.dart
+++ b/tests/language/abstract_getter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to ensure that an abstract getter is not mistaken for a field.
class Foo {
diff --git a/tests/language/abstract_runtime_error_test.dart b/tests/language/abstract_runtime_error_test.dart
index ceb973c..c408ec8 100644
--- a/tests/language/abstract_runtime_error_test.dart
+++ b/tests/language/abstract_runtime_error_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test various conditions around instantiating an abstract class.
// From The Dart Programming Langauge Specification, 11.11.1 "New":
diff --git a/tests/language/abstract_syntax_test.dart b/tests/language/abstract_syntax_test.dart
index b3f0a20..531b0ef2 100644
--- a/tests/language/abstract_syntax_test.dart
+++ b/tests/language/abstract_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var b = new B();
Expect.equals(42, b.foo());
diff --git a/tests/language/ackermann_test.dart b/tests/language/ackermann_test.dart
index 4d95f810..69fab1b 100644
--- a/tests/language/ackermann_test.dart
+++ b/tests/language/ackermann_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart version of two-argument Ackermann-Peter function.
+import "package:expect/expect.dart";
+
class AckermannTest {
static ack(m, n) {
return m == 0 ?
diff --git a/tests/language/adjacent_const_string_literals_test.dart b/tests/language/adjacent_const_string_literals_test.dart
index 6a7eb81..3111c29 100644
--- a/tests/language/adjacent_const_string_literals_test.dart
+++ b/tests/language/adjacent_const_string_literals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Conster {
const Conster(this.value);
diff --git a/tests/language/adjacent_string_literals_test.dart b/tests/language/adjacent_string_literals_test.dart
index 9c1efcf..dacdc81 100644
--- a/tests/language/adjacent_string_literals_test.dart
+++ b/tests/language/adjacent_string_literals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
testEmpty();
testInterpolation();
diff --git a/tests/language/allocate_large_object_test.dart b/tests/language/allocate_large_object_test.dart
index 54347ce..1cd7016 100644
--- a/tests/language/allocate_large_object_test.dart
+++ b/tests/language/allocate_large_object_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int a;
double d1;
diff --git a/tests/language/allocate_test.dart b/tests/language/allocate_test.dart
index db62167..1f2fce2 100644
--- a/tests/language/allocate_test.dart
+++ b/tests/language/allocate_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
class MyAllocate {
const MyAllocate([int value = 0]) : value_ = value;
int getValue() { return value_; }
diff --git a/tests/language/argument_definition2_test.dart b/tests/language/argument_definition2_test.dart
index c59b061..cd458f0 100644
--- a/tests/language/argument_definition2_test.dart
+++ b/tests/language/argument_definition2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
test1(bool passed, [a = 42]) {
if (passed) {
Expect.equals(54, a);
diff --git a/tests/language/argument_definition3_test.dart b/tests/language/argument_definition3_test.dart
index be74835..0f9a125 100644
--- a/tests/language/argument_definition3_test.dart
+++ b/tests/language/argument_definition3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
new Param.test1(false);
new Param.test1(true, 42);
diff --git a/tests/language/argument_definition4_test.dart b/tests/language/argument_definition4_test.dart
index f58157f..69ed794 100644
--- a/tests/language/argument_definition4_test.dart
+++ b/tests/language/argument_definition4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
test1(bool passed, {a: 42}) {
if (passed) {
Expect.equals(54, a);
diff --git a/tests/language/argument_definition5_test.dart b/tests/language/argument_definition5_test.dart
index 331499a..ae8af0a 100644
--- a/tests/language/argument_definition5_test.dart
+++ b/tests/language/argument_definition5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var x = "";
test(String str, [onError(String)]) {
diff --git a/tests/language/argument_definition6_test.dart b/tests/language/argument_definition6_test.dart
index 5dc8748..5ac86b4 100644
--- a/tests/language/argument_definition6_test.dart
+++ b/tests/language/argument_definition6_test.dart
@@ -7,6 +7,7 @@
// Parameters used to be passed in the wrong order in a constructor in the
// presence of parameter checks.
+import 'package:expect/expect.dart';
class A {
A(expect1, expect2, value1, value2, {layers, serviceUrl}) {
diff --git a/tests/language/argument_definition_test.dart b/tests/language/argument_definition_test.dart
index 14d7e6d..31d8431d 100644
--- a/tests/language/argument_definition_test.dart
+++ b/tests/language/argument_definition_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing argument definition test.
+import "package:expect/expect.dart";
+
int test(int a, {int b: 2, int c: 3}) {
int result = 0;
?b;
diff --git a/tests/language/arithmetic2_test.dart b/tests/language/arithmetic2_test.dart
index b0715e0..0952f2b 100644
--- a/tests/language/arithmetic2_test.dart
+++ b/tests/language/arithmetic2_test.dart
@@ -4,6 +4,8 @@
// Dart test program to test arithmetic operations.
// @static-clean
+import "package:expect/expect.dart";
+
class A {
static foo() => 499;
}
diff --git a/tests/language/arithmetic_canonicalization_test.dart b/tests/language/arithmetic_canonicalization_test.dart
index cf87e9e..cc0f795 100644
--- a/tests/language/arithmetic_canonicalization_test.dart
+++ b/tests/language/arithmetic_canonicalization_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test canonicalization of simple arithmetic equivalences.
+import "package:expect/expect.dart";
+
main() {
for (var i = 0; i < 5000; i++) {
Expect.isTrue(mul1double(i) is double);
diff --git a/tests/language/arithmetic_test.dart b/tests/language/arithmetic_test.dart
index f6abde7..e28ab716 100644
--- a/tests/language/arithmetic_test.dart
+++ b/tests/language/arithmetic_test.dart
@@ -4,6 +4,7 @@
// Dart test program to test arithmetic operations.
library arithmetic_test;
+import "package:expect/expect.dart";
import 'dart:math';
class ArithmeticTest {
diff --git a/tests/language/assertion_test.dart b/tests/language/assertion_test.dart
index 8761bd6..68bdf04 100644
--- a/tests/language/assertion_test.dart
+++ b/tests/language/assertion_test.dart
@@ -5,6 +5,8 @@
//
// Dart test program testing assert statements.
+import "package:expect/expect.dart";
+
class AssertionTest {
static testTrue() {
int i = 0;
diff --git a/tests/language/assign_op_test.dart b/tests/language/assign_op_test.dart
index 440eaa8..00378c7 100644
--- a/tests/language/assign_op_test.dart
+++ b/tests/language/assign_op_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing assign operators.
+import "package:expect/expect.dart";
+
class AssignOpTest {
AssignOpTest() {}
diff --git a/tests/language/assign_top_method_test.dart b/tests/language/assign_top_method_test.dart
index eb85481..923d9e0 100644
--- a/tests/language/assign_top_method_test.dart
+++ b/tests/language/assign_top_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
method() { return 0; }
main() {
diff --git a/tests/language/bad_initializer2_negative_test.dart b/tests/language/bad_initializer2_negative_test.dart
index c554002..3f0fce0 100644
--- a/tests/language/bad_initializer2_negative_test.dart
+++ b/tests/language/bad_initializer2_negative_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Variable initializer must not reference the initialized variable.
+import "package:expect/expect.dart";
+
class BadInitializer2NegativeTest {
static testMain() {
var foo = (int n) {
diff --git a/tests/language/bad_named_parameters2_test.dart b/tests/language/bad_named_parameters2_test.dart
index 03450a1..1d0a273 100644
--- a/tests/language/bad_named_parameters2_test.dart
+++ b/tests/language/bad_named_parameters2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing bad named parameters.
+import "package:expect/expect.dart";
+
class BadNamedParameters2Test {
diff --git a/tests/language/bad_named_parameters_test.dart b/tests/language/bad_named_parameters_test.dart
index 99a82b8..bbe9b28 100644
--- a/tests/language/bad_named_parameters_test.dart
+++ b/tests/language/bad_named_parameters_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing bad named parameters.
+import "package:expect/expect.dart";
+
class BadNamedParametersTest {
diff --git a/tests/language/bailout2_test.dart b/tests/language/bailout2_test.dart
index 085c1d8..4a2b5607 100644
--- a/tests/language/bailout2_test.dart
+++ b/tests/language/bailout2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var a;
main() {
diff --git a/tests/language/bailout3_test.dart b/tests/language/bailout3_test.dart
index 16cc121..ca8441e 100644
--- a/tests/language/bailout3_test.dart
+++ b/tests/language/bailout3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that the return type of a method is being registered for both
// its bailout and optimized version in dart2js.
diff --git a/tests/language/bailout4_test.dart b/tests/language/bailout4_test.dart
index 52e9713..54c2f3f 100644
--- a/tests/language/bailout4_test.dart
+++ b/tests/language/bailout4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that dart2s computes the right bailout environment in presence
// of nested loops.
diff --git a/tests/language/bailout5_test.dart b/tests/language/bailout5_test.dart
index 157e1ca..fee2b81 100644
--- a/tests/language/bailout5_test.dart
+++ b/tests/language/bailout5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to make sure the bailout environment in dart2js is correct.
var global;
diff --git a/tests/language/bailout6_test.dart b/tests/language/bailout6_test.dart
index 5227f65..38b84db 100644
--- a/tests/language/bailout6_test.dart
+++ b/tests/language/bailout6_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for dart2js to make sure the computed bailout environment is
// correct.
diff --git a/tests/language/bailout7_test.dart b/tests/language/bailout7_test.dart
index e61d688..033a47a 100644
--- a/tests/language/bailout7_test.dart
+++ b/tests/language/bailout7_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to make sure the do/while loop exit condition is generated.
var global;
diff --git a/tests/language/bailout_test.dart b/tests/language/bailout_test.dart
index e5e5653..a88780d 100644
--- a/tests/language/bailout_test.dart
+++ b/tests/language/bailout_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that a call to a bailout method in dart2js resolves to the
// right method.
diff --git a/tests/language/bind_test.dart b/tests/language/bind_test.dart
index e73f68e..3617af3 100644
--- a/tests/language/bind_test.dart
+++ b/tests/language/bind_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Bound {
run() {
return 42;
diff --git a/tests/language/bit_operations_test.dart b/tests/language/bit_operations_test.dart
index a28b9ab..f4d58dd 100644
--- a/tests/language/bit_operations_test.dart
+++ b/tests/language/bit_operations_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing bitwise operations.
+import "package:expect/expect.dart";
+
class BitOperationsTest {
static testMain() {
for (int i = 0; i < 4; i++) {
diff --git a/tests/language/bit_shift_test.dart b/tests/language/bit_shift_test.dart
index edbd1eb..3032736 100644
--- a/tests/language/bit_shift_test.dart
+++ b/tests/language/bit_shift_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
constants() {
Expect.equals(0, 499 >> 33);
Expect.equals(0, (499 << 33) & 0xFFFFFFFF);
diff --git a/tests/language/block_scope_test.dart b/tests/language/block_scope_test.dart
index 6ae0495..cc19981 100644
--- a/tests/language/block_scope_test.dart
+++ b/tests/language/block_scope_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo() => 123;
void testShadowingScope1() {
diff --git a/tests/language/bool_test.dart b/tests/language/bool_test.dart
index 6f1e562..4015c18 100644
--- a/tests/language/bool_test.dart
+++ b/tests/language/bool_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing basic boolean properties.
// @static-clean
diff --git a/tests/language/branch_canonicalization_test.dart b/tests/language/branch_canonicalization_test.dart
index 0735076..a317d42 100644
--- a/tests/language/branch_canonicalization_test.dart
+++ b/tests/language/branch_canonicalization_test.dart
@@ -5,6 +5,8 @@
// Test that branch fusion correctly sets branch environment for comparisons
// that require unboxing and does not fuse branches that can deoptimize.
+import "package:expect/expect.dart";
+
var sideEffect = true;
barDouble(a, b) {
diff --git a/tests/language/branches_test.dart b/tests/language/branches_test.dart
index d893cbc..31fee90 100644
--- a/tests/language/branches_test.dart
+++ b/tests/language/branches_test.dart
@@ -4,6 +4,8 @@
// Dart test for branches. Make sure that shortcuts work, even if they have
// to jump over several expressions.
+import "package:expect/expect.dart";
+
class BranchesTest {
static bool f() {
Expect.equals("Never reached", 0);
diff --git a/tests/language/break_test.dart b/tests/language/break_test.dart
index 68cd63c..672ffff 100644
--- a/tests/language/break_test.dart
+++ b/tests/language/break_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for breaks in for, do/while and while loops.
+import "package:expect/expect.dart";
+
class BreakTest {
static testMain() {
int i;
diff --git a/tests/language/built_in_identifier_prefix_test.dart b/tests/language/built_in_identifier_prefix_test.dart
index cb08c87..de995c9 100644
--- a/tests/language/built_in_identifier_prefix_test.dart
+++ b/tests/language/built_in_identifier_prefix_test.dart
@@ -26,6 +26,7 @@
// abstract<dynamic> foo;" is not illegal because "abstract" is used
// as a typeName.
+import "package:expect/expect.dart";
import 'built_in_identifier_prefix_library_abstract.dart' as abstract;
import 'built_in_identifier_prefix_library_as.dart' as as;
import 'built_in_identifier_prefix_library_dynamic.dart' as dynamic;
diff --git a/tests/language/call_constructor_on_unresolvable_class_test.dart b/tests/language/call_constructor_on_unresolvable_class_test.dart
index 4c0ab7f..9e02d7d 100644
--- a/tests/language/call_constructor_on_unresolvable_class_test.dart
+++ b/tests/language/call_constructor_on_unresolvable_class_test.dart
@@ -5,6 +5,7 @@
// Check that calling a constructor of a class that cannot be resolved causes
// a runtime error.
+import "package:expect/expect.dart";
import 'dart:math';
never() {
diff --git a/tests/language/call_nonexistent_constructor_test.dart b/tests/language/call_nonexistent_constructor_test.dart
index 5e3bdf4..1e661a7 100644
--- a/tests/language/call_nonexistent_constructor_test.dart
+++ b/tests/language/call_nonexistent_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// When attempting to call a nonexistent constructor, check that a
// NoSuchMethodError is thrown.
diff --git a/tests/language/call_nonexistent_static_test.dart b/tests/language/call_nonexistent_static_test.dart
index f114be9..dd2835f 100644
--- a/tests/language/call_nonexistent_static_test.dart
+++ b/tests/language/call_nonexistent_static_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// When attempting to call a nonexistent static method, getter or setter, check
// that a NoSuchMethodError is thrown.
diff --git a/tests/language/call_operator_test.dart b/tests/language/call_operator_test.dart
index c3e2858..ecaefb5 100644
--- a/tests/language/call_operator_test.dart
+++ b/tests/language/call_operator_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// simple test with no types in signature
class A1 {
diff --git a/tests/language/call_property_test.dart b/tests/language/call_property_test.dart
index 27a658d..fbab146 100644
--- a/tests/language/call_property_test.dart
+++ b/tests/language/call_property_test.dart
@@ -5,6 +5,8 @@
// Test that a class with a [call] property does not implement [Function] or
// a typedef of function type.
+import 'package:expect/expect.dart';
+
class Call {
int get call => 0;
}
diff --git a/tests/language/call_test.dart b/tests/language/call_test.dart
index 6e87507..bd6d24f 100644
--- a/tests/language/call_test.dart
+++ b/tests/language/call_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
bar(a) {
return a is String;
diff --git a/tests/language/call_this_test.dart b/tests/language/call_this_test.dart
new file mode 100644
index 0000000..55e7ccd
--- /dev/null
+++ b/tests/language/call_this_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that dart2js treats [:this():] as a closure send.
+
+import "package:expect/expect.dart";
+
+class A {
+ call() => 42;
+ test1() => this();
+ test2() => (this)();
+}
+
+main() {
+ Expect.equals(42, (new A()).test1());
+ Expect.equals(42, (new A()).test2());
+}
diff --git a/tests/language/call_through_getter_test.dart b/tests/language/call_through_getter_test.dart
index fc24d4d..79ad94eff 100644
--- a/tests/language/call_through_getter_test.dart
+++ b/tests/language/call_through_getter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests that we can call functions through getters.
const TOP_LEVEL_CONST = 1;
diff --git a/tests/language/call_through_null_getter_test.dart b/tests/language/call_through_null_getter_test.dart
index 24edb03..6ef59ed 100644
--- a/tests/language/call_through_null_getter_test.dart
+++ b/tests/language/call_through_null_getter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests that we can call functions through getters which return null.
const TOP_LEVEL_NULL = null;
diff --git a/tests/language/canonical_const2_test.dart b/tests/language/canonical_const2_test.dart
index 3508885..25a350e 100644
--- a/tests/language/canonical_const2_test.dart
+++ b/tests/language/canonical_const2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Check that compile-time constants are correctly canonicalized.
main() {
diff --git a/tests/language/canonical_const_test.dart b/tests/language/canonical_const_test.dart
index 4c91baa..8a04a3f 100644
--- a/tests/language/canonical_const_test.dart
+++ b/tests/language/canonical_const_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that initializers of static const fields are compile time constants.
+import "package:expect/expect.dart";
+
class CanonicalConstTest {
static const A = const C1();
static const B = const C2();
diff --git a/tests/language/cascade_2_test.dart b/tests/language/cascade_2_test.dart
index 2675f61..4e5cdbc 100644
--- a/tests/language/cascade_2_test.dart
+++ b/tests/language/cascade_2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test cascades, issues 7494 (vm), 7689 (dart2js).
main() {
diff --git a/tests/language/cascade_in_expression_function_test.dart b/tests/language/cascade_in_expression_function_test.dart
index 2c5852f..5c8c83d 100644
--- a/tests/language/cascade_in_expression_function_test.dart
+++ b/tests/language/cascade_in_expression_function_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
makeMap() => new Map()..[3] = 4 ..[0] = 11;
class MyClass {
diff --git a/tests/language/cascade_in_initializer_list_test.dart b/tests/language/cascade_in_initializer_list_test.dart
index 99f2261..8e7e9ee 100644
--- a/tests/language/cascade_in_initializer_list_test.dart
+++ b/tests/language/cascade_in_initializer_list_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
foo() {}
bar() {}
diff --git a/tests/language/cascade_precedence_test.dart b/tests/language/cascade_precedence_test.dart
index de39f02..acbb373 100644
--- a/tests/language/cascade_precedence_test.dart
+++ b/tests/language/cascade_precedence_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int value;
diff --git a/tests/language/cascade_test.dart b/tests/language/cascade_test.dart
index c962fda..757ad22 100644
--- a/tests/language/cascade_test.dart
+++ b/tests/language/cascade_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test cascades.
class A {
diff --git a/tests/language/cast_test.dart b/tests/language/cast_test.dart
index 6b8eaba..39d7f04 100644
--- a/tests/language/cast_test.dart
+++ b/tests/language/cast_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Test 'expression as Type' casts.
class C {
diff --git a/tests/language/char_escape_test.dart b/tests/language/char_escape_test.dart
index 23c95ca..7b87fbe 100644
--- a/tests/language/char_escape_test.dart
+++ b/tests/language/char_escape_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for reading escape sequences in string literals
+import "package:expect/expect.dart";
+
class CharEscapeTest {
static testMain() {
var x00 = "\x00";
diff --git a/tests/language/checked_null_test.dart b/tests/language/checked_null_test.dart
index cd95d61..0f2a200f 100644
--- a/tests/language/checked_null_test.dart
+++ b/tests/language/checked_null_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
Map a;
Comparator b;
diff --git a/tests/language/class_codegen_test.dart b/tests/language/class_codegen_test.dart
index 1b1c738..bfec70f 100644
--- a/tests/language/class_codegen_test.dart
+++ b/tests/language/class_codegen_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
A() : x = 3;
foo() => x;
diff --git a/tests/language/class_cycle_test.dart b/tests/language/class_cycle_test.dart
index e41181e..4c8a382 100644
--- a/tests/language/class_cycle_test.dart
+++ b/tests/language/class_cycle_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check fail because of cycles in super class relationship.
+import "package:expect/expect.dart";
+
class Foo implements Bar {
}
diff --git a/tests/language/class_literal_test.dart b/tests/language/class_literal_test.dart
index 21bc0fc..246f99c 100644
--- a/tests/language/class_literal_test.dart
+++ b/tests/language/class_literal_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test class literal expressions.
class Class {
diff --git a/tests/language/class_test.dart b/tests/language/class_test.dart
index 10a00f5..7a03fb1 100644
--- a/tests/language/class_test.dart
+++ b/tests/language/class_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests basic classes and methods.
class ClassTest {
ClassTest() {}
diff --git a/tests/language/closure2_test.dart b/tests/language/closure2_test.dart
index b600518..bf3cf01 100644
--- a/tests/language/closure2_test.dart
+++ b/tests/language/closure2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for closures.
+import "package:expect/expect.dart";
+
bounce(fn) {
return fn();
}
diff --git a/tests/language/closure3_test.dart b/tests/language/closure3_test.dart
index c01bfc1..358a78a 100644
--- a/tests/language/closure3_test.dart
+++ b/tests/language/closure3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that a NoSuchMethodError is thrown even when an expression
// seems to be free of side-effects.
diff --git a/tests/language/closure4_test.dart b/tests/language/closure4_test.dart
index abc8bb1..a1b0996 100644
--- a/tests/language/closure4_test.dart
+++ b/tests/language/closure4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart2js failed when a declared function was captured inside itself.
foo(f) => f(499);
diff --git a/tests/language/closure5_test.dart b/tests/language/closure5_test.dart
index 5aebb1e..4ce0744 100644
--- a/tests/language/closure5_test.dart
+++ b/tests/language/closure5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart2js failed when a declared function was captured inside itself.
foo(f) => f(499);
diff --git a/tests/language/closure6_test.dart b/tests/language/closure6_test.dart
index e88852b..774aa0d 100644
--- a/tests/language/closure6_test.dart
+++ b/tests/language/closure6_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that captured final variables are correctly mangled.
class A {
diff --git a/tests/language/closure7_test.dart b/tests/language/closure7_test.dart
index 491cb20..58c7131 100644
--- a/tests/language/closure7_test.dart
+++ b/tests/language/closure7_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that implicitly bound closures work correctly
class A {
diff --git a/tests/language/closure_break1_test.dart b/tests/language/closure_break1_test.dart
index 5f5ead7..e1fdcac 100644
--- a/tests/language/closure_break1_test.dart
+++ b/tests/language/closure_break1_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for closures.
+import "package:expect/expect.dart";
+
class ClosureBreak1 {
ClosureBreak1(this.field);
int field;
diff --git a/tests/language/closure_break2_test.dart b/tests/language/closure_break2_test.dart
index 38b1c85..5f05890 100644
--- a/tests/language/closure_break2_test.dart
+++ b/tests/language/closure_break2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for closures.
+import "package:expect/expect.dart";
+
class ClosureBreak2 {
ClosureBreak2(this.field);
int field;
diff --git a/tests/language/closure_break_test.dart b/tests/language/closure_break_test.dart
index 0aca644..e21717b 100644
--- a/tests/language/closure_break_test.dart
+++ b/tests/language/closure_break_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for closures.
+import "package:expect/expect.dart";
+
class ClosureBreak {
ClosureBreak(this.field);
int field;
diff --git a/tests/language/closure_in_constructor_test.dart b/tests/language/closure_in_constructor_test.dart
index d8fc8d3..1975cdc 100644
--- a/tests/language/closure_in_constructor_test.dart
+++ b/tests/language/closure_in_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
var closure;
diff --git a/tests/language/closure_in_field_initializer_test.dart b/tests/language/closure_in_field_initializer_test.dart
index 88ca236..bf0198a 100644
--- a/tests/language/closure_in_field_initializer_test.dart
+++ b/tests/language/closure_in_field_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Foo {
var closures = {
'a': (x, y) => x + y
diff --git a/tests/language/closure_in_initializer2_test.dart b/tests/language/closure_in_initializer2_test.dart
index 3c1e1bd..b44b0c7 100644
--- a/tests/language/closure_in_initializer2_test.dart
+++ b/tests/language/closure_in_initializer2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S {
S() {
Expect.equals(2, this.f());
diff --git a/tests/language/closure_in_initializer_test.dart b/tests/language/closure_in_initializer_test.dart
index 607553c..04f1033 100644
--- a/tests/language/closure_in_initializer_test.dart
+++ b/tests/language/closure_in_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var f;
var g;
diff --git a/tests/language/closure_parameter_types_test.dart b/tests/language/closure_parameter_types_test.dart
index a9fa956..2c1f7bc 100644
--- a/tests/language/closure_parameter_types_test.dart
+++ b/tests/language/closure_parameter_types_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for dart2js, where the optimizer was too agressive
// about parameter types of closures.
diff --git a/tests/language/closure_shared_state_test.dart b/tests/language/closure_shared_state_test.dart
index 99dda76..8a063a1 100644
--- a/tests/language/closure_shared_state_test.dart
+++ b/tests/language/closure_shared_state_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests for closures sharing mutable bindings.
var f;
diff --git a/tests/language/closure_test.dart b/tests/language/closure_test.dart
index 0d7220b..9dc3a90 100644
--- a/tests/language/closure_test.dart
+++ b/tests/language/closure_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for closures.
+import "package:expect/expect.dart";
+
class A {
var field;
A(this.field) {}
diff --git a/tests/language/closure_type_test.dart b/tests/language/closure_type_test.dart
index 8908de7..59d11de 100644
--- a/tests/language/closure_type_test.dart
+++ b/tests/language/closure_type_test.dart
@@ -5,6 +5,7 @@
// time.
library closure_type_test;
+import "package:expect/expect.dart";
import 'dart:math' as math;
class Math {
diff --git a/tests/language/closure_type_variable_test.dart b/tests/language/closure_type_variable_test.dart
index 4f73267..2ed61c2 100644
--- a/tests/language/closure_type_variable_test.dart
+++ b/tests/language/closure_type_variable_test.dart
@@ -4,6 +4,8 @@
// Test that the type argument is available inside a closure.
+import "package:expect/expect.dart";
+
class A<T> {
foo() {
bar() => T;
diff --git a/tests/language/closure_type_variables_test.dart b/tests/language/closure_type_variables_test.dart
index f870588..79c6703 100644
--- a/tests/language/closure_type_variables_test.dart
+++ b/tests/language/closure_type_variables_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that type variables are available in closures.
class A<T> {
diff --git a/tests/language/closure_with_super_field_test.dart b/tests/language/closure_with_super_field_test.dart
index ff64fa2..67f75d1 100644
--- a/tests/language/closure_with_super_field_test.dart
+++ b/tests/language/closure_with_super_field_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int a;
A(): a = 42;
diff --git a/tests/language/closure_with_super_send_test.dart b/tests/language/closure_with_super_send_test.dart
index 7e86616..bcaae49 100644
--- a/tests/language/closure_with_super_send_test.dart
+++ b/tests/language/closure_with_super_send_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test a closurized super send.
class Super {
diff --git a/tests/language/closures_with_complex_params_test.dart b/tests/language/closures_with_complex_params_test.dart
index 8e1ddc7..bf20e49 100644
--- a/tests/language/closures_with_complex_params_test.dart
+++ b/tests/language/closures_with_complex_params_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests for parsing closures with complex parameter types.
main() {
diff --git a/tests/language/code_after_try_is_executed_test.dart b/tests/language/code_after_try_is_executed_test.dart
index 76ccbf6..010cc6a 100644
--- a/tests/language/code_after_try_is_executed_test.dart
+++ b/tests/language/code_after_try_is_executed_test.dart
@@ -5,6 +5,8 @@
// test cannot use Expect.throws, because Expect.throws uses the same
// pattern.
+import "package:expect/expect.dart";
+
main() {
var exception;
try {
diff --git a/tests/language/comparison_test.dart b/tests/language/comparison_test.dart
index 4a19920..2df0fd5 100644
--- a/tests/language/comparison_test.dart
+++ b/tests/language/comparison_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing comparison operators.
+import "package:expect/expect.dart";
+
class Helper {
static bool STRICT_EQ(a, b) {
return identical(a, b);
diff --git a/tests/language/compile_time_constant10_test.dart b/tests/language/compile_time_constant10_test.dart
index 5902fd2..a2d1a02 100644
--- a/tests/language/compile_time_constant10_test.dart
+++ b/tests/language/compile_time_constant10_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that 'identical(a,b)' is a compile-time constant.
class C {
diff --git a/tests/language/compile_time_constant2_test.dart b/tests/language/compile_time_constant2_test.dart
index 1df0b92..132a93b 100644
--- a/tests/language/compile_time_constant2_test.dart
+++ b/tests/language/compile_time_constant2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const x = 19;
const y = 3;
const z = -5;
diff --git a/tests/language/compile_time_constant3_test.dart b/tests/language/compile_time_constant3_test.dart
index 1c14c80..1723086 100644
--- a/tests/language/compile_time_constant3_test.dart
+++ b/tests/language/compile_time_constant3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const x = 19.5;
const y = 3.3;
const g1 = x + y;
diff --git a/tests/language/compile_time_constant5_test.dart b/tests/language/compile_time_constant5_test.dart
index 8357a48..5136b29 100644
--- a/tests/language/compile_time_constant5_test.dart
+++ b/tests/language/compile_time_constant5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const x = true;
const g1 = !true;
const g2 = !g1;
diff --git a/tests/language/compile_time_constant6_test.dart b/tests/language/compile_time_constant6_test.dart
index 38c8729..b30b2b6 100644
--- a/tests/language/compile_time_constant6_test.dart
+++ b/tests/language/compile_time_constant6_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const g1 = true;
const g2 = 499;
const g3 = "foo";
diff --git a/tests/language/compile_time_constant7_test.dart b/tests/language/compile_time_constant7_test.dart
index 25bf20d..4780b47 100644
--- a/tests/language/compile_time_constant7_test.dart
+++ b/tests/language/compile_time_constant7_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
const A();
toString() => "a";
diff --git a/tests/language/compile_time_constant8_test.dart b/tests/language/compile_time_constant8_test.dart
index f82c158..e39d7f2 100644
--- a/tests/language/compile_time_constant8_test.dart
+++ b/tests/language/compile_time_constant8_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
const A();
toString() => "a";
diff --git a/tests/language/compile_time_constant9_test.dart b/tests/language/compile_time_constant9_test.dart
index 0b0b082..96cf41a 100644
--- a/tests/language/compile_time_constant9_test.dart
+++ b/tests/language/compile_time_constant9_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class B {
const B();
}
diff --git a/tests/language/compile_time_constant_a_test.dart b/tests/language/compile_time_constant_a_test.dart
index 73ff7de..576939f 100644
--- a/tests/language/compile_time_constant_a_test.dart
+++ b/tests/language/compile_time_constant_a_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const m1 = const { 'a': 400 + 99 };
const m2 = const { 'a': 499, 'b': 42 };
const m3 = const { 'm1': m1, 'm2': m2 };
diff --git a/tests/language/compile_time_constant_b_test.dart b/tests/language/compile_time_constant_b_test.dart
index 49e48f9..212dd2f 100644
--- a/tests/language/compile_time_constant_b_test.dart
+++ b/tests/language/compile_time_constant_b_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const m1 = const { '__proto__': 400 + 99 };
const m2 = const { 'a': 499, 'b': 42 };
const m3 = const { '__proto__': 499 };
diff --git a/tests/language/compile_time_constant_d_test.dart b/tests/language/compile_time_constant_d_test.dart
index 6695fbe..e56415f 100644
--- a/tests/language/compile_time_constant_d_test.dart
+++ b/tests/language/compile_time_constant_d_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
final y;
diff --git a/tests/language/compile_time_constant_e_test.dart b/tests/language/compile_time_constant_e_test.dart
index 48fd9e2..9a91f3c 100644
--- a/tests/language/compile_time_constant_e_test.dart
+++ b/tests/language/compile_time_constant_e_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
final y;
diff --git a/tests/language/compile_time_constant_f_test.dart b/tests/language/compile_time_constant_f_test.dart
index 7684178..21c215e 100644
--- a/tests/language/compile_time_constant_f_test.dart
+++ b/tests/language/compile_time_constant_f_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
const A(this.x);
diff --git a/tests/language/compile_time_constant_g_test.dart b/tests/language/compile_time_constant_g_test.dart
index 469aa62..1be8936 100644
--- a/tests/language/compile_time_constant_g_test.dart
+++ b/tests/language/compile_time_constant_g_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
const A(this.x);
diff --git a/tests/language/compile_time_constant_h_test.dart b/tests/language/compile_time_constant_h_test.dart
index 9c3bd98..3409882 100644
--- a/tests/language/compile_time_constant_h_test.dart
+++ b/tests/language/compile_time_constant_h_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A implements B {
final x;
const A(this.x);
diff --git a/tests/language/compile_time_constant_i_test.dart b/tests/language/compile_time_constant_i_test.dart
index c3d3939..7095598 100644
--- a/tests/language/compile_time_constant_i_test.dart
+++ b/tests/language/compile_time_constant_i_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
const A(this.x);
diff --git a/tests/language/compile_time_constant_j_test.dart b/tests/language/compile_time_constant_j_test.dart
index 9715662..8a5ed24 100644
--- a/tests/language/compile_time_constant_j_test.dart
+++ b/tests/language/compile_time_constant_j_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final field;
const A() : field = 499;
diff --git a/tests/language/compile_time_constant_k_test.dart b/tests/language/compile_time_constant_k_test.dart
index 2071587..f4260a3 100644
--- a/tests/language/compile_time_constant_k_test.dart
+++ b/tests/language/compile_time_constant_k_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
const x = const { 'a': 3, 'a': 4 };
const y = const { 'a': 10, 'b': 11, 'a': 12, 'b': 13, 'a': 14 };
const z = const { '__proto__': 496,
diff --git a/tests/language/compile_time_constant_l_test.dart b/tests/language/compile_time_constant_l_test.dart
index d8f8a86..1f6bc50 100644
--- a/tests/language/compile_time_constant_l_test.dart
+++ b/tests/language/compile_time_constant_l_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
const A([x = 499]) : this.x = x;
diff --git a/tests/language/compile_time_constant_m_test.dart b/tests/language/compile_time_constant_m_test.dart
index b43eb82..0ae096ea 100644
--- a/tests/language/compile_time_constant_m_test.dart
+++ b/tests/language/compile_time_constant_m_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
const A();
foo([x = const A()]) => x;
diff --git a/tests/language/compile_time_constant_n_test.dart b/tests/language/compile_time_constant_n_test.dart
index af2c5f1..3f621b2 100644
--- a/tests/language/compile_time_constant_n_test.dart
+++ b/tests/language/compile_time_constant_n_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
const A();
operator ==(x) => x == 499;
diff --git a/tests/language/compile_time_constant_o_test.dart b/tests/language/compile_time_constant_o_test.dart
index 8fc4c40..6af0826 100644
--- a/tests/language/compile_time_constant_o_test.dart
+++ b/tests/language/compile_time_constant_o_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test compile-time constants with string-interpolation.
+import "package:expect/expect.dart";
+
const str = "foo";
const m1 = const { "foo": 499 };
const m2 = const { "$str": 499 };
diff --git a/tests/language/compile_time_constant_p_test.dart b/tests/language/compile_time_constant_p_test.dart
index a0ff240..d833ff2 100644
--- a/tests/language/compile_time_constant_p_test.dart
+++ b/tests/language/compile_time_constant_p_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
const A(
this.x /// 01: compile-time error
diff --git a/tests/language/compound_assignment_operator_test.dart b/tests/language/compound_assignment_operator_test.dart
index e875af1..c8a54ab 100644
--- a/tests/language/compound_assignment_operator_test.dart
+++ b/tests/language/compound_assignment_operator_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Tests that lhs of a compound assignement is executed only once.
+import "package:expect/expect.dart";
+
class Indexed {
Indexed() : _f = new List(10), count = 0 {
diff --git a/tests/language/cond_expr_test.dart b/tests/language/cond_expr_test.dart
index 26766bc..8e458cd 100644
--- a/tests/language/cond_expr_test.dart
+++ b/tests/language/cond_expr_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that conditional expressions can contain assignment expressions.
+import "package:expect/expect.dart";
+
var e1, e2;
diff --git a/tests/language/condition_bailout_test.dart b/tests/language/condition_bailout_test.dart
index 60329a5..738d9d7 100644
--- a/tests/language/condition_bailout_test.dart
+++ b/tests/language/condition_bailout_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing closures.
+import "package:expect/expect.dart";
+
class A {
operator -() => this;
diff --git a/tests/language/const_constructor_test.dart b/tests/language/const_constructor_test.dart
index 3eafee8..94dbaee 100644
--- a/tests/language/const_constructor_test.dart
+++ b/tests/language/const_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
final int x;
const A.named() : x = 42;
diff --git a/tests/language/const_counter_negative_test.dart b/tests/language/const_counter_negative_test.dart
index 38ba11e..ad4d835 100644
--- a/tests/language/const_counter_negative_test.dart
+++ b/tests/language/const_counter_negative_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Bug: 4254106 Constant constructors must have (implicit) const parameters.
+import "package:expect/expect.dart";
+
class ConstCounter {
// Incorrect assignment of a non const function to a final field.
const ConstCounter(int i) : nextValue_ = (() => i++);
diff --git a/tests/language/const_escape_frog_test.dart b/tests/language/const_escape_frog_test.dart
index 776ea8e..ea39cc3 100644
--- a/tests/language/const_escape_frog_test.dart
+++ b/tests/language/const_escape_frog_test.dart
@@ -1,3 +1,11 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Test division by power of two.
+// Test that results before and after optimization are the same.
+
+import "package:expect/expect.dart";
+
class Foo {
const Bar<Foo> bar = const Bar/* comment here use to trigger bug 323 */();
}
diff --git a/tests/language/const_factory_redirection_test.dart b/tests/language/const_factory_redirection_test.dart
index 01390a8..3d2fdea 100644
--- a/tests/language/const_factory_redirection_test.dart
+++ b/tests/language/const_factory_redirection_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that factory redirections work for compile-time constants, and
// that abstract classes can redirect.
diff --git a/tests/language/const_init_test.dart b/tests/language/const_init_test.dart
index 78e01f3..3f18dc1 100644
--- a/tests/language/const_init_test.dart
+++ b/tests/language/const_init_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that initializers of static const fields are compile time constants.
+import "package:expect/expect.dart";
+
class Point {
final x_;
final y_;
diff --git a/tests/language/const_list_test.dart b/tests/language/const_list_test.dart
index e05f7a7..e8f95f2 100644
--- a/tests/language/const_list_test.dart
+++ b/tests/language/const_list_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ConstListTest {
static testMain() {
diff --git a/tests/language/const_locals_test.dart b/tests/language/const_locals_test.dart
index 4c57168..8261b15 100644
--- a/tests/language/const_locals_test.dart
+++ b/tests/language/const_locals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test of compile time constant local variables.
const N = 8;
diff --git a/tests/language/const_named_test.dart b/tests/language/const_named_test.dart
index 919551a..94b5598 100644
--- a/tests/language/const_named_test.dart
+++ b/tests/language/const_named_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that const constructors work with named arguments.
+import "package:expect/expect.dart";
+
main() {
var d = const Duration(milliseconds: 499);
Expect.equals(499, d.inMilliseconds);
diff --git a/tests/language/const_nested_test.dart b/tests/language/const_nested_test.dart
index 962c1eb..d78e626 100644
--- a/tests/language/const_nested_test.dart
+++ b/tests/language/const_nested_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test of compile time constant local variables in outer function levels.
const N = 8;
diff --git a/tests/language/const_objects_are_immutable_test.dart b/tests/language/const_objects_are_immutable_test.dart
index 6dd2ac7..c3f6d21 100644
--- a/tests/language/const_objects_are_immutable_test.dart
+++ b/tests/language/const_objects_are_immutable_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that const objects (including literals) are immutable.
+import "package:expect/expect.dart";
+
class A {
const A(this.x, this.y);
final num x, y;
diff --git a/tests/language/const_string_test.dart b/tests/language/const_string_test.dart
index feecc88..4736ca4 100644
--- a/tests/language/const_string_test.dart
+++ b/tests/language/const_string_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Exercises compile-time string constants
main() {
diff --git a/tests/language/const_syntax_test.dart b/tests/language/const_syntax_test.dart
index 7540709..668bb9f 100644
--- a/tests/language/const_syntax_test.dart
+++ b/tests/language/const_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
const f0 = 42;
const f1; /// 01: compile-time error
diff --git a/tests/language/const_test.dart b/tests/language/const_test.dart
index 966bda7..e34eb0d 100644
--- a/tests/language/const_test.dart
+++ b/tests/language/const_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check const classes.
+import "package:expect/expect.dart";
+
class AConst {
const AConst() : b_ = 3 ;
final int b_;
diff --git a/tests/language/constant_fold_equals_test.dart b/tests/language/constant_fold_equals_test.dart
index b69c1e7..48a11d1 100644
--- a/tests/language/constant_fold_equals_test.dart
+++ b/tests/language/constant_fold_equals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var a = 'foo';
for (int i = 0; i < 10; i++) {
diff --git a/tests/language/constant_propagation_phis_test.dart b/tests/language/constant_propagation_phis_test.dart
index 50b84b7..80359f5 100644
--- a/tests/language/constant_propagation_phis_test.dart
+++ b/tests/language/constant_propagation_phis_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that constant propagation correctly updates phis when predecessor's
// reachability changes.
diff --git a/tests/language/constructor2_test.dart b/tests/language/constructor2_test.dart
index c4e9f37..f6050a5 100644
--- a/tests/language/constructor2_test.dart
+++ b/tests/language/constructor2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Expect the initializer expressions E(i) to be evaluated
// in the order 1, 2, 3, ...
// Each expression must be evaluated exactly once.
diff --git a/tests/language/constructor3_test.dart b/tests/language/constructor3_test.dart
index c8916e0..0c5eb51 100644
--- a/tests/language/constructor3_test.dart
+++ b/tests/language/constructor3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Expect the initializer expressions E(i) to be evaluated
// in the order 1, 2, 3, ...
// Each expression must be evaluated exactly once.
diff --git a/tests/language/constructor4_test.dart b/tests/language/constructor4_test.dart
index ad16fb3..b4df9b0 100644
--- a/tests/language/constructor4_test.dart
+++ b/tests/language/constructor4_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Expect the initializer expressions E(i) to be evaluated
// in the order 1, 2, 3, ...
// Each expression must be evaluated exactly once.
diff --git a/tests/language/constructor5_test.dart b/tests/language/constructor5_test.dart
index c087840..77ecd94 100644
--- a/tests/language/constructor5_test.dart
+++ b/tests/language/constructor5_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Super initializer and super constructor body are executed in with the same
// bindings.
diff --git a/tests/language/constructor6_test.dart b/tests/language/constructor6_test.dart
index ff105e8..2f6c991 100644
--- a/tests/language/constructor6_test.dart
+++ b/tests/language/constructor6_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Super initializer and super constructor body are executed in with the same
// bindings.
diff --git a/tests/language/constructor7_test.dart b/tests/language/constructor7_test.dart
index 25468f8..432fe29 100644
--- a/tests/language/constructor7_test.dart
+++ b/tests/language/constructor7_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Expect the initializer expressions E(i) to be evaluated
// in the order 1, 2, 3, ...
// This test has no inheritance but many fields to flush out issues with
diff --git a/tests/language/constructor8_test.dart b/tests/language/constructor8_test.dart
index 0cfcc76..9f05e14 100644
--- a/tests/language/constructor8_test.dart
+++ b/tests/language/constructor8_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for dart2js that used to crash on this program.
class A {
diff --git a/tests/language/constructor_body_test.dart b/tests/language/constructor_body_test.dart
index e365855..d64d61f 100644
--- a/tests/language/constructor_body_test.dart
+++ b/tests/language/constructor_body_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors without function bodies.
+import "package:expect/expect.dart";
+
// Test a non-const constructor works without a body.
class First {
First(int this.value);
diff --git a/tests/language/constructor_default_test.dart b/tests/language/constructor_default_test.dart
index 9154ed4..a8fc22e 100644
--- a/tests/language/constructor_default_test.dart
+++ b/tests/language/constructor_default_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for default constructors.
+import "package:expect/expect.dart";
+
class A {
A() : a = 499;
diff --git a/tests/language/constructor_initializer_test.dart b/tests/language/constructor_initializer_test.dart
index a752ecd..fd328b6 100644
--- a/tests/language/constructor_initializer_test.dart
+++ b/tests/language/constructor_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var _x, _y;
A(x, [y = 10]): _x = x++, _y = y++ {
diff --git a/tests/language/constructor_named_arguments_test.dart b/tests/language/constructor_named_arguments_test.dart
index c320179..63e5e34 100644
--- a/tests/language/constructor_named_arguments_test.dart
+++ b/tests/language/constructor_named_arguments_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for default constructors.
+import "package:expect/expect.dart";
+
String message;
foo() {
diff --git a/tests/language/constructor_redirect_test.dart b/tests/language/constructor_redirect_test.dart
index fe79274..1667493 100644
--- a/tests/language/constructor_redirect_test.dart
+++ b/tests/language/constructor_redirect_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for redirection constructors.
+import "package:expect/expect.dart";
+
class A {
var x;
A(this.x) {}
diff --git a/tests/language/constructor_return_test.dart b/tests/language/constructor_return_test.dart
index 0e49400..8f30645 100644
--- a/tests/language/constructor_return_test.dart
+++ b/tests/language/constructor_return_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart spec 0.03, section 11.10 - generative constructors can only have return
// statements in the form 'return;'.
class A {
diff --git a/tests/language/constructor_test.dart b/tests/language/constructor_test.dart
index 4ca57b1..eb7239c 100644
--- a/tests/language/constructor_test.dart
+++ b/tests/language/constructor_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
class A extends B {
A(x, y) : super(y), a = x { }
diff --git a/tests/language/context2_test.dart b/tests/language/context2_test.dart
index 44550b8..1b4d683 100644
--- a/tests/language/context2_test.dart
+++ b/tests/language/context2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for capturing.
+import "package:expect/expect.dart";
+
// Regression test for issue 5991015.
// @static-clean
diff --git a/tests/language/context_args_with_defaults_test.dart b/tests/language/context_args_with_defaults_test.dart
index 272efc9..7557026 100644
--- a/tests/language/context_args_with_defaults_test.dart
+++ b/tests/language/context_args_with_defaults_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ContextArgsWithDefaultsTest {
static void testMain() {
crasher(1, 'foo')();
diff --git a/tests/language/context_test.dart b/tests/language/context_test.dart
index ec59c94..2cff404 100644
--- a/tests/language/context_test.dart
+++ b/tests/language/context_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for capturing.
+import "package:expect/expect.dart";
+
class ContextTest {
static foo(Function f) {
return f();
diff --git a/tests/language/continue_test.dart b/tests/language/continue_test.dart
index bba2bbe..576c4fe 100644
--- a/tests/language/continue_test.dart
+++ b/tests/language/continue_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for continue in for, do/while and while loops.
+import "package:expect/expect.dart";
+
class ContinueTest {
static testMain() {
int i;
diff --git a/tests/language/core_type_check_test.dart b/tests/language/core_type_check_test.dart
index 4c8c861..86f525b 100644
--- a/tests/language/core_type_check_test.dart
+++ b/tests/language/core_type_check_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
check(value, expectComparable, expectPattern) {
Expect.equals(expectComparable, value is Comparable);
Expect.equals(expectPattern, value is Pattern);
diff --git a/tests/language/crash_6725_test.dart b/tests/language/crash_6725_test.dart
new file mode 100644
index 0000000..f9cbb18
--- /dev/null
+++ b/tests/language/crash_6725_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for a crash in dart2js.
+
+class Fisk {
+ it1(x) {
+ // "key" is unresolved and caused a crash in dart2js.
+ // This is the original example the user reported.
+ for (key in x) {
+ print(key);
+ }
+ }
+
+ it2(x) {
+ // "length" is "intercepted" and handled differently from other
+ // names when an instance of list is observed.
+ for (length in x) {
+ print(length);
+ }
+ }
+
+ it3(x) {
+ // We're pretty sure that there's no "fisk" that is "intercepted".
+ for (fisk in x) {
+ print(fisk);
+ }
+ }
+}
+
+class SubFisk extends Fisk {
+ var key;
+ var length;
+ var fisk;
+}
+
+main() {
+ Fisk f = new SubFisk();
+ var m = (x) {
+ for (undeclared in x) {
+ print(undeclared);
+ }
+ };
+ if (new DateTime.now().millisecondsSinceEpoch == 42) {
+ f = null;
+ m = (x) {};
+ }
+
+ f.it1([87, 42]);
+ if (f.key != 42) {
+ throw 'f.key != 42 (${f.key})';
+ }
+
+ f.it2([87, 42]);
+ if (f.length != 42) {
+ throw 'f.length != 42 (${f.length})';
+ }
+
+ f.it3([87, 42]);
+ if (f.fisk != 42) {
+ throw 'f.fisk != 42 (${f.fisk})';
+ }
+
+ try {
+ m([87, 42]);
+ throw 'NoSuchMethodError expected';
+ } on NoSuchMethodError {
+ // Expected.
+ }
+}
diff --git a/tests/language/ct_const3_test.dart b/tests/language/ct_const3_test.dart
index cc4c91d..0758057 100644
--- a/tests/language/ct_const3_test.dart
+++ b/tests/language/ct_const3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that initializers of const fields can be declared out of order.
+import "package:expect/expect.dart";
+
const P = 2 * (O - N);
const N = 1;
const O = 1 + 3;
diff --git a/tests/language/ct_const4_test.dart b/tests/language/ct_const4_test.dart
index 0c58e52..d7ab8db 100644
--- a/tests/language/ct_const4_test.dart
+++ b/tests/language/ct_const4_test.dart
@@ -4,6 +4,7 @@
// Check compile-time constant library references with prefixes
library CTConst4Test;
+import "package:expect/expect.dart";
import "ct_const4_lib.dart" as mylib;
const A = mylib.B;
diff --git a/tests/language/ct_const_test.dart b/tests/language/ct_const_test.dart
index 3374ea0..f0098f1 100644
--- a/tests/language/ct_const_test.dart
+++ b/tests/language/ct_const_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// All things regarding compile time constant expressions.
+import "package:expect/expect.dart";
+
abstract class Roman {
static const I = 1;
static const II = 2;
diff --git a/tests/language/dangling_else_test.dart b/tests/language/dangling_else_test.dart
index d6d3bdb..84bdec8 100644
--- a/tests/language/dangling_else_test.dart
+++ b/tests/language/dangling_else_test.dart
@@ -4,6 +4,8 @@
// Tests dangling else. The VM should not have any problems, but dart2js or
// dart2dart could get this wrong.
+import "package:expect/expect.dart";
+
nestedIf1(notTrue) {
if (notTrue) return 'bad input';
if (notTrue) {
diff --git a/tests/language/default_class_implicit_constructor_test.dart b/tests/language/default_class_implicit_constructor_test.dart
index 72e9132..0a00a80 100644
--- a/tests/language/default_class_implicit_constructor_test.dart
+++ b/tests/language/default_class_implicit_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// An abstract class with a redirecting factory to a class with no declared
// constructor should use the implicit default constructor.
diff --git a/tests/language/default_factory_library_test.dart b/tests/language/default_factory_library_test.dart
index ec3c231..92a44f4 100644
--- a/tests/language/default_factory_library_test.dart
+++ b/tests/language/default_factory_library_test.dart
@@ -5,6 +5,7 @@
// Dart test program for testing factories defined across libraries
library test;
+import "package:expect/expect.dart";
import "default_factory_library.dart" as lib;
class B implements lib.A, C {
diff --git a/tests/language/default_factory_test.dart b/tests/language/default_factory_test.dart
index aee33f7..bc4ce60 100644
--- a/tests/language/default_factory_test.dart
+++ b/tests/language/default_factory_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing default factories.
abstract class Vehicle {
diff --git a/tests/language/default_implementation_test.dart b/tests/language/default_implementation_test.dart
index 6d6da4f..74a797d 100644
--- a/tests/language/default_implementation_test.dart
+++ b/tests/language/default_implementation_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test to verify that factory classes are working.
+import "package:expect/expect.dart";
+
// @static-clean
abstract class Point {
diff --git a/tests/language/default_init_test.dart b/tests/language/default_init_test.dart
index 4192585..63c9be8 100644
--- a/tests/language/default_init_test.dart
+++ b/tests/language/default_init_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests static and instance fields initialization.
class DefaultInitTest {
static testMain() {
diff --git a/tests/language/deopt_hoisted_smi_check_vm_test.dart b/tests/language/deopt_hoisted_smi_check_vm_test.dart
index 6fab79c..0eef995 100644
--- a/tests/language/deopt_hoisted_smi_check_vm_test.dart
+++ b/tests/language/deopt_hoisted_smi_check_vm_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test deoptimization on an optimistically hoisted smi check.
+import 'package:expect/expect.dart';
+
sum(a, b) {
var sum = 0;
for (var j = 1; j < 10; j++) {
diff --git a/tests/language/deopt_inlined_function_lazy_test.dart b/tests/language/deopt_inlined_function_lazy_test.dart
index 362631e..59e8930 100644
--- a/tests/language/deopt_inlined_function_lazy_test.dart
+++ b/tests/language/deopt_inlined_function_lazy_test.dart
@@ -4,6 +4,8 @@
// Test lazy deoptimization from within an inlined function.
// VMOptions=--deoptimize_alot
+import "package:expect/expect.dart";
+
call_native(x) {
// Wrap in try to avoid inlining.
// Use a large int so the intrinsifier does not fire.
diff --git a/tests/language/deopt_inlined_function_test.dart b/tests/language/deopt_inlined_function_test.dart
index b0d8844..d35b5ed 100644
--- a/tests/language/deopt_inlined_function_test.dart
+++ b/tests/language/deopt_inlined_function_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test deoptimization from within an inlined function.
+import "package:expect/expect.dart";
+
class A {
deopt_here() => 1;
}
diff --git a/tests/language/deopt_no_feedback_test.dart b/tests/language/deopt_no_feedback_test.dart
index f307e77..a10e406 100644
--- a/tests/language/deopt_no_feedback_test.dart
+++ b/tests/language/deopt_no_feedback_test.dart
@@ -4,6 +4,8 @@
// Test deoptimization caused by running code that did not collect type
// feedback before.
+import "package:expect/expect.dart";
+
testStoreIndexed() {
test(a, i, v, flag) {
if (flag) {
diff --git a/tests/language/deopt_smi_op_test.dart b/tests/language/deopt_smi_op_test.dart
index 7ad01c6..90e918b 100644
--- a/tests/language/deopt_smi_op_test.dart
+++ b/tests/language/deopt_smi_op_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test hoisted (loop-invariant) smi operations with deoptimization.
test_mul(h) {
diff --git a/tests/language/deoptimized_function_on_stack_test.dart b/tests/language/deoptimized_function_on_stack_test.dart
index 9071f1c..f03b916 100644
--- a/tests/language/deoptimized_function_on_stack_test.dart
+++ b/tests/language/deoptimized_function_on_stack_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This is a test for deoptimization infrastructure and to reproduce the
// failure from bug 5442338.
diff --git a/tests/language/disable_privacy_test.dart b/tests/language/disable_privacy_test.dart
index 8d0348d..6e774e9 100644
--- a/tests/language/disable_privacy_test.dart
+++ b/tests/language/disable_privacy_test.dart
@@ -6,6 +6,7 @@
// Dart test program checking that library privacy can be disabled.
library DisablePrivacyTest;
+import "package:expect/expect.dart";
import "disable_privacy_lib.dart";
main() {
diff --git a/tests/language/div_by_zero_test.dart b/tests/language/div_by_zero_test.dart
index 8f0ec10..f98c4bf 100644
--- a/tests/language/div_by_zero_test.dart
+++ b/tests/language/div_by_zero_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program to test integer div by zero.
+import "package:expect/expect.dart";
+
class DivByZeroTest {
static double divBy(int a, int b) {
diff --git a/tests/language/div_with_power_of_two_test.dart b/tests/language/div_with_power_of_two_test.dart
index fbd3151..6b50749 100644
--- a/tests/language/div_with_power_of_two_test.dart
+++ b/tests/language/div_with_power_of_two_test.dart
@@ -4,6 +4,8 @@
// Test division by power of two.
// Test that results before and after optimization are the same.
+import "package:expect/expect.dart";
+
// [function, [list of tuples argument/result]].
var expectedResults =
[ [divBy1,
diff --git a/tests/language/do_while2_test.dart b/tests/language/do_while2_test.dart
index c6cae30..9243e94 100644
--- a/tests/language/do_while2_test.dart
+++ b/tests/language/do_while2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var a = 42;
foo1() {
diff --git a/tests/language/do_while3_test.dart b/tests/language/do_while3_test.dart
index 615ebd1..4026ec9 100644
--- a/tests/language/do_while3_test.dart
+++ b/tests/language/do_while3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that a condition is only evaluated once in a loop.
main() {
diff --git a/tests/language/do_while4_test.dart b/tests/language/do_while4_test.dart
new file mode 100644
index 0000000..9b7115a
--- /dev/null
+++ b/tests/language/do_while4_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js that used to crash in the presence of
+// do/while, break and a local variable declared after the break.
+
+import "package:expect/expect.dart";
+
+var a = false;
+main() {
+ do {
+ if (!a) break;
+ var c = main();
+ a = true;
+ } while (true);
+ Expect.isFalse(a);
+}
diff --git a/tests/language/do_while_test.dart b/tests/language/do_while_test.dart
index d4edf86..42195ad 100644
--- a/tests/language/do_while_test.dart
+++ b/tests/language/do_while_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing do while statement.
+import "package:expect/expect.dart";
+
class Helper {
static int f1(bool b) {
do return 1;
diff --git a/tests/language/double_int_addition_test.dart b/tests/language/double_int_addition_test.dart
index 8319df1..9f748e2 100644
--- a/tests/language/double_int_addition_test.dart
+++ b/tests/language/double_int_addition_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that optimized code does not silently convert integers to doubles.
diff --git a/tests/language/double_int_to_string_test.dart b/tests/language/double_int_to_string_test.dart
index 96dbe0e..7ba8e27 100644
--- a/tests/language/double_int_to_string_test.dart
+++ b/tests/language/double_int_to_string_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("0.0", (0.0).toString());
Expect.equals("9.0", (9.0).toString());
diff --git a/tests/language/double_modulo_test.dart b/tests/language/double_modulo_test.dart
index 6a9a15a..d2b90ca 100644
--- a/tests/language/double_modulo_test.dart
+++ b/tests/language/double_modulo_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test optimization of modulo operator on Double.
+import "package:expect/expect.dart";
+
main() {
double k = -0.33333;
double firstResPos = doMod(k, 1.0);
diff --git a/tests/language/double_to_string_as_exponential2_test.dart b/tests/language/double_to_string_as_exponential2_test.dart
index 9c085a4..f5030ca 100644
--- a/tests/language/double_to_string_as_exponential2_test.dart
+++ b/tests/language/double_to_string_as_exponential2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.throws(() => (1.0).toStringAsExponential(-1),
(e) => e is RangeError);
diff --git a/tests/language/double_to_string_as_exponential3_test.dart b/tests/language/double_to_string_as_exponential3_test.dart
index daaa069..7530033 100644
--- a/tests/language/double_to_string_as_exponential3_test.dart
+++ b/tests/language/double_to_string_as_exponential3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("1.00000000000000000000e+0", (1.0).toStringAsExponential(20));
diff --git a/tests/language/double_to_string_as_exponential_test.dart b/tests/language/double_to_string_as_exponential_test.dart
index 9827109..c44bbd1 100644
--- a/tests/language/double_to_string_as_exponential_test.dart
+++ b/tests/language/double_to_string_as_exponential_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("1e+0", (1.0).toStringAsExponential());
Expect.equals("1.1e+1", (11.0).toStringAsExponential());
diff --git a/tests/language/double_to_string_as_fixed2_test.dart b/tests/language/double_to_string_as_fixed2_test.dart
index f43418c..4da08a4 100644
--- a/tests/language/double_to_string_as_fixed2_test.dart
+++ b/tests/language/double_to_string_as_fixed2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.throws(() => 0.0.toStringAsFixed(-1),
(e) => e is RangeError);
diff --git a/tests/language/double_to_string_as_fixed_test.dart b/tests/language/double_to_string_as_fixed_test.dart
index 80dda0c..bc15175 100644
--- a/tests/language/double_to_string_as_fixed_test.dart
+++ b/tests/language/double_to_string_as_fixed_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
class ToStringAsFixedTest {
static void testMain() {
Expect.equals("2.000", 2.0.toStringAsFixed(3));
diff --git a/tests/language/double_to_string_as_precision2_test.dart b/tests/language/double_to_string_as_precision2_test.dart
index ef04587..a2f78f0 100644
--- a/tests/language/double_to_string_as_precision2_test.dart
+++ b/tests/language/double_to_string_as_precision2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.throws(() => 0.0.toStringAsPrecision(0),
(e) => e is RangeError);
diff --git a/tests/language/double_to_string_as_precision3_test.dart b/tests/language/double_to_string_as_precision3_test.dart
index b2d4e32..a208f10 100644
--- a/tests/language/double_to_string_as_precision3_test.dart
+++ b/tests/language/double_to_string_as_precision3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("0.000555000000000000046248",
(0.000555).toStringAsPrecision(21));
diff --git a/tests/language/double_to_string_as_precision_test.dart b/tests/language/double_to_string_as_precision_test.dart
index ac91aff..4f159f9 100644
--- a/tests/language/double_to_string_as_precision_test.dart
+++ b/tests/language/double_to_string_as_precision_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("NaN", (double.NAN).toStringAsPrecision(1));
Expect.equals("Infinity", (double.INFINITY).toStringAsPrecision(2));
diff --git a/tests/language/double_to_string_test.dart b/tests/language/double_to_string_test.dart
index ce30f50..a7c1061 100644
--- a/tests/language/double_to_string_test.dart
+++ b/tests/language/double_to_string_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("NaN", (double.NAN).toString());
Expect.equals("Infinity", (1/0).toString());
diff --git a/tests/language/duplicate_interface_test.dart b/tests/language/duplicate_interface_test.dart
index 5553a5e..887cd30 100644
--- a/tests/language/duplicate_interface_test.dart
+++ b/tests/language/duplicate_interface_test.dart
@@ -5,6 +5,7 @@
library duplicateInterfaceTest;
+import 'package:expect/expect.dart';
import "duplicate_interface_lib.dart" as alib;
class InterfB { }
diff --git a/tests/language/dynamic2_test.dart b/tests/language/dynamic2_test.dart
new file mode 100644
index 0000000..82c9074
--- /dev/null
+++ b/tests/language/dynamic2_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// Test the prohibited use of 'dynamic' in extending and implementing classes.
+
+class A
+ extends dynamic /// 00: compile-time error
+ implements dynamic /// 01: compile-time error
+{
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language/dynamic_call_test.dart b/tests/language/dynamic_call_test.dart
index 07cf6ff..f7a760c 100644
--- a/tests/language/dynamic_call_test.dart
+++ b/tests/language/dynamic_call_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing dynamic calls.
+import "package:expect/expect.dart";
+
class Helper {
Helper() {}
int foo(int i) {
diff --git a/tests/language/dynamic_field_test.dart b/tests/language/dynamic_field_test.dart
index eb4d662..db77ea3 100644
--- a/tests/language/dynamic_field_test.dart
+++ b/tests/language/dynamic_field_test.dart
@@ -4,6 +4,8 @@
//
// Test that ensures that fields can be accessed dynamically.
+import "package:expect/expect.dart";
+
class A extends C {
var a;
var b;
diff --git a/tests/language/dynamic_test.dart b/tests/language/dynamic_test.dart
index e7641de..9b1cc77 100644
--- a/tests/language/dynamic_test.dart
+++ b/tests/language/dynamic_test.dart
@@ -5,6 +5,8 @@
// Dart test program testing the use of 'dynamic' in generic types.
// @static-clean
+import "package:expect/expect.dart";
+
abstract class Iface<K,V> {
}
diff --git a/tests/language/emit_const_fields_test.dart b/tests/language/emit_const_fields_test.dart
index 17e5ab5..61e09d6 100644
--- a/tests/language/emit_const_fields_test.dart
+++ b/tests/language/emit_const_fields_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test that used static consts are emitted.
+import "package:expect/expect.dart";
+
class Guide {
static const LTUAE = 42;
static const TITLE = "Life, the Universe and Everything";
diff --git a/tests/language/empty_block_case_test.dart b/tests/language/empty_block_case_test.dart
index 6aeb6cf..085ce70 100644
--- a/tests/language/empty_block_case_test.dart
+++ b/tests/language/empty_block_case_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that a case with an empty block does not fall through.
class EmptyBlockCaseTest {
diff --git a/tests/language/equality_test.dart b/tests/language/equality_test.dart
index 6efe953..4e47521 100644
--- a/tests/language/equality_test.dart
+++ b/tests/language/equality_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
bool _result;
diff --git a/tests/language/example_constructor_test.dart b/tests/language/example_constructor_test.dart
index 6ae7b48..612bb18 100644
--- a/tests/language/example_constructor_test.dart
+++ b/tests/language/example_constructor_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing order of constructor invocation.
+import "package:expect/expect.dart";
+
var trace = "";
int rec(int i) {
diff --git a/tests/language/exception_identity_test.dart b/tests/language/exception_identity_test.dart
index c6b7168..2b16607 100644
--- a/tests/language/exception_identity_test.dart
+++ b/tests/language/exception_identity_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that an object when thrown stays the same.
class A {
diff --git a/tests/language/exception_test.dart b/tests/language/exception_test.dart
index 0876c5c..2cdab5e 100644
--- a/tests/language/exception_test.dart
+++ b/tests/language/exception_test.dart
@@ -1,6 +1,9 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
class ExceptionTest {
static testMain() {
int i = 0;
diff --git a/tests/language/execute_finally10_test.dart b/tests/language/execute_finally10_test.dart
new file mode 100644
index 0000000..4591908
--- /dev/null
+++ b/tests/language/execute_finally10_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js that used to not treat the finally
+// block as a successor of a catch block that throws.
+
+import "package:expect/expect.dart";
+
+class A {
+ var field;
+ start() {}
+ stop() { field = 42; }
+}
+
+class B {
+ var totalCompileTime = new A();
+ var runCompiler = new Object();
+
+ run() {
+ totalCompileTime.start();
+ try {
+ throw 'foo';
+ } catch (exception) {
+ // Use [runCompiler] twice to ensure it will have a local
+ // variable.
+ runCompiler.toString();
+ runCompiler.toString();
+ throw;
+ } finally {
+ totalCompileTime.stop();
+ }
+ }
+}
+
+main() {
+ var b = new B();
+ try {
+ b.run();
+ throw 'Expected exception';
+ } catch (exception) {
+ // Expected exception.
+ }
+
+ Expect.equals(42, b.totalCompileTime.field);
+}
diff --git a/tests/language/execute_finally11_test.dart b/tests/language/execute_finally11_test.dart
new file mode 100644
index 0000000..093d7dc
--- /dev/null
+++ b/tests/language/execute_finally11_test.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js that used to not treat the finally
+// block as a successor of a nested try block.
+
+import "package:expect/expect.dart";
+
+class A {
+ var field;
+ start() {}
+ stop() { field = 42; }
+}
+
+class B {
+ var totalCompileTime = new A();
+ var runCompiler = new Object();
+
+ run() {
+ totalCompileTime.start();
+ try {
+ throw 'foo';
+ } catch (exception) {
+ try {
+ // Use [runCompiler] twice to ensure it will have a local
+ // variable.
+ runCompiler.toString();
+ runCompiler.toString();
+ } catch (exception) {
+ }
+ throw;
+ } finally {
+ totalCompileTime.stop();
+ }
+ }
+}
+
+main() {
+ var b = new B();
+ try {
+ b.run();
+ throw 'Expected exception';
+ } catch (exception) {
+ // Expected exception.
+ }
+
+ Expect.equals(42, b.totalCompileTime.field);
+}
diff --git a/tests/language/execute_finally12_test.dart b/tests/language/execute_finally12_test.dart
new file mode 100644
index 0000000..edce516
--- /dev/null
+++ b/tests/language/execute_finally12_test.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js that used to not treat the finally
+// block as a successor of a nested try block.
+
+import "package:expect/expect.dart";
+
+var a;
+
+foo() {
+ var b = a == 8; // This should not be GVN'ed.
+ while (!b) {
+ try {
+ try {
+ } finally {
+ a = 8;
+ break;
+ }
+ } finally {
+ return a == 8;
+ }
+ }
+}
+
+main() {
+ Expect.isTrue(foo());
+}
diff --git a/tests/language/execute_finally1_test.dart b/tests/language/execute_finally1_test.dart
index 946f3bb..ee2ac09 100644
--- a/tests/language/execute_finally1_test.dart
+++ b/tests/language/execute_finally1_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks on
// control flow breaks because of 'return', 'continue' etc.
+import "package:expect/expect.dart";
+
class Helper {
Helper() : i = 0 { }
diff --git a/tests/language/execute_finally2_test.dart b/tests/language/execute_finally2_test.dart
index ab7e93a..7eaec3e 100644
--- a/tests/language/execute_finally2_test.dart
+++ b/tests/language/execute_finally2_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks on
// control flow breaks because of 'return', 'continue' etc.
+import "package:expect/expect.dart";
+
class Helper {
Helper() : i = 0 { }
diff --git a/tests/language/execute_finally3_test.dart b/tests/language/execute_finally3_test.dart
index 122402a..1da7b6f 100644
--- a/tests/language/execute_finally3_test.dart
+++ b/tests/language/execute_finally3_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks on
// control flow breaks because of 'return', 'continue' etc.
+import "package:expect/expect.dart";
+
class Helper {
Helper() : i = 0 { }
diff --git a/tests/language/execute_finally4_test.dart b/tests/language/execute_finally4_test.dart
index fedf2f0..ab0d023 100644
--- a/tests/language/execute_finally4_test.dart
+++ b/tests/language/execute_finally4_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks on
// control flow breaks because of 'return', 'continue' etc.
+import "package:expect/expect.dart";
+
class Helper {
Helper() : i = 0 { }
diff --git a/tests/language/execute_finally5_test.dart b/tests/language/execute_finally5_test.dart
index dbdb016..37fa316 100644
--- a/tests/language/execute_finally5_test.dart
+++ b/tests/language/execute_finally5_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks on
// control flow breaks because of 'return', 'continue' etc.
+import "package:expect/expect.dart";
+
class Helper {
Helper() : i = 0 { }
diff --git a/tests/language/execute_finally6_test.dart b/tests/language/execute_finally6_test.dart
index dae478b..ff2e6e7 100644
--- a/tests/language/execute_finally6_test.dart
+++ b/tests/language/execute_finally6_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks on
// control flow breaks because of 'return', 'continue' etc.
+import "package:expect/expect.dart";
+
class Helper {
Helper() : i = 0 { }
diff --git a/tests/language/execute_finally7_test.dart b/tests/language/execute_finally7_test.dart
index 265e4c1..7ba11aa 100644
--- a/tests/language/execute_finally7_test.dart
+++ b/tests/language/execute_finally7_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing execution of finally blocks after an exception
// is thrown from inside a local function capturing a variable.
+import "package:expect/expect.dart";
+
class MyException {
const MyException(String message) : message_ = message;
diff --git a/tests/language/execute_finally8_test.dart b/tests/language/execute_finally8_test.dart
index 8ab2a34..f597c68 100644
--- a/tests/language/execute_finally8_test.dart
+++ b/tests/language/execute_finally8_test.dart
@@ -4,6 +4,8 @@
// This test ensures that the finally block executes correctly when
// there are throw, break and return statements in the finally block.
+import "package:expect/expect.dart";
+
class Hello {
static var sum;
diff --git a/tests/language/execute_finally9_test.dart b/tests/language/execute_finally9_test.dart
index 19108da..ac53600 100644
--- a/tests/language/execute_finally9_test.dart
+++ b/tests/language/execute_finally9_test.dart
@@ -4,6 +4,8 @@
// This test ensures that the finally block executes correctly when
// there are throw, break and return statements in the finally block.
+import "package:expect/expect.dart";
+
class Hello {
static var sum;
diff --git a/tests/language/expect_test.dart b/tests/language/expect_test.dart
index 13453f3..ee24d6d 100644
--- a/tests/language/expect_test.dart
+++ b/tests/language/expect_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Testing the Expect class.
+import "package:expect/expect.dart";
+
class ExpectTest {
static testEquals(a) {
diff --git a/tests/language/f_bounded_quantification_test.dart b/tests/language/f_bounded_quantification_test.dart
index 928b71e..133fd19 100644
--- a/tests/language/f_bounded_quantification_test.dart
+++ b/tests/language/f_bounded_quantification_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for F-Bounded Quantification.
class FBound<F extends FBound<F>> {}
diff --git a/tests/language/factory_arrow_test.dart b/tests/language/factory_arrow_test.dart
index 02d3392..d2cf528 100644
--- a/tests/language/factory_arrow_test.dart
+++ b/tests/language/factory_arrow_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
A.foo() {}
factory A() => new A.foo();
diff --git a/tests/language/factory_implementation_test.dart b/tests/language/factory_implementation_test.dart
index 0f7e2f6..c21bda6 100644
--- a/tests/language/factory_implementation_test.dart
+++ b/tests/language/factory_implementation_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class A {
factory A(int x, int y) = B;
}
diff --git a/tests/language/factory_redirection2_test.dart b/tests/language/factory_redirection2_test.dart
index b4592d8..0884930 100644
--- a/tests/language/factory_redirection2_test.dart
+++ b/tests/language/factory_redirection2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that it is a compile-time error to have a redirection in a
// non-factory constructor.
diff --git a/tests/language/factory_redirection_test.dart b/tests/language/factory_redirection_test.dart
index fb3ceb6..2fcc27c8 100644
--- a/tests/language/factory_redirection_test.dart
+++ b/tests/language/factory_redirection_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
A() : x = null;
diff --git a/tests/language/factory_test.dart b/tests/language/factory_test.dart
index 5176eba..b0441ea 100644
--- a/tests/language/factory_test.dart
+++ b/tests/language/factory_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing factories.
+import "package:expect/expect.dart";
+
class A {
factory A(n) {
return new A.internal(n);
diff --git a/tests/language/factory_type_parameter2_test.dart b/tests/language/factory_type_parameter2_test.dart
new file mode 100644
index 0000000..6536be8
--- /dev/null
+++ b/tests/language/factory_type_parameter2_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that type variables are correctly set in instances created by factories.
+
+import 'package:expect/expect.dart';
+
+var p;
+bool done = false;
+
+class D {}
+
+abstract class I<T> {
+ factory I.name() {
+ return new C<T>.name();
+ }
+}
+
+class C<T> implements I<T> {
+ C.name() {
+ Expect.isTrue(p is T);
+ done = true;
+ }
+}
+
+main() {
+ p = new D();
+ new I<D>.name();
+ Expect.equals(true, done);
+}
diff --git a/tests/language/factory_type_parameter_test.dart b/tests/language/factory_type_parameter_test.dart
index fe6b0fa..c9e7a0b 100644
--- a/tests/language/factory_type_parameter_test.dart
+++ b/tests/language/factory_type_parameter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
factory A.factory() {
return new B<T>();
diff --git a/tests/language/fannkuch_test.dart b/tests/language/fannkuch_test.dart
index 356f20f..ffde845 100644
--- a/tests/language/fannkuch_test.dart
+++ b/tests/language/fannkuch_test.dart
@@ -6,6 +6,8 @@
// Ported from JavaScript contributed by Isaac Gouy.
// Description: Repeatedly acccess a tiny integer-sequence.
+import "package:expect/expect.dart";
+
class FannkuchTest {
static fannkuch(n) {
var p = new List(n), q = new List(n), s = new List(n);
diff --git a/tests/language/fast_method_extraction_test.dart b/tests/language/fast_method_extraction_test.dart
index 22177c7..e562b60 100644
--- a/tests/language/fast_method_extraction_test.dart
+++ b/tests/language/fast_method_extraction_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test that fast method extraction returns correct closure.
+import "package:expect/expect.dart";
+
class A {
var f;
A(this.f);
diff --git a/tests/language/fauxverride_test.dart b/tests/language/fauxverride_test.dart
index 3ac1d5d..4bc2d36 100644
--- a/tests/language/fauxverride_test.dart
+++ b/tests/language/fauxverride_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test the semantics of static members mixed with instance members.
// Following are relevant quotes from Dart Programming Language
diff --git a/tests/language/fibo_test.dart b/tests/language/fibo_test.dart
index 28e3eae..e6f13bd 100644
--- a/tests/language/fibo_test.dart
+++ b/tests/language/fibo_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program calculating the Fibonacci sequence.
+import "package:expect/expect.dart";
+
class Helper {
static int fibonacci(int n) {
int a = 0, b = 1, i = 0;
diff --git a/tests/language/field3_negative_test.dart b/tests/language/field3_negative_test.dart
index 6973128..4ee13ba 100644
--- a/tests/language/field3_negative_test.dart
+++ b/tests/language/field3_negative_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test to catch error reporting bugs in class fields declarations.
+import "package:expect/expect.dart";
+
class C {
final var a = 0; // illegal: var cannot follow final.
}
diff --git a/tests/language/field3a_negative_test.dart b/tests/language/field3a_negative_test.dart
index d0706f6..f42779b 100644
--- a/tests/language/field3a_negative_test.dart
+++ b/tests/language/field3a_negative_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test to catch error reporting bugs in class fields declarations.
+import "package:expect/expect.dart";
+
class C {
final a; // illegal field declaration - must be initialized
}
diff --git a/tests/language/field_increment_bailout_test.dart b/tests/language/field_increment_bailout_test.dart
index 8ea2caa..2dc2fe6 100644
--- a/tests/language/field_increment_bailout_test.dart
+++ b/tests/language/field_increment_bailout_test.dart
@@ -4,6 +4,8 @@
// dart2js regression test for issue 8781.
+import "package:expect/expect.dart";
+
class N {
var outgoing;
var incoming;
diff --git a/tests/language/field_initialization_order_test.dart b/tests/language/field_initialization_order_test.dart
index 3bf24b6..92fd3df 100644
--- a/tests/language/field_initialization_order_test.dart
+++ b/tests/language/field_initialization_order_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that field initializers are evaluated in the right order.
int counter = 0;
diff --git a/tests/language/field_optimization2_test.dart b/tests/language/field_optimization2_test.dart
index d8b6ec3..870d4ed 100644
--- a/tests/language/field_optimization2_test.dart
+++ b/tests/language/field_optimization2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program to test type-based optimization on fields.
diff --git a/tests/language/field_optimization3_test.dart b/tests/language/field_optimization3_test.dart
index 1f11c10..bb551f7 100644
--- a/tests/language/field_optimization3_test.dart
+++ b/tests/language/field_optimization3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program to test type-based optimization on fields.
class A {
diff --git a/tests/language/field_optimization_test.dart b/tests/language/field_optimization_test.dart
index 9dea38b..1d1ba3c 100644
--- a/tests/language/field_optimization_test.dart
+++ b/tests/language/field_optimization_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program to test type-based optimization on fields.
diff --git a/tests/language/field_override2_test.dart b/tests/language/field_override2_test.dart
index 0a08402..620667eb 100644
--- a/tests/language/field_override2_test.dart
+++ b/tests/language/field_override2_test.dart
@@ -5,6 +5,8 @@
// Test that we are accessing the right field in a method of a super
// class, when that field is overridden.
+import "package:expect/expect.dart";
+
class A {
final a = [42];
foo() => a[0];
diff --git a/tests/language/field_override_test.dart b/tests/language/field_override_test.dart
index 399fc65..2d3bc5a 100644
--- a/tests/language/field_override_test.dart
+++ b/tests/language/field_override_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test overriding of fields.
+import "package:expect/expect.dart";
+
class A {}
class B1 extends A {}
diff --git a/tests/language/field_parameter_test.dart b/tests/language/field_parameter_test.dart
index 80037f5..8363eb0 100644
--- a/tests/language/field_parameter_test.dart
+++ b/tests/language/field_parameter_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing setting/getting of instance fields.
+import "package:expect/expect.dart";
+
class A {
var x = 4;
A(this.x);
diff --git a/tests/language/field_test.dart b/tests/language/field_test.dart
index 6a87019..6a1937f 100644
--- a/tests/language/field_test.dart
+++ b/tests/language/field_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing setting/getting of instance fields.
+import "package:expect/expect.dart";
+
class First {
First() {}
var a;
diff --git a/tests/language/final_field_initialization_order_test.dart b/tests/language/final_field_initialization_order_test.dart
index 8735046..7c87dfbc 100644
--- a/tests/language/final_field_initialization_order_test.dart
+++ b/tests/language/final_field_initialization_order_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that initializers for final fields are evaluated in the right
// order.
diff --git a/tests/language/final_is_not_const_test.dart b/tests/language/final_is_not_const_test.dart
index 597ff7a..ab0d7b0 100644
--- a/tests/language/final_is_not_const_test.dart
+++ b/tests/language/final_is_not_const_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
final F0 = 42;
const C0 = F0; /// 01: compile-time error
diff --git a/tests/language/final_syntax_test.dart b/tests/language/final_syntax_test.dart
index 78a540e..3ac879d 100644
--- a/tests/language/final_syntax_test.dart
+++ b/tests/language/final_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
final f0 = 42;
final f1; /// 01: compile-time error
diff --git a/tests/language/final_used_in_try_test.dart b/tests/language/final_used_in_try_test.dart
index 9da3e17..3fbfddf 100644
--- a/tests/language/final_used_in_try_test.dart
+++ b/tests/language/final_used_in_try_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
while (true) {
final a = 'fff'.substring(1, 2);
diff --git a/tests/language/finally_test.dart b/tests/language/finally_test.dart
index d71dab6..9277416 100644
--- a/tests/language/finally_test.dart
+++ b/tests/language/finally_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for a bug in dart2js where the update of a field in a try
// block would not be seen by the finally block. See dartbug.com/5517.
diff --git a/tests/language/first_class_types_constants_test.dart b/tests/language/first_class_types_constants_test.dart
index 6a4c4d4..5dfa136 100644
--- a/tests/language/first_class_types_constants_test.dart
+++ b/tests/language/first_class_types_constants_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class C<T> {
final T t;
const C(this.t);
diff --git a/tests/language/first_class_types_libraries_test.dart b/tests/language/first_class_types_libraries_test.dart
index db6442f..734be65 100644
--- a/tests/language/first_class_types_libraries_test.dart
+++ b/tests/language/first_class_types_libraries_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library firstClassLibrariestest;
+import "package:expect/expect.dart";
import 'first_class_types_lib1.dart' as lib1;
import 'first_class_types_lib2.dart' as lib2;
diff --git a/tests/language/first_class_types_literals_test.dart b/tests/language/first_class_types_literals_test.dart
index 31724b6..896ba5d 100644
--- a/tests/language/first_class_types_literals_test.dart
+++ b/tests/language/first_class_types_literals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class C<T, U, V> {}
class D {}
diff --git a/tests/language/first_class_types_test.dart b/tests/language/first_class_types_test.dart
index 95090d6..6b65f5a 100644
--- a/tests/language/first_class_types_test.dart
+++ b/tests/language/first_class_types_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class C<T> {}
sameType(a, b) {
diff --git a/tests/language/fixed_length_test.dart b/tests/language/fixed_length_test.dart
index 0e8ab56..6d0d85d 100644
--- a/tests/language/fixed_length_test.dart
+++ b/tests/language/fixed_length_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for https://code.google.com/p/dart/issues/detail?id=7994.
void main() {
diff --git a/tests/language/for2_test.dart b/tests/language/for2_test.dart
index 7477565..52686e2 100644
--- a/tests/language/for2_test.dart
+++ b/tests/language/for2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing for statement which captures loop variable.
+import "package:expect/expect.dart";
+
var f;
main() {
diff --git a/tests/language/for_in_test.dart b/tests/language/for_in_test.dart
index 0f910eb..4360a489 100644
--- a/tests/language/for_in_test.dart
+++ b/tests/language/for_in_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test for testing for in on a list literal.
class ForInTest {
diff --git a/tests/language/for_test.dart b/tests/language/for_test.dart
index 3aed595..8576acb 100644
--- a/tests/language/for_test.dart
+++ b/tests/language/for_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing for statement.
+import "package:expect/expect.dart";
+
class Helper {
static int f1() {
for (;;) return 1;
diff --git a/tests/language/for_without_condition_test.dart b/tests/language/for_without_condition_test.dart
index a0860b7..b63739d 100644
--- a/tests/language/for_without_condition_test.dart
+++ b/tests/language/for_without_condition_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
int i = 0;
for (;; i++) {
diff --git a/tests/language/full_stacktrace1_test.dart b/tests/language/full_stacktrace1_test.dart
index 37ac2bc..4bef00e 100644
--- a/tests/language/full_stacktrace1_test.dart
+++ b/tests/language/full_stacktrace1_test.dart
@@ -1,3 +1,9 @@
+// (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
void func1() {
throw new Exception("Test peanut gallery request for Full stacktrace");
}
diff --git a/tests/language/full_stacktrace2_test.dart b/tests/language/full_stacktrace2_test.dart
index 93625c9..7f45706 100644
--- a/tests/language/full_stacktrace2_test.dart
+++ b/tests/language/full_stacktrace2_test.dart
@@ -1,3 +1,9 @@
+// (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
void func1() {
throw new Exception("Test peanut gallery request for Full stacktrace");
}
diff --git a/tests/language/full_stacktrace3_test.dart b/tests/language/full_stacktrace3_test.dart
index 64abc93..4bacd04 100644
--- a/tests/language/full_stacktrace3_test.dart
+++ b/tests/language/full_stacktrace3_test.dart
@@ -1,3 +1,9 @@
+// (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
void func1() {
throw new Exception("Test peanut gallery request for Full stacktrace");
}
diff --git a/tests/language/function_argument_test.dart b/tests/language/function_argument_test.dart
index f718965..b0cb5bb 100644
--- a/tests/language/function_argument_test.dart
+++ b/tests/language/function_argument_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for function passing.
+import "package:expect/expect.dart";
+
class FunctionArgumentTest {
static testMe(Function f) {
return f();
diff --git a/tests/language/function_field_test.dart b/tests/language/function_field_test.dart
index 8c44b17..7b0966e 100644
--- a/tests/language/function_field_test.dart
+++ b/tests/language/function_field_test.dart
@@ -5,6 +5,8 @@
//
// Test of calling Function, which is field of some class.
+import "package:expect/expect.dart";
+
class Wrapper {
Function f;
}
diff --git a/tests/language/function_getter_test.dart b/tests/language/function_getter_test.dart
index d927a04..efc483e 100644
--- a/tests/language/function_getter_test.dart
+++ b/tests/language/function_getter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
a() => 42;
}
diff --git a/tests/language/function_literals2_test.dart b/tests/language/function_literals2_test.dart
index 420892b..3572cbe 100644
--- a/tests/language/function_literals2_test.dart
+++ b/tests/language/function_literals2_test.dart
@@ -4,6 +4,8 @@
//
// Dart test for new function type alias.
+import "package:expect/expect.dart";
+
class FunctionLiteralsTest {
static void testMain() {
diff --git a/tests/language/function_literals_test.dart b/tests/language/function_literals_test.dart
index 2f321ee..92c2ee2 100644
--- a/tests/language/function_literals_test.dart
+++ b/tests/language/function_literals_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
/**
* Test various forms of function literals.
*/
diff --git a/tests/language/function_malformed_result_type_test.dart b/tests/language/function_malformed_result_type_test.dart
index c41936e..d010be7 100644
--- a/tests/language/function_malformed_result_type_test.dart
+++ b/tests/language/function_malformed_result_type_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for a function with a malformed result type.
+import "package:expect/expect.dart";
+
class C<T, U> {}
isCheckedMode() {
diff --git a/tests/language/function_syntax_test.dart b/tests/language/function_syntax_test.dart
index 4fc4ac3..ff96445 100644
--- a/tests/language/function_syntax_test.dart
+++ b/tests/language/function_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests function statement and expression syntax.
class FunctionSyntaxTest {
diff --git a/tests/language/function_test.dart b/tests/language/function_test.dart
index f917531..243eb4b 100644
--- a/tests/language/function_test.dart
+++ b/tests/language/function_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests function statements and expressions.
class Bug4089219 {
diff --git a/tests/language/function_type_alias2_test.dart b/tests/language/function_type_alias2_test.dart
index f2c03c5..bce01b0 100644
--- a/tests/language/function_type_alias2_test.dart
+++ b/tests/language/function_type_alias2_test.dart
@@ -5,6 +5,8 @@
//
// Dart test for function type alias with optional parameters.
+import "package:expect/expect.dart";
+
typedef int f1<T>([int a, int b, T c]);
typedef int f2<T>([int a, int b, T d]);
typedef int f3<T>({int a, int b, T c});
diff --git a/tests/language/function_type_alias3_test.dart b/tests/language/function_type_alias3_test.dart
index fe61988..043c02e 100644
--- a/tests/language/function_type_alias3_test.dart
+++ b/tests/language/function_type_alias3_test.dart
@@ -6,6 +6,7 @@
// to have the same name as a type parameter.
library main;
+import "package:expect/expect.dart";
import "library11.dart" as lib11;
typedef lib11.Library111<Library111>
diff --git a/tests/language/function_type_alias4_test.dart b/tests/language/function_type_alias4_test.dart
index 465f0a7..b517423 100644
--- a/tests/language/function_type_alias4_test.dart
+++ b/tests/language/function_type_alias4_test.dart
@@ -4,6 +4,8 @@
//
// Dart test for function type alias with a type parameter as result type.
+import "package:expect/expect.dart";
+
typedef bool F<bool>(bool a); // 'bool' is not the boolean type.
bool bar(bool a) {
diff --git a/tests/language/function_type_alias6_test.dart b/tests/language/function_type_alias6_test.dart
index 15fe9b6..59e78af 100644
--- a/tests/language/function_type_alias6_test.dart
+++ b/tests/language/function_type_alias6_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for legally self referencing function type alias.
+import "package:expect/expect.dart";
+
typedef F(List<F> x);
typedef D C();
diff --git a/tests/language/function_type_alias_test.dart b/tests/language/function_type_alias_test.dart
index e1bf33b..c52700f 100644
--- a/tests/language/function_type_alias_test.dart
+++ b/tests/language/function_type_alias_test.dart
@@ -5,6 +5,8 @@
//
// Dart test for function type alias.
+import "package:expect/expect.dart";
+
typedef Fun(a, b);
typedef int IntFun(a, b);
diff --git a/tests/language/function_type_parameter2_test.dart b/tests/language/function_type_parameter2_test.dart
index 77d3d21..ce3d014 100644
--- a/tests/language/function_type_parameter2_test.dart
+++ b/tests/language/function_type_parameter2_test.dart
@@ -4,6 +4,8 @@
// Test to check that we can parse closure type formal parameters with
// default value.
+import "package:expect/expect.dart";
+
class FunctionTypeParameterTest {
static var formatter;
diff --git a/tests/language/function_type_parameter_test.dart b/tests/language/function_type_parameter_test.dart
index 3f23daf..7ffe052 100644
--- a/tests/language/function_type_parameter_test.dart
+++ b/tests/language/function_type_parameter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to check that we can parse closure type formal parameters with
// default value.
diff --git a/tests/language/function_type_test.dart b/tests/language/function_type_test.dart
index 4beb620..b58c9a4 100644
--- a/tests/language/function_type_test.dart
+++ b/tests/language/function_type_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for a function type test that cannot be eliminated at compile time.
+import "package:expect/expect.dart";
+
isCheckedMode() {
try {
var i = 1;
diff --git a/tests/language/function_type_this_parameter_test.dart b/tests/language/function_type_this_parameter_test.dart
index cb7d6c5..4ce65c7 100644
--- a/tests/language/function_type_this_parameter_test.dart
+++ b/tests/language/function_type_this_parameter_test.dart
@@ -4,6 +4,8 @@
// Check that function types are accepted for constructor arguments that
// initialize fields.
+import "package:expect/expect.dart";
+
class A {
Function f;
A(int this.f());
diff --git a/tests/language/generic2_test.dart b/tests/language/generic2_test.dart
index 9048978..00cf5e6 100644
--- a/tests/language/generic2_test.dart
+++ b/tests/language/generic2_test.dart
@@ -4,6 +4,8 @@
// Test is-tests with type variables.
+import "package:expect/expect.dart";
+
class A<T> {
foo(o) => o is T;
}
diff --git a/tests/language/generic_creation_test.dart b/tests/language/generic_creation_test.dart
index 4bfd4d4..8086f89 100644
--- a/tests/language/generic_creation_test.dart
+++ b/tests/language/generic_creation_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<X, Y, Z> {
shift() => new A<Z, X, Y>();
swap() => new A<Z, Y, X>();
diff --git a/tests/language/generic_deep_test.dart b/tests/language/generic_deep_test.dart
index 73e018c..d3ee241 100644
--- a/tests/language/generic_deep_test.dart
+++ b/tests/language/generic_deep_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test for deeply nested generic types.
/** A natural number aka Peano number. */
diff --git a/tests/language/generic_inheritance_test.dart b/tests/language/generic_inheritance_test.dart
index 487c9ca..fec8adb 100644
--- a/tests/language/generic_inheritance_test.dart
+++ b/tests/language/generic_inheritance_test.dart
@@ -5,6 +5,8 @@
// Test verifying that the type argument vector of subclasses are properly
// initialized by the class finalizer.
+import "package:expect/expect.dart";
+
class A<T> { A(); }
class B extends A<Object> { B(); }
class C extends B { C(); }
diff --git a/tests/language/generic_instanceof2_test.dart b/tests/language/generic_instanceof2_test.dart
index bb4d45f..38fdbcd 100644
--- a/tests/language/generic_instanceof2_test.dart
+++ b/tests/language/generic_instanceof2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test that instanceof works correctly with type variables.
+import "package:expect/expect.dart";
+
// Test that partially typed generic instances are correctly constructed.
// Test factory case.
diff --git a/tests/language/generic_instanceof3_test.dart b/tests/language/generic_instanceof3_test.dart
index 27938f3..293880f 100644
--- a/tests/language/generic_instanceof3_test.dart
+++ b/tests/language/generic_instanceof3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing the instanceof operation.
+import "package:expect/expect.dart";
+
// Tests involving generics.
abstract class I<T> {
diff --git a/tests/language/generic_instanceof_test.dart b/tests/language/generic_instanceof_test.dart
index 64a40aa..597651b 100644
--- a/tests/language/generic_instanceof_test.dart
+++ b/tests/language/generic_instanceof_test.dart
@@ -4,6 +4,7 @@
// Test that instanceof works correctly with type variables.
library GenericInstanceofTest.dart;
+import "package:expect/expect.dart";
part "generic_instanceof.dart";
main() {
diff --git a/tests/language/generic_is_check_test.dart b/tests/language/generic_is_check_test.dart
index 4e13c1f..810964c 100644
--- a/tests/language/generic_is_check_test.dart
+++ b/tests/language/generic_is_check_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
foo() => this is A<int>;
}
diff --git a/tests/language/generic_native_test.dart b/tests/language/generic_native_test.dart
index 53e4c78..80eb8fe 100644
--- a/tests/language/generic_native_test.dart
+++ b/tests/language/generic_native_test.dart
@@ -4,6 +4,8 @@
// Test is-tests with type variables on native subclasses.
+import "package:expect/expect.dart";
+
class A<T> {
foo(o) => o is T;
}
@@ -16,9 +18,6 @@
Expect.isTrue(new A<Iterable<B>>().foo(new List<B>()));
Expect.isFalse(new A<Iterable<C>>().foo(new List<B>()));
- Expect.isTrue(new A<Collection<B>>().foo(new List<B>()));
- Expect.isFalse(new A<Collection<C>>().foo(new List<B>()));
-
Expect.isTrue(new A<Pattern>().foo('hest'));
Expect.isTrue(new A<Comparable<String>>().foo('hest'));
diff --git a/tests/language/generic_parameterized_extends_test.dart b/tests/language/generic_parameterized_extends_test.dart
index bef0d71..e275dd3 100644
--- a/tests/language/generic_parameterized_extends_test.dart
+++ b/tests/language/generic_parameterized_extends_test.dart
@@ -4,6 +4,8 @@
//
// Test verifying that generic extends are processed correctly.
+import "package:expect/expect.dart";
+
class A<T> {}
class B<T1, T2 extends A<T1>> {}
class C<T1 extends A<T2>, T2> {}
diff --git a/tests/language/generic_syntax_test.dart b/tests/language/generic_syntax_test.dart
index 9b2273e..bb8850a 100644
--- a/tests/language/generic_syntax_test.dart
+++ b/tests/language/generic_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test verifying that the parser does not confuse parameterized types with
// boolean expressions, since both contain '<'.
diff --git a/tests/language/generic_test.dart b/tests/language/generic_test.dart
index 6b4236e..55c6d41 100644
--- a/tests/language/generic_test.dart
+++ b/tests/language/generic_test.dart
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--checked
-//
// Dart test program testing generic type allocations and generic type tests.
+import "package:expect/expect.dart";
class A {
const A();
diff --git a/tests/language/generics_test.dart b/tests/language/generics_test.dart
index a077b98..dc240bd 100644
--- a/tests/language/generics_test.dart
+++ b/tests/language/generics_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for generic types.
+import "package:expect/expect.dart";
+
class GenericsTest<T,V> implements Map<int, int> {
static int myFunc(bool a, bool b) {
Expect.equals(true, a);
diff --git a/tests/language/getter_closure_execution_order_test.dart b/tests/language/getter_closure_execution_order_test.dart
index 05011f6..ad5daaf 100644
--- a/tests/language/getter_closure_execution_order_test.dart
+++ b/tests/language/getter_closure_execution_order_test.dart
@@ -5,6 +5,8 @@
// Test that a getter is evaluated after the arguments, when a getter is
// for invoking a method. See chapter 'Method Invocation' in specification.
+import "package:expect/expect.dart";
+
var counter = 0;
class Test1 {
diff --git a/tests/language/getter_no_setter2_test.dart b/tests/language/getter_no_setter2_test.dart
index c7b8859..62444b7 100644
--- a/tests/language/getter_no_setter2_test.dart
+++ b/tests/language/getter_no_setter2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Verifies behavior with a static getter, but no field and no setter.
+import "package:expect/expect.dart";
+
class Example {
static int _var = 1;
static int get nextVar => _var++;
diff --git a/tests/language/getter_no_setter_test.dart b/tests/language/getter_no_setter_test.dart
index eb8075a..d48864f 100644
--- a/tests/language/getter_no_setter_test.dart
+++ b/tests/language/getter_no_setter_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Verifies behavior with a static getter, but no field and no setter.
+import "package:expect/expect.dart";
+
class Example {
static int _var = 1;
static int get nextVar => _var++;
diff --git a/tests/language/getter_setter_in_lib_test.dart b/tests/language/getter_setter_in_lib_test.dart
index 968d6fe..deba2ba 100644
--- a/tests/language/getter_setter_in_lib_test.dart
+++ b/tests/language/getter_setter_in_lib_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library GetterSetterInLibTest;
+import "package:expect/expect.dart";
import 'getter_setter_in_lib.dart';
main() {
diff --git a/tests/language/getter_setter_interceptor_test.dart b/tests/language/getter_setter_interceptor_test.dart
index 8423fab..1e55875 100644
--- a/tests/language/getter_setter_interceptor_test.dart
+++ b/tests/language/getter_setter_interceptor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int length = 0;
}
diff --git a/tests/language/getter_setter_order_test.dart b/tests/language/getter_setter_order_test.dart
index 0805df8..feada29 100644
--- a/tests/language/getter_setter_order_test.dart
+++ b/tests/language/getter_setter_order_test.dart
@@ -4,6 +4,8 @@
// Test for the evaluation order of getters and setters.
+import 'package:expect/expect.dart';
+
var trace;
class X {
diff --git a/tests/language/getters_setters2_test.dart b/tests/language/getters_setters2_test.dart
index 3807597..8f62f05 100644
--- a/tests/language/getters_setters2_test.dart
+++ b/tests/language/getters_setters2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests classes with getters and setters that do not have the same type.
class A {
diff --git a/tests/language/getters_setters_test.dart b/tests/language/getters_setters_test.dart
index 010855b..1511e77 100644
--- a/tests/language/getters_setters_test.dart
+++ b/tests/language/getters_setters_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class GettersSettersTest {
static int foo;
diff --git a/tests/language/getters_setters_type2_test.dart b/tests/language/getters_setters_type2_test.dart
index dbf0316..22a3264 100644
--- a/tests/language/getters_setters_type2_test.dart
+++ b/tests/language/getters_setters_type2_test.dart
@@ -5,6 +5,8 @@
// two types are assignable.
// @static-clean
+import "package:expect/expect.dart";
+
int bar = 499;
int get foo => bar;
diff --git a/tests/language/getters_setters_type3_test.dart b/tests/language/getters_setters_type3_test.dart
index 25d4888..aaa8b35 100644
--- a/tests/language/getters_setters_type3_test.dart
+++ b/tests/language/getters_setters_type3_test.dart
@@ -5,6 +5,8 @@
// two types are assignable.
// @static-clean
+import "package:expect/expect.dart";
+
int bar = 499;
get foo => bar;
diff --git a/tests/language/getters_setters_type_test.dart b/tests/language/getters_setters_type_test.dart
index 39b84ae..547a74c 100644
--- a/tests/language/getters_setters_type_test.dart
+++ b/tests/language/getters_setters_type_test.dart
@@ -4,6 +4,8 @@
// Getters and setters can have different types, but it is a warning if the
// two types are not assignable.
+import "package:expect/expect.dart";
+
int bar = 499;
int /// 01: static type warning
diff --git a/tests/language/gvn_field_access_test.dart b/tests/language/gvn_field_access_test.dart
index 79359f2..cf124b1 100644
--- a/tests/language/gvn_field_access_test.dart
+++ b/tests/language/gvn_field_access_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var y = 0;
foo(x) {
diff --git a/tests/language/gvn_interceptor_test.dart b/tests/language/gvn_interceptor_test.dart
index 9e75f20..d638a23 100644
--- a/tests/language/gvn_interceptor_test.dart
+++ b/tests/language/gvn_interceptor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(a, index) {
if (a.length < index) {
for (int i = a.length; i <= index; i++) a.add(i);
diff --git a/tests/language/gvn_test.dart b/tests/language/gvn_test.dart
index b4859bf..a52944d 100644
--- a/tests/language/gvn_test.dart
+++ b/tests/language/gvn_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int x = 0;
diff --git a/tests/language/hash_code_mangling_test.dart b/tests/language/hash_code_mangling_test.dart
index 07b01a4..615da7b 100644
--- a/tests/language/hash_code_mangling_test.dart
+++ b/tests/language/hash_code_mangling_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Foo {
var $identityHash;
}
diff --git a/tests/language/hello_script_lib.dart b/tests/language/hello_script_lib.dart
index 95ed82e..92a0976 100644
--- a/tests/language/hello_script_lib.dart
+++ b/tests/language/hello_script_lib.dart
@@ -6,6 +6,7 @@
// This file contains the library.
library HelloScriptLib;
+import "package:expect/expect.dart";
part "hello_script_lib_source.dart";
class HelloLib {
diff --git a/tests/language/hello_script_test.dart b/tests/language/hello_script_test.dart
index b81e697..e5ab7c4 100644
--- a/tests/language/hello_script_test.dart
+++ b/tests/language/hello_script_test.dart
@@ -7,6 +7,7 @@
// This file contains the script (aka root library).
library HelloScriptTest.dart;
+import "package:expect/expect.dart";
import "hello_script_lib.dart";
main() {
diff --git a/tests/language/identical_closure2_test.dart b/tests/language/identical_closure2_test.dart
index 1217ad5..94c956a 100644
--- a/tests/language/identical_closure2_test.dart
+++ b/tests/language/identical_closure2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var myIdentical = identical;
class Point {
diff --git a/tests/language/identical_closure_test.dart b/tests/language/identical_closure_test.dart
index 2ce5373..fc1a556e3 100644
--- a/tests/language/identical_closure_test.dart
+++ b/tests/language/identical_closure_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var myIdentical = identical;
class Point {
diff --git a/tests/language/identical_test.dart b/tests/language/identical_test.dart
index 1533890..8a3887e 100644
--- a/tests/language/identical_test.dart
+++ b/tests/language/identical_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test efficient and correct implementation of !identical(a, b).
+import 'package:expect/expect.dart';
+
notIdenticalTest1(a) {
if (!identical("ho", a)) {
return 2;
diff --git a/tests/language/if_and_test.dart b/tests/language/if_and_test.dart
index 0b0cc84..55c28da 100644
--- a/tests/language/if_and_test.dart
+++ b/tests/language/if_and_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// The "if (negative) res2 |= 3" below can be emitted as negative && (res2 |= 3)
// in JavaScript. Dart2js produced the wrong output.
diff --git a/tests/language/if_conversion_vm_test.dart b/tests/language/if_conversion_vm_test.dart
new file mode 100644
index 0000000..22e6203
--- /dev/null
+++ b/tests/language/if_conversion_vm_test.dart
@@ -0,0 +1,92 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test if-convertion pass in the optimizing compiler.
+
+import "package:expect/expect.dart";
+
+f1(i) => (i == 0) ? 0 : 1;
+f2(i) => (i == 0) ? 2 : 3;
+f3(i) => (i == null) ? 0 : 1;
+f4(i) => (i == null) ? 2 : 3;
+
+f5(i) => (i != 0) ? 0 : 1;
+f6(i) => (i != 0) ? 2 : 3;
+f7(i) => (i != null) ? 0 : 1;
+f8(i) => (i != null) ? 2 : 3;
+
+f9(i) => identical(i, 0) ? 0 : 1;
+f10(i) => identical(i, 0) ? 2 : 3;
+f11(i) => identical(i, null) ? 0 : 1;
+f12(i) => identical(i, null) ? 2 : 3;
+
+f13(i) => !identical(i, 0) ? 0 : 1;
+f14(i) => !identical(i, 0) ? 2 : 3;
+f15(i) => !identical(i, null) ? 0 : 1;
+f16(i) => !identical(i, null) ? 2 : 3;
+
+const POWER_OF_2 = 0x1000000000;
+
+bigPower(i) => (i == 11) ? 0 : POWER_OF_2;
+
+main() {
+ for (var i = 0; i < 10000; i++) {
+ f1(i);
+ f2(i);
+ f3(i);
+ f4(i);
+ f5(i);
+ f6(i);
+ f7(i);
+ f8(i);
+ f9(i);
+ f10(i);
+ f11(i);
+ f12(i);
+ f13(i);
+ f14(i);
+ f15(i);
+ f16(i);
+ bigPower(i);
+ }
+
+ Expect.equals(0, f1(0));
+ Expect.equals(1, f1(44));
+ Expect.equals(2, f2(0));
+ Expect.equals(3, f2(44));
+ Expect.equals(0, f3(null));
+ Expect.equals(1, f3(44));
+ Expect.equals(2, f4(null));
+ Expect.equals(3, f4(44));
+
+ Expect.equals(1, f5(0));
+ Expect.equals(0, f5(44));
+ Expect.equals(3, f6(0));
+ Expect.equals(2, f6(44));
+ Expect.equals(1, f7(null));
+ Expect.equals(0, f7(44));
+ Expect.equals(3, f8(null));
+ Expect.equals(2, f8(44));
+
+ Expect.equals(0, f9(0));
+ Expect.equals(1, f9(44));
+ Expect.equals(2, f10(0));
+ Expect.equals(3, f10(44));
+ Expect.equals(0, f11(null));
+ Expect.equals(1, f11(44));
+ Expect.equals(2, f12(null));
+ Expect.equals(3, f12(44));
+
+ Expect.equals(1, f13(0));
+ Expect.equals(0, f13(44));
+ Expect.equals(3, f14(0));
+ Expect.equals(2, f14(44));
+ Expect.equals(1, f15(null));
+ Expect.equals(0, f15(44));
+ Expect.equals(3, f16(null));
+ Expect.equals(2, f16(44));
+
+ Expect.equals(0, bigPower(11));
+ Expect.equals(POWER_OF_2, bigPower(12));
+}
\ No newline at end of file
diff --git a/tests/language/if_test.dart b/tests/language/if_test.dart
index ebf32a8..1a64faf 100644
--- a/tests/language/if_test.dart
+++ b/tests/language/if_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing if statement.
+import "package:expect/expect.dart";
+
class Helper {
static int f0(bool b) {
if (b);
diff --git a/tests/language/implicit_closure2_test.dart b/tests/language/implicit_closure2_test.dart
index 40c47be..104154a 100644
--- a/tests/language/implicit_closure2_test.dart
+++ b/tests/language/implicit_closure2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class B {
foo(i) => 499 + i;
}
diff --git a/tests/language/implicit_closure_test.dart b/tests/language/implicit_closure_test.dart
index 3c61714..b5f8b8b 100644
--- a/tests/language/implicit_closure_test.dart
+++ b/tests/language/implicit_closure_test.dart
@@ -5,6 +5,8 @@
// VMOptions=
// VMOptions=--use_slow_path
+import "package:expect/expect.dart";
+
class First {
First(this.i) {}
var b;
diff --git a/tests/language/implicit_scope_test.dart b/tests/language/implicit_scope_test.dart
index 3446fb2..26cb13c 100644
--- a/tests/language/implicit_scope_test.dart
+++ b/tests/language/implicit_scope_test.dart
@@ -4,6 +4,8 @@
// Test that if, while etc create an implicit scope if the body
// is not a compound statement.
+import "package:expect/expect.dart";
+
class ImplicitScopeTest {
static bool alwaysTrue() {
return 1 + 1 == 2;
diff --git a/tests/language/implicit_this_test.dart b/tests/language/implicit_this_test.dart
index f6ebd58..490e7e1 100644
--- a/tests/language/implicit_this_test.dart
+++ b/tests/language/implicit_this_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class Interface {
final x;
}
diff --git a/tests/language/implied_interface_test.dart b/tests/language/implied_interface_test.dart
index 93d0d6e..36acb25 100644
--- a/tests/language/implied_interface_test.dart
+++ b/tests/language/implied_interface_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class BaseClass {
var foo;
BaseClass() { foo = 0; }
diff --git a/tests/language/import_combinators_test.dart b/tests/language/import_combinators_test.dart
index 0d91356..e975fb3 100644
--- a/tests/language/import_combinators_test.dart
+++ b/tests/language/import_combinators_test.dart
@@ -5,6 +5,7 @@
// Dart test program importing with show/hide combinators.
library importCombinatorsTest;
+import "package:expect/expect.dart";
import "import1_lib.dart" show hide, show hide ugly;
import "export1_lib.dart";
import "dart:math" as M show E;
diff --git a/tests/language/import_core_prefix_test.dart b/tests/language/import_core_prefix_test.dart
index a3a7c93..ec237ff 100644
--- a/tests/language/import_core_prefix_test.dart
+++ b/tests/language/import_core_prefix_test.dart
@@ -4,6 +4,7 @@
// Test explicit import of dart:core in the source code..
library ImportCorePrefixTest.dart;
+import "package:expect/expect.dart";
import "dart:core" as mycore;
class Object {
@@ -30,6 +31,6 @@
var greenwich = new Map(51, 0);
var kpao = new Map(37, -122);
- mycore.Expect.isTrue(greenwich.isPrimeMeridian);
- mycore.Expect.isFalse(kpao.isPrimeMeridian);
+ Expect.isTrue(greenwich.isPrimeMeridian);
+ Expect.isFalse(kpao.isPrimeMeridian);
}
diff --git a/tests/language/incr_op_test.dart b/tests/language/incr_op_test.dart
index be772e7..9050a41 100644
--- a/tests/language/incr_op_test.dart
+++ b/tests/language/incr_op_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing increment operator.
+import "package:expect/expect.dart";
+
class A {
static var yy;
static set y(v) {
diff --git a/tests/language/index_test.dart b/tests/language/index_test.dart
index 9e1c634..2fd48d1 100644
--- a/tests/language/index_test.dart
+++ b/tests/language/index_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing index operators.
+import "package:expect/expect.dart";
+
class Helper {
static int fibonacci(int n) {
int a = 0, b = 1, i = 0;
diff --git a/tests/language/infinity_test.dart b/tests/language/infinity_test.dart
index 7ac9f31..c7b0272 100644
--- a/tests/language/infinity_test.dart
+++ b/tests/language/infinity_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
main() {
diff --git a/tests/language/inline_argument_test.dart b/tests/language/inline_argument_test.dart
index a04786f..61761c5 100644
--- a/tests/language/inline_argument_test.dart
+++ b/tests/language/inline_argument_test.dart
@@ -4,6 +4,8 @@
// Test that when inlining A.foo, we're not evaluating the argument
// twice.
+import "package:expect/expect.dart";
+
class A {
var field = 0;
diff --git a/tests/language/inline_closure_with_constant_arguments_test.dart b/tests/language/inline_closure_with_constant_arguments_test.dart
index 0182453..b5e8eba 100644
--- a/tests/language/inline_closure_with_constant_arguments_test.dart
+++ b/tests/language/inline_closure_with_constant_arguments_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test inlining of a closure call with constant propagation.
primeForSmis(bool b) {
smi_op(a, b) => a + b;
diff --git a/tests/language/inline_effect_context_test.dart b/tests/language/inline_effect_context_test.dart
index 73fd50a..fcb5dbd 100644
--- a/tests/language/inline_effect_context_test.dart
+++ b/tests/language/inline_effect_context_test.dart
@@ -5,6 +5,8 @@
// Optimize function foo with instance of A and inlined function bar. Call later
// with instance of B and cause deoptimization.
+import "package:expect/expect.dart";
+
class A {
var x = 1;
}
diff --git a/tests/language/inline_getter_test.dart b/tests/language/inline_getter_test.dart
index eb671f9..27322c8 100644
--- a/tests/language/inline_getter_test.dart
+++ b/tests/language/inline_getter_test.dart
@@ -5,6 +5,8 @@
// Three classes access always the same field. Optimize method foo and inline
// getter for classes 'A' and 'B'. Call later via 'C' and cause deoptimization.
+import "package:expect/expect.dart";
+
class A {
int f;
A(this.f) {}
diff --git a/tests/language/inline_super_field_test.dart b/tests/language/inline_super_field_test.dart
index 2daa34d..a3dc029 100644
--- a/tests/language/inline_super_field_test.dart
+++ b/tests/language/inline_super_field_test.dart
@@ -7,6 +7,7 @@
library inline_super_field_test;
+import 'package:expect/expect.dart';
import "inline_super_field_lib.dart";
class S {
diff --git a/tests/language/inline_super_test.dart b/tests/language/inline_super_test.dart
index 9305984..7ed155b 100644
--- a/tests/language/inline_super_test.dart
+++ b/tests/language/inline_super_test.dart
@@ -5,6 +5,7 @@
// Regression test for dart2js issue 6639.
library inline_super_test;
+import "package:expect/expect.dart";
part 'inline_super_part.dart';
diff --git a/tests/language/inline_test_context_test.dart b/tests/language/inline_test_context_test.dart
index 7692bff..5ec00d6 100644
--- a/tests/language/inline_test_context_test.dart
+++ b/tests/language/inline_test_context_test.dart
@@ -5,6 +5,8 @@
// Optimize function foo with instance of A and inlined function bar. Call later
// with instance of B and cause deoptimization.
+import "package:expect/expect.dart";
+
class A {
var x = 1;
}
diff --git a/tests/language/inline_value_context_test.dart b/tests/language/inline_value_context_test.dart
index 8d8e3c1..46cde91 100644
--- a/tests/language/inline_value_context_test.dart
+++ b/tests/language/inline_value_context_test.dart
@@ -5,6 +5,8 @@
// Optimize function foo with instance of A and inlined function bar. Call later
// with instance of B and cause deoptimization.
+import "package:expect/expect.dart";
+
class A {
var x = 1;
}
diff --git a/tests/language/inlined_throw_test.dart b/tests/language/inlined_throw_test.dart
index 1b1afe1..4394949 100644
--- a/tests/language/inlined_throw_test.dart
+++ b/tests/language/inlined_throw_test.dart
@@ -5,6 +5,8 @@
// Dart test program to test check that we don't fail to compile when an
// inlinable method contains a throw.
+import 'package:expect/expect.dart';
+
var x = false;
bool called;
@@ -71,6 +73,12 @@
yo() {
throw kast("yo");
}
+bin() {
+ return 5 * kast("bin");
+}
+binCallThrow() {
+ return callMe() * kast("binct");
+}
hoo() {
x[kast("hoo")] = 0;
x[kast("hoo")];
@@ -85,6 +93,26 @@
}
}
+class ThrowConstructor {
+ ThrowConstructor() :
+ foo = callMeTrue(),
+ bar = kast("ThrowConstructor") {
+ called = false;
+ }
+
+ bool foo;
+ var bar;
+}
+
+throwConstructor() {
+ called = false;
+ return new ThrowConstructor();
+}
+
+cascade() {
+ return new List()..add(callMeTrue())..add(kast("cascade"));
+}
+
interpole() => "inter${kast('tada!')}pole";
interpoleCallThrow() => "inter${callMeTrue()}...${kast('tada!')}pole";
@@ -140,6 +168,81 @@
return(x);
}
+dovileBreakContinue(x) {
+ do {
+ callMe();
+ if (x == 1) break;
+ continue;
+ } while (kast("vile"));
+ return(x);
+}
+
+faar1() {
+ callMe();
+ for (kast("faar"); called = false; called = false) {
+ called = false;
+ }
+}
+
+faar2() {
+ for (callMe(); kast("faar"); called = false) {
+ called = false;
+ }
+}
+
+faar3() {
+ for (; true; kast("faar")) {
+ callMe();
+ }
+ called = false;
+}
+
+faar4() {
+ callMe();
+ for (kast("faar"); called = false; called = false) {
+ called = false;
+ continue;
+ }
+}
+
+faar5() {
+ for (callMe(); kast("faar"); called = false) {
+ called = false;
+ continue;
+ }
+}
+
+faar6() {
+ for (; true; kast("faar")) {
+ callMe();
+ continue;
+ }
+ called = false;
+}
+
+faar7() {
+ callMe();
+ for (kast("faar"); called = false; called = false) {
+ called = false;
+ break;
+ }
+}
+
+faar8() {
+ for (callMe(); kast("faar"); called = false) {
+ called = false;
+ break;
+ }
+}
+
+faar9() {
+ for (; true; kast("faar")) {
+ callMe();
+ break;
+ called = false;
+ }
+}
+
main() {
Expect.throws(hest);
Expect.throws(hest2);
@@ -159,6 +262,8 @@
Expect.throws(unary);
testCallThenThrow(boo);
Expect.throws(yo);
+ Expect.throws(bin);
+ testCallThenThrow(binCallThrow);
Expect.throws(hoo);
Expect.throws(switcheroo);
Expect.throws(interpole);
@@ -176,4 +281,16 @@
testCallThenThrow(dovile);
testCall(dovileBreak);
testCallThenThrow(dovileContinue);
+ testCallThenThrow(throwConstructor);
+ testCallThenThrow(cascade);
+ dovileBreakContinue(1);
+ testCallThenThrow(faar1);
+ testCallThenThrow(faar2);
+ testCallThenThrow(faar3);
+ testCallThenThrow(faar4);
+ testCallThenThrow(faar5);
+ testCallThenThrow(faar6);
+ testCallThenThrow(faar7);
+ testCallThenThrow(faar8);
+ testCall(faar9);
}
diff --git a/tests/language/inst_field_initializer_test.dart b/tests/language/inst_field_initializer_test.dart
index 43a2c51..6368b8d 100644
--- a/tests/language/inst_field_initializer_test.dart
+++ b/tests/language/inst_field_initializer_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test for instance field initializer expressions.
+import "package:expect/expect.dart";
+
class Cheese {
static const mild = 1;
static const stinky = 2;
diff --git a/tests/language/instance_compound_assignment_operator_test.dart b/tests/language/instance_compound_assignment_operator_test.dart
index a69cbe6..bbbb834 100644
--- a/tests/language/instance_compound_assignment_operator_test.dart
+++ b/tests/language/instance_compound_assignment_operator_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test correct instance compound assignment operator.
+import "package:expect/expect.dart";
+
class A {
A() : f = 2 {}
var f;
diff --git a/tests/language/instance_field_initializer_test.dart b/tests/language/instance_field_initializer_test.dart
index 20f11ca..1cb5c93 100644
--- a/tests/language/instance_field_initializer_test.dart
+++ b/tests/language/instance_field_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int x = 1;
A() {}
diff --git a/tests/language/instance_incr_deopt_test.dart b/tests/language/instance_incr_deopt_test.dart
index c0e0ffd..b7152e3 100644
--- a/tests/language/instance_incr_deopt_test.dart
+++ b/tests/language/instance_incr_deopt_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Check correct deoptimization of instance field increment.
diff --git a/tests/language/instance_inline_test.dart b/tests/language/instance_inline_test.dart
index fefdf21..a13d93a 100644
--- a/tests/language/instance_inline_test.dart
+++ b/tests/language/instance_inline_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test inlining of assignments in parameter passing. If [StringScanner.charAt]
// is inlined, the argument expresion [: ++byteOffset :] should not be
// duplicated.
diff --git a/tests/language/instanceof2_test.dart b/tests/language/instanceof2_test.dart
index f93c0b3..2fb30ba 100644
--- a/tests/language/instanceof2_test.dart
+++ b/tests/language/instanceof2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing the instanceof operation.
+import "package:expect/expect.dart";
+
abstract class I { }
abstract class AI implements I { }
diff --git a/tests/language/instanceof3_test.dart b/tests/language/instanceof3_test.dart
index 4921a181..5075840 100644
--- a/tests/language/instanceof3_test.dart
+++ b/tests/language/instanceof3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing the instanceof operation.
+import "package:expect/expect.dart";
+
// In the type test 'e is T', it is a run-time error if T does not denote a type
// available in the current lexical scope.
diff --git a/tests/language/instanceof4_test.dart b/tests/language/instanceof4_test.dart
index 9fcb54e..489ad2d 100644
--- a/tests/language/instanceof4_test.dart
+++ b/tests/language/instanceof4_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing the instanceof operation.
// Regression test for issue 5216.
+import "package:expect/expect.dart";
+
class Foo<T> {
bool isT() => "a string" is T;
bool isNotT() => "a string" is! T;
diff --git a/tests/language/instanceof_test.dart b/tests/language/instanceof_test.dart
index 7233e3c..73bc640 100644
--- a/tests/language/instanceof_test.dart
+++ b/tests/language/instanceof_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class InstanceofTest {
InstanceofTest() {}
diff --git a/tests/language/int_test.dart b/tests/language/int_test.dart
index 298f716..f91f90d 100644
--- a/tests/language/int_test.dart
+++ b/tests/language/int_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test basic integer operations.
+import "package:expect/expect.dart";
+
class IntTest {
static void testMain() {
Expect.equals(0, 0 + 0);
diff --git a/tests/language/interceptor2_test.dart b/tests/language/interceptor2_test.dart
index 3cff1be..64e0e59 100644
--- a/tests/language/interceptor2_test.dart
+++ b/tests/language/interceptor2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for issue http://dartbug.com/6903: dart2js used to
// not generate an interceptor forwarder when a getter call and a
// method call on an intercepted method were both used.
diff --git a/tests/language/interceptor3_test.dart b/tests/language/interceptor3_test.dart
index ec9cc6d..a121721 100644
--- a/tests/language/interceptor3_test.dart
+++ b/tests/language/interceptor3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that code motion in the presence of interceptors work in dart2js.
main() {
diff --git a/tests/language/interceptor4_test.dart b/tests/language/interceptor4_test.dart
index 2a7d030..00bac28 100644
--- a/tests/language/interceptor4_test.dart
+++ b/tests/language/interceptor4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that dart2js gets the right interceptor for an int.
main() {
diff --git a/tests/language/interceptor5_test.dart b/tests/language/interceptor5_test.dart
index a74da66..41b76e9 100644
--- a/tests/language/interceptor5_test.dart
+++ b/tests/language/interceptor5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
get X => [() => 123];
main() {
diff --git a/tests/language/interceptor6_test.dart b/tests/language/interceptor6_test.dart
index 35f4bd3..208a59d 100644
--- a/tests/language/interceptor6_test.dart
+++ b/tests/language/interceptor6_test.dart
@@ -5,6 +5,8 @@
// Check that an intercepted call on a method that does not exist does
// not crash the compiler.
+import "package:expect/expect.dart";
+
main() {
Expect.throws(() => 42.clamp(), (e) => e is NoSuchMethodError);
}
diff --git a/tests/language/interceptor7_test.dart b/tests/language/interceptor7_test.dart
index 853523a..965ddfc 100644
--- a/tests/language/interceptor7_test.dart
+++ b/tests/language/interceptor7_test.dart
@@ -5,6 +5,8 @@
// Test that dart2js uses the right interceptor when call a method on
// something that has type number.
+import 'package:expect/expect.dart';
+
var array = [];
main() {
diff --git a/tests/language/interceptor_test.dart b/tests/language/interceptor_test.dart
index 2fe247e..cbca9f9 100644
--- a/tests/language/interceptor_test.dart
+++ b/tests/language/interceptor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that interceptors (that is, methods in classes implemented as
// JavaScript primitives) in dart2js work.
diff --git a/tests/language/interface_constants_test.dart b/tests/language/interface_constants_test.dart
index 62875fc..5654066 100644
--- a/tests/language/interface_constants_test.dart
+++ b/tests/language/interface_constants_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class Constants {
static const int FIVE = 5;
}
diff --git a/tests/language/interface_injection1_negative_test.dart b/tests/language/interface_injection1_negative_test.dart
index 3c6c697..474a27e 100644
--- a/tests/language/interface_injection1_negative_test.dart
+++ b/tests/language/interface_injection1_negative_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class S { }
abstract class I { }
abstract class I implements S;
diff --git a/tests/language/interface_injection2_negative_test.dart b/tests/language/interface_injection2_negative_test.dart
index fdb7275..29540f3 100644
--- a/tests/language/interface_injection2_negative_test.dart
+++ b/tests/language/interface_injection2_negative_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class S { }
class C { }
class C implements S;
diff --git a/tests/language/intrinsified_methods_test.dart b/tests/language/intrinsified_methods_test.dart
index 464c4fa..c7792ee 100644
--- a/tests/language/intrinsified_methods_test.dart
+++ b/tests/language/intrinsified_methods_test.dart
@@ -4,6 +4,7 @@
// Dart test program for testing the instanceof operation.
library intrinsified_methods_test;
+import "package:expect/expect.dart";
import 'dart:math';
testIsNegative() {
diff --git a/tests/language/invocation_mirror2_test.dart b/tests/language/invocation_mirror2_test.dart
index e320835..f93ac1e 100644
--- a/tests/language/invocation_mirror2_test.dart
+++ b/tests/language/invocation_mirror2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class GetName {
set flif(_) => "flif=";
}
diff --git a/tests/language/invocation_mirror_invoke_on2_test.dart b/tests/language/invocation_mirror_invoke_on2_test.dart
index 0e4deac..3b1fc9f 100644
--- a/tests/language/invocation_mirror_invoke_on2_test.dart
+++ b/tests/language/invocation_mirror_invoke_on2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Proxy {
final proxied;
Proxy(this.proxied);
diff --git a/tests/language/invocation_mirror_invoke_on_test.dart b/tests/language/invocation_mirror_invoke_on_test.dart
index f03726c..030fee6 100644
--- a/tests/language/invocation_mirror_invoke_on_test.dart
+++ b/tests/language/invocation_mirror_invoke_on_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Testing InvocationMirror.invokeOn method; test of issue 7227.
var reachedSetX = 0;
diff --git a/tests/language/invocation_mirror_test.dart b/tests/language/invocation_mirror_test.dart
index bb573a4..5c5a91b 100644
--- a/tests/language/invocation_mirror_test.dart
+++ b/tests/language/invocation_mirror_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// InvocationMirror and noSuchMethod testing.
/** Class with noSuchMethod that returns the mirror */
diff --git a/tests/language/is_function_test.dart b/tests/language/is_function_test.dart
index 0dce0bb..24e3a8b 100644
--- a/tests/language/is_function_test.dart
+++ b/tests/language/is_function_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var staticClosure;
staticMethod() => 42;
diff --git a/tests/language/is_interfaces2_test.dart b/tests/language/is_interfaces2_test.dart
index ce20575..d14f9fa 100644
--- a/tests/language/is_interfaces2_test.dart
+++ b/tests/language/is_interfaces2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
}
diff --git a/tests/language/is_interfaces_test.dart b/tests/language/is_interfaces_test.dart
index 1301c23..dbdfa5d 100644
--- a/tests/language/is_interfaces_test.dart
+++ b/tests/language/is_interfaces_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
}
diff --git a/tests/language/is_nan_test.dart b/tests/language/is_nan_test.dart
index 3edfebd..7dcc805 100644
--- a/tests/language/is_nan_test.dart
+++ b/tests/language/is_nan_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
bool get isNaN => false;
}
diff --git a/tests/language/is_object_test.dart b/tests/language/is_object_test.dart
index 1a47bb2..7dc6574 100644
--- a/tests/language/is_object_test.dart
+++ b/tests/language/is_object_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for the "is" type test operator.
+import "package:expect/expect.dart";
+
testTryCatch(x) {
try {
throw x;
diff --git a/tests/language/is_operator_test.dart b/tests/language/is_operator_test.dart
index 406d6bf..e5b0792 100644
--- a/tests/language/is_operator_test.dart
+++ b/tests/language/is_operator_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for the "is" type test operator.
+import "package:expect/expect.dart";
+
abstract class I { }
abstract class AI implements I { }
diff --git a/tests/language/issue4515170_test.dart b/tests/language/issue4515170_test.dart
index c735893..b187204 100644
--- a/tests/language/issue4515170_test.dart
+++ b/tests/language/issue4515170_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Issue4515170Test {
static const VAL = 3;
static int defaultVal([int a = VAL]) {
diff --git a/tests/language/issue7513_test.dart b/tests/language/issue7513_test.dart
index 4d503c3..02efb67 100644
--- a/tests/language/issue7513_test.dart
+++ b/tests/language/issue7513_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for issue 7513.
foo(a, b) {
diff --git a/tests/language/issue7525_test.dart b/tests/language/issue7525_test.dart
index c2b44d5..0ba650b 100644
--- a/tests/language/issue7525_test.dart
+++ b/tests/language/issue7525_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for issue 7525.
foo() {
diff --git a/tests/language/js_properties_test.dart b/tests/language/js_properties_test.dart
index 6303730..fdca010 100644
--- a/tests/language/js_properties_test.dart
+++ b/tests/language/js_properties_test.dart
@@ -4,6 +4,8 @@
// Test that JavaScript properties on Object can still be classes in
// Dart.
+import "package:expect/expect.dart";
+
void main() {
Expect.equals(42, new __defineGetter__().hello());
Expect.equals(42, new __defineSetter__().hello());
diff --git a/tests/language/label_test.dart b/tests/language/label_test.dart
index e9affb2..2d524e1 100644
--- a/tests/language/label_test.dart
+++ b/tests/language/label_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program to test check that we can parse labels.
+import "package:expect/expect.dart";
+
class Helper {
diff --git a/tests/language/language.status b/tests/language/language.status
index f937659..13347e4 100644
--- a/tests/language/language.status
+++ b/tests/language/language.status
@@ -71,6 +71,9 @@
super_getter_setter_test: Fail # Issue 8917
super_operator_index7_test: Fail # Issue 8918
+execute_finally10_test: Fail # Issue 430
+execute_finally11_test: Fail # Issue 430
+
[ $compiler == none && ($system == macos || $system == linux) && $arch == ia32 && $checked ]
gc_test: Skip # Issue 1487, flaky.
@@ -547,6 +550,9 @@
super_getter_setter_test: Fail # VM bug: issue 8917
super_operator_index7_test: Fail # VM bug: issue 8918
+execute_finally10_test: Fail # VM bug: issue 430
+execute_finally11_test: Fail # VM bug: issue 430
+
[ $compiler == dart2dart && $minified ]
# TODO(tball): Assign proper bug numbers.
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index 9f28309..10d7d8d 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -342,8 +342,6 @@
[ $compiler == dart2js && $runtime == safari ]
-execute_finally8_test: Fail # Issue: 7414
-execute_finally9_test: Fail # Issue: 7414
null_pointer_exception_test: Fail # Uncaught error: Instance of 'TypeError'
string_interpolate_npe_test: Fail # Uncaught error: Instance of 'TypeError'
arithmetic_test: Fail # Issue: 7414
diff --git a/tests/language/lazy_map_test.dart b/tests/language/lazy_map_test.dart
index f1ff770..65fb19b 100644
--- a/tests/language/lazy_map_test.dart
+++ b/tests/language/lazy_map_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var data = { 'a': 'a' };
main() {
Expect.equals('a', data['a']);
diff --git a/tests/language/lazy_static2_test.dart b/tests/language/lazy_static2_test.dart
index b06db04..72010f0 100644
--- a/tests/language/lazy_static2_test.dart
+++ b/tests/language/lazy_static2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
final x = (t) => t + 1;
main() {
diff --git a/tests/language/lazy_static3_test.dart b/tests/language/lazy_static3_test.dart
index aa6c801..76186f6 100644
--- a/tests/language/lazy_static3_test.dart
+++ b/tests/language/lazy_static3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
final x = foo();
var x2 = foo2();
var x3 = foo3();
diff --git a/tests/language/lazy_static4_test.dart b/tests/language/lazy_static4_test.dart
index 558b388..4e532c9 100644
--- a/tests/language/lazy_static4_test.dart
+++ b/tests/language/lazy_static4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
final x = foo(499);
final y = foo(41) + 1;
diff --git a/tests/language/lazy_static5_test.dart b/tests/language/lazy_static5_test.dart
index 00b30bb..66b9b61 100644
--- a/tests/language/lazy_static5_test.dart
+++ b/tests/language/lazy_static5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
final x = (t) => (u) => t + u;
main() {
diff --git a/tests/language/lazy_static6_test.dart b/tests/language/lazy_static6_test.dart
index 5e1b2c3..2810e52 100644
--- a/tests/language/lazy_static6_test.dart
+++ b/tests/language/lazy_static6_test.dart
@@ -2,4 +2,5 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library lazy_static6_test;
+import "package:expect/expect.dart";
part "lazy_static6_src.dart";
diff --git a/tests/language/lazy_static_test.dart b/tests/language/lazy_static_test.dart
index 0f51770..5c582d9 100644
--- a/tests/language/lazy_static_test.dart
+++ b/tests/language/lazy_static_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
final x = foo();
final y = y2(y3);
final y2 = incrementCreator();
diff --git a/tests/language/left_shift_test.dart b/tests/language/left_shift_test.dart
index 9cca5d3..7f151b1 100644
--- a/tests/language/left_shift_test.dart
+++ b/tests/language/left_shift_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 80; i++) {
var a = -1 << i;
diff --git a/tests/language/library10.dart b/tests/language/library10.dart
index ebcd114..3af75b6 100644
--- a/tests/language/library10.dart
+++ b/tests/language/library10.dart
@@ -6,6 +6,7 @@
library library10.dart;
import "library11.dart" as lib11;
+import "package:expect/expect.dart";
class Library10 {
Library10(this.fld);
diff --git a/tests/language/library1_negative_test.dart b/tests/language/library1_negative_test.dart
index 7af4786..aa5f869 100644
--- a/tests/language/library1_negative_test.dart
+++ b/tests/language/library1_negative_test.dart
@@ -6,6 +6,7 @@
// which define the same top level name foo, and we are referring to the name.
library Library1NegativeTest.dart;
+import "package:expect/expect.dart";
import "library1.dart"; // Defines top level variable 'foo'
import "library2.dart"; // Defines top level variable 'foo'
diff --git a/tests/language/library1_test.dart b/tests/language/library1_test.dart
index 297b1a6..fb5bf7d 100644
--- a/tests/language/library1_test.dart
+++ b/tests/language/library1_test.dart
@@ -4,6 +4,7 @@
// Dart test program for testing libraries.
library Library1Test.dart;
+import "package:expect/expect.dart";
import "library1_lib.lib";
main() {
diff --git a/tests/language/library5_test.dart b/tests/language/library5_test.dart
index dbc2dc7..d3a45b0 100644
--- a/tests/language/library5_test.dart
+++ b/tests/language/library5_test.dart
@@ -4,6 +4,7 @@
//
library Library5Test.dart;
+import "package:expect/expect.dart";
import "library5a.dart" as lib5a;
import "library5b.dart" as lib5b;
diff --git a/tests/language/library_juxtaposition_test.dart b/tests/language/library_juxtaposition_test.dart
index 880d2c8..aad08ac 100644
--- a/tests/language/library_juxtaposition_test.dart
+++ b/tests/language/library_juxtaposition_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "library_" "juxtaposition_" "lib.dart";
export "library_" "juxtaposition_" "lib.dart";
diff --git a/tests/language/library_prefixes_test.dart b/tests/language/library_prefixes_test.dart
index da739e1..80714da 100644
--- a/tests/language/library_prefixes_test.dart
+++ b/tests/language/library_prefixes_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library LibraryPrefixesTest.dart;
+import "package:expect/expect.dart";
import "library_prefixes.lib";
class LibraryPrefixesTest {
diff --git a/tests/language/library_private_in_constructor_test.dart b/tests/language/library_private_in_constructor_test.dart
index 37a1b83..ce6b3db 100644
--- a/tests/language/library_private_in_constructor_test.dart
+++ b/tests/language/library_private_in_constructor_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library LibraryPrivateInConstructor;
+import "package:expect/expect.dart";
import "library_private_in_constructor_a.dart";
import "library_private_in_constructor_b.dart";
diff --git a/tests/language/library_same_name_used_test.dart b/tests/language/library_same_name_used_test.dart
index 33568b9..6ed7aec 100644
--- a/tests/language/library_same_name_used_test.dart
+++ b/tests/language/library_same_name_used_test.dart
@@ -6,6 +6,7 @@
// abstract class in lib2. Use of import prefixes should allow this.
library main;
+import "package:expect/expect.dart";
import "library_same_name_used_lib1.dart";
main() {
diff --git a/tests/language/licm_test.dart b/tests/language/licm_test.dart
index 67fea65..e058e8e 100644
--- a/tests/language/licm_test.dart
+++ b/tests/language/licm_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var sum = 0;
var foo = 0;
var bar = 1;
diff --git a/tests/language/list_double_index_in_loop2_test.dart b/tests/language/list_double_index_in_loop2_test.dart
index 59e0ddd..5a4454d 100644
--- a/tests/language/list_double_index_in_loop2_test.dart
+++ b/tests/language/list_double_index_in_loop2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing arrays.
+import "package:expect/expect.dart";
+
bar() => true;
tata() => 1.5;
diff --git a/tests/language/list_double_index_in_loop_test.dart b/tests/language/list_double_index_in_loop_test.dart
index 89725cc..708fb4b 100644
--- a/tests/language/list_double_index_in_loop_test.dart
+++ b/tests/language/list_double_index_in_loop_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing arrays.
+import "package:expect/expect.dart";
+
bar() => true;
// The type propagation in Dart2Js wrongly took the intersection of all incoming
diff --git a/tests/language/list_is_test.dart b/tests/language/list_is_test.dart
index 147ab33..8df30bd 100644
--- a/tests/language/list_is_test.dart
+++ b/tests/language/list_is_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
bar() => new List<T>();
}
diff --git a/tests/language/list_literal2_test.dart b/tests/language/list_literal2_test.dart
index 5157c36..49dc1af 100644
--- a/tests/language/list_literal2_test.dart
+++ b/tests/language/list_literal2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test program for array literals.
+import "package:expect/expect.dart";
+
class ArrayLiteral2Test {
static const int LAUREL = 1965;
static const int HARDY = 1957;
diff --git a/tests/language/list_literal3_test.dart b/tests/language/list_literal3_test.dart
index 1d657e3..d6151ce 100644
--- a/tests/language/list_literal3_test.dart
+++ b/tests/language/list_literal3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that arrays from const array literals are immutable.
+import "package:expect/expect.dart";
+
class ListLiteral3Test {
static const List<String> canonicalJoke = const ["knock", "knock"];
diff --git a/tests/language/list_literal4_test.dart b/tests/language/list_literal4_test.dart
index 92935f5..9f85220 100644
--- a/tests/language/list_literal4_test.dart
+++ b/tests/language/list_literal4_test.dart
@@ -5,6 +5,8 @@
//
// Dart test program testing type checks in list literals.
+import "package:expect/expect.dart";
+
class ListLiteral4Test<T> {
test() {
int result = 0;
diff --git a/tests/language/list_literal_syntax_test.dart b/tests/language/list_literal_syntax_test.dart
index 01554f7..83f23a9 100644
--- a/tests/language/list_literal_syntax_test.dart
+++ b/tests/language/list_literal_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class I {}
void main() {
diff --git a/tests/language/list_literal_test.dart b/tests/language/list_literal_test.dart
index 7b85971..ccfa1c5 100644
--- a/tests/language/list_literal_test.dart
+++ b/tests/language/list_literal_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test program for array literals.
+import "package:expect/expect.dart";
+
class ListLiteralTest {
static const LAUREL = 1;
diff --git a/tests/language/list_test.dart b/tests/language/list_test.dart
index 58000c7..a0a12ec 100644
--- a/tests/language/list_test.dart
+++ b/tests/language/list_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing arrays.
+import "package:expect/expect.dart";
+
class ListTest {
static void TestIterator() {
List<int> a = new List<int>(10);
diff --git a/tests/language/liveness_test.dart b/tests/language/liveness_test.dart
index 08d84e7..61e6284 100644
--- a/tests/language/liveness_test.dart
+++ b/tests/language/liveness_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing closures.
+import "package:expect/expect.dart";
+
foo(x) {
var y = x;
for (int i = 0; i < 10; i++) x++;
diff --git a/tests/language/load_to_load_forwarding_test.dart b/tests/language/load_to_load_forwarding_test.dart
index 5738263..6c7d8b4 100644
--- a/tests/language/load_to_load_forwarding_test.dart
+++ b/tests/language/load_to_load_forwarding_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test correctness of side effects tracking used by load to load forwarding.
+import "package:expect/expect.dart";
+
class A {
var x, y;
A(this.x, this.y);
diff --git a/tests/language/local_export_test.dart b/tests/language/local_export_test.dart
index ce2ca1d..2d3efc8 100644
--- a/tests/language/local_export_test.dart
+++ b/tests/language/local_export_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library localExportTest;
+import "package:expect/expect.dart";
import 'local_export_a.dart';
void main() {
diff --git a/tests/language/local_function2_test.dart b/tests/language/local_function2_test.dart
index 5aaf7f5..1ccf9c1 100644
--- a/tests/language/local_function2_test.dart
+++ b/tests/language/local_function2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing closures.
+import "package:expect/expect.dart";
+
typedef T F<T>(T t);
class Parameterized<T> {
diff --git a/tests/language/local_function3_test.dart b/tests/language/local_function3_test.dart
index c3282c3..501510e 100644
--- a/tests/language/local_function3_test.dart
+++ b/tests/language/local_function3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing closures.
+import "package:expect/expect.dart";
+
class LocalFunction3Test {
static testExceptions() {
var f = (int n) { return n + 1; };
diff --git a/tests/language/local_function_test.dart b/tests/language/local_function_test.dart
index 104319f..8051fe2 100644
--- a/tests/language/local_function_test.dart
+++ b/tests/language/local_function_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing closures.
+import "package:expect/expect.dart";
+
class LocalFunctionTest {
LocalFunctionTest() : field1 = 100, field2_ = 200 { }
static int f(int n) {
diff --git a/tests/language/loop_exchange2_test.dart b/tests/language/loop_exchange2_test.dart
index 98c97a3..576c5af 100644
--- a/tests/language/loop_exchange2_test.dart
+++ b/tests/language/loop_exchange2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This program tripped dart2js.
main() {
var a = 1;
diff --git a/tests/language/loop_exchange3_test.dart b/tests/language/loop_exchange3_test.dart
index 5b85005..d0cbb0f 100644
--- a/tests/language/loop_exchange3_test.dart
+++ b/tests/language/loop_exchange3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This program tripped dart2js.
main() {
int foo;
diff --git a/tests/language/loop_exchange4_test.dart b/tests/language/loop_exchange4_test.dart
index 9c1f459..089e93d 100644
--- a/tests/language/loop_exchange4_test.dart
+++ b/tests/language/loop_exchange4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This program tripped dart2js.
main() {
var count = 0;
diff --git a/tests/language/loop_exchange_test.dart b/tests/language/loop_exchange_test.dart
index 9b06a17..da2e5ad 100644
--- a/tests/language/loop_exchange_test.dart
+++ b/tests/language/loop_exchange_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This program tripped dart2js.
main() {
var x = 1;
diff --git a/tests/language/loop_hoist_test.dart b/tests/language/loop_hoist_test.dart
index a4024af..628d635 100644
--- a/tests/language/loop_hoist_test.dart
+++ b/tests/language/loop_hoist_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
num x;
A() : this.x = 0;
diff --git a/tests/language/many_calls_test.dart b/tests/language/many_calls_test.dart
index c59b90f..12a59f2 100644
--- a/tests/language/many_calls_test.dart
+++ b/tests/language/many_calls_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test megamorphic calls.
+import "package:expect/expect.dart";
+
class A {
A() {}
f1() { return 1; }
diff --git a/tests/language/many_generic_instanceof_test.dart b/tests/language/many_generic_instanceof_test.dart
index b3be553..5f92367 100644
--- a/tests/language/many_generic_instanceof_test.dart
+++ b/tests/language/many_generic_instanceof_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library ManyGenericInstanceofTest.dart;
+import "package:expect/expect.dart";
part "generic_instanceof.dart";
class ManyGenericInstanceofTest {
diff --git a/tests/language/many_overridden_no_such_method_test.dart b/tests/language/many_overridden_no_such_method_test.dart
index 76a847a..cb9416c 100644
--- a/tests/language/many_overridden_no_such_method_test.dart
+++ b/tests/language/many_overridden_no_such_method_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library ManyOverriddenNoSuchMethodTest.dart;
+import "package:expect/expect.dart";
part "overridden_no_such_method.dart";
class ManyOverriddenNoSuchMethodTest {
diff --git a/tests/language/map_literal2_test.dart b/tests/language/map_literal2_test.dart
index 6361f89..c510f35 100644
--- a/tests/language/map_literal2_test.dart
+++ b/tests/language/map_literal2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test program for map literals.
+import "package:expect/expect.dart";
+
int nextValCtr;
get nextVal {
diff --git a/tests/language/map_literal3_test.dart b/tests/language/map_literal3_test.dart
index 0e571e8..3a11f76 100644
--- a/tests/language/map_literal3_test.dart
+++ b/tests/language/map_literal3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test program for map literals.
+import "package:expect/expect.dart";
+
class MapLiteralTest {
static testMain() {
diff --git a/tests/language/map_literal4_test.dart b/tests/language/map_literal4_test.dart
index 35a3f97..ce922fe 100644
--- a/tests/language/map_literal4_test.dart
+++ b/tests/language/map_literal4_test.dart
@@ -5,6 +5,8 @@
//
// Dart test program testing type checks in map literals.
+import "package:expect/expect.dart";
+
class MapLiteral4Test<T> {
test() {
int result = 0;
diff --git a/tests/language/map_literal_syntax_test.dart b/tests/language/map_literal_syntax_test.dart
index 464081a..1f537b4 100644
--- a/tests/language/map_literal_syntax_test.dart
+++ b/tests/language/map_literal_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class Foo {
var x;
var y;
diff --git a/tests/language/map_literal_test.dart b/tests/language/map_literal_test.dart
index 1f2b8d7..48fa0d8 100644
--- a/tests/language/map_literal_test.dart
+++ b/tests/language/map_literal_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests map literals.
class MapLiteralTest {
diff --git a/tests/language/map_test.dart b/tests/language/map_test.dart
index a055f76..347bb9a 100644
--- a/tests/language/map_test.dart
+++ b/tests/language/map_test.dart
@@ -4,6 +4,8 @@
// A subtest of the larger MapTest. Will eliminate once the full
// test is running.
+import "package:expect/expect.dart";
+
class MapTest {
static void testDeletedElement(Map map) {
diff --git a/tests/language/math_vm_test.dart b/tests/language/math_vm_test.dart
index 96e88bc..ad71888 100644
--- a/tests/language/math_vm_test.dart
+++ b/tests/language/math_vm_test.dart
@@ -6,6 +6,7 @@
library math_vm_test;
+import "package:expect/expect.dart";
import 'dart:math';
class FakeNumber {
diff --git a/tests/language/mega_load_test.dart b/tests/language/mega_load_test.dart
index 8c933f2..a5d4591 100644
--- a/tests/language/mega_load_test.dart
+++ b/tests/language/mega_load_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test megamorphic, but single target field load.
+import "package:expect/expect.dart";
+
class Base {
var f;
}
diff --git a/tests/language/megamorphic_no_such_method_test.dart b/tests/language/megamorphic_no_such_method_test.dart
index 56c3287..8d7976a 100644
--- a/tests/language/megamorphic_no_such_method_test.dart
+++ b/tests/language/megamorphic_no_such_method_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test program for correct optimizations related to types fo allocated lists.
+import "package:expect/expect.dart";
+
// Classes to induce polymorphism of degree 10.
class A0 {
test() => 0;
diff --git a/tests/language/metadata_syntax_test.dart b/tests/language/metadata_syntax_test.dart
index ed8d22f..dc3ff8c 100644
--- a/tests/language/metadata_syntax_test.dart
+++ b/tests/language/metadata_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that is is an error to use type arguments in metadata without
// parens.
diff --git a/tests/language/metadata_test.dart b/tests/language/metadata_test.dart
index fcd70b1..dc901c2 100644
--- a/tests/language/metadata_test.dart
+++ b/tests/language/metadata_test.dart
@@ -6,6 +6,7 @@
// test cases with illegal metadata annotations.
library metadata_test.dart;
+import "package:expect/expect.dart";
import "metadata_lib.dart" as Meta;
class Tag {
diff --git a/tests/language/method_binding_test.dart b/tests/language/method_binding_test.dart
index e540116..454d8f1 100644
--- a/tests/language/method_binding_test.dart
+++ b/tests/language/method_binding_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Bind a method to a variable that can be invoked as a function
class A {
diff --git a/tests/language/method_invocation_test.dart b/tests/language/method_invocation_test.dart
index 44c9da2..393d2a6 100644
--- a/tests/language/method_invocation_test.dart
+++ b/tests/language/method_invocation_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Testing method invocation.
// Currently testing only NoSuchMethodError.
diff --git a/tests/language/method_name_test.dart b/tests/language/method_name_test.dart
index b6e2acb..b0199cf 100644
--- a/tests/language/method_name_test.dart
+++ b/tests/language/method_name_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests that methods with names "get", "set" and "operator" don't
// cause fatal problems.
diff --git a/tests/language/method_override_test.dart b/tests/language/method_override_test.dart
index 514f7fc..b1a8b1d 100644
--- a/tests/language/method_override_test.dart
+++ b/tests/language/method_override_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Checks that a method with an instantiated return type can override a method
// with a generic return type.
diff --git a/tests/language/methods_as_constants2_test.dart b/tests/language/methods_as_constants2_test.dart
index b850a71..fa52f64 100644
--- a/tests/language/methods_as_constants2_test.dart
+++ b/tests/language/methods_as_constants2_test.dart
@@ -4,6 +4,8 @@
// Test that a function only used by compile-time constants is being
// generated.
+import "package:expect/expect.dart";
+
topLevelMethod() => 42;
class A {
diff --git a/tests/language/methods_as_constants_test.dart b/tests/language/methods_as_constants_test.dart
index b9aee07..98468e9 100644
--- a/tests/language/methods_as_constants_test.dart
+++ b/tests/language/methods_as_constants_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
topLevelMethod() => 't';
const topLevelFieldForTopLevelMethod = topLevelMethod;
diff --git a/tests/language/mint_arithmetic_test.dart b/tests/language/mint_arithmetic_test.dart
index 0e05d92..18b532a 100644
--- a/tests/language/mint_arithmetic_test.dart
+++ b/tests/language/mint_arithmetic_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test arithmetic on 64-bit integers.
test_and_1() {
diff --git a/tests/language/mint_compares_test.dart b/tests/language/mint_compares_test.dart
index fea302e..acbacab 100644
--- a/tests/language/mint_compares_test.dart
+++ b/tests/language/mint_compares_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test compares on 64-bit integers.
compareTest() {
diff --git a/tests/language/mixin_extends_field_test.dart b/tests/language/mixin_extends_field_test.dart
index eafc0e8..dce8fe5 100644
--- a/tests/language/mixin_extends_field_test.dart
+++ b/tests/language/mixin_extends_field_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S {
var foo = "S-foo";
}
diff --git a/tests/language/mixin_extends_is_test.dart b/tests/language/mixin_extends_is_test.dart
index 4f08849..dacdd3c 100644
--- a/tests/language/mixin_extends_is_test.dart
+++ b/tests/language/mixin_extends_is_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S { }
class M1 { }
class M2 { }
diff --git a/tests/language/mixin_extends_method_test.dart b/tests/language/mixin_extends_method_test.dart
index e9423e4..f80b16e 100644
--- a/tests/language/mixin_extends_method_test.dart
+++ b/tests/language/mixin_extends_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S {
foo() => "S-foo";
baz() => "S-baz";
diff --git a/tests/language/mixin_field_initializer_test.dart b/tests/language/mixin_field_initializer_test.dart
index c179684..f3d75c3 100644
--- a/tests/language/mixin_field_initializer_test.dart
+++ b/tests/language/mixin_field_initializer_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import 'package:expect/expect.dart';
+
class S {
var s1 = good_stuff();
static good_stuff() => "Speyburn";
diff --git a/tests/language/mixin_field_test.dart b/tests/language/mixin_field_test.dart
index 251aa50..99f68e4 100644
--- a/tests/language/mixin_field_test.dart
+++ b/tests/language/mixin_field_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S {
var foo = "S-foo";
}
diff --git a/tests/language/mixin_getter_regression_test.dart b/tests/language/mixin_getter_regression_test.dart
index 52603c6..f3a7bcd 100644
--- a/tests/language/mixin_getter_regression_test.dart
+++ b/tests/language/mixin_getter_regression_test.dart
@@ -5,6 +5,8 @@
// Regression test case for dart2js bug where the getter for y wasn't
// properly mixed in.
+import "package:expect/expect.dart";
+
class C {
int x;
int get y => x;
diff --git a/tests/language/mixin_illegal_static_access_test.dart b/tests/language/mixin_illegal_static_access_test.dart
index 46390c2..81b032b 100644
--- a/tests/language/mixin_illegal_static_access_test.dart
+++ b/tests/language/mixin_illegal_static_access_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S {
static foo() => 42;
}
diff --git a/tests/language/mixin_illegal_super_use_test.dart b/tests/language/mixin_illegal_super_use_test.dart
index 414b2f2..7f12e4d 100644
--- a/tests/language/mixin_illegal_super_use_test.dart
+++ b/tests/language/mixin_illegal_super_use_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class M {
}
diff --git a/tests/language/mixin_implements_test.dart b/tests/language/mixin_implements_test.dart
index 8df1d9e..3eaad79 100644
--- a/tests/language/mixin_implements_test.dart
+++ b/tests/language/mixin_implements_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
abstract class I0 {
foo();
}
diff --git a/tests/language/mixin_is_test.dart b/tests/language/mixin_is_test.dart
index 2d61ab9..7e8d080 100644
--- a/tests/language/mixin_is_test.dart
+++ b/tests/language/mixin_is_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S { }
class M1 { }
class M2 { }
diff --git a/tests/language/mixin_lib_extends_field_test.dart b/tests/language/mixin_lib_extends_field_test.dart
index b58c44a..5edafd3 100644
--- a/tests/language/mixin_lib_extends_field_test.dart
+++ b/tests/language/mixin_lib_extends_field_test.dart
@@ -4,6 +4,7 @@
library mixin_lib_extends_field_test;
+import 'package:expect/expect.dart';
import "mixin_lib_extends_field_lib.dart" as L;
class S {
diff --git a/tests/language/mixin_lib_extends_method_test.dart b/tests/language/mixin_lib_extends_method_test.dart
index b43e0e0..25ade93 100644
--- a/tests/language/mixin_lib_extends_method_test.dart
+++ b/tests/language/mixin_lib_extends_method_test.dart
@@ -4,6 +4,7 @@
library mixin_lib_extends_method_test;
+import "package:expect/expect.dart";
import "mixin_lib_extends_method_lib.dart" as L;
class S {
diff --git a/tests/language/mixin_method_test.dart b/tests/language/mixin_method_test.dart
index d5643f7..a7bd09b 100644
--- a/tests/language/mixin_method_test.dart
+++ b/tests/language/mixin_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S {
foo() => "S-foo";
baz() => "S-baz";
diff --git a/tests/language/mixin_mixin_test.dart b/tests/language/mixin_mixin_test.dart
index f6d2f35..cd234b4 100644
--- a/tests/language/mixin_mixin_test.dart
+++ b/tests/language/mixin_mixin_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class M1 { foo() => 42; }
typedef M2 = Object with M1;
diff --git a/tests/language/mixin_naming_test.dart b/tests/language/mixin_naming_test.dart
index b3b4a9c..7e2476b 100644
--- a/tests/language/mixin_naming_test.dart
+++ b/tests/language/mixin_naming_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S { }
class M1 { }
class M2 { }
diff --git a/tests/language/mixin_override_regression_test.dart b/tests/language/mixin_override_regression_test.dart
index bbc9b89..2470da3 100644
--- a/tests/language/mixin_override_regression_test.dart
+++ b/tests/language/mixin_override_regression_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class C0 {
int m1() => 5;
int m2() => m1();
diff --git a/tests/language/mixin_this_use_test.dart b/tests/language/mixin_this_use_test.dart
index 1619a76..7398391 100644
--- a/tests/language/mixin_this_use_test.dart
+++ b/tests/language/mixin_this_use_test.dart
@@ -5,6 +5,8 @@
// Test that [:this:] in a class A used as a mixin in class D knows it can be an
// instance of D.
+import "package:expect/expect.dart";
+
class A {
foo() => bar(); // Implicit use of [:this:]
bar() => 42;
diff --git a/tests/language/mixin_type_parameters_mixin_extends_test.dart b/tests/language/mixin_type_parameters_mixin_extends_test.dart
index 6db5188..72952ba 100644
--- a/tests/language/mixin_type_parameters_mixin_extends_test.dart
+++ b/tests/language/mixin_type_parameters_mixin_extends_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class M<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
diff --git a/tests/language/mixin_type_parameters_mixin_test.dart b/tests/language/mixin_type_parameters_mixin_test.dart
index fa9e49b..1e8df1d 100644
--- a/tests/language/mixin_type_parameters_mixin_test.dart
+++ b/tests/language/mixin_type_parameters_mixin_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class M<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
diff --git a/tests/language/mixin_type_parameters_super_extends_test.dart b/tests/language/mixin_type_parameters_super_extends_test.dart
index d05fd7a..0ad3fe6 100644
--- a/tests/language/mixin_type_parameters_super_extends_test.dart
+++ b/tests/language/mixin_type_parameters_super_extends_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
diff --git a/tests/language/mixin_type_parameters_super_test.dart b/tests/language/mixin_type_parameters_super_test.dart
index 5c4b660..0202219 100644
--- a/tests/language/mixin_type_parameters_super_test.dart
+++ b/tests/language/mixin_type_parameters_super_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class S<T> {
bool matches(o) {
bool isChecked = checkUsingIs(o);
diff --git a/tests/language/modulo_test.dart b/tests/language/modulo_test.dart
index 7fac3bc..8ac27c0 100644
--- a/tests/language/modulo_test.dart
+++ b/tests/language/modulo_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test optimization of modulo operator on Smi.
+import "package:expect/expect.dart";
+
main() {
for (int i = -3000; i < 3000; i++) {
diff --git a/tests/language/multi_assign_test.dart b/tests/language/multi_assign_test.dart
index 8dc8933..1697f3b 100644
--- a/tests/language/multi_assign_test.dart
+++ b/tests/language/multi_assign_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing multiple assignment.
+import "package:expect/expect.dart";
+
class MultiAssignTest {
static testMain() {
diff --git a/tests/language/multi_pass2_test.dart b/tests/language/multi_pass2_test.dart
index da1c7eb..4e67d98 100644
--- a/tests/language/multi_pass2_test.dart
+++ b/tests/language/multi_pass2_test.dart
@@ -5,6 +5,7 @@
// Same as MultiPassTest, except that the file order is reversed.
library MultiPass2Test.dart;
+import "package:expect/expect.dart";
part "multi_pass_a.dart";
part "multi_pass_b.dart";
diff --git a/tests/language/multi_pass_test.dart b/tests/language/multi_pass_test.dart
index 8ece81a..8a2fdd1 100644
--- a/tests/language/multi_pass_test.dart
+++ b/tests/language/multi_pass_test.dart
@@ -4,6 +4,7 @@
// Dart test for loading several dart files and resolving superclasses lazily.
library MultiPassTest.dart;
+import "package:expect/expect.dart";
part "multi_pass_a.dart";
part "multi_pass_b.dart";
diff --git a/tests/language/named_argument_in_const_creation_test.dart b/tests/language/named_argument_in_const_creation_test.dart
index 797525d..e7dbb5f 100644
--- a/tests/language/named_argument_in_const_creation_test.dart
+++ b/tests/language/named_argument_in_const_creation_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
final x;
final y;
diff --git a/tests/language/named_argument_test.dart b/tests/language/named_argument_test.dart
index a6a2d39..0514c2d 100644
--- a/tests/language/named_argument_test.dart
+++ b/tests/language/named_argument_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
var c1 = ({b, a}) => 'a: $a b: $b';
var c2 = ({a, b}) => 'a: $a b: $b';
diff --git a/tests/language/named_parameters2_test.dart b/tests/language/named_parameters2_test.dart
index e6c037d..22ae603 100644
--- a/tests/language/named_parameters2_test.dart
+++ b/tests/language/named_parameters2_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing named parameters.
// You may not provide the same parameter as both a positional and a named argument.
+import "package:expect/expect.dart";
+
int test(int a, [int b]) {
return a;
}
diff --git a/tests/language/named_parameters3_test.dart b/tests/language/named_parameters3_test.dart
index 13c679c..d738ad7 100644
--- a/tests/language/named_parameters3_test.dart
+++ b/tests/language/named_parameters3_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing named parameters.
// Specifying named argument for not existing named parameter is run time error.
+import "package:expect/expect.dart";
+
int test(int a, [int b]) {
return a;
}
diff --git a/tests/language/named_parameters4_test.dart b/tests/language/named_parameters4_test.dart
index ca41dec..2547364 100644
--- a/tests/language/named_parameters4_test.dart
+++ b/tests/language/named_parameters4_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing named parameters.
// Specifying named argument for not existing named parameter is run time error.
+import "package:expect/expect.dart";
+
// This test is very similar to NamedParameters3Test, but exersizes a
// different corner case in the frog compiler. frog wasn't detecting unused
// named arguments when no other arguments were expected. So, this test
diff --git a/tests/language/named_parameters_aggregated_test.dart b/tests/language/named_parameters_aggregated_test.dart
index 6de5407..4e61963 100644
--- a/tests/language/named_parameters_aggregated_test.dart
+++ b/tests/language/named_parameters_aggregated_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing named parameters.
+import "package:expect/expect.dart";
+
class TypeTester<T> {}
diff --git a/tests/language/named_parameters_named_count_test.dart b/tests/language/named_parameters_named_count_test.dart
index 711eee3..56434d8 100644
--- a/tests/language/named_parameters_named_count_test.dart
+++ b/tests/language/named_parameters_named_count_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for named parameter called 'count'.
diff --git a/tests/language/named_parameters_passing_false_test.dart b/tests/language/named_parameters_passing_false_test.dart
index f11d020..1866ff9 100644
--- a/tests/language/named_parameters_passing_false_test.dart
+++ b/tests/language/named_parameters_passing_false_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing named parameters with 'false' passed as an
// argument.
diff --git a/tests/language/named_parameters_passing_falsy_test.dart b/tests/language/named_parameters_passing_falsy_test.dart
index 696f329..faa1fce 100644
--- a/tests/language/named_parameters_passing_falsy_test.dart
+++ b/tests/language/named_parameters_passing_falsy_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing named parameters with various values that might
// be implemented as 'falsy' values in a JavaScript implementation.
diff --git a/tests/language/named_parameters_passing_null_test.dart b/tests/language/named_parameters_passing_null_test.dart
index 3f33a9e..aeb21cd 100644
--- a/tests/language/named_parameters_passing_null_test.dart
+++ b/tests/language/named_parameters_passing_null_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing named parameters with 'null' passed as an
// argument.
diff --git a/tests/language/named_parameters_passing_zero_test.dart b/tests/language/named_parameters_passing_zero_test.dart
index 1f6d896..42ea649 100644
--- a/tests/language/named_parameters_passing_zero_test.dart
+++ b/tests/language/named_parameters_passing_zero_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing named parameters with zero passed as an
// argument.
diff --git a/tests/language/named_parameters_test.dart b/tests/language/named_parameters_test.dart
index 04e939a..10e5f1a 100644
--- a/tests/language/named_parameters_test.dart
+++ b/tests/language/named_parameters_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing named parameters.
+import "package:expect/expect.dart";
+
class NamedParametersTest {
diff --git a/tests/language/named_parameters_type_test.dart b/tests/language/named_parameters_type_test.dart
index 33841fb..304cbed 100644
--- a/tests/language/named_parameters_type_test.dart
+++ b/tests/language/named_parameters_type_test.dart
@@ -5,6 +5,8 @@
//
// Dart test program for testing optional named parameters in type tests.
+import "package:expect/expect.dart";
+
class NamedParametersTypeTest {
static int testMain() {
int result = 0;
diff --git a/tests/language/named_parameters_with_conversions_test.dart b/tests/language/named_parameters_with_conversions_test.dart
index 4436383..cbf3888 100644
--- a/tests/language/named_parameters_with_conversions_test.dart
+++ b/tests/language/named_parameters_with_conversions_test.dart
@@ -5,6 +5,8 @@
// Test named arguments work as expected regardless of whether the function or
// method is called via function call syntax or method call syntax.
+import "package:expect/expect.dart";
+
Validate(tag, a, b) {
// tag encodes which parameters are passed in with values a: 111, b: 222.
diff --git a/tests/language/named_parameters_with_dollars_test.dart b/tests/language/named_parameters_with_dollars_test.dart
index e4f0f27..cc28cd6 100644
--- a/tests/language/named_parameters_with_dollars_test.dart
+++ b/tests/language/named_parameters_with_dollars_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test to stress Frog's named parameter scheme.
main() {
diff --git a/tests/language/named_parameters_with_object_property_names_test.dart b/tests/language/named_parameters_with_object_property_names_test.dart
index 2f6c03c..e291bc8 100644
--- a/tests/language/named_parameters_with_object_property_names_test.dart
+++ b/tests/language/named_parameters_with_object_property_names_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test for named parameter with the name of a JavaScript property found on
// 'Object'. For such a NAME, foo.NAME may exist in an empty map, i.e.
// 'toString' in {} --> true.
diff --git a/tests/language/namer2_test.dart b/tests/language/namer2_test.dart
index 1f911b82..81a7de4 100644
--- a/tests/language/namer2_test.dart
+++ b/tests/language/namer2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that user field names cannot clash with internal names of the
// dart2js compiler.
diff --git a/tests/language/namer_test.dart b/tests/language/namer_test.dart
index 67fa633..d9ad7d8 100644
--- a/tests/language/namer_test.dart
+++ b/tests/language/namer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for a bug in dart2js where global names could
// collide.
diff --git a/tests/language/naming2_test.dart b/tests/language/naming2_test.dart
index 934fa70..f9c0800 100644
--- a/tests/language/naming2_test.dart
+++ b/tests/language/naming2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var function;
A(function) : function = function;
diff --git a/tests/language/naming3_test.dart b/tests/language/naming3_test.dart
index 2d9dbf8..7299df1 100644
--- a/tests/language/naming3_test.dart
+++ b/tests/language/naming3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var __PROTO__ = 499;
var constructor = 1;
diff --git a/tests/language/naming_test.dart b/tests/language/naming_test.dart
index 1edfb9d..9130914 100644
--- a/tests/language/naming_test.dart
+++ b/tests/language/naming_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
A() { NamingTest.count++; }
foo(a, b) {
diff --git a/tests/language/native_test.dart b/tests/language/native_test.dart
index 93f435a..01d62d1 100644
--- a/tests/language/native_test.dart
+++ b/tests/language/native_test.dart
@@ -4,6 +4,8 @@
// Dart test program which shows how to write self verifying tests
// and how to print dart objects if needed.
+import "package:expect/expect.dart";
+
class Helper {
static int foo(int i) {
return i + 10;
diff --git a/tests/language/nested_comments_test.dart b/tests/language/nested_comments_test.dart
index 10bba58..48d07ba 100644
--- a/tests/language/nested_comments_test.dart
+++ b/tests/language/nested_comments_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing nested comments
+import "package:expect/expect.dart";
+
// /* nested comment */
/*// nested comment */
/*/* nested comment */*/
diff --git a/tests/language/nested_if_test.dart b/tests/language/nested_if_test.dart
index 34b486a..41c7d34 100644
--- a/tests/language/nested_if_test.dart
+++ b/tests/language/nested_if_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart2Js had problems with nested ifs inside loops.
+import "package:expect/expect.dart";
+
foo(x, a) {
/*---------------------------------------------*/
/*---------------------------------------------*/
diff --git a/tests/language/new_statement_test.dart b/tests/language/new_statement_test.dart
index 5e00f4d..fea8cb6 100644
--- a/tests/language/new_statement_test.dart
+++ b/tests/language/new_statement_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test a new statement by itself.
+import "package:expect/expect.dart";
+
class A {
int a;
int b;
diff --git a/tests/language/no_such_method2_test.dart b/tests/language/no_such_method2_test.dart
index f30ae45..bd0b6a8 100644
--- a/tests/language/no_such_method2_test.dart
+++ b/tests/language/no_such_method2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for https://code.google.com/p/dart/issues/detail?id=7697.
// dart2js used to optimize [noSuchMethod] based on the user-provided
// argument, and forget that the runtime might call it with its own
diff --git a/tests/language/no_such_method_test.dart b/tests/language/no_such_method_test.dart
index e23ca5b..5e154d2 100644
--- a/tests/language/no_such_method_test.dart
+++ b/tests/language/no_such_method_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing that NoSuchMethod is properly called.
+import "package:expect/expect.dart";
+
class GetName {
foo({a, b}) => "foo";
moo({b}) => "moo";
diff --git a/tests/language/non_const_constructor_without_body_test.dart b/tests/language/non_const_constructor_without_body_test.dart
index 7e8fdc2..13ef775 100644
--- a/tests/language/non_const_constructor_without_body_test.dart
+++ b/tests/language/non_const_constructor_without_body_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class NonConstConstructorWithoutBodyTest {
int x;
diff --git a/tests/language/non_dominating_loop_test.dart b/tests/language/non_dominating_loop_test.dart
index e924e01..ac16396 100644
--- a/tests/language/non_dominating_loop_test.dart
+++ b/tests/language/non_dominating_loop_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int calls = 0;
void callMeOnce() {
diff --git a/tests/language/null_access_error_test.dart b/tests/language/null_access_error_test.dart
index f36a9f3..cef7bce 100644
--- a/tests/language/null_access_error_test.dart
+++ b/tests/language/null_access_error_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class NullAccessTest {
static void testNullVariable() {
diff --git a/tests/language/null_is_test.dart b/tests/language/null_is_test.dart
index 8b49793..395d474 100644
--- a/tests/language/null_is_test.dart
+++ b/tests/language/null_is_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
Expect.isTrue(null is Object);
Expect.isFalse(null is int);
diff --git a/tests/language/null_method_test.dart b/tests/language/null_method_test.dart
index 97befa1..bf5b51f 100644
--- a/tests/language/null_method_test.dart
+++ b/tests/language/null_method_test.dart
@@ -5,6 +5,8 @@
// Regression test for dart2js that used to not compile null methods
// in the presence of typed selectors.
+import "package:expect/expect.dart";
+
class C {
foo(s) {
return s.hashCode;
diff --git a/tests/language/null_no_such_method_test.dart b/tests/language/null_no_such_method_test.dart
index adfab89..a9514cd 100644
--- a/tests/language/null_no_such_method_test.dart
+++ b/tests/language/null_no_such_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var array = [1];
main() {
diff --git a/tests/language/null_test.dart b/tests/language/null_test.dart
index e52a06d..6ce22ee 100644
--- a/tests/language/null_test.dart
+++ b/tests/language/null_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Second dart test program.
+import "package:expect/expect.dart";
+
class NullTest {
static int foo(var obj) {
Expect.equals(null, obj);
diff --git a/tests/language/null_to_string2_test.dart b/tests/language/null_to_string2_test.dart
index 2a087b9..a56e705 100644
--- a/tests/language/null_to_string2_test.dart
+++ b/tests/language/null_to_string2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test correct handling of NULL object in invocation and implicit closures.
+import "package:expect/expect.dart";
+
class A {}
A foo() => null;
diff --git a/tests/language/null_to_string_test.dart b/tests/language/null_to_string_test.dart
index 19eef3a..08bb56a 100644
--- a/tests/language/null_to_string_test.dart
+++ b/tests/language/null_to_string_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test correct handling of NULL object in invocation and implicit closures.
+import "package:expect/expect.dart";
+
main() {
var nullObj = null;
var x = nullObj.toString();
diff --git a/tests/language/number_constant_folding1_test.dart b/tests/language/number_constant_folding1_test.dart
index 1d48f7b..dfcba75 100644
--- a/tests/language/number_constant_folding1_test.dart
+++ b/tests/language/number_constant_folding1_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// On frogsh constant folded hex literals of large magnitude were truncated on
// constant folding - Issue 636 is 'fixed', remaining concerns at Issue 638.
diff --git a/tests/language/number_identity2_test.dart b/tests/language/number_identity2_test.dart
index 883049b..c10ce04 100644
--- a/tests/language/number_identity2_test.dart
+++ b/tests/language/number_identity2_test.dart
@@ -6,6 +6,8 @@
// Contains test that is failing on dart2js. Merge this test with
// 'number_identity_test.dart' once fixed.
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 1000; i++) testNumberIdentity();
}
diff --git a/tests/language/number_identity_test.dart b/tests/language/number_identity_test.dart
index 9f475e7..2173342 100644
--- a/tests/language/number_identity_test.dart
+++ b/tests/language/number_identity_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing params.
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 1000; i++) testNumberIdentity();
}
diff --git a/tests/language/number_syntax_test.dart b/tests/language/number_syntax_test.dart
index 7ec4e24..d06aeee 100644
--- a/tests/language/number_syntax_test.dart
+++ b/tests/language/number_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class NumberSyntaxTest {
static void testMain() {
diff --git a/tests/language/numbers_test.dart b/tests/language/numbers_test.dart
index 97301d8..2565910 100644
--- a/tests/language/numbers_test.dart
+++ b/tests/language/numbers_test.dart
@@ -4,6 +4,7 @@
// Test number types.
library NumbersTest.dart;
+import "package:expect/expect.dart";
class NumbersTest {
static double testMain() {
diff --git a/tests/language/operator2_test.dart b/tests/language/operator2_test.dart
index f6e48f3..66d0ba5 100644
--- a/tests/language/operator2_test.dart
+++ b/tests/language/operator2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Operator dart test program.
+import "package:expect/expect.dart";
+
class Helper {
int i;
Helper(int val) : i = val { }
diff --git a/tests/language/operator3_test.dart b/tests/language/operator3_test.dart
index e024c90..98e9571 100644
--- a/tests/language/operator3_test.dart
+++ b/tests/language/operator3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
operator -() => this;
toString() => "5";
diff --git a/tests/language/operator4_test.dart b/tests/language/operator4_test.dart
index b937d4f..e203a16 100644
--- a/tests/language/operator4_test.dart
+++ b/tests/language/operator4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
operator <(other) => 1;
}
diff --git a/tests/language/operator5_test.dart b/tests/language/operator5_test.dart
index 3afb2eb..8c2f800 100644
--- a/tests/language/operator5_test.dart
+++ b/tests/language/operator5_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
operator ==(other) => 1;
operator <(other) => null;
diff --git a/tests/language/operator6_test.dart b/tests/language/operator6_test.dart
index 69ae0b3..87fae7d 100644
--- a/tests/language/operator6_test.dart
+++ b/tests/language/operator6_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class OperatorTest {
static int i1, i2;
diff --git a/tests/language/operator_equals_test.dart b/tests/language/operator_equals_test.dart
index 1f0d720..0e2e5e4 100644
--- a/tests/language/operator_equals_test.dart
+++ b/tests/language/operator_equals_test.dart
@@ -5,6 +5,8 @@
// Regression test for dart2js that used to infer [:super == null:]
// always returns an int.
+import 'package:expect/expect.dart';
+
class A {
operator==(other) => 42;
}
diff --git a/tests/language/operator_index_evaluation_order_test.dart b/tests/language/operator_index_evaluation_order_test.dart
index 9f8182e..023d027 100644
--- a/tests/language/operator_index_evaluation_order_test.dart
+++ b/tests/language/operator_index_evaluation_order_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class B {
int value;
List trace;
diff --git a/tests/language/operator_negate_and_method_negate_test.dart b/tests/language/operator_negate_and_method_negate_test.dart
index 83a19e4..cc7c4a6 100644
--- a/tests/language/operator_negate_and_method_negate_test.dart
+++ b/tests/language/operator_negate_and_method_negate_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This checks that it is possible to have a method named negate as
// well as unary- operator.
diff --git a/tests/language/operator_test.dart b/tests/language/operator_test.dart
index b692400..bd240e1 100644
--- a/tests/language/operator_test.dart
+++ b/tests/language/operator_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class OperatorTest {
static int i1, i2;
diff --git a/tests/language/optimization_test.dart b/tests/language/optimization_test.dart
index c399754..0dbbcf5 100644
--- a/tests/language/optimization_test.dart
+++ b/tests/language/optimization_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test various optimizations and deoptimizations of optimizing compiler..
+import "package:expect/expect.dart";
+
addThem(a, b) {
return a + b;
}
diff --git a/tests/language/optimize_redundant_array_load_test.dart b/tests/language/optimize_redundant_array_load_test.dart
index ae4bb59..d490f31 100644
--- a/tests/language/optimize_redundant_array_load_test.dart
+++ b/tests/language/optimize_redundant_array_load_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test optimization of redundant array loads.
var A = [0,2,3];
diff --git a/tests/language/optimized_constant_array_string_access_test.dart b/tests/language/optimized_constant_array_string_access_test.dart
index 391d971..d8f6a80 100644
--- a/tests/language/optimized_constant_array_string_access_test.dart
+++ b/tests/language/optimized_constant_array_string_access_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test optimized constant string and constant array access.
int testConstantStringAndIndexCodeUnitAt() {
diff --git a/tests/language/optimized_hoisting_checked_mode_assert_test.dart b/tests/language/optimized_hoisting_checked_mode_assert_test.dart
index 2f67833..23e2654 100644
--- a/tests/language/optimized_hoisting_checked_mode_assert_test.dart
+++ b/tests/language/optimized_hoisting_checked_mode_assert_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test checked mode assertions inside loops.
int foo(x, n) {
diff --git a/tests/language/optimized_lists_test.dart b/tests/language/optimized_lists_test.dart
index cc3b862..a2406ae 100644
--- a/tests/language/optimized_lists_test.dart
+++ b/tests/language/optimized_lists_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test program for correct optimizations related to types fo allocated lists.
+import "package:expect/expect.dart";
+
main() {
// Trigger optimization of 'test' method.
for (int i = 0; i < 1000; i++) {
diff --git a/tests/language/optimized_setter_test.dart b/tests/language/optimized_setter_test.dart
index 1a87139..099be16 100644
--- a/tests/language/optimized_setter_test.dart
+++ b/tests/language/optimized_setter_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test various setter situations, testing special cases in optimizing compiler.
+import "package:expect/expect.dart";
+
class A {
int field = 0;
}
diff --git a/tests/language/optimized_string_charat_test.dart b/tests/language/optimized_string_charat_test.dart
index b11c672..5f2e6e4 100644
--- a/tests/language/optimized_string_charat_test.dart
+++ b/tests/language/optimized_string_charat_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test optimized [] on strings.
var a = "abc";
diff --git a/tests/language/optimized_string_charcodeat_test.dart b/tests/language/optimized_string_charcodeat_test.dart
index e4747f2..88a08de 100644
--- a/tests/language/optimized_string_charcodeat_test.dart
+++ b/tests/language/optimized_string_charcodeat_test.dart
@@ -4,6 +4,9 @@
// Test optimized CodeUnitAt and array access.
+import "package:expect/expect.dart";
+
+
String one_byte = "hest";
String two_byte = "høns";
diff --git a/tests/language/optional_named_parameters_test.dart b/tests/language/optional_named_parameters_test.dart
index c2a771c..70b770a 100644
--- a/tests/language/optional_named_parameters_test.dart
+++ b/tests/language/optional_named_parameters_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing optional named parameters.
+import "package:expect/expect.dart";
+
class OptionalNamedParametersTest {
diff --git a/tests/language/ordered_maps_test.dart b/tests/language/ordered_maps_test.dart
index e375877..1b845c9 100644
--- a/tests/language/ordered_maps_test.dart
+++ b/tests/language/ordered_maps_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests that map literals are ordered.
class OrderedMapsTest {
diff --git a/tests/language/overridden_no_such_method_test.dart b/tests/language/overridden_no_such_method_test.dart
index f3eb3df..3aa37be 100644
--- a/tests/language/overridden_no_such_method_test.dart
+++ b/tests/language/overridden_no_such_method_test.dart
@@ -4,6 +4,8 @@
// Dart test program testing overridden messageNotUnderstood.
library OverriddenNoSuchMethodTest.dart;
+
+import "package:expect/expect.dart";
part "overridden_no_such_method.dart";
main() {
diff --git a/tests/language/override_method_with_field_test.dart b/tests/language/override_method_with_field_test.dart
index f277baa..77bd565 100644
--- a/tests/language/override_method_with_field_test.dart
+++ b/tests/language/override_method_with_field_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test overriding a method with a field.
class Super {
diff --git a/tests/language/param2_test.dart b/tests/language/param2_test.dart
index fce72ba..375a2c5 100644
--- a/tests/language/param2_test.dart
+++ b/tests/language/param2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing function type parameters.
+import "package:expect/expect.dart";
+
class Param2Test {
diff --git a/tests/language/param_test.dart b/tests/language/param_test.dart
index 43abf50f..4b5c033 100644
--- a/tests/language/param_test.dart
+++ b/tests/language/param_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing params.
+import "package:expect/expect.dart";
+
class Helper {
static int foo(int i) {
var b;
diff --git a/tests/language/parameter_initializer2_test.dart b/tests/language/parameter_initializer2_test.dart
index 4f303c9..7897f93 100644
--- a/tests/language/parameter_initializer2_test.dart
+++ b/tests/language/parameter_initializer2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test Parameter Intializer.
diff --git a/tests/language/parameter_initializer6_negative_test.dart b/tests/language/parameter_initializer6_negative_test.dart
index 3c4e0337..40a2231 100644
--- a/tests/language/parameter_initializer6_negative_test.dart
+++ b/tests/language/parameter_initializer6_negative_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// It is a compile-time error if a named formal parameter begins with an '_'
class Foo {
diff --git a/tests/language/parameter_initializer_test.dart b/tests/language/parameter_initializer_test.dart
index d285581..23d1bc8 100644
--- a/tests/language/parameter_initializer_test.dart
+++ b/tests/language/parameter_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ParameterInitializerTest {
static testMain() {
diff --git a/tests/language/parameter_name_conflict_test.dart b/tests/language/parameter_name_conflict_test.dart
index 5c2465b..3f238da 100644
--- a/tests/language/parameter_name_conflict_test.dart
+++ b/tests/language/parameter_name_conflict_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(t0) {
var a = t0, b = baz(), c = bar();
if (t0 == 'foo') {
diff --git a/tests/language/parameter_types_specialization_test.dart b/tests/language/parameter_types_specialization_test.dart
index 110a714..532a7a7 100644
--- a/tests/language/parameter_types_specialization_test.dart
+++ b/tests/language/parameter_types_specialization_test.dart
@@ -4,6 +4,8 @@
// Test that we invalidate parameter type optimization in the presence
// of optional parameters.
+import "package:expect/expect.dart";
+
class A {
void foo(bool firstInvocation, [a = 42, b = 'foo']) {
if (firstInvocation) {
diff --git a/tests/language/parse_types_test.dart b/tests/language/parse_types_test.dart
index bc30665..665759d 100644
--- a/tests/language/parse_types_test.dart
+++ b/tests/language/parse_types_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing parsing of "standard" types.
+import "package:expect/expect.dart";
+
class ParseTypesTest {
static bool callBool1() {
return true;
diff --git a/tests/language/partial_min_test.dart b/tests/language/partial_min_test.dart
index f6c5e17..754549a 100644
--- a/tests/language/partial_min_test.dart
+++ b/tests/language/partial_min_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This test triggered an NPE in dart2js.
// The bug needed:
// - double usage of the same variable in one expression ("b != b").
diff --git a/tests/language/patch_test.dart b/tests/language/patch_test.dart
index cd2f17e..2815cbf 100644
--- a/tests/language/patch_test.dart
+++ b/tests/language/patch_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
patch() {
return 12;
}
diff --git a/tests/language/positional_parameters_type_test.dart b/tests/language/positional_parameters_type_test.dart
index 7a23761..db26b84 100644
--- a/tests/language/positional_parameters_type_test.dart
+++ b/tests/language/positional_parameters_type_test.dart
@@ -5,6 +5,8 @@
//
// Dart test program for testing optional positional parameters in type tests.
+import "package:expect/expect.dart";
+
class NamedParametersTypeTest {
static int testMain() {
int result = 0;
diff --git a/tests/language/positive_bit_operations_test.dart b/tests/language/positive_bit_operations_test.dart
index 86af1a1..9663db2 100644
--- a/tests/language/positive_bit_operations_test.dart
+++ b/tests/language/positive_bit_operations_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
constants() {
Expect.equals(0x80000000, 0x80000000 | 0);
Expect.equals(0x80000001, 0x80000000 | 1);
diff --git a/tests/language/prefix101_test.dart b/tests/language/prefix101_test.dart
index 834d754..b6e72b1 100644
--- a/tests/language/prefix101_test.dart
+++ b/tests/language/prefix101_test.dart
@@ -7,6 +7,7 @@
library Prefix101Test.dart;
+import "package:expect/expect.dart";
import "library10.dart" as lib101;
import "library11.dart" as lib101;
diff --git a/tests/language/prefix10_negative_test.dart b/tests/language/prefix10_negative_test.dart
index 1f97272..1f0ff83 100644
--- a/tests/language/prefix10_negative_test.dart
+++ b/tests/language/prefix10_negative_test.dart
@@ -6,6 +6,7 @@
// Type parameters can shadow a library prefix.
library Prefix10NegativeTest.dart;
+import "package:expect/expect.dart";
import "library10.dart" as T;
class P<T> {
diff --git a/tests/language/prefix10_test.dart b/tests/language/prefix10_test.dart
index b3c2c9d..d01aeee 100644
--- a/tests/language/prefix10_test.dart
+++ b/tests/language/prefix10_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library Prefix10Test.dart;
+import "package:expect/expect.dart";
import "library10.dart" as lib10;
import "library11.dart" as lib11;
diff --git a/tests/language/prefix11_test.dart b/tests/language/prefix11_test.dart
index 43f5c95..11fb620 100644
--- a/tests/language/prefix11_test.dart
+++ b/tests/language/prefix11_test.dart
@@ -4,6 +4,7 @@
//
library Prefix11Test.dart;
+import "package:expect/expect.dart";
import "library10.dart";
import "library11.dart" as lib11;
diff --git a/tests/language/prefix12_test.dart b/tests/language/prefix12_test.dart
index 1fb4cb3..e2c90b3 100644
--- a/tests/language/prefix12_test.dart
+++ b/tests/language/prefix12_test.dart
@@ -4,6 +4,7 @@
//
library Prefix12Test.dart;
+import "package:expect/expect.dart";
import "library11.dart" as lib11;
class Prefix12Test {
diff --git a/tests/language/prefix14_test.dart b/tests/language/prefix14_test.dart
index 4d66818..a7cec0a 100644
--- a/tests/language/prefix14_test.dart
+++ b/tests/language/prefix14_test.dart
@@ -5,6 +5,7 @@
// Use qualified symbols at various places.
library Prefix14Test.dart;
+import "package:expect/expect.dart";
import "library12.dart" as lib12;
typedef lib12.Library12 myFunc(lib12.Library12 param);
diff --git a/tests/language/prefix15_test.dart b/tests/language/prefix15_test.dart
index 09f72ae..fe86fc4 100644
--- a/tests/language/prefix15_test.dart
+++ b/tests/language/prefix15_test.dart
@@ -5,6 +5,7 @@
// Use qualified symbols with generics at various places.
library Prefix15Test.dart;
+import "package:expect/expect.dart";
import "library12.dart" as lib12;
typedef T myFunc<T>(T param);
diff --git a/tests/language/prefix16_test.dart b/tests/language/prefix16_test.dart
index 91449f4..4fca6b0 100644
--- a/tests/language/prefix16_test.dart
+++ b/tests/language/prefix16_test.dart
@@ -9,6 +9,7 @@
// In production, no assignment type checks are performed.
library Prefix16NegativeTest.dart;
+import "package:expect/expect.dart";
import "library12.dart" as lib12;
typedef lib12.Library13 myFunc(lib12.Library13 param);
diff --git a/tests/language/prefix21_test.dart b/tests/language/prefix21_test.dart
index 26e9c34..2c1e347 100644
--- a/tests/language/prefix21_test.dart
+++ b/tests/language/prefix21_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library Prefix21;
+import "package:expect/expect.dart";
import "prefix21_good_lib.dart" as good;
import "prefix21_bad_lib.dart" as bad;
diff --git a/tests/language/prefix4_negative_test.dart b/tests/language/prefix4_negative_test.dart
index c11f2f3..0b49e0d 100644
--- a/tests/language/prefix4_negative_test.dart
+++ b/tests/language/prefix4_negative_test.dart
@@ -4,6 +4,7 @@
//
library Prefix4NegativeTest.dart;
+import "package:expect/expect.dart";
import "library10.dart";
class Prefix4NegativeTest {
diff --git a/tests/language/prefix5_negative_test.dart b/tests/language/prefix5_negative_test.dart
index ba15fc0..ae76bd9 100644
--- a/tests/language/prefix5_negative_test.dart
+++ b/tests/language/prefix5_negative_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library Prefix5NegativeTest.dart;
+import "package:expect/expect.dart";
import "library10.dart";
class Prefix5NegativeTest {
diff --git a/tests/language/prefix8_negative_test.dart b/tests/language/prefix8_negative_test.dart
index 93e3477..5878046 100644
--- a/tests/language/prefix8_negative_test.dart
+++ b/tests/language/prefix8_negative_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
+
// Local variables can shadow class names and hence should result in an
// error.
diff --git a/tests/language/prefix9_negative_test.dart b/tests/language/prefix9_negative_test.dart
index 1d8d918..51df506 100644
--- a/tests/language/prefix9_negative_test.dart
+++ b/tests/language/prefix9_negative_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
+
// Local variables can shadow type parameters and hence should result in an
// error.
diff --git a/tests/language/prefix_new_test.dart b/tests/language/prefix_new_test.dart
index 91c8103..8271082 100644
--- a/tests/language/prefix_new_test.dart
+++ b/tests/language/prefix_new_test.dart
@@ -4,6 +4,7 @@
library PrefixTest;
+import "package:expect/expect.dart";
import "prefix_test1.dart";
diff --git a/tests/language/prefix_test.dart b/tests/language/prefix_test.dart
index 5a63efc..ec3208e 100644
--- a/tests/language/prefix_test.dart
+++ b/tests/language/prefix_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library PrefixTest.dart;
+import "package:expect/expect.dart";
import "prefix_test1.dart";
class PrefixTest {
diff --git a/tests/language/private3_test.dart b/tests/language/private3_test.dart
index 23527d0..655db6f 100644
--- a/tests/language/private3_test.dart
+++ b/tests/language/private3_test.dart
@@ -4,6 +4,7 @@
// Dart test for testing access to private fields.
library Private3Test.dart;
+import "package:expect/expect.dart";
import "private_lib";
part "private_main.dart";
diff --git a/tests/language/private4_test.dart b/tests/language/private4_test.dart
index 226eba3..3f64b2f 100644
--- a/tests/language/private4_test.dart
+++ b/tests/language/private4_test.dart
@@ -6,6 +6,7 @@
library private4_test;
+import "package:expect/expect.dart";
import 'other_library.dart';
main() {
diff --git a/tests/language/private_mixin2_test.dart b/tests/language/private_mixin2_test.dart
index f01a2c9..0bc0645 100644
--- a/tests/language/private_mixin2_test.dart
+++ b/tests/language/private_mixin2_test.dart
@@ -6,6 +6,7 @@
library private_mixin2;
+import 'package:expect/expect.dart';
import 'private_other_mixin2.lib';
void main() {
diff --git a/tests/language/private_selector_test.dart b/tests/language/private_selector_test.dart
index 53dca839..5d00c94 100644
--- a/tests/language/private_selector_test.dart
+++ b/tests/language/private_selector_test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library private_selector_test;
-
+import "package:expect/expect.dart";
import 'private_selector_lib.dart';
class B extends A {
diff --git a/tests/language/private_test.dart b/tests/language/private_test.dart
index 87e735e..161cb65 100644
--- a/tests/language/private_test.dart
+++ b/tests/language/private_test.dart
@@ -5,6 +5,8 @@
// Dart test for testing access to private fields.
library PrivateTest.dart;
+
+import "package:expect/expect.dart";
import "private_other.lib";
part "private1.dart";
part "private2.dart";
diff --git a/tests/language/propagated_argument_type_check_test.dart b/tests/language/propagated_argument_type_check_test.dart
index f4bb713..d6923f3 100644
--- a/tests/language/propagated_argument_type_check_test.dart
+++ b/tests/language/propagated_argument_type_check_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
Expect.equals("str", foo("str"));
}
diff --git a/tests/language/property_field_override_test.dart b/tests/language/property_field_override_test.dart
index 50f64cb9..a1dc8ed 100644
--- a/tests/language/property_field_override_test.dart
+++ b/tests/language/property_field_override_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test overriding a getter property with a field.
class A {
int get v; // Abstract.
diff --git a/tests/language/pseudo_kw_test.dart b/tests/language/pseudo_kw_test.dart
index 2c9614d..0e55cc1 100644
--- a/tests/language/pseudo_kw_test.dart
+++ b/tests/language/pseudo_kw_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that we can use pseudo keywords as names in function level code.
+import "package:expect/expect.dart";
+
class PseudoKWTest {
static testMain() {
diff --git a/tests/language/range_analysis_test.dart b/tests/language/range_analysis_test.dart
index a8b0203..4be7414 100644
--- a/tests/language/range_analysis_test.dart
+++ b/tests/language/range_analysis_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
+import "package:expect/expect.dart";
+
// Check that range analysis does not enter infinite loop trying to propagate
// ranges through dependant phis.
bar() {
diff --git a/tests/language/raw_string_test.dart b/tests/language/raw_string_test.dart
index 9cdb383..ee5365b 100644
--- a/tests/language/raw_string_test.dart
+++ b/tests/language/raw_string_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class RawStringTest {
static testMain() {
Expect.equals("abcd", r"abcd");
diff --git a/tests/language/recursive_loop_phis_test.dart b/tests/language/recursive_loop_phis_test.dart
index 430fb8d..36fa4f2 100644
--- a/tests/language/recursive_loop_phis_test.dart
+++ b/tests/language/recursive_loop_phis_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This program tripped dart2js.
foo(bool b) {
diff --git a/tests/language/reexport_core_test.dart b/tests/language/reexport_core_test.dart
index cbdc15b..23964c4 100644
--- a/tests/language/reexport_core_test.dart
+++ b/tests/language/reexport_core_test.dart
@@ -11,6 +11,7 @@
library reexport_core_test;
+import "package:expect/expect.dart";
import 'reexport_core_helper.dart' as core;
void main() {
diff --git a/tests/language/reg_exp2_test.dart b/tests/language/reg_exp2_test.dart
index 489d917..7859fe5 100644
--- a/tests/language/reg_exp2_test.dart
+++ b/tests/language/reg_exp2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
+import "package:expect/expect.dart";
+
class RegExp2Test {
static String findImageTag_(String text, String extensions) {
final re = new RegExp('src="(http://\\S+\\.(${extensions}))"');
diff --git a/tests/language/reg_exp3_test.dart b/tests/language/reg_exp3_test.dart
index b0410ed..6c2d68b 100644
--- a/tests/language/reg_exp3_test.dart
+++ b/tests/language/reg_exp3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
+import "package:expect/expect.dart";
+
class RegExp3Test {
static testMain() {
var i = 2000;
diff --git a/tests/language/reg_exp_test.dart b/tests/language/reg_exp_test.dart
index aa3fe39..631cfda 100644
--- a/tests/language/reg_exp_test.dart
+++ b/tests/language/reg_exp_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing regular expressions in Dart.
+import "package:expect/expect.dart";
+
class RegExpTest {
static test1() {
RegExp exp = new RegExp("(\\w+)");
diff --git a/tests/language/resolution_test.dart b/tests/language/resolution_test.dart
index aed286b..e9c1dc7 100644
--- a/tests/language/resolution_test.dart
+++ b/tests/language/resolution_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int get foo => 499;
class CompileError {
diff --git a/tests/language/resolve_test.dart b/tests/language/resolve_test.dart
index 5276158..4c0e319 100644
--- a/tests/language/resolve_test.dart
+++ b/tests/language/resolve_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing resolving of dynamic and static calls.
+import "package:expect/expect.dart";
+
class A {
static staticCall() { return 4; }
dynamicCall() { return 5; }
diff --git a/tests/language/rethrow_test.dart b/tests/language/rethrow_test.dart
index 60c055c..7c3bf04 100644
--- a/tests/language/rethrow_test.dart
+++ b/tests/language/rethrow_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException {
const MyException();
}
diff --git a/tests/language/return_in_loop_test.dart b/tests/language/return_in_loop_test.dart
index a960ba6..b4393b2 100644
--- a/tests/language/return_in_loop_test.dart
+++ b/tests/language/return_in_loop_test.dart
@@ -4,6 +4,8 @@
// Test for a dart2js bug where the live environment was not computed
// right.
+import "package:expect/expect.dart";
+
class A {
foo() {
var x = 0;
diff --git a/tests/language/return_this_type_test.dart b/tests/language/return_this_type_test.dart
index b97e382..d7ad739 100644
--- a/tests/language/return_this_type_test.dart
+++ b/tests/language/return_this_type_test.dart
@@ -4,6 +4,8 @@
// Make sure the engine does not infer the wrong type for [:A.foo:].
+import "package:expect/expect.dart";
+
class A {
foo() => this;
}
diff --git a/tests/language/return_type_test.dart b/tests/language/return_type_test.dart
index 462282d..a2137bb 100644
--- a/tests/language/return_type_test.dart
+++ b/tests/language/return_type_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
isCheckedMode() {
try {
var i = 1;
diff --git a/tests/language/runtime_type_test.dart b/tests/language/runtime_type_test.dart
index 1a3f1c8..03c4576 100644
--- a/tests/language/runtime_type_test.dart
+++ b/tests/language/runtime_type_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
get className => runtimeType;
}
diff --git a/tests/language/savannah_test.dart b/tests/language/savannah_test.dart
index fea178e..449f2c2 100644
--- a/tests/language/savannah_test.dart
+++ b/tests/language/savannah_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test using an identity hash.
+import "package:expect/expect.dart";
+
abstract class BigGame {
String get name;
}
diff --git a/tests/language/scope_variable_test.dart b/tests/language/scope_variable_test.dart
index 86716d0..d3bca7c 100644
--- a/tests/language/scope_variable_test.dart
+++ b/tests/language/scope_variable_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class ScopeVariableTest {
static void testSimpleScope() {
diff --git a/tests/language/scoped_variables_try_catch_test.dart b/tests/language/scoped_variables_try_catch_test.dart
index 137cf03..575dbc5 100644
--- a/tests/language/scoped_variables_try_catch_test.dart
+++ b/tests/language/scoped_variables_try_catch_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that try/catch does not shadow a variable at runtime.
main() {
diff --git a/tests/language/second_test.dart b/tests/language/second_test.dart
index a60941d..5ceb940 100644
--- a/tests/language/second_test.dart
+++ b/tests/language/second_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Second dart test program.
+import "package:expect/expect.dart";
+
class Helper {
static empty() { }
static int foo() { return 42; }
diff --git a/tests/language/setter0_test.dart b/tests/language/setter0_test.dart
index e14c651..8eebd0d 100644
--- a/tests/language/setter0_test.dart
+++ b/tests/language/setter0_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing setting/getting of fields when
// only getter/setter methods are specified.
+import "package:expect/expect.dart";
+
class First {
First(int val) : a_ = val { }
int a_;
diff --git a/tests/language/setter1_test.dart b/tests/language/setter1_test.dart
index 270351c..5f8b4a4 100644
--- a/tests/language/setter1_test.dart
+++ b/tests/language/setter1_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing setting/getting of fields when
// only getter/setter methods are specified.
+import "package:expect/expect.dart";
+
class First {
First(int val) : a_ = val { }
diff --git a/tests/language/setter2_test.dart b/tests/language/setter2_test.dart
index bdfc8a6..e6d0c62 100644
--- a/tests/language/setter2_test.dart
+++ b/tests/language/setter2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing use of 'this' in an instance method.
+import "package:expect/expect.dart";
+
class Nested {
Nested(int val) : a = val { }
int a;
diff --git a/tests/language/setter_no_getter_call_test.dart b/tests/language/setter_no_getter_call_test.dart
index c7b467b..b789d60 100644
--- a/tests/language/setter_no_getter_call_test.dart
+++ b/tests/language/setter_no_getter_call_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
var topLevelClosure;
/* /// 01: runtime error
diff --git a/tests/language/setter_no_getter_test.dart b/tests/language/setter_no_getter_test.dart
index f504a30..661b753 100644
--- a/tests/language/setter_no_getter_test.dart
+++ b/tests/language/setter_no_getter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
/* /// 01: runtime error
get topLevel => 42;
*/ /// 01: continued
diff --git a/tests/language/side_effect_throw_test.dart b/tests/language/side_effect_throw_test.dart
index 82c9cdd..484b762 100644
--- a/tests/language/side_effect_throw_test.dart
+++ b/tests/language/side_effect_throw_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class B {
static var x;
operator <<(other) {
diff --git a/tests/language/skip_expression_test.dart b/tests/language/skip_expression_test.dart
index bbadada..ad9d685 100644
--- a/tests/language/skip_expression_test.dart
+++ b/tests/language/skip_expression_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class OneArg<A> {
OneArg<A> get foo => new OneArg<A>();
OneArg<A> get bar {
diff --git a/tests/language/stack_overflow_stacktrace_test.dart b/tests/language/stack_overflow_stacktrace_test.dart
index 3bef1d6..8e85037 100644
--- a/tests/language/stack_overflow_stacktrace_test.dart
+++ b/tests/language/stack_overflow_stacktrace_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart program testing stack overflow.
+import "package:expect/expect.dart";
+
class StackOverflowTest {
static void curseTheRecurse(a, b, c) {
diff --git a/tests/language/stack_overflow_test.dart b/tests/language/stack_overflow_test.dart
index a8e400f..fa3bd7e 100644
--- a/tests/language/stack_overflow_test.dart
+++ b/tests/language/stack_overflow_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart program testing stack overflow.
+import "package:expect/expect.dart";
+
class StackOverflowTest {
static void curseTheRecurse(a, b, c) {
diff --git a/tests/language/stack_trace_test.dart b/tests/language/stack_trace_test.dart
index 87c5815..665313f 100644
--- a/tests/language/stack_trace_test.dart
+++ b/tests/language/stack_trace_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException {
const MyException(String message) : message_ = message;
final String message_;
diff --git a/tests/language/stacktrace_test.dart b/tests/language/stacktrace_test.dart
index 98e644e..e39f151 100644
--- a/tests/language/stacktrace_test.dart
+++ b/tests/language/stacktrace_test.dart
@@ -4,6 +4,9 @@
// BSD-style license that can be found in the LICENSE file.
// Test that a stack trace is properly terminated (issue 8850).
+
+import "package:expect/expect.dart";
+
void main() {
var ex = new Exception("fail");
try {
diff --git a/tests/language/state_mangling2_test.dart b/tests/language/state_mangling2_test.dart
index 637df3e..9467d79 100644
--- a/tests/language/state_mangling2_test.dart
+++ b/tests/language/state_mangling2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(state) {
if (state == null) return 0;
var sum = 0;
diff --git a/tests/language/state_mangling3_test.dart b/tests/language/state_mangling3_test.dart
index 195a2dd..05e3c50 100644
--- a/tests/language/state_mangling3_test.dart
+++ b/tests/language/state_mangling3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(state0) {
if (state0 == null) return 0;
var sum = 0;
diff --git a/tests/language/state_mangling4_test.dart b/tests/language/state_mangling4_test.dart
index b6aab91..58c18d1 100644
--- a/tests/language/state_mangling4_test.dart
+++ b/tests/language/state_mangling4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(env1) {
if (env1 == null) return 0;
var env0 = 0;
diff --git a/tests/language/state_mangling_test.dart b/tests/language/state_mangling_test.dart
index 02df690..84d697b 100644
--- a/tests/language/state_mangling_test.dart
+++ b/tests/language/state_mangling_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo(state) {
if (state == null) return 0;
var sum = 0;
diff --git a/tests/language/statement_test.dart b/tests/language/statement_test.dart
index 17d611b..ca11da9 100644
--- a/tests/language/statement_test.dart
+++ b/tests/language/statement_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests all statement types. Not an exhaustive test of all statement semantics.
class StatementTest {
diff --git a/tests/language/static_const_field_test.dart b/tests/language/static_const_field_test.dart
index 510f08c..0d2a188 100644
--- a/tests/language/static_const_field_test.dart
+++ b/tests/language/static_const_field_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing static const fields.
+import "package:expect/expect.dart";
+
abstract class Spain {
static const AG = "Antoni Gaudi";
static const SD = "Salvador Dali";
diff --git a/tests/language/static_field_test.dart b/tests/language/static_field_test.dart
index b7018fa..3261aed 100644
--- a/tests/language/static_field_test.dart
+++ b/tests/language/static_field_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing setting/getting/initializing static fields.
+import "package:expect/expect.dart";
+
class First {
First() {}
static var a;
diff --git a/tests/language/static_implicit_closure_test.dart b/tests/language/static_implicit_closure_test.dart
index 5835a26..b73050e 100644
--- a/tests/language/static_implicit_closure_test.dart
+++ b/tests/language/static_implicit_closure_test.dart
@@ -5,6 +5,8 @@
// VMOptions=
// VMOptions=--use_slow_path
+import "package:expect/expect.dart";
+
class First {
First() {}
static int get a {
diff --git a/tests/language/static_initializer_type_error_test.dart b/tests/language/static_initializer_type_error_test.dart
index 3d9e1af..d8f668a 100644
--- a/tests/language/static_initializer_type_error_test.dart
+++ b/tests/language/static_initializer_type_error_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int x = "milou";
bool inCheckedMode = false;
diff --git a/tests/language/static_inline_test.dart b/tests/language/static_inline_test.dart
index 5163b3d..cad3bf6 100644
--- a/tests/language/static_inline_test.dart
+++ b/tests/language/static_inline_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test inlining of assignments in parameter passing. If [StringScanner.charAt]
// is inlined, the argument expresion [: ++byteOffset :] should not be
// duplicated.
diff --git a/tests/language/static_postfix_operator_test.dart b/tests/language/static_postfix_operator_test.dart
index f55eda1..f8c26cd 100644
--- a/tests/language/static_postfix_operator_test.dart
+++ b/tests/language/static_postfix_operator_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int a = 0;
int b = 0;
diff --git a/tests/language/strict_equal_test.dart b/tests/language/strict_equal_test.dart
index 1cd00a9..7a31d93 100644
--- a/tests/language/strict_equal_test.dart
+++ b/tests/language/strict_equal_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 6000; i++) {
diff --git a/tests/language/string_escapes_test.dart b/tests/language/string_escapes_test.dart
index 6e80214..3261363 100644
--- a/tests/language/string_escapes_test.dart
+++ b/tests/language/string_escapes_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class StringEscapesTest {
static testMain() {
diff --git a/tests/language/string_interpolate2_test.dart b/tests/language/string_interpolate2_test.dart
index fe4e6a8..6cf88a97 100644
--- a/tests/language/string_interpolate2_test.dart
+++ b/tests/language/string_interpolate2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing string interpolation of expressions.
+import "package:expect/expect.dart";
+
class StringInterpolate2Test {
diff --git a/tests/language/string_interpolate_null_test.dart b/tests/language/string_interpolate_null_test.dart
index c8aff4a..a06427a 100644
--- a/tests/language/string_interpolate_null_test.dart
+++ b/tests/language/string_interpolate_null_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing NPE within string interpolation.
+import "package:expect/expect.dart";
+
class A {
A(String this.name) {}
String name;
diff --git a/tests/language/string_interpolate_test.dart b/tests/language/string_interpolate_test.dart
index f8960c9..ae9b0f0 100644
--- a/tests/language/string_interpolate_test.dart
+++ b/tests/language/string_interpolate_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing string interpolation.
+import "package:expect/expect.dart";
+
class WhatchamaCallIt {
WhatchamaCallIt() { }
diff --git a/tests/language/string_interpolation7_test.dart b/tests/language/string_interpolation7_test.dart
index a750804..6f558d4 100644
--- a/tests/language/string_interpolation7_test.dart
+++ b/tests/language/string_interpolation7_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program testing string interpolation with toString on custom
// classes and on null.
diff --git a/tests/language/string_interpolation8_test.dart b/tests/language/string_interpolation8_test.dart
index 8999daf..a3c09bc 100644
--- a/tests/language/string_interpolation8_test.dart
+++ b/tests/language/string_interpolation8_test.dart
@@ -4,6 +4,8 @@
//
// Allow assignment of string interpolation to a static const field
+import "package:expect/expect.dart";
+
class A {
static const x = 1;
static const y = "Two is greater than ${x}";
diff --git a/tests/language/string_interpolation_test.dart b/tests/language/string_interpolation_test.dart
index ed8b796..5a4f897 100644
--- a/tests/language/string_interpolation_test.dart
+++ b/tests/language/string_interpolation_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Tests for string interpolation
class StringInterpolationTest {
diff --git a/tests/language/string_intrinsics_test.dart b/tests/language/string_intrinsics_test.dart
index de3e3f0..d90ff7a 100644
--- a/tests/language/string_intrinsics_test.dart
+++ b/tests/language/string_intrinsics_test.dart
@@ -4,6 +4,8 @@
// Replace with shared test once interface issues clarified.
// Test various String intrinsics
+import "package:expect/expect.dart";
+
main() {
var oneByte = "Hello world";
var empty = "";
diff --git a/tests/language/string_join_test.dart b/tests/language/string_join_test.dart
index c98b79fa..eb576d8 100644
--- a/tests/language/string_join_test.dart
+++ b/tests/language/string_join_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Regression test ensuring that only ObjectArrays are handed to the VM code.
+import "package:expect/expect.dart";
+
class StringJoinTest {
static testMain() {
List<String> ga = new List<String>();
diff --git a/tests/language/string_supertype_checked_test.dart b/tests/language/string_supertype_checked_test.dart
index 171e31a..75a2a6b 100644
--- a/tests/language/string_supertype_checked_test.dart
+++ b/tests/language/string_supertype_checked_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// This tests a bug in dart2js which caused the compiler to emit bad
// type assertions for supertypes of String.
diff --git a/tests/language/string_test.dart b/tests/language/string_test.dart
index bbeb91c..70e77cf 100644
--- a/tests/language/string_test.dart
+++ b/tests/language/string_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Replace with shared test once interface issues clarified.
+import "package:expect/expect.dart";
+
class StringTest {
static testMain() {
diff --git a/tests/language/sub/sub.dart b/tests/language/sub/sub.dart
index 3e9691f..d7f2d20 100644
--- a/tests/language/sub/sub.dart
+++ b/tests/language/sub/sub.dart
@@ -1,5 +1,6 @@
library sub;
import '../cyclic_import_test.dart';
+import 'package:expect/expect.dart';
subMain() {
Expect.equals(42, value);
diff --git a/tests/language/super_all_named_constructor_test.dart b/tests/language/super_all_named_constructor_test.dart
index d33e4c9..37b15d7 100644
--- a/tests/language/super_all_named_constructor_test.dart
+++ b/tests/language/super_all_named_constructor_test.dart
@@ -4,6 +4,8 @@
// Dart test for testing implicit invocation of super constructor with all
// named parameters.
+import "package:expect/expect.dart";
+
var res = 0;
class A {
diff --git a/tests/language/super_assign_test.dart b/tests/language/super_assign_test.dart
index 84f8146..39a42d2 100644
--- a/tests/language/super_assign_test.dart
+++ b/tests/language/super_assign_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int x;
}
diff --git a/tests/language/super_call3_test.dart b/tests/language/super_call3_test.dart
index 178f4f8..81b19c1 100644
--- a/tests/language/super_call3_test.dart
+++ b/tests/language/super_call3_test.dart
@@ -4,6 +4,8 @@
// Dart test for testing implicit super calls with bad arguments or no default
// constructor in super class.
+import "package:expect/expect.dart";
+
class A {
A(
this.x /// 01: compile-time error
diff --git a/tests/language/super_call4_test.dart b/tests/language/super_call4_test.dart
index 0093bda..4d68a19 100644
--- a/tests/language/super_call4_test.dart
+++ b/tests/language/super_call4_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Checks that noSuchMethod is resolved in the super class and not in the
// current class.
diff --git a/tests/language/super_call_test.dart b/tests/language/super_call_test.dart
index 1f56c1c..57e1707 100644
--- a/tests/language/super_call_test.dart
+++ b/tests/language/super_call_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing super calls
+import "package:expect/expect.dart";
+
class A {
A() : field = 0 {}
int field;
diff --git a/tests/language/super_closure_test.dart b/tests/language/super_closure_test.dart
index c7ba932..ad159ce 100644
--- a/tests/language/super_closure_test.dart
+++ b/tests/language/super_closure_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing access to super from closure.
class Super {
diff --git a/tests/language/super_field_access_test.dart b/tests/language/super_field_access_test.dart
index ff87b19..38129e8 100644
--- a/tests/language/super_field_access_test.dart
+++ b/tests/language/super_field_access_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
int foo;
A(this.foo);
diff --git a/tests/language/super_field_test.dart b/tests/language/super_field_test.dart
index 7245d4c..5d51cb2 100644
--- a/tests/language/super_field_test.dart
+++ b/tests/language/super_field_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing super field access.
+import "package:expect/expect.dart";
+
class A {
A() {
diff --git a/tests/language/super_first_constructor_test.dart b/tests/language/super_first_constructor_test.dart
index 5954b59..e6cdee1 100644
--- a/tests/language/super_first_constructor_test.dart
+++ b/tests/language/super_first_constructor_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that the constructor body of a superclass is invoked.
class Super {
diff --git a/tests/language/super_getter_setter_test.dart b/tests/language/super_getter_setter_test.dart
index 80ac380..ea923e8 100644
--- a/tests/language/super_getter_setter_test.dart
+++ b/tests/language/super_getter_setter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A {
var missingSetterField;
var missingGetterField;
diff --git a/tests/language/super_implicit_closure_test.dart b/tests/language/super_implicit_closure_test.dart
index b25bf04..584d795 100644
--- a/tests/language/super_implicit_closure_test.dart
+++ b/tests/language/super_implicit_closure_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing invocation of implicit closures.
+import "package:expect/expect.dart";
+
class BaseClass {
BaseClass(this._i) {}
int foo() { return _i; }
diff --git a/tests/language/super_operator_index2_test.dart b/tests/language/super_operator_index2_test.dart
index 47cf16d..29ff893 100644
--- a/tests/language/super_operator_index2_test.dart
+++ b/tests/language/super_operator_index2_test.dart
@@ -4,6 +4,8 @@
// Test for super indexing operations.
+import "package:expect/expect.dart";
+
class A {
var map = new Map();
operator[]=(a, b) { map[a] = b; }
diff --git a/tests/language/super_operator_index3_test.dart b/tests/language/super_operator_index3_test.dart
index f456ba7..405bfc1 100644
--- a/tests/language/super_operator_index3_test.dart
+++ b/tests/language/super_operator_index3_test.dart
@@ -4,6 +4,8 @@
// Test for operator[]= resolved in super class.
+import "package:expect/expect.dart";
+
class A {
var indexField = new List(2);
operator[]=(index, value) { indexField[index] = value; }
diff --git a/tests/language/super_operator_index4_test.dart b/tests/language/super_operator_index4_test.dart
index bb31116..8a82959 100644
--- a/tests/language/super_operator_index4_test.dart
+++ b/tests/language/super_operator_index4_test.dart
@@ -4,6 +4,8 @@
// Test for operator[] resolved in the super class.
+import "package:expect/expect.dart";
+
class A {
var indexField = new List(2);
operator[](index) => indexField[index];
diff --git a/tests/language/super_operator_index5_test.dart b/tests/language/super_operator_index5_test.dart
index ca14bb7..6842709 100644
--- a/tests/language/super_operator_index5_test.dart
+++ b/tests/language/super_operator_index5_test.dart
@@ -4,6 +4,8 @@
// Test for unresolved super[]=.
+import "package:expect/expect.dart";
+
class A {
var indexField = new List(2);
operator[](index) => indexField[index];
diff --git a/tests/language/super_operator_index6_test.dart b/tests/language/super_operator_index6_test.dart
index 70e2bcb..9fb942f 100644
--- a/tests/language/super_operator_index6_test.dart
+++ b/tests/language/super_operator_index6_test.dart
@@ -4,6 +4,8 @@
// Test for unresolved super[].
+import "package:expect/expect.dart";
+
class A {
var indexField = new List(2);
operator[]=(index, value) { indexField[index] = value; }
diff --git a/tests/language/super_operator_index7_test.dart b/tests/language/super_operator_index7_test.dart
index 112d882..b77b06f 100644
--- a/tests/language/super_operator_index7_test.dart
+++ b/tests/language/super_operator_index7_test.dart
@@ -4,6 +4,8 @@
// Test for unresolved super[] and super[]=.
+import "package:expect/expect.dart";
+
class A {
var indexField = new List(2);
diff --git a/tests/language/super_operator_test.dart b/tests/language/super_operator_test.dart
index eea7545..d47eb54 100644
--- a/tests/language/super_operator_test.dart
+++ b/tests/language/super_operator_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing super operator calls
+import "package:expect/expect.dart";
+
class A {
String val = "";
diff --git a/tests/language/super_setter_interceptor_test.dart b/tests/language/super_setter_interceptor_test.dart
index d9ef157..32b5062 100644
--- a/tests/language/super_setter_interceptor_test.dart
+++ b/tests/language/super_setter_interceptor_test.dart
@@ -4,6 +4,8 @@
// Test that we correctly intercept super getter and setter calls.
+import "package:expect/expect.dart";
+
var expected;
class A {
diff --git a/tests/language/super_setter_test.dart b/tests/language/super_setter_test.dart
index 22baa40..7683d78 100644
--- a/tests/language/super_setter_test.dart
+++ b/tests/language/super_setter_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing super setters and getters.
+import "package:expect/expect.dart";
+
class Base {
Base() {}
String value_;
diff --git a/tests/language/super_test.dart b/tests/language/super_test.dart
index f4bd085..4a4c8d1 100644
--- a/tests/language/super_test.dart
+++ b/tests/language/super_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int i = 0;
// Tests super calls and constructors.
diff --git a/tests/language/switch6_test.dart b/tests/language/switch6_test.dart
index a4d9dd3..231adfc 100644
--- a/tests/language/switch6_test.dart
+++ b/tests/language/switch6_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// The break is in the right scope, http://b/3428700 was agreed upon.
+import "package:expect/expect.dart";
+
class Switch6Test {
static testMain() {
diff --git a/tests/language/switch_fallthru_test.dart b/tests/language/switch_fallthru_test.dart
index 49085e1..a3c8504 100644
--- a/tests/language/switch_fallthru_test.dart
+++ b/tests/language/switch_fallthru_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Check that FallThroughError is thrown if switch clause does not terminate.
+import "package:expect/expect.dart";
+
class SwitchFallthruTest {
static String test(int n) {
String result = "foo";
diff --git a/tests/language/switch_label_test.dart b/tests/language/switch_label_test.dart
index 56c3d5d..9bb5e9e 100644
--- a/tests/language/switch_label_test.dart
+++ b/tests/language/switch_label_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test switch statement using labels.
+import "package:expect/expect.dart";
+
class Switcher {
Switcher() { }
diff --git a/tests/language/switch_scope_test.dart b/tests/language/switch_scope_test.dart
index fc297ca..dbba94b 100644
--- a/tests/language/switch_scope_test.dart
+++ b/tests/language/switch_scope_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test that a new scope is introduced for each switch case.
+import "package:expect/expect.dart";
+
class SwitchScopeTest {
static testMain() {
switch(1) {
diff --git a/tests/language/switch_test.dart b/tests/language/switch_test.dart
index a79a3e6..0ff8e9a 100644
--- a/tests/language/switch_test.dart
+++ b/tests/language/switch_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test switch statement.
+import "package:expect/expect.dart";
+
class Switcher {
Switcher() { }
diff --git a/tests/language/temp_mangling_test.dart b/tests/language/temp_mangling_test.dart
index 3031891..29f26ee 100644
--- a/tests/language/temp_mangling_test.dart
+++ b/tests/language/temp_mangling_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
main() {
testOne();
testTwo();
diff --git a/tests/language/ternary_test.dart b/tests/language/ternary_test.dart
index 52b4450..6549990 100644
--- a/tests/language/ternary_test.dart
+++ b/tests/language/ternary_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing the ternary operator.
+import "package:expect/expect.dart";
+
class TernaryTest {
static true_cond() { return true; }
static false_cond() { return false; }
diff --git a/tests/language/third_test.dart b/tests/language/third_test.dart
index 1e0b91d..04fc19a 100644
--- a/tests/language/third_test.dart
+++ b/tests/language/third_test.dart
@@ -4,6 +4,8 @@
// Third dart test program.
// @static-clean
+import "package:expect/expect.dart";
+
class A extends B {
var a;
static var s;
diff --git a/tests/language/throw1_test.dart b/tests/language/throw1_test.dart
index ba18e06..088eb0e 100644
--- a/tests/language/throw1_test.dart
+++ b/tests/language/throw1_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
abstract class TestException {
String getMessage();
}
diff --git a/tests/language/throw2_test.dart b/tests/language/throw2_test.dart
index a706b3a..b25e340 100644
--- a/tests/language/throw2_test.dart
+++ b/tests/language/throw2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
abstract class TestException {
String getMessage();
}
diff --git a/tests/language/throw3_test.dart b/tests/language/throw3_test.dart
index 49d184f..111404c 100644
--- a/tests/language/throw3_test.dart
+++ b/tests/language/throw3_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException {
const MyException([String message = ""]) : message_ = message;
final String message_;
diff --git a/tests/language/throw4_test.dart b/tests/language/throw4_test.dart
index 6b4a36d..5b82a80 100644
--- a/tests/language/throw4_test.dart
+++ b/tests/language/throw4_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException1 {
const MyException1([String message = "1"]) : message_ = message;
final String message_;
diff --git a/tests/language/throw5_test.dart b/tests/language/throw5_test.dart
index d742cf4..349ade7 100644
--- a/tests/language/throw5_test.dart
+++ b/tests/language/throw5_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException1 {
const MyException1([String message = "1"]) : message_ = message;
final String message_;
diff --git a/tests/language/throw6_test.dart b/tests/language/throw6_test.dart
index b6a4ac7..014f677 100644
--- a/tests/language/throw6_test.dart
+++ b/tests/language/throw6_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException1 {
const MyException1([String message = "1"]) : message_ = message;
final String message_;
diff --git a/tests/language/throw_expr_test.dart b/tests/language/throw_expr_test.dart
index 901a9f5..f844771 100644
--- a/tests/language/throw_expr_test.dart
+++ b/tests/language/throw_expr_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test program for testing throw expressions.
void test1() {
diff --git a/tests/language/throw_test.dart b/tests/language/throw_test.dart
index 24ec9d1..0c864cc 100644
--- a/tests/language/throw_test.dart
+++ b/tests/language/throw_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing throw statement
+import "package:expect/expect.dart";
+
class MyException {
const MyException(String this.message_);
final String message_;
diff --git a/tests/language/top_level_func_test.dart b/tests/language/top_level_func_test.dart
index c26f8e4..1871b90c 100644
--- a/tests/language/top_level_func_test.dart
+++ b/tests/language/top_level_func_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing top-level variables.
+import "package:expect/expect.dart";
+
class TopLevelFuncTest {
static testMain() {
diff --git a/tests/language/top_level_getter_arrow_syntax_test.dart b/tests/language/top_level_getter_arrow_syntax_test.dart
index 44c0689..990c0ad 100644
--- a/tests/language/top_level_getter_arrow_syntax_test.dart
+++ b/tests/language/top_level_getter_arrow_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
get getter => 42;
List<int> get lgetter => null;
diff --git a/tests/language/top_level_in_initializer_test.dart b/tests/language/top_level_in_initializer_test.dart
index 4c379bf..a037081 100644
--- a/tests/language/top_level_in_initializer_test.dart
+++ b/tests/language/top_level_in_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that constructor initializers can access top level elements.
const topLevelField = 1;
diff --git a/tests/language/top_level_method_test.dart b/tests/language/top_level_method_test.dart
index a86b776..ea3ce0f 100644
--- a/tests/language/top_level_method_test.dart
+++ b/tests/language/top_level_method_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
untypedTopLevel() {
return 1;
}
diff --git a/tests/language/top_level_multiple_files_test.dart b/tests/language/top_level_multiple_files_test.dart
index f9c835a..b6dd4b5 100644
--- a/tests/language/top_level_multiple_files_test.dart
+++ b/tests/language/top_level_multiple_files_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
library TopLevelMultipleFilesTest.dart;
+
+import "package:expect/expect.dart";
part 'top_level_file1.dart';
part 'top_level_file2.dart';
diff --git a/tests/language/top_level_non_prefixed_library_test.dart b/tests/language/top_level_non_prefixed_library_test.dart
index 689eb97..5a3995c 100644
--- a/tests/language/top_level_non_prefixed_library_test.dart
+++ b/tests/language/top_level_non_prefixed_library_test.dart
@@ -3,5 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library TopLevelNonPrefixLibraryTest.dart;
+
+import "package:expect/expect.dart";
import 'top_level_prefixed_library_test.lib';
part 'top_level_file1.dart';
diff --git a/tests/language/top_level_prefixed_declaration_test.dart b/tests/language/top_level_prefixed_declaration_test.dart
index 7bdad68..c1c765a 100644
--- a/tests/language/top_level_prefixed_declaration_test.dart
+++ b/tests/language/top_level_prefixed_declaration_test.dart
@@ -5,6 +5,7 @@
// Dart test for top level declarations involving an imported type.
library main;
+import "package:expect/expect.dart";
import "library11.dart" as lib11;
lib11.Library11 variable = null;
diff --git a/tests/language/top_level_var_test.dart b/tests/language/top_level_var_test.dart
index 9bd029a..91806ae 100644
--- a/tests/language/top_level_var_test.dart
+++ b/tests/language/top_level_var_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program testing top-level variables.
+import "package:expect/expect.dart";
+
var a, b;
diff --git a/tests/language/tree_shake_typed_selector_test.dart b/tests/language/tree_shake_typed_selector_test.dart
index fa02e08..480c846 100644
--- a/tests/language/tree_shake_typed_selector_test.dart
+++ b/tests/language/tree_shake_typed_selector_test.dart
@@ -4,6 +4,8 @@
// Check that dart2js emits code for classes that implement another
// class.
+import "package:expect/expect.dart";
+
class A {
factory A() => new B();
foo() => 0;
diff --git a/tests/language/try_catch2_test.dart b/tests/language/try_catch2_test.dart
index 908e4ce..fea2de8 100644
--- a/tests/language/try_catch2_test.dart
+++ b/tests/language/try_catch2_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing try/catch statement without any exceptions
// being thrown. (Nested try/catch blocks).
+import "package:expect/expect.dart";
+
abstract class TestException {
String getMessage();
}
diff --git a/tests/language/try_catch3_test.dart b/tests/language/try_catch3_test.dart
index 115714e..d679a4b 100644
--- a/tests/language/try_catch3_test.dart
+++ b/tests/language/try_catch3_test.dart
@@ -4,6 +4,8 @@
// Dart test program for testing try/catch statement without any exceptions
// being thrown.
+import "package:expect/expect.dart";
+
abstract class TestException {
String getMessage();
}
diff --git a/tests/language/try_catch4_test.dart b/tests/language/try_catch4_test.dart
index 16a0457..9ee40f5 100644
--- a/tests/language/try_catch4_test.dart
+++ b/tests/language/try_catch4_test.dart
@@ -4,6 +4,8 @@
// Check that our SSA graph does have the try body a predecessor of a
// try/finally.
+import "package:expect/expect.dart";
+
var a;
foo1() {
diff --git a/tests/language/try_catch5_test.dart b/tests/language/try_catch5_test.dart
index cf74a47..1b0e421 100644
--- a/tests/language/try_catch5_test.dart
+++ b/tests/language/try_catch5_test.dart
@@ -4,6 +4,8 @@
// Check that our SSA graph does have the try body a predecessor of a
// try/finally.
+import "package:expect/expect.dart";
+
var a;
foo1() {
diff --git a/tests/language/try_catch_on_syntax_test.dart b/tests/language/try_catch_on_syntax_test.dart
index e62f00f..cf79fdd7 100644
--- a/tests/language/try_catch_on_syntax_test.dart
+++ b/tests/language/try_catch_on_syntax_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class MyException { }
class MyException1 extends MyException { }
diff --git a/tests/language/try_catch_test.dart b/tests/language/try_catch_test.dart
index c3da133..ff3d6d6 100644
--- a/tests/language/try_catch_test.dart
+++ b/tests/language/try_catch_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class MyException { }
class MyException1 extends MyException { }
diff --git a/tests/language/type_cast_vm_test.dart b/tests/language/type_cast_vm_test.dart
index d61f036..90bb522 100644
--- a/tests/language/type_cast_vm_test.dart
+++ b/tests/language/type_cast_vm_test.dart
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--no_show_internal_names
-//
// Dart test program testing type casts.
+import "package:expect/expect.dart";
checkTopFunction(String expected, StackTrace stacktrace) {
var topLine = stacktrace.toString().split("\n")[0];
diff --git a/tests/language/type_checks_in_factory_method_test.dart b/tests/language/type_checks_in_factory_method_test.dart
index b0056d7..4402fd6 100644
--- a/tests/language/type_checks_in_factory_method_test.dart
+++ b/tests/language/type_checks_in_factory_method_test.dart
@@ -4,6 +4,8 @@
// VMOptions=--enable_checked_mode
// Tests the type checking when passing code into closure from inside a factory method
+import "package:expect/expect.dart";
+
abstract class Foo<T> {
factory Foo.from() = Bar<T>.from;
}
diff --git a/tests/language/type_error_test.dart b/tests/language/type_error_test.dart
index c1eca89..b41ad07 100644
--- a/tests/language/type_error_test.dart
+++ b/tests/language/type_error_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that various type errors doesn't invoke user-defined code
// during error reporting.
diff --git a/tests/language/type_guard_conversion_test.dart b/tests/language/type_guard_conversion_test.dart
index a008b62..c931108 100644
--- a/tests/language/type_guard_conversion_test.dart
+++ b/tests/language/type_guard_conversion_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
foo() => 'bar';
main() {
diff --git a/tests/language/type_intersection_test.dart b/tests/language/type_intersection_test.dart
index a6e2603..dc548b4 100644
--- a/tests/language/type_intersection_test.dart
+++ b/tests/language/type_intersection_test.dart
@@ -5,6 +5,8 @@
// Regression test for dart2js that used to consider that the
// intersection of [Comparable] and [num] is conflicting.
+import "package:expect/expect.dart";
+
class A {
foo(a, Comparable b) => a == b;
bar(a, Comparable b) => b == a;
diff --git a/tests/language/type_parameter_literal_test.dart b/tests/language/type_parameter_literal_test.dart
index 64d95eb..452b535 100644
--- a/tests/language/type_parameter_literal_test.dart
+++ b/tests/language/type_parameter_literal_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test type parameter literal expressions.
class D<T> {
diff --git a/tests/language/type_parameter_test.dart b/tests/language/type_parameter_test.dart
index 7244c43..e1a03d3 100644
--- a/tests/language/type_parameter_test.dart
+++ b/tests/language/type_parameter_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
class A<T> {
Function closure;
A._(this.closure);
diff --git a/tests/language/type_propagation_in_for_update_test.dart b/tests/language/type_propagation_in_for_update_test.dart
index 2a41e0c..058518e 100644
--- a/tests/language/type_propagation_in_for_update_test.dart
+++ b/tests/language/type_propagation_in_for_update_test.dart
@@ -4,6 +4,8 @@
// Check that phi type computation in the Dart2Js compiler does the
// correct thing.
+import "package:expect/expect.dart";
+
bar() => 'foo';
main() {
diff --git a/tests/language/type_propagation_phi_test.dart b/tests/language/type_propagation_phi_test.dart
index b64cfa7..8154ffc 100644
--- a/tests/language/type_propagation_phi_test.dart
+++ b/tests/language/type_propagation_phi_test.dart
@@ -4,6 +4,8 @@
// Check that phi type computation in the Dart2Js compiler does the
// correct thing.
+import "package:expect/expect.dart";
+
bar() => 490;
bar2() => 0;
diff --git a/tests/language/type_variable_bounds2_test.dart b/tests/language/type_variable_bounds2_test.dart
index d5ce7c7..1a23beb 100644
--- a/tests/language/type_variable_bounds2_test.dart
+++ b/tests/language/type_variable_bounds2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test of parameterized types with invalid bounds.
abstract class J<T> { }
diff --git a/tests/language/type_variable_field_initializer_closure_test.dart b/tests/language/type_variable_field_initializer_closure_test.dart
index e4da4a5..a3e3e47 100644
--- a/tests/language/type_variable_field_initializer_closure_test.dart
+++ b/tests/language/type_variable_field_initializer_closure_test.dart
@@ -5,6 +5,8 @@
// Check that an inlined field closure has access to the enclosing
// type variables.
+import "package:expect/expect.dart";
+
class A<T> {
var c = (() => new List<T>())();
}
diff --git a/tests/language/type_variable_field_initializer_test.dart b/tests/language/type_variable_field_initializer_test.dart
index 5519409..cc0ba50 100644
--- a/tests/language/type_variable_field_initializer_test.dart
+++ b/tests/language/type_variable_field_initializer_test.dart
@@ -5,6 +5,8 @@
// Check that an inlined field initializer has access to the enclosing
// type variables.
+import "package:expect/expect.dart";
+
class A<T> {
var c = new List<T>();
}
diff --git a/tests/language/type_variable_initializer_test.dart b/tests/language/type_variable_initializer_test.dart
index 721be03..e7b1ddf 100644
--- a/tests/language/type_variable_initializer_test.dart
+++ b/tests/language/type_variable_initializer_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for dart2js where the reference to [:this:] in a
// constructor was not propagated to the super initializers.
diff --git a/tests/language/type_variable_nested_test.dart b/tests/language/type_variable_nested_test.dart
index 5611ea74..eee0be0 100644
--- a/tests/language/type_variable_nested_test.dart
+++ b/tests/language/type_variable_nested_test.dart
@@ -5,6 +5,8 @@
// Regression test for
// http://code.google.com/p/dart/issues/detail?id=9050.
+import 'package:expect/expect.dart';
+
class A<T> {
}
diff --git a/tests/language/type_variable_scope2_test.dart b/tests/language/type_variable_scope2_test.dart
index 5c018a6..569daee 100644
--- a/tests/language/type_variable_scope2_test.dart
+++ b/tests/language/type_variable_scope2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test that malformed type arguments are reported in checked mode.
isCheckedMode() {
diff --git a/tests/language/type_vm_test.dart b/tests/language/type_vm_test.dart
index 7b525a1..29f7aff 100644
--- a/tests/language/type_vm_test.dart
+++ b/tests/language/type_vm_test.dart
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--enable_type_checks --no_show_internal_names
-//
// Dart test program testing type checks.
+import "package:expect/expect.dart";
class TypeTest {
static test() {
diff --git a/tests/language/typed_message_test.dart b/tests/language/typed_message_test.dart
index 4c23387..0904fae 100644
--- a/tests/language/typed_message_test.dart
+++ b/tests/language/typed_message_test.dart
@@ -6,6 +6,7 @@
// VMOptions=--checked
library TypedMessageTest;
+import "package:expect/expect.dart";
import "dart:isolate";
void logMessages() {
diff --git a/tests/language/typed_selector_test.dart b/tests/language/typed_selector_test.dart
index 8624528..676dcad 100644
--- a/tests/language/typed_selector_test.dart
+++ b/tests/language/typed_selector_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Regression test for http://dartbug.com/6259. This test used to fail
// on dart2js because class A does not know [A.document] is a target for
// the call [:obj.document:] in the [main] method. Therefore, dart2js
diff --git a/tests/language/typedef_is_test.dart b/tests/language/typedef_is_test.dart
index 768eb4c..43b9456 100644
--- a/tests/language/typedef_is_test.dart
+++ b/tests/language/typedef_is_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Test is-test of typedefs with optional and named parameters.
typedef int Func1(int a);
diff --git a/tests/language/unary2_test.dart b/tests/language/unary2_test.dart
index 550cb48..81d3335 100644
--- a/tests/language/unary2_test.dart
+++ b/tests/language/unary2_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for testing binary operations.
+import "package:expect/expect.dart";
+
class UnaryTest {
static foo() { return -4; }
static moo() { return +5; }
diff --git a/tests/language/unary_test.dart b/tests/language/unary_test.dart
index 109aa7f..a4001e7 100644
--- a/tests/language/unary_test.dart
+++ b/tests/language/unary_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Dart test for testing binary operations.
class UnaryTest {
diff --git a/tests/language/unnamed_closure_test.dart b/tests/language/unnamed_closure_test.dart
index 49fb684..cb4a075 100644
--- a/tests/language/unnamed_closure_test.dart
+++ b/tests/language/unnamed_closure_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
getNonArray() => new A();
class A {
diff --git a/tests/language/unqual_name_test.dart b/tests/language/unqual_name_test.dart
index 57a178c..ec51947 100644
--- a/tests/language/unqual_name_test.dart
+++ b/tests/language/unqual_name_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program to check that we can resolve unqualified identifiers
+import "package:expect/expect.dart";
+
class B {
B(x, y) : b = y { }
diff --git a/tests/language/value_range2_test.dart b/tests/language/value_range2_test.dart
index 6e45cc1..539af35 100644
--- a/tests/language/value_range2_test.dart
+++ b/tests/language/value_range2_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
foo() {
diff --git a/tests/language/value_range3_test.dart b/tests/language/value_range3_test.dart
index 6b5e169..7180938 100644
--- a/tests/language/value_range3_test.dart
+++ b/tests/language/value_range3_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
+
class A {
copy(array, index1, index2) {
if (index1 < index2 + index2) {
diff --git a/tests/language/value_range_test.dart b/tests/language/value_range_test.dart
index 5f4abb7..52892ce 100644
--- a/tests/language/value_range_test.dart
+++ b/tests/language/value_range_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
foo() {
diff --git a/tests/language/var_init_test.dart b/tests/language/var_init_test.dart
index 562d592..61ffd9b 100644
--- a/tests/language/var_init_test.dart
+++ b/tests/language/var_init_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Testing correct initialization of variables in scopes.
+import "package:expect/expect.dart";
+
class VarInitTest {
static void testMain() {
for (int i = 0; i < 10; i++) {
diff --git a/tests/language/void_type_test.dart b/tests/language/void_type_test.dart
index 5d52f0b..92ccd4d 100644
--- a/tests/language/void_type_test.dart
+++ b/tests/language/void_type_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test for type checks involving the void type.
+import "package:expect/expect.dart";
+
isCheckedMode() {
try {
var i = 1;
diff --git a/tests/language/while_test.dart b/tests/language/while_test.dart
index 378048a..5263d75 100644
--- a/tests/language/while_test.dart
+++ b/tests/language/while_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Dart test program for testing while statement.
+import "package:expect/expect.dart";
+
class Helper {
static int f1(bool b) {
while (b)
diff --git a/tests/language/wrong_number_type_arguments_test.dart b/tests/language/wrong_number_type_arguments_test.dart
index f04f438..8d84160 100644
--- a/tests/language/wrong_number_type_arguments_test.dart
+++ b/tests/language/wrong_number_type_arguments_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
// Map takes 2 type arguments.
Map
<String> /// 00: static type warning
diff --git a/tests/lib/async/deferred/deferred_api_test.dart b/tests/lib/async/deferred/deferred_api_test.dart
index a144468..7c6d390 100644
--- a/tests/lib/async/deferred/deferred_api_test.dart
+++ b/tests/lib/async/deferred/deferred_api_test.dart
@@ -8,6 +8,7 @@
// makes it possible to pass this test without having implemented
// deferred loading correctly.
+import "package:expect/expect.dart";
import 'dart:async';
@lazy
diff --git a/tests/lib/async/first_regression_test.dart b/tests/lib/async/first_regression_test.dart
new file mode 100644
index 0000000..a8a512d
--- /dev/null
+++ b/tests/lib/async/first_regression_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for http://dartbug.com/7964
+
+library first_regression_test;
+import 'dart:async';
+import '../../../pkg/unittest/lib/unittest.dart';
+
+class DoubleTransformer<T> extends StreamEventTransformer<T, T> {
+ void handleData(T data, EventSink<T> sink) {
+ sink.add(data);
+ sink.add(data);
+ }
+}
+
+main() {
+ test("Double event before first", () {
+ // This should not crash. Did crash by trying to complete future more
+ // than once.
+ new Stream.fromIterable([1, 2])
+ .transform(new DoubleTransformer())
+ .first
+ .then(expectAsync1((e) {}));
+ });
+}
diff --git a/tests/lib/async/future_delayed_error_test.dart b/tests/lib/async/future_delayed_error_test.dart
index a17343e..8d444c2 100644
--- a/tests/lib/async/future_delayed_error_test.dart
+++ b/tests/lib/async/future_delayed_error_test.dart
@@ -4,6 +4,7 @@
library future_delayed_error_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/lib/async/future_test.dart b/tests/lib/async/future_test.dart
index af4a5dd..6feffe1 100644
--- a/tests/lib/async/future_test.dart
+++ b/tests/lib/async/future_test.dart
@@ -4,6 +4,7 @@
library future_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/lib/async/futures_test.dart b/tests/lib/async/futures_test.dart
index e694134..7ae1d7e 100644
--- a/tests/lib/async/futures_test.dart
+++ b/tests/lib/async/futures_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library futures_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/lib/async/run_async2_test.dart b/tests/lib/async/run_async2_test.dart
index 0343c79..96a7c7b 100644
--- a/tests/lib/async/run_async2_test.dart
+++ b/tests/lib/async/run_async2_test.dart
@@ -4,6 +4,7 @@
library run_async_test;
+import 'package:expect/expect.dart';
import 'dart:async';
import '../../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/lib/async/run_async5_test.dart b/tests/lib/async/run_async5_test.dart
index 4565282..7bfdf26 100644
--- a/tests/lib/async/run_async5_test.dart
+++ b/tests/lib/async/run_async5_test.dart
@@ -4,6 +4,7 @@
library run_async_test;
+import "package:expect/expect.dart";
import 'dart:async';
import '../../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/lib/async/slow_consumer2_test.dart b/tests/lib/async/slow_consumer2_test.dart
index 25dbf95..d4865c4 100644
--- a/tests/lib/async/slow_consumer2_test.dart
+++ b/tests/lib/async/slow_consumer2_test.dart
@@ -6,6 +6,7 @@
library slow_consumer2_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/lib/async/slow_consumer3_test.dart b/tests/lib/async/slow_consumer3_test.dart
index 8dde399..18842c0 100644
--- a/tests/lib/async/slow_consumer3_test.dart
+++ b/tests/lib/async/slow_consumer3_test.dart
@@ -6,6 +6,7 @@
library slow_consumer3_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/lib/async/slow_consumer_test.dart b/tests/lib/async/slow_consumer_test.dart
index b8ae7f9..c07f8ac 100644
--- a/tests/lib/async/slow_consumer_test.dart
+++ b/tests/lib/async/slow_consumer_test.dart
@@ -6,6 +6,7 @@
library slow_consumer_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
diff --git a/tests/lib/async/stream_controller_async_test.dart b/tests/lib/async/stream_controller_async_test.dart
index 98fd749..dca28e1 100644
--- a/tests/lib/async/stream_controller_async_test.dart
+++ b/tests/lib/async/stream_controller_async_test.dart
@@ -5,6 +5,7 @@
// Test the basic StreamController and StreamController.singleSubscription.
library stream_controller_async_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
import '../../../pkg/unittest/lib/unittest.dart';
@@ -31,22 +32,6 @@
.catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); }));
c.add(42);
});
-
- test("StreamController.pipeInto", () {
- StreamController c = new StreamController.broadcast();
- var list = <int>[];
- Stream stream = c.stream;
- stream.pipeInto(new CollectionSink<int>(list))
- .whenComplete(expectAsync0(() {
- Expect.listEquals(<int>[1,2,9,3,9], list);
- }));
- c.add(1);
- c.add(2);
- c.add(9);
- c.add(3);
- c.add(9);
- c.close();
- });
}
testSingleController() {
@@ -68,22 +53,6 @@
c.add(42);
});
- test("Single-subscription StreamController.pipeInto", () {
- StreamController c = new StreamController();
- var list = <int>[];
- Stream stream = c.stream;
- stream.pipeInto(new CollectionSink<int>(list))
- .whenComplete(expectAsync0(() {
- Expect.listEquals(<int>[1,2,9,3,9], list);
- }));
- c.add(1);
- c.add(2);
- c.add(9);
- c.add(3);
- c.add(9);
- c.close();
- });
-
test("Single-subscription StreamController subscription changes", () {
StreamController c = new StreamController();
EventSink sink = c.sink;
@@ -431,7 +400,7 @@
Future f = streamValueTransform(c.stream, (v) { throw error; });
f.then((v) { Expect.fail("unreachable"); },
onError: expectAsync1((e) { Expect.identical(error, e); }));
- // Need two values to trigger compare for min/max.
+ // Need two values to trigger compare for reduce.
c.add(0);
c.add(1);
c.close();
@@ -446,9 +415,7 @@
testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act));
testFuture("every", (s, act) => s.every(act));
testFuture("any", (s, act) => s.any(act));
- testFuture("min", (s, act) => s.min((a, b) => act(b)));
- testFuture("max", (s, act) => s.max((a, b) => act(b)));
- testFuture("reduce", (s, act) => s.reduce(0, (a,b) => act(b)));
+ testFuture("reduce", (s, act) => s.reduce((a,b) => act(b)));
testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b)));
}
diff --git a/tests/lib/async/stream_controller_test.dart b/tests/lib/async/stream_controller_test.dart
index 20a05fd..7eba3c1 100644
--- a/tests/lib/async/stream_controller_test.dart
+++ b/tests/lib/async/stream_controller_test.dart
@@ -5,6 +5,7 @@
// Test the basic StreamController and StreamController.singleSubscription.
library stream_controller_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'event_helper.dart';
@@ -97,8 +98,11 @@
handleData: (v, s) { s.addError(new AsyncError(v)); },
handleError: (e, s) { s.add(e.error); },
handleDone: (s) {
+
s.add("foo");
+
s.close();
+
})));
sentEvents.replay(c);
Expect.listEquals(expectedEvents.events, actualEvents.events);
@@ -228,18 +232,6 @@
sentEvents.replay(c);
Expect.listEquals(expectedEvents.events, actualEvents.events);
- // pipe is tested asynchronously and therefore not in this file.
- c = new StreamController();
- var list = <int>[];
- c.stream.pipeInto(new CollectionSink<int>(list))
- .whenComplete(() { Expect.listEquals(<int>[1,2,9,3,9], list); });
- c.add(1);
- c.add(2);
- c.add(9);
- c.add(3);
- c.add(9);
- c.close();
-
// test contains.
{
c = new StreamController();
@@ -372,6 +364,7 @@
sentEvents.replay(c);
Expect.listEquals(expectedEvents.events, actualEvents.events);
+
c = new StreamController();
sentEvents = new Events()
..add(1)..add(1)..add(2)..add(1)..add(2)..add(2)..add(2)..close();
@@ -381,6 +374,7 @@
sentEvents.replay(c);
Expect.listEquals(expectedEvents.events, actualEvents.events);
+
c = new StreamController();
sentEvents = new Events()
..add(5)..add(6)..add(4)..add(6)..add(8)..add(3)..add(4)..add(1)..close();
diff --git a/tests/lib/async/stream_event_transform_test.dart b/tests/lib/async/stream_event_transform_test.dart
index 1f79f99..78c79cd 100644
--- a/tests/lib/async/stream_event_transform_test.dart
+++ b/tests/lib/async/stream_event_transform_test.dart
@@ -4,6 +4,7 @@
library stream_event_transform_test;
+import "package:expect/expect.dart";
import 'dart:async';
import '../../../pkg/unittest/lib/unittest.dart';
import 'event_helper.dart';
diff --git a/tests/lib/async/stream_from_iterable_test.dart b/tests/lib/async/stream_from_iterable_test.dart
index 0af493d..ab7d543 100644
--- a/tests/lib/async/stream_from_iterable_test.dart
+++ b/tests/lib/async/stream_from_iterable_test.dart
@@ -5,6 +5,7 @@
// Test merging streams.
library dart.test.stream_from_iterable;
+import "package:expect/expect.dart";
import "dart:async";
import '../../../pkg/unittest/lib/unittest.dart';
import 'event_helper.dart';
diff --git a/tests/lib/async/stream_min_max_test.dart b/tests/lib/async/stream_min_max_test.dart
deleted file mode 100644
index 67c9f01..0000000
--- a/tests/lib/async/stream_min_max_test.dart
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library stream_min_max_test;
-
-import 'dart:async';
-import 'dart:isolate';
-import '../../../pkg/unittest/lib/unittest.dart';
-import 'event_helper.dart';
-
-const int big = 1000000;
-const double inf = double.INFINITY;
-List intList = const [-0, 0, -1, 1, -10, 10, -big, big];
-List doubleList = const [-0.0, 0.0, -1.0, 1.0, -10.0, 10.0, -inf, inf];
-
-main() {
- testMinMax(name, iterable, min, max, [int compare(a, b)]) {
- test("$name-min", () {
- StreamController c = new StreamController();
- Future f = c.stream.min(compare);
- f.then(expectAsync1((v) { Expect.equals(min, v);}));
- new Events.fromIterable(iterable).replay(c);
- });
- test("$name-max", () {
- StreamController c = new StreamController();
- Future f = c.stream.max(compare);
- f.then(expectAsync1((v) { Expect.equals(max, v);}));
- new Events.fromIterable(iterable).replay(c);
- });
- }
-
- testMinMax("const-int", intList, -big, big);
- testMinMax("list-int", intList.toList(), -big, big);
- testMinMax("set-int", intList.toSet(), -big, big);
-
- testMinMax("const-double", doubleList, -inf, inf);
- testMinMax("list-double", doubleList.toList(), -inf, inf);
- testMinMax("set-double", doubleList.toSet(), -inf, inf);
-
- int reverse(a, b) => b.compareTo(a);
- testMinMax("rev-int", intList, big, -big, reverse);
- testMinMax("rev-double", doubleList, inf, -inf, reverse);
-}
diff --git a/tests/lib/async/stream_single_test.dart b/tests/lib/async/stream_single_test.dart
index a3348b5..3bc889a 100644
--- a/tests/lib/async/stream_single_test.dart
+++ b/tests/lib/async/stream_single_test.dart
@@ -5,6 +5,7 @@
// Test the Stream.single method.
library stream_single_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
import '../../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/lib/async/stream_single_to_multi_subscriber_test.dart b/tests/lib/async/stream_single_to_multi_subscriber_test.dart
index 2b814b7..8424cb2 100644
--- a/tests/lib/async/stream_single_to_multi_subscriber_test.dart
+++ b/tests/lib/async/stream_single_to_multi_subscriber_test.dart
@@ -5,6 +5,7 @@
// Test the basic StreamController and StreamController.singleSubscription.
library stream_single_test;
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:isolate';
import '../../../pkg/unittest/lib/unittest.dart';
diff --git a/tests/lib/async/stream_state_helper.dart b/tests/lib/async/stream_state_helper.dart
index 8f9b33f..b982d9d 100644
--- a/tests/lib/async/stream_state_helper.dart
+++ b/tests/lib/async/stream_state_helper.dart
@@ -105,7 +105,7 @@
_withNextExpectation((Event expect) {
if (!expect.matchSubscriptionChange(_controller)) {
_fail("Expected: $expect\n"
- "Found: [Subscribed:${_controller.hasSubscribers}, "
+ "Found: [Has listener:${_controller.hasListener}, "
"Paused:${_controller.isPaused}]");
}
});
@@ -159,12 +159,12 @@
}
_expectations.add(new PauseCallbackEvent(isPaused, action));
}
- void expectSubscription(bool hasSubscribers, bool isPaused, [void action()]) {
+ void expectSubscription(bool hasListener, bool isPaused, [void action()]) {
if (_onComplete == null) {
_fail("Adding expectation after completing");
}
_expectations.add(
- new SubscriptionCallbackEvent(hasSubscribers, isPaused, action));
+ new SubscriptionCallbackEvent(hasListener, isPaused, action));
}
void _fail(String message) {
@@ -252,14 +252,14 @@
}
class SubscriptionCallbackEvent extends Event {
- final bool hasSubscribers;
+ final bool hasListener;
final bool isPaused;
- SubscriptionCallbackEvent(this.hasSubscribers, this.isPaused, void action())
+ SubscriptionCallbackEvent(this.hasListener, this.isPaused, void action())
: super(action);
bool _testSubscribe(StreamController c) {
- return hasSubscribers == c.hasSubscribers && isPaused == c.isPaused;
+ return hasListener == c.hasListener && isPaused == c.isPaused;
}
- String toString() => "[Subscribers:$hasSubscribers, Paused:$isPaused]";
+ String toString() => "[Has listener:$hasListener, Paused:$isPaused]";
}
@@ -283,7 +283,7 @@
return true;
}
bool _testSubcribe(StreamController c) {
- _actual = "*[Subscribers:${c.hasSubscribers}, Paused:${c.isPaused}]";
+ _actual = "*[Has listener:${c.hasListener}, Paused:${c.isPaused}]";
return true;
}
diff --git a/tests/lib/async/stream_transform_test.dart b/tests/lib/async/stream_transform_test.dart
index 6bc4db8..414c02c 100644
--- a/tests/lib/async/stream_transform_test.dart
+++ b/tests/lib/async/stream_transform_test.dart
@@ -4,6 +4,7 @@
library stream_transform_test;
+import "package:expect/expect.dart";
import 'dart:async';
import '../../../pkg/unittest/lib/unittest.dart';
import 'event_helper.dart';
diff --git a/tests/lib/async/timer_not_available_test.dart b/tests/lib/async/timer_not_available_test.dart
index d0efd1f..0e55107 100644
--- a/tests/lib/async/timer_not_available_test.dart
+++ b/tests/lib/async/timer_not_available_test.dart
@@ -4,6 +4,7 @@
library timerNotAvailable;
+import 'package:expect/expect.dart';
import 'dart:async';
main() {
diff --git a/tests/lib/crypto/base64_test.dart b/tests/lib/crypto/base64_test.dart
index ff53c9e..663e067 100644
--- a/tests/lib/crypto/base64_test.dart
+++ b/tests/lib/crypto/base64_test.dart
@@ -5,6 +5,7 @@
// Library tag to allow the test to run on Dartium.
library base64_test;
+import "package:expect/expect.dart";
import 'dart:crypto';
import 'dart:math';
diff --git a/tests/lib/crypto/hmac_md5_test.dart b/tests/lib/crypto/hmac_md5_test.dart
index 2973147..8f9e768 100644
--- a/tests/lib/crypto/hmac_md5_test.dart
+++ b/tests/lib/crypto/hmac_md5_test.dart
@@ -5,6 +5,7 @@
// Library tag to allow the test to run on Dartium.
library hmac_md5_test;
+import "package:expect/expect.dart";
import 'dart:crypto';
// Data from http://tools.ietf.org/html/rfc2202.
diff --git a/tests/lib/crypto/hmac_sha1_test.dart b/tests/lib/crypto/hmac_sha1_test.dart
index 8a87ceb..12e0c00 100644
--- a/tests/lib/crypto/hmac_sha1_test.dart
+++ b/tests/lib/crypto/hmac_sha1_test.dart
@@ -5,6 +5,7 @@
// Library tag to allow the test to run on Dartium.
library hmac_sha1_test;
+import "package:expect/expect.dart";
import 'dart:crypto';
part 'hmac_sha1_test_vectors.dart';
diff --git a/tests/lib/crypto/hmac_sha256_test.dart b/tests/lib/crypto/hmac_sha256_test.dart
index bfd85b2..1d52efd 100644
--- a/tests/lib/crypto/hmac_sha256_test.dart
+++ b/tests/lib/crypto/hmac_sha256_test.dart
@@ -5,6 +5,7 @@
// Library tag to allow the test to run on Dartium.
library hmac_sha256_test;
+import "package:expect/expect.dart";
import 'dart:crypto';
part 'hmac_sha256_test_vectors.dart';
diff --git a/tests/lib/crypto/sha1_test.dart b/tests/lib/crypto/sha1_test.dart
index d977230..1254dc8 100644
--- a/tests/lib/crypto/sha1_test.dart
+++ b/tests/lib/crypto/sha1_test.dart
@@ -5,6 +5,7 @@
// Library tag to allow dartium to run the test.
library sha1_test;
+import "package:expect/expect.dart";
import 'dart:crypto';
part 'sha1_long_test_vectors.dart';
diff --git a/tests/lib/crypto/sha256_test.dart b/tests/lib/crypto/sha256_test.dart
index 767812a..f42a3f2 100644
--- a/tests/lib/crypto/sha256_test.dart
+++ b/tests/lib/crypto/sha256_test.dart
@@ -5,6 +5,7 @@
// Library tag to allow Dartium to run the tests.
library sha256_test;
+import "package:expect/expect.dart";
import 'dart:crypto';
part 'sha256_long_test_vectors.dart';
diff --git a/tests/lib/lib.status b/tests/lib/lib.status
index 00a3fc5..b7f3acb 100644
--- a/tests/lib/lib.status
+++ b/tests/lib/lib.status
@@ -20,7 +20,7 @@
async/run_async3_test: Fail # _enqueueImmediate runs after Timer. http://dartbug.com/9002
async/run_async4_test: Pass, Fail # no global exception handler in isolates. http://dartbug.com/9012
-[ $compiler == dart2js && $runtime == chrome && ($system == macos || $system == windows)]
+[ $compiler == dart2js && ( $runtime == chrome || $runtime == drt ) && ($system == macos || $system == windows)]
crypto/hmac_sha1_test: Fail # Issue 9471
[ $compiler == dart2js && $checked ]
diff --git a/tests/lib/math/coin_test.dart b/tests/lib/math/coin_test.dart
index c5dcb16..0da9aed 100644
--- a/tests/lib/math/coin_test.dart
+++ b/tests/lib/math/coin_test.dart
@@ -7,6 +7,7 @@
// Library tag to allow Dartium to run the test.
library coin_test;
+import "package:expect/expect.dart";
import 'dart:math';
main() {
diff --git a/tests/lib/math/low_test.dart b/tests/lib/math/low_test.dart
index cb261d0..31f0e8a 100644
--- a/tests/lib/math/low_test.dart
+++ b/tests/lib/math/low_test.dart
@@ -8,6 +8,7 @@
// Library tag to allow Dartium to run the test.
library low_test;
+import "package:expect/expect.dart";
import 'dart:math';
void main() {
diff --git a/tests/lib/math/math2_test.dart b/tests/lib/math/math2_test.dart
index fb3c804..2f741d4 100644
--- a/tests/lib/math/math2_test.dart
+++ b/tests/lib/math/math2_test.dart
@@ -6,6 +6,7 @@
// class. This can easily be simplified once we get rid of the Math
// class entirely.
library math_test;
+import "package:expect/expect.dart";
import 'dart:math' as math;
class MathLibraryTest {
diff --git a/tests/lib/math/math_parse_double_test.dart b/tests/lib/math/math_parse_double_test.dart
index fb6b3fa..af77f6b 100644
--- a/tests/lib/math/math_parse_double_test.dart
+++ b/tests/lib/math/math_parse_double_test.dart
@@ -6,6 +6,7 @@
// class. This can easily be simplified once we get rid of the Math
// class entirely.
library math_parse_double_test;
+import "package:expect/expect.dart";
void parseDoubleThrowsFormatException(str) {
Expect.throws(() => double.parse(str), (e) => e is FormatException);
diff --git a/tests/lib/math/math_test.dart b/tests/lib/math/math_test.dart
index cfd2af6..2bc7741 100644
--- a/tests/lib/math/math_test.dart
+++ b/tests/lib/math/math_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library math_test;
+import "package:expect/expect.dart";
import 'dart:math';
class MathTest {
diff --git a/tests/lib/math/min_max_test.dart b/tests/lib/math/min_max_test.dart
index 42c9730..3bf864c 100644
--- a/tests/lib/math/min_max_test.dart
+++ b/tests/lib/math/min_max_test.dart
@@ -4,6 +4,7 @@
// Dart test for testing Math.min and Math.max.
library min_max_test;
+import "package:expect/expect.dart";
import 'dart:math';
testMin() {
diff --git a/tests/lib/math/pi_test.dart b/tests/lib/math/pi_test.dart
index c042b4b..deb58fd 100644
--- a/tests/lib/math/pi_test.dart
+++ b/tests/lib/math/pi_test.dart
@@ -8,6 +8,7 @@
// Library tag to allow Dartium to run the test.
library pi_test;
+import "package:expect/expect.dart";
import 'dart:math';
void main() {
diff --git a/tests/lib/math/random_test.dart b/tests/lib/math/random_test.dart
index 88b67a9..f06fa2b 100644
--- a/tests/lib/math/random_test.dart
+++ b/tests/lib/math/random_test.dart
@@ -7,6 +7,7 @@
// Library tag to allow Dartium to run the test.
library random_test;
+import "package:expect/expect.dart";
import 'dart:math';
main() {
diff --git a/tests/lib/mirrors/mirrors_test.dart b/tests/lib/mirrors/mirrors_test.dart
index 14ab436..33c57ac 100644
--- a/tests/lib/mirrors/mirrors_test.dart
+++ b/tests/lib/mirrors/mirrors_test.dart
@@ -25,22 +25,22 @@
var classMirror = libMirror.classes["Class"];
var instMirror = reflect(instance);
- libMirror.setField('topLevelField', 42);
- var future = libMirror.getField('topLevelField');
+ libMirror.setFieldAsync('topLevelField', 42);
+ var future = libMirror.getFieldAsync('topLevelField');
future.then(expectAsync1((resultMirror) {
expect(resultMirror.reflectee, equals(42));
expect(topLevelField, equals(42));
}));
- classMirror.setField('staticField', 43);
- future = classMirror.getField('staticField');
+ classMirror.setFieldAsync('staticField', 43);
+ future = classMirror.getFieldAsync('staticField');
future.then(expectAsync1((resultMirror) {
expect(resultMirror.reflectee, equals(43));
expect(Class.staticField, equals(43));
}));
- instMirror.setField('field', 44);
- future = instMirror.getField('field');
+ instMirror.setFieldAsync('field', 44);
+ future = instMirror.getFieldAsync('field');
future.then(expectAsync1((resultMirror) {
expect(resultMirror.reflectee, equals(44));
expect(instance.field, equals(44));
@@ -57,7 +57,7 @@
expect(funcMirror is MethodMirror, equals(true));
expect(funcMirror.parameters.length, equals(3));
- var future = mirror.apply([2, 4, 8]);
+ var future = mirror.applyAsync([2, 4, 8]);
future.then(expectAsync1((resultMirror) {
expect(resultMirror.reflectee, equals(14));
}));
@@ -67,14 +67,14 @@
var libMirror = mirrors.libraries["MirrorsTest"];
var classMirror = libMirror.classes["Class"];
- var future = classMirror.newInstance('', []);
+ var future = classMirror.newInstanceAsync('', []);
future.then(expectAsync1((resultMirror) {
var instance = resultMirror.reflectee;
expect(instance is Class, equals(true));
expect(instance.field, equals("default value"));
}));
- future = classMirror.newInstance('withInitialValue', [45]);
+ future = classMirror.newInstanceAsync('withInitialValue', [45]);
future.then(expectAsync1((resultMirror) {
var instance = resultMirror.reflectee;
expect(instance is Class, equals(true));
diff --git a/tests/lib/typeddata/float32x4_list_test.dart b/tests/lib/typeddata/float32x4_list_test.dart
index 3fffde0..055b652 100644
--- a/tests/lib/typeddata/float32x4_list_test.dart
+++ b/tests/lib/typeddata/float32x4_list_test.dart
@@ -1,10 +1,12 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--deoptimization_counter_threshold=1000
// Library tag to be able to run in html test framework.
library float32x4_list_test;
+import 'package:expect/expect.dart';
import 'dart:typeddata';
testLoadStore(array) {
@@ -27,6 +29,72 @@
Expect.equals(4.0, array[1].w);
}
+testLoadStoreDeopt(array, index, value) {
+ array[index] = value;
+ Expect.equals(value.x, array[index].x);
+ Expect.equals(value.y, array[index].y);
+ Expect.equals(value.z, array[index].z);
+ Expect.equals(value.w, array[index].w);
+}
+
+testLoadStoreDeoptDriver() {
+ Float32x4List list = new Float32x4List(4);
+ Float32x4 value = new Float32x4(1.0, 2.0, 3.0, 4.0);
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+ try {
+ // Invalid index.
+ testLoadStoreDeopt(list, 5, value);
+ } catch (_) {}
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+ try {
+ // null list.
+ testLoadStoreDeopt(null, 0, value);
+ } catch (_) {}
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+ try {
+ // null value.
+ testLoadStoreDeopt(list, 0, null);
+ } catch (_) {}
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+ try {
+ // non-smi index.
+ testLoadStoreDeopt(list, 3.14159, value);
+ } catch (_) {}
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+ try {
+ // non-Float32x4 value.
+ testLoadStoreDeopt(list, 0, 4.toDouble());
+ } catch (_) {}
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+ try {
+ // non-Float32x4List list.
+ testLoadStoreDeopt([new Float32x4(2.0, 3.0, 4.0, 5.0)], 0, value);
+ } catch (_) {}
+ for (int i = 0; i < 3000; i++) {
+ testLoadStoreDeopt(list, 0, value);
+ }
+}
+
+testListZero() {
+ Float32x4List list = new Float32x4List(1);
+ Expect.equals(0.0, list[0].x);
+ Expect.equals(0.0, list[0].y);
+ Expect.equals(0.0, list[0].z);
+ Expect.equals(0.0, list[0].w);
+}
+
testView(array) {
Expect.equals(8, array.length);
Expect.isTrue(array is List<Float32x4>);
@@ -63,4 +131,8 @@
for (int i = 0; i < 3000; i++) {
testLoadStore(list);
}
+ for (int i = 0; i < 3000; i++) {
+ testListZero();
+ }
+ testLoadStoreDeoptDriver();
}
diff --git a/tests/lib/typeddata/float32x4_test.dart b/tests/lib/typeddata/float32x4_test.dart
index deb0ce8..490009a 100644
--- a/tests/lib/typeddata/float32x4_test.dart
+++ b/tests/lib/typeddata/float32x4_test.dart
@@ -5,6 +5,7 @@
// Library tag to be able to run in html test framework.
library float32x4_test;
+import "package:expect/expect.dart";
import 'dart:typeddata';
testAdd() {
diff --git a/tests/lib/typeddata/float32x4_unbox_regress_test.dart b/tests/lib/typeddata/float32x4_unbox_regress_test.dart
new file mode 100644
index 0000000..48563e2
--- /dev/null
+++ b/tests/lib/typeddata/float32x4_unbox_regress_test.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Library tag to be able to run in html test framework.
+library float32x4_unbox_regress_test;
+
+import 'package:expect/expect.dart';
+import 'dart:typeddata';
+
+testListStore(array, index, value) {
+ array[index] = value;
+}
+
+main() {
+ var list;
+ var value = new Float32x4(1.0, 2.0, 3.0, 4.0);
+ var smi = 12;
+ list = new Float32x4List(8);
+ for (int i = 0; i < 3000; i++) {
+ testListStore(list, 0, value);
+ }
+
+ try {
+ // Without a proper check for SMI in the Float32x4 unbox instruction
+ // this might trigger a crash.
+ testListStore(list, 0, smi);
+ } catch (_) { }
+}
diff --git a/tests/utils/utf8_test.dart b/tests/lib/utf/utf8_test.dart
similarity index 97%
rename from tests/utils/utf8_test.dart
rename to tests/lib/utf/utf8_test.dart
index b92d5aaa..3fdd8a8 100644
--- a/tests/utils/utf8_test.dart
+++ b/tests/lib/utf/utf8_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library utf8_test;
+import "package:expect/expect.dart";
import 'dart:utf';
String decode(List<int> bytes) => decodeUtf8(bytes);
diff --git a/tests/utils/utf_test.dart b/tests/lib/utf/utf_test.dart
similarity index 84%
rename from tests/utils/utf_test.dart
rename to tests/lib/utf/utf_test.dart
index 10401a3..85a8564 100644
--- a/tests/utils/utf_test.dart
+++ b/tests/lib/utf/utf_test.dart
@@ -3,10 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
library utf_test;
+import "package:expect/expect.dart";
import 'dart:utf';
main() {
- String str = codepointsToString([0x1d537]);
+ String str = new String.fromCharCodes([0x1d537]);
// String.codeUnits gives 16-bit code units, but stringToCodepoints gives
// back the original code points.
Expect.listEquals([0xd835, 0xdd37], str.codeUnits);
diff --git a/tests/standalone/assert_test.dart b/tests/standalone/assert_test.dart
index ae841bd..af63a68 100644
--- a/tests/standalone/assert_test.dart
+++ b/tests/standalone/assert_test.dart
@@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// VMOptions=--enable_asserts
-//
// Dart test program testing assert statements.
+import "package:expect/expect.dart";
class AssertTest {
static test() {
diff --git a/tests/standalone/byte_array_view_optimized_test.dart b/tests/standalone/byte_array_view_optimized_test.dart
index 9f3b0be..6699d0b 100644
--- a/tests/standalone/byte_array_view_optimized_test.dart
+++ b/tests/standalone/byte_array_view_optimized_test.dart
@@ -7,6 +7,7 @@
// Library tag to be able to run in html test framework.
library ByteArrayViewOptimizedTest;
+import "package:expect/expect.dart";
import "dart:typeddata";
li16(v) => v[0];
diff --git a/tests/standalone/constant_left_shift_test.dart b/tests/standalone/constant_left_shift_test.dart
index 3385a24..229bc38 100644
--- a/tests/standalone/constant_left_shift_test.dart
+++ b/tests/standalone/constant_left_shift_test.dart
@@ -4,6 +4,8 @@
//
// Dart test program for testing left shifts of a constant.
+import "package:expect/expect.dart";
+
shiftLeft0(c) => 0 << c;
shiftLeft1(c) => 1 << c;
shiftLeft8448(c) => 8448 << c;
diff --git a/tests/standalone/crypto/base64_test.dart b/tests/standalone/crypto/base64_test.dart
index 36546d4..55546f0 100644
--- a/tests/standalone/crypto/base64_test.dart
+++ b/tests/standalone/crypto/base64_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
part "../../../sdk/lib/io/base64.dart";
void main() {
diff --git a/tests/standalone/debugger/debug_lib.dart b/tests/standalone/debugger/debug_lib.dart
index 7d3b8ec..bc1f246 100644
--- a/tests/standalone/debugger/debug_lib.dart
+++ b/tests/standalone/debugger/debug_lib.dart
@@ -11,9 +11,6 @@
import "dart:utf";
import "dart:json" as JSON;
-// Whether or not to print debug target process on the console.
-var showDebuggeeOutput = true;
-
// Whether or not to print the debugger wire messages on the console.
var verboseWire = false;
@@ -49,7 +46,22 @@
return msg;
}
- // Returns the character length of the newxt json message in the
+ bool haveGarbage() {
+ if (buffer == null || buffer.length == 0) return false;
+ var i = 0, char = " ";
+ while (i < buffer.length) {
+ char = buffer[i];
+ if (char != " " && char != "\n" && char != "\r" && char != "\t") break;
+ i++;
+ }
+ if (i >= buffer.length) {
+ return false;
+ } else {
+ return char != "{";
+ }
+ }
+
+ // Returns the character length of the next json message in the
// buffer, or 0 if there is only a partial message in the buffer.
// The object value must start with '{' and continues to the
// matching '}'. No attempt is made to otherwise validate the contents
@@ -293,24 +305,23 @@
int isolateId = 0;
bool isPaused = false;
- Debugger(this.targetProcess, this.portNumber) {
+ Debugger(this.targetProcess, this.portNumber, this.script) {
stdin.listen((_) {});
var stdoutStringStream = targetProcess.stdout
.transform(new StringDecoder())
.transform(new LineTransformer());
stdoutStringStream.listen((line) {
- if (showDebuggeeOutput) {
- print("TARG: $line");
+ if (line == "Debugger initialized") {
+ openConnection();
}
+ print("TARG: $line");
});
var stderrStringStream = targetProcess.stderr
.transform(new StringDecoder())
.transform(new LineTransformer());
stderrStringStream.listen((line) {
- if (showDebuggeeOutput) {
- print("TARG: $line");
- }
+ print("TARG: $line");
});
}
@@ -380,6 +391,12 @@
var msg = responses.getNextMessage();
while (msg != null) {
if (verboseWire) print("RECV: $msg");
+ if (responses.haveGarbage()) {
+ error("Error: leftover text after message: '${responses.buffer}'");
+ error("Previous message may be malformed, was: '$msg'");
+ close(killDebugee: true);
+ return;
+ }
var msgObj = JSON.parse(msg);
handleMessage(msgObj);
if (errorsDetected) {
@@ -445,7 +462,7 @@
});
},
onError: (asyncErr) {
- print("Error while connecting to debugee: $asyncErr");
+ error("Error while connecting to debugee: $asyncErr");
close(killDebugee: true);
});
}
@@ -459,7 +476,7 @@
targetProcess.kill();
print("Target process killed");
}
- Expect.isTrue(!errorsDetected);
+ if (errorsDetected) throw "Errors detected";
exit(errors.length);
}
}
@@ -470,8 +487,6 @@
if (options.arguments.contains("--debuggee")) {
return false;
}
- // The default is to show debugging output.
- showDebuggeeOutput = !options.arguments.contains("--non-verbose");
verboseWire = options.arguments.contains("--wire");
// Pick a port in the upper half of the port number range.
@@ -482,19 +497,22 @@
ServerSocket.bind('127.0.0.1', debugPort).then((ServerSocket s) {
s.close();
var targetOpts = [ "--debug:$debugPort" ];
- if (showDebuggeeOutput) targetOpts.add("--verbose_debug");
+ // --verbose_debug is necessary so the test knows when the debuggee
+ // is initialized.
+ targetOpts.add("--verbose_debug");
targetOpts.add(options.script);
targetOpts.add("--debuggee");
+ print('args: ${targetOpts.join(" ")}');
Process.start(options.executable, targetOpts).then((Process process) {
print("Debug target process started");
process.stdin.close();
process.exitCode.then((int exitCode) {
- Expect.equals(0, exitCode);
+ if (exitCode != 0) throw "bad exit code: $exitCode";
print("Debug target process exited with exit code $exitCode");
});
- var debugger = new Debugger(process, debugPort);
- debugger.runScript(script);
+ var debugger =
+ new Debugger(process, debugPort, new DebugScript(script));
});
},
onError: (e) {
diff --git a/tests/standalone/deoptimization_test.dart b/tests/standalone/deoptimization_test.dart
index b357126..8b68c11 100644
--- a/tests/standalone/deoptimization_test.dart
+++ b/tests/standalone/deoptimization_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test deoptimization.
+import "package:expect/expect.dart";
+
class SmiCompares {
// Test deoptimization when one argument is known to be Smi.
static bool smiCompareLessThan2(a) {
diff --git a/tests/standalone/double_temp_test.dart b/tests/standalone/double_temp_test.dart
index cfda808..cec3c9e 100644
--- a/tests/standalone/double_temp_test.dart
+++ b/tests/standalone/double_temp_test.dart
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
// Test correct usage of inlined double temporary objects.
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 2000; i++) {
testBinaryOp();
diff --git a/tests/standalone/double_to_int_test.dart b/tests/standalone/double_to_int_test.dart
index 0386644..282c187 100644
--- a/tests/standalone/double_to_int_test.dart
+++ b/tests/standalone/double_to_int_test.dart
@@ -6,6 +6,8 @@
// unless we encounter a non-Smi result, in which case we deoptimize and
// optimize it later to DoubleToInt.
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 600; i++) {
diff --git a/tests/standalone/float_array_test.dart b/tests/standalone/float_array_test.dart
index 085593a..d8c9ebb 100644
--- a/tests/standalone/float_array_test.dart
+++ b/tests/standalone/float_array_test.dart
@@ -7,6 +7,7 @@
// Library tag to be able to run in html test framework.
library FloatArrayTest;
+import "package:expect/expect.dart";
import 'dart:typeddata';
void testCreateFloat32Array() {
diff --git a/tests/standalone/int_array_load_elimination_test.dart b/tests/standalone/int_array_load_elimination_test.dart
index 55997a9..c3792b0 100644
--- a/tests/standalone/int_array_load_elimination_test.dart
+++ b/tests/standalone/int_array_load_elimination_test.dart
@@ -7,6 +7,7 @@
// TODO: remove once bug 2264 fixed.
library int_array_load_elimination;
+import "package:expect/expect.dart";
import 'dart:typeddata';
void testUint16() {
diff --git a/tests/standalone/int_array_test.dart b/tests/standalone/int_array_test.dart
index bebc2ef..3712a42 100644
--- a/tests/standalone/int_array_test.dart
+++ b/tests/standalone/int_array_test.dart
@@ -7,6 +7,7 @@
// Library tag to be able to run in html test framework.
library IntArrayTest;
+import "package:expect/expect.dart";
import 'dart:typeddata';
void testInt16() {
diff --git a/tests/standalone/io/dart_std_io_pipe_script.dart b/tests/standalone/io/dart_std_io_pipe_script.dart
index 1299645..76402d6 100644
--- a/tests/standalone/io/dart_std_io_pipe_script.dart
+++ b/tests/standalone/io/dart_std_io_pipe_script.dart
@@ -27,8 +27,8 @@
stdin.pipe(stderr);
} else if (options.arguments[0] == "2") {
stdin.listen((data) {
- stdout.writeBytes(data);
- stderr.writeBytes(data);
+ stdout.add(data);
+ stderr.add(data);
});
}
}
diff --git a/tests/standalone/io/dart_std_io_pipe_test.dart b/tests/standalone/io/dart_std_io_pipe_test.dart
index 4310d78..bdbffeb 100644
--- a/tests/standalone/io/dart_std_io_pipe_test.dart
+++ b/tests/standalone/io/dart_std_io_pipe_test.dart
@@ -10,6 +10,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/delete_symlink_test.dart b/tests/standalone/io/delete_symlink_test.dart
index 3161eb4..ad10a48 100644
--- a/tests/standalone/io/delete_symlink_test.dart
+++ b/tests/standalone/io/delete_symlink_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/io/directory_create_race_test.dart b/tests/standalone/io/directory_create_race_test.dart
index 50b5ff2..e743a76 100644
--- a/tests/standalone/io/directory_create_race_test.dart
+++ b/tests/standalone/io/directory_create_race_test.dart
@@ -7,6 +7,7 @@
// issue https://code.google.com/p/dart/issues/detail?id=7679 in revisions
// without the fix for this issue.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/directory_error_test.dart b/tests/standalone/io/directory_error_test.dart
index 6a8ebe9..33418ef 100644
--- a/tests/standalone/io/directory_error_test.dart
+++ b/tests/standalone/io/directory_error_test.dart
@@ -4,6 +4,7 @@
//
// Dart test program for testing error handling in directory I/O.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -94,13 +95,8 @@
Expect.isTrue(e is DirectoryIOException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf("Deletion failed") != -1);
- if (Platform.operatingSystem == "linux") {
- Expect.equals(2, e.osError.errorCode);
- } else if (Platform.operatingSystem == "macos") {
- Expect.equals(2, e.osError.errorCode);
- } else if (Platform.operatingSystem == "windows") {
- Expect.equals(3, e.osError.errorCode);
- }
+ // File not not found has error code 2 on all supported platforms.
+ Expect.equals(2, e.osError.errorCode);
return true;
}
diff --git a/tests/standalone/io/directory_invalid_arguments_test.dart b/tests/standalone/io/directory_invalid_arguments_test.dart
index 54cdfda..29f96c8 100644
--- a/tests/standalone/io/directory_invalid_arguments_test.dart
+++ b/tests/standalone/io/directory_invalid_arguments_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/directory_list_nonexistent_test.dart b/tests/standalone/io/directory_list_nonexistent_test.dart
index 3ee62ac..1e58f63 100644
--- a/tests/standalone/io/directory_list_nonexistent_test.dart
+++ b/tests/standalone/io/directory_list_nonexistent_test.dart
@@ -7,6 +7,7 @@
// TODO(7157): Merge this test into directory_test.dart testListNonExistent()
// when it no longer crashes on Windows, when issue 7157 is resolved.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/directory_non_ascii_sync_test.dart b/tests/standalone/io/directory_non_ascii_sync_test.dart
index 3932731..f73225f 100644
--- a/tests/standalone/io/directory_non_ascii_sync_test.dart
+++ b/tests/standalone/io/directory_non_ascii_sync_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
main() {
diff --git a/tests/standalone/io/directory_non_ascii_test.dart b/tests/standalone/io/directory_non_ascii_test.dart
index 2745086..9fe3ef0 100644
--- a/tests/standalone/io/directory_non_ascii_test.dart
+++ b/tests/standalone/io/directory_non_ascii_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/io/directory_test.dart b/tests/standalone/io/directory_test.dart
index db5903d..decf05d 100644
--- a/tests/standalone/io/directory_test.dart
+++ b/tests/standalone/io/directory_test.dart
@@ -4,6 +4,7 @@
//
// Directory listing test.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/echo_server_stream_test.dart b/tests/standalone/io/echo_server_stream_test.dart
index 6cd0f37..dfd264d 100644
--- a/tests/standalone/io/echo_server_stream_test.dart
+++ b/tests/standalone/io/echo_server_stream_test.dart
@@ -11,6 +11,7 @@
library ServerTest;
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
part "testing_server.dart";
@@ -63,7 +64,7 @@
_socket.listen(onData,
onError: errorHandler,
onDone: onClosed);
- _socket.writeBytes(_buffer);
+ _socket.add(_buffer);
_socket.close();
data = new List<int>(MSGSIZE);
}
@@ -120,7 +121,7 @@
Expect.equals(EchoServerGame.FIRSTCHAR + i, buffer[i]);
}
if (offset == MSGSIZE) {
- connection.writeBytes(buffer);
+ connection.add(buffer);
connection.close();
}
}
diff --git a/tests/standalone/io/file_constructor_test.dart b/tests/standalone/io/file_constructor_test.dart
index f347b70..4ed7bb7 100644
--- a/tests/standalone/io/file_constructor_test.dart
+++ b/tests/standalone/io/file_constructor_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
void main() {
diff --git a/tests/standalone/io/file_error_test.dart b/tests/standalone/io/file_error_test.dart
index f026d16..e1741fd 100644
--- a/tests/standalone/io/file_error_test.dart
+++ b/tests/standalone/io/file_error_test.dart
@@ -4,6 +4,7 @@
//
// Dart test program for testing error handling in file I/O.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/file_input_stream_test.dart b/tests/standalone/io/file_input_stream_test.dart
index b25bfc1..93c9deb 100644
--- a/tests/standalone/io/file_input_stream_test.dart
+++ b/tests/standalone/io/file_input_stream_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Testing file input stream, VM-only, standalone test.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/file_invalid_arguments_test.dart b/tests/standalone/io/file_invalid_arguments_test.dart
index 515271c..1406290 100644
--- a/tests/standalone/io/file_invalid_arguments_test.dart
+++ b/tests/standalone/io/file_invalid_arguments_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/file_non_ascii_sync_test.dart b/tests/standalone/io/file_non_ascii_sync_test.dart
index 19bf7aa..23290e3 100644
--- a/tests/standalone/io/file_non_ascii_sync_test.dart
+++ b/tests/standalone/io/file_non_ascii_sync_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
main() {
diff --git a/tests/standalone/io/file_non_ascii_test.dart b/tests/standalone/io/file_non_ascii_test.dart
index 98b8336..3bdc939 100644
--- a/tests/standalone/io/file_non_ascii_test.dart
+++ b/tests/standalone/io/file_non_ascii_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/io/file_output_stream_test.dart b/tests/standalone/io/file_output_stream_test.dart
index b1d81fc..f71c962 100644
--- a/tests/standalone/io/file_output_stream_test.dart
+++ b/tests/standalone/io/file_output_stream_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// Testing file input stream, VM-only, standalone test.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
@@ -21,7 +22,7 @@
file.createSync();
IOSink x = file.openWrite();
var data = [65, 66, 67];
- x.writeBytes(data);
+ x.add(data);
x.close();
x.done.then((_) {
Expect.listEquals(file.readAsBytesSync(), data);
diff --git a/tests/standalone/io/file_read_special_device_test.dart b/tests/standalone/io/file_read_special_device_test.dart
index 3855395..1ea10e9 100644
--- a/tests/standalone/io/file_read_special_device_test.dart
+++ b/tests/standalone/io/file_read_special_device_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import 'dart:io';
void openAndWriteScript(String script) {
diff --git a/tests/standalone/io/file_read_stdio_script.dart b/tests/standalone/io/file_read_stdio_script.dart
index 0c58343..b2043ff 100644
--- a/tests/standalone/io/file_read_stdio_script.dart
+++ b/tests/standalone/io/file_read_stdio_script.dart
@@ -7,5 +7,7 @@
void main() {
var expected = new File(new Options().script).readAsStringSync();
var stdin = new File('/dev/fd/0').readAsStringSync();
- Expect.equals(expected, stdin);
+ if (expected != stdin) {
+ throw "stdin not equal expected file";
+ }
}
diff --git a/tests/standalone/io/file_system_delete_test.dart b/tests/standalone/io/file_system_delete_test.dart
new file mode 100644
index 0000000..84847bf
--- /dev/null
+++ b/tests/standalone/io/file_system_delete_test.dart
@@ -0,0 +1,407 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "dart:async";
+import "dart:io";
+
+Future throws(callback()) {
+ return new Future.immediate(null)
+ .then((_) => callback())
+ .then((_) { throw "Expected error"; },
+ onError: (_) {});
+}
+
+void testDeleteFileSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var file = new File("${path}myFile");
+
+ file.createSync();
+
+ Expect.isTrue(file.existsSync());
+ new File(file.path).deleteSync();
+ Expect.isFalse(file.existsSync());
+
+ file.createSync();
+
+ Expect.isTrue(file.existsSync());
+ new Directory(file.path).deleteSync(recursive: true);
+ Expect.isFalse(file.existsSync());
+
+ file.createSync();
+
+ Expect.isTrue(file.existsSync());
+ Expect.throws(() => new Directory(file.path).deleteSync());
+ Expect.isTrue(file.existsSync());
+
+ Expect.isTrue(file.existsSync());
+ Expect.throws(() => new Link(file.path).deleteSync());
+ Expect.isTrue(file.existsSync());
+
+ file.deleteSync();
+ Expect.isFalse(file.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDeleteFile() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var file = new File("${path}myFile");
+ return file.create()
+ .then((_) => file.exists().then(Expect.isTrue))
+ .then((_) => new File(file.path).delete())
+ .then((_) => file.exists().then(Expect.isFalse))
+
+ .then((_) => file.create())
+
+ .then((_) => file.exists().then(Expect.isTrue))
+ .then((_) => new Directory(file.path).delete(recursive: true))
+ .then((_) => file.exists().then(Expect.isFalse))
+
+ .then((_) => file.create())
+
+ .then((_) => file.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new Directory(file.path).delete()))
+ .then((_) => file.exists().then(Expect.isTrue))
+
+ .then((_) => file.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new Link(file.path).delete()))
+ .then((_) => file.exists().then(Expect.isTrue))
+
+ .then((_) => file.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void testDeleteDirectorySync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var dir = new Directory("${path}myDirectory");
+
+ dir.createSync();
+
+ Expect.isTrue(dir.existsSync());
+ new Directory(dir.path).deleteSync();
+ Expect.isFalse(dir.existsSync());
+
+ dir.createSync();
+
+ Expect.isTrue(dir.existsSync());
+ new Directory(dir.path).deleteSync(recursive: true);
+ Expect.isFalse(dir.existsSync());
+
+ dir.createSync();
+
+ Expect.isTrue(dir.existsSync());
+ Expect.throws(() => new File(dir.path).deleteSync());
+ Expect.isTrue(dir.existsSync());
+
+ Expect.isTrue(dir.existsSync());
+ Expect.throws(() => new Link(dir.path).deleteSync());
+ Expect.isTrue(dir.existsSync());
+
+ dir.deleteSync();
+ Expect.isFalse(dir.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDeleteDirectory() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var dir = new Directory("${path}myDirectory");
+ return dir.create()
+ .then((_) => dir.exists().then(Expect.isTrue))
+ .then((_) => new Directory(dir.path).delete())
+ .then((_) => dir.exists().then(Expect.isFalse))
+
+ .then((_) => dir.create())
+
+ .then((_) => dir.exists().then(Expect.isTrue))
+ .then((_) => new Directory(dir.path).delete(recursive: true))
+ .then((_) => dir.exists().then(Expect.isFalse))
+
+ .then((_) => dir.create())
+
+ .then((_) => dir.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new File(dir.path).delete()))
+ .then((_) => dir.exists().then(Expect.isTrue))
+
+ .then((_) => dir.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new Link(dir.path).delete()))
+ .then((_) => dir.exists().then(Expect.isTrue))
+
+ .then((_) => dir.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void testDeleteFileLinkSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var file = new File("${path}myFile");
+ file.createSync();
+
+ var link = new Link("${path}myLink");
+
+ link.createSync(file.path);
+
+ Expect.isTrue(link.existsSync());
+ new File(link.path).deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ link.createSync(file.path);
+
+ Expect.isTrue(link.existsSync());
+ new Link(link.path).deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ link.createSync(file.path);
+
+ Expect.isTrue(link.existsSync());
+ new Directory(link.path).deleteSync(recursive: true);
+ Expect.isFalse(link.existsSync());
+
+ link.createSync(file.path);
+
+ Expect.isTrue(link.existsSync());
+ Expect.throws(() => new Directory(link.path).deleteSync());
+ Expect.isTrue(link.existsSync());
+
+ link.deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ Expect.isTrue(file.existsSync());
+ file.deleteSync();
+ Expect.isFalse(file.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDeleteFileLink() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var file = new File("${path}myFile");
+ var link = new Link("${path}myLink");
+ return file.create()
+ .then((_) => link.create(file.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new File(link.path).delete())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => link.create(file.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Link(link.path).delete())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => link.create(file.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Directory(link.path).delete(recursive: true))
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => link.create(file.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new Directory(link.path).delete()))
+ .then((_) => link.exists().then(Expect.isTrue))
+
+ .then((_) => link.deleteSync())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => file.exists().then(Expect.isTrue))
+ .then((_) => file.delete())
+ .then((_) => file.exists().then(Expect.isFalse))
+
+ .then((_) => tmp.delete());
+ });
+}
+
+void testDeleteDirectoryLinkSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var directory = new Directory("${path}myDirectory");
+ directory.createSync();
+
+ var link = new Link("${path}myLink");
+
+ link.createSync(directory.path);
+
+ Expect.isTrue(link.existsSync());
+ new Link(link.path).deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ link.createSync(directory.path);
+
+ Expect.isTrue(link.existsSync());
+ new Directory(link.path).deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ link.createSync(directory.path);
+
+ Expect.isTrue(link.existsSync());
+ new Directory(link.path).deleteSync(recursive: true);
+ Expect.isFalse(link.existsSync());
+
+ link.createSync(directory.path);
+
+ Expect.isTrue(link.existsSync());
+ Expect.throws(() => new File(link.path).deleteSync());
+ Expect.isTrue(link.existsSync());
+
+ link.deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ Expect.isTrue(directory.existsSync());
+ directory.deleteSync();
+ Expect.isFalse(directory.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDeleteDirectoryLink() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var dir = new Directory("${path}myDir");
+ var link = new Link("${path}myLink");
+ return dir.create()
+ .then((_) => link.create(dir.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Directory(link.path).delete())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => link.create(dir.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Directory(link.path).delete(recursive: true))
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => link.create(dir.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Link(link.path).delete())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => link.create(dir.path))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new File(link.path).delete()))
+ .then((_) => link.exists().then(Expect.isTrue))
+
+ .then((_) => link.deleteSync())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => dir.exists().then(Expect.isTrue))
+ .then((_) => dir.delete())
+ .then((_) => dir.exists().then(Expect.isFalse))
+
+ .then((_) => tmp.delete());
+ });
+}
+
+void testDeleteBrokenLinkSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var directory = new Directory("${path}myDirectory");
+ directory.createSync();
+
+ var link = new Link("${path}myLink");
+
+ link.createSync(directory.path);
+ directory.deleteSync();
+
+ Expect.isTrue(link.existsSync());
+ new Link(link.path).deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ directory.createSync();
+ link.createSync(directory.path);
+ directory.deleteSync();
+
+ Expect.isTrue(link.existsSync());
+ new Directory(link.path).deleteSync(recursive: true);
+ Expect.isFalse(link.existsSync());
+
+ directory.createSync();
+ link.createSync(directory.path);
+ directory.deleteSync();
+
+ Expect.isTrue(link.existsSync());
+ Expect.throws(() => new Directory(link.path).deleteSync());
+ Expect.isTrue(link.existsSync());
+
+ Expect.isTrue(link.existsSync());
+ Expect.throws(() => new File(link.path).deleteSync());
+ Expect.isTrue(link.existsSync());
+
+ link.deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDeleteBrokenLink() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var dir = new Directory("${path}myDir");
+ var link = new Link("${path}myLink");
+ return dir.create()
+ .then((_) => link.create(dir.path))
+ .then((_) => dir.delete())
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Link(link.path).delete())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => dir.create())
+ .then((_) => link.create(dir.path))
+ .then((_) => dir.delete())
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => new Directory(link.path).delete(recursive: true))
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => dir.create())
+ .then((_) => link.create(dir.path))
+ .then((_) => dir.delete())
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new Directory(link.path).delete()))
+ .then((_) => link.exists().then(Expect.isTrue))
+
+ .then((_) => link.exists().then(Expect.isTrue))
+ .then((_) => throws(() => new File(link.path).delete()))
+ .then((_) => link.exists().then(Expect.isTrue))
+
+ .then((_) => link.deleteSync())
+ .then((_) => link.exists().then(Expect.isFalse))
+
+ .then((_) => tmp.delete());
+ });
+}
+
+void main() {
+ testDeleteFileSync();
+ testDeleteFile();
+ testDeleteDirectorySync();
+ testDeleteDirectory();
+ if (Platform.operatingSystem != 'windows') {
+ testDeleteFileLinkSync();
+ testDeleteFileLink();
+ }
+ testDeleteDirectoryLinkSync();
+ testDeleteDirectoryLink();
+ testDeleteBrokenLinkSync();
+ testDeleteBrokenLink();
+}
diff --git a/tests/standalone/io/file_system_exists_test.dart b/tests/standalone/io/file_system_exists_test.dart
new file mode 100644
index 0000000..a87bdd1
--- /dev/null
+++ b/tests/standalone/io/file_system_exists_test.dart
@@ -0,0 +1,205 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "dart:io";
+
+void testFileExistsSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var file = new File("${path}myFile");
+ file.createSync();
+
+ Expect.isTrue(new File(file.path).existsSync());
+ Expect.isFalse(new Directory(file.path).existsSync());
+ Expect.isFalse(new Link(file.path).existsSync());
+
+ file.deleteSync();
+ Expect.isFalse(file.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testFileExists() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var file = new File("${path}myFile");
+ return file.create()
+ .then((_) => new File(file.path).exists().then(Expect.isTrue))
+ .then((_) => new Directory(file.path).exists().then(Expect.isFalse))
+ .then((_) => new Link(file.path).exists().then(Expect.isFalse))
+
+ .then((_) => file.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void testDirectoryExistsSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var dir = new Directory("${path}myDirectory");
+ dir.createSync();
+
+ Expect.isFalse(new File(dir.path).existsSync());
+ Expect.isTrue(new Directory(dir.path).existsSync());
+ Expect.isFalse(new Link(dir.path).existsSync());
+
+ dir.deleteSync();
+ Expect.isFalse(dir.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDirectoryExists() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var dir = new Directory("${path}myDirectory");
+ return dir.create()
+ .then((_) => new File(dir.path).exists().then(Expect.isFalse))
+ .then((_) => new Directory(dir.path).exists().then(Expect.isTrue))
+ .then((_) => new Link(dir.path).exists().then(Expect.isFalse))
+
+ .then((_) => dir.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void testFileLinkExistsSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var file = new File("${path}myFile");
+ file.createSync();
+
+ var link = new Link("${path}myLink");
+ link.createSync(file.path);
+
+ Expect.isTrue(new File(link.path).existsSync());
+ Expect.isFalse(new Directory(link.path).existsSync());
+ Expect.isTrue(new Link(link.path).existsSync());
+
+ link.deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ file.deleteSync();
+ Expect.isFalse(file.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testFileLinkExists() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var file = new File("${path}myFile");
+ var link = new Link("${path}myLink");
+ return file.create()
+ .then((_) => link.create(file.path))
+
+ .then((_) => new File(link.path).exists().then(Expect.isTrue))
+ .then((_) => new Directory(link.path).exists().then(Expect.isFalse))
+ .then((_) => new Link(link.path).exists().then(Expect.isTrue))
+
+ .then((_) => link.delete())
+ .then((_) => file.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void testDirectoryLinkExistsSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var directory = new Directory("${path}myDirectory");
+ directory.createSync();
+
+ var link = new Link("${path}myLink");
+ link.createSync(directory.path);
+
+ Expect.isFalse(new File(link.path).existsSync());
+ Expect.isTrue(new Directory(link.path).existsSync());
+ Expect.isTrue(new Link(link.path).existsSync());
+
+ link.deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ directory.deleteSync();
+ Expect.isFalse(directory.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testDirectoryLinkExists() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var dir = new Directory("${path}myDir");
+ var link = new Link("${path}myLink");
+ return dir.create()
+ .then((_) => link.create(dir.path))
+
+ .then((_) => new File(link.path).exists().then(Expect.isFalse))
+ .then((_) => new Directory(link.path).exists().then(Expect.isTrue))
+ .then((_) => new Link(link.path).exists().then(Expect.isTrue))
+
+ .then((_) => link.delete())
+ .then((_) => dir.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void testBrokenLinkExistsSync() {
+ var tmp = new Directory("").createTempSync();
+ var path = "${tmp.path}${Platform.pathSeparator}";
+
+ var directory = new Directory("${path}myDirectory");
+ directory.createSync();
+
+ var link = new Link("${path}myLink");
+ link.createSync(directory.path);
+ directory.deleteSync();
+
+ Expect.isFalse(new File(link.path).existsSync());
+ Expect.isFalse(new Directory(link.path).existsSync());
+ Expect.isTrue(new Link(link.path).existsSync());
+
+ link.deleteSync();
+ Expect.isFalse(link.existsSync());
+
+ tmp.deleteSync();
+}
+
+void testBrokenLinkExists() {
+ new Directory("").createTemp().then((tmp) {
+ var path = "${tmp.path}${Platform.pathSeparator}";
+ var dir = new Directory("${path}myDir");
+ var link = new Link("${path}myLink");
+ return dir.create()
+ .then((_) => link.create(dir.path))
+ .then((_) => dir.delete())
+
+ .then((_) => new File(link.path).exists().then(Expect.isFalse))
+ .then((_) => new Directory(link.path).exists().then(Expect.isFalse))
+ .then((_) => new Link(link.path).exists().then(Expect.isTrue))
+
+ .then((_) => link.delete())
+ .then((_) => tmp.delete());
+ });
+}
+
+void main() {
+ testFileExistsSync();
+ testFileExists();
+ testDirectoryExistsSync();
+ testDirectoryExists();
+ if (Platform.operatingSystem != 'windows') {
+ testFileLinkExistsSync();
+ testFileLinkExists();
+ }
+ testDirectoryLinkExistsSync();
+ testDirectoryLinkExists();
+ testBrokenLinkExistsSync();
+ testBrokenLinkExists();
+}
+
diff --git a/tests/standalone/io/file_system_links_test.dart b/tests/standalone/io/file_system_links_test.dart
index 7c3cdc7..2230c07 100644
--- a/tests/standalone/io/file_system_links_test.dart
+++ b/tests/standalone/io/file_system_links_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
@@ -57,7 +58,7 @@
FileSystemEntity.typeSync(x, followLinks: false));
Expect.equals(x, new Link(y).targetSync());
- new File(y).deleteSync();
+ new Link(y).deleteSync();
Expect.isFalse(FileSystemEntity.isLinkSync(y));
Expect.isFalse(FileSystemEntity.isLinkSync(x));
Expect.equals(FileSystemEntityType.NOT_FOUND, FileSystemEntity.typeSync(y));
@@ -100,7 +101,7 @@
createLink(x, y, () {
var data = "asdf".codeUnits;
var output = new File(y).openWrite(mode: FileMode.WRITE);
- output.writeBytes(data);
+ output.add(data);
output.close();
output.done.then((_) {
var read = new File(y).readAsBytesSync();
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index 1583d7f..a4dc4ec 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -4,6 +4,7 @@
//
// Dart test program for testing file I/O.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
@@ -91,7 +92,7 @@
tempDirectory.path + "/out_read_write_stream";
var file2 = new File(outFilename);
var output = file2.openWrite();
- output.writeBytes(buffer);
+ output.add(buffer);
output.close();
output.done.then((_) {
// Now read the contents of the file just written.
@@ -129,8 +130,8 @@
tempDirectory.path + "/out_read_write_stream_large_file";
File file = new File(filename);
IOSink output = file.openWrite();
- output.writeBytes(buffer);
- output.writeBytes(buffer);
+ output.add(buffer);
+ output.add(buffer);
output.close();
output.done.then((_) {
Stream input = file.openRead();
@@ -200,7 +201,7 @@
// Read a file and check part of it's contents.
String filename = getFilename("bin/file_test.cc");
File file = new File(filename);
- file.open(mode: FileMode.READ).then((RandomAccessFile file) {
+ file.open(mode: READ).then((RandomAccessFile file) {
List<int> buffer = new List<int>(10);
file.readList(buffer, 0, 5).then((bytes_read) {
Expect.equals(5, bytes_read);
@@ -262,7 +263,7 @@
// Read a file.
String inFilename = getFilename("tests/vm/data/fixed_length_file");
final File file = new File(inFilename);
- file.open(mode: FileMode.READ).then((openedFile) {
+ file.open(mode: READ).then((openedFile) {
List<int> buffer1 = new List<int>(42);
openedFile.readList(buffer1, 0, 42).then((bytes_read) {
Expect.equals(42, bytes_read);
@@ -276,12 +277,12 @@
if (s[0] != '/' && s[0] != '\\' && s[1] != ':') {
Expect.fail("Not a full path");
}
- file2.open(mode: FileMode.WRITE).then((openedFile2) {
+ file2.open(mode: WRITE).then((openedFile2) {
openedFile2.writeList(buffer1, 0, bytes_read).then((ignore) {
openedFile2.close().then((ignore) {
List<int> buffer2 = new List<int>(bytes_read);
final File file3 = new File(outFilename);
- file3.open(mode: FileMode.READ).then((openedFile3) {
+ file3.open(mode: READ).then((openedFile3) {
openedFile3.readList(buffer2, 0, 42).then((bytes_read) {
Expect.equals(42, bytes_read);
openedFile3.close().then((ignore) {
@@ -320,17 +321,17 @@
file.createSync();
Expect.isTrue(new File(filename).existsSync());
List<int> buffer = content.codeUnits;
- RandomAccessFile openedFile = file.openSync(mode: FileMode.WRITE);
+ RandomAccessFile openedFile = file.openSync(mode: WRITE);
openedFile.writeListSync(buffer, 0, buffer.length);
openedFile.closeSync();
// Reopen the file in write mode to ensure that we overwrite the content.
- openedFile = (new File(filename)).openSync(mode: FileMode.WRITE);
+ openedFile = (new File(filename)).openSync(mode: WRITE);
openedFile.writeListSync(buffer, 0, buffer.length);
Expect.equals(content.length, openedFile.lengthSync());
openedFile.closeSync();
// Open the file in append mode and ensure that we do not overwrite
// the existing content.
- openedFile = (new File(filename)).openSync(mode: FileMode.APPEND);
+ openedFile = (new File(filename)).openSync(mode: APPEND);
openedFile.writeListSync(buffer, 0, buffer.length);
Expect.equals(content.length * 2, openedFile.lengthSync());
openedFile.closeSync();
@@ -344,16 +345,16 @@
file.createSync();
List<int> buffer = content.codeUnits;
var output = file.openWrite();
- output.writeBytes(buffer);
+ output.add(buffer);
output.close();
output.done.then((_) {
File file2 = new File(filename);
- var appendingOutput = file2.openWrite(mode: FileMode.APPEND);
- appendingOutput.writeBytes(buffer);
+ var appendingOutput = file2.openWrite(mode: APPEND);
+ appendingOutput.add(buffer);
appendingOutput.close();
appendingOutput.done.then((_) {
File file3 = new File(filename);
- file3.open(mode: FileMode.READ).then((RandomAccessFile openedFile) {
+ file3.open(mode: READ).then((RandomAccessFile openedFile) {
openedFile.length().then((int length) {
Expect.equals(content.length * 2, length);
openedFile.close().then((ignore) {
@@ -377,13 +378,13 @@
List<int> buffer = content.codeUnits;
var output = file.openWrite();
output.write("abcdABCD");
- output.encoding = Encoding.UTF_8;
+ output.encoding = UTF_8;
output.write("abcdABCD");
- output.encoding = Encoding.ISO_8859_1;
+ output.encoding = ISO_8859_1;
output.write("abcdABCD");
- output.encoding = Encoding.ASCII;
+ output.encoding = ASCII;
output.write("abcdABCD");
- output.encoding = Encoding.UTF_8;
+ output.encoding = UTF_8;
output.write("æøå");
output.close();
output.done.then((_) {
@@ -416,7 +417,7 @@
Expect.fail("Not a full path");
}
Expect.isTrue(new File(path).existsSync());
- RandomAccessFile openedFile = outFile.openSync(mode: FileMode.WRITE);
+ RandomAccessFile openedFile = outFile.openSync(mode: WRITE);
openedFile.writeListSync(buffer1, 0, bytes_read);
openedFile.closeSync();
// Now read the contents of the file just written.
@@ -450,7 +451,7 @@
File file = new File(fileName);
asyncTestStarted();
file.create().then((ignore) {
- file.open(mode: FileMode.READ).then((RandomAccessFile openedFile) {
+ file.open(mode: READ).then((RandomAccessFile openedFile) {
var readByteFuture = openedFile.readByte();
readByteFuture.then((int byte) {
Expect.equals(-1, byte);
@@ -468,7 +469,7 @@
final String fileName = "${tempDirectory.path}/testWriteVariousLists";
final File file = new File(fileName);
file.create().then((ignore) {
- file.open(mode: FileMode.WRITE).then((RandomAccessFile openedFile) {
+ file.open(mode: WRITE).then((RandomAccessFile openedFile) {
// Write bytes from 0 to 7.
openedFile.writeList([0], 0, 1);
openedFile.writeList(const [1], 0, 1);
@@ -629,7 +630,7 @@
static void testTruncate() {
File file = new File(tempDirectory.path + "/out_truncate");
List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65];
- file.open(mode: FileMode.WRITE).then((RandomAccessFile openedFile) {
+ file.open(mode: WRITE).then((RandomAccessFile openedFile) {
openedFile.writeList(buffer, 0, 10).then((ignore) {
openedFile.length().then((length) {
Expect.equals(10, length);
@@ -655,7 +656,7 @@
static void testTruncateSync() {
File file = new File(tempDirectory.path + "/out_truncate_sync");
List buffer = const [65, 65, 65, 65, 65, 65, 65, 65, 65, 65];
- RandomAccessFile openedFile = file.openSync(mode: FileMode.WRITE);
+ RandomAccessFile openedFile = file.openSync(mode: WRITE);
openedFile.writeListSync(buffer, 0, 10);
Expect.equals(10, openedFile.lengthSync());
openedFile.truncateSync(5);
@@ -670,7 +671,7 @@
bool exceptionCaught = false;
bool wrongExceptionCaught = false;
File input = new File(tempDirectory.path + "/out_close_exception");
- RandomAccessFile openedFile = input.openSync(mode: FileMode.WRITE);
+ RandomAccessFile openedFile = input.openSync(mode: WRITE);
openedFile.closeSync();
try {
openedFile.readByteSync();
@@ -765,7 +766,7 @@
file.createSync();
var output = file.openWrite();
output.close();
- Expect.throws(() => output.writeBytes(buffer));
+ Expect.throws(() => output.add(buffer));
output.done.then((_) {
file.deleteSync();
asyncTestDone("testCloseExceptionStream");
@@ -778,7 +779,7 @@
bool wrongExceptionCaught = false;
File file =
new File(tempDirectory.path + "/out_buffer_out_of_bounds");
- RandomAccessFile openedFile = file.openSync(mode: FileMode.WRITE);
+ RandomAccessFile openedFile = file.openSync(mode: WRITE);
try {
List<int> buffer = new List<int>(10);
openedFile.readListSync(buffer, 0, 12);
@@ -872,7 +873,7 @@
static void testOpenDirectoryAsFile() {
var f = new File('.');
- var future = f.open(mode: FileMode.READ);
+ var future = f.open(mode: READ);
future.then((r) => Expect.fail('Directory opened as file'))
.catchError((e) {});
}
@@ -947,20 +948,20 @@
});
var name = getFilename("tests/vm/data/fixed_length_file");
var f = new File(name);
- f.readAsString(encoding: Encoding.UTF_8).then((text) {
+ f.readAsString(encoding: UTF_8).then((text) {
Expect.isTrue(text.endsWith("42 bytes."));
Expect.equals(42, text.length);
var name = getDataFilename("tests/standalone/io/read_as_text.dat");
var f = new File(name);
- f.readAsString(encoding: Encoding.UTF_8).then((text) {
+ f.readAsString(encoding: UTF_8).then((text) {
Expect.equals(6, text.length);
var expected = [955, 120, 46, 32, 120, 10];
Expect.listEquals(expected, text.codeUnits);
- f.readAsString(encoding: Encoding.ISO_8859_1).then((text) {
+ f.readAsString(encoding: ISO_8859_1).then((text) {
Expect.equals(7, text.length);
var expected = [206, 187, 120, 46, 32, 120, 10];
Expect.listEquals(expected, text.codeUnits);
- var readAsStringFuture = f.readAsString(encoding: Encoding.ASCII);
+ var readAsStringFuture = f.readAsString(encoding: ASCII);
readAsStringFuture.then((text) {
Expect.fail("Non-ascii char should cause error");
}).catchError((e) {
@@ -979,7 +980,7 @@
});
var name = getFilename("tests/vm/data/empty_file");
var f = new File(name);
- f.readAsString(encoding: Encoding.UTF_8).then((text) {
+ f.readAsString(encoding: UTF_8).then((text) {
port.toSendPort().send(text.length);
return true;
});
@@ -995,11 +996,11 @@
Expect.equals(6, text.length);
var expected = [955, 120, 46, 32, 120, 10];
Expect.listEquals(expected, text.codeUnits);
- text = new File(name).readAsStringSync(encoding: Encoding.ASCII);
+ text = new File(name).readAsStringSync(encoding: ASCII);
// Default replacement character is '?', char code 63.
expected = [63, 63, 120, 46, 32, 120, 10];
Expect.listEquals(expected, text.codeUnits);
- text = new File(name).readAsStringSync(encoding: Encoding.ISO_8859_1);
+ text = new File(name).readAsStringSync(encoding: ISO_8859_1);
expected = [206, 187, 120, 46, 32, 120, 10];
Expect.equals(7, text.length);
Expect.listEquals(expected, text.codeUnits);
@@ -1019,7 +1020,7 @@
});
var name = getFilename("tests/vm/data/fixed_length_file");
var f = new File(name);
- f.readAsLines(encoding: Encoding.UTF_8).then((lines) {
+ f.readAsLines(encoding: UTF_8).then((lines) {
Expect.equals(1, lines.length);
var line = lines[0];
Expect.isTrue(line.endsWith("42 bytes."));
@@ -1053,10 +1054,10 @@
var readAsBytesFuture = f.readAsBytes();
readAsBytesFuture.then((bytes) => Expect.fail("no bytes expected"))
.catchError((e) {
- var readAsStringFuture = f.readAsString(encoding: Encoding.UTF_8);
+ var readAsStringFuture = f.readAsString(encoding: UTF_8);
readAsStringFuture.then((text) => Expect.fail("no text expected"))
.catchError((e) {
- var readAsLinesFuture = f.readAsLines(encoding: Encoding.UTF_8);
+ var readAsLinesFuture = f.readAsLines(encoding: UTF_8);
readAsLinesFuture.then((lines) => Expect.fail("no lines expected"))
.catchError((e) {
port.toSendPort().send(1);
@@ -1069,7 +1070,7 @@
var port = new ReceivePort();
new File(new Options().executable).lastModified().then((modified) {
Expect.isTrue(modified is DateTime);
- Expect.isTrue(modified < new DateTime.now());
+ Expect.isTrue(modified.isBefore(new DateTime.now()));
port.close();
});
}
@@ -1077,17 +1078,17 @@
static void testLastModifiedSync() {
var modified = new File(new Options().executable).lastModifiedSync();
Expect.isTrue(modified is DateTime);
- Expect.isTrue(modified < new DateTime.now());
+ Expect.isTrue(modified.isBefore(new DateTime.now()));
}
// Test that opens the same file for writing then for appending to test
// that the file is not truncated when opened for appending.
static void testAppend() {
var file = new File('${tempDirectory.path}/out_append');
- file.open(mode: FileMode.WRITE).then((openedFile) {
+ file.open(mode: WRITE).then((openedFile) {
openedFile.writeString("asdf").then((ignore) {
openedFile.close().then((ignore) {
- file.open(mode: FileMode.APPEND).then((openedFile) {
+ file.open(mode: APPEND).then((openedFile) {
openedFile.length().then((length) {
Expect.equals(4, length);
openedFile.writeString("asdf").then((ignore) {
@@ -1113,11 +1114,11 @@
static void testAppendSync() {
var file = new File('${tempDirectory.path}/out_append_sync');
- var openedFile = file.openSync(mode: FileMode.WRITE);
+ var openedFile = file.openSync(mode: WRITE);
openedFile.writeStringSync("asdf");
Expect.equals(4, openedFile.lengthSync());
openedFile.closeSync();
- openedFile = file.openSync(mode: FileMode.WRITE);
+ openedFile = file.openSync(mode: WRITE);
openedFile.setPositionSync(4);
openedFile.writeStringSync("asdf");
Expect.equals(8, openedFile.lengthSync());
@@ -1129,12 +1130,12 @@
static void testWriteStringUtf8() {
var file = new File('${tempDirectory.path}/out_write_string');
var string = new String.fromCharCodes([0x192]);
- file.open(mode: FileMode.WRITE).then((openedFile) {
+ file.open(mode: WRITE).then((openedFile) {
openedFile.writeString(string).then((_) {
openedFile.length().then((l) {
Expect.equals(2, l);
openedFile.close().then((_) {
- file.open(mode: FileMode.APPEND).then((openedFile) {
+ file.open(mode: APPEND).then((openedFile) {
openedFile.setPosition(2).then((_) {
openedFile.writeString(string).then((_) {
openedFile.length().then((l) {
@@ -1164,11 +1165,11 @@
static void testWriteStringUtf8Sync() {
var file = new File('${tempDirectory.path}/out_write_string_sync');
var string = new String.fromCharCodes([0x192]);
- var openedFile = file.openSync(mode: FileMode.WRITE);
+ var openedFile = file.openSync(mode: WRITE);
openedFile.writeStringSync(string);
Expect.equals(2, openedFile.lengthSync());
openedFile.closeSync();
- openedFile = file.openSync(mode: FileMode.APPEND);
+ openedFile = file.openSync(mode: APPEND);
openedFile.setPositionSync(2);
openedFile.writeStringSync(string);
Expect.equals(4, openedFile.lengthSync());
diff --git a/tests/standalone/io/file_typed_data_test.dart b/tests/standalone/io/file_typed_data_test.dart
new file mode 100644
index 0000000..027c191
--- /dev/null
+++ b/tests/standalone/io/file_typed_data_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// Dart test program for testing file I/O.
+
+import "package:expect/expect.dart";
+import 'dart:async';
+import 'dart:io';
+import 'dart:isolate';
+import 'dart:typeddata';
+
+void testWriteUint8ListAndView() {
+ ReceivePort port = new ReceivePort();
+ Uint8List list = new Uint8List(8);
+ for (int i = 0; i < 8; i++) list[i] = i;
+ var view = new Uint8List.view(list.buffer, 2, 4);
+
+ new Directory('').createTemp().then((temp) {
+ var file = new File("${temp.path}/test");
+ file.open(mode: FileMode.WRITE).then((raf) {
+ return raf.writeList(list, 0, 8);
+ }).then((raf) {
+ return raf.writeList(view, 0, 4);
+ }).then((raf) {
+ return raf.close();
+ }).then((_) {
+ var expected = [];
+ expected.addAll(list);
+ expected.addAll(view);
+ var content = file.readAsBytesSync();
+ Expect.listEquals(expected, content);
+ temp.deleteSync(recursive: true);
+ port.close();
+ });
+ });
+}
+
+
+main() {
+ testWriteUint8ListAndView();
+}
diff --git a/tests/standalone/io/file_write_as_test.dart b/tests/standalone/io/file_write_as_test.dart
index 1932b70..3178bfe 100644
--- a/tests/standalone/io/file_write_as_test.dart
+++ b/tests/standalone/io/file_write_as_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/io/fuzz_support.dart b/tests/standalone/io/fuzz_support.dart
index e6caa12..e3a874e 100644
--- a/tests/standalone/io/fuzz_support.dart
+++ b/tests/standalone/io/fuzz_support.dart
@@ -4,6 +4,7 @@
library fuzz_support;
+import 'package:expect/expect.dart';
import 'dart:async';
import 'dart:io';
diff --git a/tests/standalone/io/http_10_test.dart b/tests/standalone/io/http_10_test.dart
index bf88a9a..0c79981 100644
--- a/tests/standalone/io/http_10_test.dart
+++ b/tests/standalone/io/http_10_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:isolate";
import "dart:io";
diff --git a/tests/standalone/io/http_advanced_test.dart b/tests/standalone/io/http_advanced_test.dart
index 56b51e8..1d4ca89 100644
--- a/tests/standalone/io/http_advanced_test.dart
+++ b/tests/standalone/io/http_advanced_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
@@ -123,7 +124,7 @@
// Set the "Expires" header using the expires property.
void _expires1Handler(HttpRequest request) {
var response = request.response;
- DateTime date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
+ DateTime date = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
response.headers.expires = date;
Expect.equals(date, response.headers.expires);
response.close();
@@ -133,7 +134,7 @@
void _expires2Handler(HttpRequest request) {
var response = request.response;
response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT");
- DateTime date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
+ DateTime date = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
Expect.equals(date, response.headers.expires);
response.close();
}
@@ -169,7 +170,7 @@
Expect.equals(0, request.cookies.length);
Cookie cookie1 = new Cookie("name1", "value1");
- DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0);
+ DateTime date = new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0);
cookie1.expires = date;
cookie1.domain = "www.example.com";
cookie1.httpOnly = true;
@@ -292,7 +293,7 @@
Expect.equals(HttpStatus.OK, response.statusCode);
Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT",
response.headers["expires"][0]);
- Expect.equals(new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0),
+ Expect.equals(new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0),
response.headers.expires);
response.listen((_) { },
onDone: () {
@@ -379,7 +380,7 @@
if (cookie.name == "name1") {
Expect.equals("value1", cookie.value);
DateTime date =
- new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0);
+ new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0);
Expect.equals(date, cookie.expires);
Expect.equals("www.example.com", cookie.domain);
Expect.isTrue(cookie.httpOnly);
diff --git a/tests/standalone/io/http_auth_test.dart b/tests/standalone/io/http_auth_test.dart
index d1a706a..bd5e2c0 100644
--- a/tests/standalone/io/http_auth_test.dart
+++ b/tests/standalone/io/http_auth_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:crypto';
import 'dart:io';
diff --git a/tests/standalone/io/http_basic_test.dart b/tests/standalone/io/http_basic_test.dart
index 670a649..9ebb389 100644
--- a/tests/standalone/io/http_basic_test.dart
+++ b/tests/standalone/io/http_basic_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:isolate";
import "dart:io";
diff --git a/tests/standalone/io/http_body_test.dart b/tests/standalone/io/http_body_test.dart
new file mode 100644
index 0000000..c25406e
--- /dev/null
+++ b/tests/standalone/io/http_body_test.dart
@@ -0,0 +1,161 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:utf';
+
+import 'package:expect/expect.dart';
+
+void testHttpClientResponseBody() {
+ new HttpBodyHandler();
+ void test(String mimeType,
+ List<int> content,
+ dynamic expectedBody,
+ String type,
+ [bool shouldFail = false]) {
+ HttpServer.bind().then((server) {
+ server.listen((request) {
+ request.listen(
+ (_) {},
+ onDone: () {
+ request.response.headers.contentType =
+ new ContentType.fromString(mimeType);
+ request.response.add(content);
+ request.response.close();
+ });
+ });
+
+ var client = new HttpClient();
+ client.get("127.0.0.1", server.port, "/")
+ .then((request) => request.close())
+ .then(HttpBodyHandler.processResponse)
+ .then((body) {
+ if (shouldFail) Expect.fail("Error expected");
+ Expect.equals(type, body.type);
+ switch (type) {
+ case "text":
+ Expect.equals(expectedBody, body.body);
+ break;
+
+ case "json":
+ Expect.mapEquals(expectedBody, body.body);
+ break;
+
+ default:
+ Expect.fail("bad body type");
+ }
+ }, onError: (error) {
+ if (!shouldFail) Expect.fail("Error unexpected");
+ })
+ .whenComplete(() {
+ client.close();
+ server.close();
+ });
+ });
+ }
+ test("text/plain", "body".codeUnits, "body", "text");
+ test("text/plain; charset=utf-8",
+ "body".codeUnits,
+ "body",
+ "text");
+ test("text/plain; charset=iso-8859-1",
+ "body".codeUnits,
+ "body",
+ "text");
+ test("text/plain; charset=us-ascii",
+ "body".codeUnits,
+ "body",
+ "text");
+ test("text/plain; charset=utf-8", [42], "*", "text");
+ test("text/plain; charset=us-ascii", [142], "?", "text");
+ test("text/plain; charset=utf-8",
+ [142],
+ new String.fromCharCodes([UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]),
+ "text");
+
+ test("application/json",
+ '{"val": 5}'.codeUnits,
+ { "val" : 5 },
+ "json");
+ test("application/json",
+ '{ bad json }'.codeUnits,
+ null,
+ "json",
+ true);
+}
+
+void testHttpServerRequestBody() {
+ void test(String mimeType,
+ List<int> content,
+ dynamic expectedBody,
+ String type,
+ [bool shouldFail = false]) {
+ HttpServer.bind().then((server) {
+ server.transform(new HttpBodyHandler())
+ .listen((body) {
+ if (shouldFail) Expect.fail("Error expected");
+ Expect.equals(type, body.type);
+ switch (type) {
+ case "text":
+ Expect.equals(expectedBody, body.body);
+ break;
+
+ case "json":
+ Expect.mapEquals(expectedBody, body.body);
+ break;
+
+ default:
+ Expect.fail("bad body type");
+ }
+ body.response.close();
+ }, onError: (error) {
+ if (!shouldFail) Expect.fail("Error unexpected");
+ });
+
+ var client = new HttpClient();
+ client.post("127.0.0.1", server.port, "/")
+ .then((request) {
+ request.headers.contentType =
+ new ContentType.fromString(mimeType);
+ request.add(content);
+ return request.close();
+ })
+ .then((response) {
+ if (shouldFail) {
+ Expect.equals(HttpStatus.BAD_REQUEST, response.statusCode);
+ }
+ response.fold(null, (x, y) {});
+ client.close();
+ server.close();
+ });
+ });
+ }
+ test("text/plain", "body".codeUnits, "body", "text");
+ test("text/plain; charset=utf-8",
+ "body".codeUnits,
+ "body",
+ "text");
+ test("text/plain; charset=utf-8", [42], "*", "text");
+ test("text/plain; charset=us-ascii", [142], "?", "text");
+ test("text/plain; charset=utf-8",
+ [142],
+ new String.fromCharCodes([UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]),
+ "text");
+
+ test("application/json",
+ '{"val": 5}'.codeUnits,
+ { "val" : 5 },
+ "json");
+ test("application/json",
+ '{ bad json }'.codeUnits,
+ null,
+ "json",
+ true);
+}
+
+
+void main() {
+ testHttpClientResponseBody();
+ testHttpServerRequestBody();
+}
diff --git a/tests/standalone/io/http_client_connect_test.dart b/tests/standalone/io/http_client_connect_test.dart
index 3f466dd..9c18e75 100644
--- a/tests/standalone/io/http_client_connect_test.dart
+++ b/tests/standalone/io/http_client_connect_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
@@ -32,7 +33,7 @@
HttpServer.bind().then((server) {
var data = "lalala".codeUnits;
server.listen((request) {
- request.response.writeBytes(data);
+ request.response.add(data);
request.pipe(request.response);
});
diff --git a/tests/standalone/io/http_client_exception_test.dart b/tests/standalone/io/http_client_exception_test.dart
index 65c0a41..0d2f1e3 100644
--- a/tests/standalone/io/http_client_exception_test.dart
+++ b/tests/standalone/io/http_client_exception_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
import "dart:uri";
diff --git a/tests/standalone/io/http_client_request_test.dart b/tests/standalone/io/http_client_request_test.dart
index b762a78..a9434d3 100644
--- a/tests/standalone/io/http_client_request_test.dart
+++ b/tests/standalone/io/http_client_request_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
import "dart:typeddata";
@@ -28,17 +29,18 @@
.catchError((error) {
server.close();
client.close();
- }, test: (e) => e is HttpParserException);
+ });
});
}
void testResponseDone() {
testClientRequest((request) {
- request.close();
- request.done.then((req) {
- Expect.equals(request, req);
+ request.close().then((res1) {
+ request.done.then((res2) {
+ Expect.equals(res1, res2);
+ });
});
- return request.response;
+ return request.done;
});
}
@@ -46,37 +48,37 @@
testClientRequest((request) {
var port = new ReceivePort();
request.contentLength = 0;
- request.writeBytes([0]);
+ request.add([0]);
request.close();
request.done.catchError((error) {
port.close();
}, test: (e) => e is HttpException);
- return request.response;
+ return request.done;
});
testClientRequest((request) {
var port = new ReceivePort();
request.contentLength = 5;
- request.writeBytes([0, 0, 0]);
- request.writeBytes([0, 0, 0]);
+ request.add([0, 0, 0]);
+ request.add([0, 0, 0]);
request.close();
request.done.catchError((error) {
port.close();
}, test: (e) => e is HttpException);
- return request.response;
+ return request.done;
});
testClientRequest((request) {
var port = new ReceivePort();
request.contentLength = 0;
- request.writeBytes(new Uint8List(64 * 1024));
- request.writeBytes(new Uint8List(64 * 1024));
- request.writeBytes(new Uint8List(64 * 1024));
+ request.add(new Uint8List(64 * 1024));
+ request.add(new Uint8List(64 * 1024));
+ request.add(new Uint8List(64 * 1024));
request.close();
request.done.catchError((error) {
port.close();
}, test: (e) => e is HttpException);
- return request.response;
+ return request.done;
});
}
@@ -88,18 +90,18 @@
request.done.catchError((error) {
port.close();
}, test: (e) => e is HttpException);
- return request.response;
+ return request.done;
});
testClientRequest((request) {
var port = new ReceivePort();
request.contentLength = 5;
- request.writeBytes([0]);
+ request.add([0]);
request.close();
request.done.catchError((error) {
port.close();
}, test: (e) => e is HttpException);
- return request.response;
+ return request.done;
});
}
diff --git a/tests/standalone/io/http_close_test.dart b/tests/standalone/io/http_close_test.dart
index 43bde37..cc9fd62 100644
--- a/tests/standalone/io/http_close_test.dart
+++ b/tests/standalone/io/http_close_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:typeddata";
@@ -68,47 +69,6 @@
}
-void testClientCloseDelayed(int connections) {
- HttpServer.bind().then((server) {
- int closed = 0;
- void check() {
- closed++;
- // Wait for both server and client to see the connections as closed.
- if (closed == connections * 2) {
- Expect.equals(0, server.connectionsInfo().active);
- Expect.equals(server.connectionsInfo().total,
- server.connectionsInfo().idle);
- server.close();
- }
- }
- server.listen((request) {
- request.pipe(request.response)
- .then((_) => check());
- });
- var client = new HttpClient();
- for (int i = 0; i < connections; i++) {
- var req;
- client.post("localhost", server.port, "/")
- .then((request) {
- req = request;
- request.writeBytes(new Uint8List(1024));
- return request.response;
- })
- .then((response) {
- req.close();
- // Ensure we don't accept the response until we have send the entire
- // request.
- response.listen(
- (_) {},
- onDone: () {
- check();
- });
- });
- }
- });
-}
-
-
void testClientCloseSendingResponse(int connections) {
HttpServer.bind().then((server) {
int closed = 0;
@@ -124,7 +84,7 @@
}
server.listen((request) {
var timer = new Timer.periodic(const Duration(milliseconds: 20), (_) {
- request.response.writeBytes(new Uint8List(16 * 1024));
+ request.response.add(new Uint8List(16 * 1024));
});
request.response.done
.catchError((_) {})
@@ -154,7 +114,6 @@
void main() {
testClientAndServerCloseNoListen(10);
testClientCloseServerListen(10);
- testClientCloseDelayed(10);
testClientCloseSendingResponse(10);
}
diff --git a/tests/standalone/io/http_compression_test.dart b/tests/standalone/io/http_compression_test.dart
index c347023..8bec0a2 100644
--- a/tests/standalone/io/http_compression_test.dart
+++ b/tests/standalone/io/http_compression_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import 'package:expect/expect.dart';
import 'dart:io';
import 'dart:typeddata';
@@ -14,7 +15,7 @@
void test(List<int> data) {
HttpServer.bind().then((server) {
server.listen((request) {
- request.response.writeBytes(data);
+ request.response.add(data);
request.response.close();
});
var client = new HttpClient();
@@ -27,7 +28,6 @@
Expect.equals("gzip",
response.headers.value(HttpHeaders.CONTENT_ENCODING));
response
- .transform(new ZLibInflater())
.fold([], (list, b) {
list.addAll(b);
return list;
diff --git a/tests/standalone/io/http_connection_close_test.dart b/tests/standalone/io/http_connection_close_test.dart
index 7225ef7..5a22540 100644
--- a/tests/standalone/io/http_connection_close_test.dart
+++ b/tests/standalone/io/http_connection_close_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:uri";
diff --git a/tests/standalone/io/http_connection_header_test.dart b/tests/standalone/io/http_connection_header_test.dart
index b7966a2..9d43624 100644
--- a/tests/standalone/io/http_connection_header_test.dart
+++ b/tests/standalone/io/http_connection_header_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
import "dart:isolate";
import "dart:io";
diff --git a/tests/standalone/io/http_connection_info_test.dart b/tests/standalone/io/http_connection_info_test.dart
index 54c0628..0d4caa4 100644
--- a/tests/standalone/io/http_connection_info_test.dart
+++ b/tests/standalone/io/http_connection_info_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
void testHttpConnectionInfo() {
diff --git a/tests/standalone/io/http_content_length_test.dart b/tests/standalone/io/http_content_length_test.dart
index cbe04ea..c42b8d3 100644
--- a/tests/standalone/io/http_content_length_test.dart
+++ b/tests/standalone/io/http_content_length_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:isolate";
import "dart:io";
diff --git a/tests/standalone/io/http_date_test.dart b/tests/standalone/io/http_date_test.dart
index 8f2ee60..df88afe 100644
--- a/tests/standalone/io/http_date_test.dart
+++ b/tests/standalone/io/http_date_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:math";
@@ -14,18 +15,18 @@
void testParseHttpDate() {
DateTime date;
- date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
+ date = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
Expect.equals(date, _HttpUtils.parseDate("Fri, 11 Jun 1999 18:46:53 GMT"));
Expect.equals(date, _HttpUtils.parseDate("Friday, 11-Jun-1999 18:46:53 GMT"));
Expect.equals(date, _HttpUtils.parseDate("Fri Jun 11 18:46:53 1999"));
- date = new DateTime.utc(1970, DateTime.JAN, 1, 0, 0, 0, 0);
+ date = new DateTime.utc(1970, DateTime.JANUARY, 1, 0, 0, 0, 0);
Expect.equals(date, _HttpUtils.parseDate("Thu, 1 Jan 1970 00:00:00 GMT"));
Expect.equals(date,
_HttpUtils.parseDate("Thursday, 1-Jan-1970 00:00:00 GMT"));
Expect.equals(date, _HttpUtils.parseDate("Thu Jan 1 00:00:00 1970"));
- date = new DateTime.utc(2012, DateTime.MAR, 5, 23, 59, 59, 0);
+ date = new DateTime.utc(2012, DateTime.MARCH, 5, 23, 59, 59, 0);
Expect.equals(date, _HttpUtils.parseDate("Mon, 5 Mar 2012 23:59:59 GMT"));
Expect.equals(date, _HttpUtils.parseDate("Monday, 5-Mar-2012 23:59:59 GMT"));
Expect.equals(date, _HttpUtils.parseDate("Mon Mar 5 23:59:59 2012"));
@@ -47,9 +48,9 @@
Expect.equals(date, _HttpUtils.parseDate(formatted));
}
- test(1999, DateTime.JUN, 11, 18, 46, 53, "Fri, 11 Jun 1999 18:46:53 GMT");
- test(1970, DateTime.JAN, 1, 0, 0, 0, "Thu, 1 Jan 1970 00:00:00 GMT");
- test(2012, DateTime.MAR, 5, 23, 59, 59, "Mon, 5 Mar 2012 23:59:59 GMT");
+ test(1999, DateTime.JUNE, 11, 18, 46, 53, "Fri, 11 Jun 1999 18:46:53 GMT");
+ test(1970, DateTime.JANUARY, 1, 0, 0, 0, "Thu, 1 Jan 1970 00:00:00 GMT");
+ test(2012, DateTime.MARCH, 5, 23, 59, 59, "Mon, 5 Mar 2012 23:59:59 GMT");
}
void testParseHttpDateFailures() {
@@ -97,11 +98,11 @@
Expect.equals(date, _HttpUtils.parseCookieDate(formatted));
}
- test(2012, DateTime.JUN, 19, 14, 15, 01, "tue, 19-jun-12 14:15:01 gmt");
- test(2021, DateTime.JUN, 09, 10, 18, 14, "Wed, 09-Jun-2021 10:18:14 GMT");
- test(2021, DateTime.JAN, 13, 22, 23, 01, "Wed, 13-Jan-2021 22:23:01 GMT");
- test(2013, DateTime.JAN, 15, 21, 47, 38, "Tue, 15-Jan-2013 21:47:38 GMT");
- test(1970, DateTime.JAN, 01, 00, 00, 01, "Thu, 01-Jan-1970 00:00:01 GMT");
+ test(2012, DateTime.JUNE, 19, 14, 15, 01, "tue, 19-jun-12 14:15:01 gmt");
+ test(2021, DateTime.JUNE, 09, 10, 18, 14, "Wed, 09-Jun-2021 10:18:14 GMT");
+ test(2021, DateTime.JANUARY, 13, 22, 23, 01, "Wed, 13-Jan-2021 22:23:01 GMT");
+ test(2013, DateTime.JANUARY, 15, 21, 47, 38, "Tue, 15-Jan-2013 21:47:38 GMT");
+ test(1970, DateTime.JANUARY, 01, 00, 00, 01, "Thu, 01-Jan-1970 00:00:01 GMT");
}
void main() {
diff --git a/tests/standalone/io/http_detach_socket_test.dart b/tests/standalone/io/http_detach_socket_test.dart
index 9c6f8c3..7d14b37 100644
--- a/tests/standalone/io/http_detach_socket_test.dart
+++ b/tests/standalone/io/http_detach_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
@@ -29,8 +30,8 @@
Socket.connect("127.0.0.1", server.port).then((socket) {
socket.write("GET / HTTP/1.1\r\n"
- "content-length: 0\r\n\r\n"
- "Some data");
+ "content-length: 0\r\n\r\n"
+ "Some data");
var body = new StringBuffer();
socket.listen(
(data) => body.write(new String.fromCharCodes(data)),
@@ -58,7 +59,7 @@
Socket.connect("127.0.0.1", server.port).then((socket) {
socket.write("GET / HTTP/1.1\r\n"
- "content-length: 0\r\n\r\n");
+ "content-length: 0\r\n\r\n");
socket.listen((_) {}, onDone: () {
socket.close();
});
@@ -77,6 +78,7 @@
(data) => body.write(new String.fromCharCodes(data)),
onDone: () {
Expect.equals("GET / HTTP/1.1\r\n"
+ "accept-encoding: gzip\r\n"
"content-length: 0\r\n"
"host: 127.0.0.1:${server.port}\r\n\r\n"
"Some data",
diff --git a/tests/standalone/io/http_head_test.dart b/tests/standalone/io/http_head_test.dart
index bb33ad3..ea5974b 100644
--- a/tests/standalone/io/http_head_test.dart
+++ b/tests/standalone/io/http_head_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
void testHEAD(int totalConnections) {
@@ -14,15 +15,15 @@
} else if (request.uri.path == "/test200") {
response.contentLength = 200;
List<int> data = new List<int>.filled(200, 0);
- response.writeBytes(data);
+ response.add(data);
response.close();
} else if (request.uri.path == "/testChunked100") {
List<int> data = new List<int>.filled(100, 0);
- response.writeBytes(data);
+ response.add(data);
response.close();
} else if (request.uri.path == "/testChunked200") {
List<int> data = new List<int>.filled(200, 0);
- response.writeBytes(data);
+ response.add(data);
response.close();
} else {
assert(false);
diff --git a/tests/standalone/io/http_headers_state_test.dart b/tests/standalone/io/http_headers_state_test.dart
index a685eb6..db4cdc1 100644
--- a/tests/standalone/io/http_headers_state_test.dart
+++ b/tests/standalone/io/http_headers_state_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
import "dart:isolate";
import "dart:io";
@@ -52,7 +53,7 @@
// Cannot mutate request headers when data has been sent.
Expect.throws(() => request.headers.add("X-Request-Header", "value3"),
(e) => e is HttpException);
- return request.response;
+ return request.done;
})
.then((HttpClientResponse response) {
// Cannot mutate response headers.
diff --git a/tests/standalone/io/http_headers_test.dart b/tests/standalone/io/http_headers_test.dart
index 5d94173..111379c 100644
--- a/tests/standalone/io/http_headers_test.dart
+++ b/tests/standalone/io/http_headers_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:math';
@@ -51,9 +52,9 @@
}
void testDate() {
- DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
+ DateTime date1 = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
- DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0);
+ DateTime date2 = new DateTime.utc(2000, DateTime.AUGUST, 16, 12, 34, 56, 0);
String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
_HttpHeaders headers = new _HttpHeaders("1.1");
@@ -77,9 +78,9 @@
}
void testExpires() {
- DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
+ DateTime date1 = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
- DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0);
+ DateTime date2 = new DateTime.utc(2000, DateTime.AUGUST, 16, 12, 34, 56, 0);
String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
_HttpHeaders headers = new _HttpHeaders("1.1");
@@ -103,9 +104,9 @@
}
void testIfModifiedSince() {
- DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
+ DateTime date1 = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
- DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0);
+ DateTime date2 = new DateTime.utc(2000, DateTime.AUGUST, 16, 12, 34, 56, 0);
String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
_HttpHeaders headers = new _HttpHeaders("1.1");
@@ -329,7 +330,7 @@
Cookie cookie;
cookie = new Cookie("name", "value");
Expect.equals("name=value", cookie.toString());
- DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0);
+ DateTime date = new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0);
cookie.expires = date;
checkCookie(cookie, "name=value"
"; Expires=Sun, 5 Jan 2014 23:59:59 GMT");
diff --git a/tests/standalone/io/http_keep_alive_test.dart b/tests/standalone/io/http_keep_alive_test.dart
index ad20ea8..c2160d3 100644
--- a/tests/standalone/io/http_keep_alive_test.dart
+++ b/tests/standalone/io/http_keep_alive_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
@@ -28,7 +29,7 @@
int length = int.parse(request.queryParameters["length"]);
var buffer = new List<int>.filled(length, 0);
if (!chunked) request.response.contentLength = length;
- request.response.writeBytes(buffer);
+ request.response.add(buffer);
request.response.close();
});
return server;
diff --git a/tests/standalone/io/http_parser_test.dart b/tests/standalone/io/http_parser_test.dart
index 87abee3..00d5b8e 100644
--- a/tests/standalone/io/http_parser_test.dart
+++ b/tests/standalone/io/http_parser_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:math';
import 'dart:typeddata';
diff --git a/tests/standalone/io/http_proxy_configuration_test.dart b/tests/standalone/io/http_proxy_configuration_test.dart
index b5016ee..568b47c 100644
--- a/tests/standalone/io/http_proxy_configuration_test.dart
+++ b/tests/standalone/io/http_proxy_configuration_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:uri";
diff --git a/tests/standalone/io/http_proxy_test.dart b/tests/standalone/io/http_proxy_test.dart
index 173c3c0..3f2d0cf 100644
--- a/tests/standalone/io/http_proxy_test.dart
+++ b/tests/standalone/io/http_proxy_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:uri";
@@ -103,8 +104,7 @@
clientRequest.headers.add(
HttpHeaders.VIA, "${viaPrefix}1.1 localhost:$port");
// Copy all content.
- request.pipe(clientRequest);
- return clientRequest.response;
+ return request.pipe(clientRequest);
})
.then((HttpClientResponse clientResponse) {
clientResponse.pipe(request.response);
diff --git a/tests/standalone/io/http_read_test.dart b/tests/standalone/io/http_read_test.dart
index 32226c6..e9f9cfc 100644
--- a/tests/standalone/io/http_read_test.dart
+++ b/tests/standalone/io/http_read_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:isolate";
import "dart:io";
@@ -174,7 +175,7 @@
request.write(data.substring(10, data.length));
} else {
request.contentLength = data.length;
- request.writeBytes(data.codeUnits);
+ request.add(data.codeUnits);
}
return request.close();
})
diff --git a/tests/standalone/io/http_redirect_test.dart b/tests/standalone/io/http_redirect_test.dart
index 3209496..f146083 100644
--- a/tests/standalone/io/http_redirect_test.dart
+++ b/tests/standalone/io/http_redirect_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
//
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:uri";
diff --git a/tests/standalone/io/http_request_pipeling_test.dart b/tests/standalone/io/http_request_pipeling_test.dart
index b12cb48..152fd15 100644
--- a/tests/standalone/io/http_request_pipeling_test.dart
+++ b/tests/standalone/io/http_request_pipeling_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:io";
import "dart:uri";
diff --git a/tests/standalone/io/http_server_early_client_close_test.dart b/tests/standalone/io/http_server_early_client_close_test.dart
index 8573f93..5a58899 100644
--- a/tests/standalone/io/http_server_early_client_close_test.dart
+++ b/tests/standalone/io/http_server_early_client_close_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -11,7 +12,7 @@
socket.listen((data) {
Expect.fail("No data response was expected");
});
- socket.writeBytes(data);
+ socket.add(data);
socket.close();
socket.done.then((_) {
socket.destroy();
diff --git a/tests/standalone/io/http_server_early_server_close_test.dart b/tests/standalone/io/http_server_early_server_close_test.dart
index 79f1254..d5de5d9 100644
--- a/tests/standalone/io/http_server_early_server_close_test.dart
+++ b/tests/standalone/io/http_server_early_server_close_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/http_server_response_test.dart b/tests/standalone/io/http_server_response_test.dart
index db3888f..51ad60d 100644
--- a/tests/standalone/io/http_server_response_test.dart
+++ b/tests/standalone/io/http_server_response_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:typeddata";
@@ -87,7 +88,7 @@
void testBadResponseAdd() {
testServerRequest((server, request) {
request.response.contentLength = 0;
- request.response.writeBytes([0]);
+ request.response.add([0]);
request.response.close();
request.response.done.catchError((error) {
server.close();
@@ -96,8 +97,8 @@
testServerRequest((server, request) {
request.response.contentLength = 5;
- request.response.writeBytes([0, 0, 0]);
- request.response.writeBytes([0, 0, 0]);
+ request.response.add([0, 0, 0]);
+ request.response.add([0, 0, 0]);
request.response.close();
request.response.done.catchError((error) {
server.close();
@@ -106,9 +107,9 @@
testServerRequest((server, request) {
request.response.contentLength = 0;
- request.response.writeBytes(new Uint8List(64 * 1024));
- request.response.writeBytes(new Uint8List(64 * 1024));
- request.response.writeBytes(new Uint8List(64 * 1024));
+ request.response.add(new Uint8List(64 * 1024));
+ request.response.add(new Uint8List(64 * 1024));
+ request.response.add(new Uint8List(64 * 1024));
request.response.close();
request.response.done.catchError((error) {
server.close();
@@ -127,7 +128,7 @@
testServerRequest((server, request) {
request.response.contentLength = 5;
- request.response.writeBytes([0]);
+ request.response.add([0]);
request.response.close();
request.response.done.catchError((error) {
server.close();
diff --git a/tests/standalone/io/http_server_test.dart b/tests/standalone/io/http_server_test.dart
index dd6eeac..4724467 100644
--- a/tests/standalone/io/http_server_test.dart
+++ b/tests/standalone/io/http_server_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/http_session_test.dart b/tests/standalone/io/http_session_test.dart
index 5648bd059..6c9d565 100644
--- a/tests/standalone/io/http_session_test.dart
+++ b/tests/standalone/io/http_session_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
diff --git a/tests/standalone/io/http_shutdown_test.dart b/tests/standalone/io/http_shutdown_test.dart
index 6c3612a..1cf4803 100644
--- a/tests/standalone/io/http_shutdown_test.dart
+++ b/tests/standalone/io/http_shutdown_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
@@ -164,7 +165,7 @@
for (int i = 0; i < totalConnections; i++) {
client.post("127.0.0.1", server.port, "/")
.then((request) {
- request.writeBytes([0]);
+ request.add([0]);
// TODO(sgjesse): Make this test work with
//request.response instead of request.close() return
//return request.response;
diff --git a/tests/standalone/io/https_client_certificate_test.dart b/tests/standalone/io/https_client_certificate_test.dart
index 62144046..720f0c6 100644
--- a/tests/standalone/io/https_client_certificate_test.dart
+++ b/tests/standalone/io/https_client_certificate_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:uri";
diff --git a/tests/standalone/io/https_client_exception_test.dart b/tests/standalone/io/https_client_exception_test.dart
index 22c743c..a49c51a 100644
--- a/tests/standalone/io/https_client_exception_test.dart
+++ b/tests/standalone/io/https_client_exception_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
import "dart:uri";
diff --git a/tests/standalone/io/https_server_test.dart b/tests/standalone/io/https_server_test.dart
index e4e86e8..490152e 100644
--- a/tests/standalone/io/https_server_test.dart
+++ b/tests/standalone/io/https_server_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:uri";
import "dart:isolate";
diff --git a/tests/standalone/io/link_test.dart b/tests/standalone/io/link_test.dart
index 8d467d4..0562cb3b 100644
--- a/tests/standalone/io/link_test.dart
+++ b/tests/standalone/io/link_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -132,11 +133,47 @@
}
}
Future.wait(futures).then((_) {
+ new Directory(target).deleteSync(recursive: true);
+ for (bool recursive in [true, false]) {
+ for (bool followLinks in [true, false]) {
+ var result = baseDir.listSync(recursive: recursive,
+ followLinks: followLinks);
+ Expect.equals(1, result.length);
+ Expect.isTrue(result[0] is Link);
+ }
+ }
baseDir.deleteSync(recursive: true);
});
}
+testCreateLoopingLink() {
+ Path base = new Path(new Directory('').createTempSync().path);
+ new Directory.fromPath(base.append('a/b/c')).create(recursive: true)
+ .then((_) =>
+ new Link.fromPath(base.append('a/b/c/d'))
+ .create(base.append('a/b').toNativePath()))
+ .then((_) =>
+ new Link.fromPath(base.append('a/b/c/e'))
+ .create(base.append('a').toNativePath()))
+ .then((_) =>
+ new Directory.fromPath(base.append('a'))
+ .list(recursive: true, followLinks: false)
+ .last)
+ .then((_) =>
+ // This directory listing must terminate, even though it contains loops.
+ new Directory.fromPath(base.append('a'))
+ .list(recursive: true, followLinks: true)
+ .last)
+ .then((_) =>
+ // This directory listing must terminate, even though it contains loops.
+ new Directory.fromPath(base.append('a/b/c'))
+ .list(recursive: true, followLinks: true)
+ .last)
+ .then((_) =>
+ new Directory.fromPath(base).delete(recursive: true));
+}
main() {
testCreateSync();
+ testCreateLoopingLink();
}
diff --git a/tests/standalone/io/mime_multipart_parser_test.dart b/tests/standalone/io/mime_multipart_parser_test.dart
index 506a46e..e8635aa 100644
--- a/tests/standalone/io/mime_multipart_parser_test.dart
+++ b/tests/standalone/io/mime_multipart_parser_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:math';
diff --git a/tests/standalone/io/options_test.dart b/tests/standalone/io/options_test.dart
index 5963046..cad7d91 100644
--- a/tests/standalone/io/options_test.dart
+++ b/tests/standalone/io/options_test.dart
@@ -4,6 +4,7 @@
// Stress test isolate generation.
// DartOptions=tests/standalone/io/options_test.dart 10 options_test 20
+import "package:expect/expect.dart";
import "dart:math";
import "dart:io";
diff --git a/tests/standalone/io/path_test.dart b/tests/standalone/io/path_test.dart
index 99756cb..5e972f5 100644
--- a/tests/standalone/io/path_test.dart
+++ b/tests/standalone/io/path_test.dart
@@ -4,6 +4,7 @@
//
// Test the Path class in dart:io.
+import "package:expect/expect.dart";
import "dart:io";
void main() {
@@ -322,6 +323,7 @@
var C2Path = new Path(r'C:\a\b\d');
var C3Path = new Path(r'C:\a\b');
var C4Path = new Path(r'C:\');
+ var c4Path = new Path(r'c:\');
var DPath = new Path(r'D:\a\b\d\e');
var NoPath = new Path(r'\a\b\c\.');
@@ -337,4 +339,5 @@
Expect.equals('d', cPath.relativeTo(C3Path).toString());
Expect.equals('a/b/d', cPath.relativeTo(C4Path).toString());
Expect.equals('../../../', C4Path.relativeTo(cPath).toString());
+ Expect.equals('a/b', C3Path.relativeTo(c4Path).toString());
}
diff --git a/tests/standalone/io/pipe_server_test.dart b/tests/standalone/io/pipe_server_test.dart
index 6fa9f62..d86e5f5 100644
--- a/tests/standalone/io/pipe_server_test.dart
+++ b/tests/standalone/io/pipe_server_test.dart
@@ -9,6 +9,7 @@
library ServerTest;
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/platform_test.dart b/tests/standalone/io/platform_test.dart
index 96839e3..4a42683a 100644
--- a/tests/standalone/io/platform_test.dart
+++ b/tests/standalone/io/platform_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
main() {
diff --git a/tests/standalone/io/process_broken_pipe_test.dart b/tests/standalone/io/process_broken_pipe_test.dart
index 4db19ac9..01451bf 100644
--- a/tests/standalone/io/process_broken_pipe_test.dart
+++ b/tests/standalone/io/process_broken_pipe_test.dart
@@ -4,6 +4,7 @@
//
// Process test program to test closed stdin from child process.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
@@ -24,7 +25,7 @@
// Write to the stdin after the process is terminated to test
// writing to a broken pipe.
process.exitCode.then((code) {
- process.stdin.writeBytes([0]);
+ process.stdin.add([0]);
});
});
}
diff --git a/tests/standalone/io/process_check_arguments_script.dart b/tests/standalone/io/process_check_arguments_script.dart
index de5df11..4e933b9 100644
--- a/tests/standalone/io/process_check_arguments_script.dart
+++ b/tests/standalone/io/process_check_arguments_script.dart
@@ -7,6 +7,20 @@
import "dart:math";
import "dart:io";
+class Expect {
+ static void isTrue(x) {
+ if (!x) {
+ throw new Error("Not true");
+ }
+ }
+
+ static void equals(x, y) {
+ if (x != y) {
+ throw new Error("Not equal");
+ }
+ }
+}
+
main() {
var options = new Options();
Expect.isTrue(options.script.endsWith('process_check_arguments_script.dart'));
diff --git a/tests/standalone/io/process_check_arguments_test.dart b/tests/standalone/io/process_check_arguments_test.dart
index 22ccde4..68da4a2 100644
--- a/tests/standalone/io/process_check_arguments_test.dart
+++ b/tests/standalone/io/process_check_arguments_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/process_environment_test.dart b/tests/standalone/io/process_environment_test.dart
index c0aaa68..30e523b 100644
--- a/tests/standalone/io/process_environment_test.dart
+++ b/tests/standalone/io/process_environment_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
import "process_test_util.dart";
diff --git a/tests/standalone/io/process_exit_test.dart b/tests/standalone/io/process_exit_test.dart
index 060bb14..8e09ae9 100644
--- a/tests/standalone/io/process_exit_test.dart
+++ b/tests/standalone/io/process_exit_test.dart
@@ -5,6 +5,7 @@
// Process test program to test process communication.
library ProcessExitTest;
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/process_invalid_arguments_test.dart b/tests/standalone/io/process_invalid_arguments_test.dart
index c58d131..8dc60d1 100644
--- a/tests/standalone/io/process_invalid_arguments_test.dart
+++ b/tests/standalone/io/process_invalid_arguments_test.dart
@@ -4,6 +4,7 @@
//
// Process test program to test that invalid arguments throw exceptions.
+import "package:expect/expect.dart";
import "dart:io";
void main() {
diff --git a/tests/standalone/io/process_kill_test.dart b/tests/standalone/io/process_kill_test.dart
index 733724f..6739336 100644
--- a/tests/standalone/io/process_kill_test.dart
+++ b/tests/standalone/io/process_kill_test.dart
@@ -5,6 +5,7 @@
// Process test program to test process communication.
library ProcessKillTest;
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/process_non_ascii_test.dart b/tests/standalone/io/process_non_ascii_test.dart
index 88291be..020b07e 100644
--- a/tests/standalone/io/process_non_ascii_test.dart
+++ b/tests/standalone/io/process_non_ascii_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
import 'dart:isolate';
@@ -17,7 +18,9 @@
import 'dart:io';
main() {
- Expect.equals('æøå', new File('æøå.txt').readAsStringSync());
+ if ('æøå' != new File('æøå.txt').readAsStringSync()) {
+ throw new RuntimeError("not equal");
+ }
}
""");
var nonAsciiTxtFile = new File('${nonAsciiDir.path}/æøå.txt');
diff --git a/tests/standalone/io/process_path_environment_test.dart b/tests/standalone/io/process_path_environment_test.dart
index 3cd4cf6..72f5165 100644
--- a/tests/standalone/io/process_path_environment_test.dart
+++ b/tests/standalone/io/process_path_environment_test.dart
@@ -5,6 +5,7 @@
// Test that the executable is looked up on the user's PATH when spawning a
// process and environment variables are passed in.
+import "package:expect/expect.dart";
import "dart:io";
main() {
diff --git a/tests/standalone/io/process_path_test.dart b/tests/standalone/io/process_path_test.dart
index 3ce0713..e517d9e 100644
--- a/tests/standalone/io/process_path_test.dart
+++ b/tests/standalone/io/process_path_test.dart
@@ -5,6 +5,7 @@
// Test that the executable is looked up on the user's PATH when spawning a
// process.
+import "package:expect/expect.dart";
import "dart:io";
main() {
diff --git a/tests/standalone/io/process_run_output_test.dart b/tests/standalone/io/process_run_output_test.dart
index bc5a4e3..5dd731b 100644
--- a/tests/standalone/io/process_run_output_test.dart
+++ b/tests/standalone/io/process_run_output_test.dart
@@ -5,6 +5,7 @@
// Test script for testing that output is handled correctly for
// non-interactive processes started with Process.run.
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/process_segfault_test.dart b/tests/standalone/io/process_segfault_test.dart
index 5c278d2..3308139 100644
--- a/tests/standalone/io/process_segfault_test.dart
+++ b/tests/standalone/io/process_segfault_test.dart
@@ -5,6 +5,7 @@
// Process test program to test process communication.
library ProcessSegfaultTest;
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/process_set_exit_code_test.dart b/tests/standalone/io/process_set_exit_code_test.dart
index 29baed7..1b0f767 100644
--- a/tests/standalone/io/process_set_exit_code_test.dart
+++ b/tests/standalone/io/process_set_exit_code_test.dart
@@ -6,6 +6,7 @@
library ProcessSetExitCodeTest;
+import "package:expect/expect.dart";
import "dart:io";
main() {
diff --git a/tests/standalone/io/process_start_exception_test.dart b/tests/standalone/io/process_start_exception_test.dart
index a75b131..f7a0a66 100644
--- a/tests/standalone/io/process_start_exception_test.dart
+++ b/tests/standalone/io/process_start_exception_test.dart
@@ -4,6 +4,7 @@
//
// Process test program to errors during startup of the process.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
diff --git a/tests/standalone/io/process_std_io_script.dart b/tests/standalone/io/process_std_io_script.dart
index 4ca28f4..7e55c8d 100644
--- a/tests/standalone/io/process_std_io_script.dart
+++ b/tests/standalone/io/process_std_io_script.dart
@@ -15,8 +15,8 @@
stdin.pipe(stderr);
} else if (options.arguments[0] == "2") {
stdin.listen((data) {
- stdout.writeBytes(data);
- stderr.writeBytes(data);
+ stdout.add(data);
+ stderr.add(data);
});
}
}
diff --git a/tests/standalone/io/process_stderr_test.dart b/tests/standalone/io/process_stderr_test.dart
index 38e47f4..8292b99 100644
--- a/tests/standalone/io/process_stderr_test.dart
+++ b/tests/standalone/io/process_stderr_test.dart
@@ -9,6 +9,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:math';
@@ -46,7 +47,7 @@
}
process.stdout.listen((_) {});
- process.stdin.writeBytes(data);
+ process.stdin.add(data);
process.stdin.close();
process.stderr.listen(readData);
});
diff --git a/tests/standalone/io/process_stdin_transform_unsubscribe_test.dart b/tests/standalone/io/process_stdin_transform_unsubscribe_test.dart
index 23736f7..94085a4 100644
--- a/tests/standalone/io/process_stdin_transform_unsubscribe_test.dart
+++ b/tests/standalone/io/process_stdin_transform_unsubscribe_test.dart
@@ -9,6 +9,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:math';
diff --git a/tests/standalone/io/process_stdout_test.dart b/tests/standalone/io/process_stdout_test.dart
index 15b124d..0bce7aa 100644
--- a/tests/standalone/io/process_stdout_test.dart
+++ b/tests/standalone/io/process_stdout_test.dart
@@ -9,6 +9,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:math';
@@ -46,7 +47,7 @@
}
process.stderr.listen((_) {});
- process.stdin.writeBytes(data);
+ process.stdin.add(data);
process.stdin.close();
process.stdout.listen(readData);
});
diff --git a/tests/standalone/io/process_working_directory_test.dart b/tests/standalone/io/process_working_directory_test.dart
index 714d2a4..9bc1d0c 100644
--- a/tests/standalone/io/process_working_directory_test.dart
+++ b/tests/standalone/io/process_working_directory_test.dart
@@ -5,6 +5,7 @@
// Process working directory test.
library ProcessWorkingDirectoryTest;
+import "package:expect/expect.dart";
import "dart:io";
import "process_test_util.dart";
diff --git a/tests/standalone/io/raw_secure_server_closing_test.dart b/tests/standalone/io/raw_secure_server_closing_test.dart
index 0fa8121..51e1ab2 100644
--- a/tests/standalone/io/raw_secure_server_closing_test.dart
+++ b/tests/standalone/io/raw_secure_server_closing_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/raw_secure_server_socket_test.dart b/tests/standalone/io/raw_secure_server_socket_test.dart
index b12b87a..3b3079c 100644
--- a/tests/standalone/io/raw_secure_server_socket_test.dart
+++ b/tests/standalone/io/raw_secure_server_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/raw_secure_socket_pause_test.dart b/tests/standalone/io/raw_secure_socket_pause_test.dart
index b5081f5..d703112 100644
--- a/tests/standalone/io/raw_secure_socket_pause_test.dart
+++ b/tests/standalone/io/raw_secure_socket_pause_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -23,7 +24,7 @@
onDone: () {
request.response.contentLength = 100;
for (int i = 0; i < 10; i++) {
- request.response.writeBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ request.response.add([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
}
request.response.close();
});
diff --git a/tests/standalone/io/raw_secure_socket_test.dart b/tests/standalone/io/raw_secure_socket_test.dart
index 7375161..02254b4 100644
--- a/tests/standalone/io/raw_secure_socket_test.dart
+++ b/tests/standalone/io/raw_secure_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -23,7 +24,7 @@
onDone: () {
request.response.contentLength = 100;
for (int i = 0; i < 10; i++) {
- request.response.writeBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ request.response.add([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
}
request.response.close();
});
diff --git a/tests/standalone/io/raw_socket_test.dart b/tests/standalone/io/raw_socket_test.dart
index 01e8e71..b619668 100644
--- a/tests/standalone/io/raw_socket_test.dart
+++ b/tests/standalone/io/raw_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/raw_socket_write_destroy_test.dart b/tests/standalone/io/raw_socket_write_destroy_test.dart
index d7dc0d8..13ecaf3 100644
--- a/tests/standalone/io/raw_socket_write_destroy_test.dart
+++ b/tests/standalone/io/raw_socket_write_destroy_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/read_into_const_list_test.dart b/tests/standalone/io/read_into_const_list_test.dart
index 576cc3f..e1ed587 100644
--- a/tests/standalone/io/read_into_const_list_test.dart
+++ b/tests/standalone/io/read_into_const_list_test.dart
@@ -5,6 +5,7 @@
// Regression test for missing immutability check in the ListSet
// methods in the API. This allowed overwriting const Lists.
+import "package:expect/expect.dart";
import "dart:io";
String getFilename(String path) =>
diff --git a/tests/standalone/io/regress_6521_test.dart b/tests/standalone/io/regress_6521_test.dart
deleted file mode 100644
index aa8a964..0000000
--- a/tests/standalone/io/regress_6521_test.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-//
-// Regression test for http://code.google.com/p/dart/issues/detail?id=6393.
-
-import "dart:io";
-import "dart:uri";
-
-var client = new HttpClient();
-var clientRequest;
-
-void main() {
- HttpServer.bind("127.0.0.1", 0)
- .then((server) {
- server.listen(
- (req) {
- req.pipe(req.response);
- });
-
- client.openUrl("POST", Uri.parse("http://localhost:${server.port}/"))
- .then((request) {
- // Keep a reference to the client request object.
- clientRequest = request;
- request.writeBytes([0]);
- return request.response;
- })
- .then((response) {
- // Wait with closing the client request until the response headers
- // are done.
- clientRequest.close();
- response.listen(
- (_) {},
- onDone: () {
- client.close();
- server.close();
- });
- });
- });
-}
diff --git a/tests/standalone/io/regress_7191_script.dart b/tests/standalone/io/regress_7191_script.dart
index 1b047f1..7bc7a3e 100644
--- a/tests/standalone/io/regress_7191_script.dart
+++ b/tests/standalone/io/regress_7191_script.dart
@@ -17,9 +17,8 @@
p.stderr.listen((_) { });
// When receiving data again, kill sub-process and exit.
subscription.onData((data) {
- Expect.listEquals([0], data);
p.kill();
- p.exitCode.then(exit);
+ p.exitCode.then((_) => exit(0));
});
// Close stdout. If handles are incorrectly inherited this will
// not actually close stdout and the test will hang.
diff --git a/tests/standalone/io/regress_7191_test.dart b/tests/standalone/io/regress_7191_test.dart
index 3d46cfa..8c56fb3 100644
--- a/tests/standalone/io/regress_7191_test.dart
+++ b/tests/standalone/io/regress_7191_test.dart
@@ -19,10 +19,13 @@
var scriptDir = new Path(options.script).directoryPath;
var script = scriptDir.append('regress_7191_script.dart').toNativePath();
Process.start(executable, [script]).then((process) {
- process.stdin.writeBytes([0]);
- process.stdout.listen((_) { },
- onDone: () { process.stdin.writeBytes([0]); });
+ process.stdin.add([0]);
+ process.stdout.listen((_) { },
+ onDone: () { process.stdin.add([0]); });
process.stderr.listen((_) { });
- process.exitCode.then((exitCode) => port.close());
+ process.exitCode.then((exitCode) {
+ port.close();
+ if (exitCode != 0) throw "Bad exit code";
+ });
});
}
diff --git a/tests/standalone/io/regress_7679_test.dart b/tests/standalone/io/regress_7679_test.dart
index b13c249..dba91ed 100644
--- a/tests/standalone/io/regress_7679_test.dart
+++ b/tests/standalone/io/regress_7679_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
main() {
@@ -10,6 +11,14 @@
script.writeAsStringSync("""
import 'dart:io';
+class Expect {
+ static void isTrue(var x) {
+ if (!identical(x, true)) {
+ throw new Error("Not identical");
+ }
+ }
+}
+
main() {
Directory d = new Directory('a');
d.create(recursive: true).then((_) {
diff --git a/tests/standalone/io/regress_8828_test.dart b/tests/standalone/io/regress_8828_test.dart
index 258d7a6..7842be5 100644
--- a/tests/standalone/io/regress_8828_test.dart
+++ b/tests/standalone/io/regress_8828_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import 'dart:io';
void main() {
diff --git a/tests/standalone/io/regress_9194_test.dart b/tests/standalone/io/regress_9194_test.dart
index 32e8851..0b686e0 100644
--- a/tests/standalone/io/regress_9194_test.dart
+++ b/tests/standalone/io/regress_9194_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:io';
void main() {
diff --git a/tests/standalone/io/secure_client_raw_server_test.dart b/tests/standalone/io/secure_client_raw_server_test.dart
index 7b63775..a00e27b 100644
--- a/tests/standalone/io/secure_client_raw_server_test.dart
+++ b/tests/standalone/io/secure_client_raw_server_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/secure_client_server_test.dart b/tests/standalone/io/secure_client_server_test.dart
index 75cdd77..6681c11 100644
--- a/tests/standalone/io/secure_client_server_test.dart
+++ b/tests/standalone/io/secure_client_server_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -22,7 +23,7 @@
server.listen((SecureSocket client) {
client.fold(<int>[], (message, data) => message..addAll(data))
.then((message) {
- client.writeBytes(message);
+ client.add(message);
client.close();
});
});
diff --git a/tests/standalone/io/secure_multiple_client_server_test.dart b/tests/standalone/io/secure_multiple_client_server_test.dart
index 4700fcd..dc6720f 100644
--- a/tests/standalone/io/secure_multiple_client_server_test.dart
+++ b/tests/standalone/io/secure_multiple_client_server_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -25,7 +26,7 @@
String received = new String.fromCharCodes(message);
Expect.isTrue(received.contains("Hello from client "));
String name = received.substring(received.indexOf("client ") + 7);
- client.writeBytes("Welcome, client $name".codeUnits);
+ client.add("Welcome, client $name".codeUnits);
client.close();
});
});
@@ -35,7 +36,7 @@
Future testClient(server, name) {
return SecureSocket.connect(HOST_NAME, server.port).then((socket) {
- socket.writeBytes("Hello from client $name".codeUnits);
+ socket.add("Hello from client $name".codeUnits);
socket.close();
return socket.fold(<int>[], (message, data) => message..addAll(data))
.then((message) {
diff --git a/tests/standalone/io/secure_no_builtin_roots_database_test.dart b/tests/standalone/io/secure_no_builtin_roots_database_test.dart
new file mode 100644
index 0000000..078ba70
--- /dev/null
+++ b/tests/standalone/io/secure_no_builtin_roots_database_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "dart:io";
+import "dart:uri";
+import "dart:isolate";
+import "dart:async";
+
+void testGoogleUrl() {
+ ReceivePort keepAlive = new ReceivePort();
+ HttpClient client = new HttpClient();
+ client.getUrl(Uri.parse('https://www.google.com'))
+ .then((request) => request.close())
+ .then((response) => Expect.fail("Unexpected successful connection"))
+ .catchError((error) {
+ Expect.isTrue(error is AsyncError);
+ Expect.isTrue(error.error is SocketIOException);
+ keepAlive.close();
+ client.close();
+ });
+}
+
+void InitializeSSL() {
+ // If the built-in root certificates aren't loaded, the connection
+ // should signal an error. Even when an external database is loaded,
+ // they should not be loaded.
+ Path scriptDir = new Path(new Options().script).directoryPath;
+ Path certificateDatabase = scriptDir.append('pkcert');
+ SecureSocket.initialize(database: certificateDatabase.toNativePath(),
+ password: 'dartdart',
+ useBuiltinRoots: false);
+}
+
+void main() {
+ InitializeSSL();
+ testGoogleUrl();
+}
diff --git a/tests/standalone/io/secure_no_builtin_roots_test.dart b/tests/standalone/io/secure_no_builtin_roots_test.dart
index 9b6f489..a93404c 100644
--- a/tests/standalone/io/secure_no_builtin_roots_test.dart
+++ b/tests/standalone/io/secure_no_builtin_roots_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:uri";
import "dart:isolate";
diff --git a/tests/standalone/io/secure_server_client_certificate_test.dart b/tests/standalone/io/secure_server_client_certificate_test.dart
index 24e72a0..4d24783 100644
--- a/tests/standalone/io/secure_server_client_certificate_test.dart
+++ b/tests/standalone/io/secure_server_client_certificate_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/secure_server_closing_test.dart b/tests/standalone/io/secure_server_closing_test.dart
index fde898c..29f3a1b 100644
--- a/tests/standalone/io/secure_server_closing_test.dart
+++ b/tests/standalone/io/secure_server_closing_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/secure_server_socket_test.dart b/tests/standalone/io/secure_server_socket_test.dart
index ad5f4d3..da71e0d 100644
--- a/tests/standalone/io/secure_server_socket_test.dart
+++ b/tests/standalone/io/secure_server_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -170,7 +171,7 @@
bytesRead += buffer.length;
if (bytesRead == data.length) {
verifyTestData(data);
- client.writeBytes(data);
+ client.add(data);
client.close();
}
},
@@ -184,7 +185,7 @@
int bytesWritten = 0;
List<int> dataSent = createTestData();
List<int> dataReceived = new List<int>(dataSent.length);
- socket.writeBytes(dataSent);
+ socket.add(dataSent);
socket.close(); // Can also be delayed.
socket.listen(
(List<int> buffer) {
diff --git a/tests/standalone/io/secure_session_resume_test.dart b/tests/standalone/io/secure_session_resume_test.dart
index 83ec1cc..6e5f48b 100644
--- a/tests/standalone/io/secure_session_resume_test.dart
+++ b/tests/standalone/io/secure_session_resume_test.dart
@@ -16,6 +16,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/secure_socket_argument_test.dart b/tests/standalone/io/secure_socket_argument_test.dart
index 7fda4a4..5e59c06 100644
--- a/tests/standalone/io/secure_socket_argument_test.dart
+++ b/tests/standalone/io/secure_socket_argument_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
void main() {
diff --git a/tests/standalone/io/secure_socket_bad_certificate_test.dart b/tests/standalone/io/secure_socket_bad_certificate_test.dart
index 5cb4145..658d560 100644
--- a/tests/standalone/io/secure_socket_bad_certificate_test.dart
+++ b/tests/standalone/io/secure_socket_bad_certificate_test.dart
@@ -10,6 +10,7 @@
// www.google.dk. Add this to the test when we have secure server sockets.
// See TODO below.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:isolate";
import "dart:io";
@@ -39,8 +40,8 @@
bool badCertificateCallback(X509Certificate certificate) {
Expect.isTrue(certificate.subject.contains("O=Google Inc"));
- Expect.isTrue(certificate.startValidity < new DateTime.now());
- Expect.isTrue(certificate.endValidity > new DateTime.now());
+ Expect.isTrue(certificate.startValidity.isBefore(new DateTime.now()));
+ Expect.isTrue(certificate.endValidity.isAfter(new DateTime.now()));
return acceptCertificate;
};
diff --git a/tests/standalone/io/secure_socket_test.dart b/tests/standalone/io/secure_socket_test.dart
index 0fe4c55..09a5852 100644
--- a/tests/standalone/io/secure_socket_test.dart
+++ b/tests/standalone/io/secure_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
@@ -22,7 +23,7 @@
onDone: () {
request.response.contentLength = 100;
for (int i = 0; i < 10; i++) {
- request.response.writeBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ request.response.add([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
}
request.response.close();
});
diff --git a/tests/standalone/io/skipping_dart2js_compilations_test.dart b/tests/standalone/io/skipping_dart2js_compilations_test.dart
index a142ab3..2dd7bf2 100644
--- a/tests/standalone/io/skipping_dart2js_compilations_test.dart
+++ b/tests/standalone/io/skipping_dart2js_compilations_test.dart
@@ -14,6 +14,7 @@
* output (+deps file), dart application)
*/
+import 'package:expect/expect.dart';
import 'dart:async';
import 'dart:io';
import 'dart:uri';
diff --git a/tests/standalone/io/sleep_test.dart b/tests/standalone/io/sleep_test.dart
index d953bf9..795de81 100644
--- a/tests/standalone/io/sleep_test.dart
+++ b/tests/standalone/io/sleep_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
test(int milliseconds) {
@@ -13,7 +14,10 @@
}
main() {
+ test(0);
test(1);
test(10);
test(100);
+ Expect.throws(() => sleep(new Duration(milliseconds: -1)),
+ (e) => e is ArgumentError);
}
diff --git a/tests/standalone/io/socket_close_test.dart b/tests/standalone/io/socket_close_test.dart
index a48f5e8..8022fcd 100644
--- a/tests/standalone/io/socket_close_test.dart
+++ b/tests/standalone/io/socket_close_test.dart
@@ -9,6 +9,7 @@
//
// Test socket close events.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/io/socket_exception_test.dart b/tests/standalone/io/socket_exception_test.dart
index 3b83564..c82f3fb 100644
--- a/tests/standalone/io/socket_exception_test.dart
+++ b/tests/standalone/io/socket_exception_test.dart
@@ -4,6 +4,7 @@
//
// Tests socket exceptions.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:isolate";
import "dart:io";
@@ -88,7 +89,7 @@
Expect.isFalse(wrongExceptionCaught);
try {
List<int> buffer = new List<int>(10);
- client.writeBytes(buffer);
+ client.add(buffer);
} on StateError catch (ex) {
exceptionCaught = true;
} catch (ex) {
@@ -121,7 +122,7 @@
});
Socket.connect("127.0.0.1", server.port).then((client) {
client.listen((data) {}, onDone: server.close);
- client.writeBytes(new List.filled(1024 * 1024, 0));
+ client.add(new List.filled(1024 * 1024, 0));
client.destroy();
});
});
@@ -143,7 +144,7 @@
Expect.equals(SIZE, count);
server.close();
});
- client.writeBytes(new List.filled(SIZE, 0));
+ client.add(new List.filled(SIZE, 0));
client.close();
// Start piping now.
completer.complete(null);
@@ -174,7 +175,7 @@
Expect.isTrue(errors <= 1);
server.close();
});
- client.writeBytes(new List.filled(SIZE, 0));
+ client.add(new List.filled(SIZE, 0));
// Destroy other socket now.
completer.complete(null);
var port = new ReceivePort();
@@ -199,7 +200,7 @@
Socket.connect("127.0.0.1", server.port).then((client) {
const int SIZE = 1024 * 1024;
int errors = 0;
- client.writeBytes(new List.filled(SIZE, 0));
+ client.add(new List.filled(SIZE, 0));
client.close();
client.done.catchError((error) {
server.close();
diff --git a/tests/standalone/io/socket_info_test.dart b/tests/standalone/io/socket_info_test.dart
index f3b675f..f626d66 100644
--- a/tests/standalone/io/socket_info_test.dart
+++ b/tests/standalone/io/socket_info_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
void testHostAndPort() {
diff --git a/tests/standalone/io/socket_invalid_arguments_test.dart b/tests/standalone/io/socket_invalid_arguments_test.dart
index b0378a6..61d526d 100644
--- a/tests/standalone/io/socket_invalid_arguments_test.dart
+++ b/tests/standalone/io/socket_invalid_arguments_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
@@ -39,7 +40,7 @@
socket.destroy();
server.close();
});
- socket.writeBytes(buffer);
+ socket.add(buffer);
});
});
}
diff --git a/tests/standalone/io/socket_many_connections_test.dart b/tests/standalone/io/socket_many_connections_test.dart
index 49aa34d..b10ad71 100644
--- a/tests/standalone/io/socket_many_connections_test.dart
+++ b/tests/standalone/io/socket_many_connections_test.dart
@@ -5,6 +5,7 @@
// Test creating a large number of socket connections.
library ServerTest;
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
part "testing_server.dart";
diff --git a/tests/standalone/io/socket_port_test.dart b/tests/standalone/io/socket_port_test.dart
index 009a522..d3c0179 100644
--- a/tests/standalone/io/socket_port_test.dart
+++ b/tests/standalone/io/socket_port_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:io";
void testPort() {
diff --git a/tests/standalone/io/socket_test.dart b/tests/standalone/io/socket_test.dart
index 8e757c8..a405c05 100644
--- a/tests/standalone/io/socket_test.dart
+++ b/tests/standalone/io/socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -113,7 +114,7 @@
ServerSocket.bind().then((server) {
server.listen((_) { });
Socket.connect("127.0.0.1", server.port).then((socket) {
- socket.writeBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ socket.add([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
socket.close();
socket.done.then((_) {
socket.destroy();
@@ -155,7 +156,7 @@
ServerSocket.bind().then((server) {
server.listen(
(client) {
- client.writeBytes(sendData);
+ client.add(sendData);
if (useDestroy) {
client.destroy();
} else {
@@ -171,7 +172,7 @@
Expect.isFalse(onDoneCalled);
onDoneCalled = true;
if (!useDestroy) Expect.listEquals(sendData, data);
- socket.writeBytes([0]);
+ socket.add([0]);
socket.close();
server.close();
port.close();
@@ -186,7 +187,7 @@
ServerSocket.bind().then((server) {
server.listen(
(client) {
- client.writeBytes(sendData);
+ client.add(sendData);
if (useDestroy) {
client.destroy();
} else {
diff --git a/tests/standalone/io/status_file_parser_test.dart b/tests/standalone/io/status_file_parser_test.dart
index aaf9604..0369d49 100644
--- a/tests/standalone/io/status_file_parser_test.dart
+++ b/tests/standalone/io/status_file_parser_test.dart
@@ -4,6 +4,7 @@
library StatusFileParserTest;
+import "package:expect/expect.dart";
import "dart:io";
import "../../../tools/testing/dart/status_file_parser.dart";
diff --git a/tests/standalone/io/stdout_bad_argument_test.dart b/tests/standalone/io/stdout_bad_argument_test.dart
index 481691f..24b2965 100644
--- a/tests/standalone/io/stdout_bad_argument_test.dart
+++ b/tests/standalone/io/stdout_bad_argument_test.dart
@@ -5,7 +5,7 @@
import "dart:io";
main() {
- stdout.writeBytes("Hello\n");
+ stdout.add("Hello\n");
stdout.done.catchError((e) {
exit(0);
});
diff --git a/tests/standalone/io/stdout_stderr_test.dart b/tests/standalone/io/stdout_stderr_test.dart
index 8929ea8..4775891 100644
--- a/tests/standalone/io/stdout_stderr_test.dart
+++ b/tests/standalone/io/stdout_stderr_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
@@ -13,7 +14,7 @@
sink.writeln("Hello");
sink.writeAll(["H", "e", "l", "lo\n"]);
sink.writeCharCode(72);
- sink.writeBytes([101, 108, 108, 111, 10]);
+ sink.add([101, 108, 108, 111, 10]);
var controller = new StreamController();
sink.writeStream(controller.stream);
diff --git a/tests/standalone/io/stream_pipe_test.dart b/tests/standalone/io/stream_pipe_test.dart
index 4e77cdf..c029e0b 100644
--- a/tests/standalone/io/stream_pipe_test.dart
+++ b/tests/standalone/io/stream_pipe_test.dart
@@ -8,6 +8,7 @@
// VMOptions=--short_socket_read --short_socket_write
library ServerTest;
+import "package:expect/expect.dart";
import "dart:io";
import "dart:isolate";
@@ -100,7 +101,7 @@
dstFile.createSync();
var output = dstFile.openWrite();
output.writeStream(srcStream).then((_) {
- output.writeBytes([32]);
+ output.add([32]);
output.close();
output.done.then((_) {
var src = srcFile.openSync();
diff --git a/tests/standalone/io/string_decoder_test.dart b/tests/standalone/io/string_decoder_test.dart
index f2ff9e00..d5c3da1 100644
--- a/tests/standalone/io/string_decoder_test.dart
+++ b/tests/standalone/io/string_decoder_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
diff --git a/tests/standalone/io/string_transformer_test.dart b/tests/standalone/io/string_transformer_test.dart
index d65fb33..a15633d 100644
--- a/tests/standalone/io/string_transformer_test.dart
+++ b/tests/standalone/io/string_transformer_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/test_extension_fail_test.dart b/tests/standalone/io/test_extension_fail_test.dart
index 7109416..0c721a5 100644
--- a/tests/standalone/io/test_extension_fail_test.dart
+++ b/tests/standalone/io/test_extension_fail_test.dart
@@ -17,7 +17,8 @@
case 'windows':
return Process.run('cmd.exe', ['/C', 'copy $src $dst']);
default:
- Expect.fail('Unknown operating system ${Platform.operatingSystem}');
+ throw new RuntimeError(
+ 'Unknown operating system ${Platform.operatingSystem}');
}
}
@@ -30,7 +31,8 @@
case 'windows':
return buildDirectory.append('test_extension.dll');
default:
- Expect.fail('Unknown operating system ${Platform.operatingSystem}');
+ throw new RuntimeError(
+ 'Unknown operating system ${Platform.operatingSystem}');
}
}
@@ -58,8 +60,14 @@
}).then((ProcessResult result) {
print("ERR: ${result.stderr}\n\n");
print("OUT: ${result.stdout}\n\n");
- Expect.equals(255, result.exitCode);
- Expect.isTrue(result.stderr.contains("Unhandled exception:"));
- Expect.isTrue(result.stderr.contains("ball"));
+ if (result.exitCode != 255) {
+ throw new RuntimeError("bad exit code");
+ }
+ if (!result.stderr.contains("Unhandled exception:")) {
+ throw new RuntimeError("stderr doesn't contain unhandled exception.");
+ }
+ if (!result.stderr.contains("ball")) {
+ throw new RuntimeError("stderr doesn't contain 'ball'.");
+ }
}).whenComplete(() => tempDirectory.deleteSync(recursive: true));
}
diff --git a/tests/standalone/io/test_extension_fail_tester.dart b/tests/standalone/io/test_extension_fail_tester.dart
index 7ce00e2..aa8daae 100644
--- a/tests/standalone/io/test_extension_fail_tester.dart
+++ b/tests/standalone/io/test_extension_fail_tester.dart
@@ -12,7 +12,7 @@
try {
Cat.throwMeTheBall("ball");
} on String catch (e) {
- Expect.equals("ball", e);
+ if (e != "ball") throw new RuntimeError("exception not equal to 'ball'");
}
// Make sure the exception is thrown out to the event handler from C++ code.
// The harness expects the string "ball" to be thrown and the process to
diff --git a/tests/standalone/io/test_extension_test.dart b/tests/standalone/io/test_extension_test.dart
index 0f5662e..9961daf 100644
--- a/tests/standalone/io/test_extension_test.dart
+++ b/tests/standalone/io/test_extension_test.dart
@@ -4,6 +4,7 @@
//
// Dart test program for testing native extensions.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/io/test_extension_tester.dart b/tests/standalone/io/test_extension_tester.dart
index deacbaa..7077717 100644
--- a/tests/standalone/io/test_extension_tester.dart
+++ b/tests/standalone/io/test_extension_tester.dart
@@ -6,6 +6,22 @@
import "test_extension.dart";
+class Expect {
+ static void equals(expected, actual, [msg]) {
+ if (expected != actual) {
+ if (msg == null) msg = "Expected: $expected. Actual: $actual";
+ throw new RuntimeError(msg);
+ }
+ }
+
+ static void isNull(x, [msg]) {
+ if (x != null) {
+ if (msg != null) msg = "$x not null";
+ throw new RuntimeError(msg);
+ }
+ }
+}
+
main() {
Expect.equals('cat 13', new Cat(13).toString(), 'new Cat(13).toString()');
diff --git a/tests/standalone/io/test_runner_test.dart b/tests/standalone/io/test_runner_test.dart
index b9ad2c6..f4a975d 100644
--- a/tests/standalone/io/test_runner_test.dart
+++ b/tests/standalone/io/test_runner_test.dart
@@ -24,14 +24,21 @@
numCompletedTests++;
CommandOutput output = testCase.lastCommandOutput;
if (testCase.displayName == "fail-unexpected") {
- Expect.isTrue(output.unexpectedOutput);
+ if (!output.unexpectedOutput) {
+ throw "Expected fail-unexpected";
+ }
} else {
- Expect.isFalse(output.unexpectedOutput);
+ if (output.unexpectedOutput) {
+ throw "Unexpected fail";
+ }
}
}
static void finished() {
- Expect.equals(numTests, numCompletedTests);
+ if (numTests != numCompletedTests) {
+ throw "bad completion count. "
+ "expected: $numTests, actual: $numCompletedTests";
+ }
}
}
@@ -111,7 +118,7 @@
return;
case 'fail-unexpected':
case 'fail':
- Expect.fail("This test always fails, to test the test scripts.");
+ throw "This test always fails, to test the test scripts.";
break;
case 'timeout':
// Run for 10 seconds, then exit. This tests a 2 second timeout.
diff --git a/tests/standalone/io/url_encoding_test.dart b/tests/standalone/io/url_encoding_test.dart
index 788dfb1..c99346a 100644
--- a/tests/standalone/io/url_encoding_test.dart
+++ b/tests/standalone/io/url_encoding_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:async";
import "dart:utf";
diff --git a/tests/standalone/io/web_socket_protocol_processor_test.dart b/tests/standalone/io/web_socket_protocol_processor_test.dart
index c762ae4..54a7c12 100644
--- a/tests/standalone/io/web_socket_protocol_processor_test.dart
+++ b/tests/standalone/io/web_socket_protocol_processor_test.dart
@@ -2,11 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import "dart:utf";
import "dart:math";
import "dart:async";
import "dart:collection";
import "dart:typeddata";
+import "dart:isolate";
part "../../../sdk/lib/io/http.dart";
part "../../../sdk/lib/io/buffer_list.dart";
@@ -225,7 +227,22 @@
Expect.equals(0, mc.closeCount);
}
+void testUnmaskedMessage() {
+ var transformer = new _WebSocketProtocolTransformer(true);
+ var controller = new StreamController();
+ var port = new ReceivePort();
+ controller.stream.transform(transformer).listen((_) {}, onError: (e) {
+ port.close();
+ });
+ var message = new Uint8List(10);
+ List<int> frame = createFrame(
+ true, FRAME_OPCODE_BINARY, null, message, 0, message.length);
+ controller.add(frame);
+}
+
+
void main() {
testFullMessages();
testFragmentedMessages();
+ testUnmaskedMessage();
}
diff --git a/tests/standalone/io/web_socket_test.dart b/tests/standalone/io/web_socket_test.dart
index 94cd01d..9a126f4 100644
--- a/tests/standalone/io/web_socket_test.dart
+++ b/tests/standalone/io/web_socket_test.dart
@@ -7,6 +7,7 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+import "package:expect/expect.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
diff --git a/tests/standalone/io/windows_environment_script.dart b/tests/standalone/io/windows_environment_script.dart
index d0fce49..f142163 100644
--- a/tests/standalone/io/windows_environment_script.dart
+++ b/tests/standalone/io/windows_environment_script.dart
@@ -6,9 +6,9 @@
main() {
var scriptDir = Platform.environment['SCRIPTDIR'];
- Expect.isTrue(scriptDir.contains('å'));
+ if (!scriptDir.contains('å')) throw "scriptDir not containing character å";
scriptDir = Platform.environment['ScriptDir'];
- Expect.isTrue(scriptDir.contains('å'));
+ if (!scriptDir.contains('å')) throw "scriptDir not containing character å";
var str = new File('$scriptDir/funky.bat').readAsStringSync();
- Expect.isTrue(str.contains('%~dp0'));
+ if (!str.contains('%~dp0')) throw "str not containing dp0";
}
diff --git a/tests/standalone/io/windows_environment_test.dart b/tests/standalone/io/windows_environment_test.dart
index dfe5af6..6508da8 100644
--- a/tests/standalone/io/windows_environment_test.dart
+++ b/tests/standalone/io/windows_environment_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import "dart:io";
main() {
@@ -21,7 +22,7 @@
var script = scriptDir.append('windows_environment_script.dart');
Process.run('cmd',
['/c', funkyFile.path, dart, script.toNativePath()]).then((p) {
- Expect.equals(0, p.exitCode);
+ if (0 != p.exitCode) throw "Exit code not 0";
tempDir.deleteSync(recursive: true);
});
}
diff --git a/tests/standalone/io/windows_file_system_links_test.dart b/tests/standalone/io/windows_file_system_links_test.dart
index f161b0e..7775be8 100644
--- a/tests/standalone/io/windows_file_system_links_test.dart
+++ b/tests/standalone/io/windows_file_system_links_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:expect/expect.dart';
import "dart:io";
import "dart:isolate";
@@ -30,13 +31,13 @@
// Test Junction pointing to a missing directory.
new Directory(x).deleteSync();
- Expect.isTrue(new Directory(y).existsSync());
+ Expect.isTrue(new Link(y).existsSync());
Expect.isFalse(new Directory(x).existsSync());
Expect.isTrue(FileSystemEntity.isLinkSync(y));
Expect.isFalse(FileSystemEntity.isLinkSync(x));
Expect.isFalse(FileSystemEntity.isDirectorySync(y));
Expect.isFalse(FileSystemEntity.isDirectorySync(x));
- Expect.equals(FileSystemEntityType.NOT_FOUND,
+ Expect.equals(FileSystemEntityType.LINK,
FileSystemEntity.typeSync(y));
Expect.equals(FileSystemEntityType.NOT_FOUND,
FileSystemEntity.typeSync(x));
@@ -47,7 +48,7 @@
Expect.equals(x, new Link(y).targetSync());
// Delete Junction pointing to a missing directory.
- new Directory(y).deleteSync();
+ new Link(y).deleteSync();
Expect.isFalse(FileSystemEntity.isLinkSync(y));
Expect.equals(FileSystemEntityType.NOT_FOUND,
FileSystemEntity.typeSync(y));
diff --git a/tests/standalone/io/zlib_test.dart b/tests/standalone/io/zlib_test.dart
index 0c50fc3..1e83af9 100644
--- a/tests/standalone/io/zlib_test.dart
+++ b/tests/standalone/io/zlib_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
diff --git a/tests/standalone/left_shift_bit_and_op_test.dart b/tests/standalone/left_shift_bit_and_op_test.dart
index c9e142a..490881a 100644
--- a/tests/standalone/left_shift_bit_and_op_test.dart
+++ b/tests/standalone/left_shift_bit_and_op_test.dart
@@ -4,6 +4,8 @@
//
// Tests optimizing (a << b) & c if c is a Smi constant.
+import "package:expect/expect.dart";
+
main() {
checkshiftAnd32();
checkShiftAnd64();
diff --git a/tests/standalone/medium_integer_test.dart b/tests/standalone/medium_integer_test.dart
index 579f721..6f826ca 100644
--- a/tests/standalone/medium_integer_test.dart
+++ b/tests/standalone/medium_integer_test.dart
@@ -5,6 +5,7 @@
// as Smi's would be used to represent many of the numbers.
library MediumIntegerTest;
+import "package:expect/expect.dart";
class MediumIntegerTest {
diff --git a/tests/standalone/number_identity_test.dart b/tests/standalone/number_identity_test.dart
index 4336e81..4e83e46 100644
--- a/tests/standalone/number_identity_test.dart
+++ b/tests/standalone/number_identity_test.dart
@@ -6,6 +6,8 @@
// Tests 'identical' for cases that not supported in dart2js (bigint,
// disambiguation int/double).
+import "package:expect/expect.dart";
+
main() {
for (int i = 0; i < 1000; i++) testNumberIdentity();
}
diff --git a/tests/standalone/out_of_memory_test.dart b/tests/standalone/out_of_memory_test.dart
index 1fb36f9..91e7c27 100644
--- a/tests/standalone/out_of_memory_test.dart
+++ b/tests/standalone/out_of_memory_test.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import "package:expect/expect.dart";
+
void main() {
var number_of_ints = 134000000;
var exception_thrown = false;
diff --git a/tests/standalone/package/package_test.dart b/tests/standalone/package/package_test.dart
index c71d54d..b606a23 100644
--- a/tests/standalone/package/package_test.dart
+++ b/tests/standalone/package/package_test.dart
@@ -15,5 +15,7 @@
lib1();
// Make sure they were all reached successfully.
- Expect.equals(output, 'main|lib1|lib2|lib3');
+ if (output != 'main|lib1|lib2|lib3') {
+ throw new Error("libraries were not reached successfully");
+ }
}
diff --git a/tests/standalone/package/packages/package1.dart b/tests/standalone/package/packages/package1.dart
index c409ec5..d0a6081 100644
--- a/tests/standalone/package/packages/package1.dart
+++ b/tests/standalone/package/packages/package1.dart
@@ -9,6 +9,10 @@
import 'package:package2.dart' as p3;
main() {
- Expect.identical(p1.x, p2.x);
- Expect.identical(p1.x, p3.x);
+ if (!identical(p1.x, p2.x)) {
+ throw new Error("Not identical");
+ }
+ if (!identical(p1.x, p3.x)) {
+ throw new Error("Not identical");
+ }
}
diff --git a/tests/standalone/pow_test.dart b/tests/standalone/pow_test.dart
index 02ad5a3..01f7506 100644
--- a/tests/standalone/pow_test.dart
+++ b/tests/standalone/pow_test.dart
@@ -6,6 +6,7 @@
library pow_test;
+import "package:expect/expect.dart";
import 'dart:math';
var expectedResults =
diff --git a/tests/standalone/standalone.status b/tests/standalone/standalone.status
index 4872967..f17fa0f 100644
--- a/tests/standalone/standalone.status
+++ b/tests/standalone/standalone.status
@@ -11,7 +11,6 @@
[ $runtime == vm ]
package/package_isolate_test: Fail # http://dartbug.com/7520.
io/raw_server_socket_cancel_test: Pass, Fail, Timeout # Issue 8675
-debugger/basic_debugger_test: Skip # Issue 8232.
[ $runtime == vm && $checked ]
# These tests have type errors on purpose.
@@ -26,8 +25,6 @@
io/directory_fuzz_test: Skip
[ $runtime == vm && $system == macos ]
-io/regress_7191_test: Pass, Timeout # http://dartbug.com/8091
-
# This test fails with "Too many open files" on the Mac OS buildbot.
# This is expected as MacOS by default runs with a very low number
# of allowed open files ('ulimit -n' says something like 256).
diff --git a/tests/standalone/status_expression_test.dart b/tests/standalone/status_expression_test.dart
index 2c6da43..03be619 100644
--- a/tests/standalone/status_expression_test.dart
+++ b/tests/standalone/status_expression_test.dart
@@ -4,6 +4,7 @@
library StatusExpressionTest;
+import "package:expect/expect.dart";
import "../../tools/testing/dart/status_expression.dart";
@@ -64,7 +65,8 @@
} on Exception catch (e) {
thrown = e;
}
- Expect.equals("Syntax error in '$input'", thrown.toString());
+ Expect.equals("FormatException: Syntax error in '$input'",
+ thrown.toString());
}
static void test4() {
@@ -77,7 +79,8 @@
} on Exception catch (e) {
thrown = e;
}
- Expect.equals("Syntax error in '$input'", thrown.toString());
+ Expect.equals("FormatException: Syntax error in '$input'",
+ thrown.toString());
}
static void test5() {
diff --git a/tests/standalone/typed_array_test.dart b/tests/standalone/typed_array_test.dart
index 4532ee1..007f9ec 100644
--- a/tests/standalone/typed_array_test.dart
+++ b/tests/standalone/typed_array_test.dart
@@ -6,6 +6,7 @@
// Library tag to be able to run in html test framework.
library TypedArray;
+import "package:expect/expect.dart";
import 'dart:isolate';
import 'dart:typeddata';
diff --git a/tests/standalone/typed_data_test.dart b/tests/standalone/typed_data_test.dart
index cdbf3bf..62c4425 100644
--- a/tests/standalone/typed_data_test.dart
+++ b/tests/standalone/typed_data_test.dart
@@ -7,6 +7,7 @@
// Library tag to be able to run in html test framework.
library TypedDataTest;
+import "package:expect/expect.dart";
import 'dart:typeddata';
void testCreateUint8TypedData() {
@@ -313,6 +314,31 @@
Expect.equals(5, bytes.where((v) => v > 0).length);
}
+testCreationFromList() {
+ var intList =
+ [-10000000000000000000, -255, -127, 0, 128, 256, 1000000000000000000000];
+ var intLists = [];
+ intLists.add(new Int8List.fromList(intList));
+ intLists.add(new Int16List.fromList(intList));
+ intLists.add(new Int32List.fromList(intList));
+ intLists.add(new Int64List.fromList(intList));
+ intLists.add(new Uint8List.fromList(intList));
+ intLists.add(new Uint16List.fromList(intList));
+ intLists.add(new Uint32List.fromList(intList));
+ intLists.add(new Uint64List.fromList(intList));
+ var doubleList =
+ [-123123123123.123123123123, -123.0, 0.0, 123.0, 123123123123.123123123];
+ var doubleLists = [];
+ doubleLists.add(new Float32List.fromList(doubleList));
+ doubleLists.add(new Float64List.fromList(doubleList));
+ for (var ints in intLists) {
+ for (var doubles in doubleLists) {
+ Expect.throws(() => ints[0] = doubles[0]);
+ Expect.throws(() => doubles[0] = ints[0]);
+ }
+ }
+}
+
main() {
for (int i = 0; i < 2000; i++) {
testCreateUint8TypedData();
@@ -371,5 +397,6 @@
testExternalClampedUnsignedTypedDataRange(true);
testViewCreation();
testWhere();
+ testCreationFromList();
}
diff --git a/tests/standalone/typed_data_view_test.dart b/tests/standalone/typed_data_view_test.dart
index 4ac855b..5e046ec 100644
--- a/tests/standalone/typed_data_view_test.dart
+++ b/tests/standalone/typed_data_view_test.dart
@@ -7,6 +7,7 @@
// Library tag to be able to run in html test framework.
library TypedDataTest;
+import "package:expect/expect.dart";
import 'dart:typeddata';
validate(TypedData list, num expected) {
diff --git a/tests/utils/json_test.dart b/tests/utils/json_test.dart
index f4b6521..7d350e3 100644
--- a/tests/utils/json_test.dart
+++ b/tests/utils/json_test.dart
@@ -4,6 +4,7 @@
library jsonTest;
+import "package:expect/expect.dart";
import 'dart:json';
main() {
diff --git a/tests/utils/recursive_import_test.dart b/tests/utils/recursive_import_test.dart
index b3020c5..2c707e7 100644
--- a/tests/utils/recursive_import_test.dart
+++ b/tests/utils/recursive_import_test.dart
@@ -4,6 +4,7 @@
// Test of "recursive" imports using the dart2js compiler API.
+import "package:expect/expect.dart";
import 'dart:async';
import '../../sdk/lib/_internal/compiler/compiler.dart';
import 'dart:uri';
diff --git a/tests/utils/uri_test.dart b/tests/utils/uri_test.dart
index a5f0c23..3653d2a 100644
--- a/tests/utils/uri_test.dart
+++ b/tests/utils/uri_test.dart
@@ -4,6 +4,7 @@
library uriTest;
+import "package:expect/expect.dart";
import 'dart:utf';
import 'dart:uri';
diff --git a/tests/utils/utils.status b/tests/utils/utils.status
index efd167c..376aa7e 100644
--- a/tests/utils/utils.status
+++ b/tests/utils/utils.status
@@ -6,7 +6,7 @@
dummy_compiler_test: Slow, Pass
recursive_import_test: Slow, Pass
-[ $compiler == dart2js && $checked ]
+[ $compiler == dart2js && $checked]
dummy_compiler_test: Slow, Fail # http://dartbug.com/9687
[ $compiler == none && $runtime == drt ]
diff --git a/tools/VERSION b/tools/VERSION
index 96004c7..e4e6452 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -1,4 +1,4 @@
MAJOR 0
MINOR 4
-BUILD 5
-PATCH 3
+BUILD 6
+PATCH 0
diff --git a/tools/bots/compiler.py b/tools/bots/compiler.py
index ff1eb33..3de5b93 100644
--- a/tools/bots/compiler.py
+++ b/tools/bots/compiler.py
@@ -210,7 +210,9 @@
# The dart2js compiler isn't self-hosted (yet) so we run its
# unit tests on the VM. We avoid doing this on the builders
# that run the browser tests to cut down on the cycle time.
- TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'], flags)
+ TestStep("dart2js_unit", mode, system, 'none', 'vm', ['dart2js'],
+ # Run the unit tests in checked mode (the VM's checked mode).
+ ['--checked'])
if system.startswith('win') and runtime.startswith('ie10'):
TestStep("dart2js", mode, system, 'dart2js', runtime, ['html'], flags)
@@ -220,7 +222,13 @@
# TODO(kasperl): Consider running peg and css tests too.
extras = ['dart2js_extra', 'dart2js_native', 'dart2js_foreign']
- TestStep("dart2js_extra", mode, system, 'dart2js', runtime, extras, flags)
+ extras_flags = flags
+ if system == 'linux' and runtime == 'd8':
+ # Run the extra tests in checked mode, but only on linux/d8.
+ # Other systems have less resources and tend to time out.
+ extras_flags = extras_flags + ['--host-checked']
+ TestStep("dart2js_extra", mode, system, 'dart2js', runtime, extras,
+ extras_flags)
def _DeleteTempWebdriverProfiles(directory):
diff --git a/tools/build.py b/tools/build.py
index 414f980..2ee32d6 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -7,6 +7,7 @@
import optparse
import os
+import re
import shutil
import subprocess
import sys
@@ -267,21 +268,30 @@
# The capability "clr_eol" means clear the line from cursor to end
# of line. See man pages for tput and terminfo.
try:
- clr_eol = subprocess.check_output(['tput', '-T' + term, 'el'],
- stderr=subprocess.STDOUT)
+ with open('/dev/null', 'a') as dev_null:
+ clr_eol = subprocess.check_output(['tput', '-T' + term, 'el'],
+ stderr=dev_null)
if clr_eol:
is_fancy_tty = True
except subprocess.CalledProcessError:
is_fancy_tty = False
except AttributeError:
is_fancy_tty = False
+ pattern = re.compile(r'=== BUILD .* TARGET (.*) OF PROJECT (.*) WITH ' +
+ r'CONFIGURATION (.*) ===')
+ has_interesting_info = False
for line in unbuffered(process.stdout.readline):
line = line.rstrip()
if line.startswith('=== BUILD ') or line.startswith('** BUILD '):
- if not is_empty_chunk(chunk):
- print '\n'.join(chunk)
+ has_interesting_info = False
section = line
if is_fancy_tty:
+ match = re.match(pattern, section)
+ if match:
+ section = '%s/%s/%s' % (
+ match.group(3), match.group(2), match.group(1))
+ # Truncate to avoid extending beyond 80 columns.
+ section = section[:80]
# If stdout is a terminal, emit "progress" information. The
# progress information is the first line of the current chunk.
# After printing the line, move the cursor back to the
@@ -293,10 +303,19 @@
# overwrites a longer line.
print '%s%s\r' % (clr_eol, section),
chunk = []
- if not section:
+ if not section or has_interesting_info:
print line
else:
- chunk.append(line)
+ length = len(chunk)
+ if length == 1 and line != 'Check dependencies':
+ has_interesting_info = True
+ elif (length == 2 or length == 3) and line:
+ has_interesting_info = True
+ if has_interesting_info:
+ print '\n'.join(chunk)
+ chunk = []
+ else:
+ chunk.append(line)
if not is_empty_chunk(chunk):
print '\n'.join(chunk)
@@ -325,6 +344,7 @@
for target_os in options.os:
for mode in options.mode:
for arch in options.arch:
+ os.environ['DART_BUILD_MODE'] = mode
build_config = utils.GetBuildConf(mode, arch)
if HOST_OS == 'macos':
filter_xcodebuild_output = True
diff --git a/tools/create_sdk.py b/tools/create_sdk.py
index c3aeed9..942b57c 100755
--- a/tools/create_sdk.py
+++ b/tools/create_sdk.py
@@ -18,6 +18,8 @@
# ......dart2js
# ......dart_analyzer
# ......pub
+# ......snapshots/
+# ........utils_wrapper.dart.snapshot
# ....include/
# ......dart_api.h
# ......dart_debugger_api.h
@@ -53,7 +55,7 @@
# ......(more will come here)
-
+import optparse
import os
import re
import sys
@@ -69,6 +71,16 @@
# TODO(dgrove): Only import modules following Google style guide.
from shutil import copyfile, copymode, copytree, ignore_patterns, rmtree, move
+
+def GetOptions():
+ options = optparse.OptionParser(usage='usage: %prog [options]')
+ options.add_option("--sdk_output_dir",
+ help='Where to output the sdk')
+ options.add_option("--utils_snapshot_location",
+ help='Location of the utils snapshot.')
+ return options.parse_args()
+
+
def ReplaceInFiles(paths, subs):
'''Reads a series of files, applies a series of substitutions to each, and
saves them back out. subs should by a list of (pattern, replace) tuples.'''
@@ -99,33 +111,28 @@
Copy(src, dest)
-def CopyDartScripts(home, build_dir, sdk_root, version):
- if version:
- ReplaceInFiles([os.path.join(sdk_root, 'lib', '_internal', 'compiler',
- 'implementation', 'compiler.dart')],
- [(r"BUILD_ID = 'build number could not be determined'",
- r"BUILD_ID = '%s'" % version)])
+def CopyDartScripts(home, sdk_root):
# TODO(dgrove) - add pub once issue 6619 is fixed
for executable in ['dart2js', 'dartdoc']:
CopyShellScript(os.path.join(home, 'sdk', 'bin', executable),
os.path.join(sdk_root, 'bin'))
- subprocess.call([os.path.join(build_dir, 'dart'),
- '--generate-script-snapshot=%s' %
- os.path.join(sdk_root, 'lib', '_internal', 'compiler',
- 'implementation', 'dart2js.dart.snapshot'),
- os.path.join(sdk_root, 'lib', '_internal', 'compiler',
- 'implementation', 'dart2js.dart')])
+def CopySnapshots(snapshot, sdk_root):
+ copyfile(snapshot, join(sdk_root, 'bin', 'snapshots', basename(snapshot)))
def Main(argv):
- # Pull in all of the gpyi files which will be munged into the sdk.
+ # Pull in all of the gypi files which will be munged into the sdk.
HOME = dirname(dirname(realpath(__file__)))
- SDK = argv[1]
+ (options, args) = GetOptions()
+
+ SDK = options.sdk_output_dir
SDK_tmp = '%s.tmp' % SDK
+ SNAPSHOT = options.utils_snapshot_location
+
# TODO(dgrove) - deal with architectures that are not ia32.
if exists(SDK):
@@ -140,11 +147,13 @@
BIN = join(SDK_tmp, 'bin')
os.makedirs(BIN)
+ os.makedirs(join(BIN, 'snapshots'))
+
# Copy the Dart VM binary and the Windows Dart VM link library
# into sdk/bin.
#
# TODO(dgrove) - deal with architectures that are not ia32.
- build_dir = os.path.dirname(argv[1])
+ build_dir = os.path.dirname(SDK)
dart_file_extension = ''
analyzer_file_extension = ''
if HOST_OS == 'win32':
@@ -199,7 +208,9 @@
#
os.makedirs(join(LIB, 'html'))
- for library in ['_internal', 'async', 'collection', '_collection_dev', 'core',
+
+ for library in ['_internal',
+ 'async', 'collection', '_collection_dev', 'core',
'crypto', 'io', 'isolate',
join('chrome', 'dart2js'), join('chrome', 'dartium'),
join('html', 'dart2js'), join('html', 'dartium'),
@@ -214,7 +225,6 @@
copytree(join(HOME, 'sdk', 'lib', library), join(LIB, library),
ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh'))
-
# Create and copy packages.
PACKAGES = join(SDK_tmp, 'packages')
os.makedirs(PACKAGES)
@@ -224,7 +234,7 @@
#
for library in ['args', 'http', 'intl', 'logging', 'meta', 'oauth2', 'pathos',
- 'serialization', 'unittest', 'yaml']:
+ 'serialization', 'unittest', 'yaml', 'analyzer_experimental']:
copytree(join(HOME, 'pkg', library, 'lib'), join(PACKAGES, library),
ignore=ignore_patterns('*.svn'))
@@ -269,12 +279,12 @@
"7zip/7za.exe"),
])
- version = utils.GetVersion()
-
# Copy dart2js/dartdoc/pub.
- CopyDartScripts(HOME, build_dir, SDK_tmp, version)
+ CopyDartScripts(HOME, SDK_tmp)
+ CopySnapshots(SNAPSHOT, SDK_tmp)
# Write the 'version' file
+ version = utils.GetVersion()
versionFile = open(os.path.join(SDK_tmp, 'version'), 'w')
versionFile.write(version + '\n')
versionFile.close()
diff --git a/tools/ddbg.dart b/tools/ddbg.dart
index c92174c..e79e294 100644
--- a/tools/ddbg.dart
+++ b/tools/ddbg.dart
@@ -15,18 +15,16 @@
Socket vmSock;
String vmData;
-StreamSubscription<String> streamSubscription;
+var stdinSubscription;
+var vmSubscription;
int seqNum = 0;
int isolate_id = -1;
-bool verbose = false;
+final verbose = false;
+final printMessages = false;
-// The current stack trace, while the VM is paused. It's a list
-// of activation frames.
-List stackTrace;
-
-// The current activation frame, while the VM is paused.
-Map curFrame;
+// The location of the last paused event.
+Map pausedLocation = null;
void printHelp() {
@@ -48,6 +46,7 @@
pg <id> Print all global variables visible within given library id
ls <lib_id> List loaded scripts in library
gs <lib_id> <script_url> Get source text of script in library
+ tok <lib_id> <script_url> Get line and token table of script in library
epi <none|all|unhandled> Set exception pause info
i <id> Interrupt execution of given isolate id
h Print help
@@ -56,9 +55,9 @@
void quitShell() {
- streamSubscription.cancel();
+ vmSubscription.cancel();
vmSock.close();
- stdin.close();
+ stdinSubscription.cancel();
}
@@ -88,7 +87,6 @@
"command": simple_commands[command],
"params": { "isolateId" : isolate_id } };
sendCmd(cmd).then((result) => handleGenericResponse(result));
- stackTrace = curFrame = null;
} else if (command == "bt") {
var cmd = { "id": seqNum,
"command": "getStackTrace",
@@ -101,8 +99,9 @@
sendCmd(cmd).then((result) => handleGetLibraryResponse(result));
} else if (command == "sbp" && args.length >= 2) {
var url, line;
- if (args.length == 2) {
- url = stackTrace[0]["location"]["url"];
+ if (args.length == 2 && pausedLocation != null) {
+ url = pausedLocation["url"];
+ assert(url != null);
line = int.parse(args[1]);
} else {
url = args[1];
@@ -181,6 +180,13 @@
"libraryId": int.parse(args[1]),
"url": args[2] } };
sendCmd(cmd).then((result) => handleGetSourceResponse(result));
+ } else if (command == "tok" && args.length == 3) {
+ var cmd = { "id": seqNum,
+ "command": "getLineNumberTable",
+ "params": { "isolateId" : isolate_id,
+ "libraryId": int.parse(args[1]),
+ "url": args[2] } };
+ sendCmd(cmd).then((result) => handleGetLineTableResponse(result));
} else if (command == "epi" && args.length == 2) {
var cmd = { "id": seqNum,
"command": "setPauseOnException",
@@ -324,6 +330,13 @@
}
+handleGetLineTableResponse(response) {
+ Map result = response["result"];
+ var info = result["lines"];
+ print("Line info table:\n$info");
+}
+
+
void handleGetLibraryResponse(response) {
Map result = response["result"];
List libs = result["libraries"];
@@ -391,13 +404,13 @@
void handlePausedEvent(msg) {
assert(msg["params"] != null);
var reason = msg["params"]["reason"];
- isolate_id = msg["params"]["id"];
- stackTrace = msg["params"]["callFrames"];
- assert(stackTrace != null);
- assert(stackTrace.length >= 1);
- curFrame = stackTrace[0];
+ isolate_id = msg["params"]["isolateId"];
+ assert(isolate_id != null);
+ pausedLocation = msg["params"]["location"];
+ assert(pausedLocation != null);
if (reason == "breakpoint") {
print("Isolate $isolate_id paused on breakpoint");
+ print("location: $pausedLocation");
} else if (reason == "interrupted") {
print("Isolate $isolate_id paused due to an interrupt");
} else {
@@ -406,8 +419,6 @@
print("Isolate $isolate_id paused on exception");
print(remoteObject(excObj));
}
- print("Stack trace:");
- printStackTrace(stackTrace);
}
@@ -448,14 +459,32 @@
}
}
+bool haveGarbageVmData() {
+ if (vmData == null || vmData.length == 0) return false;
+ var i = 0, char = " ";
+ while (i < vmData.length) {
+ char = vmData[i];
+ if (char != " " && char != "\n" && char != "\r" && char != "\t") break;
+ i++;
+ }
+ if (i >= vmData.length) {
+ return false;
+ } else {
+ return char != "{";
+ }
+}
+
void processVmData(String data) {
- final printMessages = false;
if (vmData == null || vmData.length == 0) {
vmData = data;
} else {
vmData = vmData + data;
}
+ if (haveGarbageVmData()) {
+ print("Error: have garbage data from VM: '$vmData'");
+ return;
+ }
int msg_len = jsonObjectLength(vmData);
if (printMessages && msg_len == 0) {
print("have partial or illegal json message"
@@ -472,8 +501,13 @@
if (printMessages) { print("at least one message: '$vmData'"); }
var msg = vmData.substring(0, msg_len);
if (printMessages) { print("first message: $msg"); }
- processVmMessage(msg);
vmData = vmData.substring(msg_len);
+ if (haveGarbageVmData()) {
+ print("Error: garbage data after previous message: '$vmData'");
+ print("Previous message was: '$msg'");
+ return;
+ }
+ processVmMessage(msg);
msg_len = jsonObjectLength(vmData);
}
if (printMessages) { print("leftover vm data '$vmData'"); }
@@ -530,8 +564,8 @@
outstandingCommands = new Map<int, Completer>();
Socket.connect("127.0.0.1", 5858).then((s) {
vmSock = s;
- Stream<String> stringStream = vmSock.transform(new StringDecoder());
- streamSubscription = stringStream.listen(
+ var stringStream = vmSock.transform(new StringDecoder());
+ vmSubscription = stringStream.listen(
(String data) {
processVmData(data);
},
@@ -543,9 +577,9 @@
print("Error in debug connection: $err");
quitShell();
});
- stdin.transform(new StringDecoder())
- .transform(new LineTransformer())
- .listen((String line) => processCommand(line));
+ stdinSubscription = stdin.transform(new StringDecoder())
+ .transform(new LineTransformer())
+ .listen((String line) => processCommand(line));
});
}
diff --git a/tools/dom/docs/docs.json b/tools/dom/docs/docs.json
index 568e824..4b67a76 100644
--- a/tools/dom/docs/docs.json
+++ b/tools/dom/docs/docs.json
@@ -11,7 +11,7 @@
" * Example usage:",
" *",
" * var canvas = new CanvasElement(width: 600, height: 600);",
- " * var ctx = canvas.context2d;",
+ " * var ctx = canvas.context2D;",
" * ctx.clearRect(0, 0, 600, 600);",
" * ctx.save();",
" * // Create radial gradient.",
@@ -56,7 +56,7 @@
" * Example usage:",
" *",
" * var canvas = new CanvasElement(width: 600, height: 600);",
- " * var ctx = canvas.context2d;",
+ " * var ctx = canvas.context2D;",
" * var img = new ImageElement();",
" * // Image src needs to be loaded before pattern is applied.",
" * img.onLoad.listen((event) {",
@@ -92,6 +92,28 @@
]
}
},
+ "Clipboard": {
+ "members": {
+ "getData": [
+ "/**",
+ " * Gets the data for the specified type.",
+ " *",
+ " * The data is only available from within a drop operation (such as an",
+ " * [Element.onDrop] event) and will return `null` before the event is",
+ " * triggered.",
+ " *",
+ " * Data transfer is prohibited across domains. If a drag originates",
+ " * from content from another domain or protocol (HTTP vs HTTPS) then the",
+ " * data cannot be accessed.",
+ " *",
+ " * The [type] can have values such as:",
+ " *",
+ " * * `'Text'`",
+ " * * `'URL'`",
+ " */"
+ ]
+ }
+ },
"Document": {
"members": {
"body": [
@@ -232,7 +254,7 @@
" * Example usage:",
" *",
" * CanvasElement canvas = new CanvasElement();",
- " * var ctx = canvas.context2d",
+ " * var ctx = canvas.context2D",
" * ..fillStyle = \"rgb(200,0,0)\"",
" * ..fillRect(10, 10, 55, 50);",
" * var dataUrl = canvas.toDataURL(\"image/jpeg\", 0.95);",
@@ -343,30 +365,6 @@
" */"
]
},
- "WorkerContext": {
- "members": {
- "webkitRequestFileSystem": [
- "/**",
- " * Access a sandboxed file system of the specified `size`. If `persistent` is",
- " * true, the application will request permission from the user to create",
- " * lasting storage. This storage cannot be freed without the user's",
- " * permission. Returns a [Future] whose value stores a reference to the",
- " * sandboxed file system for use. Because the file system is sandboxed,",
- " * applications cannot access file systems created in other web pages. ",
- " */"
- ],
- "webkitRequestFileSystemSync": [
- "/**",
- " * Access a sandboxed file system of the specified `size`. If `persistent` is",
- " * true, the application will request permission from the user to create",
- " * lasting storage. This storage cannot be freed without the user's",
- " * permission. This call will block until a reference to the synchronous file ",
- " * system API has been obtained. Because the file system is sandboxed,",
- " * applications cannot access file systems created in other web pages. ",
- " */"
- ]
- }
- },
"XMLHttpRequest": {
"members": {
"abort": [
diff --git a/tools/dom/scripts/dartdomgenerator.py b/tools/dom/scripts/dartdomgenerator.py
index 149ae86..6af0d7d 100755
--- a/tools/dom/scripts/dartdomgenerator.py
+++ b/tools/dom/scripts/dartdomgenerator.py
@@ -20,7 +20,8 @@
from htmleventgenerator import HtmlEventGenerator
from htmlrenamer import HtmlRenamer
from systemhtml import DartLibraryEmitter, Dart2JSBackend,\
- HtmlDartInterfaceGenerator, DartLibrary, DartLibraries
+ HtmlDartInterfaceGenerator, DartLibrary, DartLibraries,\
+ HTML_LIBRARY_NAMES
from systemnative import CPPLibraryEmitter, DartiumBackend
from templateloader import TemplateLoader
@@ -29,9 +30,6 @@
_logger = logging.getLogger('dartdomgenerator')
-_libraries = ['chrome', 'html', 'indexed_db', 'svg', 'web_audio', 'web_gl',
- 'web_sql']
-
class GeneratorOptions(object):
def __init__(self, templates, database, type_registry, renamer):
self.templates = templates
@@ -102,7 +100,7 @@
dart_output_dir = os.path.join(dart2js_output_dir, 'dart')
dart_libraries = DartLibraries(
- _libraries, template_loader, 'dart2js', dart2js_output_dir)
+ HTML_LIBRARY_NAMES, template_loader, 'dart2js', dart2js_output_dir)
RunGenerator(dart_libraries, dart_output_dir,
template_loader, backend_factory)
@@ -121,7 +119,7 @@
dart_output_dir = os.path.join(dartium_output_dir, 'dart')
dart_libraries = DartLibraries(
- _libraries, template_loader, 'dartium', dartium_output_dir)
+ HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir)
RunGenerator(dart_libraries, dart_output_dir,
template_loader, backend_factory)
@@ -195,13 +193,13 @@
if 'htmldart2js' in systems:
_logger.info('Generating dart2js single files.')
- for library_name in _libraries:
+ for library_name in HTML_LIBRARY_NAMES:
GenerateSingleFile(
os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name),
os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js'))
if 'htmldartium' in systems:
_logger.info('Generating dartium single files.')
- for library_name in _libraries:
+ for library_name in HTML_LIBRARY_NAMES:
GenerateSingleFile(
os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name),
os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dartium'))
diff --git a/tools/dom/scripts/generator.py b/tools/dom/scripts/generator.py
index 2258962..1ab6c53 100644
--- a/tools/dom/scripts/generator.py
+++ b/tools/dom/scripts/generator.py
@@ -493,10 +493,8 @@
'any set IDBCursor.update': _serialize_SSV,
# postMessage
- 'any set DedicatedWorkerContext.postMessage': _serialize_SSV,
'any set MessagePort.postMessage': _serialize_SSV,
'SerializedScriptValue set DOMWindow.postMessage': _serialize_SSV,
- 'SerializedScriptValue set Worker.postMessage': _serialize_SSV,
# receiving message via MessageEvent
'* get MessageEvent.data':
@@ -594,7 +592,6 @@
'DOMWindow.openDatabase': [
"@Creates('SqlDatabase')",
- "@Creates('SqlDatabaseSync')",
],
# To be in callback with the browser-created Event, we had to have called
@@ -898,13 +895,7 @@
'WebKitCSSMatrix': _webkit_experimental_annotations,
'WebKitPoint': _webkit_experimental_annotations,
'WebSocket': _all_but_ie9_annotations,
- 'WorkerContext.indexedDB': _indexed_db_annotations,
- 'WorkerContext.openDatabase': _web_sql_annotations,
- 'WorkerContext.openDatabaseSync': _web_sql_annotations,
- 'WorkerContext.webkitRequestFileSystem': _file_system_annotations,
- 'WorkerContext.webkitRequestFileSystemSync': _file_system_annotations,
- 'WorkerContext.webkitResolveLocalFileSystemSyncURL': _file_system_annotations,
- 'WorkerContext.webkitResolveLocalFileSystemURL': _file_system_annotations,
+ 'Worker': _all_but_ie9_annotations,
'XMLHttpRequest.onloadend': _all_but_ie9_annotations,
'XMLHttpRequest.onprogress': _all_but_ie9_annotations,
'XMLHttpRequest.response': _all_but_ie9_annotations,
@@ -1454,8 +1445,6 @@
suppress_interface=True),
'HTMLAllCollection': TypeData(clazz='Interface', item_type='Node'),
'HTMLCollection': TypeData(clazz='Interface', item_type='Node'),
- 'MediaStreamList': TypeData(clazz='Interface',
- item_type='MediaStream', suppress_interface=True),
'NamedNodeMap': TypeData(clazz='Interface', item_type='Node'),
'NodeList': TypeData(clazz='Interface', item_type='Node',
suppress_interface=False, dart_type='List<Node>'),
diff --git a/tools/dom/scripts/htmleventgenerator.py b/tools/dom/scripts/htmleventgenerator.py
index 64063b3..7f64f1b 100644
--- a/tools/dom/scripts/htmleventgenerator.py
+++ b/tools/dom/scripts/htmleventgenerator.py
@@ -161,16 +161,16 @@
'Notification.close': ('close', 'Event'),
'Notification.display': ('display', 'Event'),
'Notification.show': ('show', 'Event'),
+ 'RTCDTMFSender.tonechange': ('toneChange', 'RtcDtmfToneChangeEvent'),
'RTCDataChannel.close': ('close', 'Event'),
'RTCDataChannel.open': ('open', 'Event'),
'RTCPeerConnection.addstream': ('addStream', 'MediaStreamEvent'),
'RTCPeerConnection.datachannel': ('dataChannel', 'RtcDataChannelEvent'),
'RTCPeerConnection.icecandidate': ('iceCandidate', 'RtcIceCandidateEvent'),
- 'RTCPeerConnection.icechange': ('iceChange', 'Event'),
- 'RTCPeerConnection.gatheringchange': ('gatheringChange', 'Event'),
+ 'RTCPeerConnection.iceconnectionstatechange': ('iceConnectionStateChange', 'Event'),
'RTCPeerConnection.negotiationneeded': ('negotiationNeeded', 'Event'),
'RTCPeerConnection.removestream': ('removeStream', 'MediaStreamEvent'),
- 'RTCPeerConnection.statechange': ('stateChange', 'Event'),
+ 'RTCPeerConnection.signalingstatechange': ('signalingStateChange', 'Event'),
'SharedWorkerContext.connect': ('connect', 'Event'),
'SpeechRecognition.audioend': ('audioEnd', 'Event'),
'SpeechRecognition.audiostart': ('audioStart', 'Event'),
diff --git a/tools/dom/scripts/htmlrenamer.py b/tools/dom/scripts/htmlrenamer.py
index 8b696d6..2604dd9 100644
--- a/tools/dom/scripts/htmlrenamer.py
+++ b/tools/dom/scripts/htmlrenamer.py
@@ -14,7 +14,6 @@
'DOMApplicationCache': 'ApplicationCache',
'DOMCoreException': 'DomException',
'DOMFileSystem': 'FileSystem',
- 'DOMFileSystemSync': 'FileSystemSync',
'DOMFormData': 'FormData',
'DOMURL': 'Url',
'DOMWindow': 'Window',
@@ -32,26 +31,22 @@
'NotificationPermissionCallback': '_NotificationPermissionCallback',
'PositionCallback': '_PositionCallback',
'PositionErrorCallback': '_PositionErrorCallback',
- 'Rect': 'CssRect',
- 'RGBColor': 'CssRgbColor',
'RTCDTMFSender': 'RtcDtmfSender',
'RTCDTMFToneChangeEvent': 'RtcDtmfToneChangeEvent',
'RTCErrorCallback': '_RtcErrorCallback',
'RTCSessionDescriptionCallback': '_RtcSessionDescriptionCallback',
- 'StorageInfoErrorCallback': '_StorageInfoErrorCallback',
- 'StorageInfoUsageCallback': '_StorageInfoUsageCallback',
'StringCallback': '_StringCallback',
'SVGDocument': 'SvgDocument', # Manual to avoid name conflicts.
'SVGElement': 'SvgElement', # Manual to avoid name conflicts.
'SVGException': 'SvgException', # Manual of avoid conflict with Exception.
+ 'SVGGradientElement': '_GradientElement',
'SVGSVGElement': 'SvgSvgElement', # Manual to avoid name conflicts.
'WebGLVertexArrayObjectOES': 'VertexArrayObject',
'WebKitAnimationEvent': 'AnimationEvent',
'WebKitCSSKeyframeRule': 'CssKeyframeRule',
'WebKitCSSKeyframesRule': 'CssKeyframesRule',
- 'WebKitCSSMatrix': 'CssMatrix',
'WebKitCSSTransformValue': 'CssTransformValue',
- 'WebKitPoint': 'DomPoint',
+ 'WebKitPoint': '_DomPoint',
'WebKitTransitionEvent': '_WebKitTransitionEvent',
'XMLHttpRequest': 'HttpRequest',
'XMLHttpRequestException': 'HttpRequestException',
@@ -62,6 +57,18 @@
# Interfaces that are suppressed, but need to still exist for Dartium and to
# properly wrap DOM objects if/when encountered.
_removed_html_interfaces = [
+ 'CSSPrimitiveValue',
+ 'CSSValue',
+ 'Counter',
+ 'DOMFileSystemSync', # Workers
+ 'DatabaseSync', # Workers
+ 'DedicatedWorkerContext', # Workers
+ 'DirectoryEntrySync', # Workers
+ 'DirectoryReaderSync', # Workers
+ 'EntrySync', # Workers
+ 'FileEntrySync', # Workers
+ 'FileReaderSync', # Workers
+ 'FileWriterSync', # Workers
'HTMLAppletElement',
'HTMLBaseFontElement',
'HTMLDirectoryElement',
@@ -70,12 +77,16 @@
'HTMLFrameSetElement',
'HTMLMarqueeElement',
'IDBAny',
+ 'RGBColor',
+ 'Rect',
+ 'SQLTransactionSync', # Workers
+ 'SQLTransactionSyncCallback', # Workers
'SVGAltGlyphDefElement', # Webkit only.
'SVGAltGlyphItemElement', # Webkit only.
'SVGAnimateColorElement', # Deprecated. Use AnimateElement instead.
+ 'SVGColor',
'SVGComponentTransferFunctionElement', # Currently not supported anywhere.
'SVGCursorElement', # Webkit only.
- 'SVGGradientElement', # Currently not supported anywhere.
'SVGFEDropShadowElement', # Webkit only for the following:
'SVGFontElement',
'SVGFontFaceElement',
@@ -86,10 +97,20 @@
'SVGGlyphElement',
'SVGGlyphRefElement',
'SVGHKernElement',
- 'SVGMissingGlyphElement',
'SVGMPathElement',
+ 'SVGPaint',
+ 'SVGMissingGlyphElement',
'SVGTRefElement',
'SVGVKernElement',
+ 'SharedWorker', # Workers
+ 'SharedWorkerContext', # Workers
+ 'WebKitCSSFilterValue',
+ 'WebKitCSSMatrix',
+ 'WebKitCSSMixFunctionValue',
+ 'WebKitCSSTransformValue',
+ 'WorkerContext', # Workers
+ 'WorkerLocation', # Workers
+ 'WorkerNavigator', # Workers
]
for interface in _removed_html_interfaces:
@@ -237,7 +258,6 @@
'Node.childNodes',
'Node.firstChild',
'Node.lastChild',
- 'Node.localName',
'Node.namespaceURI',
'Node.removeChild',
'Node.replaceChild',
@@ -287,8 +307,8 @@
'DOMWindow.clearInterval': '_clearInterval',
'DOMWindow.setTimeout': '_setTimeout',
'DOMWindow.setInterval': '_setInterval',
- 'DOMWindow.webkitConvertPointFromNodeToPage': 'convertPointFromNodeToPage',
- 'DOMWindow.webkitConvertPointFromPageToNode': 'convertPointFromPageToNode',
+ 'DOMWindow.webkitConvertPointFromNodeToPage': '_convertPointFromNodeToPage',
+ 'DOMWindow.webkitConvertPointFromPageToNode': '_convertPointFromPageToNode',
'DOMWindow.webkitNotifications': 'notifications',
'DOMWindow.webkitRequestFileSystem': '_requestFileSystem',
'DOMWindow.webkitResolveLocalFileSystemURL': 'resolveLocalFileSystemUrl',
@@ -306,15 +326,10 @@
'RTCPeerConnection.createAnswer': '_createAnswer',
'RTCPeerConnection.createOffer': '_createOffer',
'StorageInfo.queryUsageAndQuota': '_queryUsageAndQuota',
- 'SVGComponentTransferFunctionElement.offset': 'gradientOffset',
'SVGElement.className': '$dom_svgClassName',
'SVGStopElement.offset': 'gradientOffset',
- 'WorkerContext.webkitRequestFileSystem': '_requestFileSystem',
- 'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync',
- 'WorkerContext.webkitResolveLocalFileSystemSyncURL':
- 'resolveLocalFileSystemSyncUrl',
- 'WorkerContext.webkitResolveLocalFileSystemURL':
- 'resolveLocalFileSystemUrl',
+ #'WorkerContext.webkitRequestFileSystem': '_requestFileSystem', # Workers
+ #'WorkerContext.webkitRequestFileSystemSync': '_requestFileSystemSync', # Workers
})
for member in convert_to_future_members:
@@ -332,6 +347,7 @@
# TODO(jacobr): cleanup and augment this list.
_removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
'Attr.*',
+ 'CSSStyleDeclaration.getPropertyCSSValue',
'CanvasRenderingContext2D.clearShadow',
'CanvasRenderingContext2D.drawImageFromRect',
'CanvasRenderingContext2D.setAlpha',
@@ -347,10 +363,11 @@
'CanvasRenderingContext2D.webkitLineDashOffset',
'CharacterData.remove',
'DOMWindow.call:blur',
- 'DOMWindow.clientInformation',
'DOMWindow.call:focus',
+ 'DOMWindow.clientInformation',
'DOMWindow.get:frames',
'DOMWindow.get:length',
+ 'DOMWindow.on:beforeUnload',
'DOMWindow.prompt',
'DOMWindow.webkitCancelAnimationFrame',
'DOMWindow.webkitCancelRequestAnimationFrame',
@@ -448,6 +465,7 @@
'Element.set:outerHTML',
'Element.setAttributeNode',
'Element.setAttributeNodeNS',
+ 'Event.returnValue',
'Event.srcElement',
'EventSource.URL',
'HTMLAnchorElement.charset',
@@ -463,6 +481,7 @@
'HTMLBodyElement.background',
'HTMLBodyElement.bgColor',
'HTMLBodyElement.link',
+ 'HTMLBodyElement.on:beforeUnload',
'HTMLBodyElement.text',
'HTMLBodyElement.vLink',
'HTMLDListElement.compact',
@@ -517,7 +536,6 @@
'HTMLPreElement.width',
'HTMLScriptElement.text',
'HTMLSelectElement.options',
- 'HTMLSelectElement.remove',
'HTMLSelectElement.selectedOptions',
'HTMLTableCaptionElement.align',
'HTMLTableCellElement.abbr',
@@ -592,6 +610,7 @@
'Node.set:nodeValue',
'NodeList.item',
'ShadowRoot.getElementsByTagNameNS',
+ 'SVGStyledElement.getPresentationAttribute',
'WheelEvent.wheelDelta',
'WorkerContext.webkitIndexedDB',
# TODO(jacobr): should these be removed?
@@ -611,6 +630,10 @@
self._database = database
def RenameInterface(self, interface):
+ if 'Callback' in interface.ext_attrs:
+ if interface.id in _removed_html_interfaces:
+ return None
+
if interface.id in html_interface_renames:
return html_interface_renames[interface.id]
elif interface.id.startswith('HTML'):
@@ -655,8 +678,15 @@
if self._FindMatch(interface, member, member_prefix,
_removed_html_members):
return True
+ if interface.id in _removed_html_interfaces:
+ return True
return False
+ def ShouldSuppressInterface(self, interface):
+ """ Returns true if the interface should be suppressed."""
+ if interface.id in _removed_html_interfaces:
+ return True
+
def _FindMatch(self, interface, member, member_prefix, candidates):
for interface in self._database.Hierarchy(interface):
member_name = interface.id + '.' + member
@@ -674,6 +704,11 @@
if interface.id in _library_names:
return _library_names[interface.id]
+ # TODO(ager, blois): The conditional has been removed from indexed db,
+ # so we can no longer determine the library based on the conditionals.
+ if interface.id.startswith("IDB"):
+ return 'indexed_db'
+
if 'Conditional' in interface.ext_attrs:
if 'WEB_AUDIO' in interface.ext_attrs['Conditional']:
return 'web_audio'
diff --git a/tools/dom/scripts/idlparser_test.dart b/tools/dom/scripts/idlparser_test.dart
index 126d8cf..4ca9f95 100644
--- a/tools/dom/scripts/idlparser_test.dart
+++ b/tools/dom/scripts/idlparser_test.dart
@@ -95,7 +95,9 @@
if (expected is String)
formatted = printList(ast);
- Expect.equals(expected, formatted, "parse: $input");
+ if (expected != formatted) {
+ throw new StateError("parse: $input");
+ }
}
// Prints the list in [1,2,3] notation, including nested lists.
diff --git a/tools/dom/scripts/systemhtml.py b/tools/dom/scripts/systemhtml.py
index 99c27e7..4d813a4 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -12,6 +12,9 @@
from generator import *
from htmldartgenerator import *
+HTML_LIBRARY_NAMES = ['chrome', 'html', 'indexed_db', 'svg', 'web_audio',
+ 'web_gl', 'web_sql']
+
_js_custom_members = monitored.Set('systemhtml._js_custom_members', [
'ArrayBuffer.slice',
'AudioBufferSourceNode.start',
@@ -70,7 +73,7 @@
'Window.location',
'Window.open',
'Window.requestAnimationFrame',
- 'WorkerContext.indexedDB',
+ # 'WorkerContext.indexedDB', # Workers
])
_js_custom_constructors = monitored.Set('systemhtml._js_custom_constructors', [
@@ -392,9 +395,9 @@
'XMLHttpRequestProgressEvent':
"Device.isEventTypeSupported('XMLHttpRequestProgressEvent')",
'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')",
- 'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')",
'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')",
'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')",
+ 'Worker': "JS('bool', '(typeof window.Worker != \"undefined\")')",
'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')",
}.items() +
dict((key,
@@ -429,12 +432,15 @@
def GenerateCallback(self):
"""Generates a typedef for the callback interface."""
+ typedef_name = self._renamer.RenameInterface(self._interface)
+ if not typedef_name:
+ return
+
info = GetCallbackInfo(self._interface)
code = self._library_emitter.FileEmitter(self._interface.id,
self._library_name)
code.Emit(self._template_loader.Load('callback.darttemplate'))
- typedef_name = self._renamer.RenameInterface(self._interface)
code.Emit('typedef void $NAME($PARAMS);\n',
LIBRARYNAME='dart.dom.%s' % self._library_name,
NAME=typedef_name,
@@ -511,10 +517,15 @@
GetAnnotationsAndComments(self._library_name,
self._interface.doc_js_name), '')
+ class_modifiers = ''
+ if self._renamer.ShouldSuppressInterface(self._interface):
+ class_modifiers = 'abstract '
+
self._implementation_members_emitter = implementation_emitter.Emit(
self._backend.ImplementationTemplate(),
LIBRARYNAME='dart.dom.%s' % self._library_name,
ANNOTATIONS=annotations,
+ CLASS_MODIFIERS=class_modifiers,
CLASSNAME=self._interface_type_info.implementation_name(),
EXTENDS=' extends %s' % base_class if base_class else '',
IMPLEMENTS=implements_str,
diff --git a/tools/dom/scripts/systemnative.py b/tools/dom/scripts/systemnative.py
index 4bc95a5..25d3370 100644
--- a/tools/dom/scripts/systemnative.py
+++ b/tools/dom/scripts/systemnative.py
@@ -10,7 +10,7 @@
import os
from generator import *
from htmldartgenerator import *
-from systemhtml import js_support_checks, GetCallbackInfo
+from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES
class DartiumBackend(HtmlDartGenerator):
"""Generates Dart implementation for one DOM IDL interface."""
@@ -152,6 +152,9 @@
# Emit internal constructor which is necessary for Dartium bindings
# to construct wrappers from C++. Eventually it should go away
# once it is possible to construct such an instance directly.
+ if not self._members_emitter:
+ return
+
super_constructor = ''
if base_class and base_class != 'NativeFieldWrapperClass1':
super_constructor = ' : super.internal()'
@@ -875,14 +878,12 @@
def __init__(self, emitters, cpp_sources_dir):
self._emitters = emitters
self._cpp_sources_dir = cpp_sources_dir
- self._library_headers = {}
+ self._library_headers = dict((lib, []) for lib in HTML_LIBRARY_NAMES)
self._sources_list = []
def CreateHeaderEmitter(self, interface_name, library_name, is_callback=False):
path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name)
if not is_callback:
- if not library_name in self._library_headers:
- self._library_headers[library_name] = []
self._library_headers[library_name].append(path)
return self._emitters.FileEmitter(path)
diff --git a/tools/dom/src/AttributeMap.dart b/tools/dom/src/AttributeMap.dart
index 1d196e3..6c96bc9 100644
--- a/tools/dom/src/AttributeMap.dart
+++ b/tools/dom/src/AttributeMap.dart
@@ -38,19 +38,19 @@
}
}
- Collection<String> get keys {
+ Iterable<String> get keys {
// TODO: generate a lazy collection instead.
var attributes = _element.$dom_attributes;
var keys = new List<String>();
for (int i = 0, len = attributes.length; i < len; i++) {
if (_matches(attributes[i])) {
- keys.add(attributes[i].$dom_localName);
+ keys.add(attributes[i].localName);
}
}
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
// TODO: generate a lazy collection instead.
var attributes = _element.$dom_attributes;
var values = new List<String>();
@@ -191,7 +191,7 @@
});
}
- Collection<String> get keys {
+ Iterable<String> get keys {
final keys = new List<String>();
$dom_attributes.forEach((String key, String value) {
if (_matches(key)) {
@@ -201,7 +201,7 @@
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
final values = new List<String>();
$dom_attributes.forEach((String key, String value) {
if (_matches(key)) {
diff --git a/tools/dom/src/CssClassSet.dart b/tools/dom/src/CssClassSet.dart
index 29aa860..acae69c 100644
--- a/tools/dom/src/CssClassSet.dart
+++ b/tools/dom/src/CssClassSet.dart
@@ -42,7 +42,7 @@
readClasses().forEach(f);
}
- String join([String separator]) => readClasses().join(separator);
+ String join([String separator = ""]) => readClasses().join(separator);
Iterable map(f(String element)) => readClasses().map(f);
@@ -58,9 +58,8 @@
int get length => readClasses().length;
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, String element)) {
- return readClasses().reduce(initialValue, combine);
+ String reduce(String combine(String value, String element)) {
+ return readClasses().reduce(combine);
}
dynamic fold(dynamic initialValue,
@@ -149,9 +148,6 @@
_modify((s) => s.retainWhere(test));
}
- bool isSubsetOf(Collection<String> collection) =>
- readClasses().isSubsetOf(collection);
-
bool containsAll(Iterable<String> collection) =>
readClasses().containsAll(collection);
@@ -170,10 +166,6 @@
List<String> toList({ bool growable: true }) =>
readClasses().toList(growable: growable);
Set<String> toSet() => readClasses().toSet();
- String min([int compare(String a, String b)]) =>
- readClasses().min(compare);
- String max([int compare(String a, String b)]) =>
- readClasses().max(compare);
Iterable<String> take(int n) => readClasses().take(n);
Iterable<String> takeWhile(bool test(String value)) =>
readClasses().takeWhile(test);
diff --git a/tools/dom/src/EventListener.dart b/tools/dom/src/EventListener.dart
index 2c9f2b4..60b29f1 100644
--- a/tools/dom/src/EventListener.dart
+++ b/tools/dom/src/EventListener.dart
@@ -4,4 +4,4 @@
part of html;
-typedef void EventListener(Event event);
+typedef EventListener(Event event);
diff --git a/tools/dom/src/WrappedEvent.dart b/tools/dom/src/WrappedEvent.dart
new file mode 100644
index 0000000..92b13f9
--- /dev/null
+++ b/tools/dom/src/WrappedEvent.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of dart.html;
+
+/**
+ * Helper class to implement custom events which wrap DOM events.
+ */
+class _WrappedEvent implements Event {
+ final Event wrapped;
+ _WrappedEvent(this.wrapped);
+
+ bool get bubbles => wrapped.bubbles;
+
+ bool get cancelBubble => wrapped.bubbles;
+ void set cancelBubble(bool value) {
+ wrapped.cancelBubble = value;
+ }
+
+ bool get cancelable => wrapped.cancelable;
+
+ DataTransfer get clipboardData => wrapped.clipboardData;
+
+ EventTarget get currentTarget => wrapped.currentTarget;
+
+ bool get defaultPrevented => wrapped.defaultPrevented;
+
+ int get eventPhase => wrapped.eventPhase;
+
+ EventTarget get target => wrapped.target;
+
+ int get timeStamp => wrapped.timeStamp;
+
+ String get type => wrapped.type;
+
+ void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
+ bool cancelableArg) {
+ throw new UnsupportedError(
+ 'Cannot initialize this Event.');
+ }
+
+ void preventDefault() {
+ wrapped.preventDefault();
+ }
+
+ void stopImmediatePropagation() {
+ wrapped.stopImmediatePropagation();
+ }
+
+ void stopPropagation() {
+ wrapped.stopPropagation();
+ }
+}
diff --git a/tools/dom/src/WrappedList.dart b/tools/dom/src/WrappedList.dart
index 171dd7e..c20cfd5 100644
--- a/tools/dom/src/WrappedList.dart
+++ b/tools/dom/src/WrappedList.dart
@@ -27,15 +27,15 @@
void forEach(void f(E element)) { _list.forEach(f); }
- dynamic reduce(initialValue, combine(previousValue, E element)) =>
- _list.reduce(initialValue, combine);
+ E reduce(E combine(E value, E element)) =>
+ _list.reduce(combine);
dynamic fold(initialValue, combine(previousValue, E element)) =>
_list.fold(initialValue, combine);
bool every(bool f(E element)) => _list.every(f);
- String join([String separator]) => _list.join(separator);
+ String join([String separator = ""]) => _list.join(separator);
bool any(bool f(E element)) => _list.any(f);
@@ -46,10 +46,6 @@
int get length => _list.length;
- E min([int compare(E a, E b)]) => _list.min(compare);
-
- E max([int compare(E a, E b)]) => _list.max(compare);
-
bool get isEmpty => _list.isEmpty;
Iterable<E> take(int n) => _list.take(n);
@@ -84,10 +80,6 @@
void remove(Object element) { _list.remove(element); }
- void removeAll(Iterable elements) { _list.removeAll(elements); }
-
- void retainAll(Iterable elements) { _list.retainAll(elements); }
-
void removeWhere(bool test(E element)) { _list.removeWhere(test); }
void retainWhere(bool test(E element)) { _list.retainWhere(test); }
@@ -118,7 +110,7 @@
List<E> sublist(int start, [int end]) => _list.sublist(start, end);
- List<E> getRange(int start, int length) => sublist(start, start + length);
+ Iterable<E> getRange(int start, int end) => _list.getRange(start, end);
void setRange(int start, int length, List<E> from, [int startFrom]) {
_list.setRange(start, length, from, startFrom);
@@ -130,7 +122,14 @@
_list.insertRange(start, length, fill);
}
- Map<int, E> asMap() => IterableMixinWorkaround.asMapList(_list);
+ Map<int, E> asMap() => _list.asMap();
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
}
/**
diff --git a/tools/dom/src/dart2js_KeyEvent.dart b/tools/dom/src/dart2js_KeyEvent.dart
index 5a0a133..a81d842 100644
--- a/tools/dom/src/dart2js_KeyEvent.dart
+++ b/tools/dom/src/dart2js_KeyEvent.dart
@@ -10,7 +10,7 @@
* on how we can make this class work with as many international keyboards as
* possible. Bugs welcome!
*/
-class KeyEvent implements KeyboardEvent {
+class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
KeyboardEvent _parent;
@@ -45,7 +45,7 @@
bool get _realAltKey => JS('int', '#.altKey', _parent);
/** Construct a KeyEvent with [parent] as the event we're emulating. */
- KeyEvent(KeyboardEvent parent) {
+ KeyEvent(KeyboardEvent parent): super(parent) {
_parent = parent;
_shadowAltKey = _realAltKey;
_shadowCharCode = _realCharCode;
@@ -66,22 +66,11 @@
/** True if the altGraphKey is pressed during this event. */
bool get altGraphKey => _parent.altGraphKey;
- bool get bubbles => _parent.bubbles;
- /** True if this event can be cancelled. */
- bool get cancelable => _parent.cancelable;
- bool get cancelBubble => _parent.cancelBubble;
- void set cancelBubble(bool cancel) {
- _parent.cancelBubble = cancel;
- }
/** Accessor to the clipboardData available for this event. */
DataTransfer get clipboardData => _parent.clipboardData;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
- /** Accessor to the target this event is listening to for changes. */
- EventTarget get currentTarget => _parent.currentTarget;
- bool get defaultPrevented => _parent.defaultPrevented;
int get detail => _parent.detail;
- int get eventPhase => _parent.eventPhase;
/**
* Accessor to the part of the keyboard that the key was pressed from (one of
* KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
@@ -92,35 +81,17 @@
/** True if the Meta (or Mac command) key is pressed during this event. */
bool get metaKey => _parent.metaKey;
Point get page => _parent.page;
- bool get returnValue => _parent.returnValue;
- void set returnValue(bool value) {
- _parent.returnValue = value;
- }
/** True if the shift key was pressed during this event. */
bool get shiftKey => _parent.shiftKey;
- int get timeStamp => _parent.timeStamp;
- /**
- * The type of key event that occurred. One of "keydown", "keyup", or
- * "keypress".
- */
- String get type => _parent.type;
Window get view => _parent.view;
- void preventDefault() => _parent.preventDefault();
- void stopImmediatePropagation() => _parent.stopImmediatePropagation();
- void stopPropagation() => _parent.stopPropagation();
void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
Window view, int detail) {
throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
}
- void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
- bool cancelableArg) {
- throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
- }
String get _shadowKeyIdentifier => JS('String', '#.keyIdentifier', _parent);
int get $dom_charCode => charCode;
int get $dom_keyCode => keyCode;
- EventTarget get target => _parent.target;
String get $dom_keyIdentifier {
throw new UnsupportedError("keyIdentifier is unsupported.");
}
diff --git a/tools/dom/src/dartium_KeyEvent.dart b/tools/dom/src/dartium_KeyEvent.dart
index 8f129a1..6f2cd78 100644
--- a/tools/dom/src/dartium_KeyEvent.dart
+++ b/tools/dom/src/dartium_KeyEvent.dart
@@ -10,7 +10,7 @@
* on how we can make this class work with as many international keyboards as
* possible. Bugs welcome!
*/
-class KeyEvent implements KeyboardEvent {
+class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The parent KeyboardEvent that this KeyEvent is wrapping and "fixing". */
KeyboardEvent _parent;
@@ -45,7 +45,7 @@
bool get _realAltKey => _parent.altKey;
/** Construct a KeyEvent with [parent] as the event we're emulating. */
- KeyEvent(KeyboardEvent parent) {
+ KeyEvent(KeyboardEvent parent): super(parent) {
_parent = parent;
_shadowAltKey = _realAltKey;
_shadowCharCode = _realCharCode;
@@ -64,22 +64,9 @@
/** True if the altGraphKey is pressed during this event. */
bool get altGraphKey => _parent.altGraphKey;
- bool get bubbles => _parent.bubbles;
- /** True if this event can be cancelled. */
- bool get cancelable => _parent.cancelable;
- bool get cancelBubble => _parent.cancelBubble;
- void set cancelBubble(bool cancel) {
- _parent.cancelBubble = cancel;
- }
- /** Accessor to the clipboardData available for this event. */
- DataTransfer get clipboardData => _parent.clipboardData;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
- /** Accessor to the target this event is listening to for changes. */
- EventTarget get currentTarget => _parent.currentTarget;
- bool get defaultPrevented => _parent.defaultPrevented;
int get detail => _parent.detail;
- int get eventPhase => _parent.eventPhase;
/**
* Accessor to the part of the keyboard that the key was pressed from (one of
* KeyLocation.STANDARD, KeyLocation.RIGHT, KeyLocation.LEFT,
@@ -90,35 +77,17 @@
/** True if the Meta (or Mac command) key is pressed during this event. */
bool get metaKey => _parent.metaKey;
Point get page => _parent.page;
- bool get returnValue => _parent.returnValue;
- void set returnValue(bool value) {
- _parent.returnValue = value;
- }
/** True if the shift key was pressed during this event. */
bool get shiftKey => _parent.shiftKey;
- int get timeStamp => _parent.timeStamp;
- /**
- * The type of key event that occurred. One of "keydown", "keyup", or
- * "keypress".
- */
- String get type => _parent.type;
Window get view => _parent.view;
- void preventDefault() => _parent.preventDefault();
- void stopImmediatePropagation() => _parent.stopImmediatePropagation();
- void stopPropagation() => _parent.stopPropagation();
void $dom_initUIEvent(String type, bool canBubble, bool cancelable,
Window view, int detail) {
throw new UnsupportedError("Cannot initialize a UI Event from a KeyEvent.");
}
- void $dom_initEvent(String eventTypeArg, bool canBubbleArg,
- bool cancelableArg) {
- throw new UnsupportedError("Cannot initialize an Event from a KeyEvent.");
- }
String get _shadowKeyIdentifier => _parent.$dom_keyIdentifier;
int get $dom_charCode => charCode;
int get $dom_keyCode => keyCode;
- EventTarget get target => _parent.target;
String get $dom_keyIdentifier {
throw new UnsupportedError("keyIdentifier is unsupported.");
}
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart
index aeb3775..b5b2650 100644
--- a/tools/dom/src/native_DOMImplementation.dart
+++ b/tools/dom/src/native_DOMImplementation.dart
@@ -126,8 +126,8 @@
String remove(String key) native "DOMStringMap_remove_Callback";
void clear() => Maps.clear(this);
void forEach(void f(String key, String value)) => Maps.forEach(this, f);
- Collection<String> get keys native "DOMStringMap_getKeys_Callback";
- Collection<String> get values => Maps.getValues(this);
+ Iterable<String> get keys native "DOMStringMap_getKeys_Callback";
+ Iterable<String> get values => Maps.getValues(this);
int get length => Maps.length(this);
bool get isEmpty => Maps.isEmpty(this);
}
diff --git a/tools/dom/templates/dart2js_impl.darttemplate b/tools/dom/templates/dart2js_impl.darttemplate
index 39e363c..6195077 100644
--- a/tools/dom/templates/dart2js_impl.darttemplate
+++ b/tools/dom/templates/dart2js_impl.darttemplate
@@ -5,5 +5,5 @@
part of $LIBRARYNAME;
@DocsEditable
-$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+$(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
$!MEMBERS}
diff --git a/tools/dom/templates/html/dart2js/html_dart2js.darttemplate b/tools/dom/templates/html/dart2js/html_dart2js.darttemplate
index fa10608..4ab1438 100644
--- a/tools/dom/templates/html/dart2js/html_dart2js.darttemplate
+++ b/tools/dom/templates/html/dart2js/html_dart2js.darttemplate
@@ -45,6 +45,7 @@
part '$AUXILIARY_DIR/Isolates.dart';
part '$AUXILIARY_DIR/Microtask.dart';
part '$AUXILIARY_DIR/Serialization.dart';
+part '$AUXILIARY_DIR/WrappedEvent.dart';
part '$AUXILIARY_DIR/WrappedList.dart';
part '$AUXILIARY_DIR/shared_FactoryProviders.dart';
part '$AUXILIARY_DIR/dart2js_Conversions.dart';
@@ -64,7 +65,7 @@
/**
* The top-level Document object.
*/
-HtmlDocument get document => JS('Document', 'document');
+HtmlDocument get document => JS('HtmlDocument', 'document');
Element query(String selector) => document.query(selector);
List<Element> queryAll(String selector) => document.queryAll(selector);
diff --git a/tools/dom/templates/html/dartium/cpp_resolver.template b/tools/dom/templates/html/dartium/cpp_resolver.template
index e104ebe..2a021c1 100644
--- a/tools/dom/templates/html/dartium/cpp_resolver.template
+++ b/tools/dom/templates/html/dartium/cpp_resolver.template
@@ -6,6 +6,7 @@
#include "config.h"
$!INCLUDES
+#include <dart_api.h>
namespace WebCore {
diff --git a/tools/dom/templates/html/dartium/dart_implementation.darttemplate b/tools/dom/templates/html/dartium/dart_implementation.darttemplate
index f0c067d..3b2c20f 100644
--- a/tools/dom/templates/html/dartium/dart_implementation.darttemplate
+++ b/tools/dom/templates/html/dartium/dart_implementation.darttemplate
@@ -7,6 +7,6 @@
part of $LIBRARYNAME;
@DocsEditable
-$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
+$(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
$!MEMBERS
}
diff --git a/tools/dom/templates/html/dartium/html_dartium.darttemplate b/tools/dom/templates/html/dartium/html_dartium.darttemplate
index c84c791..72e2df7 100644
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate
@@ -39,6 +39,7 @@
part '$AUXILIARY_DIR/Point.dart';
part '$AUXILIARY_DIR/ReadyState.dart';
part '$AUXILIARY_DIR/Rectangle.dart';
+part '$AUXILIARY_DIR/WrappedEvent.dart';
part '$AUXILIARY_DIR/WrappedList.dart';
part '$AUXILIARY_DIR/_HttpRequestUtils.dart';
part '$AUXILIARY_DIR/shared_FactoryProviders.dart';
diff --git a/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate b/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate
index 8aa13d1..1fca45d 100644
--- a/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate
+++ b/tools/dom/templates/html/impl/impl_CanvasRenderingContext2D.darttemplate
@@ -62,7 +62,7 @@
* will allow, the image will be clipped to fit the available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
* img.width = 100;
* img.height = 100;
@@ -140,7 +140,7 @@
* available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
*
* ctx.drawImage(img, 100, 100);
@@ -181,7 +181,7 @@
* will allow, the image will be clipped to fit the available space.
*
* CanvasElement canvas = new CanvasElement(width: 600, height: 600);
- * CanvasRenderingContext2D ctx = canvas.context2d;
+ * CanvasRenderingContext2D ctx = canvas.context2D;
* ImageElement img = document.query('img');
* img.width = 100;
* img.height = 100;
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
index 6d34148..13eaa30 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -6,7 +6,7 @@
// TODO(jacobr): use _Lists.dart to remove some of the duplicated
// functionality.
-class _ChildrenElementList implements List {
+class _ChildrenElementList extends ListBase<Element> {
// Raw Element.
final Element _element;
final HtmlCollection _childElements;
@@ -63,20 +63,20 @@
return false;
}
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
+ String join([String separator = ""]) {
+ return _childElements.join(separator);
}
Iterable map(f(Element element)) {
- return IterableMixinWorkaround.mapList(this, f);
+ return _childElements.map(f);
}
Iterable<Element> where(bool f(Element element)) {
- return IterableMixinWorkaround.where(this, f);
+ return _childElements.where(f);
}
Iterable expand(Iterable f(Element element)) {
- return IterableMixinWorkaround.expand(this, f);
+ return _childElements.expand(f);
}
bool get isEmpty {
@@ -84,31 +84,31 @@
}
Iterable<Element> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
+ return _childElements.take(n);
}
Iterable<Element> takeWhile(bool test(Element value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
+ return _childElements.takeWhile(test);
}
Iterable<Element> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
+ return _childElements.skip(n);
}
Iterable<Element> skipWhile(bool test(Element value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
+ return _childElements.skipWhile(test);
}
Element firstWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
+ return _childElements.firstWhere(test, orElse: orElse);
}
Element lastWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
+ return _childElements.lastWhere(test, orElse: orElse);
}
Element singleWhere(bool test(Element value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
+ return _childElements.singleWhere(test);
}
Element elementAt(int index) {
@@ -150,24 +150,24 @@
}
Iterable<Element> get reversed {
- return IterableMixinWorkaround.reversedList(this);
+ return _childElements.reversed;
}
void sort([int compare(Element a, Element b)]) {
throw new UnsupportedError('TODO(jacobr): should we impl?');
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ Element reduce(Element combine(Element value, Element element)) {
+ return _childElements.reduce(combine);
}
dynamic fold(dynamic initialValue,
dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
+ return _childElements.fold(initialValue, combine);
}
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
+ void setRange(int start, int rangeLength, List from,
+ [int startFrom = 0]) {
throw new UnimplementedError();
}
@@ -180,20 +180,12 @@
}
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
- }
-
void removeWhere(bool test(Element element)) {
- IterableMixinWorkaround.removeWhere(this, test);
+ _childElements.removeWhere(test);
}
void retainWhere(bool test(Element element)) {
- IterableMixinWorkaround.retainWhere(this, test);
+ _childElements.retainWhere(test);
}
void removeRange(int start, int rangeLength) {
@@ -204,14 +196,15 @@
throw new UnimplementedError();
}
+ Iterable getRange(int start, int end) {
+ throw new UnimplementedError();
+ }
+
List sublist(int start, [int end]) {
if (end == null) end = length;
return new _FrozenElementList._wrap(Lists.getRange(this, start, end, []));
}
- List getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
int indexOf(Element element, [int start = 0]) {
return Lists.indexOf(this, element, start, this.length);
}
@@ -271,16 +264,15 @@
return first;
}
- Element min([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.min(this, compare);
- }
-
- Element max([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
Map<int, Element> asMap() {
- return IterableMixinWorkaround.asMapList(this);
+ return _childElements.asMap();
+ }
+
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
}
}
@@ -288,96 +280,11 @@
// a better option given that we cannot quite force NodeList to be an
// ElementList as there are valid cases where a NodeList JavaScript object
// contains Node objects that are not Elements.
-class _FrozenElementList implements List {
+class _FrozenElementList extends ListBase {
final List<Node> _nodeList;
_FrozenElementList._wrap(this._nodeList);
- bool contains(Element element) {
- for (Element el in this) {
- if (el == element) return true;
- }
- return false;
- }
-
- void forEach(void f(Element element)) {
- for (Element el in this) {
- f(el);
- }
- }
-
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
- }
-
- Iterable map(f(Element element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
- Iterable<Element> where(bool f(Element element)) {
- return IterableMixinWorkaround.where(this, f);
- }
-
- Iterable expand(Iterable f(Element element)) {
- return IterableMixinWorkaround.expand(this, f);
- }
-
- bool every(bool f(Element element)) {
- for(Element element in this) {
- if (!f(element)) {
- return false;
- }
- };
- return true;
- }
-
- bool any(bool f(Element element)) {
- for(Element element in this) {
- if (f(element)) {
- return true;
- }
- };
- return false;
- }
-
- List<Element> toList({ bool growable: true }) =>
- new List<Element>.from(this, growable: growable);
- Set<Element> toSet() => new Set<Element>.from(this);
-
- Iterable<Element> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
- }
-
- Iterable<Element> takeWhile(bool test(Element value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
-
- Iterable<Element> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
- }
-
- Iterable<Element> skipWhile(bool test(Element value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- Element firstWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- Element lastWhere(bool test(Element value), {Element orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- Element singleWhere(bool test(Element value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- Element elementAt(int index) {
- return this[index];
- }
-
- bool get isEmpty => _nodeList.isEmpty;
-
int get length => _nodeList.length;
Element operator [](int index) => _nodeList[index];
@@ -394,31 +301,16 @@
throw new UnsupportedError('');
}
- Iterator<Element> get iterator => new _FrozenElementListIterator(this);
-
void addAll(Iterable<Element> iterable) {
throw new UnsupportedError('');
}
- Iterable<Element> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
void sort([int compare(Element a, Element b)]) {
throw new UnsupportedError('');
}
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, Element element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
- void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
+ void setRange(int start, int rangeLength, List from,
+ [int startFrom = 0]) {
throw new UnsupportedError('');
}
@@ -434,15 +326,6 @@
return new _FrozenElementList._wrap(_nodeList.sublist(start, end));
}
- List<Element> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
- int indexOf(Element element, [int start = 0]) =>
- _nodeList.indexOf(element, start);
-
- int lastIndexOf(Element element, [int start = null]) =>
- _nodeList.lastIndexOf(element, start);
-
void clear() {
throw new UnsupportedError('');
}
@@ -459,14 +342,6 @@
throw new UnsupportedError('');
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError('');
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError('');
- }
-
void removeWhere(bool test(Element element)) {
throw new UnsupportedError('');
}
@@ -481,49 +356,12 @@
Element get single => _nodeList.single;
- Element min([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.min(this, compare);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
}
-
- Element max([int compare(Element a, Element b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
- Map<int, Element> asMap() {
- return IterableMixinWorkaround.asMapList(this);
- }
-}
-
-class _FrozenElementListIterator implements Iterator<Element> {
- final _FrozenElementList _list;
- int _index = -1;
- Element _current;
-
- _FrozenElementListIterator(this._list);
-
- /**
- * Moves to the next element. Returns true if the iterator is positioned
- * at an element. Returns false if it is positioned after the last element.
- */
- bool moveNext() {
- int nextIndex = _index + 1;
- if (nextIndex < _list.length) {
- _current = _list[nextIndex];
- _index = nextIndex;
- return true;
- }
- _index = _list.length;
- _current = null;
- return false;
- }
-
- /**
- * Returns the element the [Iterator] is positioned at.
- *
- * Return [:null:] if the iterator is positioned before the first, or
- * after the last element.
- */
- Element get current => _current;
}
class _ElementCssClassSet extends CssClassSet {
@@ -661,7 +499,7 @@
*/
CssClassSet get classes => new _ElementCssClassSet(this);
- void set classes(Collection<String> value) {
+ void set classes(Iterable<String> value) {
CssClassSet classSet = classes;
classSet.clear();
classSet.addAll(value);
diff --git a/tools/dom/templates/html/impl/impl_Geolocation.darttemplate b/tools/dom/templates/html/impl/impl_Geolocation.darttemplate
index 11e52b7..19447c2 100644
--- a/tools/dom/templates/html/impl/impl_Geolocation.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Geolocation.darttemplate
@@ -55,7 +55,7 @@
var controller;
controller = new StreamController<Geoposition>(
onSubscriptionStateChange: () {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
assert(watchId == null);
watchId = $dom_watchPosition(
(position) {
diff --git a/tools/dom/templates/html/impl/impl_HTMLCanvasElement.darttemplate b/tools/dom/templates/html/impl/impl_HTMLCanvasElement.darttemplate
index 50b23ad..ef01381 100644
--- a/tools/dom/templates/html/impl/impl_HTMLCanvasElement.darttemplate
+++ b/tools/dom/templates/html/impl/impl_HTMLCanvasElement.darttemplate
@@ -6,7 +6,16 @@
$(ANNOTATIONS)class $CLASSNAME$EXTENDS implements CanvasImageSource$IMPLEMENTS$NATIVESPEC {
$!MEMBERS
- CanvasRenderingContext2D get context2d => getContext('2d');
+ /** An API for drawing on this canvas. */
+$if DART2JS
+ CanvasRenderingContext2D get context2D =>
+ JS('Null|CanvasRenderingContext2D', '#.getContext(#)', this, '2d');
+$else
+ CanvasRenderingContext2D get context2D => getContext('2d');
+$endif
+
+ @deprecated
+ CanvasRenderingContext2D get context2d => this.context2D;
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
diff --git a/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate b/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
index a8940cb..dd2e6e4 100644
--- a/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
+++ b/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
@@ -8,22 +8,28 @@
$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
$!MEMBERS
+
+$if DART2JS
@DomName('Document.body')
- BodyElement get body => document.$dom_body;
+ BodyElement body;
+$else
+ @DomName('Document.body')
+ BodyElement get body => $dom_body;
@DomName('Document.body')
void set body(BodyElement value) {
- document.$dom_body = value;
+ $dom_body = value;
}
+$endif
@DomName('Document.caretRangeFromPoint')
Range caretRangeFromPoint(int x, int y) {
- return document.$dom_caretRangeFromPoint(x, y);
+ return $dom_caretRangeFromPoint(x, y);
}
@DomName('Document.elementFromPoint')
Element elementFromPoint(int x, int y) {
- return document.$dom_elementFromPoint(x, y);
+ return $dom_elementFromPoint(x, y);
}
/**
@@ -67,36 +73,36 @@
@DomName('Document.getCSSCanvasContext')
CanvasRenderingContext getCssCanvasContext(String contextId, String name,
int width, int height) {
- return document.$dom_getCssCanvasContext(contextId, name, width, height);
+ return $dom_getCssCanvasContext(contextId, name, width, height);
}
@DomName('Document.head')
- HeadElement get head => document.$dom_head;
+ HeadElement get head => $dom_head;
@DomName('Document.lastModified')
- String get lastModified => document.$dom_lastModified;
+ String get lastModified => $dom_lastModified;
@DomName('Document.preferredStylesheetSet')
- String get preferredStylesheetSet => document.$dom_preferredStylesheetSet;
+ String get preferredStylesheetSet => $dom_preferredStylesheetSet;
@DomName('Document.referrer')
- String get referrer => document.$dom_referrer;
+ String get referrer => $dom_referrer;
@DomName('Document.selectedStylesheetSet')
- String get selectedStylesheetSet => document.$dom_selectedStylesheetSet;
+ String get selectedStylesheetSet => $dom_selectedStylesheetSet;
void set selectedStylesheetSet(String value) {
- document.$dom_selectedStylesheetSet = value;
+ $dom_selectedStylesheetSet = value;
}
@DomName('Document.styleSheets')
- List<StyleSheet> get styleSheets => document.$dom_styleSheets;
+ List<StyleSheet> get styleSheets => $dom_styleSheets;
@DomName('Document.title')
- String get title => document.$dom_title;
+ String get title => $dom_title;
@DomName('Document.title')
void set title(String value) {
- document.$dom_title = value;
+ $dom_title = value;
}
@DomName('Document.webkitCancelFullScreen')
@@ -104,7 +110,7 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void cancelFullScreen() {
- document.$dom_webkitCancelFullScreen();
+ $dom_webkitCancelFullScreen();
}
@DomName('Document.webkitExitFullscreen')
@@ -112,7 +118,7 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void exitFullscreen() {
- document.$dom_webkitExitFullscreen();
+ $dom_webkitExitFullscreen();
}
@DomName('Document.webkitExitPointerLock')
@@ -120,43 +126,43 @@
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
void exitPointerLock() {
- document.$dom_webkitExitPointerLock();
+ $dom_webkitExitPointerLock();
}
@DomName('Document.webkitFullscreenElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- Element get fullscreenElement => document.$dom_webkitFullscreenElement;
+ Element get fullscreenElement => $dom_webkitFullscreenElement;
@DomName('Document.webkitFullscreenEnabled')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get fullscreenEnabled => document.$dom_webkitFullscreenEnabled;
+ bool get fullscreenEnabled => $dom_webkitFullscreenEnabled;
@DomName('Document.webkitHidden')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get hidden => document.$dom_webkitHidden;
+ bool get hidden => $dom_webkitHidden;
@DomName('Document.webkitIsFullScreen')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- bool get isFullScreen => document.$dom_webkitIsFullScreen;
+ bool get isFullScreen => $dom_webkitIsFullScreen;
@DomName('Document.webkitPointerLockElement')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
Element get pointerLockElement =>
- document.$dom_webkitPointerLockElement;
+ $dom_webkitPointerLockElement;
@DomName('Document.webkitVisibilityState')
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
- String get visibilityState => document.$dom_webkitVisibilityState;
+ String get visibilityState => $dom_webkitVisibilityState;
}
diff --git a/tools/dom/templates/html/impl/impl_IDBObjectStore.darttemplate b/tools/dom/templates/html/impl/impl_IDBObjectStore.darttemplate
index d963e04eb..5343411 100644
--- a/tools/dom/templates/html/impl/impl_IDBObjectStore.darttemplate
+++ b/tools/dom/templates/html/impl/impl_IDBObjectStore.darttemplate
@@ -160,7 +160,7 @@
controller.close();
} else {
controller.add(cursor);
- if (autoAdvance == true && controller.hasSubscribers) {
+ if (autoAdvance == true && controller.hasListener) {
cursor.next();
}
}
diff --git a/tools/dom/templates/html/impl/impl_Node.darttemplate b/tools/dom/templates/html/impl/impl_Node.darttemplate
index bd9eeb2..cb664d6 100644
--- a/tools/dom/templates/html/impl/impl_Node.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Node.darttemplate
@@ -9,7 +9,7 @@
* the actual child nodes of an element until strictly necessary greatly
* improving performance for the typical cases where it is not required.
*/
-class _ChildNodeListLazy implements List {
+class _ChildNodeListLazy extends ListBase<Node> {
final Node _this;
_ChildNodeListLazy(this._this);
@@ -51,14 +51,6 @@
}
$endif
- Node min([int compare(Node a, Node b)]) {
- return IterableMixinWorkaround.min(this, compare);
- }
-
- Node max([int compare(Node a, Node b)]) {
- return IterableMixinWorkaround.max(this, compare);
- }
-
void add(Node value) {
_this.append(value);
}
@@ -113,20 +105,26 @@
_this.$dom_removeChild(node);
}
- void removeAll(Iterable elements) {
- IterableMixinWorkaround.removeAll(this, elements);
- }
-
- void retainAll(Iterable elements) {
- IterableMixinWorkaround.retainAll(this, elements);
+ void _filter(bool test(Node node), bool removeMatching) {
+ // This implementation of removeWhere/retainWhere is more efficient
+ // than the default in ListBase. Child nodes can be removed in constant
+ // time.
+ Node child = _this.$dom_firstChild;
+ while (child != null) {
+ Node nextChild = child.nextSibling;
+ if (test(child) == removeMatching) {
+ _this.$dom_removeChild(child);
+ }
+ child = nextChild;
+ }
}
void removeWhere(bool test(Node node)) {
- IterableMixinWorkaround.removeWhere(this, test);
+ _filter(test, true);
}
void retainWhere(bool test(Node node)) {
- IterableMixinWorkaround.retainWhere(this, test);
+ _filter(test, false);
}
void clear() {
@@ -139,42 +137,6 @@
Iterator<Node> get iterator => _this.$dom_childNodes.iterator;
- // TODO(jacobr): We can implement these methods much more efficiently by
- // looking up the nodeList only once instead of once per iteration.
- bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
-
- void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
-
- dynamic reduce(dynamic initialValue,
- dynamic combine(dynamic previousValue, Node element)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
- }
-
- dynamic fold(dynamic initialValue,
- dynamic combine(dynamic previousValue, Node element)) {
- return IterableMixinWorkaround.fold(this, initialValue, combine);
- }
-
- String join([String separator]) {
- return IterableMixinWorkaround.joinList(this, separator);
- }
-
- Iterable map(f(Node element)) {
- return IterableMixinWorkaround.mapList(this, f);
- }
-
- Iterable<Node> where(bool f(Node element)) {
- return IterableMixinWorkaround.where(this, f);
- }
-
- Iterable expand(Iterable f(Node element)) {
- return IterableMixinWorkaround.expand(this, f);
- }
-
- bool every(bool f(Node element)) => IterableMixinWorkaround.every(this, f);
-
- bool any(bool f(Node element)) => IterableMixinWorkaround.any(this, f);
-
List<Node> toList({ bool growable: true }) =>
new List<Node>.from(this, growable: growable);
Set<Node> toSet() => new Set<Node>.from(this);
@@ -183,54 +145,12 @@
// From List<Node>:
- Iterable<Node> take(int n) {
- return IterableMixinWorkaround.takeList(this, n);
- }
-
- Iterable<Node> takeWhile(bool test(Node value)) {
- return IterableMixinWorkaround.takeWhile(this, test);
- }
-
- Iterable<Node> skip(int n) {
- return IterableMixinWorkaround.skipList(this, n);
- }
-
- Iterable<Node> skipWhile(bool test(Node value)) {
- return IterableMixinWorkaround.skipWhile(this, test);
- }
-
- Node firstWhere(bool test(Node value), {Node orElse()}) {
- return IterableMixinWorkaround.firstWhere(this, test, orElse);
- }
-
- Node lastWhere(bool test(Node value), {Node orElse()}) {
- return IterableMixinWorkaround.lastWhereList(this, test, orElse);
- }
-
- Node singleWhere(bool test(Node value)) {
- return IterableMixinWorkaround.singleWhere(this, test);
- }
-
- Node elementAt(int index) {
- return this[index];
- }
-
- Iterable<Node> get reversed {
- return IterableMixinWorkaround.reversedList(this);
- }
-
// TODO(jacobr): this could be implemented for child node lists.
// The exception we throw here is misleading.
void sort([int compare(Node a, Node b)]) {
throw new UnsupportedError("Cannot sort immutable List.");
}
- int indexOf(Node element, [int start = 0]) =>
- Lists.indexOf(this, element, start, this.length);
-
- int lastIndexOf(Node element, [int start = 0]) =>
- Lists.lastIndexOf(this, element, start);
-
// FIXME: implement these.
void setRange(int start, int rangeLength, List<Node> from, [int startFrom]) {
throw new UnsupportedError(
@@ -244,14 +164,22 @@
throw new UnsupportedError(
"Cannot insertRange on immutable List.");
}
+
+ Iterable<Node> getRange(int start, int end) {
+ throw new UnimplementedError("NodeList.getRange");
+ }
+
List<Node> sublist(int start, [int end]) {
if (end == null) end == length;
return Lists.getRange(this, start, end, <Node>[]);
}
- List<Node> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
// -- end List<Node> mixins.
// TODO(jacobr): benchmark whether this is more efficient or whether caching
@@ -264,8 +192,6 @@
}
Node operator[](int index) => _this.$dom_childNodes[index];
-
- Map<int, Node> asMap() => IterableMixinWorkaround.asMapList(this);
}
$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
@@ -273,7 +199,7 @@
return new _ChildNodeListLazy(this);
}
- void set nodes(Collection<Node> value) {
+ void set nodes(Iterable<Node> value) {
// Copy list first since we don't want liveness during iteration.
// TODO(jacobr): there is a better way to do this.
List copy = new List.from(value);
@@ -418,5 +344,11 @@
return _modelChangedStream.stream;
}
+ /**
+ * Print out a String representation of this Node.
+ */
+ String toString() => localName == null ?
+ (nodeValue == null ? super.toString() : nodeValue) : localName;
+
$!MEMBERS
}
diff --git a/tools/dom/templates/html/impl/impl_SVGColor.darttemplate b/tools/dom/templates/html/impl/impl_SVGColor.darttemplate
new file mode 100644
index 0000000..afe3c34
--- /dev/null
+++ b/tools/dom/templates/html/impl/impl_SVGColor.darttemplate
@@ -0,0 +1,12 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of $LIBRARYNAME;
+
+// Hack because the baseclass is private in dart:html, and we want to omit this
+// type entirely but can't.
+@DocsEditable
+$(ANNOTATIONS)class $CLASSNAME$IMPLEMENTS$NATIVESPEC {
+ _SVGColor.internal();
+}
diff --git a/tools/dom/templates/html/impl/impl_ScriptProcessorNode.darttemplate b/tools/dom/templates/html/impl/impl_ScriptProcessorNode.darttemplate
index 15bf88e..d6f813f 100644
--- a/tools/dom/templates/html/impl/impl_ScriptProcessorNode.darttemplate
+++ b/tools/dom/templates/html/impl/impl_ScriptProcessorNode.darttemplate
@@ -18,7 +18,7 @@
if (_eventStream == null) {
var controller = new StreamController();
var callback = (audioData) {
- if (controller.hasSubscribers) {
+ if (controller.hasListener) {
// This stream is a strange combination of broadcast and single
// subscriber streams. We only allow one listener, but if there is
// no listener, we don't queue up events, we just drop them on the
diff --git a/tools/dom/templates/html/impl/impl_Storage.darttemplate b/tools/dom/templates/html/impl/impl_Storage.darttemplate
index e4d0523..d043abe 100644
--- a/tools/dom/templates/html/impl/impl_Storage.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Storage.darttemplate
@@ -63,13 +63,13 @@
}
}
- Collection<String> get keys {
+ Iterable<String> get keys {
final keys = [];
forEach((k, v) => keys.add(k));
return keys;
}
- Collection<String> get values {
+ Iterable<String> get values {
final values = [];
forEach((k, v) => values.add(v));
return values;
diff --git a/tools/dom/templates/html/impl/impl_Window.darttemplate b/tools/dom/templates/html/impl/impl_Window.darttemplate
index 2f1c194..2d9493d 100644
--- a/tools/dom/templates/html/impl/impl_Window.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Window.darttemplate
@@ -231,10 +231,102 @@
* lasting storage. This storage cannot be freed without the user's
* permission. Returns a [Future] whose value stores a reference to the
* sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
+ * applications cannot access file systems created in other web pages.
*/
Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
return _requestFileSystem(persistent? 1 : 0, size);
}
+
+ @DomName('DOMWindow.convertPointFromNodeToPage')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.SAFARI)
+ @Experimental
+ Point convertPointFromNodeToPage(Node node, Point point) {
+ var result = _convertPointFromNodeToPage(node,
+ new _DomPoint(point.x, point.y));
+ return new Point(result.x, result.y);
+ }
+
+ @DomName('DOMWindow.convertPointFromPageToNode')
+ @SupportedBrowser(SupportedBrowser.CHROME)
+ @SupportedBrowser(SupportedBrowser.SAFARI)
+ @Experimental
+ Point convertPointFromPageToNode(Node node, Point point) {
+ var result = _convertPointFromPageToNode(node,
+ new _DomPoint(point.x, point.y));
+ return new Point(result.x, result.y);
+ }
+
+ /**
+ * Checks whether [convertPointFromNodeToPage] and
+ * [convertPointFromPageToNode] are supported on the current platform.
+ */
+ static bool get supportsPointConversions => _DomPoint.supported;
$!MEMBERS
+
+ @DomName('DOMWindow.beforeunloadEvent')
+ @DocsEditable
+ static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
+ const _BeforeUnloadEventStreamProvider('beforeunload');
+
+ @DomName('DOMWindow.onbeforeunload')
+ @DocsEditable
+ Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
+}
+
+/**
+ * Event object that is fired before the window is closed.
+ *
+ * The standard window close behavior can be prevented by setting the
+ * [returnValue]. This will display a dialog to the user confirming that they
+ * want to close the page.
+ */
+abstract class BeforeUnloadEvent implements Event {
+ /**
+ * If set to a non-null value, a dialog will be presented to the user
+ * confirming that they want to close the page.
+ */
+ String returnValue;
+}
+
+class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent {
+ String _returnValue;
+
+ _BeforeUnloadEvent(Event base): super(base);
+
+ String get returnValue => _returnValue;
+
+ void set returnValue(String value) {
+ _returnValue = value;
+$if DART2JS
+ // FF and IE use the value as the return value, Chrome will return this from
+ // the event callback function.
+ if (JS('bool', '("returnValue" in #)', _base)) {
+ JS('void', '#.returnValue = #', _base, value);
+ }
+$endif
+ }
+}
+
+class _BeforeUnloadEventStreamProvider implements
+ EventStreamProvider<BeforeUnloadEvent> {
+ final String _eventType;
+
+ const _BeforeUnloadEventStreamProvider(this._eventType);
+
+ Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) {
+ var controller = new StreamController.broadcast();
+ var stream = new _EventStream(e, _eventType, useCapture);
+ stream.listen((event) {
+ var wrapped = new _BeforeUnloadEvent(event);
+ controller.add(wrapped);
+ return wrapped.returnValue;
+ });
+
+ return controller.stream;
+ }
+
+ String getEventType(EventTarget target) {
+ return _eventType;
+ }
}
diff --git a/tools/dom/templates/html/impl/impl_WorkerContext.darttemplate b/tools/dom/templates/html/impl/impl_WorkerContext.darttemplate
deleted file mode 100644
index 9215272..0000000
--- a/tools/dom/templates/html/impl/impl_WorkerContext.darttemplate
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of $LIBRARYNAME;
-
-$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
-$if DART2JS
- /**
- * Gets an instance of the Indexed DB factory to being using Indexed DB.
- *
- * Use [IdbFactory.supported] to check if Indexed DB is supported on the
- * current platform.
- */
- @SupportedBrowser(SupportedBrowser.CHROME, '23.0')
- @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
- @SupportedBrowser(SupportedBrowser.IE, '10.0')
- @Experimental
- IdbFactory get indexedDB =>
- JS('IdbFactory',
- '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
- this, this, this);
-$endif
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. Returns a [Future] whose value stores a reference to the
- * sandboxed file system for use. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystem')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- Future<FileSystem> requestFileSystem(int size, {bool persistent: false}) {
- return _requestFileSystem(persistent? 1 : 0, size);
- }
-
- /**
- * Access a sandboxed file system of the specified `size`. If `persistent` is
- * true, the application will request permission from the user to create
- * lasting storage. This storage cannot be freed without the user's
- * permission. This call will block until a reference to the synchronous file
- * system API has been obtained. Because the file system is sandboxed,
- * applications cannot access file systems created in other web pages.
- */
- @DomName('WorkerContext.webkitRequestFileSystemSync')
- @DocsEditable
- @SupportedBrowser(SupportedBrowser.CHROME)
- @Experimental
- FileSystemSync requestFileSystemSync(int size, {bool persistent: false}) {
- return _requestFileSystemSync(persistent? 1 : 0, size);
- }
-$!MEMBERS
-}
diff --git a/tools/dom/templates/immutable_list_mixin.darttemplate b/tools/dom/templates/immutable_list_mixin.darttemplate
index 81c72e2..8b85dab 100644
--- a/tools/dom/templates/immutable_list_mixin.darttemplate
+++ b/tools/dom/templates/immutable_list_mixin.darttemplate
@@ -14,11 +14,12 @@
// SVG Collections expose numberOfItems rather than length.
int get length => numberOfItems;
$endif
- dynamic reduce(dynamic initialValue, dynamic combine(dynamic, $E)) {
- return IterableMixinWorkaround.reduce(this, initialValue, combine);
+ $E reduce($E combine($E value, $E element)) {
+ return IterableMixinWorkaround.reduce(this, combine);
}
- dynamic fold(dynamic initialValue, dynamic combine(dynamic, $E)) {
+ dynamic fold(dynamic initialValue,
+ dynamic combine(dynamic previousValue, $E element)) {
return IterableMixinWorkaround.fold(this, initialValue, combine);
}
@@ -30,7 +31,7 @@
void forEach(void f($E element)) => IterableMixinWorkaround.forEach(this, f);
- String join([String separator]) =>
+ String join([String separator = ""]) =>
IterableMixinWorkaround.joinList(this, separator);
Iterable map(f($E element)) =>
@@ -138,12 +139,6 @@
throw new StateError("More than one element");
}
- $E min([int compare($E a, $E b)]) =>
- IterableMixinWorkaround.min(this, compare);
-
- $E max([int compare($E a, $E b)]) =>
- IterableMixinWorkaround.max(this, compare);
-
void insert(int index, $E element) {
throw new UnsupportedError("Cannot add to immutable List.");
}
@@ -160,14 +155,6 @@
throw new UnsupportedError("Cannot remove from immutable List.");
}
- void removeAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
- void retainAll(Iterable elements) {
- throw new UnsupportedError("Cannot remove from immutable List.");
- }
-
void removeWhere(bool test($E element)) {
throw new UnsupportedError("Cannot remove from immutable List.");
}
@@ -188,15 +175,22 @@
throw new UnsupportedError("Cannot insertRange on immutable List.");
}
+ Iterable<$E> getRange(int start, int end) =>
+ IterableMixinWorkaround.getRangeList(this, start, end);
+
List<$E> sublist(int start, [int end]) {
if (end == null) end = length;
return Lists.getRange(this, start, end, <$E>[]);
}
- List<$E> getRange(int start, int rangeLength) =>
- sublist(start, start + rangeLength);
-
Map<int, $E> asMap() =>
IterableMixinWorkaround.asMapList(this);
+ String toString() {
+ StringBuffer buffer = new StringBuffer('[');
+ buffer.writeAll(this, ', ');
+ buffer.write(']');
+ return buffer.toString();
+ }
+
// -- end List<$E> mixins.
diff --git a/tools/gyp/configurations_make.gypi b/tools/gyp/configurations_make.gypi
index 8a73b91..b13dabd 100644
--- a/tools/gyp/configurations_make.gypi
+++ b/tools/gyp/configurations_make.gypi
@@ -25,10 +25,8 @@
#'-ansi',
'-fno-rtti',
'-fno-exceptions',
- '-fPIC',
'-fvisibility=hidden',
'-fvisibility-inlines-hidden',
- '-fno-omit-frame-pointer',
],
},
@@ -70,7 +68,10 @@
},
'Dart_Debug': {
- 'cflags': [ '-O<(dart_debug_optimization_level)' ],
+ 'cflags': [
+ '-O<(dart_debug_optimization_level)',
+ '-fno-omit-frame-pointer',
+ ],
},
'Dart_Release': {
diff --git a/tools/only_in_release_mode.py b/tools/only_in_release_mode.py
new file mode 100644
index 0000000..2713b10
--- /dev/null
+++ b/tools/only_in_release_mode.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+"""
+Wrapper around a build action that should only be executed in release mode.
+
+The mode is defined via an environment varible DART_BUILD_MODE.
+
+The arguments to the script are:
+
+ only_in_release_mode.py files... -- command arguments...
+
+If mode is not 'release', the script will create the files listed
+before --. If mode is release, the script will execute the command
+after --.
+"""
+
+import os
+import subprocess
+import sys
+
+
+def Main():
+ # Throws an error if '--' is not in the argument list.
+ separator_index = sys.argv.index('--')
+ outputs = sys.argv[1:separator_index]
+ arguments = sys.argv[separator_index + 1:]
+ mode = os.getenv('DART_BUILD_MODE', default='release')
+ if mode != 'release':
+ print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, mode)
+ for output in outputs:
+ with open(output, 'w'):
+ # Create an empty file to ensure that we don't rerun this
+ # command unnecessarily.
+ pass
+ return 0
+ else:
+ try:
+ subprocess.check_call(arguments)
+ except subprocess.CalledProcessError as e:
+ return e.returncode
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/tools/publish_all_pkgs.py b/tools/publish_all_pkgs.py
index 5ddeb20..1958a3b 100644
--- a/tools/publish_all_pkgs.py
+++ b/tools/publish_all_pkgs.py
@@ -21,7 +21,7 @@
pkgs_to_publish = []
for name in os.listdir('pkg'):
if os.path.isdir(os.path.join('pkg', name)):
- if name != '.svn' and name != 'fixnum':
+ if (name != '.svn' and name != 'fixnum' and name != 'expect':
pkgs_to_publish.append(os.path.join('pkg', name))
# Publish dart2js as an "unsupported" package.
diff --git a/tools/test.dart b/tools/test.dart
index 218f996..1d78bbc 100755
--- a/tools/test.dart
+++ b/tools/test.dart
@@ -77,15 +77,15 @@
var startTime = new DateTime.now();
// Extract global options from first configuration.
var firstConf = configurations[0];
- Map<String, RegExp> selectors = firstConf['selectors'];
var maxProcesses = firstConf['tasks'];
var progressIndicator = firstConf['progress'];
+ // TODO(kustermann): Remove this option once the buildbots don't use it
+ // anymore.
var failureSummary = firstConf['failure-summary'];
BuildbotProgressIndicator.stepName = firstConf['step_name'];
var verbose = firstConf['verbose'];
var printTiming = firstConf['time'];
var listTests = firstConf['list'];
- var useContentSecurityPolicy = firstConf['csp'];
if (!firstConf['append_logs']) {
var file = new File(TestUtils.flakyFileName());
@@ -120,6 +120,8 @@
var testSuites = new List<TestSuite>();
var maxBrowserProcesses = maxProcesses;
for (var conf in configurations) {
+ Map<String, RegExp> selectors = conf['selectors'];
+ var useContentSecurityPolicy = conf['csp'];
if (!listTests && runningBrowserTests) {
// Start global http servers that serve the entire dart repo.
// The http server is available on window.location.port, and a second
@@ -195,10 +197,9 @@
eventListener.add(new FlakyLogWriter());
if (printFailures) {
// The buildbot has it's own failure summary since it needs to wrap it
- // into'@@@'-annotated sections.
- var printFaiureSummary =
- failureSummary && progressIndicator != 'buildbot';
- eventListener.add(new TestFailurePrinter(printFaiureSummary, formatter));
+ // into '@@@'-annotated sections.
+ var printFailureSummary = progressIndicator != 'buildbot';
+ eventListener.add(new TestFailurePrinter(printFailureSummary, formatter));
}
eventListener.add(new ProgressIndicator.fromName(progressIndicator,
startTime,
diff --git a/tools/test.py b/tools/test.py
index d047998..f7794c1 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -19,7 +19,7 @@
client = os.path.abspath(os.path.join(tools_dir, '..'));
dart_script_name = 'test.dart'
dart_test_script = string.join([tools_dir, dart_script_name], os.sep)
- command = [utils.DartBinary(), dart_test_script] + args
+ command = [utils.DartBinary(), '--checked', dart_test_script] + args
exit_code = subprocess.call(command)
utils.DiagnoseExitCode(exit_code, command)
return exit_code
diff --git a/tools/testing/dart/browser_test.dart b/tools/testing/dart/browser_test.dart
index cb8fd7d..2e9ec0a 100644
--- a/tools/testing/dart/browser_test.dart
+++ b/tools/testing/dart/browser_test.dart
@@ -33,7 +33,7 @@
</html>
""";
-String getHtmlLayoutContents(String scriptType, String sourceScript) =>
+String getHtmlLayoutContents(String scriptType, Path sourceScript) =>
"""
<!DOCTYPE html>
<html>
diff --git a/tools/testing/dart/multitest.dart b/tools/testing/dart/multitest.dart
index 44ba773..1af62b2 100644
--- a/tools/testing/dart/multitest.dart
+++ b/tools/testing/dart/multitest.dart
@@ -96,9 +96,10 @@
for (String nextOutcome in annotation.outcomesList) {
outcomes[annotation.key].add(nextOutcome);
if (!validMultitestOutcomes.contains(nextOutcome)) {
- Expect.fail(
- "Invalid test directive '$nextOutcome' on line ${lineCount}:\n"
- "${annotation.rest} ");
+ print(
+ "Invalid test directive '$nextOutcome' on line ${lineCount}:\n"
+ "${annotation.rest} ");
+ exit(1);
}
}
}
@@ -111,8 +112,9 @@
// Check that every key (other than the none case) has at least one outcome
for (var outcomeKey in outcomes.keys) {
if (outcomeKey != 'none' && outcomes[outcomeKey].isEmpty) {
- Expect.fail("Test ${outcomeKey} has no valid annotated outcomes.\n"
- "Expected one of: ${validMultitestOutcomes.toString()}");
+ print("Test ${outcomeKey} has no valid annotated outcomes.\n"
+ "Expected one of: ${validMultitestOutcomes.toString()}");
+ exit(1);
}
}
@@ -172,7 +174,8 @@
// This is just for safety reasons, we don't want
// to unintentionally clobber files relative to the destination
// dir when copying them ove.
- Expect.fail("relative paths containing .. are not allowed.");
+ print("relative paths containing .. are not allowed.");
+ exit(1);
}
foundImports.add(relativePath);
toSearch.add(libraryDir.join(relativePath));
@@ -192,7 +195,7 @@
Path sourceDir = filePath.directoryPath;
Path targetDir = CreateMultitestDirectory(outputDir, suiteDir);
- Expect.isNotNull(targetDir);
+ assert(targetDir != null);
// Copy all the relative imports of the multitest.
Set<Path> importsToCopy = _findAllRelativeImports(filePath);
diff --git a/tools/testing/dart/status_expression.dart b/tools/testing/dart/status_expression.dart
index 2ac072a..95f175c 100644
--- a/tools/testing/dart/status_expression.dart
+++ b/tools/testing/dart/status_expression.dart
@@ -56,7 +56,7 @@
List<String> tokenize() {
if (!testRegexp.hasMatch(expression)) {
- throw new ExpectException("Syntax error in '$expression'");
+ throw new FormatException("Syntax error in '$expression'");
}
for (Match match in regexp.allMatches(expression)) tokens.add(match[0]);
return tokens;
@@ -229,13 +229,16 @@
if (scanner.current == Token.LEFT_PAREN) {
scanner.advance();
SetExpression value = parseSetExpression();
- Expect.equals(scanner.current, Token.RIGHT_PAREN,
- "Missing right parenthesis in expression");
+ if (scanner.current != Token.RIGHT_PAREN) {
+ throw new RuntimeError("Missing right parenthesis in expression");
+ }
scanner.advance();
return value;
}
- Expect.isTrue(new RegExp(r"^\w+$").hasMatch(scanner.current),
- "Expected identifier in expression, got ${scanner.current}");
+ if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) {
+ throw new RuntimeError(
+ "Expected identifier in expression, got ${scanner.current}");
+ }
SetExpression value = new SetConstant(scanner.current);
scanner.advance();
return value;
@@ -267,25 +270,32 @@
if (scanner.current == Token.LEFT_PAREN) {
scanner.advance();
BooleanExpression value = parseBooleanExpression();
- Expect.equals(scanner.current, Token.RIGHT_PAREN,
- "Missing right parenthesis in expression");
+ if (scanner.current != Token.RIGHT_PAREN) {
+ throw new RuntimeError("Missing right parenthesis in expression");
+ }
scanner.advance();
return value;
}
// The only atomic booleans are of the form $variable == value or the
// form $variable.
- Expect.equals(scanner.current, Token.DOLLAR_SYMBOL,
- "Expected \$ in expression, got ${scanner.current}");
+ if (scanner.current != Token.DOLLAR_SYMBOL) {
+ throw new RuntimeError(
+ "Expected \$ in expression, got ${scanner.current}");
+ }
scanner.advance();
- Expect.isTrue(new RegExp(r"^\w+$").hasMatch(scanner.current),
- "Expected identifier in expression, got ${scanner.current}");
+ if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) {
+ throw new RuntimeError(
+ "Expected identifier in expression, got ${scanner.current}");
+ }
TermVariable left = new TermVariable(scanner.current);
scanner.advance();
if (scanner.current == Token.EQUALS) {
scanner.advance();
- Expect.isTrue(new RegExp(r"^\w+$").hasMatch(scanner.current),
- "Expected identifier in expression, got ${scanner.current}");
+ if (!new RegExp(r"^\w+$").hasMatch(scanner.current)) {
+ throw new RuntimeError(
+ "Expected identifier in expression, got ${scanner.current}");
+ }
TermConstant right = new TermConstant(scanner.current);
scanner.advance();
return new Comparison(left, right);
diff --git a/tools/testing/dart/test_options.dart b/tools/testing/dart/test_options.dart
index d751ab4..0932f21 100644
--- a/tools/testing/dart/test_options.dart
+++ b/tools/testing/dart/test_options.dart
@@ -79,10 +79,10 @@
dartc: Perform static analysis on Dart code by running dartc.
(only valid with the following runtimes: none),
- new_analyzer: Perform static analysis on Dart code by running the analyzer.
+ dartanalyzer: Perform static analysis on Dart code by running the analyzer.
(only valid with the following runtimes: none)''',
['-c', '--compiler'],
- ['none', 'dart2dart', 'dart2js', 'dartc', 'new_analyzer'],
+ ['none', 'dart2dart', 'dart2js', 'dartc', 'dartanalyzer'],
'none'),
new _TestOptionSpecification(
'runtime',
@@ -442,7 +442,7 @@
'opera'];
break;
case 'dartc':
- case 'new_analyzer':
+ case 'dartanalyzer':
validRuntimes = const ['none'];
break;
case 'none':
@@ -591,7 +591,7 @@
var timeout = 60;
switch (configuration['compiler']) {
case 'dartc':
- case 'new_analyzer':
+ case 'dartanalyzer':
timeout *= 4;
break;
case 'dart2js':
diff --git a/tools/testing/dart/test_progress.dart b/tools/testing/dart/test_progress.dart
index af5caf6..5eac74a 100644
--- a/tools/testing/dart/test_progress.dart
+++ b/tools/testing/dart/test_progress.dart
@@ -310,7 +310,7 @@
}
}
-class LineProgressIndicator extends EventListener {
+class LineProgressIndicator extends EventListener implements ProgressIndicator {
void done(TestCase test) {
var status = 'pass';
if (test.lastCommandOutput.unexpectedOutput) {
diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart
index f81135d..5dd8e19 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -33,6 +33,12 @@
typedef void ExitCodeEvent(int exitCode);
typedef void EnqueueMoreWork(ProcessQueue queue);
+// Some IO tests use these variables and get confused if the host environment
+// variables are inherited so they are excluded.
+const List<String> EXCLUDED_ENVIRONMENT_VARIABLES =
+ const ['http_proxy', 'https_proxy', 'no_proxy',
+ 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY'];
+
/**
* [areByteArraysEqual] compares a range of bytes from [buffer1] with a
@@ -161,7 +167,7 @@
var dependencyLastModified =
TestUtils.lastModifiedCache.getLastModified(dependency);
if (dependencyLastModified == null ||
- dependencyLastModified > jsOutputLastModified) {
+ dependencyLastModified.isAfter(jsOutputLastModified)) {
return false;
}
}
@@ -275,8 +281,9 @@
// PREFIX EXECUTABLE SUFFIX ARGUMENTS
var specialCommand = configuration['special-command'];
if (!specialCommand.isEmpty) {
- Expect.isTrue(specialCommand.contains('@'),
- "special-command must contain a '@' char");
+ if (!specialCommand.contains('@')) {
+ throw new FormatException("special-command must contain a '@' char");
+ }
var specialCommandSplit = specialCommand.split('@');
var prefix = specialCommandSplit[0].trim();
var suffix = specialCommandSplit[1].trim();
@@ -393,8 +400,7 @@
List<String> get batchRunnerArguments => [_lastArguments[0], '--batch'];
- List<String> get batchTestArguments =>
- _lastArguments.getRange(1, _lastArguments.length - 1);
+ List<String> get batchTestArguments => _lastArguments.sublist(1);
/** Add a test case to listen for when this current test has completed. */
void addObserver(BrowserTestCase testCase) {
@@ -810,7 +816,7 @@
bool _didMultitestFail(List errors, List staticWarnings) {
Set<String> outcome = testCase.info.multitestOutcome;
- Expect.isNotNull(outcome);
+ if (outcome == null) throw "outcome must not be null";
if (outcome.contains('compile-time error') && errors.length > 0) {
return true;
} else if (outcome.contains('static type warning')
@@ -943,7 +949,9 @@
RunningProcess(TestCase this.testCase, Command this.command);
Future<CommandOutput> start() {
- Expect.isFalse(testCase.expectedOutcomes.contains(SKIP));
+ if (testCase.expectedOutcomes.contains(SKIP)) {
+ throw "testCase.expectedOutcomes must not contain 'SKIP'.";
+ }
completer = new Completer<CommandOutput>();
startTime = new DateTime.now();
@@ -1020,6 +1028,11 @@
options.environment = new Map<String, String>.from(baseEnvironment);
options.environment['DART_CONFIGURATION'] =
TestUtils.configurationDir(testCase.configuration);
+
+ for (var excludedEnvironmentVariable in EXCLUDED_ENVIRONMENT_VARIABLES) {
+ options.environment.remove(excludedEnvironmentVariable);
+ }
+
return options;
}
}
@@ -1055,7 +1068,7 @@
bool get active => _currentTest != null;
void startTest(TestCase testCase) {
- Expect.isNull(_currentTest);
+ if (_currentTest != null) throw "_currentTest must be null.";
_currentTest = testCase;
_command = testCase.commands.last;
if (_process == null) {
@@ -1413,7 +1426,7 @@
void _runTest(TestCase test) {
if (test.usesWebDriver) {
- browserUsed = test.configuration['browser'];
+ browserUsed = test.configuration['runtime'];
if (_needsSelenium) _ensureSeleniumServerRunning();
}
eventTestAdded(test);
@@ -1652,7 +1665,9 @@
var nextCommandIndex = testCase.commandOutputs.keys.length;
var numberOfCommands = testCase.commands.length;
- Expect.isTrue(nextCommandIndex < numberOfCommands);
+ if (nextCommandIndex >= numberOfCommands) {
+ throw "nextCommandIndex must be less than numberOfCommands";
+ }
var command = testCase.commands[nextCommandIndex];
var isLastCommand = nextCommandIndex == (numberOfCommands - 1);
diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart
index 24c71dc..6381a12 100644
--- a/tools/testing/dart/test_suite.dart
+++ b/tools/testing/dart/test_suite.dart
@@ -140,7 +140,7 @@
var name;
switch (configuration['compiler']) {
case 'dartc':
- case 'new_analyzer':
+ case 'dartanalyzer':
name = executablePath;
break;
case 'dart2js':
@@ -181,8 +181,8 @@
return '$buildDir/dart$suffix';
case 'dartc':
return '$buildDir/analyzer/bin/dart_analyzer$suffix';
- case 'new_analyzer':
- return 'sdk/bin/analyzer$suffix';
+ case 'dartanalyzer':
+ return 'sdk/bin/dartanalyzer_developer$suffix';
default:
throw "Unknown executable for: ${configuration['compiler']}";
}
@@ -397,7 +397,7 @@
this.hasCompileError, this.hasRuntimeError,
this.isNegativeIfChecked, this.hasFatalTypeErrors,
this.multitestOutcome) {
- Expect.isTrue(filePath.isAbsolute);
+ assert(filePath.isAbsolute);
}
}
@@ -473,8 +473,8 @@
if (!useSdk) return [];
var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join(
- new Path('dart-sdk/lib/_internal/compiler/'
- 'implementation/dart2js.dart.snapshot'))).toString();
+ new Path('dart-sdk/bin/snapshots/'
+ 'utils_wrapper.dart.snapshot'))).toString();
return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)];
}
@@ -528,7 +528,7 @@
return new Future.immediate(null);
}
- Expect.isTrue(updater.isActive);
+ assert(updater.isActive);
updater.onUpdated.add(() => completer.complete(null));
return completer.future;
@@ -637,10 +637,10 @@
} else {
// The test name is the relative path from the test suite directory to
// the test, with the .dart extension removed.
- Expect.isTrue(filePath.toNativePath().startsWith(
+ assert(filePath.toNativePath().startsWith(
suiteDir.toNativePath()));
var testNamePath = filePath.relativeTo(suiteDir);
- Expect.isTrue(testNamePath.extension == 'dart');
+ assert(testNamePath.extension == 'dart');
if (testNamePath.extension == 'dart') {
testName = testNamePath.directoryPath.append(
testNamePath.filenameWithoutExtension).toString();
@@ -717,7 +717,7 @@
info.optionsFromFile);
List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile);
- Expect.isFalse(vmOptionsList.isEmpty, "empty vmOptionsList");
+ assert(!vmOptionsList.isEmpty);
for (var vmOptions in vmOptionsList) {
doTest(new TestCase('$suiteName/$testName',
@@ -781,7 +781,7 @@
case 'none':
case 'dartc':
- case 'new_analyzer':
+ case 'dartanalyzer':
var arguments = new List.from(vmOptions);
arguments.addAll(args);
return <Command>[new Command(dartShellFileName, arguments)];
@@ -836,7 +836,8 @@
return "/$PREFIX_DARTDIR/$fileRelativeToDartDir";
}
// Unreachable
- Expect.fail('This should be unreachable.');
+ print("Cannot create URL for path $file. Not in build or dart directory.");
+ exit(1);
}
String _getUriForBrowserTest(TestInformation info,
@@ -848,7 +849,7 @@
var serverPort = "PORT";
var crossOriginPort = "CROSS_ORIGIN_PORT";
if (!configuration['list']) {
- Expect.isTrue(configuration.containsKey('_servers_'));
+ assert(configuration.containsKey('_servers_'));
serverPort = configuration['_servers_'].port;
crossOriginPort = configuration['_servers_'].crossOriginPort;
}
@@ -970,7 +971,7 @@
List<String> otherScripts = optionsFromFile['otherScripts'];
for (String name in otherScripts) {
Path namePath = new Path(name);
- Expect.equals(namePath.extension, 'dart');
+ assert(namePath.extension == 'dart');
String baseName = namePath.filenameWithoutExtension;
Path fromPath = filePath.directoryPath.join(namePath);
commands.add(_compileCommand(
@@ -1012,7 +1013,10 @@
}
commandSet.add(new Command('python', args));
} else {
- Expect.isTrue(runtime == "drt");
+ if (runtime != "drt") {
+ print("Unknown runtime $runtime");
+ exit(1);
+ }
var dartFlags = [];
var dumpRenderTreeOptions = [];
@@ -1085,7 +1089,8 @@
args.add(inputFile);
break;
default:
- Expect.fail('unimplemented compiler $compiler');
+ print('unimplemented compiler $compiler');
+ exit(1);
}
if (executable.endsWith('.dart')) {
// Run the compiler script via the Dart VM.
@@ -1148,12 +1153,13 @@
case 'dart2dart':
return 'application/dart';
case 'dart2js':
- case 'new_analyzer':
+ case 'dartanalyzer':
case 'dartc':
return 'text/javascript';
default:
- Expect.fail('Non-web runtime, so no scriptType for: '
+ print('Non-web runtime, so no scriptType for: '
'${configuration["compiler"]}');
+ exit(1);
return null;
}
}
@@ -1216,7 +1222,7 @@
bool isMultitest = optionsFromFile["isMultitest"];
List<String> dartOptions = optionsFromFile["dartOptions"];
List<List<String>> vmOptionsList = getVmOptions(optionsFromFile);
- Expect.isTrue(!isMultitest || dartOptions == null);
+ assert(!isMultitest || dartOptions == null);
if (dartOptions == null) {
args.add(filePath.toNativePath());
} else {
@@ -1225,7 +1231,7 @@
var file = new File(executable_name);
if (!file.existsSync()) {
executable_name = '../$executable_name';
- Expect.isTrue(new File(executable_name).existsSync());
+ assert(new File(executable_name).existsSync());
dartOptions[0] = executable_name;
}
args.addAll(dartOptions);
@@ -1710,8 +1716,7 @@
base = new Path('/');
}
Directory dir = new Directory.fromPath(base);
- Expect.isTrue(dir.existsSync(),
- "Expected ${dir} to already exist");
+ assert(dir.existsSync());
var segments = relativePath.segments();
for (String segment in segments) {
base = base.append(segment);
@@ -1725,7 +1730,7 @@
if (!dir.existsSync()) {
dir.createSync();
}
- Expect.isTrue(dir.existsSync(), "Failed to create ${dir.path}");
+ assert(dir.existsSync());
}
return dir;
}
@@ -1832,7 +1837,7 @@
const ['d8', 'jsshell'].contains(runtime);
static bool isCommandLineAnalyzer(String compiler) =>
- compiler == 'dartc' || compiler == 'new_analyzer';
+ compiler == 'dartc' || compiler == 'dartanalyzer';
static String buildDir(Map configuration) {
// FIXME(kustermann,ricow): Our code assumes that the returned 'buildDir'
diff --git a/utils/apidoc/apidoc.dart b/utils/apidoc/apidoc.dart
index a4fbe43..b7783b4 100644
--- a/utils/apidoc/apidoc.dart
+++ b/utils/apidoc/apidoc.dart
@@ -17,6 +17,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:json' as json;
+import 'dart:uri';
import 'html_diff.dart';
@@ -25,6 +26,7 @@
import '../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart';
import '../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart';
import '../../sdk/lib/_internal/libraries.dart';
+import 'package:pathos/path.dart' as pathos;
HtmlDiff _diff;
@@ -37,7 +39,7 @@
List<String> excludedLibraries = <String>[];
List<String> includedLibraries = <String>[];
- Path packageRoot;
+ String packageRoot;
String version;
// Parse the command-line arguments.
@@ -65,7 +67,7 @@
} else if (arg.startsWith('--out=')) {
outputDir = new Path(arg.substring('--out='.length));
} else if (arg.startsWith('--package-root=')) {
- packageRoot = new Path(arg.substring('--package-root='.length));
+ packageRoot = arg.substring('--package-root='.length);
} else if (arg.startsWith('--version=')) {
version = arg.substring('--version='.length);
} else {
@@ -104,10 +106,10 @@
// TODO(johnniwinther): Libraries for the compilation seem to be more like
// URIs. Perhaps Path should have a toURI() method.
// Add all of the core libraries.
- final apidocLibraries = <Path>[];
+ final apidocLibraries = <Uri>[];
LIBRARIES.forEach((String name, LibraryInfo info) {
if (info.documented) {
- apidocLibraries.add(new Path('dart:$name'));
+ apidocLibraries.add(Uri.parse('dart:$name'));
}
});
@@ -130,7 +132,7 @@
}
if (new File.fromPath(libPath).existsSync()) {
- apidocLibraries.add(libPath);
+ apidocLibraries.add(_pathToFileUri(libPath.toNativePath()));
includedLibraries.add(libName);
} else {
print('Warning: could not find package at $path');
@@ -147,7 +149,7 @@
// TODO(amouravski): make apidoc use roughly the same flow as bin/dartdoc.
Future.wait([copiedStatic, copiedApiDocStatic, htmlDiff])
- .then((_) => apidoc.documentLibraries( apidocLibraries, libPath,
+ .then((_) => apidoc.documentLibraries(apidocLibraries, libPath,
packageRoot))
.then((_) => compileScript(mode, outputDir, libPath))
.then((_) => print(apidoc.status))
@@ -447,3 +449,14 @@
return a(memberUrl(member), memberName);
}
}
+
+/** Converts a local path string to a `file:` [Uri]. */
+Uri _pathToFileUri(String path) {
+ path = pathos.absolute(path);
+ if (Platform.operatingSystem != 'windows') {
+ return Uri.parse('file://$path');
+ } else {
+ return Uri.parse('file:///${path.replaceAll("\\", "/")}');
+ }
+}
+
diff --git a/utils/apidoc/apidoc.gyp b/utils/apidoc/apidoc.gyp
index f3f484a..f75e4c7 100644
--- a/utils/apidoc/apidoc.gyp
+++ b/utils/apidoc/apidoc.gyp
@@ -28,24 +28,55 @@
'actions': [
{
'action_name': 'run_apidoc',
+ # The 'inputs' list records the files whose timestamps are
+ # compared to the files listed in 'outputs'. If a file
+ # 'outputs' doesn't exist or if a file in 'inputs' is newer
+ # than a file in 'outputs', this action is executed. Notice
+ # that the dependencies listed above has nothing to do with
+ # when this action is executed. You must list a file in
+ # 'inputs' to make sure that it exists before the action is
+ # executed, or to make sure this action is re-run.
+ #
+ # We want to build the platform documentation whenever
+ # dartdoc, apidoc, or its dependency changes. This prevents
+ # people from accidentally breaking apidoc when making
+ # changes to the platform libraries and or when modifying
+ # dart2js or the VM.
+ #
+ # In addition, we want to make sure that the platform
+ # documentation is regenerated when the platform sources
+ # changes.
+ #
+ # So we want this action to be re-run when a dart file
+ # changes in this directory, or in the SDK library (we may
+ # no longer need to list the files in ../../runtime/lib and
+ # ../../runtime/bin, as most of them has moved to
+ # ../../sdk/lib).
+ #
+ # In addition, we want to make sure the documentation is
+ # regenerated when a resource file (CSS, PNG, etc) is
+ # updated. This is because these files are also copied to
+ # the output directory.
'inputs': [
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)',
- '<(PRODUCT_DIR)/dart2js.snapshot',
+ '<(SHARED_INTERMEDIATE_DIR)/utils_wrapper.dart.snapshot',
'<!@(["python", "../../tools/list_files.py", "\\.(css|ico|js|json|png|sh|txt|yaml|py)$", ".", "../../sdk/lib/_internal/dartdoc"])',
- '<!@(["python", "../../tools/list_files.py", "\\.dart$", "../../sdk/lib", "../../runtime/lib", "../../runtime/bin"])',
+ '<!@(["python", "../../tools/list_files.py", "\\.dart$", ".", "../../sdk/lib", "../../runtime/lib", "../../runtime/bin"])',
'../../sdk/bin/dart',
'../../sdk/bin/dart.bat',
'../../sdk/bin/dart2js',
'../../sdk/bin/dart2js.bat',
- ],
- 'inputs': [
- '<!@(["python", "../../tools/list_files.py", "\\.(css|png|dart)$", "."])',
+ '../../tools/only_in_release_mode.py',
],
'outputs': [
'<(PRODUCT_DIR)/api_docs/index.html',
'<(PRODUCT_DIR)/api_docs/client-static.js',
],
'action': [
+ 'python',
+ '../../tools/only_in_release_mode.py',
+ '<@(_outputs)',
+ '--',
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)',
'--package-root=<(PRODUCT_DIR)/packages/',
'apidoc.dart',
@@ -56,6 +87,7 @@
'--exclude-lib=analyzer_experimental',
'--exclude-lib=browser',
'--exclude-lib=dartdoc',
+ '--exclude-lib=expect',
'--exclude-lib=http',
'--exclude-lib=oauth2',
'--exclude-lib=pathos',
diff --git a/utils/compiler/compiler.gyp b/utils/compiler/compiler.gyp
index 784a75b..1755ce2 100644
--- a/utils/compiler/compiler.gyp
+++ b/utils/compiler/compiler.gyp
@@ -22,40 +22,15 @@
'<!@(["python", "../../tools/list_files.py", "\\.dart$", "../../sdk/lib/_internal/compiler", "../../runtime/lib"])',
],
'outputs': [
- '<(PRODUCT_DIR)/dart2js.snapshot',
+ '<(SHARED_INTERMEDIATE_DIR)/utils_wrapper.dart.snapshot',
],
'action': [
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)',
- # Note: we don't store the snapshot in the location where
- # the dart2js script is looking for it. The motivation
- # for that is to support an incremental development model
- # for dart2js compiler engineers. However, we install the
- # snapshot in the proper location when building the SDK.
- '--generate-script-snapshot=<(PRODUCT_DIR)/dart2js.snapshot',
- '../../sdk/lib/_internal/compiler/implementation/dart2js.dart',
+ 'create_snapshot.dart',
+ '--output_dir=<(SHARED_INTERMEDIATE_DIR)',
+ '--dart2js_main=sdk/lib/_internal/compiler/implementation/dart2js.dart',
],
},
- {
- # TODO(ahe): Remove this action after a few days.
- 'action_name': 'remove_old_scripts',
- 'inputs': [
- 'remove_old_scripts.py',
- ],
- 'outputs': [
- '<(INTERMEDIATE_DIR)/<(_action_name).success',
- ],
- 'action': [
- 'python',
- '<@(_inputs)',
- '<@(_outputs)',
- '<(PRODUCT_DIR)/dart2js',
- '<(PRODUCT_DIR)/dart2js.bat',
- '<(PRODUCT_DIR)/dart2js_developer',
- '<(PRODUCT_DIR)/dart2js_developer.bat',
- '<(PRODUCT_DIR)/dartdoc',
- '<(PRODUCT_DIR)/dartdoc.bat',
- ]
- },
],
},
],
diff --git a/utils/compiler/create_snapshot.dart b/utils/compiler/create_snapshot.dart
new file mode 100644
index 0000000..f0e50082
--- /dev/null
+++ b/utils/compiler/create_snapshot.dart
@@ -0,0 +1,90 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+
+Future<String> getVersion(var options, var rootPath) {
+ var versionPath = rootPath.append("tools").append("version.dart");
+ return Process.run(options.executable,
+ [versionPath.toNativePath()])
+ .then((result) {
+ if (result.exitCode != 0) {
+ throw "Could not generate version";
+ }
+ return result.stdout.trim();
+ });
+}
+
+Future<String> getSnapshotGenerationFile(var options, var args, var rootPath) {
+ var dart2js = rootPath.append(args["dart2js_main"]);
+
+ return getVersion(options, rootPath).then((version) {
+ var snapshotGenerationText =
+"""
+import '${dart2js}' as dart2jsMain;
+import 'dart:io';
+
+void main() {
+ Options options = new Options();
+ if (options.arguments.length < 1) throw "No tool given as argument";
+ String tool = options.arguments.removeAt(0);
+ if (tool == "dart2js") {
+ dart2jsMain.BUILD_ID = "$version";
+ dart2jsMain.mainWithErrorHandler(options);
+ }
+}
+
+""";
+ return snapshotGenerationText;
+ });
+}
+
+void writeSnapshotFile(var path, var content) {
+ File file = new File(path);
+ var writer = file.openSync(mode: FileMode.WRITE);
+ writer.writeStringSync(content);
+ writer.close();
+}
+
+Future createSnapshot(var options, var dart_file) {
+ return Process.run(options.executable,
+ ["--generate-script-snapshot=$dart_file.snapshot",
+ dart_file])
+ .then((result) {
+ if (result.exitCode != 0) {
+ throw "Could not generate snapshot";
+ }
+ });
+}
+
+/**
+ * Takes the following arguments:
+ * --output_dir=val The full path to the output_dir.
+ * --dart2js_main=val The path to the dart2js main script releative to root.
+ */
+void main() {
+ Options options = new Options();
+ var validArguments = ["--output_dir", "--dart2js_main"];
+ var args = {};
+ for (var argument in options.arguments) {
+ var argumentSplit = argument.split("=");
+ if (argumentSplit.length != 2) throw "Invalid argument $argument, no =";
+ if (!validArguments.contains(argumentSplit[0])) {
+ throw "Invalid argument $argument";
+ }
+ args[argumentSplit[0].substring(2)] = argumentSplit[1];
+ }
+ if (!args.containsKey("dart2js_main")) throw "Please specify dart2js_main";
+ if (!args.containsKey("output_dir")) throw "Please specify output_dir";
+
+ var scriptFile = new File(options.script);
+ var path = new Path(scriptFile.directorySync().path);
+ var rootPath = path.directoryPath.directoryPath;
+
+ getSnapshotGenerationFile(options, args, rootPath).then((result) {
+ var wrapper = "${args['output_dir']}/utils_wrapper.dart";
+ writeSnapshotFile(wrapper, result);
+ createSnapshot(options, wrapper);
+ });
+}
diff --git a/utils/compiler/remove_old_scripts.py b/utils/compiler/remove_old_scripts.py
deleted file mode 100644
index ffa6400..0000000
--- a/utils/compiler/remove_old_scripts.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-'''
-Tool for deleting files given on the command line, and touching a
-file on success.
-
-Usage:
- python tools/list_files.py FILE_TO_TOUCH FILES_TO_DELETE...
-'''
-
-import os
-import sys
-
-
-def main(argv):
- file_to_touch = argv[1]
- for filename in argv[2:]:
- if os.path.exists(filename):
- os.remove(filename)
- with file(file_to_touch, 'a'):
- os.utime(file_to_touch, None)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/utils/pub/error_group.dart b/utils/pub/error_group.dart
index f579d8e..b5f8f8e 100644
--- a/utils/pub/error_group.dart
+++ b/utils/pub/error_group.dart
@@ -230,7 +230,7 @@
StreamSubscription _subscription;
/// Whether [this] has any listeners.
- bool get _hasListeners => _controller.hasSubscribers;
+ bool get _hasListeners => _controller.hasListener;
/// Creates a new [_ErrorGroupFuture] that's a child of [_group] and wraps
/// [inner].
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 3eed22c..8523d34 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -149,7 +149,7 @@
var entityPath = entity.path;
if (!includeHidden && path.basename(entityPath).startsWith('.')) continue;
- // TODO(nweiz): remove this when issue 4928 is fixed.
+ // TODO(nweiz): remove this when issue 9832 is fixed.
if (entity is Link) {
// We treat broken symlinks as files, in that we don't want to recurse
// into them.
@@ -188,12 +188,7 @@
void deleteEntry(String path) {
if (linkExists(path)) {
log.io("Deleting link $path.");
- if (Platform.operatingSystem == 'windows') {
- // TODO(nweiz): remove this when issue 9278 is fixed.
- new Directory(path).deleteSync();
- } else {
- new Link(path).deleteSync();
- }
+ new Link(path).deleteSync();
} else if (dirExists(path)) {
log.io("Deleting directory $path.");
new Directory(path).deleteSync(recursive: true);
diff --git a/utils/pub/package.dart b/utils/pub/package.dart
index d3d9819..883b01b1 100644
--- a/utils/pub/package.dart
+++ b/utils/pub/package.dart
@@ -48,12 +48,12 @@
where((entry) => entry.contains(_README_REGEXP));
if (readmes.isEmpty) return;
- return path.join(dir, readmes.min((readme1, readme2) {
+ return path.join(dir, readmes.reduce((readme1, readme2) {
var extensions1 = ".".allMatches(readme1).length;
var extensions2 = ".".allMatches(readme2).length;
var comparison = extensions1.compareTo(extensions2);
- if (comparison != 0) return comparison;
- return readme1.compareTo(readme2);
+ if (comparison == 0) comparison = readme1.compareTo(readme2);
+ return (comparison <= 0) ? readme1 : readme2;
}));
}
diff --git a/utils/pub/safe_http_server.dart b/utils/pub/safe_http_server.dart
index 7fd522b..8843e48 100644
--- a/utils/pub/safe_http_server.dart
+++ b/utils/pub/safe_http_server.dart
@@ -131,7 +131,7 @@
List<Cookie> get cookies => _inner.cookies;
Future<Socket> detachSocket() => _inner.detachSocket();
HttpConnectionInfo get connectionInfo => _inner.connectionInfo;
- void writeBytes(List<int> data) => _inner.writeBytes(data);
+ void add(List<int> data) => _inner.add(data);
Future<HttpResponse> consume(Stream<List<int>> stream) =>
_inner.consume(stream);
Future<HttpResponse> addStream(Stream<List<int>> stream) =>
diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
index cb316cbe..47c27fc 100644
--- a/utils/pub/utils.dart
+++ b/utils/pub/utils.dart
@@ -110,7 +110,7 @@
/// Returns a set containing all elements in [minuend] that are not in
/// [subtrahend].
-Set setMinus(Collection minuend, Collection subtrahend) {
+Set setMinus(Iterable minuend, Iterable subtrahend) {
var minuendSet = new Set.from(minuend);
minuendSet.removeAll(subtrahend);
return minuendSet;
@@ -333,13 +333,13 @@
String urlDecode(String encoded) =>
decodeUriComponent(encoded.replaceAll("+", " "));
-/// Takes a simple data structure (composed of [Map]s, [List]s, scalar objects,
-/// and [Future]s) and recursively resolves all the [Future]s contained within.
-/// Completes with the fully resolved structure.
+/// Takes a simple data structure (composed of [Map]s, [Iterable]s, scalar
+/// objects, and [Future]s) and recursively resolves all the [Future]s contained
+/// within. Completes with the fully resolved structure.
Future awaitObject(object) {
// Unroll nested futures.
if (object is Future) return object.then(awaitObject);
- if (object is Collection) {
+ if (object is Iterable) {
return Future.wait(object.map(awaitObject).toList());
}
if (object is! Map) return new Future.immediate(object);
diff --git a/utils/tests/pub/command_line_config.dart b/utils/tests/pub/command_line_config.dart
index f05f931..1efd7d1d 100644
--- a/utils/tests/pub/command_line_config.dart
+++ b/utils/tests/pub/command_line_config.dart
@@ -5,6 +5,7 @@
library command_line_config;
import 'dart:io';
+import 'dart:math';
import 'package:pathos/path.dart' as path;
import 'package:unittest/unittest.dart';
@@ -91,7 +92,7 @@
if (stack.length == 0) return;
// Figure out the longest path so we know how much to pad.
- int longest = stack.map((frame) => frame.location.length).max();
+ int longest = stack.map((frame) => frame.location.length).reduce(max);
// Print out the stack trace nicely formatted.
for (var frame in stack) {
diff --git a/utils/tests/pub/install/git/check_out_and_update_test.dart b/utils/tests/pub/install/git/check_out_and_update_test.dart
index 14e65c7..3af7fb7 100644
--- a/utils/tests/pub/install/git/check_out_and_update_test.dart
+++ b/utils/tests/pub/install/git/check_out_and_update_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('checks out and updates a package from Git', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/check_out_branch_test.dart b/utils/tests/pub/install/git/check_out_branch_test.dart
index 8375fb2..2df0198 100644
--- a/utils/tests/pub/install/git/check_out_branch_test.dart
+++ b/utils/tests/pub/install/git/check_out_branch_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('checks out a package at a specific branch from Git', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/check_out_revision_test.dart b/utils/tests/pub/install/git/check_out_revision_test.dart
index e9fec81..b763dd4 100644
--- a/utils/tests/pub/install/git/check_out_revision_test.dart
+++ b/utils/tests/pub/install/git/check_out_revision_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('checks out a package at a specific revision from Git', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/check_out_test.dart b/utils/tests/pub/install/git/check_out_test.dart
index dcd530b..c2a4f68 100644
--- a/utils/tests/pub/install/git/check_out_test.dart
+++ b/utils/tests/pub/install/git/check_out_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('checks out a package from Git', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/check_out_transitive_test.dart b/utils/tests/pub/install/git/check_out_transitive_test.dart
index 6031447..d68763c 100644
--- a/utils/tests/pub/install/git/check_out_transitive_test.dart
+++ b/utils/tests/pub/install/git/check_out_transitive_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('checks out packages transitively from Git', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/check_out_twice_test.dart b/utils/tests/pub/install/git/check_out_twice_test.dart
index 8ddd2ac..87d9a94 100644
--- a/utils/tests/pub/install/git/check_out_twice_test.dart
+++ b/utils/tests/pub/install/git/check_out_twice_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('checks out a package from Git twice', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/check_out_with_trailing_slash_test.dart b/utils/tests/pub/install/git/check_out_with_trailing_slash_test.dart
index 2b1bb1c..e414483 100644
--- a/utils/tests/pub/install/git/check_out_with_trailing_slash_test.dart
+++ b/utils/tests/pub/install/git/check_out_with_trailing_slash_test.dart
@@ -12,6 +12,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
group("(regression)", () {
integration('checks out a package from Git with a trailing slash', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/dependency_name_match_pubspec_test.dart b/utils/tests/pub/install/git/dependency_name_match_pubspec_test.dart
index cd12ff2..c1e5572 100644
--- a/utils/tests/pub/install/git/dependency_name_match_pubspec_test.dart
+++ b/utils/tests/pub/install/git/dependency_name_match_pubspec_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('requires the dependency name to match the remote pubspec '
'name', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/different_repo_name_test.dart b/utils/tests/pub/install/git/different_repo_name_test.dart
index 3c30faf..3e5378c 100644
--- a/utils/tests/pub/install/git/different_repo_name_test.dart
+++ b/utils/tests/pub/install/git/different_repo_name_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('doesn\'t require the repository name to match the name in the '
'pubspec', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/lock_version_test.dart b/utils/tests/pub/install/git/lock_version_test.dart
index 205b6ea..444ff38 100644
--- a/utils/tests/pub/install/git/lock_version_test.dart
+++ b/utils/tests/pub/install/git/lock_version_test.dart
@@ -14,6 +14,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('keeps a Git package locked to the version in the lockfile', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/require_pubspec_name_test.dart b/utils/tests/pub/install/git/require_pubspec_name_test.dart
index 1713e04..aad6a52 100644
--- a/utils/tests/pub/install/git/require_pubspec_name_test.dart
+++ b/utils/tests/pub/install/git/require_pubspec_name_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('requires the dependency to have a pubspec with a name '
'field', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/require_pubspec_test.dart b/utils/tests/pub/install/git/require_pubspec_test.dart
index 084bbe0..ad1a22d 100644
--- a/utils/tests/pub/install/git/require_pubspec_test.dart
+++ b/utils/tests/pub/install/git/require_pubspec_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('requires the dependency to have a pubspec', () {
ensureGit();
diff --git a/utils/tests/pub/install/git/stay_locked_if_compatible_test.dart b/utils/tests/pub/install/git/stay_locked_if_compatible_test.dart
index 0f57785..8bc5025 100644
--- a/utils/tests/pub/install/git/stay_locked_if_compatible_test.dart
+++ b/utils/tests/pub/install/git/stay_locked_if_compatible_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("doesn't update a locked Git package with a new compatible "
"constraint", () {
ensureGit();
diff --git a/utils/tests/pub/install/git/unlock_if_incompatible_test.dart b/utils/tests/pub/install/git/unlock_if_incompatible_test.dart
index 64d4406..1b23fba 100644
--- a/utils/tests/pub/install/git/unlock_if_incompatible_test.dart
+++ b/utils/tests/pub/install/git/unlock_if_incompatible_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('updates a locked Git package with a new incompatible '
'constraint', () {
ensureGit();
diff --git a/utils/tests/pub/install/hosted/do_not_update_on_removed_constraints_test.dart b/utils/tests/pub/install/hosted/do_not_update_on_removed_constraints_test.dart
index ba49e66..539d263 100644
--- a/utils/tests/pub/install/hosted/do_not_update_on_removed_constraints_test.dart
+++ b/utils/tests/pub/install/hosted/do_not_update_on_removed_constraints_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("doesn't update dependencies whose constraints have been "
"removed", () {
servePackages([
diff --git a/utils/tests/pub/install/hosted/fail_gracefully_on_missing_package_test.dart b/utils/tests/pub/install/hosted/fail_gracefully_on_missing_package_test.dart
index e0b4615..5833599 100644
--- a/utils/tests/pub/install/hosted/fail_gracefully_on_missing_package_test.dart
+++ b/utils/tests/pub/install/hosted/fail_gracefully_on_missing_package_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('fails gracefully if the package does not exist', () {
servePackages([]);
diff --git a/utils/tests/pub/install/hosted/fail_gracefully_on_url_resolve_test.dart b/utils/tests/pub/install/hosted/fail_gracefully_on_url_resolve_test.dart
index 6c7acde..2fef340 100644
--- a/utils/tests/pub/install/hosted/fail_gracefully_on_url_resolve_test.dart
+++ b/utils/tests/pub/install/hosted/fail_gracefully_on_url_resolve_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('fails gracefully if the url does not resolve', () {
d.dir(appPath, [
d.pubspec({
diff --git a/utils/tests/pub/install/hosted/install_transitive_test.dart b/utils/tests/pub/install/hosted/install_transitive_test.dart
index 23e4bd6..7da990f5 100644
--- a/utils/tests/pub/install/hosted/install_transitive_test.dart
+++ b/utils/tests/pub/install/hosted/install_transitive_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('installs packages transitively from a pub server', () {
servePackages([
packageMap("foo", "1.2.3", [dependencyMap("bar", "2.0.4")]),
diff --git a/utils/tests/pub/install/hosted/remove_removed_dependency_test.dart b/utils/tests/pub/install/hosted/remove_removed_dependency_test.dart
index d009ac3..44d4be1 100644
--- a/utils/tests/pub/install/hosted/remove_removed_dependency_test.dart
+++ b/utils/tests/pub/install/hosted/remove_removed_dependency_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("removes a dependency that's been removed from the pubspec", () {
servePackages([
packageMap("foo", "1.0.0"),
diff --git a/utils/tests/pub/install/hosted/remove_removed_transitive_dependency_test.dart b/utils/tests/pub/install/hosted/remove_removed_transitive_dependency_test.dart
index 6120c33..35aa564 100644
--- a/utils/tests/pub/install/hosted/remove_removed_transitive_dependency_test.dart
+++ b/utils/tests/pub/install/hosted/remove_removed_transitive_dependency_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("removes a transitive dependency that's no longer depended"
" on", () {
servePackages([
diff --git a/utils/tests/pub/install/hosted/resolve_constraints_test.dart b/utils/tests/pub/install/hosted/resolve_constraints_test.dart
index 2b6f2b0..0da297a 100644
--- a/utils/tests/pub/install/hosted/resolve_constraints_test.dart
+++ b/utils/tests/pub/install/hosted/resolve_constraints_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('resolves version constraints from a pub server', () {
servePackages([
packageMap("foo", "1.2.3", [dependencyMap("baz", ">=2.0.0")]),
diff --git a/utils/tests/pub/install/hosted/stay_locked_if_compatible_test.dart b/utils/tests/pub/install/hosted/stay_locked_if_compatible_test.dart
index 7681164..7c08ab5 100644
--- a/utils/tests/pub/install/hosted/stay_locked_if_compatible_test.dart
+++ b/utils/tests/pub/install/hosted/stay_locked_if_compatible_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("doesn't update a locked pub server package with a new "
"compatible constraint", () {
servePackages([packageMap("foo", "1.0.0")]);
diff --git a/utils/tests/pub/install/hosted/stay_locked_if_new_is_satisfied_test.dart b/utils/tests/pub/install/hosted/stay_locked_if_new_is_satisfied_test.dart
index 81bf855..fd2f244 100644
--- a/utils/tests/pub/install/hosted/stay_locked_if_new_is_satisfied_test.dart
+++ b/utils/tests/pub/install/hosted/stay_locked_if_new_is_satisfied_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("doesn't unlock dependencies if a new dependency is already "
"satisfied", () {
servePackages([
diff --git a/utils/tests/pub/install/hosted/stay_locked_test.dart b/utils/tests/pub/install/hosted/stay_locked_test.dart
index d765af5..6deaf5d 100644
--- a/utils/tests/pub/install/hosted/stay_locked_test.dart
+++ b/utils/tests/pub/install/hosted/stay_locked_test.dart
@@ -14,6 +14,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('keeps a pub server package locked to the version in the '
'lockfile', () {
servePackages([packageMap("foo", "1.0.0")]);
diff --git a/utils/tests/pub/install/hosted/unlock_if_incompatible_test.dart b/utils/tests/pub/install/hosted/unlock_if_incompatible_test.dart
index f1dd592..082a36c 100644
--- a/utils/tests/pub/install/hosted/unlock_if_incompatible_test.dart
+++ b/utils/tests/pub/install/hosted/unlock_if_incompatible_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('updates a locked pub server package with a new incompatible '
'constraint', () {
servePackages([packageMap("foo", "1.0.0")]);
diff --git a/utils/tests/pub/install/hosted/unlock_if_new_is_unsatisfied_test.dart b/utils/tests/pub/install/hosted/unlock_if_new_is_unsatisfied_test.dart
index 8da00dd..44ecb89 100644
--- a/utils/tests/pub/install/hosted/unlock_if_new_is_unsatisfied_test.dart
+++ b/utils/tests/pub/install/hosted/unlock_if_new_is_unsatisfied_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("unlocks dependencies if necessary to ensure that a new "
"dependency is satisfied", () {
servePackages([
diff --git a/utils/tests/pub/install/pub_install_test.dart b/utils/tests/pub/install/pub_install_test.dart
index 37bc1c1..ad2370b 100644
--- a/utils/tests/pub/install/pub_install_test.dart
+++ b/utils/tests/pub/install/pub_install_test.dart
@@ -15,7 +15,6 @@
main() {
initConfig();
-
group('requires', () {
integration('a pubspec', () {
d.dir(appPath, []).create();
diff --git a/utils/tests/pub/oauth2/with_a_malformed_credentials_authenticates_again_test.dart b/utils/tests/pub/oauth2/with_a_malformed_credentials_authenticates_again_test.dart
index d9d5389..3a0be34 100644
--- a/utils/tests/pub/oauth2/with_a_malformed_credentials_authenticates_again_test.dart
+++ b/utils/tests/pub/oauth2/with_a_malformed_credentials_authenticates_again_test.dart
@@ -15,6 +15,7 @@
import 'utils.dart';
main() {
+ initConfig();
integration('with a malformed credentials.json, authenticates again and '
'saves credentials.json', () {
d.validPackage.create();
diff --git a/utils/tests/pub/oauth2/with_a_pre_existing_credentials_does_not_authenticate_test.dart b/utils/tests/pub/oauth2/with_a_pre_existing_credentials_does_not_authenticate_test.dart
index 976903c..bcfe774 100644
--- a/utils/tests/pub/oauth2/with_a_pre_existing_credentials_does_not_authenticate_test.dart
+++ b/utils/tests/pub/oauth2/with_a_pre_existing_credentials_does_not_authenticate_test.dart
@@ -15,6 +15,7 @@
import 'utils.dart';
main() {
+ initConfig();
integration('with a pre-existing credentials.json does not authenticate', () {
d.validPackage.create();
diff --git a/utils/tests/pub/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart b/utils/tests/pub/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart
index 20cb0e5..6d900a1 100644
--- a/utils/tests/pub/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart
+++ b/utils/tests/pub/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart
@@ -15,6 +15,7 @@
import 'utils.dart';
main() {
+ initConfig();
// Regression test for issue 8849.
integration('with a server-rejected refresh token, authenticates again and '
'saves credentials.json', () {
diff --git a/utils/tests/pub/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart b/utils/tests/pub/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart
index 2526403..4f8a741 100644
--- a/utils/tests/pub/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart
+++ b/utils/tests/pub/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart
@@ -15,6 +15,7 @@
import 'utils.dart';
main() {
+ initConfig();
integration('with an expired credentials.json, refreshes and saves the '
'refreshed access token to credentials.json', () {
d.validPackage.create();
diff --git a/utils/tests/pub/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart b/utils/tests/pub/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart
index 3565951..7cfcc29 100644
--- a/utils/tests/pub/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart
+++ b/utils/tests/pub/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart
@@ -15,6 +15,7 @@
import 'utils.dart';
main() {
+ initConfig();
integration('with an expired credentials.json without a refresh token, '
'authenticates again and saves credentials.json', () {
d.validPackage.create();
diff --git a/utils/tests/pub/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart b/utils/tests/pub/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart
index ff771e6..e2d0c21 100644
--- a/utils/tests/pub/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart
+++ b/utils/tests/pub/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart
@@ -14,6 +14,7 @@
import 'utils.dart';
main() {
+ initConfig();
integration('with no credentials.json, authenticates and saves '
'credentials.json', () {
d.validPackage.create();
diff --git a/utils/tests/pub/oauth2/with_server_rejected_credentials_authenticates_again_test.dart b/utils/tests/pub/oauth2/with_server_rejected_credentials_authenticates_again_test.dart
index c607424..0dbc6e8 100644
--- a/utils/tests/pub/oauth2/with_server_rejected_credentials_authenticates_again_test.dart
+++ b/utils/tests/pub/oauth2/with_server_rejected_credentials_authenticates_again_test.dart
@@ -15,6 +15,7 @@
import 'utils.dart';
main() {
+ initConfig();
integration('with server-rejected credentials, authenticates again and saves '
'credentials.json', () {
d.validPackage.create();
diff --git a/utils/tests/pub/pub.status b/utils/tests/pub/pub.status
index f57559f..5d194b4 100644
--- a/utils/tests/pub/pub.status
+++ b/utils/tests/pub/pub.status
@@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
pub_uploader_test: Pass, Fail # Issue 9357
+oauth2/with_server_rejected_credentials_authenticates_again_test: Pass, Fail # Issue 9839.
# Pub only runs on the VM, so just rule out all compilers.
[ $compiler == dart2js || $compiler == dart2dart ]
diff --git a/utils/tests/pub/pub_uploader_test.dart b/utils/tests/pub/pub_uploader_test.dart
index 5413f1d..1085e02 100644
--- a/utils/tests/pub/pub_uploader_test.dart
+++ b/utils/tests/pub/pub_uploader_test.dart
@@ -35,6 +35,7 @@
}
main() {
+ initConfig();
group('displays usage', () {
integration('when run with no arguments', () {
schedulePub(args: ['uploader'],
diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
index f239de3d..3ba46a4 100644
--- a/utils/tests/pub/test_pub.dart
+++ b/utils/tests/pub/test_pub.dart
@@ -94,7 +94,7 @@
new ByteStream(stream).toBytes().then((data) {
response.statusCode = 200;
response.contentLength = data.length;
- response.writeBytes(data);
+ response.add(data);
response.close();
}).catchError((e) {
response.statusCode = 404;
@@ -232,6 +232,11 @@
currentSchedule.timeout = new Duration(seconds: 10);
}
+ // By default, don't capture stack traces since they slow the tests way
+ // down. To debug failing tests, comment this out.
+ currentSchedule.captureStackTraces =
+ new Options().arguments.contains('--trace');
+
// Ensure the SDK version is always available.
d.dir(sdkPath, [
d.file('version', '0.1.2.3')
diff --git a/utils/tests/pub/update/git/do_not_update_if_unneeded_test.dart b/utils/tests/pub/update/git/do_not_update_if_unneeded_test.dart
index 062e6b4..512b619 100644
--- a/utils/tests/pub/update/git/do_not_update_if_unneeded_test.dart
+++ b/utils/tests/pub/update/git/do_not_update_if_unneeded_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("doesn't update one locked Git package's dependencies if it's "
"not necessary", () {
ensureGit();
diff --git a/utils/tests/pub/update/git/update_locked_test.dart b/utils/tests/pub/update/git/update_locked_test.dart
index 300f531..3ed68c5 100644
--- a/utils/tests/pub/update/git/update_locked_test.dart
+++ b/utils/tests/pub/update/git/update_locked_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates locked Git packages", () {
ensureGit();
diff --git a/utils/tests/pub/update/git/update_one_locked_test.dart b/utils/tests/pub/update/git/update_one_locked_test.dart
index 21d239f..976553e 100644
--- a/utils/tests/pub/update/git/update_one_locked_test.dart
+++ b/utils/tests/pub/update/git/update_one_locked_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates one locked Git package but no others", () {
ensureGit();
diff --git a/utils/tests/pub/update/git/update_to_incompatible_pubspec_test.dart b/utils/tests/pub/update/git/update_to_incompatible_pubspec_test.dart
index 67d7ec2..09123f4 100644
--- a/utils/tests/pub/update/git/update_to_incompatible_pubspec_test.dart
+++ b/utils/tests/pub/update/git/update_to_incompatible_pubspec_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates Git packages to an incompatible pubspec", () {
ensureGit();
diff --git a/utils/tests/pub/update/git/update_to_nonexistent_pubspec_test.dart b/utils/tests/pub/update/git/update_to_nonexistent_pubspec_test.dart
index c4bf53d..9e2e995 100644
--- a/utils/tests/pub/update/git/update_to_nonexistent_pubspec_test.dart
+++ b/utils/tests/pub/update/git/update_to_nonexistent_pubspec_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates Git packages to a nonexistent pubspec", () {
ensureGit();
diff --git a/utils/tests/pub/update/hosted/fail_gracefully_on_missing_package_test.dart b/utils/tests/pub/update/hosted/fail_gracefully_on_missing_package_test.dart
index 8de4886..a2a47e4 100644
--- a/utils/tests/pub/update/hosted/fail_gracefully_on_missing_package_test.dart
+++ b/utils/tests/pub/update/hosted/fail_gracefully_on_missing_package_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('fails gracefully if the package does not exist', () {
servePackages([]);
diff --git a/utils/tests/pub/update/hosted/fail_gracefully_on_url_resolve_test.dart b/utils/tests/pub/update/hosted/fail_gracefully_on_url_resolve_test.dart
index fbf9043..db71d25 100644
--- a/utils/tests/pub/update/hosted/fail_gracefully_on_url_resolve_test.dart
+++ b/utils/tests/pub/update/hosted/fail_gracefully_on_url_resolve_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration('fails gracefully if the url does not resolve', () {
d.dir(appPath, [
d.pubspec({
diff --git a/utils/tests/pub/update/hosted/remove_removed_dependency_test.dart b/utils/tests/pub/update/hosted/remove_removed_dependency_test.dart
index 4841a97..2a916a2 100644
--- a/utils/tests/pub/update/hosted/remove_removed_dependency_test.dart
+++ b/utils/tests/pub/update/hosted/remove_removed_dependency_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("removes a dependency that's been removed from the pubspec", () {
servePackages([
packageMap("foo", "1.0.0"),
diff --git a/utils/tests/pub/update/hosted/remove_removed_transitive_dependency_test.dart b/utils/tests/pub/update/hosted/remove_removed_transitive_dependency_test.dart
index 4a4658c..2045050 100644
--- a/utils/tests/pub/update/hosted/remove_removed_transitive_dependency_test.dart
+++ b/utils/tests/pub/update/hosted/remove_removed_transitive_dependency_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("removes a transitive dependency that's no longer depended "
"on", () {
servePackages([
diff --git a/utils/tests/pub/update/hosted/unlock_dependers_test.dart b/utils/tests/pub/update/hosted/unlock_dependers_test.dart
index 2c3b728..f1b8e4d 100644
--- a/utils/tests/pub/update/hosted/unlock_dependers_test.dart
+++ b/utils/tests/pub/update/hosted/unlock_dependers_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates a locked package's dependers in order to get it to max "
"version", () {
servePackages([
diff --git a/utils/tests/pub/update/hosted/unlock_if_necessary_test.dart b/utils/tests/pub/update/hosted/unlock_if_necessary_test.dart
index ca7355b..3115942 100644
--- a/utils/tests/pub/update/hosted/unlock_if_necessary_test.dart
+++ b/utils/tests/pub/update/hosted/unlock_if_necessary_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates one locked pub server package's dependencies if it's "
"necessary", () {
servePackages([
diff --git a/utils/tests/pub/update/hosted/update_removed_constraints_test.dart b/utils/tests/pub/update/hosted/update_removed_constraints_test.dart
index 7bd3965..dc20323 100644
--- a/utils/tests/pub/update/hosted/update_removed_constraints_test.dart
+++ b/utils/tests/pub/update/hosted/update_removed_constraints_test.dart
@@ -10,6 +10,7 @@
import '../../test_pub.dart';
main() {
+ initConfig();
integration("updates dependencies whose constraints have been removed", () {
servePackages([
packageMap("foo", "1.0.0", [dependencyMap("shared-dep")]),
diff --git a/utils/tests/pub/validator/lib_test.dart b/utils/tests/pub/validator/lib_test.dart
index e5d21f6..6f9a38a 100644
--- a/utils/tests/pub/validator/lib_test.dart
+++ b/utils/tests/pub/validator/lib_test.dart
@@ -34,7 +34,7 @@
});
});
- integration('should consider a package invalid if it', () {
+ group('should consider a package invalid if it', () {
setUp(d.validPackage.create);
integration('has no lib directory', () {