Skip to content

Commit

Permalink
- Fixes for #1371
Browse files Browse the repository at this point in the history
- Implemented errors when functions contain illegal elements (except public elements that should be protected, since MSL uses that)
  - Added testcases FunctionWithEquation.mo and FunctionProtectedInput.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7470 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 17, 2010
1 parent 9df144f commit ae0246b
Show file tree
Hide file tree
Showing 28 changed files with 159 additions and 41 deletions.
4 changes: 4 additions & 0 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -1553,6 +1553,7 @@ protected function lowerAlgorithm
input Integer aindx;
output list<BackendDAE.Equation> lst;
output list<BackendDAE.Equation> lst1 "algorithms with no outputs will be moved to known equations";
protected
list<DAE.Exp> inputs,outputs;
BackendDAE.Value numnodes;
algorithm
Expand Down Expand Up @@ -1887,6 +1888,7 @@ protected function transformDelayExpressions
"Helper for processDelayExpressions()"
input tuple<DAE.Exp,Integer> itpl;
output tuple<DAE.Exp,Integer> otpl;
protected
DAE.Exp e;
Integer i;
algorithm
Expand Down Expand Up @@ -2598,6 +2600,7 @@ protected function differentZeroCrossing "function: differentZeroCrossing
input BackendDAE.ZeroCrossing zc1;
input BackendDAE.ZeroCrossing zc2;
output Boolean res_1;
protected
Boolean res;
algorithm
res := sameZeroCrossing(zc1, zc2);
Expand All @@ -2616,6 +2619,7 @@ public function findZeroCrossings "function: findZeroCrossings
input list<BackendDAE.WhenClause> wc;
input list<DAE.Algorithm> algs;
output list<BackendDAE.ZeroCrossing> res_1;
protected
list<BackendDAE.ZeroCrossing> res;
algorithm
res := findZeroCrossings2(vars, knvars,eq,multiDimEqs,1, wc, 1, algs);
Expand Down
5 changes: 5 additions & 0 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -83,6 +83,7 @@ public function checkBackendDAEWithErrorMsg"function: checkBackendDAEWithErrorMs
author: Frenkel TUD
run checkDEALow and prints all errors"
input BackendDAE.BackendDAE inBackendDAE;
protected
list<tuple<DAE.Exp,list<DAE.ComponentRef>>> expCrefs;
algorithm
expCrefs := checkBackendDAE(inBackendDAE);
Expand All @@ -104,6 +105,7 @@ algorithm

case ({}) then ();


case (((e,crefs))::res)
equation
false = RTOpts.debugFlag("checkBackendDAE");
Expand Down Expand Up @@ -1074,6 +1076,7 @@ public function emptyVars
Returns a Variable datastructure that is empty.
Using the bucketsize 10000 and array size 1000."
output BackendDAE.Variables outVariables;
protected
array<list<BackendDAE.CrefIndex>> arr;
array<list<BackendDAE.StringIndex>> arr2;
list<Option<BackendDAE.Var>> lst;
Expand Down Expand Up @@ -2591,6 +2594,7 @@ public function treeGet "function: treeGet
input BackendDAE.BinTree bt;
input BackendDAE.Key key;
output BackendDAE.Value v;
protected
String keystr;
algorithm
keystr := ComponentReference.printComponentRefStr(key);
Expand Down Expand Up @@ -3748,6 +3752,7 @@ public function transposeMatrix
i.e. which equations each variable is present in."
input BackendDAE.IncidenceMatrix m;
output BackendDAE.IncidenceMatrixT mt;
protected
list<list<BackendDAE.Value>> mlst,mtlst;
algorithm
mlst := arrayList(m);
Expand Down
2 changes: 2 additions & 0 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -469,6 +469,7 @@ public function crefSubIsScalar
scalar."
input DAE.ComponentRef cref;
output Boolean isScalar;
protected
list<DAE.Subscript> subs;
algorithm
subs := ComponentReference.crefSubs(cref);
Expand Down Expand Up @@ -7458,6 +7459,7 @@ protected function getCalledFunctionsInFunctions
input list<Absyn.Path> accumulated;
input DAE.FunctionTree funcs;
output list<Absyn.Path> res;
protected
list<list<Absyn.Path>> pathslist;
algorithm
res := matchcontinue(paths,accumulated,funcs)
Expand Down
1 change: 1 addition & 0 deletions Compiler/FrontEnd/Algorithm.mo
Expand Up @@ -406,6 +406,7 @@ protected function getPropExpType "function: getPropExpType
getTypeExpType. Used by makeAssignment."
input DAE.Properties p;
output DAE.ExpType t;
protected
tuple<DAE.TType, Option<Absyn.Path>> ty;
algorithm
ty := Types.getPropType(p);
Expand Down
1 change: 1 addition & 0 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -3038,6 +3038,7 @@ public function initialEnv "function: initialEnv
input Env.Cache inCache;
output Env.Cache outCache;
output list<Env.Frame> env;
protected
Env.Cache cache;
algorithm
(outCache,env) := matchcontinue(inCache)
Expand Down
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -1399,6 +1399,7 @@ protected function cevalKnownExternalFuncs "function: cevalKnownExternalFuncs
input Msg msg;
output Env.Cache outCache;
output Values.Value res;
protected
SCode.Class cdef;
list<Env.Frame> env_1;
String fid;
Expand Down Expand Up @@ -2993,6 +2994,7 @@ protected function cevalCat "function: cevalCat
input list<Values.Value> v_lst;
input Integer dim;
output Values.Value outValue;
protected
list<Values.Value> v_lst_1;
algorithm
v_lst_1 := catDimension(v_lst, dim);
Expand Down
10 changes: 5 additions & 5 deletions Compiler/FrontEnd/CevalFunction.mo
Expand Up @@ -962,7 +962,7 @@ protected function extendEnvWithForScope
output Env.Env outEnv;
output DAE.Type outIterType;
output DAE.ComponentRef outIterCref;

protected
DAE.ComponentRef iter_cr;
algorithm
outIterType := Types.expTypetoTypesType(inIterType);
Expand All @@ -985,7 +985,7 @@ protected function appendDimensions
input Env.Env inEnv;
output Env.Cache outCache;
output DAE.Type outType;

protected
list<Integer> binding_dims;
algorithm
binding_dims := ValuesUtil.valueDimensions(
Expand Down Expand Up @@ -1350,7 +1350,7 @@ protected function updateVariableBinding
input DAE.Type inType;
input Values.Value inNewValue;
output Env.Env outEnv;

protected
String var_name;
DAE.Var var;
algorithm
Expand Down Expand Up @@ -1379,7 +1379,7 @@ protected function getVariableTypeAndValue
input Env.Env inEnv;
output DAE.Type outType;
output Values.Value outValue;

protected
DAE.Binding binding;
algorithm
(outType, binding) := getVariableTypeAndBinding(inCref, inEnv);
Expand Down Expand Up @@ -1691,7 +1691,7 @@ protected function findDependencies
input DAE.ComponentRef inCref;
input list<Dependency> inDependencies;
output list<DAE.ComponentRef> outDependencies;

protected
list<DAE.ComponentRef> deps;
list<list<DAE.ComponentRef>> dep_deps;
algorithm
Expand Down

0 comments on commit ae0246b

Please sign in to comment.