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

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

Issue 9284022: Operators. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | « no previous file | frog/leg/emitter.dart » ('j') | frog/leg/lib/core.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 369
370 Element lookupConstructor(SourceString className, 370 Element lookupConstructor(SourceString className,
371 [SourceString constructorName = 371 [SourceString constructorName =
372 const SourceString(''), 372 const SourceString(''),
373 Element noMatch(Element)]) { 373 Element noMatch(Element)]) {
374 // TODO(karlklose): have a map from class names to a map of constructors 374 // TODO(karlklose): have a map from class names to a map of constructors
375 // instead of creating the name here? 375 // instead of creating the name here?
376 SourceString name; 376 SourceString name;
377 if (constructorName !== const SourceString('')) { 377 if (constructorName !== const SourceString('')) {
378 name = new SourceString('$className.$constructorName'); 378 name = Elements.constructConstructorName(className, constructorName);
379 } else { 379 } else {
380 name = className; 380 name = className;
381 } 381 }
382 Element result = constructors[name]; 382 Element result = constructors[name];
383 if (result === null && noMatch !== null) { 383 if (result === null && noMatch !== null) {
384 result = noMatch(lookupLocalMember(constructorName)); 384 result = noMatch(lookupLocalMember(constructorName));
385 } 385 }
386 return result; 386 return result;
387 } 387 }
388 388
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 static bool isClosureSend(Send send, TreeElements elements) { 428 static bool isClosureSend(Send send, TreeElements elements) {
429 if (send.isPropertyAccess) return false; 429 if (send.isPropertyAccess) return false;
430 if (send.receiver !== null) return false; 430 if (send.receiver !== null) return false;
431 Element element = elements[send]; 431 Element element = elements[send];
432 // (o)() or foo()(). 432 // (o)() or foo()().
433 if (element === null && send.selector.asIdentifier() === null) return true; 433 if (element === null && send.selector.asIdentifier() === null) return true;
434 if (element === null) return false; 434 if (element === null) return false;
435 // foo() with foo a local or a parameter. 435 // foo() with foo a local or a parameter.
436 return element.isVariable() || element.isParameter(); 436 return element.isVariable() || element.isParameter();
437 } 437 }
438
439 static SourceString constructConstructorName(SourceString receiver,
440 SourceString selector) {
441 return new SourceString('$receiver\$$selector');
442 }
443
444 static SourceString constructOperatorName(SourceString receiver,
445 SourceString selector,
446 [bool isPrefix = false]) {
447 String str = selector.stringValue;
448 if (str === '==' || str === '!=') return Namer.OPERATOR_EQUALS;
449
450 if (str === '~') str = 'not';
451 else if (str === 'negate' || (str === '-' && isPrefix)) str = 'negate';
452 else if (str === '[]') str = 'index';
453 else if (str === '[]=') str = 'indexSet';
454 else if (str === '*' || str === '*=') str = 'mul';
455 else if (str === '/' || str === '/=') str = 'div';
456 else if (str === '%' || str === '%=') str = 'mod';
457 else if (str === '~/' || str === '~/=') str = 'tdiv';
458 else if (str === '+' || str === '+=') str = 'add';
459 else if (str === '-' || str === '-=') str = 'sub';
460 else if (str === '<<' || str === '<<=') str = 'shl';
461 else if (str === '>>' || str === '>>=') str = 'shr';
462 else if (str === '>=') str = 'ge';
463 else if (str === '>') str = 'gt';
464 else if (str === '<=') str = 'le';
465 else if (str === '<') str = 'lt';
466 else if (str === '&' || str === '&=') str = 'and';
467 else if (str === '^' || str === '^=') str = 'xor';
468 else if (str === '|' || str === '|=') str = 'or';
469 return new SourceString('$receiver\$$str');
470 }
438 } 471 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/emitter.dart » ('j') | frog/leg/lib/core.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698