Skip to content

Commit

Permalink
- New API calls to check class restriction,
Browse files Browse the repository at this point in the history
  + isOperator
  + isOperatorRecord
  + isOperatorFunction

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12330 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Jul 17, 2012
1 parent f385d68 commit 8743e32
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2319,6 +2319,39 @@ annotation(
preferredView="text");
end isModel;

function isOperator
input TypeName cl;
output Boolean b;
external "builtin";
annotation(
Documentation(info="<html>
Returns true if the given class has restriction operator.
</html>"),
preferredView="text");
end isOperator;

function isOperatorRecord
input TypeName cl;
output Boolean b;
external "builtin";
annotation(
Documentation(info="<html>
Returns true if the given class has restriction \"operator record\".
</html>"),
preferredView="text");
end isOperatorRecord;

function isOperatorFunction
input TypeName cl;
output Boolean b;
external "builtin";
annotation(
Documentation(info="<html>
Returns true if the given class has restriction \"operator function\".
</html>"),
preferredView="text");
end isOperatorFunction;

function setInitXmlStartValue
input String fileName;
input String variableName;
Expand Down
18 changes: 18 additions & 0 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -1798,6 +1798,24 @@ algorithm
then
(cache,Values.BOOL(b),st);

case (cache,env,"isOperator",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
b = Interactive.isOperator(classpath, p);
then
(cache,Values.BOOL(b),st);

case (cache,env,"isOperatorRecord",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
b = Interactive.isOperatorRecord(classpath, p);
then
(cache,Values.BOOL(b),st);

case (cache,env,"isOperatorFunction",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
b = Interactive.isOperatorFunction(classpath, p);
then
(cache,Values.BOOL(b),st);

case (cache,env,"getAstAsCorbaString",{Values.STRING("<interactive>")},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
Print.clearBuf();
Expand Down
60 changes: 60 additions & 0 deletions Compiler/Script/Interactive.mo
Expand Up @@ -8686,6 +8686,66 @@ algorithm
end matchcontinue;
end isModel;

public function isOperator
"function: isOperator
This function takes a component reference and a program.
It returns true if the refrenced class has the restriction
\"operator\", otherwise it returns false."
input Absyn.Path path;
input Absyn.Program inProgram;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (path,inProgram)
local
Absyn.Program p;
case (path,p)
equation
Absyn.CLASS(_,_,_,_,Absyn.R_OPERATOR(),_,_) = getPathedClassInProgram(path, p);
then true;
else false;
end matchcontinue;
end isOperator;

public function isOperatorRecord
"function: isOperatorRecord
This function takes a component reference and a program.
It returns true if the refrenced class has the restriction
\"operator record\", otherwise it returns false."
input Absyn.Path path;
input Absyn.Program inProgram;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (path,inProgram)
local
Absyn.Program p;
case (path,p)
equation
Absyn.CLASS(_,_,_,_,Absyn.R_OPERATOR_RECORD(),_,_) = getPathedClassInProgram(path, p);
then true;
else false;
end matchcontinue;
end isOperatorRecord;

public function isOperatorFunction
"function: isOperatorFunction
This function takes a component reference and a program.
It returns true if the refrenced class has the restriction
\"operator function\", otherwise it returns false."
input Absyn.Path path;
input Absyn.Program inProgram;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (path,inProgram)
local
Absyn.Program p;
case (path,p)
equation
Absyn.CLASS(_,_,_,_,Absyn.R_FUNCTION(Absyn.FR_OPERATOR_FUNCTION()),_,_) = getPathedClassInProgram(path, p);
then true;
else false;
end matchcontinue;
end isOperatorFunction;

protected function isRecord
"function: isRecord
This function takes a component reference and a program.
Expand Down

0 comments on commit 8743e32

Please sign in to comment.