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

Side by Side Diff: frog/minfrog

Issue 8802028: fix set index bug in frog. (Closed) Base URL: https://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
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 }; 342 };
343 Object.prototype.substring$2 = function($0, $1) { 343 Object.prototype.substring$2 = function($0, $1) {
344 return this.noSuchMethod("substring", [$0, $1]); 344 return this.noSuchMethod("substring", [$0, $1]);
345 }; 345 };
346 Object.prototype.toString$0 = function() { 346 Object.prototype.toString$0 = function() {
347 return this.toString(); 347 return this.toString();
348 }; 348 };
349 Object.prototype.visit$1 = function($0) { 349 Object.prototype.visit$1 = function($0) {
350 return this.noSuchMethod("visit", [$0]); 350 return this.noSuchMethod("visit", [$0]);
351 }; 351 };
352 Object.prototype.visitBinaryExpression$1 = function($0) {
353 return this.noSuchMethod("visitBinaryExpression", [$0]);
354 };
352 Object.prototype.visitPostfixExpression$1 = function($0) { 355 Object.prototype.visitPostfixExpression$1 = function($0) {
353 return this.noSuchMethod("visitPostfixExpression", [$0]); 356 return this.noSuchMethod("visitPostfixExpression", [$0]);
354 }; 357 };
355 Object.prototype.visitSources$0 = function() { 358 Object.prototype.visitSources$0 = function() {
356 return this.noSuchMethod("visitSources", []); 359 return this.noSuchMethod("visitSources", []);
357 }; 360 };
358 Object.prototype.writeDefinition$2 = function($0, $1) { 361 Object.prototype.writeDefinition$2 = function($0, $1) {
359 return this.noSuchMethod("writeDefinition", [$0, $1]); 362 return this.noSuchMethod("writeDefinition", [$0, $1]);
360 }; 363 };
361 // ********** Code for NoSuchMethodException ************** 364 // ********** Code for NoSuchMethodException **************
(...skipping 2572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 } 2937 }
2935 MethodGenerator.prototype.visitTypedValue = function(node, expectedType) { 2938 MethodGenerator.prototype.visitTypedValue = function(node, expectedType) {
2936 return this.visitValue(node).convertTo$3(this, expectedType, node); 2939 return this.visitValue(node).convertTo$3(this, expectedType, node);
2937 } 2940 }
2938 MethodGenerator.prototype.visitVoid = function(node) { 2941 MethodGenerator.prototype.visitVoid = function(node) {
2939 if ((node instanceof PostfixExpression)) { 2942 if ((node instanceof PostfixExpression)) {
2940 var value = this.visitPostfixExpression(node, true); 2943 var value = this.visitPostfixExpression(node, true);
2941 value.checkFirstClass$1(node.span); 2944 value.checkFirstClass$1(node.span);
2942 return value; 2945 return value;
2943 } 2946 }
2947 else if ((node instanceof BinaryExpression)) {
2948 var value = this.visitBinaryExpression(node, true);
2949 value.checkFirstClass$1(node.span);
2950 return value;
2951 }
2944 return this.visitValue(node); 2952 return this.visitValue(node);
2945 } 2953 }
2946 MethodGenerator.prototype.visitDietStatement = function(node) { 2954 MethodGenerator.prototype.visitDietStatement = function(node) {
2947 var parser = new Parser(node.span.file, false, false, false, node.span.start); 2955 var parser = new Parser(node.span.file, false, false, false, node.span.start);
2948 this.visitStatementsInBlock(parser.block$0()); 2956 this.visitStatementsInBlock(parser.block$0());
2949 return false; 2957 return false;
2950 } 2958 }
2951 MethodGenerator.prototype.visitVariableDefinition = function(node) { 2959 MethodGenerator.prototype.visitVariableDefinition = function(node) {
2952 var isFinal = false; 2960 var isFinal = false;
2953 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) { 2961 if (node.modifiers != null && $eq(node.modifiers.$index(0).get$kind(), 98/*Tok enKind.FINAL*/)) {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
3397 else { 3405 else {
3398 target = node.target.visit(this); 3406 target = node.target.visit(this);
3399 } 3407 }
3400 return target.invoke$4(this, name, position, this._makeArgs(node.arguments)); 3408 return target.invoke$4(this, name, position, this._makeArgs(node.arguments));
3401 } 3409 }
3402 MethodGenerator.prototype.visitIndexExpression = function(node) { 3410 MethodGenerator.prototype.visitIndexExpression = function(node) {
3403 var target = this.visitValue(node.target); 3411 var target = this.visitValue(node.target);
3404 var index = this.visitValue(node.index); 3412 var index = this.visitValue(node.index);
3405 return target.invoke$4(this, ':index', node, new Arguments(null, [index])); 3413 return target.invoke$4(this, ':index', node, new Arguments(null, [index]));
3406 } 3414 }
3407 MethodGenerator.prototype.visitBinaryExpression = function(node) { 3415 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) {
3408 var kind = node.op.kind; 3416 var kind = node.op.kind;
3409 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) { 3417 if (kind == 35/*TokenKind.AND*/ || kind == 34/*TokenKind.OR*/) {
3410 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool); 3418 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool);
3411 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool); 3419 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool);
3412 var code = ('' + x.get$code() + ' ' + node.op + ' ' + y.get$code()); 3420 var code = ('' + x.get$code() + ' ' + node.op + ' ' + y.get$code());
3413 if (x.get$isConst() && y.get$isConst()) { 3421 if (x.get$isConst() && y.get$isConst()) {
3414 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue(); 3422 var value = (kind == 35/*TokenKind.AND*/) ? x.get$actualValue() && y.get$a ctualValue() : x.get$actualValue() || y.get$actualValue();
3415 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ('' + value), node.span); 3423 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v alue, ('' + value), node.span);
3416 } 3424 }
3417 return new Value($globals.world.nonNullBool, code, node.span, true); 3425 return new Value($globals.world.nonNullBool, code, node.span, true);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 if (node.op.kind == 49/*TokenKind.NE*/) { 3459 if (node.op.kind == 49/*TokenKind.NE*/) {
3452 name = ':ne'; 3460 name = ':ne';
3453 } 3461 }
3454 if (name == null) { 3462 if (name == null) {
3455 $globals.world.internalError(('unimplemented binary op ' + node.op), node. span); 3463 $globals.world.internalError(('unimplemented binary op ' + node.op), node. span);
3456 return; 3464 return;
3457 } 3465 }
3458 return x.invoke$4(this, name, node, new Arguments(null, [y])); 3466 return x.invoke$4(this, name, node, new Arguments(null, [y]));
3459 } 3467 }
3460 else { 3468 else {
3461 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null)); 3469 return this._visitAssign(assignKind, node.x, node.y, node, to$call$1(null), isVoid);
3462 } 3470 }
3463 } 3471 }
3464 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal) { 3472 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, captur eOriginal, isVoid) {
3465 if (captureOriginal == null) { 3473 if (captureOriginal == null) {
3466 captureOriginal = (function (x) { 3474 captureOriginal = (function (x) {
3467 return x; 3475 return x;
3468 }) 3476 })
3469 ; 3477 ;
3470 } 3478 }
3471 if ((xn instanceof VarExpression)) { 3479 if ((xn instanceof VarExpression)) {
3472 return this._visitVarAssign(kind, xn, yn, position, captureOriginal); 3480 return this._visitVarAssign(kind, xn, yn, position, captureOriginal);
3473 } 3481 }
3474 else if ((xn instanceof IndexExpression)) { 3482 else if ((xn instanceof IndexExpression)) {
3475 return this._visitIndexAssign(kind, xn, yn, position, captureOriginal); 3483 return this._visitIndexAssign(kind, xn, yn, position, captureOriginal, isVoi d);
3476 } 3484 }
3477 else if ((xn instanceof DotExpression)) { 3485 else if ((xn instanceof DotExpression)) {
3478 return this._visitDotAssign(kind, xn, yn, position, captureOriginal); 3486 return this._visitDotAssign(kind, xn, yn, position, captureOriginal);
3479 } 3487 }
3480 else { 3488 else {
3481 $globals.world.error('illegal lhs', xn.span); 3489 $globals.world.error('illegal lhs', xn.span);
3482 } 3490 }
3483 } 3491 }
3484 MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, cap tureOriginal) { 3492 MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, cap tureOriginal) {
3485 var name = xn.name.name; 3493 var name = xn.name.name;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3538 var op = TokenKind.kindToString(kind); 3546 var op = TokenKind.kindToString(kind);
3539 return new Value(y.get$type(), ('' + x.get$code() + ' ' + op + '= ' + y.get$ code()), position.span, true); 3547 return new Value(y.get$type(), ('' + x.get$code() + ' ' + op + '= ' + y.get$ code()), position.span, true);
3540 } 3548 }
3541 else { 3549 else {
3542 var right = x; 3550 var right = x;
3543 right = captureOriginal(right); 3551 right = captureOriginal(right);
3544 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 3552 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
3545 return new Value(y.get$type(), ('' + x.get$code() + ' = ' + y.get$code()), p osition.span, true); 3553 return new Value(y.get$type(), ('' + x.get$code() + ' = ' + y.get$code()), p osition.span, true);
3546 } 3554 }
3547 } 3555 }
3548 MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, c aptureOriginal) { 3556 MethodGenerator.prototype._visitIndexAssign = function(kind, xn, yn, position, c aptureOriginal, isVoid) {
3549 var target = this.visitValue(xn.target); 3557 var target = this.visitValue(xn.target);
3550 var index = this.visitValue(xn.index); 3558 var index = this.visitValue(xn.index);
3551 var y = this.visitValue(yn); 3559 var y = this.visitValue(yn);
3552 var tmptarget = target; 3560 var tmptarget = target;
3553 var tmpindex = index; 3561 var tmpindex = index;
3554 if (kind != 0) { 3562 if (kind != 0) {
3555 tmptarget = this.getTemp(target); 3563 tmptarget = this.getTemp(target);
3556 tmpindex = this.getTemp(index); 3564 tmpindex = this.getTemp(index);
3557 index = this.assignTemp(tmpindex, index); 3565 index = this.assignTemp(tmpindex, index);
3558 var right = tmptarget.invoke$4(this, ':index', position, new Arguments(null, [tmpindex])); 3566 var right = tmptarget.invoke$4(this, ':index', position, new Arguments(null, [tmpindex]));
3559 right = captureOriginal(right); 3567 right = captureOriginal(right);
3560 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y])); 3568 y = right.invoke$4(this, TokenKind.binaryMethodName(kind), position, new Arg uments(null, [y]));
3561 } 3569 }
3570 var tmpy = null;
3571 if (!isVoid) {
3572 tmpy = this.getTemp(y);
3573 y = this.assignTemp(tmpy, y);
3574 }
3562 var ret = this.assignTemp(tmptarget, target).invoke(this, ':setindex', positio n, new Arguments(null, [index, y]), false); 3575 var ret = this.assignTemp(tmptarget, target).invoke(this, ':setindex', positio n, new Arguments(null, [index, y]), false);
3576 if ($ne(tmpy, null)) {
3577 ret = new Value(ret.get$type(), ('(' + ret.get$code() + ', ' + tmpy.get$code () + ')'), ret.get$span(), true);
3578 if ($ne(tmpy, y)) this.freeTemp(tmpy);
3579 }
3563 if ($ne(tmptarget, target)) this.freeTemp(tmptarget); 3580 if ($ne(tmptarget, target)) this.freeTemp(tmptarget);
3564 if ($ne(tmpindex, index)) this.freeTemp(tmpindex); 3581 if ($ne(tmpindex, index)) this.freeTemp(tmpindex);
3565 return ret; 3582 return ret;
3566 } 3583 }
3567 MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, cap tureOriginal) { 3584 MethodGenerator.prototype._visitDotAssign = function(kind, xn, yn, position, cap tureOriginal) {
3568 var target = xn.self.visit(this); 3585 var target = xn.self.visit(this);
3569 var y = this.visitValue(yn); 3586 var y = this.visitValue(yn);
3570 var tmptarget = target; 3587 var tmptarget = target;
3571 if (kind != 0) { 3588 if (kind != 0) {
3572 tmptarget = this.getTemp(target); 3589 tmptarget = this.getTemp(target);
(...skipping 10 matching lines...) Expand all
3583 switch (node.op.kind) { 3600 switch (node.op.kind) {
3584 case 16/*TokenKind.INCR*/: 3601 case 16/*TokenKind.INCR*/:
3585 case 17/*TokenKind.DECR*/: 3602 case 17/*TokenKind.DECR*/:
3586 3603
3587 if (value.get$type().get$isNum()) { 3604 if (value.get$type().get$isNum()) {
3588 return new Value(value.get$type(), ('' + node.op + value.get$code()), no de.span, true); 3605 return new Value(value.get$type(), ('' + node.op + value.get$code()), no de.span, true);
3589 } 3606 }
3590 else { 3607 else {
3591 var kind = (16/*TokenKind.INCR*/ == node.op.kind ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/); 3608 var kind = (16/*TokenKind.INCR*/ == node.op.kind ? 42/*TokenKind.ADD*/ : 43/*TokenKind.SUB*/);
3592 var operand = new LiteralExpression(1, new TypeReference(node.span, $glo bals.world.numType), '1', node.span); 3609 var operand = new LiteralExpression(1, new TypeReference(node.span, $glo bals.world.numType), '1', node.span);
3593 var assignValue = this._visitAssign(kind, node.self, operand, node, to$c all$1(null)); 3610 var assignValue = this._visitAssign(kind, node.self, operand, node, to$c all$1(null), false);
3594 return new Value(assignValue.get$type(), ('(' + assignValue.get$code() + ')'), node.span, true); 3611 return new Value(assignValue.get$type(), ('(' + assignValue.get$code() + ')'), node.span, true);
3595 } 3612 }
3596 3613
3597 case 19/*TokenKind.NOT*/: 3614 case 19/*TokenKind.NOT*/:
3598 3615
3599 if (value.get$type().get$isBool() && value.get$isConst()) { 3616 if (value.get$type().get$isBool() && value.get$isConst()) {
3600 var newVal = !value.get$actualValue(); 3617 var newVal = !value.get$actualValue();
3601 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, ( '' + newVal), node.span); 3618 return EvaluatedValue.EvaluatedValue$factory(value.get$type(), newVal, ( '' + newVal), node.span);
3602 } 3619 }
3603 else { 3620 else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3644 var ret = this._visitAssign(kind, node.body, operand, node, (function (l) { 3661 var ret = this._visitAssign(kind, node.body, operand, node, (function (l) {
3645 if (isVoid) { 3662 if (isVoid) {
3646 return l; 3663 return l;
3647 } 3664 }
3648 else { 3665 else {
3649 left = l; 3666 left = l;
3650 tmpleft = $this.forceTemp(l); 3667 tmpleft = $this.forceTemp(l);
3651 return $this.assignTemp(tmpleft, left); 3668 return $this.assignTemp(tmpleft, left);
3652 } 3669 }
3653 }) 3670 })
3654 ); 3671 , false);
3655 if ($ne(tmpleft, null)) { 3672 if ($ne(tmpleft, null)) {
3656 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpleft.get$c ode() + ")"), node.span, true); 3673 ret = new Value(ret.get$type(), ("(" + ret.get$code() + ", " + tmpleft.get$c ode() + ")"), node.span, true);
3657 } 3674 }
3658 if ($ne(tmpleft, left)) { 3675 if ($ne(tmpleft, left)) {
3659 this.freeTemp(tmpleft); 3676 this.freeTemp(tmpleft);
3660 } 3677 }
3661 return ret; 3678 return ret;
3662 } 3679 }
3663 MethodGenerator.prototype.visitNewExpression = function(node) { 3680 MethodGenerator.prototype.visitNewExpression = function(node) {
3664 var typeRef = node.type; 3681 var typeRef = node.type;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3860 text = toDoubleQuote(text); 3877 text = toDoubleQuote(text);
3861 text = ('"' + text + '"'); 3878 text = ('"' + text + '"');
3862 } 3879 }
3863 if (text !== node.text) { 3880 if (text !== node.text) {
3864 node.value = text; 3881 node.value = text;
3865 node.text = text; 3882 node.text = text;
3866 } 3883 }
3867 } 3884 }
3868 return EvaluatedValue.EvaluatedValue$factory(type, node.value, node.text, null ); 3885 return EvaluatedValue.EvaluatedValue$factory(type, node.value, node.text, null );
3869 } 3886 }
3887 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) {
3888 return this.visitBinaryExpression($0, false);
3889 };
3870 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { 3890 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) {
3871 return this.visitPostfixExpression($0, false); 3891 return this.visitPostfixExpression($0, false);
3872 }; 3892 };
3873 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef inition; 3893 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef inition;
3874 // ********** Code for Arguments ************** 3894 // ********** Code for Arguments **************
3875 function Arguments(nodes, values) { 3895 function Arguments(nodes, values) {
3876 this.nodes = nodes; 3896 this.nodes = nodes;
3877 this.values = values; 3897 this.values = values;
3878 // Initializers done 3898 // Initializers done
3879 } 3899 }
(...skipping 6073 matching lines...) Expand 10 before | Expand all | Expand 10 after
9953 Expression.call(this, span); 9973 Expression.call(this, span);
9954 } 9974 }
9955 $inherits(BinaryExpression, Expression); 9975 $inherits(BinaryExpression, Expression);
9956 BinaryExpression.prototype.get$op = function() { return this.op; }; 9976 BinaryExpression.prototype.get$op = function() { return this.op; };
9957 BinaryExpression.prototype.set$op = function(value) { return this.op = value; }; 9977 BinaryExpression.prototype.set$op = function(value) { return this.op = value; };
9958 BinaryExpression.prototype.get$x = function() { return this.x; }; 9978 BinaryExpression.prototype.get$x = function() { return this.x; };
9959 BinaryExpression.prototype.set$x = function(value) { return this.x = value; }; 9979 BinaryExpression.prototype.set$x = function(value) { return this.x = value; };
9960 BinaryExpression.prototype.get$y = function() { return this.y; }; 9980 BinaryExpression.prototype.get$y = function() { return this.y; };
9961 BinaryExpression.prototype.set$y = function(value) { return this.y = value; }; 9981 BinaryExpression.prototype.set$y = function(value) { return this.y = value; };
9962 BinaryExpression.prototype.visit = function(visitor) { 9982 BinaryExpression.prototype.visit = function(visitor) {
9963 return visitor.visitBinaryExpression(this); 9983 return visitor.visitBinaryExpression$1(this);
9964 } 9984 }
9965 BinaryExpression.prototype.visit$1 = BinaryExpression.prototype.visit; 9985 BinaryExpression.prototype.visit$1 = BinaryExpression.prototype.visit;
9966 // ********** Code for UnaryExpression ************** 9986 // ********** Code for UnaryExpression **************
9967 function UnaryExpression(op, self, span) { 9987 function UnaryExpression(op, self, span) {
9968 this.op = op; 9988 this.op = op;
9969 this.self = self; 9989 this.self = self;
9970 // Initializers done 9990 // Initializers done
9971 Expression.call(this, span); 9991 Expression.call(this, span);
9972 } 9992 }
9973 $inherits(UnaryExpression, Expression); 9993 $inherits(UnaryExpression, Expression);
(...skipping 3001 matching lines...) Expand 10 before | Expand all | Expand 10 after
12975 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V); 12995 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ ueueEntry_KeyValuePair_K$V);
12976 // ********** Globals ************** 12996 // ********** Globals **************
12977 function $static_init(){ 12997 function $static_init(){
12978 } 12998 }
12979 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/; 12999 var const$0 = new NoMoreElementsException()/*const NoMoreElementsException()*/;
12980 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/; 13000 var const$2 = new EmptyQueueException()/*const EmptyQueueException()*/;
12981 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/; 13001 var const$3 = new _DeletedKeySentinel()/*const _DeletedKeySentinel()*/;
12982 var $globals = {}; 13002 var $globals = {};
12983 $static_init(); 13003 $static_init();
12984 main(); 13004 main();
OLDNEW
« frog/gen.dart ('K') | « frog/gen.dart ('k') | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698