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

Side by Side Diff: frog/leg/native_handler.dart

Issue 9633015: Map typeName getter to the global typeNameOf. This is a unspoken rule from the native interface :) (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
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('../../lib/uri/uri.dart'); 6 #import('../../lib/uri/uri.dart');
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Register NoSuchMethodException and captureStackTrace in the compiler 130 // Register NoSuchMethodException and captureStackTrace in the compiler
131 // because the dynamic dispatch for native classes may use them. 131 // because the dynamic dispatch for native classes may use them.
132 Compiler compiler = builder.compiler; 132 Compiler compiler = builder.compiler;
133 ClassElement cls = compiler.coreLibrary.find( 133 ClassElement cls = compiler.coreLibrary.find(
134 Compiler.NO_SUCH_METHOD_EXCEPTION); 134 Compiler.NO_SUCH_METHOD_EXCEPTION);
135 cls.resolve(compiler); 135 cls.resolve(compiler);
136 compiler.addToWorklist(cls.lookupConstructor(cls.name)); 136 compiler.addToWorklist(cls.lookupConstructor(cls.name));
137 compiler.registerStaticUse( 137 compiler.registerStaticUse(
138 compiler.findHelper(new SourceString('captureStackTrace'))); 138 compiler.findHelper(new SourceString('captureStackTrace')));
139 139
140 FunctionElement element = builder.work.element;
kasperl 2012/03/08 13:22:00 Please add a comment here explaining what this doe
ngeoffray 2012/03/08 13:34:07 Done.
141 NativeEmitter nativeEmitter = compiler.emitter.nativeEmitter;
142 if (element.name == const SourceString('typeName')
143 && element.isGetter()
144 && nativeEmitter.toNativeName(element.enclosingElement) == 'DOMType') {
145 DartString jsCode = new DartString.literal(
146 '${nativeEmitter.typeNameOfName}(\$0)');
147 List<HInstruction> inputs =
148 <HInstruction>[builder.localsHandler.readThis()];
149 builder.push(new HForeign(
150 jsCode, const LiteralDartString('String'), inputs));
151 return;
152 }
153
140 if (node.arguments.isEmpty()) { 154 if (node.arguments.isEmpty()) {
141 List<String> arguments = <String>[]; 155 List<String> arguments = <String>[];
142 List<HInstruction> inputs = <HInstruction>[]; 156 List<HInstruction> inputs = <HInstruction>[];
143 FunctionElement element = builder.work.element;
144 FunctionParameters parameters = element.computeParameters(builder.compiler); 157 FunctionParameters parameters = element.computeParameters(builder.compiler);
145 int i = 0; 158 int i = 0;
146 String receiver = ''; 159 String receiver = '';
147 if (element.isInstanceMember()) { 160 if (element.isInstanceMember()) {
148 receiver = '\$$i.'; 161 receiver = '\$$i.';
149 i++; 162 i++;
150 inputs.add(builder.localsHandler.readThis()); 163 inputs.add(builder.localsHandler.readThis());
151 } 164 }
152 Compiler compiler = builder.compiler; 165 Compiler compiler = builder.compiler;
153 parameters.forEachParameter((Element parameter) { 166 parameters.forEachParameter((Element parameter) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 268
256 } else if (!node.arguments.tail.isEmpty()) { 269 } else if (!node.arguments.tail.isEmpty()) {
257 builder.compiler.cancel('More than one argument to native'); 270 builder.compiler.cancel('More than one argument to native');
258 } else { 271 } else {
259 LiteralString jsCode = node.arguments.head; 272 LiteralString jsCode = node.arguments.head;
260 builder.push(new HForeign(jsCode.dartString, 273 builder.push(new HForeign(jsCode.dartString,
261 const LiteralDartString('Object'), 274 const LiteralDartString('Object'),
262 <HInstruction>[])); 275 <HInstruction>[]));
263 } 276 }
264 } 277 }
OLDNEW
« client/tests/client/client-leg.status ('K') | « frog/leg/elements/elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698