OLD | NEW |
---|---|
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_types.dart'; | 9 import '../dart_types.dart'; |
10 import '../dart2jslib.dart'; | 10 import '../dart2jslib.dart'; |
11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
12 import '../io/source_file.dart'; | 12 import '../io/source_file.dart'; |
13 import '../io/source_information.dart'; | |
13 import '../tree/tree.dart' as ast; | 14 import '../tree/tree.dart' as ast; |
14 import '../scanner/scannerlib.dart' show Token, isUserDefinableOperator; | 15 import '../scanner/scannerlib.dart' show Token, isUserDefinableOperator; |
15 import '../universe/universe.dart' show SelectorKind; | 16 import '../universe/universe.dart' show SelectorKind; |
16 import 'cps_ir_nodes.dart' as ir; | 17 import 'cps_ir_nodes.dart' as ir; |
17 import '../elements/modelx.dart' show SynthesizedConstructorElementX, | 18 import '../elements/modelx.dart' show SynthesizedConstructorElementX, |
18 ConstructorBodyElementX, FunctionSignatureX; | 19 ConstructorBodyElementX, FunctionSignatureX; |
19 import '../closure.dart' hide ClosureScope; | 20 import '../closure.dart' hide ClosureScope; |
20 import '../closure.dart' as closurelib; | 21 import '../closure.dart' as closurelib; |
21 import '../js_backend/js_backend.dart' show JavaScriptBackend; | 22 import '../js_backend/js_backend.dart' show JavaScriptBackend; |
22 | 23 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 ir.Primitive _continueWithExpression(ir.Expression build(ir.Continuation k)) { | 384 ir.Primitive _continueWithExpression(ir.Expression build(ir.Continuation k)) { |
384 ir.Parameter v = new ir.Parameter(null); | 385 ir.Parameter v = new ir.Parameter(null); |
385 ir.Continuation k = new ir.Continuation([v]); | 386 ir.Continuation k = new ir.Continuation([v]); |
386 ir.Expression expression = build(k); | 387 ir.Expression expression = build(k); |
387 add(new ir.LetCont(k, expression)); | 388 add(new ir.LetCont(k, expression)); |
388 return v; | 389 return v; |
389 } | 390 } |
390 | 391 |
391 ir.Primitive _buildInvokeStatic(Element element, | 392 ir.Primitive _buildInvokeStatic(Element element, |
392 Selector selector, | 393 Selector selector, |
393 List<ir.Primitive> arguments) { | 394 List<ir.Primitive> arguments, |
395 SourceInformation sourceInformation) { | |
394 assert(isOpen); | 396 assert(isOpen); |
395 return _continueWithExpression( | 397 return _continueWithExpression( |
396 (k) => new ir.InvokeStatic(element, selector, k, arguments)); | 398 (k) => new ir.InvokeStatic(element, selector, k, arguments, |
399 sourceInformation)); | |
397 } | 400 } |
398 | 401 |
399 ir.Primitive _buildInvokeSuper(Element target, | 402 ir.Primitive _buildInvokeSuper(Element target, |
400 Selector selector, | 403 Selector selector, |
401 List<ir.Primitive> arguments) { | 404 List<ir.Primitive> arguments) { |
402 assert(isOpen); | 405 assert(isOpen); |
403 return _continueWithExpression( | 406 return _continueWithExpression( |
404 (k) => new ir.InvokeMethodDirectly( | 407 (k) => new ir.InvokeMethodDirectly( |
405 buildThis(), target, selector, k, arguments)); | 408 buildThis(), target, selector, k, arguments)); |
406 } | 409 } |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 ir.Primitive value) { | 685 ir.Primitive value) { |
683 _buildInvokeDynamic( | 686 _buildInvokeDynamic( |
684 receiver, new Selector.indexSet(), <ir.Primitive>[index, value]); | 687 receiver, new Selector.indexSet(), <ir.Primitive>[index, value]); |
685 return value; | 688 return value; |
686 } | 689 } |
687 | 690 |
688 /// Create a static invocation of [element] where argument structure is | 691 /// Create a static invocation of [element] where argument structure is |
689 /// defined by [selector] and the argument values are defined by [arguments]. | 692 /// defined by [selector] and the argument values are defined by [arguments]. |
690 ir.Primitive buildStaticInvocation(Element element, | 693 ir.Primitive buildStaticInvocation(Element element, |
691 Selector selector, | 694 Selector selector, |
692 List<ir.Primitive> arguments) { | 695 List<ir.Primitive> arguments, |
693 return _buildInvokeStatic(element, selector, arguments); | 696 {SourceInformation sourceInformation}) { |
697 return _buildInvokeStatic(element, selector, arguments, sourceInformation); | |
694 } | 698 } |
695 | 699 |
696 /// Create a static getter invocation of [element] where the getter name is | 700 /// Create a static getter invocation of [element] where the getter name is |
697 /// defined by [selector]. | 701 /// defined by [selector]. |
698 ir.Primitive buildStaticGet(Element element, Selector selector) { | 702 ir.Primitive buildStaticGet(Element element, |
Johnni Winther
2015/02/24 08:29:30
The JS backend doesn't support static-get yet, so
| |
703 Selector selector, | |
704 {SourceInformation sourceInformation}) { | |
699 assert(selector.isGetter); | 705 assert(selector.isGetter); |
700 // TODO(karlklose,sigurdm): build different nodes for getters. | 706 // TODO(karlklose,sigurdm): build different nodes for getters. |
701 return _buildInvokeStatic(element, selector, const <ir.Primitive>[]); | 707 return _buildInvokeStatic( |
708 element, selector, const <ir.Primitive>[], sourceInformation); | |
702 } | 709 } |
703 | 710 |
704 /// Create a static setter invocation of [element] where the setter name and | 711 /// Create a static setter invocation of [element] where the setter name and |
705 /// argument are defined by [selector] and [value], respectively. | 712 /// argument are defined by [selector] and [value], respectively. |
706 ir.Primitive buildStaticSet(Element element, | 713 ir.Primitive buildStaticSet(Element element, |
707 Selector selector, | 714 Selector selector, |
708 ir.Primitive value) { | 715 ir.Primitive value, |
716 {SourceInformation sourceInformation}) { | |
709 assert(selector.isSetter); | 717 assert(selector.isSetter); |
710 // TODO(karlklose,sigurdm): build different nodes for setters. | 718 // TODO(karlklose,sigurdm): build different nodes for setters. |
711 _buildInvokeStatic(element, selector, <ir.Primitive>[value]); | 719 _buildInvokeStatic( |
720 element, selector, <ir.Primitive>[value], sourceInformation); | |
712 return value; | 721 return value; |
713 } | 722 } |
714 | 723 |
715 /// Create a constructor invocation of [element] on [type] where the | 724 /// Create a constructor invocation of [element] on [type] where the |
716 /// constructor name and argument structure are defined by [selector] and the | 725 /// constructor name and argument structure are defined by [selector] and the |
717 /// argument values are defined by [arguments]. | 726 /// argument values are defined by [arguments]. |
718 ir.Primitive buildConstructorInvocation(FunctionElement element, | 727 ir.Primitive buildConstructorInvocation(FunctionElement element, |
719 Selector selector, | 728 Selector selector, |
720 DartType type, | 729 DartType type, |
721 List<ir.Primitive> arguments) { | 730 List<ir.Primitive> arguments) { |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2012 ClosureEnvironment(this.selfReference, this.thisLocal, this.freeVariables); | 2021 ClosureEnvironment(this.selfReference, this.thisLocal, this.freeVariables); |
2013 } | 2022 } |
2014 | 2023 |
2015 /// Information about which variables are captured by a nested function. | 2024 /// Information about which variables are captured by a nested function. |
2016 /// | 2025 /// |
2017 /// This is used by the [DartIrBuilder] instead of [ClosureScope] and | 2026 /// This is used by the [DartIrBuilder] instead of [ClosureScope] and |
2018 /// [ClosureEnvironment]. | 2027 /// [ClosureEnvironment]. |
2019 abstract class DartCapturedVariableInfo { | 2028 abstract class DartCapturedVariableInfo { |
2020 Iterable<Local> get capturedVariables; | 2029 Iterable<Local> get capturedVariables; |
2021 } | 2030 } |
OLD | NEW |