Skip to content

Commit

Permalink
Merging r6302 through r6316
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 8, 2010
2 parents 4e21b07 + 90a9e36 commit 6c517a0
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 29 deletions.
94 changes: 82 additions & 12 deletions Compiler/Static.mo
Expand Up @@ -7847,24 +7847,46 @@ protected function elabCallInteractive "function: elabCallInteractive
case (cache,env,Absyn.CREF_IDENT(name = "getClassesInModelicaPath"),{},{},impl,SOME(st),_)
then (cache,DAE.CALL(Absyn.IDENT("getClassesInModelicaPath"),{},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{},{},impl,SOME(st),_)
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));
case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{},args,impl,SOME(st),pre)
local
list<DAE.Exp> excludeList;
Integer excludeListSize;
equation
excludeList = getOptionalNamedArgExpList("exclude", args);
excludeListSize = listLength(excludeList);
then
(cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.ARRAY(DAE.ET_ARRAY(DAE.ET_OTHER,{DAE.DIM_INTEGER(excludeListSize)}),false,excludeList)},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{Absyn.STRING(value = str)},{},impl,SOME(st),_)
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.SCONST(str)},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));
case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{Absyn.STRING(value = str)},args,impl,SOME(st),pre)
local
list<DAE.Exp> excludeList;
Integer excludeListSize;
equation
excludeList = getOptionalNamedArgExpList("exclude", args);
excludeListSize = listLength(excludeList);
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.ARRAY(DAE.ET_ARRAY(DAE.ET_OTHER,{DAE.DIM_INTEGER(excludeListSize)}),false,excludeList),DAE.SCONST(str)},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{Absyn.CREF(componentRef = cr)},{},impl,SOME(st),_)
local Absyn.Path className;
case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{Absyn.CREF(componentRef = cr)},args,impl,SOME(st),pre)
local
Absyn.Path className;
list<DAE.Exp> excludeList;
Integer excludeListSize;
equation
className = Absyn.crefToPath(cr);
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.CODE(Absyn.C_TYPENAME(className),DAE.ET_OTHER())},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));
excludeList = getOptionalNamedArgExpList("exclude", args);
excludeListSize = listLength(excludeList);
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.ARRAY(DAE.ET_ARRAY(DAE.ET_OTHER,{DAE.DIM_INTEGER(excludeListSize)}),false,excludeList),DAE.CODE(Absyn.C_TYPENAME(className),DAE.ET_OTHER())},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{Absyn.CREF(componentRef = cr), Absyn.STRING(value = str)},{},impl,SOME(st),_)
local Absyn.Path className;
case (cache,env,Absyn.CREF_IDENT(name = "checkExamplePackages"),{Absyn.CREF(componentRef = cr), Absyn.STRING(value = str)},args,impl,SOME(st),pre)
local
Absyn.Path className;
list<DAE.Exp> excludeList;
Integer excludeListSize;
equation
className = Absyn.crefToPath(cr);
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.CODE(Absyn.C_TYPENAME(className),DAE.ET_OTHER()), DAE.SCONST(str)},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));

excludeList = getOptionalNamedArgExpList("exclude", args);
excludeListSize = listLength(excludeList);
then (cache,DAE.CALL(Absyn.IDENT("checkExamplePackages"),{DAE.ARRAY(DAE.ET_ARRAY(DAE.ET_OTHER,{DAE.DIM_INTEGER(excludeListSize)}),false,excludeList),DAE.CODE(Absyn.C_TYPENAME(className),DAE.ET_OTHER()),DAE.SCONST(str)},false,true,DAE.ET_STRING(),DAE.NO_INLINE),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "dumpXMLDAE"),{Absyn.CREF(componentRef = cr)},args,impl,SOME(st),pre)
local
Expand Down Expand Up @@ -7938,6 +7960,54 @@ algorithm
end matchcontinue;
end elabVariablenames;

protected function getOptionalNamedArgExpList
input Ident name;
input list<Absyn.NamedArg> nargs;
output list<DAE.Exp> out;
algorithm
out := matchcontinue (name, nargs)
local
list<Absyn.Exp> absynExpList;
list<DAE.Exp> daeExpList;
Ident argName;
list<Absyn.NamedArg> rest;
case (_, {})
then {};
case (name, (Absyn.NAMEDARG(argName = argName, argValue = Absyn.ARRAY(arrayExp = absynExpList)) :: _))
equation
true = stringEqual(name, argName);
daeExpList = absynExpListToDaeExpList(absynExpList);
then daeExpList;
case (name, _::rest)
then getOptionalNamedArgExpList(name, rest);
end matchcontinue;
end getOptionalNamedArgExpList;

protected function absynExpListToDaeExpList
input list<Absyn.Exp> absynExpList;
output list<DAE.Exp> out;
algorithm
out := matchcontinue (absynExpList)
local
list<DAE.Exp> daeExpList;
Ident argName;
list<Absyn.Exp> absynRest;
Absyn.ComponentRef absynCr;
Absyn.Path absynPath;
DAE.ComponentRef daeCr;
case ({})
then {};
case (Absyn.CREF(componentRef = absynCr) :: absynRest)
equation
absynPath = Absyn.crefToPath(absynCr);
daeCr = pathToComponentRef(absynPath);
daeExpList = absynExpListToDaeExpList(absynRest);
then DAE.CREF(daeCr,DAE.ET_OTHER) :: daeExpList;
case (_ :: absynRest)
then absynExpListToDaeExpList(absynRest);
end matchcontinue;
end absynExpListToDaeExpList;

protected function getOptionalNamedArg "function: getOptionalNamedArg
This function is used to \"elaborate\" interactive functions optional parameters,
e.g. simulate(A.b, startTime=1), startTime is an optional parameter
Expand Down Expand Up @@ -8026,7 +8096,7 @@ algorithm
end elabUntypedCref;

protected function pathToComponentRef "function: pathToComponentRef
This function tranlates a typename to a variable name.
This function translates a typename to a variable name.
"
input Absyn.Path inPath;
output DAE.ComponentRef outComponentRef;
Expand Down
33 changes: 16 additions & 17 deletions Compiler/runtime/systemimpl.c
Expand Up @@ -380,32 +380,31 @@ RML_BEGIN_LABEL(System__trim)
int start_pos = 0;
int end_pos = length - 1;
if(length > 1)
{
strncpy(res,str,length);
for(i=0; i < length; i++ )
{

if(str_contain_char(chars_to_be_removed,res[start_pos]))
start_pos++;
if(str_contain_char(chars_to_be_removed,res[end_pos]))
end_pos--;
if (start_pos == end_pos) break;
}


res[length] = '\0';
{
strncpy(res,str,length);
for(i=0; i < length; i++ ) {
if(str_contain_char(chars_to_be_removed,res[start_pos]))
start_pos++;
if(str_contain_char(chars_to_be_removed,res[end_pos]))
end_pos--;
if (start_pos == end_pos) break;
}
if(start_pos <= end_pos)
{
res[length] = '\0';
if(start_pos <= end_pos) {
res[end_pos+1] = '\0';
rmlA0 = (void*) mk_scon(&res[start_pos]);
} else {
rmlA0 = (void*) mk_scon("");
}
} else {
if (length == 0 || str_contain_char(chars_to_be_removed,str[0]))
rmlA0 = (void*) mk_scon("");
else
rmlA0 = (void*) mk_scon(str);
}

free(res);


RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand Down

0 comments on commit 6c517a0

Please sign in to comment.