Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
[NF] Fix for builtin calls
Browse files Browse the repository at this point in the history
Calls like Modelica.Math.sin need to be replaced with sin in the DAE
structure.

Belonging to [master]:
  - #2001
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Nov 9, 2017
1 parent 332341b commit eaa2e12
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Compiler/FrontEnd/Absyn.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,19 @@ algorithm
end match;
end pathLastIdent;

public function pathLast
"Returns the last ident (after last dot) in a path"
input output Path path;
algorithm
path := match path
local
Path p;
case QUALIFIED(path = p) then pathLast(p);
case IDENT() then path;
case FULLYQUALIFIED(path = p) then pathLast(p);
end match;
end pathLast;

public function pathFirstIdent "Returns the first ident (before first dot) in a path"
input Path inPath;
output Ident outIdent;
Expand Down
3 changes: 2 additions & 1 deletion Compiler/NFFrontEnd/NFCall.mo
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,9 @@ protected
output DAE.Exp daeCall;
algorithm
daeCall := match call

case TYPED_CALL()
then DAE.CALL(Function.name(call.fn),
then DAE.CALL(Function.nameConsiderBuiltin(call.fn),
list(Expression.toDAE(e) for e in call.arguments),
CallAttributes.toDAE(call.attributes));

Expand Down
13 changes: 13 additions & 0 deletions Compiler/NFFrontEnd/NFFunction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ uniontype Function
output Absyn.Path path = fn.path;
end name;

function nameConsiderBuiltin "Handles the DAE.mo structure where builtin calls are replaced by their simpler name"
input Function fn;
output Absyn.Path path;
algorithm
path := match fn.attributes.isBuiltin
local
String name;
case DAE.FUNCTION_BUILTIN(name=SOME(name)) then Absyn.IDENT(name);
case DAE.FUNCTION_BUILTIN() then Absyn.pathLast(fn.path);
else fn.path;
end match;
end nameConsiderBuiltin;

function signatureString
"Constructs a signature string for a function, e.g. Real func(Real x, Real y)"
input Function fn;
Expand Down

0 comments on commit eaa2e12

Please sign in to comment.