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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1642493002: Add type info to JSArray. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: array changes Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../closure.dart' show 9 import '../../closure.dart' show
10 ClosureClassElement; 10 ClosureClassElement;
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 ClassElement classElement = node.classElement; 820 ClassElement classElement = node.classElement;
821 // TODO(asgerf): To allow inlining of InvokeConstructor, CreateInstance must 821 // TODO(asgerf): To allow inlining of InvokeConstructor, CreateInstance must
822 // carry a DartType so we can register the instantiated type 822 // carry a DartType so we can register the instantiated type
823 // with its type arguments. Otherwise dataflow analysis is 823 // with its type arguments. Otherwise dataflow analysis is
824 // needed to reconstruct the instantiated type. 824 // needed to reconstruct the instantiated type.
825 registry.registerInstantiation(classElement.rawType); 825 registry.registerInstantiation(classElement.rawType);
826 if (classElement is ClosureClassElement) { 826 if (classElement is ClosureClassElement) {
827 registry.registerInstantiatedClosure(classElement.methodElement); 827 registry.registerInstantiatedClosure(classElement.methodElement);
828 } 828 }
829 js.Expression instance = new js.New( 829 js.Expression instance = new js.New(
830 glue.constructorAccess(classElement), 830 glue.constructorAccess(classElement),
831 visitExpressionList(node.arguments)) 831 visitExpressionList(node.arguments))
832 .withSourceInformation(node.sourceInformation); 832 .withSourceInformation(node.sourceInformation);
833 833
834 List<tree_ir.Expression> typeInformation = node.typeInformation; 834 tree_ir.Expression typeInformation = node.typeInformation;
835 assert(typeInformation.isEmpty || 835 if (typeInformation != null) {
836 typeInformation.length == classElement.typeVariables.length);
837 if (typeInformation.isNotEmpty) {
838 FunctionElement helper = glue.getAddRuntimeTypeInformation(); 836 FunctionElement helper = glue.getAddRuntimeTypeInformation();
839 js.Expression typeArguments = new js.ArrayInitializer( 837 js.Expression typeArguments = visitExpression(typeInformation);
840 visitExpressionList(typeInformation));
841 return buildStaticHelperInvocation(helper, 838 return buildStaticHelperInvocation(helper,
842 <js.Expression>[instance, typeArguments], 839 <js.Expression>[instance, typeArguments],
843 sourceInformation: node.sourceInformation); 840 sourceInformation: node.sourceInformation);
844 } else { 841 } else {
845 return instance; 842 return instance;
846 } 843 }
847 } 844 }
848 845
849 @override 846 @override
850 js.Expression visitCreateInvocationMirror( 847 js.Expression visitCreateInvocationMirror(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 return buildStaticHelperInvocation( 979 return buildStaticHelperInvocation(
983 glue.getTypeArgumentByIndex(), 980 glue.getTypeArgumentByIndex(),
984 [visitExpression(node.target), index], 981 [visitExpression(node.target), index],
985 sourceInformation: node.sourceInformation); 982 sourceInformation: node.sourceInformation);
986 } 983 }
987 } 984 }
988 985
989 @override 986 @override
990 js.Expression visitTypeExpression(tree_ir.TypeExpression node) { 987 js.Expression visitTypeExpression(tree_ir.TypeExpression node) {
991 List<js.Expression> arguments = visitExpressionList(node.arguments); 988 List<js.Expression> arguments = visitExpressionList(node.arguments);
992 return glue.generateTypeRepresentation(node.dartType, arguments, registry); 989 switch (node.kind) {
990 case tree_ir.TypeExpressionKind.COMPLETE:
991 return glue.generateTypeRepresentation(
992 node.dartType, arguments, registry);
993 case tree_ir.TypeExpressionKind.INSTANCE:
994 registry.registerInstantiatedClass(glue.listClass);
995 return new js.ArrayInitializer(arguments);
996 }
993 } 997 }
994 998
995 js.Node handleForeignCode(tree_ir.ForeignCode node) { 999 js.Node handleForeignCode(tree_ir.ForeignCode node) {
996 if (node.dependency != null) { 1000 if (node.dependency != null) {
997 // Dependency is only used if [node] calls a Dart function. Currently only 1001 // Dependency is only used if [node] calls a Dart function. Currently only
998 // through foreign function `RAW_DART_FUNCTION_REF`. 1002 // through foreign function `RAW_DART_FUNCTION_REF`.
999 registry.registerStaticUse( 1003 registry.registerStaticUse(
1000 new StaticUse.staticInvoke( 1004 new StaticUse.staticInvoke(
1001 node.dependency, 1005 node.dependency,
1002 new CallStructure.unnamed(node.arguments.length))); 1006 new CallStructure.unnamed(node.arguments.length)));
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 void registerDefaultParameterValues(ExecutableElement element) { 1231 void registerDefaultParameterValues(ExecutableElement element) {
1228 if (element is! FunctionElement) return; 1232 if (element is! FunctionElement) return;
1229 FunctionElement function = element; 1233 FunctionElement function = element;
1230 if (function.isStatic) return; // Defaults are inlined at call sites. 1234 if (function.isStatic) return; // Defaults are inlined at call sites.
1231 function.functionSignature.forEachOptionalParameter((param) { 1235 function.functionSignature.forEachOptionalParameter((param) {
1232 ConstantValue constant = glue.getDefaultParameterValue(param); 1236 ConstantValue constant = glue.getDefaultParameterValue(param);
1233 registry.registerCompileTimeConstant(constant); 1237 registry.registerCompileTimeConstant(constant);
1234 }); 1238 });
1235 } 1239 }
1236 } 1240 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698