Skip to content

Commit

Permalink
- g++ is now set as compileCommand in Compiler/runtime/settingsimpl.c
Browse files Browse the repository at this point in the history
  Compiler/CevalScript.mo CevalScript.compileModel now matches for "g++" instead of ""
- Lookup.buildRecordConstructorElts now selects the full modifier only if the component
  modifier is empty.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4558 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 23, 2009
1 parent bb750a5 commit 55011e0
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 71 deletions.
4 changes: 2 additions & 2 deletions Compiler/Ceval.mo
Expand Up @@ -256,8 +256,7 @@ algorithm
DAE.ComponentRef c;
Interactive.InteractiveSymbolTable st;
equation
(cache,v) = cevalCref(cache,env, c, false, msg) "When in interactive mode, always evalutate crefs, i.e non-implicit
mode.." ;
(cache,v) = cevalCref(cache,env, c, false, msg) "When in interactive mode, always evalutate crefs, i.e non-implicit mode.." ;
then
(cache,v,SOME(st));

Expand Down Expand Up @@ -4426,6 +4425,7 @@ algorithm
str = Exp.printComponentRefStr(c);
scope_str = Env.printEnvPathStr(env);
Error.addMessage(Error.NO_CONSTANT_BINDING, {str,scope_str});
Debug.fprintln("ceval","-Ceval.cevalCref on: " +& str +& " failed with no constant binding in scope: " +& scope_str);
then
fail();
end matchcontinue;
Expand Down
7 changes: 5 additions & 2 deletions Compiler/CevalScript.mo
Expand Up @@ -2663,8 +2663,11 @@ algorithm

// If compileCommand not set, use $OPENMODELICAHOME\bin\Compile
case (fileprefix,libs,file_dir,noClean)
equation
"" = Settings.getCompileCommand();
equation
// if compileCommand is set to g++ use $OPENMODELICAHOME/bin/Compile
// MathCore needs compileCommand to be set to g++ in Compiler/runtime/settingsimpl.c
// so we test for g++ instead of "" (nothing).
"g++" = Settings.getCompileCommand();
pd = System.pathDelimiter();
omhome = Settings.getInstallationDirectoryPath();
omhome_1 = System.stringReplace(omhome, "\"", "");
Expand Down
50 changes: 35 additions & 15 deletions Compiler/Lookup.mo
Expand Up @@ -99,6 +99,20 @@ algorithm
String classname,scope;
Env.Cache cache;

// Special handling for Connections.isRoot
case (cache,env,Absyn.QUALIFIED("Connections", Absyn.IDENT("isRoot")),msg)
equation
t = (DAE.T_FUNCTION({("x", (DAE.T_ANYTYPE(NONE), NONE))}, (DAE.T_BOOL({}), NONE)), NONE);
then
(cache, t, env);

// Special handling for MultiBody 3.x rooted() operator
case (cache,env,Absyn.IDENT("rooted"),msg)
equation
t = (DAE.T_FUNCTION({("x", (DAE.T_ANYTYPE(NONE), NONE))}, (DAE.T_BOOL({}), NONE)), NONE);
then
(cache, t, env);

// For simple names
case (cache,env,(path as Absyn.IDENT(name = _)),msg)
equation
Expand All @@ -113,14 +127,6 @@ algorithm
(cache,t,env_2) = lookupType2(cache,env_1,path,c);
then
(cache,t,env_2);

// Special handling for Connections.isRoot
case (cache,env,Absyn.QUALIFIED("Connections", Absyn.IDENT("isRoot")),msg)
equation
t = (DAE.T_FUNCTION({("x", (DAE.T_ANYTYPE(NONE), NONE))},
(DAE.T_BOOL({}), NONE)), NONE);
then
(cache, t, env);

// Error for type not found
case (cache,env,path,true)
Expand Down Expand Up @@ -1951,6 +1957,19 @@ algorithm
end matchcontinue;
end buildRecordConstructorClass2;

protected function selectModifier
"@author: adrpo
if the first modifier is empty (NOMOD) use the second one!"
input DAE.Mod inModID;
input DAE.Mod inModNoID;
output DAE.Mod outMod;
algorithm
outMod := matchcontinue (inModID, inModNoID)
case (DAE.NOMOD(), inModNoID) then inModNoID;
case (inModID, _) then inModID;
end matchcontinue;
end selectModifier;

protected function buildRecordConstructorElts
"function: buildRecordConstructorElts
Helper function to build_record_constructor_class. Creates the elements
Expand Down Expand Up @@ -1984,20 +2003,21 @@ algorithm
SCode.Class cl;
Absyn.Path path;
SCode.Mod mod,umod;
DAE.Mod mod_1,compMod;
DAE.Mod mod_1, compMod, fullMod, selectedMod;
Option<Absyn.Info> nfo;
Option<Absyn.ConstrainClass> cc;

case (((comp as SCode.COMPONENT( id,io,fl,repl,prot,SCode.ATTR(d,f,st,ac,var,dir),tp,mod,bc,comment,cond,nfo,cc)) :: rest),mods,env)
equation
(_,mod_1) = Mod.elabMod(Env.emptyCache(), env, Prefix.NOPRE(), mod, false);
mod_1 = Mod.merge(mods,mod_1,env,Prefix.NOPRE());
// adrpo: this was wrong, you won't find any id modification there!!!
// bjozac: This was right, you will find id modification unless modifers does not belong to component!
// compMod = Mod.lookupModificationP(mod_1,Absyn.IDENT(id));
// umod = Mod.unelabMod(compMod);
// adpro TODO! FIXME! we need to discuss this as it breaks 2 tests:
// graphical API and Record Constructor with Parameters
umod = Mod.unelabMod(mod_1);
// bjozac: This was right, you will find id modification unless modifers does not belong to component!
// adrpo 2009-11-23 -> solved by selecting the full modifier if the component modifier is empty!
compMod = Mod.lookupModificationP(mod_1,Absyn.IDENT(id));
fullMod = mod_1;
selectedMod = selectModifier(compMod, fullMod); // if the first one is empty use the other one.
umod = Mod.unelabMod(selectedMod);
res = buildRecordConstructorElts(rest, mods, env);
// - Prefixes (constant, parameter, final, discrete, input, output, ...) of the remaining record components are removed.
var = SCode.VAR();
Expand Down
103 changes: 52 additions & 51 deletions Compiler/Static.mo
Expand Up @@ -5513,10 +5513,9 @@ algorithm
end matchcontinue;
end elabBuiltinIdentity;

protected function elabBuiltinIsRoot "function: elabBuiltinIsRoot
This function elaborates on the builtin operator Connections.isRoot.
"
protected function elabBuiltinIsRoot
"function: elabBuiltinIsRoot
This function elaborates on the builtin operator Connections.isRoot."
input Env.Cache inCache;
input Env.Env inEnv;
input list<Absyn.Exp> inAbsynExpLst;
Expand Down Expand Up @@ -5545,6 +5544,39 @@ algorithm
end matchcontinue;
end elabBuiltinIsRoot;

protected function elabBuiltinRooted
"author: adrpo
This function handles the built-in rooted operator. (MultiBody).
See more here: http://trac.modelica.org/Modelica/ticket/95"
input Env.Cache inCache;
input Env.Env inEnv;
input list<Absyn.Exp> inAbsynExpLst;
input list<Absyn.NamedArg> inNamedArg;
input Boolean inBoolean;
output Env.Cache outCache;
output DAE.Exp outExp;
output DAE.Properties outProperties;
algorithm
(outCache,outExp,outProperties) := matchcontinue (inCache,inEnv,inAbsynExpLst,inNamedArg,inBoolean)
local
list<Env.Frame> env;
Env.Cache cache;
Boolean impl;
Absyn.Exp exp0;
DAE.Exp exp;

// adrpo: TODO! FIXME!
// this operator is not even specified in the specification!
// We should implement this as said here:
// http://trac.modelica.org/Modelica/ticket/95
case (cache,env,{exp0},{},impl) /* impl */
equation
(cache, exp, _, _) = elabExp(cache, env, exp0, false, NONE, false);
then
(cache, DAE.BCONST(true),DAE.PROP((DAE.T_BOOL({}), NONE), DAE.C_CONST));
end matchcontinue;
end elabBuiltinRooted;

protected function elabBuiltinScalar "function: elab_builtin_
author: PA
Expand Down Expand Up @@ -5790,45 +5822,6 @@ algorithm
DAE.PROP((DAE.T_STRING({}),NONE),c));
end matchcontinue;
end elabBuiltinString;

protected function elabBuiltinRooted
"author: adrpo
This function handles the built-in rooted operator. (MultiBody)"
input Env.Cache inCache;
input Env.Env inEnv;
input list<Absyn.Exp> inAbsynExpLst;
input list<Absyn.NamedArg> inNamedArg;
input Boolean inBoolean;
output Env.Cache outCache;
output DAE.Exp outExp;
output DAE.Properties outProperties;
algorithm
(outCache,outExp,outProperties):=
matchcontinue (inCache,inEnv,inAbsynExpLst,inNamedArg,inBoolean)
local
DAE.Exp exp;
tuple<DAE.TType, Option<Absyn.Path>> tp,arr_tp;
DAE.Const c,const;
list<DAE.Const> constlist;
DAE.ExpType tp_1,etp;
list<Env.Frame> env;
Absyn.Exp e;
Boolean impl,scalar;
list<DAE.Exp> expl,expl_1,args_1;
list<Integer> dims;
Env.Cache cache;
DAE.Properties prop;
list<Absyn.Exp> args;
list<Absyn.NamedArg> nargs;
list<Slot> slots,newslots;
case (cache,env,args as _,nargs,impl)
equation
then
(cache,
DAE.BCONST(true),
DAE.PROP((DAE.T_BOOL({}),NONE),DAE.C_CONST()));
end matchcontinue;
end elabBuiltinRooted;

protected function elabBuiltinLinspace "
author: PA
Expand Down Expand Up @@ -6265,24 +6258,31 @@ algorithm
list<Absyn.NamedArg> nargs;
Boolean impl;
Env.Cache cache;
/* impl for normal builtin operators and functions */

/* impl for normal builtin operators and functions */
case (cache,env,Absyn.CREF_IDENT(name = name,subscripts = {}),args,nargs,impl)
equation
handler = elabBuiltinHandler(name);
(cache,exp,prop) = handler(cache,env, args, nargs, impl);
then
(cache,exp,prop);
/* For generic types, like e.g. cardinality */
case (cache,env,Absyn.CREF_IDENT(name = name,subscripts = {}),args,nargs,impl)
equation
handler = elabBuiltinHandlerGeneric(name);
(cache,exp,prop) = handler(cache,env, args, nargs, impl);
/* special handling for MultiBody 3.x rooted() operator */
case (cache,env,Absyn.CREF_IDENT(name = "rooted"),args,nargs,impl)
equation
(cache,exp,prop) = elabBuiltinRooted(cache,env, args, nargs, impl);
then
(cache,exp,prop);
case (cache,env,Absyn.CREF_QUAL(name = "Connections",
componentRef = Absyn.CREF_IDENT(name = "isRoot")),args,nargs,impl)
/* special handling for Connections.isRoot() operator */
case (cache,env,Absyn.CREF_QUAL(name = "Connections", componentRef = Absyn.CREF_IDENT(name = "isRoot")),args,nargs,impl)
equation
(cache,exp,prop) = elabBuiltinIsRoot(cache,env, args, nargs, impl);
then
(cache,exp,prop);
/* for generic types, like e.g. cardinality */
case (cache,env,Absyn.CREF_IDENT(name = name,subscripts = {}),args,nargs,impl)
equation
handler = elabBuiltinHandlerGeneric(name);
(cache,exp,prop) = handler(cache,env, args, nargs, impl);
then
(cache,exp,prop);
end matchcontinue;
Expand Down Expand Up @@ -9934,6 +9934,7 @@ algorithm
Error.addMessage(Error.NO_CONSTANT_BINDING, {s,scope});
t = Types.elabType(tt);
cr_1 = fillCrefSubscripts(cr, tt);
Debug.fprintln("static","-Static.elabCref2 on: " +& s +& " failed with no constant binding in scope: " +& scope);
then
(cache,DAE.CREF(cr_1,t),DAE.C_CONST(),acc);

Expand Down
3 changes: 2 additions & 1 deletion Compiler/runtime/settingsimpl.c
Expand Up @@ -95,8 +95,9 @@ void Settings_5finit(void)
/* adrpo: TODO! FIXME!
* MathCore wants this set to g++
* but OpenModelica uses $OPENMODELICAHOME/bin/Compile
* now this is solved in CevalScript.compileModel which is different for OpenModelica vs. MathModelica
*/
strcpy(compileCommand,"");
strcpy(compileCommand,"g++");
}


Expand Down

0 comments on commit 55011e0

Please sign in to comment.