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

Side by Side Diff: frog/minfrog

Issue 8947008: When += (and similar operations) are converted to = + , (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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/gen.dart ('k') | tests/language/src/AssignOpTest.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 #!/usr/bin/env node 1 #!/usr/bin/env node
2 // ********** Library dart:core ************** 2 // ********** Library dart:core **************
3 // ********** Natives dart:core ************** 3 // ********** Natives dart:core **************
4 /** 4 /**
5 * Generates a dynamic call stub for a function. 5 * Generates a dynamic call stub for a function.
6 * Our goal is to create a stub method like this on-the-fly: 6 * Our goal is to create a stub method like this on-the-fly:
7 * function($0, $1, capture) { return this($0, $1, true, capture); } 7 * function($0, $1, capture) { return this($0, $1, true, capture); }
8 * 8 *
9 * This stub then replaces the dynamic one on Function, with one that is 9 * This stub then replaces the dynamic one on Function, with one that is
10 * specialized for that particular function, taking into account its default 10 * specialized for that particular function, taking into account its default
(...skipping 3503 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 else { 3514 else {
3515 target = node.target.visit(this); 3515 target = node.target.visit(this);
3516 } 3516 }
3517 return target.invoke$4(this, name, position, this._makeArgs(node.arguments)); 3517 return target.invoke$4(this, name, position, this._makeArgs(node.arguments));
3518 } 3518 }
3519 MethodGenerator.prototype.visitIndexExpression = function(node) { 3519 MethodGenerator.prototype.visitIndexExpression = function(node) {
3520 var target = this.visitValue(node.target); 3520 var target = this.visitValue(node.target);
3521 var index = this.visitValue(node.index); 3521 var index = this.visitValue(node.index);
3522 return target.invoke$4(this, ':index', node, new Arguments(null, [index])); 3522 return target.invoke$4(this, ':index', node, new Arguments(null, [index]));
3523 } 3523 }
3524 MethodGenerator.prototype._expressionNeedsParens = function(e) {
3525 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression ) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e));
3526 }
3524 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) { 3527 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) {
3525 var kind = node.op.kind; 3528 var kind = node.op.kind;
3526 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) { 3529 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) {
3527 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool); 3530 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool);
3528 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool); 3531 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool);
3529 var code = ('' + x.get$code() + ' ' + node.op + ' ' + y.get$code()); 3532 var code = ('' + x.get$code() + ' ' + node.op + ' ' + y.get$code());
3530 if (x.get$isConst() && y.get$isConst()) { 3533 if (x.get$isConst() && y.get$isConst()) {
3531 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue(); 3534 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue();
3532 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ('' + value), node.span); 3535 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ('' + value), node.span);
3533 } 3536 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3567 var name = TokenKind.binaryMethodName(node.op.kind); 3570 var name = TokenKind.binaryMethodName(node.op.kind);
3568 if (node.op.kind == 49/*TokenKind.NE*/) { 3571 if (node.op.kind == 49/*TokenKind.NE*/) {
3569 name = ':ne'; 3572 name = ':ne';
3570 } 3573 }
3571 if (name == null) { 3574 if (name == null) {
3572 $globals.world.internalError(('unimplemented binary op ' + node.op), node. span); 3575 $globals.world.internalError(('unimplemented binary op ' + node.op), node. span);
3573 return; 3576 return;
3574 } 3577 }
3575 return x.invoke$4(this, name, node, new Arguments(null, [y])); 3578 return x.invoke$4(this, name, node, new Arguments(null, [y]));
3576 } 3579 }
3580 else if ((assignKind != 0) && this._expressionNeedsParens(node.y)) {
3581 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod e.y.span), node, to$call$1(null), isVoid);
3582 }
3577 else { 3583 else {
3578 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid); 3584 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid);
3579 } 3585 }
3580 } 3586 }
3581 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) { 3587 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) {
3582 if (captureOriginal == null) { 3588 if (captureOriginal == null) {
3583 captureOriginal = (function (x) { 3589 captureOriginal = (function (x) {
3584 return x; 3590 return x;
3585 }) 3591 })
3586 ; 3592 ;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 var $0; 3982 var $0;
3977 var type = node.type.type; 3983 var type = node.type.type;
3978 if (!!(($0 = node.value) && $0.is$List())) { 3984 if (!!(($0 = node.value) && $0.is$List())) {
3979 var items = []; 3985 var items = [];
3980 var $$list = node.value; 3986 var $$list = node.value;
3981 for (var $$i = node.value.iterator$0(); $$i.hasNext$0(); ) { 3987 for (var $$i = node.value.iterator$0(); $$i.hasNext$0(); ) {
3982 var item = $$i.next$0(); 3988 var item = $$i.next$0();
3983 var val = this.visitValue(item); 3989 var val = this.visitValue(item);
3984 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY()); 3990 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY());
3985 var code = val.get$code(); 3991 var code = val.get$code();
3986 if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpr ession) || (item instanceof PostfixExpression) || this._isUnaryIncrement(item)) { 3992 if (this._expressionNeedsParens(item)) {
3987 code = ('(' + code + ')'); 3993 code = ('(' + code + ')');
3988 } 3994 }
3989 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) { 3995 if ($eq(items.get$length(), 0) || ($ne(code, "''") && $ne(code, '""'))) {
3990 items.add$1(code); 3996 items.add$1(code);
3991 } 3997 }
3992 } 3998 }
3993 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span, true); 3999 return new Value(type, ('(' + Strings.join(items, " + ") + ')'), node.span, true);
3994 } 4000 }
3995 var text = node.text; 4001 var text = node.text;
3996 if (type.get$isString()) { 4002 if (type.get$isString()) {
(...skipping 9324 matching lines...) Expand 10 before | Expand all | Expand 10 after
13321 $globals._NO_COLOR = '\u001b[0m'; 13327 $globals._NO_COLOR = '\u001b[0m';
13322 $globals._RED_COLOR = '\u001b[31m'; 13328 $globals._RED_COLOR = '\u001b[31m';
13323 } 13329 }
13324 var const$0 = new EnvMap()/*const EnvMap()*/; 13330 var const$0 = new EnvMap()/*const EnvMap()*/;
13325 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; 13331 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/;
13326 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; 13332 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/;
13327 var const$8 = new NoMoreElementsException()/*const NoMoreElementsException()*/; 13333 var const$8 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
13328 var $globals = {}; 13334 var $globals = {};
13329 $static_init(); 13335 $static_init();
13330 main(); 13336 main();
OLDNEW
« no previous file with comments | « frog/gen.dart ('k') | tests/language/src/AssignOpTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698