首页> 外文期刊>ACM SIGPLAN Notices: A Monthly Publication of the Special Interest Group on Programming Languages >All about the with Statement in JavaScript: Removing with Statements in JavaScript Applications
【24h】

All about the with Statement in JavaScript: Removing with Statements in JavaScript Applications

机译:关于JavaScript中的with语句的所有信息:在JavaScript应用程序中删除with语句

获取原文
获取原文并翻译 | 示例
       

摘要

The with statement in JavaScript makes static analysis of JavaScript applications difficult by introducing a new scope at run time and thus invalidating lexical scoping. Therefore, many static approaches to JavaScript program analysis and the strict mode of ECMAScript 5 simply disallow the with statement. To justify exclusion of the with statement, we should better understand the actual usage patterns of the with statement. In this paper, we present the usage patterns of the with statement in real-world JavaScript applications currently used in the 898 most popular web sites. We investigate whether we can rewrite the with statements in each pattern to other statements not using the with statement. We show that we can rewrite all the static occurrences of the with statement that do not have any dynamic code generating functions. Even though the rewriting process is not applicable to any dynamically generated with statements, our results are still promising. Because all the static approaches that disallow the with statement also disallow dynamic code generation, such static approaches can allow the with statement using our rewriting process. We formally present our rewriting strategy, provide its implementation, and show its faithfulness using extensive testing. We believe that removing with statements will simplify JavaScript program analysis designs without considering dynamic scope introduction while imposing fewer syntactic restrictions.
机译:JavaScript中的with语句通过在运行时引入新作用域,从而使词法作用域无效,从而使JavaScript应用程序的静态分析变得困难。因此,许多用于JavaScript程序分析的静态方法和ECMAScript 5的严格模式都根本不允许with语句。为了证明with语句被排除在外,我们应该更好地了解with语句的实际使用模式。在本文中,我们介绍了with语句在898个最流行的网站上当前使用的实际JavaScript应用程序中的使用模式。我们调查是否可以不使用with语句将每个模式中的with语句重写为其他语句。我们证明了我们可以重写with语句的所有静态出现,这些语句不具有任何动态代码生成功能。即使重写过程不适用于任何用语句动态生成的语句,我们的结果仍然很有希望。因为所有禁止with语句的静态方法也不允许动态代码生成,所以这种静态方法可以使用我们的重写过程允许with语句。我们正式提出了重写策略,提供了其实施方案,并通过广泛的测试证明了其忠实性。我们相信,使用with语句删除将简化JavaScript程序分析设计,而无需考虑动态范围的引入,同时施加更少的语法限制。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号