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

Unified Diff: lib/compiler/implementation/lib/patch/coreimpl.dart

Issue 10837219: Port the remaining of dart:coreimpl to the unified corelib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/lib/patch/coreimpl.dart
diff --git a/lib/compiler/implementation/lib/patch/coreimpl.dart b/lib/compiler/implementation/lib/patch/coreimpl.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8cf9e7afe0343861b67ced8baa47b3a64a2f01cf
--- /dev/null
+++ b/lib/compiler/implementation/lib/patch/coreimpl.dart
@@ -0,0 +1,122 @@
+// 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 file for dart:core.
Lasse Reichstein Nielsen 2012/08/13 12:58:22 dart:coreimpl
Anders Johnsen 2012/08/13 13:51:37 Done.
+
+patch class DateImplementation {
+ patch DateImplementation(int years,
+ [int month = 1,
+ int day = 1,
+ int hour = 0,
+ int minute = 0,
+ int second = 0,
+ int millisecond = 0,
+ bool isUtc = false])
+ : this.isUtc = checkNull(isUtc),
+ millisecondsSinceEpoch = Primitives.valueFromDecomposedDate(
+ years, month, day, hour, minute, second, millisecond, isUtc) {
+ Primitives.lazyAsJsDate(this);
+ }
+
+ patch DateImplementation.now()
+ : isUtc = false,
+ millisecondsSinceEpoch = Primitives.dateNow() {
+ Primitives.lazyAsJsDate(this);
+ }
+
+ patch String get timeZoneName() {
+ if (isUtc) return "UTC";
+ return Primitives.getTimeZoneName(this);
+ }
+
+ patch Duration get timeZoneOffset() {
+ if (isUtc) return new Duration(0);
+ return new Duration(minutes: Primitives.getTimeZoneOffsetInMinutes(this));
+ }
+
+ patch int get year() => Primitives.getYear(this);
+
+ patch int get month() => Primitives.getMonth(this);
+
+ patch int get day() => Primitives.getDay(this);
+
+ patch int get hour() => Primitives.getHours(this);
+
+ patch int get minute() => Primitives.getMinutes(this);
+
+ patch int get second() => Primitives.getSeconds(this);
+
+ patch int get millisecond() => Primitives.getMilliseconds(this);
+
+ patch int get weekday() => Primitives.getWeekday(this);
+}
+
+patch class RuntimeOptions {
+ patch List<String> get arguments() {
+ if (_arguments === null) {
+ // On first access make a copy of the native arguments.
+ _arguments = _nativeArguments.getRange(0, _nativeArguments.length);
+ }
+ return _arguments;
+ }
+
+ patch String get executable() {
+ return _nativeExecutable;
+ }
+
+ patch String get script() {
+ return _nativeScript;
+ }
+
+ List<String> _arguments = null;
+
+ // This arguments singleton is written to by the embedder if applicable.
+ static List<String> _nativeArguments = const [];
+
+ // This executable singleton is written to by the embedder if applicable.
+ static String _nativeExecutable = '';
+
+ // This script singleton is written to by the embedder if applicable.
+ static String _nativeScript = '';
+}
+
+patch class _Clock {
+ patch static int now() => Primitives.dateNow();
+
+ patch static int frequency() => 1000;
+}
+
+patch class ExpandoImplementation<T> {
+ patch T operator[](Object object) {
+ var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
+ return (values === null) ? null : Primitives.getProperty(values, _getKey());
+ }
+
+ patch operator[]=(Object object, T value) {
+ var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
+ if (values === null) {
+ values = new Object();
+ Primitives.setProperty(object, _EXPANDO_PROPERTY_NAME, values);
+ }
+ Primitives.setProperty(values, _getKey(), value);
+ }
+
+ patch String toString() {
+ String key = _getKey();
+ return (name === null) ? "Expando:${key}" : "Expando:${name}@${key}";
+ }
+
+ String _getKey() {
+ String key = Primitives.getProperty(this, _KEY_PROPERTY_NAME);
+ if (key === null) {
+ key = "expando\$key\$${_keyCount++}";
+ Primitives.setProperty(this, _KEY_PROPERTY_NAME, key);
+ }
+ return key;
+ }
+
+ static final String _KEY_PROPERTY_NAME = 'expando\$key';
+ static final String _EXPANDO_PROPERTY_NAME = 'expando\$values';
+ static int _keyCount = 0;
+}

Powered by Google App Engine
This is Rietveld 408576698