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

Side by Side Diff: tool/input_sdk/private/ddc_runtime/classes.dart

Issue 1803033002: Fixes #479 (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/_runtime.js ('k') | tool/input_sdk/private/ddc_runtime/types.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// This library defines the operations that define and manipulate Dart 5 /// This library defines the operations that define and manipulate Dart
6 /// classes. Included in this are: 6 /// classes. Included in this are:
7 /// - Generics 7 /// - Generics
8 /// - Class metadata 8 /// - Class metadata
9 /// - Extension methods 9 /// - Extension methods
10 /// 10 ///
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 getGenericClass(type) => 115 getGenericClass(type) =>
116 JS('', '$safeGetOwnProperty($type, $_originalDeclaration)'); 116 JS('', '$safeGetOwnProperty($type, $_originalDeclaration)');
117 117
118 getGenericArgs(type) => 118 getGenericArgs(type) =>
119 JS('', '$safeGetOwnProperty($type, $_typeArguments)'); 119 JS('', '$safeGetOwnProperty($type, $_typeArguments)');
120 120
121 final _constructorSig = JS('', 'Symbol("sigCtor")'); 121 final _constructorSig = JS('', 'Symbol("sigCtor")');
122 final _methodSig = JS('', 'Symbol("sig")'); 122 final _methodSig = JS('', 'Symbol("sig")');
123 final _staticSig = JS('', 'Symbol("sigStatic")'); 123 final _staticSig = JS('', 'Symbol("sigStatic")');
124 124
125 /// Get the type of a method using the stored signature 125 /// Get the type of a method from an object using the stored signature
126 getMethodType(obj, name) => JS('', '''(() => { 126 getMethodType(obj, name) => JS('', '''(() => {
127 if ($obj === void 0) return void 0; 127 if ($obj === void 0) return void 0;
128 if ($obj == null) return void 0; 128 if ($obj == null) return void 0;
129 let sigObj = $obj.__proto__.constructor[$_methodSig]; 129 return $getMethodTypeFromType($obj.__proto__.constructor, $name);
130 })()''');
131
132 /// Get the type of a method from a type using the stored signature
133 getMethodTypeFromType(type, name) => JS('', '''(() => {
134 let sigObj = $type[$_methodSig];
130 if (sigObj === void 0) return void 0; 135 if (sigObj === void 0) return void 0;
131 let parts = sigObj[$name]; 136 let parts = sigObj[$name];
132 if (parts === void 0) return void 0; 137 if (parts === void 0) return void 0;
133 return $definiteFunctionType.apply(null, parts); 138 return $definiteFunctionType.apply(null, parts);
134 })()'''); 139 })()''');
135 140
136 /// Get the type of a constructor from a class using the stored signature 141 /// Get the type of a constructor from a class using the stored signature
137 /// If name is undefined, returns the type of the default constructor 142 /// If name is undefined, returns the type of the default constructor
138 /// Returns undefined if the constructor is not found. 143 /// Returns undefined if the constructor is not found.
139 classGetConstructorType(cls, name) => JS('', '''(() => { 144 classGetConstructorType(cls, name) => JS('', '''(() => {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 })()'''); 372 })()''');
368 373
369 /// Sets the element type of a list literal. 374 /// Sets the element type of a list literal.
370 list(obj, elementType) => 375 list(obj, elementType) =>
371 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))'); 376 JS('', '$setType($obj, ${getGenericClass(JSArray)}($elementType))');
372 377
373 setBaseClass(derived, base) => JS('', '''(() => { 378 setBaseClass(derived, base) => JS('', '''(() => {
374 // Link the extension to the type it's extending as a base class. 379 // Link the extension to the type it's extending as a base class.
375 $derived.prototype.__proto__ = $base.prototype; 380 $derived.prototype.__proto__ = $base.prototype;
376 })()'''); 381 })()''');
OLDNEW
« no previous file with comments | « lib/runtime/dart/_runtime.js ('k') | tool/input_sdk/private/ddc_runtime/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698