| 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 '../closure.dart' as closure; | 7 import '../closure.dart' as closure; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/names.dart' show | 9 import '../common/names.dart' show |
| 10 Names, | 10 Names, |
| (...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 value = buildThis(); | 2404 value = buildThis(); |
| 2405 } else if (field.local is closure.TypeVariableLocal) { | 2405 } else if (field.local is closure.TypeVariableLocal) { |
| 2406 closure.TypeVariableLocal variable = field.local; | 2406 closure.TypeVariableLocal variable = field.local; |
| 2407 value = buildTypeVariableAccess(variable.typeVariable); | 2407 value = buildTypeVariableAccess(variable.typeVariable); |
| 2408 } else { | 2408 } else { |
| 2409 value = environment.lookup(field.local); | 2409 value = environment.lookup(field.local); |
| 2410 } | 2410 } |
| 2411 arguments.add(value); | 2411 arguments.add(value); |
| 2412 } | 2412 } |
| 2413 return addPrimitive(new ir.CreateInstance( | 2413 return addPrimitive(new ir.CreateInstance( |
| 2414 classElement, arguments, const <ir.Primitive>[], sourceInformation)); | 2414 classElement, arguments, null, sourceInformation)); |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 /// Create a read access of [local] function, variable, or parameter. | 2417 /// Create a read access of [local] function, variable, or parameter. |
| 2418 ir.Primitive buildLocalGet(LocalElement local) { | 2418 ir.Primitive buildLocalGet(LocalElement local) { |
| 2419 assert(isOpen); | 2419 assert(isOpen); |
| 2420 ClosureLocation location = state.boxedVariables[local]; | 2420 ClosureLocation location = state.boxedVariables[local]; |
| 2421 if (location != null) { | 2421 if (location != null) { |
| 2422 ir.Primitive result = new ir.GetField(environment.lookup(location.box), | 2422 ir.Primitive result = new ir.GetField(environment.lookup(location.box), |
| 2423 location.field); | 2423 location.field); |
| 2424 result.useElementAsHint(local); | 2424 result.useElementAsHint(local); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2548 SourceInformation sourceInformation, | 2548 SourceInformation sourceInformation, |
| 2549 {TypeMask allocationSiteType}) { | 2549 {TypeMask allocationSiteType}) { |
| 2550 assert(isOpen); | 2550 assert(isOpen); |
| 2551 Selector selector = | 2551 Selector selector = |
| 2552 new Selector(SelectorKind.CALL, element.memberName, callStructure); | 2552 new Selector(SelectorKind.CALL, element.memberName, callStructure); |
| 2553 ClassElement cls = element.enclosingClass; | 2553 ClassElement cls = element.enclosingClass; |
| 2554 if (program.requiresRuntimeTypesFor(cls)) { | 2554 if (program.requiresRuntimeTypesFor(cls)) { |
| 2555 InterfaceType interface = type; | 2555 InterfaceType interface = type; |
| 2556 Iterable<ir.Primitive> typeArguments = | 2556 Iterable<ir.Primitive> typeArguments = |
| 2557 interface.typeArguments.map((DartType argument) { | 2557 interface.typeArguments.map((DartType argument) { |
| 2558 return type.treatAsRaw | 2558 return type.treatAsRaw |
| 2559 ? buildNullConstant() | 2559 ? buildNullConstant() |
| 2560 : buildTypeExpression(argument); | 2560 : buildTypeExpression(argument); |
| 2561 }); | 2561 }); |
| 2562 arguments = new List<ir.Primitive>.from(arguments) | 2562 arguments = new List<ir.Primitive>.from(arguments) |
| 2563 ..addAll(typeArguments); | 2563 ..addAll(typeArguments); |
| 2564 } | 2564 } |
| 2565 return addPrimitive(new ir.InvokeConstructor( | 2565 return addPrimitive(new ir.InvokeConstructor( |
| 2566 type, element, selector, arguments, sourceInformation, | 2566 type, element, selector, arguments, sourceInformation, |
| 2567 allocationSiteType: allocationSiteType)); | 2567 allocationSiteType: allocationSiteType)); |
| 2568 } | 2568 } |
| 2569 | 2569 |
| 2570 ir.Primitive buildTypeExpression(DartType type) { | 2570 ir.Primitive buildTypeExpression(DartType type) { |
| 2571 type = program.unaliasType(type); | 2571 type = program.unaliasType(type); |
| 2572 if (type is TypeVariableType) { | 2572 if (type is TypeVariableType) { |
| 2573 return buildTypeVariableAccess(type); | 2573 return buildTypeVariableAccess(type); |
| 2574 } else if (type is InterfaceType || type is FunctionType) { | 2574 } else if (type is InterfaceType || type is FunctionType) { |
| 2575 List<ir.Primitive> arguments = <ir.Primitive>[]; | 2575 List<ir.Primitive> arguments = <ir.Primitive>[]; |
| 2576 type.forEachTypeVariable((TypeVariableType variable) { | 2576 type.forEachTypeVariable((TypeVariableType variable) { |
| 2577 ir.Primitive value = buildTypeVariableAccess(variable); | 2577 ir.Primitive value = buildTypeVariableAccess(variable); |
| 2578 arguments.add(value); | 2578 arguments.add(value); |
| 2579 }); | 2579 }); |
| 2580 return addPrimitive(new ir.TypeExpression(type, arguments)); | 2580 return addPrimitive(new ir.TypeExpression(ir.TypeExpressionKind.COMPLETE, |
| 2581 type, arguments)); |
| 2581 } else if (type.treatAsDynamic) { | 2582 } else if (type.treatAsDynamic) { |
| 2582 return buildNullConstant(); | 2583 return buildNullConstant(); |
| 2583 } else { | 2584 } else { |
| 2584 // TypedefType can reach here, and possibly other things. | 2585 // TypedefType can reach here, and possibly other things. |
| 2585 throw 'unimplemented translation of type expression $type (${type.kind})'; | 2586 throw 'unimplemented translation of type expression $type (${type.kind})'; |
| 2586 } | 2587 } |
| 2587 } | 2588 } |
| 2588 | 2589 |
| 2589 /// Obtains the internal type representation of the type held in [variable]. | 2590 /// Obtains the internal type representation of the type held in [variable]. |
| 2590 /// | 2591 /// |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 this.stackTraceVariable, | 2843 this.stackTraceVariable, |
| 2843 this.buildCatchBlock}); | 2844 this.buildCatchBlock}); |
| 2844 } | 2845 } |
| 2845 | 2846 |
| 2846 class SwitchCaseInfo { | 2847 class SwitchCaseInfo { |
| 2847 final SubbuildFunction buildCondition; | 2848 final SubbuildFunction buildCondition; |
| 2848 final SubbuildFunction buildBody; | 2849 final SubbuildFunction buildBody; |
| 2849 | 2850 |
| 2850 SwitchCaseInfo(this.buildCondition, this.buildBody); | 2851 SwitchCaseInfo(this.buildCondition, this.buildBody); |
| 2851 } | 2852 } |
| OLD | NEW |