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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes and further implementation. Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart b/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
index a336f32f8834e4aff0f880e9716c488243b1e7f8..76a8a8ceec8e78456b71af459fbdd50d6c8029d9 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/type_variable_handler.dart
@@ -65,27 +65,42 @@ class TypeVariableHandler {
List<int> constants = <int>[];
for (TypeVariableType currentTypeVariable in cls.typeVariables) {
- List<Constant> createArguments(FunctionElement constructor) {
- if (constructor != typeVariableConstructor) {
- compiler.internalError(currentTypeVariable.element,
- 'Unexpected constructor $constructor');
- }
- Constant name = backend.constantSystem.createString(
- new DartString.literal(currentTypeVariable.name));
- Constant bound = backend.constantSystem.createInt(
- emitter.reifyType(currentTypeVariable.element.bound));
- Constant type = backend.constants.createTypeConstant(cls);
- return [type, name, bound];
+ TypeVariableElement typeVariableElement = currentTypeVariable.element;
+
+ AstConstant wrapConstant(ConstExp constant) {
+ return new AstConstant(typeVariableElement,
+ typeVariableElement.node,
+ constant);
}
- Constant c = CompileTimeConstantEvaluator.makeConstructedConstant(
- compiler, backend.constants,
- currentTypeVariable.element, typeVariableType,
- typeVariableConstructor, createArguments);
- backend.registerCompileTimeConstant(c, compiler.globalDependencies);
- backend.constants.addCompileTimeConstantForEmission(c);
+ ConstExp name = new PrimitiveConstExp(
+ backend.constantSystem.createString(
+ new DartString.literal(currentTypeVariable.name)));
+ ConstExp bound = new PrimitiveConstExp(
+ backend.constantSystem.createInt(
+ emitter.reifyType(typeVariableElement.bound)));
+ ConstExp type = backend.constants.createTypeConstant(cls);
+ List<AstConstant> arguments =
+ [wrapConstant(type), wrapConstant(name), wrapConstant(bound)];
+
+ // TODO(johnniwinther): Support a less front-end specific creation of
+ // constructed constants.
+ AstConstant constant =
+ CompileTimeConstantEvaluator.makeConstructedConstant(
+ compiler,
+ backend.constants,
+ typeVariableElement,
+ typeVariableElement.node,
+ typeVariableType,
+ typeVariableConstructor,
+ new Selector.callConstructor('', null, 3),
+ arguments,
+ arguments);
+ Constant value = constant.value;
+ backend.registerCompileTimeConstant(value, compiler.globalDependencies);
+ backend.constants.addCompileTimeConstantForEmission(value);
constants.add(
- reifyTypeVariableConstant(c, currentTypeVariable.element));
+ reifyTypeVariableConstant(value, currentTypeVariable.element));
}
typeVariables[cls] = constants;
}

Powered by Google App Engine
This is Rietveld 408576698