Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Drop down menus for Enumeration and Boolean types.
- Added a new API getBuiltinType.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23278 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Nov 8, 2014
1 parent 7dc01b6 commit efcf9b5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -225,6 +225,34 @@ algorithm
then
(cache,t,env_3);

// Real Type
case (cache,env_1,_,c as SCode.CLASS(restriction=SCode.R_TYPE(),classDef=SCode.DERIVED(typeSpec=Absyn.TPATH(path=Absyn.IDENT(name="Real")))))
equation
t = DAE.T_REAL({}, DAE.emptyTypeSource);
then
(cache,t,env_1);

// Integer Type
case (cache,env_1,_,c as SCode.CLASS(restriction=SCode.R_TYPE(),classDef=SCode.DERIVED(typeSpec=Absyn.TPATH(path=Absyn.IDENT(name="Integer")))))
equation
t = DAE.T_INTEGER({}, DAE.emptyTypeSource);
then
(cache,t,env_1);

// Boolean Type
case (cache,env_1,_,c as SCode.CLASS(restriction=SCode.R_TYPE(),classDef=SCode.DERIVED(typeSpec=Absyn.TPATH(path=Absyn.IDENT(name="Boolean")))))
equation
t = DAE.T_BOOL({}, DAE.emptyTypeSource);
then
(cache,t,env_1);

// String Type
case (cache,env_1,_,c as SCode.CLASS(restriction=SCode.R_TYPE(),classDef=SCode.DERIVED(typeSpec=Absyn.TPATH(path=Absyn.IDENT(name="String")))))
equation
t = DAE.T_STRING({}, DAE.emptyTypeSource);
then
(cache,t,env_1);

// Metamodelica extension, Uniontypes
case (cache,env_1,_,c as SCode.CLASS(restriction=SCode.R_METARECORD()))
equation
Expand Down
11 changes: 11 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -3038,6 +3038,17 @@ annotation(
preferredView="text");
end isProtectedClass;

function getBuiltinType
input TypeName cl;
output String name;
external "builtin";
annotation(
Documentation(info="<html>
Returns the builtin type e.g Real, Integer, Boolean & String of the class.
</html>"),
preferredView="text");
end getBuiltinType;

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

case (cache,env,"getBuiltinType",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as GlobalScript.SYMBOLTABLE(ast=p),_)
equation
(_, tp, _) = Lookup.lookupType(cache, env, classpath, SOME(Absyn.dummyInfo));
str = Types.unparseType(tp);
then
(cache,Values.STRING(str),st);

// if the lookup fails
case (cache,env,"getBuiltinType",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as GlobalScript.SYMBOLTABLE(ast=p),_)
then
(cache,Values.STRING(""),st);

case (cache,_,"extendsFrom",
{Values.CODE(Absyn.C_TYPENAME(classpath)),
Values.CODE(Absyn.C_TYPENAME(baseClassPath))},st as GlobalScript.SYMBOLTABLE(ast=p),_)
Expand Down

0 comments on commit efcf9b5

Please sign in to comment.