Просмотр исходного кода

Added ActiveStateReferenceExpression to StextStatementInterpreter

Andreas Mülder 14 лет назад
Родитель
Сommit
0ffe1b2fb2

+ 9 - 2
plugins/org.yakindu.sct.model.sexec.interpreter/src/org/yakindu/sct/model/sexec/interpreter/stext/StextStatementInterpreter.xtend

@@ -119,7 +119,14 @@ class StextStatementInterpreter extends AbstractStatementInterpreter {
 		null;
 	}
 	
-	
+	def dispatch execute(ActiveStateReferenceExpression expression){
+		for(activeState : context.allActiveStates){
+			if(activeState == expression.value){
+				return true;
+			}
+		}
+		return false;
+	}
 	
 	def dispatch execute(LogicalAndExpression expression){
 		var leftResult = execute(expression.leftOperand)
@@ -140,7 +147,7 @@ class StextStatementInterpreter extends AbstractStatementInterpreter {
 		executeBinaryCoreFunction(expression.leftOperand, expression.rightOperand, CoreFunction::BIT_AND)
 	}
 	def dispatch execute(BitwiseOrExpression expression){
-			executeBinaryCoreFunction(expression.leftOperand, expression.rightOperand, CoreFunction::BIT_OR)
+		executeBinaryCoreFunction(expression.leftOperand, expression.rightOperand, CoreFunction::BIT_OR)
 	}
 	def dispatch execute(BitwiseXorExpression expression){
 		executeBinaryCoreFunction(expression.leftOperand, expression.rightOperand, CoreFunction::BIT_XOR)		

+ 8 - 8
plugins/org.yakindu.sct.model.sexec.interpreter/xtend-gen/org/yakindu/sct/model/sexec/interpreter/impl/ExecutionFlowInterpreter.java

@@ -77,7 +77,7 @@ public class ExecutionFlowInterpreter extends AbstractExecutionFacade implements
     {
       this.flow = flow;
       EList<Scope> _scopes = flow.getScopes();
-      for (Scope scope : _scopes) {
+      for (final Scope scope : _scopes) {
         this.declareContents(scope);
       }
       StateVector _stateVector = flow.getStateVector();
@@ -100,21 +100,21 @@ public class ExecutionFlowInterpreter extends AbstractExecutionFacade implements
   
   protected void _declareContents(final InternalScope scope) throws NumberFormatException {
     EList<Declaration> _declarations = scope.getDeclarations();
-    for (Declaration declaration : _declarations) {
+    for (final Declaration declaration : _declarations) {
       this.addToScope(declaration);
     }
   }
   
   protected void _declareContents(final Scope scope) throws NumberFormatException {
     EList<Declaration> _declarations = scope.getDeclarations();
-    for (Declaration declaration : _declarations) {
+    for (final Declaration declaration : _declarations) {
       this.addToScope(declaration);
     }
   }
   
   protected void _declareContents(final InterfaceScope scope) throws NumberFormatException {
     EList<Declaration> _declarations = scope.getDeclarations();
-    for (Declaration declaration : _declarations) {
+    for (final Declaration declaration : _declarations) {
       this.addToScope(declaration);
     }
   }
@@ -284,7 +284,7 @@ public class ExecutionFlowInterpreter extends AbstractExecutionFacade implements
   public void enter() throws ExecutionException {
     Sequence _enterSequence = this.flow.getEnterSequence();
     EList<Step> _steps = _enterSequence.getSteps();
-    for (Step step : _steps) {
+    for (final Step step : _steps) {
       this.execute(step);
     }
   }
@@ -319,7 +319,7 @@ public class ExecutionFlowInterpreter extends AbstractExecutionFacade implements
       Statement _condition = check.getCondition();
       boolean _operator_equals = ObjectExtensions.operator_equals(_condition, null);
       if (_operator_equals) {
-        return true;
+        return ((Boolean)true);
       }
       Statement _condition_1 = check.getCondition();
       Object _evaluateStatement = this.interpreter.evaluateStatement(_condition_1, this.executionContext);
@@ -437,7 +437,7 @@ public class ExecutionFlowInterpreter extends AbstractExecutionFacade implements
     Object _xblockexpression = null;
     {
       EList<Step> _steps = sequence.getSteps();
-      for (Step step : _steps) {
+      for (final Step step : _steps) {
         this.execute(step);
       }
       _xblockexpression = (null);
@@ -449,7 +449,7 @@ public class ExecutionFlowInterpreter extends AbstractExecutionFacade implements
     Object _xblockexpression = null;
     {
       EList<StateCase> _cases = stateSwitch.getCases();
-      for (StateCase stateCase : _cases) {
+      for (final StateCase stateCase : _cases) {
         this.execute(stateCase);
       }
       _xblockexpression = (null);

+ 20 - 1
plugins/org.yakindu.sct.model.sexec.interpreter/xtend-gen/org/yakindu/sct/model/sexec/interpreter/stext/StextStatementInterpreter.java

@@ -2,6 +2,7 @@ package org.yakindu.sct.model.sexec.interpreter.stext;
 
 import com.google.inject.Inject;
 import java.util.List;
+import java.util.Set;
 import org.eclipse.xtext.naming.QualifiedName;
 import org.eclipse.xtext.xbase.lib.BooleanExtensions;
 import org.eclipse.xtext.xbase.lib.ObjectExtensions;
@@ -9,9 +10,11 @@ import org.yakindu.sct.model.sexec.interpreter.stext.AbstractStatementInterprete
 import org.yakindu.sct.model.sexec.interpreter.stext.CoreFunction;
 import org.yakindu.sct.model.sgraph.Declaration;
 import org.yakindu.sct.model.sgraph.Event;
+import org.yakindu.sct.model.sgraph.RegularState;
 import org.yakindu.sct.model.sgraph.Statement;
 import org.yakindu.sct.model.sgraph.Variable;
 import org.yakindu.sct.model.stext.naming.StextNameProvider;
+import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
 import org.yakindu.sct.model.stext.stext.AdditiveOperator;
 import org.yakindu.sct.model.stext.stext.Assignment;
 import org.yakindu.sct.model.stext.stext.AssignmentOperator;
@@ -187,6 +190,20 @@ public class StextStatementInterpreter extends AbstractStatementInterpreter {
     return _xblockexpression;
   }
   
+  protected Object _execute(final ActiveStateReferenceExpression expression) {
+    {
+      Set<RegularState> _allActiveStates = this.context.getAllActiveStates();
+      for (final RegularState activeState : _allActiveStates) {
+        RegularState _value = expression.getValue();
+        boolean _operator_equals = ObjectExtensions.operator_equals(activeState, _value);
+        if (_operator_equals) {
+          return true;
+        }
+      }
+      return false;
+    }
+  }
+  
   protected Object _execute(final LogicalAndExpression expression) throws ExecutionException {
     {
       Expression _leftOperand = expression.getLeftOperand();
@@ -353,7 +370,9 @@ public class StextStatementInterpreter extends AbstractStatementInterpreter {
   }
   
   public Object execute(final Statement expression) throws ExecutionException {
-    if ((expression instanceof BitwiseAndExpression)) {
+    if ((expression instanceof ActiveStateReferenceExpression)) {
+      return _execute((ActiveStateReferenceExpression)expression);
+    } else if ((expression instanceof BitwiseAndExpression)) {
       return _execute((BitwiseAndExpression)expression);
     } else if ((expression instanceof BitwiseOrExpression)) {
       return _execute((BitwiseOrExpression)expression);