| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class ClassStubGenerator { | 7 class ClassStubGenerator { |
| 8 final Namer namer; | 8 final Namer namer; |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 final JavaScriptBackend backend; | 10 final JavaScriptBackend backend; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 #internalName, | 162 #internalName, |
| 163 #type, | 163 #type, |
| 164 #arguments, | 164 #arguments, |
| 165 #namedArguments))''', | 165 #namedArguments))''', |
| 166 {'receiver': isIntercepted ? r'$receiver' : 'this', | 166 {'receiver': isIntercepted ? r'$receiver' : 'this', |
| 167 'noSuchMethodName': namer.noSuchMethodName, | 167 'noSuchMethodName': namer.noSuchMethodName, |
| 168 'createInvocationMirror': | 168 'createInvocationMirror': |
| 169 backend.emitter.staticFunctionAccess( | 169 backend.emitter.staticFunctionAccess( |
| 170 backend.helpers.createInvocationMirror), | 170 backend.helpers.createInvocationMirror), |
| 171 'methodName': | 171 'methodName': |
| 172 js.quoteName(compiler.enableMinification | 172 js.quoteName(compiler.options.enableMinification |
| 173 ? internalName : methodName), | 173 ? internalName : methodName), |
| 174 'internalName': js.quoteName(internalName), | 174 'internalName': js.quoteName(internalName), |
| 175 'type': js.number(type), | 175 'type': js.number(type), |
| 176 'arguments': | 176 'arguments': |
| 177 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), | 177 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), |
| 178 'namedArguments': new jsAst.ArrayInitializer(argNames)}); | 178 'namedArguments': new jsAst.ArrayInitializer(argNames)}); |
| 179 | 179 |
| 180 jsAst.Expression function; | 180 jsAst.Expression function; |
| 181 if (isIntercepted) { | 181 if (isIntercepted) { |
| 182 function = js(r'function($receiver, #) { return # }', | 182 function = js(r'function($receiver, #) { return # }', |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } else { | 220 } else { |
| 221 // Default values for mocked-up test libraries. | 221 // Default values for mocked-up test libraries. |
| 222 tearOffAccessExpression = js( | 222 tearOffAccessExpression = js( |
| 223 r'''function() { throw "Helper 'closureFromTearOff' missing." }'''); | 223 r'''function() { throw "Helper 'closureFromTearOff' missing." }'''); |
| 224 tearOffGlobalObjectString = js.string('MissingHelperFunction'); | 224 tearOffGlobalObjectString = js.string('MissingHelperFunction'); |
| 225 tearOffGlobalObject = js( | 225 tearOffGlobalObject = js( |
| 226 r'''(function() { throw "Helper 'closureFromTearOff' missing." })()'''); | 226 r'''(function() { throw "Helper 'closureFromTearOff' missing." })()'''); |
| 227 } | 227 } |
| 228 | 228 |
| 229 jsAst.Statement tearOffGetter; | 229 jsAst.Statement tearOffGetter; |
| 230 if (!compiler.useContentSecurityPolicy) { | 230 if (!compiler.options.useContentSecurityPolicy) { |
| 231 jsAst.Expression tearOffAccessText = | 231 jsAst.Expression tearOffAccessText = |
| 232 new jsAst.UnparsedNode(tearOffAccessExpression, compiler, false); | 232 new jsAst.UnparsedNode(tearOffAccessExpression, compiler, false); |
| 233 tearOffGetter = js.statement(''' | 233 tearOffGetter = js.statement(''' |
| 234 function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) { | 234 function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) { |
| 235 return isIntercepted | 235 return isIntercepted |
| 236 ? new Function("funcs", "reflectionInfo", "name", | 236 ? new Function("funcs", "reflectionInfo", "name", |
| 237 #tearOffGlobalObjectString, "c", | 237 #tearOffGlobalObjectString, "c", |
| 238 "return function tearOff_" + name + (functionCounter++) + "(x) {" + | 238 "return function tearOff_" + name + (functionCounter++) + "(x) {" + |
| 239 "if (c === null) c = " + #tearOffAccessText + "(" + | 239 "if (c === null) c = " + #tearOffAccessText + "(" + |
| 240 "this, funcs, reflectionInfo, false, [x], name);" + | 240 "this, funcs, reflectionInfo, false, [x], name);" + |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 ? function() { | 275 ? function() { |
| 276 if (cache === void 0) cache = #tearOff( | 276 if (cache === void 0) cache = #tearOff( |
| 277 this, funcs, reflectionInfo, true, [], name).prototype; | 277 this, funcs, reflectionInfo, true, [], name).prototype; |
| 278 return cache; | 278 return cache; |
| 279 } | 279 } |
| 280 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); | 280 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); |
| 281 }''', {'tearOff': tearOffAccessExpression}); | 281 }''', {'tearOff': tearOffAccessExpression}); |
| 282 | 282 |
| 283 return <jsAst.Statement>[tearOffGetter, tearOff]; | 283 return <jsAst.Statement>[tearOffGetter, tearOff]; |
| 284 } | 284 } |
| OLD | NEW |