org.eclipse.m2m.atl.engine.emfvm.lib
Class ExecEnv

java.lang.Object
  extended by org.eclipse.m2m.atl.engine.emfvm.lib.ExecEnv

public class ExecEnv
extends java.lang.Object

Execution environment.


Constructor Summary
ExecEnv(java.util.Map<java.lang.String,IModel> models, ITool[] tools)
          Creates a new execenv parametrized by models.
 
Method Summary
 void enterTools(AbstractStackFrame frame)
          Enters the tools.
static java.lang.Object findMetaElement(AbstractStackFrame frame, java.lang.Object mname, java.lang.Object me)
          Finds a meta element by its name.
 Operation getAttributeInitializer(java.lang.Object type, java.lang.String name)
          Returns the attribute initializer.
 java.lang.Object getHelperValue(AbstractStackFrame frame, java.lang.Object type, java.lang.Object element, java.lang.String name)
          Gets the value of an helper.
 IModel getModel(java.lang.Object name)
          Returns the model by name.
 IModelAdapter getModelAdapter()
           
 java.lang.String getModelNameOf(java.lang.Object element)
          Returns the model containing the element.
 IModel getModelOf(java.lang.Object element)
          Get the model of a given element.
 java.util.Iterator<IModel> getModels()
           
 java.util.Map<java.lang.String,IModel> getModelsByName()
           
 java.lang.String getNameOf(IModel model)
          Returns the model name.
 long getNbExecutedBytecodes()
           
 Operation getOperation(java.lang.Object type, java.lang.Object name)
          Find an operation by its context type and name.
 void incNbExecutedBytecodes()
          Increments the nbExecutedBytecodes.
 void init(IModelAdapter modelAdapterParam)
          Initializes the execenv.
 boolean isHelper(java.lang.Object type, java.lang.String name)
          Returns true if the given type has a helper with the given name.
 boolean isStep()
           
 boolean isWeavingHelper(java.lang.Object type, java.lang.String name)
          Returns true if there is a weaving helper for the given type and name.
 void leaveTools(AbstractStackFrame frame)
          Leaves the tools.
 java.lang.Object newElement(AbstractStackFrame frame, java.lang.Object ec)
          Creates a new element in the given frame.
 java.lang.Object newElement(AbstractStackFrame frame, java.lang.Object ec, java.lang.String metamodelName)
          Creates a new element in the given frame.
 java.lang.Object newElementIn(AbstractStackFrame frame, java.lang.Object ec, java.lang.String modelName)
          Creates a new element in the given frame and the given model.
 void prettyPrint(java.lang.Object value)
          Displays a value.
 void prettyPrint(java.io.PrintStream out, java.lang.Object value)
          Displays a value.
 void prettyPrintCollection(java.io.PrintStream out, java.util.Collection<?> col)
          Display a collection.
 void registerHelperAttribute(java.lang.Object type, java.lang.String name, java.lang.String initOperationName)
          Stores an attribute helper.
 void registerOperation(java.lang.Object type, Operation oper)
          Registers operation for a given type.
 void registerOperation(java.lang.Object type, Operation oper, java.lang.String name)
          Deprecated. use registerOperation(Object, Operation) instead
 void registerWeavingHelper(java.lang.Object type, java.lang.String name, java.lang.String persistTo)
          Registers a weaving helper.
 void setHelperValue(java.lang.Object element, java.lang.String name, java.lang.Object value)
          Sets an helper value (only for weaving helpers).
 void setStep(boolean step)
           
 void stepTools(AbstractStackFrame frame)
          Steps the tools.
 void terminated()
          Ends the execution.
 void terminateTools()
          Terminates the tools.
 java.lang.String toPrettyPrintedString(java.lang.Object value)
          Converts a value to a displayable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecEnv

public ExecEnv(java.util.Map<java.lang.String,IModel> models,
               ITool[] tools)
Creates a new execenv parametrized by models.

Parameters:
models - the models map
tools - the execution tools
Method Detail

stepTools

public void stepTools(AbstractStackFrame frame)
Steps the tools.

Parameters:
frame - the frame

enterTools

public void enterTools(AbstractStackFrame frame)
Enters the tools.

Parameters:
frame - the frame

leaveTools

public void leaveTools(AbstractStackFrame frame)
Leaves the tools.

Parameters:
frame - the frame

terminateTools

public void terminateTools()
Terminates the tools.


init

public void init(IModelAdapter modelAdapterParam)
Initializes the execenv.

Parameters:
modelAdapterParam - the model adapter

getModelNameOf

public java.lang.String getModelNameOf(java.lang.Object element)
Returns the model containing the element.

Parameters:
element - a model element
Returns:
the model containing the element

getNameOf

public java.lang.String getNameOf(IModel model)
Returns the model name.

Parameters:
model - a model
Returns:
the model name

getModel

public IModel getModel(java.lang.Object name)
Returns the model by name.

Parameters:
name - the model name
Returns:
the model by name

getModels

public java.util.Iterator<IModel> getModels()

getOperation

public Operation getOperation(java.lang.Object type,
                              java.lang.Object name)
Find an operation by its context type and name.

Parameters:
type - operation context type
name - operation name
Returns:
the operation

registerHelperAttribute

public void registerHelperAttribute(java.lang.Object type,
                                    java.lang.String name,
                                    java.lang.String initOperationName)
Stores an attribute helper.

Parameters:
type - the attribute type
name - the attribute name
initOperationName - the init operation name

getAttributeInitializer

public Operation getAttributeInitializer(java.lang.Object type,
                                         java.lang.String name)
Returns the attribute initializer.

Parameters:
type - the attribute type
name - the attribute name
Returns:
the attribute initializer

getHelperValue

public java.lang.Object getHelperValue(AbstractStackFrame frame,
                                       java.lang.Object type,
                                       java.lang.Object element,
                                       java.lang.String name)
Gets the value of an helper.

Parameters:
frame - the frame context
type - the helper type
element - the element
name - the helper value name
Returns:
the value

registerOperation

public void registerOperation(java.lang.Object type,
                              Operation oper,
                              java.lang.String name)
Deprecated. use registerOperation(Object, Operation) instead

Registers operation for a given type.

Parameters:
type - the type
oper - the operation
name - the operation name

registerOperation

public void registerOperation(java.lang.Object type,
                              Operation oper)
Registers operation for a given type.

Parameters:
type - the type
oper - the operation

toPrettyPrintedString

public java.lang.String toPrettyPrintedString(java.lang.Object value)
Converts a value to a displayable string.

Parameters:
value - the value to convert
Returns:
the displayable string

prettyPrint

public void prettyPrint(java.lang.Object value)
Displays a value.

Parameters:
value - the value to display

prettyPrint

public void prettyPrint(java.io.PrintStream out,
                        java.lang.Object value)
Displays a value.

Parameters:
out - the stream
value - the value to display

prettyPrintCollection

public void prettyPrintCollection(java.io.PrintStream out,
                                  java.util.Collection<?> col)
Display a collection.

Parameters:
out - the out stream
col - the collection

findMetaElement

public static java.lang.Object findMetaElement(AbstractStackFrame frame,
                                               java.lang.Object mname,
                                               java.lang.Object me)
Finds a meta element by its name.

Parameters:
frame - the frame context
mname - the metamodel name
me - the model element
Returns:
the meta element

newElement

public java.lang.Object newElement(AbstractStackFrame frame,
                                   java.lang.Object ec)
Creates a new element in the given frame.

Parameters:
frame - the frame context
ec - the element type
Returns:
the new element

newElement

public java.lang.Object newElement(AbstractStackFrame frame,
                                   java.lang.Object ec,
                                   java.lang.String metamodelName)
Creates a new element in the given frame.

Parameters:
frame - the frame context
ec - the element type
metamodelName - the metamodel name
Returns:
the new element

newElementIn

public java.lang.Object newElementIn(AbstractStackFrame frame,
                                     java.lang.Object ec,
                                     java.lang.String modelName)
Creates a new element in the given frame and the given model.

Parameters:
frame - the frame context
ec - the element type
modelName - the model name
Returns:
the new element

getModelsByName

public java.util.Map<java.lang.String,IModel> getModelsByName()

isStep

public boolean isStep()

setStep

public void setStep(boolean step)

getModelAdapter

public IModelAdapter getModelAdapter()

getNbExecutedBytecodes

public long getNbExecutedBytecodes()

incNbExecutedBytecodes

public void incNbExecutedBytecodes()
Increments the nbExecutedBytecodes.


isWeavingHelper

public boolean isWeavingHelper(java.lang.Object type,
                               java.lang.String name)
Returns true if there is a weaving helper for the given type and name.

Parameters:
type - the helper type
name - the helper name
Returns:
true if there is a weaving helper for the given type and name

registerWeavingHelper

public void registerWeavingHelper(java.lang.Object type,
                                  java.lang.String name,
                                  java.lang.String persistTo)
Registers a weaving helper.

Parameters:
type - the helper context
name - the helper name
persistTo - the name of the feature to persist

isHelper

public boolean isHelper(java.lang.Object type,
                        java.lang.String name)
Returns true if the given type has a helper with the given name.

Parameters:
type - the given type
name - the helper name
Returns:
true if the given type has a helper with the given name

setHelperValue

public void setHelperValue(java.lang.Object element,
                           java.lang.String name,
                           java.lang.Object value)
Sets an helper value (only for weaving helpers).

Parameters:
element - the helper context
name - the helper name
value - the value to set

terminated

public void terminated()
Ends the execution.


getModelOf

public IModel getModelOf(java.lang.Object element)
Get the model of a given element.

Parameters:
element - the given element
Returns:
the model

Copyright 2007 IBM Corporation and others.
All Rights Reserved.