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

Side by Side Diff: frog/leg/lib/native_helper.dart

Issue 9773026: Add a method on native classes for is checks. Reduces the code for generating is checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/native_emitter.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 String typeNameInChrome(obj) { 5 String typeNameInChrome(obj) {
6 String name = JS('String', "#.constructor.name", obj); 6 String name = JS('String', "#.constructor.name", obj);
7 if (name == 'Window') return 'DOMWindow'; 7 if (name == 'Window') return 'DOMWindow';
8 return name; 8 return name;
9 } 9 }
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 String tag = inputTable[i][0]; 250 String tag = inputTable[i][0];
251 String tags = inputTable[i][1]; 251 String tags = inputTable[i][1];
252 Set<String> set = new Set<String>(); 252 Set<String> set = new Set<String>();
253 List<String> tagNames = tags.split('|'); 253 List<String> tagNames = tags.split('|');
254 for (int j = 0; j < tagNames.length; j++) { 254 for (int j = 0; j < tagNames.length; j++) {
255 set.add(tagNames[j]); 255 set.add(tagNames[j]);
256 } 256 }
257 _dynamicMetadata.add(new MetaInfo(tag, tags, set)); 257 _dynamicMetadata.add(new MetaInfo(tag, tags, set));
258 } 258 }
259 } 259 }
260
261 // Initialized by the compiler.
262 var isChecksHelper;
263
264 // This method will be called for 'is' checks on native types.
265 // It takes the object on which the 'is' check is being done, and the
266 // property name for the type check. The method patches the real
267 // prototype of the object with the value from the Dart object
268 // (see [generateNativeClass]).
269 bool dynamicIsCheck(obj, String typeName) {
270 if (isJsArray(obj)) return false;
271 // Check if the Dart object corresponding to this class has the property.
272 var res = JS('bool', '!!#[#][#]', isChecksHelper, getTypeNameOf(obj),
273 typeName);
274 var proto = JS('var', 'Object.getPrototypeOf(#)', obj);
275 defineProperty(proto, typeName, res);
276 return res;
277 }
OLDNEW
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/native_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698