Opened 2 weeks ago

Last modified 2 weeks ago

#5869 new defect

FColonSizeExp is scalar

Reported by: Jesper Mattsson Owned by: Jesper Mattsson
Priority: major Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:

Description

FColonSizeExp should not be FAbstractArrayExp, it is always scalar. Also it should implement cevalCalc (just returning UNKNOWN?).

Change History (1)

comment:1 Changed 2 weeks ago by Jesper Mattsson

Suggested implementation:

Index: Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ConstantEvaluation.jrag
===================================================================
--- Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ConstantEvaluation.jrag	(revision 13897)
+++ Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ConstantEvaluation.jrag	(working copy)
@@ -2403,10 +2403,10 @@
      * This needs to be overridden for subclasses of FExp.
      */
     syn CValue FExp.cevalCalc(VariableEvaluator evaluator);
-    eq FUnsupportedExp.cevalCalc(VariableEvaluator evaluator) = CValue.UNSUPPORTED;
-    eq FAbstractArrayExp.cevalCalc(VariableEvaluator evaluator) { throw new ConstantEvaluationException(null, "Can not evaluate scalar array expression ");}
-    eq InstPreExp.cevalCalc(VariableEvaluator evaluator) = CValue.UNSUPPORTED;
-    eq FNoExp.cevalCalc(VariableEvaluator evaluator) = CValue.UNSUPPORTED;
+    eq FUnsupportedExp.cevalCalc(VariableEvaluator evaluator)   = CValue.UNSUPPORTED;
+    eq InstPreExp.cevalCalc(VariableEvaluator evaluator)        = CValue.UNSUPPORTED;
+    eq FNoExp.cevalCalc(VariableEvaluator evaluator)            = CValue.UNSUPPORTED;
+    eq FAbstractArrayExp.cevalCalc(VariableEvaluator evaluator) = CValue.UNSUPPORTED;
 
     eq FTimeExp.cevalCalc(VariableEvaluator evaluator) = evaluator.timeValue();
     
@@ -2595,6 +2595,7 @@
             getFExp().size().ceval(evaluator, dimension());
     eq FUnknownSizeExp.cevalCalc(VariableEvaluator evaluator) =
             inFunction() ? getFExp().cevalCalc(evaluator).size().ceval(evaluator, dimension()) : CValue.UNKNOWN;
+    eq FColonSizeExp.cevalCalc(VariableEvaluator evaluator) = CValue.UNKNOWN;
     
     public CValue Size.ceval(VariableEvaluator evaluator, int d) {
         int s = get(d);
Index: Compiler/ModelicaFlatTree/src/jastadd/ast/FlatModelica.ast
===================================================================
--- Compiler/ModelicaFlatTree/src/jastadd/ast/FlatModelica.ast	(revision 13897)
+++ Compiler/ModelicaFlatTree/src/jastadd/ast/FlatModelica.ast	(working copy)
@@ -1133,7 +1133,7 @@
  * 
  * Only used in Size objects.
  */
-FColonSizeExp : FAbstractArrayExp ::= <Variable:CommonVariableDecl> <Dim:int>;
+FColonSizeExp : FAbstractScalarExp ::= <Variable:CommonVariableDecl> <Dim:int>;
 
 /**
  * Dummy node.
Note: See TracTickets for help on using tickets.