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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2587203002: Correct handling of cross-frame functions in ddc. (Closed)
Patch Set: Created 4 years 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
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 137c16e3485725f6dc062423f7c7c362b29e9180..46ddce3a113ef5075e19c3fb9df4dd2221d2b645 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -126,6 +126,7 @@ class CodeGenerator extends GeneralizingAstVisitor
final ClassElement numClass;
final ClassElement objectClass;
final ClassElement stringClass;
+ final ClassElement functionClass;
final ClassElement symbolClass;
ConstFieldVisitor _constants;
@@ -171,6 +172,7 @@ class CodeGenerator extends GeneralizingAstVisitor
nullClass = _getLibrary(c, 'dart:core').getType('Null'),
objectClass = _getLibrary(c, 'dart:core').getType('Object'),
stringClass = _getLibrary(c, 'dart:core').getType('String'),
+ functionClass = _getLibrary(c, 'dart:core').getType('Function'),
symbolClass = _getLibrary(c, 'dart:_internal').getType('Symbol'),
dartJSLibrary = _getLibrary(c, 'dart:js');
@@ -930,6 +932,25 @@ class CodeGenerator extends GeneralizingAstVisitor
[className, _runtimeModule, className]));
return;
}
+ if (classElem == functionClass) {
+ body.add(js.statement(
+ '#.is = function is_Function(o) { return typeof o == "function"; }',
Leaf 2016/12/19 22:42:56 Does this do the right thing for classes with call
Jacob 2016/12/19 22:53:33 Yes because classes with call methods have to be i
+ className));
+ body.add(js.statement(
+ '#.as = function as_Function(o) {'
+ ' if (typeof o == "function" || o == null) return o;'
+ ' return #.as(o, #);'
+ '}',
+ [className, _runtimeModule, className]));
+ body.add(js.statement(
+ '#._check = function check_String(o) {'
+ ' if (typeof o == "function" || o == null) return o;'
+ ' return #.check(o, #);'
+ '}',
+ [className, _runtimeModule, className]));
+ return;
+ }
+
if (classElem == intClass) {
body.add(js.statement(
'#.is = function is_int(o) {'

Powered by Google App Engine
This is Rietveld 408576698