Sei sulla pagina 1di 16

Code Generation from an fUML Action Language

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,


Department of Computer Science, Babe s-Bolyai University, Cluj-Napoca, Romania

May 2010

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

Outline

1. Introduction
1.1 Foundational Executable UML 1.2 fUML-based Action Language

2. Model creation 3. Model execution 4. Code generation 5. Further Work

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

1. Introduction 1.1. Foundational Executable UML


fUML Specication Object Management Group (OMG) Standard
2010, Rev. 1.0, Beta 3 http://www.omg.org/spec/FUML/

a computationally complete and compact subset of UML provides a simplied subset of UML Action Semantics package simplies the context to which the actions may be applied enforces a data ow abstract representation fUML Reference Implementation ModelDriven.org 2009, version 0.4.0

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

1. Introduction 1.2. fUML-based Action Language

the abstract syntax is compliant with fUML enforces structured programming concrete syntax similar to Java and OCL used to model the behavior of class operations code generation for object-oriented programming languages (Java, C++, C#) built as part of ComDeValCo framework presented at SYNASC, 2009

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation

UML Class Structure Editor existing editors can be used Eclipse UML2 project (version 3.0)
Model Development Tools (MDT) project built on top of EMF(Core) provides a tree-based editor

Eclipse UML2 Tools project (version 0.9)


Model Development Tools (MDT) project built on top of UML2 and GMF provides an UML Class Diagram editor

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation (cont)

Figure: UML2Tools UML Class Diagram editor

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation (cont)

Figure: UML2 tree based editor

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation (cont)

fUML based Action Language Editor Eclipse Xtext project (version 0.7)
Textual Modeling Framework (TMF) project

built using UML2 as metamodel it is a textual editor must be integrated with the Class Diagram editor

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation (cont)


ActivityRule returns uml::Activity : activity name=ID ( ( ownedParameter+=ParameterRule (, ownedParameter+=ParameterRule)*)? )? ) (ownedParameter+=ReturnParameterRule)? node+=BlockStructuredActivityNodeRule; ParameterRule returns uml::Parameter : name=ID : type=[uml::Classifier];
Figure: Snippet from the Xtext Grammar for the Action Language

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation (cont)

1 2 3 4 5 6

public addItem(product:Product, quantity:Integer) { def newItem : SaleItem := new SaleItem; newItem.product := product; newItem.quantity := quantity; self.item.add(newItem); }
Figure: Sale::addItem Activity Concrete Syntax

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

2. Model creation (cont)


activity addItem ( product : Product, quantity : Integer ) MAIN_BLOCK [lines 1-6] DEF_STMT [line 2] result : SaleItem <<createObject>> SaleItem newItem product : Product ASSIGN_STMT [line 3] value <<addStructuralFeatureValue>> object product product quantity : Integer ASSIGN_STMT [line 4] value <<addStructuralFeatureValue>> object quantity quantity ADD_STMT [line 5] result result <<readSelf>> <<valueSpecification>> self * object insertAt <<addStructuralFeatureValue>> value item

Figure: Sale::addItem Activity - fUML Abstract Syntax


I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar, Code Generation from an fUML Action Language

3. Model execution

fUML Reference Implementation


ModelDriven.org version 0.4.0

executes models expressed in fUML


the starting point of the execution is an Activity

used to execute and test the model must be integrated in Eclipse workbench
popup items (in editors and explorer) debug views with tracing abilities

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

4. Code generation

Eclipse Acceleo project (version 3.0)


Model To Text (M2T) project implements MOFM2T standard from OMG code generation based on templates

the templates need to consider the model structure produced by the action language code generation aimed for languages like Java or C++ the generated code is complete
there is no need to edit the code no Reverse Engineering is needed

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

4. Code generation (cont)

Figure: Acceleo Template Snippet

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

5. Further Work

a better integration of the tools a specialized editor for Class Diagrams that allows only fUML elements apply transformations to the models generate code in different programming languages support stereotypes for the action language statements

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language

Thank you for your attention!

Questions?

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Code Generation from an fUML Action Language