Chromium Code Reviews| 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) {' |