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

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

Issue 9592009: Reapply "Refactor constant part." (r4958) with fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add TODO. 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/ssa/builder.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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 builder.add(instruction); 207 builder.add(instruction);
208 List<HInstruction> elseInputs = new List<HInstruction>.from(inputs); 208 List<HInstruction> elseInputs = new List<HInstruction>.from(inputs);
209 elseInputs.add(instruction); 209 elseInputs.add(instruction);
210 String params = arguments.isEmpty() ? '' : ', $foreignParameters'; 210 String params = arguments.isEmpty() ? '' : ', $foreignParameters';
211 jsCode = new SourceString('\$${i}.call(\$0$params)'); 211 jsCode = new SourceString('\$${i}.call(\$0$params)');
212 elseInstruction = 212 elseInstruction =
213 new HForeign(jsCode, const SourceString('Object'), elseInputs); 213 new HForeign(jsCode, const SourceString('Object'), elseInputs);
214 builder.add(elseInstruction); 214 builder.add(elseInstruction);
215 } 215 }
216 216
217 HLiteral literal = builder.graph.addNewLiteralString( 217 HLiteral literal = builder.graph.addConstantString(
218 new DartString.literal('$dartMethodName')); 218 new DartString.literal('$dartMethodName'));
219 SourceString jsCode = new SourceString( 219 SourceString jsCode = new SourceString(
220 'Object.getPrototypeOf(\$0).hasOwnProperty(\$1)'); 220 'Object.getPrototypeOf(\$0).hasOwnProperty(\$1)');
221 builder.push(new HForeign( 221 builder.push(new HForeign(
222 jsCode, const SourceString('Object'), 222 jsCode, const SourceString('Object'),
223 <HInstruction>[builder.localsHandler.readThis(), literal])); 223 <HInstruction>[builder.localsHandler.readThis(), literal]));
224 224
225 builder.handleIf(visitThen, visitElse); 225 builder.handleIf(visitThen, visitElse);
226 226
227 HPhi phi = new HPhi.manyInputs( 227 HPhi phi = new HPhi.manyInputs(
228 null, <HInstruction>[thenInstruction, elseInstruction]); 228 null, <HInstruction>[thenInstruction, elseInstruction]);
229 builder.current.addPhi(phi); 229 builder.current.addPhi(phi);
230 builder.stack.add(phi); 230 builder.stack.add(phi);
231 } 231 }
232 232
233 } else if (!node.arguments.tail.isEmpty()) { 233 } else if (!node.arguments.tail.isEmpty()) {
234 builder.compiler.cancel('More than one argument to native'); 234 builder.compiler.cancel('More than one argument to native');
235 } else { 235 } else {
236 LiteralString jsCode = node.arguments.head; 236 LiteralString jsCode = node.arguments.head;
237 int start = jsCode.value.slowToString()[0] === '@' ? 1 : 0; 237 int start = jsCode.value.slowToString()[0] === '@' ? 1 : 0;
238 builder.push(new HForeign(builder.unquote(jsCode, start), 238 builder.push(new HForeign(builder.unquote(jsCode, start),
239 const SourceString('Object'), 239 const SourceString('Object'),
240 <HInstruction>[])); 240 <HInstruction>[]));
241 } 241 }
242 } 242 }
OLDNEW
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698