Skip to content

Commit

Permalink
Compiler/Database.mo
Browse files Browse the repository at this point in the history
Compiler/runtime/Database.c
Compiler/runtime/sqlite
- a wrapper for SQlite (empty and unused for now)

Compiler/omc_profiler/Makefile.omdev.mingw
- use large address aware

Makefile*
- update so Database modules are compiled and linked in.

Ceval.mo
- better trace messages in Ceval.cevalSubscriptValue

CevalScript.mo
- filter Modelica.Media and Modelica.Fluid in
  CevalScript.checkAllModelsRecursive, also output
  the number of classes checked.

DAE.mo
- added DAE.DimensionBinding to be used for future
  handling of unknown dimensions (similar with type
  variables and inference in functional programming)
- these changes are commented out for now

DAEDump.mo
- handle all types of equations in DAEDump.dump2

DAELow.mo
- use Exp.crefEqualNoStringCompare everywhere.
- minor speedups by changing listAppend({var}, lst) to var::lst.
- partially handle DAE array equations in DAELow.lowerWhenEqn2
  and don't fail when checkModel is active.
- handle unknown dimensions DAE.DIM_UNKNOWN when checkModel
  is active in DAELow.traversingextendArrExp by using
  DAE.DIM_INTEGER(1).

DAEUtil.mo
- better message out of DAEUtil.verifyWhenEquation
- allow DAE.NORETCALL inside when equations.

Exp.mo
- handle enum literal in Exp.typeof

Inst.mo
- some more comments on Inst.instClassIn_dispatch(ENUMERATION)

InstSection.mo
- make sure we handle DAE.DIM_UNKNOWN when checkModel is active with 
  more care in InstSection.instArrayEquation and InstSection.expandArrayDimension
  as otherwise we generate equations like 1 = 1.

SCode.mo
- handle when equations in SCode.equationStr

Static.mo
- minor formatting.

Types.mo
- handle enumeration in Types.mo Types.matchWithPromote
  helps a bit Modelica.Electrical.Digital
- better unparsing/printing of enumerations

ValuesUtil.mo
- handle enumeration literals in ValuesUtil.valueIntegerMinusOne
  helps with Ceval of enumeration slices.

testsuite/mofiles/drmodelica/WhenNotValid.mo
- changes due to better error messages.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6225 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 27, 2010
1 parent 1a8ba82 commit a703380
Show file tree
Hide file tree
Showing 17 changed files with 579 additions and 247 deletions.
31 changes: 26 additions & 5 deletions Compiler/Ceval.mo
Expand Up @@ -147,6 +147,16 @@ algorithm
list<Integer> dims;
list<DAE.Dimension> arrayDims;

/* uncomment for debugging
case (cache,env,inExp,_,st,_,_)
equation
print("Ceval.ceval: " +&
Exp.printExpStr(inExp) +&
" in env: " +& Env.printEnvPathStr(env) +& "\n");
then
fail();
*/

case (cache,_,DAE.ICONST(integer = x),_,st,_,_) then (cache,Values.INTEGER(x),st);

case (cache,_,DAE.RCONST(real = x),_,st,_,_)
Expand Down Expand Up @@ -5034,8 +5044,7 @@ protected function cevalSubscriptValue "function: cevalSubscriptValue
output Env.Cache outCache;
output Values.Value outValue;
algorithm
(outCache,outValue) :=
matchcontinue (inCache,inEnv,inExpSubscriptLst,inValue,inIntegerLst,inBoolean,inMsg)
(outCache,outValue) := matchcontinue (inCache,inEnv,inExpSubscriptLst,inValue,inIntegerLst,inBoolean,inMsg)
local
Integer n,n_1,dim;
Values.Value subval,res,v;
Expand All @@ -5057,14 +5066,18 @@ algorithm
(cache,res) = cevalSubscriptValue(cache, env, subs, subval, dims, impl, msg);
then
(cache,res);

// ceval gives us a enumeration literal scalar
case (cache,env,(DAE.INDEX(exp = exp) :: subs),Values.ARRAY(valueLst = lst),(dim :: dims),impl,msg)
equation
(cache,Values.ENUM_LITERAL(index = n),_) = ceval(cache, env, exp, impl, NONE, SOME(dim), msg);
n_1 = n - 1;
subval = listNth(lst, n_1);
subval = listNth(lst, n_1); // listNth indexes from 0!
(cache,res) = cevalSubscriptValue(cache, env, subs, subval, dims, impl, msg);
then
(cache,res);

// slices
case (cache,env,(DAE.SLICE(exp = exp) :: subs),Values.ARRAY(valueLst = lst),(dim :: dims),impl,msg)
equation
(cache,subval as Values.ARRAY(valueLst = sliceLst),_) = ceval(cache, env, exp, impl, NONE, SOME(dim), msg);
Expand All @@ -5074,6 +5087,7 @@ algorithm
res = ValuesUtil.makeArray(lst);
then
(cache,res);

// we have a wholedim, so just pass the whole array on.
case (cache, env, (DAE.WHOLEDIM() :: subs), subval as Values.ARRAY(valueLst = _), (dim :: dims), impl, msg)
equation
Expand All @@ -5085,9 +5099,16 @@ algorithm
case (cache,env,{},v,_,_,_) then (cache,v);

// failtrace
case (_,_,_,_,_,_,_)
case (cache, env, subs, inValue, dims, _, _)
equation
Debug.fprint("failtrace", "- Ceval.cevalSubscriptValue failed\n");
true = RTOpts.debugFlag("failtrace");
Debug.fprintln("failtrace", "- Ceval.cevalSubscriptValue failed on:" +&
"\n env: " +& Env.printEnvPathStr(env) +&
"\n subs: " +& Util.stringDelimitList(Util.listMap(subs, Exp.printSubscriptStr), ", ") +&
"\n value: " +& ValuesUtil.printValStr(inValue) +&
"\n dim sizes: " +& Util.stringDelimitList(Util.listMap(dims, intString), ", ") +&
"\n env: " +& Env.printEnvStr(env)
);
then
fail();
end matchcontinue;
Expand Down
5 changes: 3 additions & 2 deletions Compiler/CevalScript.mo
Expand Up @@ -4054,13 +4054,14 @@ algorithm
case (cache,env,className,(st as Interactive.SYMBOLTABLE(ast = p,explodedAst = sp,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)),msg)
equation
allClassPaths = getAllClassPathsRecursive(className, p);
// allClassPaths = Util.listSelect(allClassPaths, filterLib);
allClassPaths = Util.listSelect(allClassPaths, filterLib);
// allClassPaths = listReverse(allClassPaths);
print("Number of classes to check: " +& intString(listLength(allClassPaths)) +& "\n");
// print ("All paths: \n" +& Util.stringDelimitList(Util.listMap(allClassPaths, Absyn.pathString), "\n") +& "\n");
checkAll(cache, env, allClassPaths, st, msg);
ret = "Number of classes checked: " +& intString(listLength(allClassPaths));
then
(cache,Values.STRING("done"),st);
(cache,Values.STRING(ret),st);
case (cache,env,className,(st as Interactive.SYMBOLTABLE(ast = p,explodedAst = sp,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)),msg)
equation
ret = stringAppend("Error checking: ", Absyn.pathString(className));
Expand Down
16 changes: 14 additions & 2 deletions Compiler/DAE.mo
Expand Up @@ -770,9 +770,23 @@ uniontype Dimension
end DIM_EXP;

record DIM_UNKNOWN "Dimension with unknown size."
//DimensionBinding dimensionBinding "unknown dimension can be bound or unbound";
end DIM_UNKNOWN;
end Dimension;

// adrpo: this is used to bind unknown dimensions to an expression
// and when we do subtyping we add constrains to this expression.
// this should be used for typechecking with unknown dimensions
// when running checkModel. the binding acts like a type variable.
public uniontype DimensionBinding
record DIM_UNBOUND "dimension is not bound"
end DIM_UNBOUND;
record DIM_BOUND "dimension is bound to an expression with constrains"
Exp binding "the dimension is bound to this expression";
list<Dimension> constrains "the bound has these constrains (collected when doing subtyping)";
end DIM_BOUND;
end DimensionBinding;

public
type FuncArg = tuple<Ident, Type> "- Function Argument" ;

Expand Down Expand Up @@ -899,8 +913,6 @@ uniontype ExpType "- Basic types

record ET_STRING end ET_STRING;

// record ENUM end ENUM;

record ET_ENUMERATION
Option<Integer> index "the enumeration value index, SOME for element, NONE for type" ;
Absyn.Path path "enumeration path" ;
Expand Down
28 changes: 28 additions & 0 deletions Compiler/DAEDump.mo
Expand Up @@ -231,6 +231,8 @@ algorithm
tuple<DAE.TType, Option<Absyn.Path>> tp;
DAE.ExternalDecl extdecl;
DAE.FunctionTree funcs;
list<Integer> dl;

case DAE.DAE((DAE.VAR(componentRef = cr,
binding = SOME(e),
dims = dims,
Expand Down Expand Up @@ -315,6 +317,32 @@ algorithm
dump2(DAE.DAE(xs,funcs));
then
();
case DAE.DAE((DAE.ARRAY_EQUATION(dimension=dl,exp = e1,array = e2) :: xs),funcs)
equation
Print.printBuf("ARRAY_EQUATION(");
Print.printBuf("dims = [");
Print.printBuf(Util.stringDelimitList(Util.listMap(dl, intString), ", "));
Print.printBuf("]; ");
Exp.printExp(e1);
Print.printBuf(" = ");
Exp.printExp(e2);
Print.printBuf(")\n");
dump2(DAE.DAE(xs,funcs));
then
();
case DAE.DAE((DAE.INITIAL_ARRAY_EQUATION(dimension=dl,exp = e1,array = e2) :: xs),funcs)
equation
Print.printBuf("INITIAL_ARRAY_EQUATION(");
Print.printBuf("dims = [");
Print.printBuf(Util.stringDelimitList(Util.listMap(dl, intString), ", "));
Print.printBuf("]; ");
Exp.printExp(e1);
Print.printBuf(" = ");
Exp.printExp(e2);
Print.printBuf(")\n");
dump2(DAE.DAE(xs,funcs));
then
();
case (DAE.DAE((DAE.ALGORITHM(algorithm_ = _) :: xs),funcs))
equation
Print.printBuf("ALGORITHM(...)");
Expand Down

0 comments on commit a703380

Please sign in to comment.