Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2015-07-05 10:18:06 -0400
committerHenrik Rentz-Reichert2015-07-05 10:18:06 -0400
commitc1b9ca1eda69114640c54b05bf8988ea686e765d (patch)
tree3e31f1e907f693d5fbce24bb1469ba730db81eb7 /plugins
parent8ac4564d7f2c915e9d164820313055f0242b654c (diff)
downloadorg.eclipse.etrice-c1b9ca1eda69114640c54b05bf8988ea686e765d.tar.gz
org.eclipse.etrice-c1b9ca1eda69114640c54b05bf8988ea686e765d.tar.xz
org.eclipse.etrice-c1b9ca1eda69114640c54b05bf8988ea686e765d.zip
[generator.fsm, generator.c, genmodel.fsm] avoid warnings in generated code
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/TransitionChainImpl.java8
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Initialization.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/Initialization.java24
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend16
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java66
6 files changed, 91 insertions, 27 deletions
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/TransitionChainImpl.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/TransitionChainImpl.java
index 7d279ea9b..b54eb5b3a 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/TransitionChainImpl.java
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/fsmgen/impl/TransitionChainImpl.java
@@ -216,7 +216,15 @@ public class TransitionChainImpl extends MinimalEObjectImpl.Container implements
ExpandedModelComponent emc = getExpandedModelComponent();
StringBuilder result = new StringBuilder();
+
+ /* TODO: the next generated code declares a correctly typed variable for the generic data.
+ * It is hard to determine whether it is actually needed though.
+ * It is needed in non-initial transitions with action code that are not data driven.
+ * It might be needed in condition expressions. But this code would have to be parsed
+ * with uncertain result (because of e.g. comments).
+ */
result.append(tcv.genTypedData(this));
+
genChainCode(getTransition(), emc, tcv, result);
return result.toString();
}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch b/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch
index 8f731dcd1..a4adb96c5 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch
+++ b/plugins/org.eclipse.etrice.core.room.ui/eTrice-rt.launch
@@ -17,7 +17,7 @@
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m -XX:MaxPermSize=256m -ea"/>
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Initialization.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Initialization.xtend
index 49c9edc77..31b8403ba 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Initialization.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Initialization.xtend
@@ -79,6 +79,8 @@ class Initialization {
var value = getPrimitiveValue(instance, path)
if(a.size > 0 && !aType.characterType && !value.trim.startsWith('{'))
'''{«FOR Integer i:1..a.size SEPARATOR ', '»«value»«ENDFOR»}'''
+ else if (a.size > 0 && aType.characterType && value.startsWith("'"))
+ "{"+value+"}"
else
value
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/Initialization.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/Initialization.java
index a0213edf8..f770b2dff 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/Initialization.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/Initialization.java
@@ -251,7 +251,29 @@ public class Initialization {
_builder.append("}");
_xifexpression_1 = _builder;
} else {
- _xifexpression_1 = value;
+ String _xifexpression_2 = null;
+ boolean _and_2 = false;
+ boolean _and_3 = false;
+ int _size_2 = a.getSize();
+ boolean _greaterThan_1 = (_size_2 > 0);
+ if (!_greaterThan_1) {
+ _and_3 = false;
+ } else {
+ boolean _isCharacterType_1 = this._typeHelpers.isCharacterType(((PrimitiveType)aType));
+ _and_3 = _isCharacterType_1;
+ }
+ if (!_and_3) {
+ _and_2 = false;
+ } else {
+ boolean _startsWith_1 = value.startsWith("\'");
+ _and_2 = _startsWith_1;
+ }
+ if (_and_2) {
+ _xifexpression_2 = (("{" + value) + "}");
+ } else {
+ _xifexpression_2 = value;
+ }
+ _xifexpression_1 = _xifexpression_2;
}
_xblockexpression_1 = _xifexpression_1;
}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
index 0b06cd2c8..068aa3529 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.xtend
@@ -324,14 +324,20 @@ abstract class AbstractStateMachineGenerator {
*/
«IF generateImplementation»
«privAccess»«stateType» «opScopePriv»enterHistory(«selfPtr»«stateType» state__et«IF usesHdlr», «boolType» handler__et«ENDIF») {
- «boolType» skip_entry__et = «langExt.booleanConstant(false)»;
+ «val baseStateList = xpmc.stateMachine.baseStateList»
+ «val needsSkipVar = !baseStateList.filter(s|s.hasEntryCode(true)).empty»
+ «IF needsSkipVar»
+ «boolType» skip_entry__et = «langExt.booleanConstant(false)»;
+ «ENDIF»
if (state__et >= STATE_MAX) {
state__et = «IF !langExt.usesInheritance»(«stateType»)«ENDIF» (state__et - STATE_MAX);
- skip_entry__et = «langExt.booleanConstant(true)»;
+ «IF needsSkipVar»
+ skip_entry__et = «langExt.booleanConstant(true)»;
+ «ENDIF»
}
while («langExt.booleanConstant(true)») {
switch (state__et) {
- «FOR state : xpmc.stateMachine.getBaseStateList()»
+ «FOR state : baseStateList»
case «state.getGenStateId()»:
«IF state.hasEntryCode(true)»if (!(skip_entry__et«IF usesHdlr» || handler__et«ENDIF»)) «state.getEntryCodeOperationName()»(«langExt.selfPointer(false)»);«ENDIF»
«IF state.isLeaf()»
@@ -362,7 +368,9 @@ abstract class AbstractStateMachineGenerator {
/* should not occur */
break;
}
- skip_entry__et = «langExt.booleanConstant(false)»;
+ «IF needsSkipVar»
+ skip_entry__et = «langExt.booleanConstant(false)»;
+ «ENDIF»
}
«unreachableReturn»
}
diff --git a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
index b373d8488..aea0fdf27 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/xtend-gen/org/eclipse/etrice/generator/fsm/generic/AbstractStateMachineGenerator.java
@@ -709,13 +709,31 @@ public abstract class AbstractStateMachineGenerator {
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- String _boolType_3 = this.boolType();
- _builder.append(_boolType_3, "\t");
- _builder.append(" skip_entry__et = ");
- String _booleanConstant = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant, "\t");
- _builder.append(";");
+ StateGraph _stateMachine_1 = xpmc.getStateMachine();
+ final List<State> baseStateList = this._fSMHelpers.getBaseStateList(_stateMachine_1);
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ final Function1<State, Boolean> _function = new Function1<State, Boolean>() {
+ public Boolean apply(final State s) {
+ return Boolean.valueOf(AbstractStateMachineGenerator.this._fSMHelpers.hasEntryCode(s, true));
+ }
+ };
+ Iterable<State> _filter = IterableExtensions.<State>filter(baseStateList, _function);
+ boolean _isEmpty = IterableExtensions.isEmpty(_filter);
+ final boolean needsSkipVar = (!_isEmpty);
_builder.newLineIfNotEmpty();
+ {
+ if (needsSkipVar) {
+ _builder.append("\t");
+ String _boolType_3 = this.boolType();
+ _builder.append(_boolType_3, "\t");
+ _builder.append(" skip_entry__et = ");
+ String _booleanConstant = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant, "\t");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("\t");
_builder.append("if (state__et >= STATE_MAX) {");
_builder.newLine();
@@ -733,12 +751,16 @@ public abstract class AbstractStateMachineGenerator {
}
_builder.append(" (state__et - STATE_MAX);");
_builder.newLineIfNotEmpty();
- _builder.append("\t\t");
- _builder.append("skip_entry__et = ");
- String _booleanConstant_1 = this.langExt.booleanConstant(true);
- _builder.append(_booleanConstant_1, "\t\t");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ {
+ if (needsSkipVar) {
+ _builder.append("\t\t");
+ _builder.append("skip_entry__et = ");
+ String _booleanConstant_1 = this.langExt.booleanConstant(true);
+ _builder.append(_booleanConstant_1, "\t\t");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("\t");
_builder.append("}");
_builder.newLine();
@@ -752,9 +774,7 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("switch (state__et) {");
_builder.newLine();
{
- StateGraph _stateMachine_1 = xpmc.getStateMachine();
- List<State> _baseStateList_1 = this._fSMHelpers.getBaseStateList(_stateMachine_1);
- for(final State state_1 : _baseStateList_1) {
+ for(final State state_1 : baseStateList) {
_builder.append("\t\t\t");
_builder.append("case ");
String _genStateId_2 = this._codegenHelpers.getGenStateId(state_1);
@@ -912,12 +932,16 @@ public abstract class AbstractStateMachineGenerator {
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
- _builder.append("\t\t");
- _builder.append("skip_entry__et = ");
- String _booleanConstant_3 = this.langExt.booleanConstant(false);
- _builder.append(_booleanConstant_3, "\t\t");
- _builder.append(";");
- _builder.newLineIfNotEmpty();
+ {
+ if (needsSkipVar) {
+ _builder.append("\t\t");
+ _builder.append("skip_entry__et = ");
+ String _booleanConstant_3 = this.langExt.booleanConstant(false);
+ _builder.append(_booleanConstant_3, "\t\t");
+ _builder.append(";");
+ _builder.newLineIfNotEmpty();
+ }
+ }
_builder.append("\t");
_builder.append("}");
_builder.newLine();

Back to the top