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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 708993003: Revert "Revert "dart2js: Add a type parameter to class Reference...."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../constants/expressions.dart'; 7 import '../constants/expressions.dart';
8 import '../constants/values.dart' show PrimitiveConstantValue; 8 import '../constants/values.dart' show PrimitiveConstantValue;
9 import '../dart_backend/dart_backend.dart' show DartBackend; 9 import '../dart_backend/dart_backend.dart' show DartBackend;
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 ir.Primitive _continueWithExpression(ir.Expression build(ir.Continuation k)) { 346 ir.Primitive _continueWithExpression(ir.Expression build(ir.Continuation k)) {
347 ir.Parameter v = new ir.Parameter(null); 347 ir.Parameter v = new ir.Parameter(null);
348 ir.Continuation k = new ir.Continuation([v]); 348 ir.Continuation k = new ir.Continuation([v]);
349 ir.Expression expression = build(k); 349 ir.Expression expression = build(k);
350 add(new ir.LetCont(k, expression)); 350 add(new ir.LetCont(k, expression));
351 return v; 351 return v;
352 } 352 }
353 353
354 ir.Primitive _buildInvokeStatic(Element element, 354 ir.Primitive _buildInvokeStatic(Element element,
355 Selector selector, 355 Selector selector,
356 List<ir.Definition> arguments) { 356 List<ir.Primitive> arguments) {
357 assert(isOpen); 357 assert(isOpen);
358 return _continueWithExpression( 358 return _continueWithExpression(
359 (k) => new ir.InvokeStatic(element, selector, k, arguments)); 359 (k) => new ir.InvokeStatic(element, selector, k, arguments));
360 } 360 }
361 361
362 ir.Primitive _buildInvokeSuper(Selector selector, 362 ir.Primitive _buildInvokeSuper(Selector selector,
363 List<ir.Definition> arguments) { 363 List<ir.Primitive> arguments) {
364 assert(isOpen); 364 assert(isOpen);
365 return _continueWithExpression( 365 return _continueWithExpression(
366 (k) => new ir.InvokeSuperMethod(selector, k, arguments)); 366 (k) => new ir.InvokeSuperMethod(selector, k, arguments));
367 } 367 }
368 368
369 ir.Primitive _buildInvokeDynamic(ir.Primitive receiver, 369 ir.Primitive _buildInvokeDynamic(ir.Primitive receiver,
370 Selector selector, 370 Selector selector,
371 List<ir.Definition> arguments) { 371 List<ir.Primitive> arguments) {
372 assert(isOpen); 372 assert(isOpen);
373 return _continueWithExpression( 373 return _continueWithExpression(
374 (k) => new ir.InvokeMethod(receiver, selector, k, arguments)); 374 (k) => new ir.InvokeMethod(receiver, selector, k, arguments));
375 } 375 }
376 376
377 377
378 /// Create a constant literal from [constant]. 378 /// Create a constant literal from [constant].
379 ir.Constant buildConstantLiteral(ConstantExpression constant) { 379 ir.Constant buildConstantLiteral(ConstantExpression constant) {
380 assert(isOpen); 380 assert(isOpen);
381 ir.Constant prim = new ir.Constant(constant); 381 ir.Constant prim = new ir.Constant(constant);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 return new ir.FunctionDefinition.abstract( 527 return new ir.FunctionDefinition.abstract(
528 element, _parameters, defaults); 528 element, _parameters, defaults);
529 } 529 }
530 } 530 }
531 531
532 532
533 /// Create a super invocation where the method name and the argument structure 533 /// Create a super invocation where the method name and the argument structure
534 /// are defined by [selector] and the argument values are defined by 534 /// are defined by [selector] and the argument values are defined by
535 /// [arguments]. 535 /// [arguments].
536 ir.Primitive buildSuperInvocation(Selector selector, 536 ir.Primitive buildSuperInvocation(Selector selector,
537 List<ir.Definition> arguments) { 537 List<ir.Primitive> arguments) {
538 return _buildInvokeSuper(selector, arguments); 538 return _buildInvokeSuper(selector, arguments);
539 } 539 }
540 540
541 /// Create a getter invocation on the super class where the getter name is 541 /// Create a getter invocation on the super class where the getter name is
542 /// defined by [selector]. 542 /// defined by [selector].
543 ir.Primitive buildSuperGet(Selector selector) { 543 ir.Primitive buildSuperGet(Selector selector) {
544 assert(selector.isGetter); 544 assert(selector.isGetter);
545 return _buildInvokeSuper(selector, const <ir.Definition>[]); 545 return _buildInvokeSuper(selector, const <ir.Primitive>[]);
546 } 546 }
547 547
548 /// Create a setter invocation on the super class where the setter name and 548 /// Create a setter invocation on the super class where the setter name and
549 /// argument are defined by [selector] and [value], respectively. 549 /// argument are defined by [selector] and [value], respectively.
550 ir.Primitive buildSuperSet(Selector selector, ir.Primitive value) { 550 ir.Primitive buildSuperSet(Selector selector, ir.Primitive value) {
551 assert(selector.isSetter); 551 assert(selector.isSetter);
552 _buildInvokeSuper(selector, <ir.Definition>[value]); 552 _buildInvokeSuper(selector, <ir.Primitive>[value]);
553 return value; 553 return value;
554 } 554 }
555 555
556 /// Create an index set invocation on the super class with the provided 556 /// Create an index set invocation on the super class with the provided
557 /// [index] and [value]. 557 /// [index] and [value].
558 ir.Primitive buildSuperIndexSet(ir.Primitive index, 558 ir.Primitive buildSuperIndexSet(ir.Primitive index,
559 ir.Primitive value) { 559 ir.Primitive value) {
560 _buildInvokeSuper(new Selector.indexSet(), <ir.Definition>[index, value]); 560 _buildInvokeSuper(new Selector.indexSet(), <ir.Primitive>[index, value]);
561 return value; 561 return value;
562 } 562 }
563 563
564 /// Create a dynamic invocation on [receiver] where the method name and 564 /// Create a dynamic invocation on [receiver] where the method name and
565 /// argument structure are defined by [selector] and the argument values are 565 /// argument structure are defined by [selector] and the argument values are
566 /// defined by [arguments]. 566 /// defined by [arguments].
567 ir.Primitive buildDynamicInvocation(ir.Definition receiver, 567 ir.Primitive buildDynamicInvocation(ir.Primitive receiver,
568 Selector selector, 568 Selector selector,
569 List<ir.Definition> arguments) { 569 List<ir.Primitive> arguments) {
570 return _buildInvokeDynamic(receiver, selector, arguments); 570 return _buildInvokeDynamic(receiver, selector, arguments);
571 } 571 }
572 572
573 /// Create a dynamic getter invocation on [receiver] where the getter name is 573 /// Create a dynamic getter invocation on [receiver] where the getter name is
574 /// defined by [selector]. 574 /// defined by [selector].
575 ir.Primitive buildDynamicGet(ir.Primitive receiver, Selector selector) { 575 ir.Primitive buildDynamicGet(ir.Primitive receiver, Selector selector) {
576 assert(selector.isGetter); 576 assert(selector.isGetter);
577 return _buildInvokeDynamic(receiver, selector, const <ir.Definition>[]); 577 return _buildInvokeDynamic(receiver, selector, const <ir.Primitive>[]);
578 } 578 }
579 579
580 /// Create a dynamic setter invocation on [receiver] where the setter name and 580 /// Create a dynamic setter invocation on [receiver] where the setter name and
581 /// argument are defined by [selector] and [value], respectively. 581 /// argument are defined by [selector] and [value], respectively.
582 ir.Primitive buildDynamicSet(ir.Primitive receiver, 582 ir.Primitive buildDynamicSet(ir.Primitive receiver,
583 Selector selector, 583 Selector selector,
584 ir.Primitive value) { 584 ir.Primitive value) {
585 assert(selector.isSetter); 585 assert(selector.isSetter);
586 _buildInvokeDynamic(receiver, selector, <ir.Definition>[value]); 586 _buildInvokeDynamic(receiver, selector, <ir.Primitive>[value]);
587 return value; 587 return value;
588 } 588 }
589 589
590 /// Create a dynamic index set invocation on [receiver] with the provided 590 /// Create a dynamic index set invocation on [receiver] with the provided
591 /// [index] and [value]. 591 /// [index] and [value].
592 ir.Primitive buildDynamicIndexSet(ir.Primitive receiver, 592 ir.Primitive buildDynamicIndexSet(ir.Primitive receiver,
593 ir.Primitive index, 593 ir.Primitive index,
594 ir.Primitive value) { 594 ir.Primitive value) {
595 _buildInvokeDynamic( 595 _buildInvokeDynamic(
596 receiver, new Selector.indexSet(), <ir.Definition>[index, value]); 596 receiver, new Selector.indexSet(), <ir.Primitive>[index, value]);
597 return value; 597 return value;
598 } 598 }
599 599
600 /// Create a static invocation of [element] where argument structure is 600 /// Create a static invocation of [element] where argument structure is
601 /// defined by [selector] and the argument values are defined by [arguments]. 601 /// defined by [selector] and the argument values are defined by [arguments].
602 ir.Primitive buildStaticInvocation(Element element, 602 ir.Primitive buildStaticInvocation(Element element,
603 Selector selector, 603 Selector selector,
604 List<ir.Definition> arguments) { 604 List<ir.Primitive> arguments) {
605 return _buildInvokeStatic(element, selector, arguments); 605 return _buildInvokeStatic(element, selector, arguments);
606 } 606 }
607 607
608 /// Create a static getter invocation of [element] where the getter name is 608 /// Create a static getter invocation of [element] where the getter name is
609 /// defined by [selector]. 609 /// defined by [selector].
610 ir.Primitive buildStaticGet(Element element, Selector selector) { 610 ir.Primitive buildStaticGet(Element element, Selector selector) {
611 assert(selector.isGetter); 611 assert(selector.isGetter);
612 return _buildInvokeStatic(element, selector, const <ir.Definition>[]); 612 return _buildInvokeStatic(element, selector, const <ir.Primitive>[]);
613 } 613 }
614 614
615 /// Create a static setter invocation of [element] where the setter name and 615 /// Create a static setter invocation of [element] where the setter name and
616 /// argument are defined by [selector] and [value], respectively. 616 /// argument are defined by [selector] and [value], respectively.
617 ir.Primitive buildStaticSet(Element element, 617 ir.Primitive buildStaticSet(Element element,
618 Selector selector, 618 Selector selector,
619 ir.Primitive value) { 619 ir.Primitive value) {
620 assert(selector.isSetter); 620 assert(selector.isSetter);
621 _buildInvokeStatic(element, selector, <ir.Definition>[value]); 621 _buildInvokeStatic(element, selector, <ir.Primitive>[value]);
622 return value; 622 return value;
623 } 623 }
624 624
625 /// Create a constructor invocation of [element] on [type] where the 625 /// Create a constructor invocation of [element] on [type] where the
626 /// constructor name and argument structure are defined by [selector] and the 626 /// constructor name and argument structure are defined by [selector] and the
627 /// argument values are defined by [arguments]. 627 /// argument values are defined by [arguments].
628 ir.Primitive buildConstructorInvocation(FunctionElement element, 628 ir.Primitive buildConstructorInvocation(FunctionElement element,
629 Selector selector, 629 Selector selector,
630 DartType type, 630 DartType type,
631 List<ir.Definition> arguments) { 631 List<ir.Primitive> arguments) {
632 assert(isOpen); 632 assert(isOpen);
633 return _continueWithExpression( 633 return _continueWithExpression(
634 (k) => new ir.InvokeConstructor(type, element, selector, k, arguments)); 634 (k) => new ir.InvokeConstructor(type, element, selector, k, arguments));
635 } 635 }
636 636
637 /// Create a string concatenation of the [arguments]. 637 /// Create a string concatenation of the [arguments].
638 ir.Primitive buildStringConcatenation(List<ir.Definition> arguments) { 638 ir.Primitive buildStringConcatenation(List<ir.Primitive> arguments) {
639 assert(isOpen); 639 assert(isOpen);
640 return _continueWithExpression( 640 return _continueWithExpression(
641 (k) => new ir.ConcatenateStrings(k, arguments)); 641 (k) => new ir.ConcatenateStrings(k, arguments));
642 } 642 }
643 643
644 /// Create a read access of [local]. 644 /// Create a read access of [local].
645 ir.Primitive buildLocalGet(LocalElement local) { 645 ir.Primitive buildLocalGet(LocalElement local) {
646 assert(isOpen); 646 assert(isOpen);
647 if (isClosureVariable(local)) { 647 if (isClosureVariable(local)) {
648 ir.Primitive result = new ir.GetClosureVariable(local); 648 ir.Primitive result = new ir.GetClosureVariable(local);
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 index = 0; 1403 index = 0;
1404 for (int i = 0; i < environment.length; ++i) { 1404 for (int i = 0; i < environment.length; ++i) {
1405 if (common[i] == null) { 1405 if (common[i] == null) {
1406 environment.index2value[i] = parameters[index++]; 1406 environment.index2value[i] = parameters[index++];
1407 } 1407 }
1408 } 1408 }
1409 1409
1410 return join; 1410 return join;
1411 } 1411 }
1412 } 1412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698