| | |||||||||||||||
|
|
Model-Driven Engineering, Aspect-Oriented-Programming, Program Transformation. . |
|
Program transformation systems have been used in the past to construct aspect weavers for programming languages. Program transformation engines (PTEs) such as the Design Maintenance System (DMS), or ASF+SDF, provide direct availability of scalable parsers and an underlying low-level transformation framework to modify source programs. However, due to the accidental complexities and the associated skill-sets needed to use a PTE, such tools are generally accessible only by language researchers, not general software developers. The main objective of this research is to combine metamodeling approaches with transformation systems to investigate how model engineering can assist in constructing aspect weavers for general-purpose programming languages (GPLs). The approach eliminates the accidental complexities associated with PTEs, but still leverages the power of such systems. The architecture can be divided into two layers. The front-end uses an aspect-like language similar to AspectJ, which is then translated (using ATL) to lower-order transformation rules used by the back-end (e.g., the DMS Rule Specification Language - RSL). The generated transformation rules are then processed by DMS to weave aspects into a source program. The following figures illustrates this mechanism.
In this work, we demonstrate the usage of two different aspect languages (namely AspectPascal and AspectFORTRAN). The metamodels for both AspectPascal and AspectFORTRAN share a common abstract core (GAspect). The following figures show the metamodels for AspectPascal and AspectFORTRAN respectively. The part beneath the dotted rectangle shows the commonality between these metamodels.
The core elements for designing a metamodel for an aspect language are join points, pointcuts and advice. Join points are execution points of a program, such as a method invocation or a particular exception being thrown. Pointcuts are means of identifying a set of join points through a predicate expression. Advice defines actions to be performed when a particular join point is reached. The metamodel is implemented internally using KM3 and TCS. KM3 is a metamodeling language available in AMMA and is used to specify the abstract syntax of the metamodel. TCS is also available within the AMMA toolsuite and is used to specify the concrete syntax (grammar) of the metamodel. The complete KM3 and TCS specification for AspectPascal and AspectFORTRAN is hyperlinked below. A simple comparison between the metamodels of these two languages will show the commonality between them, especially in terms of the GAspect. [AspectPascal KM3 spec]    [AspectPascal TCS spec]    [AspectFORTRAN KM3 spec]    [AspectFORTRAN TCS spec]    The target model conforms to the DMS Rule Specification Language (RSL) which provides basic primitives for describing numerous transformations that are to be performed across the entire code base of an application. The RSL consists of declarations of patterns, rules, conditions, and rule sets using the external form (concrete syntax) defined by a language domain. Patterns describe the form of a syntax tree. They are used for matching purposes to find a syntax tree having a specified structure. Patterns are often used on the right-hand side (target) of a rule to describe the resulting syntax tree after a transformation rule is applied. The RSL rules describe a directed pair of corresponding syntax trees. A rule is typically used as a rewrite specification that maps from a left-hand side (source) syntax tree expression to a right-hand side (target) syntax tree expression. Rules can be combined into sets of rules that together form a transformation strategy by defining a collection of transformations that can be applied to a syntax tree. The patterns and rules can have associated conditions that describe restrictions on when a pattern legally matches a syntax tree, or when a rule is applicable on a syntax tree. The following diagram specifies a snippet of the Rsl Metamodel and its KM3 specification.
The RSL Metamodel contains various elements like patterns, conditions, rules and rule sets. The complete RSL metamodel specification (KM3 and TCS) is available as follows: [RSL KM3 spec]    [RSL TCS spec]. The complete scenario describing how a source aspect specification is transformed to a target RSL specification is shown below. The ATL transformation language is used to do the translation from source aspect to target RSL.The following case studies will provide more details about ATL specifications and the underlying models derived from the source and target metamodels.
|
|
In order to experiment with the approach presented here, we constructed two aspect weavers – one for Object Pascal and another for FORTRAN using our generic model-driven framework. A subset (e.g., primitive pointcuts like call, execution, loop) of standard AOP features was built into both of the weavers. The FORTRAN weaver was constructed after the completion of the AspectPascal weaver and reused several functionalities, code and knowledge from the previous construction without much alteration to the core artifacts. For example, both weavers shared the generic front-end, which constituted around 50% of the overall front-end LOC (written in KM3 and TCS). Moreover, the FORTRAN weaver could reuse 30% of the Object Pascal rule generator code without any alteration, and another 25% with minor customization (See comparisons of ATL specifications for FORTRAN and ObjectPascal weavers below). Most of the time and effort on building the FORTRAN weaver was spent on understanding the concrete syntax of the language and on the conceptual design of the weaver.The following links provide all the generated artifacts, examples, complete source code of each of the individual weavers.
Comparisons of Rule Generator Code (Reusability)
The comparison between the rule generator code (higher-order ATL transformations) for both AspectPascal and AspectFORTRAN weavers are shown below. The first link shows the comparitive difference between the ATL transformations for translating a function / procedure call join point and function / subroutine call join point in ObjectPascal and FORTRAN respectively. The second link shows the comparitive difference between the ATL transformations for translating a loop execution join point defined in ObjectPascal and FORTRAN respectively. The results visually demonstrate the level of reuse among the rule generators for constructing weavers for these two languages.
Difference in ATL transformations for translating call join point in FORTRAN and ObjectPascal
|
|
[1] Gray, J, and Roychoudhury, S, "A Technique for Constructing Aspect Weavers using a Program Transformation Engine," AOSD ’04, International Conference on Aspect-Oriented Software Development, Lancaster, UK, March 22-26 , 2004, pp. 36-45 [2] Roychoudhury, S, Gray, J, and Jouault, F, "A Model-Driven Framework for Aspect Weaver Construction," submitted to Transactions of Aspect-Oriented Software Developments, Special Issue on Aspects and MDE. [3] Baxter, I, Pidgeon, C, and Mehlich, M, "DMS: Program Transformation for Practical Scalable Software Evolution," International Conference on Software Engineering (ICSE), Edinburgh, Scotland, May 2004, pp. 625-634. [4] Jouault, F, and Bézivin, J, "KM3: a DSL for Metamodel Specification," 8th IFIP International Conference on Formal Methods for Open Object-Based Distributed Systems, LNCS, Bologna, Italy, pp. 171-185. [5] Jouault, F, Bézivin, J, and Kurtev, I, "TCS: a DSL for the Specification of Textual Concrete Syntaxes in Model Engineering," International Conference on Generative Programming and Component Engineering, Portland, Oregon, USA, Oct 2006, pp. 249-254 [6] Jouault, F, and Kurtev, I, "Transforming Models with ATL," Model Transformations in Practice Workshop at MoDELS 2005, Montego Bay, Jamaica |
AspectPascal Compiler |
ANT scripts to run the AspectPascal compiler |
AspectFORTRAN Compiler |
ANT scripts to run the AspectFORTRAN compiler |
Complete Source |
Full source code for AspectPascal and AspectFORTRAN weavers including sample test files. Also contains C++ and Java metamodels (Aspect Extensions) |
|
Video 1:
Video 2:
Video 3:
If you have any problems with these videos, or would like to see them in a different video format, please write to me |
| This work is supported in part by an NSF CAREER award (CCF-0643725) and by the OpenEmbeDD project. |
Any information provided in this web page is copyright by the persons mentioned above, also any source available for download is provided "as is" and any express or implied warranties are disclaimed