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

Side by Side Diff: lib/compiler/implementation/native_handler.dart

Issue 10834243: Reduce usage of .enclosingElement to get enclosing class. (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 unified diff | Download patch | Annotate | Revision Log
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 #library('native'); 5 #library('native');
6 #import('dart:uri'); 6 #import('dart:uri');
7 #import('leg.dart'); 7 #import('leg.dart');
8 #import('elements/elements.dart'); 8 #import('elements/elements.dart');
9 #import('scanner/scannerlib.dart'); 9 #import('scanner/scannerlib.dart');
10 #import('ssa/ssa.dart'); 10 #import('ssa/ssa.dart');
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 FunctionElement element = builder.work.element; 181 FunctionElement element = builder.work.element;
182 element.setNative(); 182 element.setNative();
183 NativeEmitter nativeEmitter = builder.emitter.nativeEmitter; 183 NativeEmitter nativeEmitter = builder.emitter.nativeEmitter;
184 // If what we're compiling is a getter named 'typeName' and the native 184 // If what we're compiling is a getter named 'typeName' and the native
185 // class is named 'DOMType', we generate a call to the typeNameOf 185 // class is named 'DOMType', we generate a call to the typeNameOf
186 // function attached on the isolate. 186 // function attached on the isolate.
187 // The DOM classes assume that their 'typeName' property, which is 187 // The DOM classes assume that their 'typeName' property, which is
188 // not a JS property on the DOM types, returns the type name. 188 // not a JS property on the DOM types, returns the type name.
189 if (element.name == const SourceString('typeName') 189 if (element.name == const SourceString('typeName')
190 && element.isGetter() 190 && element.isGetter()
191 && nativeEmitter.toNativeName(element.enclosingElement) == 'DOMType') { 191 && nativeEmitter.toNativeName(element.getEnclosingClass()) == 'DOMType') {
192 Element methodElement = 192 Element methodElement =
193 compiler.findHelper(const SourceString('getTypeNameOf')); 193 compiler.findHelper(const SourceString('getTypeNameOf'));
194 HStatic method = new HStatic(methodElement); 194 HStatic method = new HStatic(methodElement);
195 builder.add(method); 195 builder.add(method);
196 builder.push(new HInvokeStatic(Selector.INVOCATION_1, 196 builder.push(new HInvokeStatic(Selector.INVOCATION_1,
197 <HInstruction>[method, builder.localsHandler.readThis()])); 197 <HInstruction>[method, builder.localsHandler.readThis()]));
198 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit); 198 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit);
199 } 199 }
200 200
201 HInstruction convertDartClosure(Element parameter, FunctionType type) { 201 HInstruction convertDartClosure(Element parameter, FunctionType type) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 String parameters) { 329 String parameters) {
330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
331 buffer.add("('$methodName')) {\n"); 331 buffer.add("('$methodName')) {\n");
332 buffer.add(" $code"); 332 buffer.add(" $code");
333 buffer.add(" } else {\n"); 333 buffer.add(" } else {\n");
334 buffer.add(" return Object.prototype.$methodName.call(this"); 334 buffer.add(" return Object.prototype.$methodName.call(this");
335 buffer.add(parameters == '' ? '' : ', $parameters'); 335 buffer.add(parameters == '' ? '' : ', $parameters');
336 buffer.add(");\n"); 336 buffer.add(");\n");
337 buffer.add(" }\n"); 337 buffer.add(" }\n");
338 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698