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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_backend; 5 part of js_backend;
6 6
7 class JavaScriptItemCompilationContext extends ItemCompilationContext { 7 class JavaScriptItemCompilationContext extends ItemCompilationContext {
8 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 8 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
9 final Set<HInstruction> allocatedFixedLists = new Set<HInstruction>(); 9 final Set<HInstruction> allocatedFixedLists = new Set<HInstruction>();
10 } 10 }
(...skipping 17 matching lines...) Expand all
28 return new jsAst.Call(new jsAst.VariableUse(helperName), arguments); 28 return new jsAst.Call(new jsAst.VariableUse(helperName), arguments);
29 } 29 }
30 30
31 void generateAdditionalArguments(SsaCodeGenerator codegen, 31 void generateAdditionalArguments(SsaCodeGenerator codegen,
32 HTypeConversion node, 32 HTypeConversion node,
33 List<jsAst.Expression> arguments) { 33 List<jsAst.Expression> arguments) {
34 // No additional arguments needed. 34 // No additional arguments needed.
35 } 35 }
36 } 36 }
37 37
38 class MalformedCheckedModeHelper extends CheckedModeHelper {
39 const MalformedCheckedModeHelper(String name) : super(name);
40
41 void generateAdditionalArguments(SsaCodeGenerator codegen,
42 HTypeConversion node,
43 List<jsAst.Expression> arguments) {
44 ErroneousElement element = node.typeExpression.element;
45 arguments.add(js.string(element.message));
46 }
47 }
48
38 class PropertyCheckedModeHelper extends CheckedModeHelper { 49 class PropertyCheckedModeHelper extends CheckedModeHelper {
39 const PropertyCheckedModeHelper(String name) : super(name); 50 const PropertyCheckedModeHelper(String name) : super(name);
40 51
41 void generateAdditionalArguments(SsaCodeGenerator codegen, 52 void generateAdditionalArguments(SsaCodeGenerator codegen,
42 HTypeConversion node, 53 HTypeConversion node,
43 List<jsAst.Expression> arguments) { 54 List<jsAst.Expression> arguments) {
44 DartType type = node.typeExpression; 55 DartType type = node.typeExpression;
45 String additionalArgument = codegen.backend.namer.operatorIsType(type); 56 String additionalArgument = codegen.backend.namer.operatorIsType(type);
46 arguments.add(js.string(additionalArgument)); 57 arguments.add(js.string(additionalArgument));
47 } 58 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 342
332 /// List of elements that the backend may use. 343 /// List of elements that the backend may use.
333 final Set<Element> helpersUsed = new Set<Element>(); 344 final Set<Element> helpersUsed = new Set<Element>();
334 345
335 346
336 /// Set of typedefs that are used as type literals. 347 /// Set of typedefs that are used as type literals.
337 final Set<TypedefElement> typedefTypeLiterals = new Set<TypedefElement>(); 348 final Set<TypedefElement> typedefTypeLiterals = new Set<TypedefElement>();
338 349
339 /// All the checked mode helpers. 350 /// All the checked mode helpers.
340 static const checkedModeHelpers = const [ 351 static const checkedModeHelpers = const [
352 const MalformedCheckedModeHelper('checkMalformedType'),
341 const CheckedModeHelper('voidTypeCheck'), 353 const CheckedModeHelper('voidTypeCheck'),
342 const CheckedModeHelper('stringTypeCast'), 354 const CheckedModeHelper('stringTypeCast'),
343 const CheckedModeHelper('stringTypeCheck'), 355 const CheckedModeHelper('stringTypeCheck'),
344 const CheckedModeHelper('doubleTypeCast'), 356 const CheckedModeHelper('doubleTypeCast'),
345 const CheckedModeHelper('doubleTypeCheck'), 357 const CheckedModeHelper('doubleTypeCheck'),
346 const CheckedModeHelper('numTypeCast'), 358 const CheckedModeHelper('numTypeCast'),
347 const CheckedModeHelper('numTypeCheck'), 359 const CheckedModeHelper('numTypeCheck'),
348 const CheckedModeHelper('boolTypeCast'), 360 const CheckedModeHelper('boolTypeCast'),
349 const CheckedModeHelper('boolTypeCheck'), 361 const CheckedModeHelper('boolTypeCheck'),
350 const CheckedModeHelper('intTypeCast'), 362 const CheckedModeHelper('intTypeCast'),
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 enqueue(world, helper.getElement(compiler), elements); 993 enqueue(world, helper.getElement(compiler), elements);
982 } 994 }
983 // We also need the native variant of the check (for DOM types). 995 // We also need the native variant of the check (for DOM types).
984 helper = getNativeCheckedModeHelper(type, typeCast: false); 996 helper = getNativeCheckedModeHelper(type, typeCast: false);
985 if (helper != null) { 997 if (helper != null) {
986 enqueue(world, helper.getElement(compiler), elements); 998 enqueue(world, helper.getElement(compiler), elements);
987 } 999 }
988 } 1000 }
989 } 1001 }
990 bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE; 1002 bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE;
1003 if (type.kind == TypeKind.MALFORMED_TYPE) {
1004 enqueueInResolution(getThrowTypeError(), elements);
1005 }
991 if (!type.treatAsRaw || type.containsTypeVariables) { 1006 if (!type.treatAsRaw || type.containsTypeVariables) {
992 enqueueInResolution(getSetRuntimeTypeInfo(), elements); 1007 enqueueInResolution(getSetRuntimeTypeInfo(), elements);
993 enqueueInResolution(getGetRuntimeTypeInfo(), elements); 1008 enqueueInResolution(getGetRuntimeTypeInfo(), elements);
994 enqueueInResolution(getGetRuntimeTypeArgument(), elements); 1009 enqueueInResolution(getGetRuntimeTypeArgument(), elements);
995 if (inCheckedMode) { 1010 if (inCheckedMode) {
996 enqueueInResolution(getAssertSubtype(), elements); 1011 enqueueInResolution(getAssertSubtype(), elements);
997 } 1012 }
998 enqueueInResolution(getCheckSubtype(), elements); 1013 enqueueInResolution(getCheckSubtype(), elements);
999 if (isTypeVariable) { 1014 if (isTypeVariable) {
1000 enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements); 1015 enqueueInResolution(getCheckSubtypeOfRuntimeType(), elements);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 if (name == null) return null; 1331 if (name == null) return null;
1317 CheckedModeHelper helper = checkedModeHelperByName[name]; 1332 CheckedModeHelper helper = checkedModeHelperByName[name];
1318 assert(helper != null); 1333 assert(helper != null);
1319 return helper; 1334 return helper;
1320 } 1335 }
1321 1336
1322 String getCheckedModeHelperNameInternal(DartType type, 1337 String getCheckedModeHelperNameInternal(DartType type,
1323 {bool typeCast, 1338 {bool typeCast,
1324 bool nativeCheckOnly}) { 1339 bool nativeCheckOnly}) {
1325 assert(type.kind != TypeKind.TYPEDEF); 1340 assert(type.kind != TypeKind.TYPEDEF);
1341 if (type.kind == TypeKind.MALFORMED_TYPE) {
1342 // The same error is thrown for type test and type cast of a malformed
1343 // type so we only need one check method.
1344 return 'checkMalformedType';
1345 }
1326 Element element = type.element; 1346 Element element = type.element;
1327 bool nativeCheck = nativeCheckOnly || 1347 bool nativeCheck = nativeCheckOnly ||
1328 emitter.nativeEmitter.requiresNativeIsCheck(element); 1348 emitter.nativeEmitter.requiresNativeIsCheck(element);
1329 1349
1330 // TODO(13955), TODO(9731). The test for non-primitive types should use an 1350 // TODO(13955), TODO(9731). The test for non-primitive types should use an
1331 // interceptor. The interceptor should be an argument to HTypeConversion so 1351 // interceptor. The interceptor should be an argument to HTypeConversion so
1332 // that it can be optimized by standard interceptor optimizations. 1352 // that it can be optimized by standard interceptor optimizations.
1333 nativeCheck = true; 1353 nativeCheck = true;
1334 1354
1335 if (type == compiler.types.voidType) { 1355 if (type == compiler.types.voidType) {
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 copy(constant.values); 1880 copy(constant.values);
1861 copy(constant.protoValue); 1881 copy(constant.protoValue);
1862 copy(constant); 1882 copy(constant);
1863 } 1883 }
1864 1884
1865 void visitConstructed(ConstructedConstant constant) { 1885 void visitConstructed(ConstructedConstant constant) {
1866 copy(constant.fields); 1886 copy(constant.fields);
1867 copy(constant); 1887 copy(constant);
1868 } 1888 }
1869 } 1889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698