コード例 #1
0
  /** Transforms the {@link Statechart} model to a {@link ExecutionFlow} model */
  protected ExecutionFlow createExecutionFlow(Statechart statechart, GeneratorEntry entry) {
    Injector injector = getInjector(entry);
    ModelSequencer sequencer = injector.getInstance(ModelSequencer.class);
    ExecutionFlow flow = sequencer.transform(statechart);
    Assert.isNotNull(flow, "Error creation ExecutionFlow");

    FeatureConfiguration optimizeConfig = entry.getFeatureConfiguration(FUNCTION_INLINING_FEATURE);

    FlowOptimizer optimizer = injector.getInstance(FlowOptimizer.class);

    optimizer.inlineReactions(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_REACTIONS, true));
    optimizer.inlineExitActions(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_ACTIONS, true));
    optimizer.inlineEntryActions(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRY_ACTIONS, true));
    optimizer.inlineEnterSequences(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTER_SEQUENCES, true));
    optimizer.inlineExitSequences(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_SEQUENCES, true));
    optimizer.inlineChoices(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_CHOICES, true));
    optimizer.inlineEntries(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRIES, true));
    optimizer.inlineEnterRegion(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTER_REGION, true));
    optimizer.inlineExitRegion(
        getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_REGION, true));

    flow = optimizer.transform(flow);

    return flow;
  }
コード例 #2
0
  @Override
  protected void setDefaultValue(
      FeatureType featureType, FeatureParameterValue parameterValue, EObject contextElement) {
    GeneratorEntry entry = (GeneratorEntry) contextElement;
    Statechart statechart = (Statechart) entry.getElementRef();

    if (parameterValue
        .getParameter()
        .getName()
        .equals(ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME)) {
      parameterValue.setValue(asIdentifier(statechart.getName(), "_"));
    } else if (parameterValue
        .getParameter()
        .getName()
        .equals(ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX)) {
      parameterValue.setValue(
          StringExtensions.toFirstLower(asIdentifier(statechart.getName(), "_")));
    } else if (parameterValue
        .getParameter()
        .getName()
        .equals(ICFeatureConstants.PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH)) {
      parameterValue.setValue("31");
    } else if (parameterValue
        .getParameter()
        .getName()
        .equals(ICFeatureConstants.PARAMETER_NAMING_SEPARATOR)) {
      parameterValue.setValue("_");
    } else if (parameterValue
        .getParameter()
        .getName()
        .equals(CPPFeatureConstants.PARAMETER_INNER_FUNCTION_VISIBILITY)) {
      parameterValue.setValue(Visibility.PRIVATE.toString().toLowerCase());
    } else if (parameterValue
        .getParameter()
        .getName()
        .equals(CPPFeatureConstants.PARAMETER_STATIC_OPC)) {
      parameterValue.setValue(false);
    }
  }
コード例 #3
0
 protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow, Output output) {
   ResourceSet resourceSet = new ResourceSetImpl();
   resourceSet
       .getResourceFactoryRegistry()
       .getExtensionToFactoryMap()
       .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
   URI fileURI =
       entry
           .getElementRef()
           .eResource()
           .getURI()
           .trimFileExtension()
           .appendFileExtension(SEXEC_FILE_EXTENSION);
   Resource resource = resourceSet.createResource(fileURI);
   resource.getContents().add(flow);
   try {
     resource.save(Collections.EMPTY_MAP);
   } catch (IOException e) {
   }
 }