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

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

Issue 9583006: Support the literal kind for native classes (ie Console). (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/native_emitter.dart ('k') | frog/tests/native/src/NativeLiteralClassFrogTest.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 #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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 HInstruction thenInstruction; 156 HInstruction thenInstruction;
157 void visitThen() { 157 void visitThen() {
158 SourceString jsCode = new SourceString(nativeMethodCall); 158 SourceString jsCode = new SourceString(nativeMethodCall);
159 thenInstruction = 159 thenInstruction =
160 new HForeign(jsCode, const SourceString('Object'), inputs); 160 new HForeign(jsCode, const SourceString('Object'), inputs);
161 builder.add(thenInstruction); 161 builder.add(thenInstruction);
162 } 162 }
163 163
164 if (!element.isInstanceMember()) { 164 bool isNativeLiteral = false;
165 // If the method is a non-instance method, we just generate a direct 165 if (element.enclosingElement.kind == ElementKind.CLASS) {
166 ClassElement classElement = element.enclosingElement;
167 String nativeName = classElement.nativeName.slowToString();
168 isNativeLiteral =
169 builder.compiler.emitter.nativeEmitter.isNativeLiteral(nativeName);
170 }
171 if (!element.isInstanceMember() || isNativeLiteral) {
172 // If the method is a non-instance method, or is a member of a native
173 // class that represents a literal, we just generate a direct
166 // call to the native method. 174 // call to the native method.
167 visitThen(); 175 visitThen();
168 builder.stack.add(thenInstruction); 176 builder.stack.add(thenInstruction);
169 } else { 177 } else {
170 // If the method is an instance method, we generate the following code: 178 // If the method is an instance method, we generate the following code:
171 // function(params) { 179 // function(params) {
172 // return Object.getPrototypeOf(this).hasOwnProperty(dartMethodName)) 180 // return Object.getPrototypeOf(this).hasOwnProperty(dartMethodName))
173 // ? this.methodName(params) 181 // ? this.methodName(params)
174 // : Object.prototype.methodName.call(this, params); 182 // : Object.prototype.methodName.call(this, params);
175 // } 183 // }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } else if (!node.arguments.tail.isEmpty()) { 223 } else if (!node.arguments.tail.isEmpty()) {
216 builder.compiler.cancel('More than one argument to native'); 224 builder.compiler.cancel('More than one argument to native');
217 } else { 225 } else {
218 LiteralString jsCode = node.arguments.head; 226 LiteralString jsCode = node.arguments.head;
219 int start = jsCode.value.slowToString()[0] === '@' ? 1 : 0; 227 int start = jsCode.value.slowToString()[0] === '@' ? 1 : 0;
220 builder.push(new HForeign(builder.unquote(jsCode, start), 228 builder.push(new HForeign(builder.unquote(jsCode, start),
221 const SourceString('Object'), 229 const SourceString('Object'),
222 <HInstruction>[])); 230 <HInstruction>[]));
223 } 231 }
224 } 232 }
OLDNEW
« no previous file with comments | « frog/leg/native_emitter.dart ('k') | frog/tests/native/src/NativeLiteralClassFrogTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698