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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1409033005: Add @anonymous annotation and restrict object literal constructors to only anonymous classes. This … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ptal Created 5 years, 2 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/js_interop_analysis.dart ('k') | pkg/js/lib/js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 58ea7cb5ff43060d73b5ac858bbc5d63289d85b6..be91b958f644db4e7aafc8efde84c29aea05c428 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -5843,6 +5843,12 @@ class SsaBuilder extends ast.Visitor
}
}
+ bool _hasNamedParameters(FunctionElement function) {
+ FunctionSignature params = function.functionSignature;
+ return params.optionalParameterCount > 0
+ && params.optionalParametersAreNamed;
+ }
+
HForeignCode invokeJsInteropFunction(Element element,
List<HInstruction> arguments,
SourceInformation sourceInformation) {
@@ -5850,9 +5856,10 @@ class SsaBuilder extends ast.Visitor
nativeEmitter.nativeMethods.add(element);
String templateString;
- if (element.isFactoryConstructor) {
- // Treat factory constructors as syntactic sugar for creating object
- // literals.
+ if (element.isFactoryConstructor &&
+ backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass)) {
+ // Factory constructor that is syntactic sugar for creating a JavaScript
+ // object literal.
ConstructorElement constructor = element;
FunctionSignature params = constructor.functionSignature;
int i = 0;
@@ -5863,13 +5870,6 @@ class SsaBuilder extends ast.Visitor
// TODO(jacobr): throw if parameter names do not match names of property
// names in the class.
assert (parameter.isNamed);
- if (!parameter.isNamed) {
- reporter.reportErrorMessage(
- parameter, MessageKind.GENERIC,
- {'text': 'All arguments to external constructors of JavaScript '
- 'interop classes must be named as these constructors '
- 'are syntactic sugar for object literals.'});
- }
HInstruction argument = arguments[i];
if (argument != null) {
filteredArguments.add(argument);
@@ -5908,10 +5908,14 @@ class SsaBuilder extends ast.Visitor
} else if (element.isSetter) {
codeTemplate = js.js.parseForeignJS("# = #");
} else {
+ FunctionElement function = element;
+ FunctionSignature params = function.functionSignature;
+
var argsStub = <String>[];
for (int i = 0; i < arguments.length; i++) {
argsStub.add('#');
}
+
if (element.isConstructor) {
codeTemplate = js.js.parseForeignJS("new #(${argsStub.join(",")})");
} else {
« no previous file with comments | « pkg/compiler/lib/src/js_backend/js_interop_analysis.dart ('k') | pkg/js/lib/js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698