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

Side by Side Diff: lib/src/checker/resolver.dart

Issue 962083002: support the JS builtin (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: formatting Created 5 years, 9 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Encapsulates how to invoke the analyzer resolver and overrides how it 5 /// Encapsulates how to invoke the analyzer resolver and overrides how it
6 /// computes types on expressions to use our restricted set of types. 6 /// computes types on expressions to use our restricted set of types.
7 library ddc.src.checker.resolver; 7 library ddc.src.checker.resolver;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // otherLib.visibleLibraries.contains(thisLib), however because we are not 356 // otherLib.visibleLibraries.contains(thisLib), however because we are not
357 // inferring type on any library that belongs to a cycle or that contains 357 // inferring type on any library that belongs to a cycle or that contains
358 // parts, we know that this cannot be true. 358 // parts, we know that this cannot be true.
359 return thisLib == otherLib; 359 return thisLib == otherLib;
360 } 360 }
361 361
362 @override // to propagate types to identifiers 362 @override // to propagate types to identifiers
363 visitMethodInvocation(MethodInvocation node) { 363 visitMethodInvocation(MethodInvocation node) {
364 // TODO(sigmund): follow up with analyzer team - why is this needed? 364 // TODO(sigmund): follow up with analyzer team - why is this needed?
365 visitSimpleIdentifier(node.methodName); 365 visitSimpleIdentifier(node.methodName);
366 return super.visitMethodInvocation(node); 366 super.visitMethodInvocation(node);
367
368 // Fix types for JS builtin calls.
369 // Analyzer has already computed them in the call above, we just need to
370 // save it as the method's static return type.
371 var e = node.methodName.staticElement;
372 if (e is FunctionElement &&
373 e.library.name == '_foreign_helper' &&
374 e.name == 'JS') {
375 node.staticType = node.propagatedType;
vsm 2015/02/27 17:20:05 We haven't been using propagatedType so far - not
Jennifer Messerly 2015/02/27 18:27:07 Analyzer is doing exactly the right logic: https:/
vsm 2015/02/27 18:39:31 I agree, it's doing the right logic right now. I'
Jennifer Messerly 2015/02/27 18:48:09 I'm super confused :| soundness -- what does that
vsm 2015/02/27 18:58:02 Sorry for belaboring the point. :-) Here's anoth
Jennifer Messerly 2015/02/27 19:24:48 ah, gotcha. yeah I see how someone could misunders
376 }
367 } 377 }
368 378
369 // Review note: no longer need to override visitFunctionExpression, this is 379 // Review note: no longer need to override visitFunctionExpression, this is
370 // handled by the analyzer internally. 380 // handled by the analyzer internally.
371 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? 381 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result?
372 // TODO(vsm): in visitConditionalExpression: check... LUB in rules? 382 // TODO(vsm): in visitConditionalExpression: check... LUB in rules?
373 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression 383 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression
374 // type in a (...) => expr or just the written type? 384 // type in a (...) => expr or just the written type?
375 385
376 } 386 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 element.returnType.isDynamic && 429 element.returnType.isDynamic &&
420 node.returnType == null) { 430 node.returnType == null) {
421 var type = searchTypeFor(element.enclosingElement.type, element); 431 var type = searchTypeFor(element.enclosingElement.type, element);
422 if (type != null && !type.returnType.isDynamic) { 432 if (type != null && !type.returnType.isDynamic) {
423 element.returnType = type.returnType; 433 element.returnType = type.returnType;
424 } 434 }
425 } 435 }
426 return res; 436 return res;
427 } 437 }
428 } 438 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | test/codegen/expect/_isolate_helper/_isolate_helper.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698