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 '../compile_time_constants.dart' show BackendConstantEnvironment; | 7 import '../compile_time_constants.dart' show BackendConstantEnvironment; |
8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
10 import '../constants/values.dart' show ConstantValue, PrimitiveConstantValue; | 10 import '../constants/values.dart' show ConstantValue, PrimitiveConstantValue; |
11 import '../dart_types.dart'; | 11 import '../dart_types.dart'; |
12 import '../dart2jslib.dart'; | 12 import '../dart2jslib.dart'; |
13 import '../elements/elements.dart'; | 13 import '../elements/elements.dart'; |
14 import '../io/source_information.dart'; | 14 import '../io/source_information.dart'; |
15 import '../tree/tree.dart' as ast; | 15 import '../tree/tree.dart' as ast; |
16 import '../types/types.dart' show TypeMask; | 16 import '../types/types.dart' show TypeMask; |
17 import '../closure.dart' hide ClosureScope; | 17 import '../closure.dart' hide ClosureScope; |
18 import '../universe/universe.dart' show SelectorKind; | 18 import '../universe/universe.dart' show SelectorKind; |
19 import 'cps_ir_nodes.dart' as ir; | 19 import 'cps_ir_nodes.dart' as ir; |
20 import 'cps_ir_builder_task.dart' show DartCapturedVariables, | 20 import 'cps_ir_builder_task.dart' show DartCapturedVariables, |
21 GlobalProgramInformation; | 21 GlobalProgramInformation; |
22 | 22 |
23 import '../common.dart' as types show TypeMask; | |
24 import '../js/js.dart' as js show Template; | |
25 import '../native/native.dart' show NativeBehavior; | |
26 | |
27 /// A mapping from variable elements to their compile-time values. | 23 /// A mapping from variable elements to their compile-time values. |
28 /// | 24 /// |
29 /// Map elements denoted by parameters and local variables to the | 25 /// Map elements denoted by parameters and local variables to the |
30 /// [ir.Primitive] that is their value. Parameters and locals are | 26 /// [ir.Primitive] that is their value. Parameters and locals are |
31 /// assigned indexes which can be used to refer to them. | 27 /// assigned indexes which can be used to refer to them. |
32 class Environment { | 28 class Environment { |
33 /// A map from locals to their environment index. | 29 /// A map from locals to their environment index. |
34 final Map<Local, int> variable2index; | 30 final Map<Local, int> variable2index; |
35 | 31 |
36 /// A reverse map from environment indexes to the variable. | 32 /// A reverse map from environment indexes to the variable. |
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2408 ir.Primitive buildReifyTypeVariable(TypeVariableType variable) { | 2404 ir.Primitive buildReifyTypeVariable(TypeVariableType variable) { |
2409 ir.Primitive typeArgument = buildTypeVariableAccess(variable); | 2405 ir.Primitive typeArgument = buildTypeVariableAccess(variable); |
2410 return addPrimitive(new ir.ReifyRuntimeType(typeArgument)); | 2406 return addPrimitive(new ir.ReifyRuntimeType(typeArgument)); |
2411 } | 2407 } |
2412 | 2408 |
2413 ir.Primitive buildInvocationMirror(Selector selector, | 2409 ir.Primitive buildInvocationMirror(Selector selector, |
2414 List<ir.Primitive> arguments) { | 2410 List<ir.Primitive> arguments) { |
2415 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); | 2411 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); |
2416 } | 2412 } |
2417 | 2413 |
2418 ir.Primitive buildForeignCode(js.Template codeTemplate, | |
2419 List<ir.Primitive> arguments, | |
2420 NativeBehavior behavior, | |
2421 {Element dependency}) { | |
2422 types.TypeMask type = program.getTypeMaskForForeign(behavior); | |
2423 if (codeTemplate.isExpression) { | |
2424 return _continueWithExpression((k) => new ir.ForeignCode( | |
2425 codeTemplate, | |
2426 type, | |
2427 arguments, | |
2428 behavior, | |
2429 continuation: k, | |
2430 dependency: dependency)); | |
2431 } else { | |
2432 assert(isOpen); | |
2433 add(new ir.ForeignCode(codeTemplate, type, arguments, behavior, | |
2434 dependency: dependency)); | |
2435 _current = null; | |
2436 } | |
2437 } | |
2438 | |
2439 @override | 2414 @override |
2440 ir.Primitive buildTypeOperator(ir.Primitive value, | 2415 ir.Primitive buildTypeOperator(ir.Primitive value, |
2441 DartType type, | 2416 DartType type, |
2442 {bool isTypeTest}) { | 2417 {bool isTypeTest}) { |
2443 assert(isOpen); | 2418 assert(isOpen); |
2444 assert(isTypeTest != null); | 2419 assert(isTypeTest != null); |
2445 | 2420 |
2446 type = program.unaliasType(type); | 2421 type = program.unaliasType(type); |
2447 | 2422 |
2448 if (type.isMalformed) { | 2423 if (type.isMalformed) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2569 final DartType type; | 2544 final DartType type; |
2570 final LocalVariableElement exceptionVariable; | 2545 final LocalVariableElement exceptionVariable; |
2571 final LocalVariableElement stackTraceVariable; | 2546 final LocalVariableElement stackTraceVariable; |
2572 final SubbuildFunction buildCatchBlock; | 2547 final SubbuildFunction buildCatchBlock; |
2573 | 2548 |
2574 CatchClauseInfo({this.type, | 2549 CatchClauseInfo({this.type, |
2575 this.exceptionVariable, | 2550 this.exceptionVariable, |
2576 this.stackTraceVariable, | 2551 this.stackTraceVariable, |
2577 this.buildCatchBlock}); | 2552 this.buildCatchBlock}); |
2578 } | 2553 } |
OLD | NEW |