Package org.eclipse.epsilon.emg
Class EmgModule
- java.lang.Object
-
- All Implemented Interfaces:
IModule
,ModuleElement
,IEmgModule
,IEolModule
,IEplModule
,IErlModule
public class EmgModule extends EplModule implements IEmgModule
The Emg Module is responsible for execution emg scripts. Emg scripts are used to generate models.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.epsilon.epl.AbstractEplModule
AbstractEplModule.LazyAdvancedRoleInstancesInitializer, AbstractEplModule.LazyBasicRoleInstancesInitializer
-
-
Field Summary
-
Fields inherited from class org.eclipse.epsilon.epl.AbstractEplModule
declaredPatterns, INFINITE, maxLoops, patternMatchModelName, patterns, repeatWhileMatchesFound
-
Fields inherited from class org.eclipse.epsilon.erl.ErlModule
declaredPost, declaredPre, post, pre
-
Fields inherited from class org.eclipse.epsilon.eol.EolModule
compilationContext, context, declaredModelDeclarations, declaredOperations, imports, main, modelDeclarations, operations, postOperationStatements
-
Fields inherited from class org.eclipse.epsilon.eol.AbstractModule
parseProblems, parser, sourceFile, sourceUri
-
-
Constructor Summary
Constructors Constructor Description EmgModule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
containAny(java.util.Collection<java.lang.Object> first, java.util.Collection<java.lang.Object> last)
Contain any.protected void
executeCreateOperations()
Execute the create operations in the EMG script.protected double
getFloat(java.lang.Object object)
Gets the float.java.util.HashMap<java.lang.String,java.lang.Class<?>>
getImportConfiguration()
protected int
getInt(java.lang.Object object)
Gets the int.java.util.Map<java.lang.String,java.util.List<java.lang.Object>>
getNamedCreatedObjects()
java.util.List<PatternMatch>
match(Pattern pattern)
This method provides the main high-level execution logic for EPL.protected void
prepareContext()
java.lang.Object
processRules()
Main rule processing logic.void
setSeed(long seed)
void
setUseSeed(boolean useSeed)
-
Methods inherited from class org.eclipse.epsilon.epl.EplModule
createCombinationGenerator, getCandidates, initGenerator, wrapAdvancedRoleInstances, wrapBasicRoleInstances
-
Methods inherited from class org.eclipse.epsilon.epl.AbstractEplModule
adapt, build, createLexer, createModel, createParser, createPatternMatch, executeDoBlock, filterElements, flatMapRoleBindings, getContext, getDeclaredPatterns, getMainRule, getMatchResult, getMaxLoops, getPatterns, getRoleInstances, getVariables, isRepeatWhileMatches, isValidCombination, matchCombination, matchPatterns, matchPatterns, negativeGuard, postProcessMatches, preMatch, putRoleBindingsIntoFrame, setMaxLoops, setRepeatWhileMatches
-
Methods inherited from class org.eclipse.epsilon.erl.ErlModule
calculateSuperRules, execute, execute, executeImpl, getDeclaredPost, getDeclaredPre, getPost, getPre, postExecution, prepareExecution
-
Methods inherited from class org.eclipse.epsilon.eol.EolModule
checkImports, clearCache, compile, execute, getCompilationContext, getDeclaredModelDeclarations, getDeclaredOperations, getImports, getImportsByExtension, getMain, getModelDelcarations, getOperations, getParentModule, getPostOperationStatements, setContext, setMain, setParentModule, toString
-
Methods inherited from class org.eclipse.epsilon.eol.AbstractModule
assignAnnotations, assignComment, assignComments, createAst, extractComments, getParseProblems, getSourceFile, getSourceUri, invokeMainRule, parse, parse
-
Methods inherited from class org.eclipse.epsilon.common.module.AbstractModuleElement
equals, getChildren, getComments, getDebugInfo, getFile, getModule, getParent, getRegion, getUri, hashCode, setModule, setParent, setRegion, setUri
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.epsilon.eol.IEolModule
configure, execute, getCompilationContext, getConfigurationProperties, getDeclaredModelDeclarations, getDeclaredOperations, getImports, getMain, getModelDelcarations, getOperations, getParentModule, getParseProblems, getPostOperationStatements, parse, setContext, setParentModule
-
Methods inherited from interface org.eclipse.epsilon.epl.IEplModule
getDeclaredPatterns, getMaximumLevel, getMaxLoops, getPatterns, isRepeatWhileMatches, matchPatterns, setMaxLoops, setRepeatWhileMatches
-
Methods inherited from interface org.eclipse.epsilon.erl.IErlModule
getContext, getDeclaredPost, getDeclaredPre, getPost, getPre
-
Methods inherited from interface org.eclipse.epsilon.common.module.IModule
compile, createAst, getSourceUri, parse, parse, parse, parse, parse
-
Methods inherited from interface org.eclipse.epsilon.common.module.ModuleElement
build, getChildren, getComments, getFile, getModule, getParent, getRegion, getUri, setModule, setParent, setRegion, setUri
-
-
-
-
Method Detail
-
setSeed
public void setSeed(long seed)
- Specified by:
setSeed
in interfaceIEmgModule
- Parameters:
seed
- the seed to set
-
setUseSeed
public void setUseSeed(boolean useSeed)
- Specified by:
setUseSeed
in interfaceIEmgModule
- Parameters:
useSeed
- the useSeed to set
-
getNamedCreatedObjects
public java.util.Map<java.lang.String,java.util.List<java.lang.Object>> getNamedCreatedObjects()
- Specified by:
getNamedCreatedObjects
in interfaceIEmgModule
- Returns:
- the namedCreatedObjects
-
getImportConfiguration
public java.util.HashMap<java.lang.String,java.lang.Class<?>> getImportConfiguration()
- Overrides:
getImportConfiguration
in classAbstractEplModule
-
prepareContext
protected void prepareContext() throws EolRuntimeException
- Overrides:
prepareContext
in classEolModule
- Throws:
EolRuntimeException
-
processRules
public java.lang.Object processRules() throws EolRuntimeException
Description copied from class:ErlModule
Main rule processing logic. Non-abstract for compatibility.- Overrides:
processRules
in classAbstractEplModule
- Returns:
- The result of executing this module.
- Throws:
EolRuntimeException
-
executeCreateOperations
protected void executeCreateOperations() throws EolRuntimeException
Execute the create operations in the EMG script.- Throws:
EolModelElementTypeNotFoundException
- the eol model element type not found exceptionEolRuntimeException
- If the type to be instantiated can't be found or any of the random functions fails.
-
match
public java.util.List<PatternMatch> match(Pattern pattern) throws EolRuntimeException
Description copied from class:AbstractEplModule
This method provides the main high-level execution logic for EPL. The idea is that for each role in the pattern, appropriate bindings are made to the role and executed. Then the match block (and subsequently onMatch) is executed for the role and a PatternMatch is created where applicable.
In essence, this method can be thought of as the executor of all roles in the pattern, and therefore acts as a bridge between the high-level methods (e.g.AbstractEplModule.matchPatterns(int, PatternMatchModel)
) and the low-level ones (e.g.AbstractEplModule.getRoleInstances(Role, String)
).
Implementation-wise, this method delegates the main execution logic toAbstractEplModule.matchCombination(Collection, Pattern)
, and so the sole responsibility of this method is to loop through the combinations returned byAbstractEplModule.getCandidates(Pattern)
and collect all the results. Subclasses may override this method to alter the type of collection returned and/or alter the looping mechanism.- Specified by:
match
in interfaceIEplModule
- Overrides:
match
in classAbstractEplModule
- Throws:
EolRuntimeException
-
getInt
protected int getInt(java.lang.Object object)
Gets the int.- Parameters:
object
- the object- Returns:
- the int
-
getFloat
protected double getFloat(java.lang.Object object)
Gets the float.- Parameters:
object
- the object- Returns:
- the float
-
containAny
protected boolean containAny(java.util.Collection<java.lang.Object> first, java.util.Collection<java.lang.Object> last)
Contain any.- Parameters:
first
- the firstlast
- the last- Returns:
- true, if successful
-
-