03c8767f73
There is no actual implementation here yet (that's your job :) ), but there is:
- An external method in dart:_internal, extractTypeArguments().
- Empty patch methods for that for the VM, dart2js, and DDC. These need to have implementations
filled in.
- A "dart_internal" package to expose a subset of the API. It gives you:
extractListTypeArgument()
extractMapTypeArguments()
We'll bring this into Google, but not publish it externally unless we find we really need to.
- A test for the behavior. It probably has bugs since I can't run it.
See: https://github.com/dart-lang/sdk/issues/31371
Change-Id: I7d9f9a3a36f8e8be106440375c80d584898c83cb
Reviewed-on: https://dart-review.googlesource.com/26467
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
Dart
// 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:_js_primitives' show printString;
|
|
import 'dart:_js_helper' show patch;
|
|
import 'dart:_interceptors' show JSArray;
|
|
import 'dart:_foreign_helper' show JS;
|
|
import 'dart:_runtime' as dart;
|
|
|
|
@patch
|
|
class Symbol implements core.Symbol {
|
|
@patch
|
|
const Symbol(String name) : this._name = name;
|
|
|
|
@patch
|
|
int get hashCode {
|
|
int hash = JS('int|Null', '#._hashCode', this);
|
|
if (hash != null) return hash;
|
|
const arbitraryPrime = 664597;
|
|
hash = 0x1fffffff & (arbitraryPrime * _name.hashCode);
|
|
JS('', '#._hashCode = #', this, hash);
|
|
return hash;
|
|
}
|
|
|
|
@patch
|
|
toString() => 'Symbol("$_name")';
|
|
|
|
@patch
|
|
static String computeUnmangledName(Symbol symbol) => symbol._name;
|
|
}
|
|
|
|
@patch
|
|
void printToConsole(String line) {
|
|
printString('$line');
|
|
}
|
|
|
|
@patch
|
|
List/*<E>*/ makeListFixedLength/*<E>*/(List/*<E>*/ growableList) {
|
|
JSArray.markFixedList(growableList);
|
|
return growableList;
|
|
}
|
|
|
|
@patch
|
|
List/*<E>*/ makeFixedListUnmodifiable/*<E>*/(List/*<E>*/ fixedLengthList) {
|
|
JSArray.markUnmodifiableList(fixedLengthList);
|
|
return fixedLengthList;
|
|
}
|
|
|
|
@patch
|
|
Object extractTypeArguments<T>(T instance, Function extract) =>
|
|
dart.extractTypeArguments<T>(instance, extract);
|