Skip to content

Commit

Permalink
- Handle ceval of tuple subscripting
Browse files Browse the repository at this point in the history
- Changed the UriLookup to return the error-message instead of printing to stdout since it is also used in simulations (and you really do not want it every time step; especially if the code looks for different modelica://-links to recover from Dymola not implementing the full ModelicaServices functionality)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15974 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 3, 2013
1 parent bc75df2 commit cba6967
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -816,6 +816,14 @@ algorithm
then
(cache,v,stOpt);

// indexing for tuple[index]
case (cache, env, DAE.TSUB(exp = e,ix = indx), impl, stOpt, msg,_)
equation
(cache,Values.TUPLE(vals),stOpt) = ceval(cache,env, e, impl, stOpt,msg,numIter+1);
v = listGet(vals, indx);
then
(cache,v,stOpt);

case (cache, env, DAE.REDUCTION(reductionInfo=DAE.REDUCTIONINFO(path = path, foldExp = foldExp, defaultValue = ov, exprType = ty), expr = daeExp, iterators = iterators), impl, stOpt, msg,_)
equation
env = Env.openScope(env, SCode.NOT_ENCAPSULATED(), SOME(Env.forScopeName), NONE());
Expand Down
12 changes: 9 additions & 3 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -1865,6 +1865,7 @@ end realpath;
function uriToFilename
input String uri;
output String filename := "";
output String message := "";
protected
String [:,2] libraries;
Integer numMatches;
Expand All @@ -1885,6 +1886,10 @@ algorithm
return;
end if;
path := matches[2];
if path == "" then
message := "Malformed modelica:// URI path. Package name '" + matches[2]+"', path: '"+matches[3] + "'";
return;
end if;
while path <> "" loop
(numMatches,matches2) := regex(path, "^([A-Za-z_][A-Za-z0-9_]*)?[.]?(.*)?$",3);
path := matches2[3];
Expand All @@ -1905,7 +1910,7 @@ algorithm
end if;
end for;
if not isMatch then
print("Could not resolve URI: " + uri + "\n");
message := "Could not resolve URI: " + uri;
filename := "";
return;
end if;
Expand All @@ -1921,12 +1926,13 @@ algorithm
return;
elseif not (isModelicaUri or isFileUri) then
/* Not using else because OpenModelica handling of assertions at runtime is not very good */
str := "Unknown URI schema: " + uri;
print(str + "\n");
message := "Unknown URI schema: " + uri;
filename := "";
return;
else
/* empty */
message := "Unknown error";
filename := "";
end if;
else
filename := if regularFileExists(uri) then realpath(uri) else if regexBool(uri, "^/") then uri else (realpath("./") + "/" + uri);
Expand Down

0 comments on commit cba6967

Please sign in to comment.