Skip to content

Commit

Permalink
Reverted -r 5194 as it destroyed a lot of testcases at MathCore. I wi…
Browse files Browse the repository at this point in the history
…ll add these as instantiation tests in OpenModelica later today.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5214 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 26, 2010
1 parent 562109b commit 9e8a425
Show file tree
Hide file tree
Showing 13 changed files with 1,140 additions and 373 deletions.
34 changes: 17 additions & 17 deletions Compiler/Builtin.mo
Expand Up @@ -78,67 +78,67 @@ protected constant SCode.Class enumType=SCode.CLASS("EnumType",false,false,SCode

protected constant SCode.Element unit=SCode.COMPONENT("unit",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("StringType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),NONE,NONE,NONE,NONE) "This `unit\' component is used in several places below, and it is
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),{},NONE,NONE,NONE,NONE) "This `unit\' component is used in several places below, and it is
declared once here to make the definitions below easier to read." ;

protected constant SCode.Element quantity=SCode.COMPONENT("quantity",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("StringType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element displayUnit=SCode.COMPONENT("displayUnit",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("StringType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element min=SCode.COMPONENT("min",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("RealType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.REAL(-1e+099),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.REAL(-1e+099),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element max=SCode.COMPONENT("max",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("RealType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.REAL(1e+099),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.REAL(1e+099),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element realStart=SCode.COMPONENT("start",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("RealType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.REAL(0.0),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.REAL(0.0),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element integerStart=SCode.COMPONENT("start",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("IntegerType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.INTEGER(0),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.INTEGER(0),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element stringStart=SCode.COMPONENT("start",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("StringType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.STRING(""),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element booleanStart=SCode.COMPONENT("start",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("BooleanType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.BOOL(false),false))),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.BOOL(false),false))),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element fixed=SCode.COMPONENT("fixed",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("BooleanType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.BOOL(false),false))),NONE,NONE,NONE,NONE) "Should be true for variables" ;
SCode.MOD(false,Absyn.NON_EACH(),{},SOME((Absyn.BOOL(false),false))),{},NONE,NONE,NONE,NONE) "Should be true for variables" ;

protected constant SCode.Element nominal=SCode.COMPONENT("nominal",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("RealType"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},NONE),NONE,NONE,NONE,NONE);
SCode.MOD(false,Absyn.NON_EACH(),{},NONE),{},NONE,NONE,NONE,NONE);

protected constant SCode.Element stateSelect=SCode.COMPONENT("stateSelect",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("StateSelect"),NONE),
SCode.MOD(false,Absyn.NON_EACH(),{},
SOME((
Absyn.CREF(
Absyn.CREF_QUAL("StateSelect",{},Absyn.CREF_IDENT("default",{}))),false))),NONE,NONE,NONE,NONE);
Absyn.CREF_QUAL("StateSelect",{},Absyn.CREF_IDENT("default",{}))),false))),{},NONE,NONE,NONE,NONE);

protected constant list<SCode.Element> stateSelectComps={
SCode.COMPONENT("never",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),NONE,NONE,NONE,NONE),
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),{},NONE,NONE,NONE,NONE),
SCode.COMPONENT("avoid",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),NONE,NONE,NONE,NONE),
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),{},NONE,NONE,NONE,NONE),
SCode.COMPONENT("default",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),NONE,NONE,NONE,NONE),
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),{},NONE,NONE,NONE,NONE),
SCode.COMPONENT("prefer",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),NONE,NONE,NONE,NONE),
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),{},NONE,NONE,NONE,NONE),
SCode.COMPONENT("always",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),NONE,NONE,NONE,NONE)} "The StateSelect enumeration" ;
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),{},NONE,NONE,NONE,NONE)} "The StateSelect enumeration" ;

protected constant SCode.Class stateSelectType=SCode.CLASS("StateSelect",false,false,SCode.R_ENUMERATION(),
SCode.PARTS(stateSelectComps,{},{},{},{},NONE,{},NONE),Absyn.dummyInfo) "The State Select Type";
Expand Down
4 changes: 0 additions & 4 deletions Compiler/Ceval.mo
Expand Up @@ -268,15 +268,13 @@ algorithm
Interactive.InteractiveSymbolTable st;
equation
(cache,v) = cevalCref(cache,env, c, false, msg) "When in interactive mode, always evalutate crefs, i.e non-implicit mode.." ;
//Debug.traceln("cevalCref cr: " +& Exp.printComponentRefStr(c) +& " in s: " +& Env.printEnvPathStr(env) +& " v:" +& ValuesUtil.valString(v));
then
(cache,v,SOME(st));

case (cache,env,DAE.CREF(componentRef = c),impl,st,_,msg)
local DAE.ComponentRef c;
equation
(cache,v) = cevalCref(cache,env, c, impl, msg);
//Debug.traceln("cevalCref cr: " +& Exp.printComponentRefStr(c) +& " in s: " +& Env.printEnvPathStr(env) +& " v:" +& ValuesUtil.valString(v));
then
(cache,v,st);

Expand Down Expand Up @@ -696,7 +694,6 @@ algorithm
case (cache,env,DAE.RELATION(exp1 = lhs,operator = relop,exp2 = rhs),impl,st,dim,msg)
local Option<Integer> dim;
equation
Debug.traceln("cevalRelation " +& Exp.printExpStr(inExp));
(cache,lhs_1,st_1) = ceval(cache,env, lhs, impl, st, dim, msg);
(cache,rhs_1,st_2) = ceval(cache,env, rhs, impl, st_1, dim, msg);
v = cevalRelation(lhs_1, relop, rhs_1);
Expand Down Expand Up @@ -4288,7 +4285,6 @@ algorithm
case (Values.INTEGER(integer = i1),DAE.EQUAL(ty = DAE.ET_INT()),Values.INTEGER(integer = i2))
equation
b = (i1 == i2);
Debug.traceln("ceval eq: " +& Util.boolString(b));
then
Values.BOOL(b);
case (Values.INTEGER(integer = i1),DAE.NEQUAL(ty = DAE.ET_INT()),Values.INTEGER(integer = i2))
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Cevalfunc.mo
Expand Up @@ -563,7 +563,7 @@ algorithm outEnv := matchcontinue(env,inAlgs,ht2)
Env.Env env1,env2;

case(env,{},_) then env;
case(env, (alg as SCode.ALGORITHM(alglst)) :: algs,ht2)
case(env, (alg as SCode.ALGORITHM(alglst,_)) :: algs,ht2)
equation
(env1) = evaluateAlgorithms(env,alglst,ht2);
(env2) = evaluateAlgorithmsList(env1,algs,ht2);
Expand Down
93 changes: 36 additions & 57 deletions Compiler/ClassInf.mo
Expand Up @@ -158,16 +158,12 @@ uniontype Event "- Events"

record NEWDEF "A definition with elements, i.e. a long definition" end NEWDEF;

record FOUND_COMPONENT " A Definition that contains components"
String name "name of the component";
end FOUND_COMPONENT;
record FOUND_COMPONENT " A Definition that contains components" end FOUND_COMPONENT;

end Event;

protected import Debug;
protected import Print;
protected import Error;
protected import RTOpts;

public function printStateStr "- Printing

Expand Down Expand Up @@ -339,18 +335,23 @@ algorithm
end matchcontinue;
end getStateName;

protected function printEventStr
protected function printEvent "function: printEvent"
input Event inEvent;
output String str;
algorithm
str := matchcontinue (inEvent)
local
String name;
case FOUND_EQUATION() then "FOUND_EQUATION";
case NEWDEF() then "NEWDEF";
case FOUND_COMPONENT(name) then "FOUND_COMPONENT(" +& name +& ")";
_:=
matchcontinue (inEvent)
case FOUND_EQUATION()
equation
Print.printBuf("FOUND_EQUATION");
then
();
case NEWDEF()
equation
Print.printBuf("NEWDEF");
then
();
end matchcontinue;
end printEventStr;
end printEvent;

public function start "!includecode
- Transitions
Expand Down Expand Up @@ -421,33 +422,29 @@ algorithm
case (META_RECORD(path = p),NEWDEF()) then META_RECORD(p); // Added 2009-08-18. sjoelund

/* Event 'FOUND_COMPONENT' */
case (UNKNOWN(path = p),FOUND_COMPONENT(name = _)) then IS_NEW(p); /* Event `NEWDEF\' */
case (MODEL(path = p),FOUND_COMPONENT(name = _)) then MODEL(p);
case (RECORD(path = p),FOUND_COMPONENT(name = _)) then RECORD(p);
case (BLOCK(path = p),FOUND_COMPONENT(name = _)) then BLOCK(p);
case (CONNECTOR(path = p,isExpandable = isExpandable),FOUND_COMPONENT(name = _)) then CONNECTOR(p,isExpandable);
case (TYPE(path = p),FOUND_COMPONENT(name = s))
equation
true = isBasicTypeComponentName(s);
then TYPE(p);
case (TYPE(path = p),FOUND_COMPONENT(name = _)) // A type can not contain new components
case (UNKNOWN(path = p),FOUND_COMPONENT()) then IS_NEW(p); /* Event `NEWDEF\' */
case (MODEL(path = p),FOUND_COMPONENT()) then MODEL(p);
case (RECORD(path = p),FOUND_COMPONENT()) then RECORD(p);
case (BLOCK(path = p),FOUND_COMPONENT()) then BLOCK(p);
case (CONNECTOR(path = p,isExpandable = isExpandable),FOUND_COMPONENT()) then CONNECTOR(p,isExpandable);
case (TYPE(path = p),FOUND_COMPONENT()) // A type can not contain components
equation
s = Absyn.pathString(p);
Error.addMessage(Error.TYPE_NOT_FROM_PREDEFINED, {s});
then
fail();
/* adrpo 2009-05-15: type Orientation can contain equalityConstraint function! */
//case (TYPE(path = p),FOUND_COMPONENT()) then TYPE(p);
case (PACKAGE(path = p),FOUND_COMPONENT(name = _)) then PACKAGE(p);
case (FUNCTION(path = p),FOUND_COMPONENT(name = _)) then FUNCTION(p);
case (ENUMERATION(path = p),FOUND_COMPONENT(name = _)) then ENUMERATION(p);
case (IS_NEW(path = p),FOUND_COMPONENT(name = _)) then IS_NEW(p);
case (TYPE_INTEGER(path = p),FOUND_COMPONENT(name = _)) then TYPE_INTEGER(p);
case (TYPE_REAL(path = p),FOUND_COMPONENT(name = _)) then TYPE_REAL(p);
case (TYPE_STRING(path = p),FOUND_COMPONENT(name = _)) then TYPE_STRING(p);
case (TYPE_BOOL(path = p),FOUND_COMPONENT(name = _)) then TYPE_BOOL(p);
case (TYPE_ENUM(path = p),FOUND_COMPONENT(name = _)) then TYPE_ENUM(p);
case (META_RECORD(path = p),FOUND_COMPONENT(name = _)) then META_RECORD(p); // Added 2009-08-19. sjoelund
case (PACKAGE(path = p),FOUND_COMPONENT()) then PACKAGE(p);
case (FUNCTION(path = p),FOUND_COMPONENT()) then FUNCTION(p);
case (ENUMERATION(path = p),FOUND_COMPONENT()) then ENUMERATION(p);
case (IS_NEW(path = p),FOUND_COMPONENT()) then IS_NEW(p);
case (TYPE_INTEGER(path = p),FOUND_COMPONENT()) then TYPE_INTEGER(p);
case (TYPE_REAL(path = p),FOUND_COMPONENT()) then TYPE_REAL(p);
case (TYPE_STRING(path = p),FOUND_COMPONENT()) then TYPE_STRING(p);
case (TYPE_BOOL(path = p),FOUND_COMPONENT()) then TYPE_BOOL(p);
case (TYPE_ENUM(path = p),FOUND_COMPONENT()) then TYPE_ENUM(p);
case (META_RECORD(path = p),FOUND_COMPONENT()) then META_RECORD(p); // Added 2009-08-19. sjoelund

/* Event `FOUND_EQUATION\' */
case (UNKNOWN(path = p),FOUND_EQUATION()) then HAS_EQUATIONS(p);
Expand All @@ -472,8 +469,11 @@ algorithm
case (HAS_EQUATIONS(path = p),FOUND_EQUATION()) then HAS_EQUATIONS(p);
case (st,ev)
equation
true = RTOpts.debugFlag("failtrace");
Debug.traceln("- ClassInf.trans failed: " +& printStateStr(st) +& ", " +& printEventStr(ev));
Print.printBuf("- trans failed: ");
printState(st);
Print.printBuf(", ");
printEvent(ev);
Print.printBuf("\n");
then
fail();
end matchcontinue;
Expand Down Expand Up @@ -626,26 +626,5 @@ algorithm
case CONNECTOR(path = _) then ();
end matchcontinue;
end isConnector;

protected constant list<String> basicTypeMods = {
"quantity",
"unit",
"displayUnit",
"min",
"max",
"start",
"fixed",
"nominal",
"stateSelect"
};

public function isBasicTypeComponentName
"Returns true if the name can be a component of a builtin type"
input String name;
output Boolean res;
algorithm
res := listMember(name,basicTypeMods);
end isBasicTypeComponentName;

end ClassInf;

0 comments on commit 9e8a425

Please sign in to comment.