Transformation patterns

From Event-B
Revision as of 13:36, 28 June 2011 by imported>Ilya.lopatkin
Jump to navigationJump to search

The Transformation patterns plugin allows users to write transformation scripts in EOL (simple object-based imperative language) and easily run them over models within the same project.

Editing is done in a simple text editor with syntax coloring. No compilation is needed to run transformations.

What it is

The plugin is essentially a wrapper around the Epsilon framework of interoperatable programming languages which are used to operate over the given EMF models (Event-B in our case). The plugin performs the necessary setup for running the transformations, provides simple user interface for choosing Event-B elements such as machines, events, variables etc, and caches the user input (see later).

User input cache

The plugin provides a cache of objects (Event-B EMF elements and strings) entered by a user. If during the execution a pattern requires to enter an object more than once, then at the first time the user will be asked for input, and the result will be cached. All subsequent requests will return the cached object unless the record about the object is erased.

The cache can be accessed directly from within the scripts, and used as a means to pass the objects between different transformations without them knowing the actual source of input. Thus, the input can be extended to other domain-specific EMF models.

A cache is a map from keys to values where a key consists of a type of object and its identifier, and the value is the actual cached object. The types of objects are handled by the utility library, while the identifiers must be supplied by script developer.

The operations which request input from the user without caching it all start with enter, such as in enterString(..), enterEvent(..) etc. The operations starting with input do the following:

  1. check the cache for existing objects, and return if the object is in the cache
  2. if there is no object in the cache with the given id, then ask user to enter the object
  3. put the entered object into the cache and return to caller

The parameter id is optional. If id=null then an input operation degenerates into enter.

Full list of provided operations

agdskgn asgn asdfjgdfjjjjjs fg ehg 46 hy4 46h hrh trh try fgh fgh fg hfg gfjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj bla
enterString(userMessage:String):String

enterString(userMessage, _default:String):String

Ask user to enter a string.

userMessage is a message that will be shown in the dialog, _default is the default value.

inputString(id:String):String

inputString(id, userMessage:String):String

inputString(id,userMessage,_default:String):String

Ask user to enter a string.

The input cache is checked first for a string object with the key id. If no such object was cached, then a dialog with userMessage and the _default value appears. The entered string is cached and returned.

enterInt(userMessage:String):Integer

enterInt(userMessage:String, _default:Integer):String

Ask user to enter an integer.

userMessage is a message that will be shown in the dialog, _default is the default value.

inputInt(id:String):Integer

inputInt(id,userMessage:String):Integer

inputInt(id,userMessage:String, _default:Integer):Integer

Ask user to enter an integer.

The input cache is checked first for an integer object with the key id. If no such object was cached, then a dialog with userMessage and the _default value appears. The entered integer is cached and returned.

inputMachine(id:String):Machine

inputMachine(id,userMessage:String):Machine

inputMachine(id,userMessage,fileName:String):Machine

Ask user to choose an Event-B model.

The input cache is checked first for a machine object with the key id. If no such object was cached, then a dialog with userMessage appears. The dialog will contain a list of all machines within the same project as the script. If fileName is specified, then the model with the given name is loaded and no dialog will appear. The model is cached and returned.

Machine enterEvent(userMessage:String):Event Ask user to choose an event of the machine.

Presents a dialog with the list of all machine events.

Machine inputEvent(id:String):Event

Machine inputEvent(id,userMessage:String):Event

Ask user to choose an event of the machine.

Checks the input cache first.

Machine findEvent(eventName: String): Event Returns an event of the machine with the name equal to eventName. Null if such event does not exist