| OLD | NEW |
| 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart'; | 7 import 'package:js_runtime/shared/embedded_names.dart'; |
| 8 | 8 |
| 9 import '../closure.dart'; | 9 import '../closure.dart'; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 {'text': 'Error: Extra argument to JS_GET_FLAG.'}); | 2701 {'text': 'Error: Extra argument to JS_GET_FLAG.'}); |
| 2702 } | 2702 } |
| 2703 return; | 2703 return; |
| 2704 } | 2704 } |
| 2705 ast.LiteralString string = argument.asLiteralString(); | 2705 ast.LiteralString string = argument.asLiteralString(); |
| 2706 if (string == null) { | 2706 if (string == null) { |
| 2707 reporter.reportErrorMessage(argument, MessageKind.GENERIC, | 2707 reporter.reportErrorMessage(argument, MessageKind.GENERIC, |
| 2708 {'text': 'Error: Expected a literal string.'}); | 2708 {'text': 'Error: Expected a literal string.'}); |
| 2709 } | 2709 } |
| 2710 String name = string.dartString.slowToString(); | 2710 String name = string.dartString.slowToString(); |
| 2711 bool value = false; | 2711 bool value = getFlagValue(name); |
| 2712 switch (name) { | 2712 if (value == null) { |
| 2713 case 'MUST_RETAIN_METADATA': | 2713 reporter.reportErrorMessage(node, MessageKind.GENERIC, |
| 2714 value = mirrorsData.mustRetainMetadata; | 2714 {'text': 'Error: Unknown internal flag "$name".'}); |
| 2715 break; | 2715 } else { |
| 2716 case 'USE_CONTENT_SECURITY_POLICY': | 2716 stack.add(graph.addConstantBool(value, closedWorld)); |
| 2717 value = options.useContentSecurityPolicy; | |
| 2718 break; | |
| 2719 default: | |
| 2720 reporter.reportErrorMessage(node, MessageKind.GENERIC, | |
| 2721 {'text': 'Error: Unknown internal flag "$name".'}); | |
| 2722 } | 2717 } |
| 2723 stack.add(graph.addConstantBool(value, closedWorld)); | |
| 2724 } | 2718 } |
| 2725 | 2719 |
| 2726 void handleForeignJsGetName(ast.Send node) { | 2720 void handleForeignJsGetName(ast.Send node) { |
| 2727 List<ast.Node> arguments = node.arguments.toList(); | 2721 List<ast.Node> arguments = node.arguments.toList(); |
| 2728 ast.Node argument; | 2722 ast.Node argument; |
| 2729 switch (arguments.length) { | 2723 switch (arguments.length) { |
| 2730 case 0: | 2724 case 0: |
| 2731 reporter.reportErrorMessage(node, MessageKind.GENERIC, | 2725 reporter.reportErrorMessage(node, MessageKind.GENERIC, |
| 2732 {'text': 'Error: Expected one argument to JS_GET_NAME.'}); | 2726 {'text': 'Error: Expected one argument to JS_GET_NAME.'}); |
| 2733 return; | 2727 return; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2982 SourceInformation sourceInformation) { | 2976 SourceInformation sourceInformation) { |
| 2983 // Until now we only handle these as getters. | 2977 // Until now we only handle these as getters. |
| 2984 invariant(node, deferredLoader.isDeferredLoaderGetter); | 2978 invariant(node, deferredLoader.isDeferredLoaderGetter); |
| 2985 FunctionEntity loadFunction = commonElements.loadLibraryWrapper; | 2979 FunctionEntity loadFunction = commonElements.loadLibraryWrapper; |
| 2986 PrefixElement prefixElement = deferredLoader.enclosingElement; | 2980 PrefixElement prefixElement = deferredLoader.enclosingElement; |
| 2987 String loadId = deferredLoadTask.getImportDeferName(node, prefixElement); | 2981 String loadId = deferredLoadTask.getImportDeferName(node, prefixElement); |
| 2988 var inputs = [ | 2982 var inputs = [ |
| 2989 graph.addConstantString(new ast.DartString.literal(loadId), closedWorld) | 2983 graph.addConstantString(new ast.DartString.literal(loadId), closedWorld) |
| 2990 ]; | 2984 ]; |
| 2991 push(new HInvokeStatic(loadFunction, inputs, commonMasks.nonNullType, | 2985 push(new HInvokeStatic(loadFunction, inputs, commonMasks.nonNullType, |
| 2992 targetCanThrow: false) | 2986 targetCanThrow: false)..sourceInformation = sourceInformation); |
| 2993 ..sourceInformation = sourceInformation); | |
| 2994 } | 2987 } |
| 2995 | 2988 |
| 2996 generateSuperNoSuchMethodSend( | 2989 generateSuperNoSuchMethodSend( |
| 2997 ast.Send node, Selector selector, List<HInstruction> arguments) { | 2990 ast.Send node, Selector selector, List<HInstruction> arguments) { |
| 2998 String name = selector.name; | 2991 String name = selector.name; |
| 2999 | 2992 |
| 3000 ClassElement cls = currentNonClosureClass; | 2993 ClassElement cls = currentNonClosureClass; |
| 3001 MethodElement element = cls.lookupSuperMember(Identifiers.noSuchMethod_); | 2994 MethodElement element = cls.lookupSuperMember(Identifiers.noSuchMethod_); |
| 3002 if (!Selectors.noSuchMethod_.signatureApplies(element)) { | 2995 if (!Selectors.noSuchMethod_.signatureApplies(element)) { |
| 3003 ClassElement objectClass = commonElements.objectClass; | 2996 ClassElement objectClass = commonElements.objectClass; |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4079 } else if (element.isSetter) { | 4072 } else if (element.isSetter) { |
| 4080 code = "# = #"; | 4073 code = "# = #"; |
| 4081 } else { | 4074 } else { |
| 4082 var args = new List.filled(arguments.length, '#').join(','); | 4075 var args = new List.filled(arguments.length, '#').join(','); |
| 4083 code = element.isConstructor ? "new #($args)" : "#($args)"; | 4076 code = element.isConstructor ? "new #($args)" : "#($args)"; |
| 4084 } | 4077 } |
| 4085 js.Template codeTemplate = js.js.parseForeignJS(code); | 4078 js.Template codeTemplate = js.js.parseForeignJS(code); |
| 4086 nativeBehavior.codeTemplate = codeTemplate; | 4079 nativeBehavior.codeTemplate = codeTemplate; |
| 4087 | 4080 |
| 4088 return new HForeignCode(codeTemplate, commonMasks.dynamicType, inputs, | 4081 return new HForeignCode(codeTemplate, commonMasks.dynamicType, inputs, |
| 4089 nativeBehavior: nativeBehavior) | 4082 nativeBehavior: nativeBehavior)..sourceInformation = sourceInformation; |
| 4090 ..sourceInformation = sourceInformation; | |
| 4091 } | 4083 } |
| 4092 | 4084 |
| 4093 void pushInvokeStatic( | 4085 void pushInvokeStatic( |
| 4094 ast.Node location, MethodElement element, List<HInstruction> arguments, | 4086 ast.Node location, MethodElement element, List<HInstruction> arguments, |
| 4095 {TypeMask typeMask, | 4087 {TypeMask typeMask, |
| 4096 ResolutionInterfaceType instanceType, | 4088 ResolutionInterfaceType instanceType, |
| 4097 SourceInformation sourceInformation}) { | 4089 SourceInformation sourceInformation}) { |
| 4098 assert(element.isDeclaration); | 4090 assert(element.isDeclaration); |
| 4099 // TODO(johnniwinther): Use [sourceInformation] instead of [location]. | 4091 // TODO(johnniwinther): Use [sourceInformation] instead of [location]. |
| 4100 if (tryInlineMethod(element, null, null, arguments, location, | 4092 if (tryInlineMethod(element, null, null, arguments, location, |
| (...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6746 this.oldReturnLocal, | 6738 this.oldReturnLocal, |
| 6747 this.oldReturnType, | 6739 this.oldReturnType, |
| 6748 this.oldResolvedAst, | 6740 this.oldResolvedAst, |
| 6749 this.oldStack, | 6741 this.oldStack, |
| 6750 this.oldLocalsHandler, | 6742 this.oldLocalsHandler, |
| 6751 this.inTryStatement, | 6743 this.inTryStatement, |
| 6752 this.allFunctionsCalledOnce, | 6744 this.allFunctionsCalledOnce, |
| 6753 this.oldElementInferenceResults) | 6745 this.oldElementInferenceResults) |
| 6754 : super(function); | 6746 : super(function); |
| 6755 } | 6747 } |
| OLD | NEW |