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

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

Issue 1930323004: instantiate generic tear-offs, fixes #525 (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: format Created 4 years, 7 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
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 runtime operations on objects used by the code 5 /// This library defines runtime operations on objects used by the code
6 /// generator. 6 /// generator.
7 part of dart._runtime; 7 part of dart._runtime;
8 8
9 _canonicalFieldName(obj, name, args, displayName) => JS('', '''(() => { 9 _canonicalFieldName(obj, name, args, displayName) => JS('', '''(() => {
10 $name = $canonicalMember($obj, $name); 10 $name = $canonicalMember($obj, $name);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 $f = $f.call; 97 $f = $f.call;
98 } 98 }
99 if (!($f instanceof Function)) { 99 if (!($f instanceof Function)) {
100 $throwNoSuchMethodFunc($obj, $name, $args, originalFunction); 100 $throwNoSuchMethodFunc($obj, $name, $args, originalFunction);
101 } 101 }
102 } 102 }
103 // If f is a function, but not a method (no method type) 103 // If f is a function, but not a method (no method type)
104 // then it should have been a function valued field, so 104 // then it should have been a function valued field, so
105 // get the type from the function. 105 // get the type from the function.
106 if ($ftype === void 0) { 106 if ($ftype === void 0) {
107 $ftype = $read($f); 107 $ftype = $_getRuntimeType($f);
108 } 108 }
109 109
110 if (!$ftype) { 110 if (!$ftype) {
111 // TODO(leafp): Allow JS objects to go through? 111 // TODO(leafp): Allow JS objects to go through?
112 if ($typeArgs != null) { 112 if ($typeArgs != null) {
113 // TODO(jmesserly): is there a sensible way to handle these? 113 // TODO(jmesserly): is there a sensible way to handle these?
114 $throwStrongModeError('call to JS object `' + $obj + 114 $throwStrongModeError('call to JS object `' + $obj +
115 '` with type arguments <' + $typeArgs + '> is not supported.'); 115 '` with type arguments <' + $typeArgs + '> is not supported.');
116 } 116 }
117 return $f.apply($obj, $args); 117 return $f.apply($obj, $args);
(...skipping 25 matching lines...) Expand all
143 } 143 }
144 return $f.apply($obj, $args); 144 return $f.apply($obj, $args);
145 } 145 }
146 146
147 // TODO(leafp): throw a type error (rather than NSM) 147 // TODO(leafp): throw a type error (rather than NSM)
148 // if the arity matches but the types are wrong. 148 // if the arity matches but the types are wrong.
149 // TODO(jmesserly): nSM should include type args? 149 // TODO(jmesserly): nSM should include type args?
150 $throwNoSuchMethodFunc($obj, $name, $args, originalFunction); 150 $throwNoSuchMethodFunc($obj, $name, $args, originalFunction);
151 })()'''); 151 })()''');
152 152
153 dcall(f, @rest args) => 153 dcall(f, @rest args) => _checkAndCall(
154 _checkAndCall(f, read(f), JS('', 'void 0'), null, args, 'call'); 154 f, _getRuntimeType(f), JS('', 'void 0'), null, args, 'call');
155 155
156 156
157 dgcall(f, typeArgs, @rest args) => 157 dgcall(f, typeArgs, @rest args) => _checkAndCall(
158 _checkAndCall(f, read(f), JS('', 'void 0'), typeArgs, args, 'call'); 158 f, _getRuntimeType(f), JS('', 'void 0'), typeArgs, args, 'call');
159 159
160 160
161 /// Shared code for dsend, dindex, and dsetindex. 161 /// Shared code for dsend, dindex, and dsetindex.
162 _callMethod(obj, name, typeArgs, args, displayName) { 162 _callMethod(obj, name, typeArgs, args, displayName) {
163 var symbol = _canonicalFieldName(obj, name, args, displayName); 163 var symbol = _canonicalFieldName(obj, name, args, displayName);
164 var f = obj != null ? JS('', '#[#]', obj, symbol) : null; 164 var f = obj != null ? JS('', '#[#]', obj, symbol) : null;
165 var ftype = getMethodType(obj, symbol); 165 var ftype = getMethodType(obj, symbol);
166 return _checkAndCall(f, ftype, obj, typeArgs, args, displayName); 166 return _checkAndCall(f, ftype, obj, typeArgs, args, displayName);
167 } 167 }
168 168
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 constructor(dartIterator) { 455 constructor(dartIterator) {
456 this.dartIterator = dartIterator; 456 this.dartIterator = dartIterator;
457 } 457 }
458 next() { 458 next() {
459 let i = this.dartIterator; 459 let i = this.dartIterator;
460 let done = !i.moveNext(); 460 let done = !i.moveNext();
461 return { done: done, value: done ? void 0 : i.current }; 461 return { done: done, value: done ? void 0 : i.current };
462 } 462 }
463 } 463 }
464 '''); 464 ''');
OLDNEW
« no previous file with comments | « tool/input_sdk/private/ddc_runtime/classes.dart ('k') | tool/input_sdk/private/ddc_runtime/rtti.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698