...
首页> 外文期刊>ACM SIGPLAN Notices: A Monthly Publication of the Special Interest Group on Programming Languages >Package Templates: A Definition by Semantics-Preserving Source-to-Source Transformations to Efficient Java Code
【24h】

Package Templates: A Definition by Semantics-Preserving Source-to-Source Transformations to Efficient Java Code

机译:软件包模板:通过语义定义,将源代码到源代码的转换保留为有效的Java代码

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

摘要

Package Templates (PT) is a mechanism designed for writing reusable modules, called templates, each consisting of a set of classes that can be adapted to their use in a program through compile-time specialization. A template must be instantiated in a program before its classes can be used. The mechanism supports type-safe renaming, merging, type parameterization and refinement in the form of static additions and overrides that are orthogonal to the corresponding concepts of ordinary inheritance. In this paper, we consider PT as an extension to Java, and a PT program will then consist of a number of Java packages and templates, where templates are instantiated in packages or other templates. Our aim and main contribution is to define the meaning of such a program, and to show that this definition is consistent. We first show this for a core subset of PT, C-PT, and define a set of source-to-source transformations for converting C-PT programs to plain Java programs using semantics we have described informally in previous papers. We can then define the meaning of a C-PT program in terms of the resulting Java program. Thus, we have to verify that the transformations will always convert a legal C-PT program to a legal Java program. Finally, we briefly discuss how this approach can be extended to full PT. A main challenge is to preserve externally visible names (for classes, methods and fields), and at the same time prevent unwanted subsequent rebindings caused e.g. by overload resolution in the Java compiler. Names that are bound to declarations in a template should not be rebound to different declarations by subsequent compositions or adaptions. In addition to defining the runtime semantics of PT constructs in terms of their translation to Java, the transformation rules can also be seen as a high-level approach to how a compiler for this language might be implemented.
机译:包模板(PT)是一种用于编写可重用模块(称为模板)的机制,每个模块由一组类组成,这些类可以通过编译时专门化使其适合于在程序中使用。必须先在程序中实例化模板,然后才能使用其类。该机制以与普通继承的相应概念正交的静态添加和覆盖的形式支持类型安全的重命名,合并,类型参数化和优化。在本文中,我们将PT视为Java的扩展,然后PT程序将由许多Java包和模板组成,其中模板在包或其他模板中实例化。我们的目标和主要贡献是定义这样一个程序的含义,并表明该定义是一致的。我们首先针对PT的核心子集C-PT展示这一点,并定义了一组源到源的转换,以使用我们在先前论文中非正式描述的语义将C-PT程序转换为纯Java程序。然后,我们可以根据生成的Java程序定义C-PT程序的含义。因此,我们必须验证这些转换将始终将合法的C-PT程序转换为合法的Java程序。最后,我们简要讨论如何将此方法扩展到完整PT。一个主要的挑战是要保留外部可见的名称(用于类,方法和字段),同时要防止不必要的后续重绑定,例如通过Java编译器中的重载解析。模板中与声明绑定的名称不应通过后续的组合或改编而反弹为不同的声明。除了根据PT构造向Java的转换来定义PT构造的运行时语义外,转换规则还可以看作是一种用于实现该语言的编译器的高级方法。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号