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 '../closure.dart' hide ClosureScope; | 16 import '../closure.dart' hide ClosureScope; |
17 import '../universe/universe.dart' show SelectorKind; | 17 import '../universe/universe.dart' show SelectorKind; |
18 import 'cps_ir_nodes.dart' as ir; | 18 import 'cps_ir_nodes.dart' as ir; |
19 import 'cps_ir_builder_task.dart' show DartCapturedVariables, | 19 import 'cps_ir_builder_task.dart' show DartCapturedVariables, |
20 GlobalProgramInformation; | 20 GlobalProgramInformation; |
21 | 21 |
| 22 import '../common.dart' as types show TypeMask; |
| 23 import '../js/js.dart' as js show Template; |
| 24 import '../native/native.dart' show NativeBehavior; |
| 25 |
22 /// A mapping from variable elements to their compile-time values. | 26 /// A mapping from variable elements to their compile-time values. |
23 /// | 27 /// |
24 /// Map elements denoted by parameters and local variables to the | 28 /// Map elements denoted by parameters and local variables to the |
25 /// [ir.Primitive] that is their value. Parameters and locals are | 29 /// [ir.Primitive] that is their value. Parameters and locals are |
26 /// assigned indexes which can be used to refer to them. | 30 /// assigned indexes which can be used to refer to them. |
27 class Environment { | 31 class Environment { |
28 /// A map from locals to their environment index. | 32 /// A map from locals to their environment index. |
29 final Map<Local, int> variable2index; | 33 final Map<Local, int> variable2index; |
30 | 34 |
31 /// A reverse map from environment indexes to the variable. | 35 /// A reverse map from environment indexes to the variable. |
(...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 ir.Primitive buildReifyTypeVariable(TypeVariableType variable) { | 2388 ir.Primitive buildReifyTypeVariable(TypeVariableType variable) { |
2385 ir.Primitive typeArgument = buildTypeVariableAccess(variable); | 2389 ir.Primitive typeArgument = buildTypeVariableAccess(variable); |
2386 return addPrimitive(new ir.ReifyRuntimeType(typeArgument)); | 2390 return addPrimitive(new ir.ReifyRuntimeType(typeArgument)); |
2387 } | 2391 } |
2388 | 2392 |
2389 ir.Primitive buildInvocationMirror(Selector selector, | 2393 ir.Primitive buildInvocationMirror(Selector selector, |
2390 List<ir.Primitive> arguments) { | 2394 List<ir.Primitive> arguments) { |
2391 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); | 2395 return addPrimitive(new ir.CreateInvocationMirror(selector, arguments)); |
2392 } | 2396 } |
2393 | 2397 |
| 2398 ir.Primitive buildForeignCode(js.Template codeTemplate, |
| 2399 List<ir.Primitive> arguments, |
| 2400 NativeBehavior behavior, |
| 2401 {Element dependency}) { |
| 2402 types.TypeMask type = program.getTypeMaskForForeign(behavior); |
| 2403 if (codeTemplate.isExpression) { |
| 2404 return _continueWithExpression((k) => new ir.ForeignCode( |
| 2405 codeTemplate, |
| 2406 type, |
| 2407 arguments, |
| 2408 behavior, |
| 2409 continuation: k, |
| 2410 dependency: dependency)); |
| 2411 } else { |
| 2412 assert(isOpen); |
| 2413 add(new ir.ForeignCode(codeTemplate, type, arguments, behavior, |
| 2414 dependency: dependency)); |
| 2415 _current = null; |
| 2416 } |
| 2417 } |
| 2418 |
2394 @override | 2419 @override |
2395 ir.Primitive buildTypeOperator(ir.Primitive value, | 2420 ir.Primitive buildTypeOperator(ir.Primitive value, |
2396 DartType type, | 2421 DartType type, |
2397 {bool isTypeTest}) { | 2422 {bool isTypeTest}) { |
2398 assert(isOpen); | 2423 assert(isOpen); |
2399 assert(isTypeTest != null); | 2424 assert(isTypeTest != null); |
2400 | 2425 |
2401 type = program.unaliasType(type); | 2426 type = program.unaliasType(type); |
2402 | 2427 |
2403 if (type.isMalformed) { | 2428 if (type.isMalformed) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 final DartType type; | 2549 final DartType type; |
2525 final LocalVariableElement exceptionVariable; | 2550 final LocalVariableElement exceptionVariable; |
2526 final LocalVariableElement stackTraceVariable; | 2551 final LocalVariableElement stackTraceVariable; |
2527 final SubbuildFunction buildCatchBlock; | 2552 final SubbuildFunction buildCatchBlock; |
2528 | 2553 |
2529 CatchClauseInfo({this.type, | 2554 CatchClauseInfo({this.type, |
2530 this.exceptionVariable, | 2555 this.exceptionVariable, |
2531 this.stackTraceVariable, | 2556 this.stackTraceVariable, |
2532 this.buildCatchBlock}); | 2557 this.buildCatchBlock}); |
2533 } | 2558 } |
OLD | NEW |