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

Commit 561c2f9

Browse files
adeas31OpenModelica-Hudson
authored andcommitted
ticket:4152 Added includeConstants argument to getClassNames API.
If true then the API will also return the constants of the class along with classes.
1 parent 1df8a4a commit 561c2f9

File tree

4 files changed

+109
-67
lines changed

4 files changed

+109
-67
lines changed

Compiler/FrontEnd/ModelicaBuiltin.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,6 +2576,7 @@ function getClassNames "Returns the list of class names defined in the class."
25762576
input Boolean sort = false;
25772577
input Boolean builtin = false "List also builtin classes if true";
25782578
input Boolean showProtected = false "List also protected classes if true";
2579+
input Boolean includeConstants = false "List also constants in the class if true";
25792580
output TypeName classNames[:];
25802581
external "builtin";
25812582
annotation(preferredView="text");

Compiler/Script/CevalScript.mo

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ algorithm
571571
Real timeTotal,timeSimulation,timeStamp,val,x1,x2,y1,y2,r,r1,r2,linearizeTime,curveWidth,offset,offset1,offset2,scaleFactor,scaleFactor1,scaleFactor2;
572572
GlobalScript.Statements istmts;
573573
list<GlobalScript.Statements> istmtss;
574-
Boolean have_corba, bval, anyCode, b, b1, b2, externalWindow, logX, logY, autoScale, forceOMPlot, gcc_res, omcfound, rm_res, touch_res, uname_res, ifcpp, ifmsvc,sort, builtin, showProtected, inputConnectors, outputConnectors, mergeAST;
574+
Boolean have_corba, bval, anyCode, b, b1, b2, externalWindow, logX, logY, autoScale, forceOMPlot, gcc_res, omcfound, rm_res, touch_res, uname_res, ifcpp, ifmsvc,sort, builtin, showProtected, includeConstants, inputConnectors, outputConnectors, mergeAST;
575575
FCore.Cache cache;
576576
list<GlobalScript.LoadedFile> lf;
577577
Absyn.ComponentRef crefCName;
@@ -1394,7 +1394,7 @@ algorithm
13941394
i = System.alarm(i);
13951395
then (cache,Values.INTEGER(i),st);
13961396

1397-
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(Absyn.IDENT("AllLoadedClasses"))),Values.BOOL(false),_,Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(_)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
1397+
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(Absyn.IDENT("AllLoadedClasses"))),Values.BOOL(false),_,Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(_),_},st as GlobalScript.SYMBOLTABLE(ast = p),_)
13981398
equation
13991399
(ip,_) = Builtin.getInitialFunctions();
14001400
p = if builtin then Interactive.updateProgram(p,ip) else p;
@@ -1404,33 +1404,33 @@ algorithm
14041404
then
14051405
(cache,ValuesUtil.makeArray(vals),st);
14061406

1407-
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(path)),Values.BOOL(false),Values.BOOL(b),Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(showProtected)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
1407+
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(path)),Values.BOOL(false),Values.BOOL(b),Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(showProtected),Values.BOOL(includeConstants)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
14081408
equation
14091409
(ip,_) = Builtin.getInitialFunctions();
14101410
p = if builtin then Interactive.updateProgram(p,ip) else p;
1411-
paths = Interactive.getClassnamesInPath(path, p, showProtected);
1411+
paths = Interactive.getClassnamesInPath(path, p, showProtected, includeConstants);
14121412
paths = if b then List.map1r(paths,Absyn.joinPaths,path) else paths;
14131413
paths = if sort then List.sort(paths, Absyn.pathGe) else paths;
14141414
vals = List.map(paths,ValuesUtil.makeCodeTypeName);
14151415
then
14161416
(cache,ValuesUtil.makeArray(vals),st);
14171417

1418-
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(Absyn.IDENT("AllLoadedClasses"))),Values.BOOL(true),_,Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(showProtected)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
1418+
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(Absyn.IDENT("AllLoadedClasses"))),Values.BOOL(true),_,Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(showProtected),Values.BOOL(includeConstants)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
14191419
equation
14201420
(ip,_) = Builtin.getInitialFunctions();
14211421
p = if builtin then Interactive.updateProgram(p,ip) else p;
1422-
(_,paths) = Interactive.getClassNamesRecursive(NONE(),p,showProtected,{});
1422+
(_,paths) = Interactive.getClassNamesRecursive(NONE(),p,showProtected,includeConstants,{});
14231423
paths = listReverse(paths);
14241424
paths = if sort then List.sort(paths, Absyn.pathGe) else paths;
14251425
vals = List.map(paths,ValuesUtil.makeCodeTypeName);
14261426
then
14271427
(cache,ValuesUtil.makeArray(vals),st);
14281428

1429-
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(path)),Values.BOOL(true),_,Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(showProtected)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
1429+
case (cache,_,"getClassNames",{Values.CODE(Absyn.C_TYPENAME(path)),Values.BOOL(true),_,Values.BOOL(sort),Values.BOOL(builtin),Values.BOOL(showProtected),Values.BOOL(includeConstants)},st as GlobalScript.SYMBOLTABLE(ast = p),_)
14301430
equation
14311431
(ip,_) = Builtin.getInitialFunctions();
14321432
p = if builtin then Interactive.updateProgram(p,ip) else p;
1433-
(_,paths) = Interactive.getClassNamesRecursive(SOME(path),p,showProtected,{});
1433+
(_,paths) = Interactive.getClassNamesRecursive(SOME(path),p,showProtected,includeConstants,{});
14341434
paths = listReverse(paths);
14351435
paths = if sort then List.sort(paths, Absyn.pathGe) else paths;
14361436
vals = List.map(paths,ValuesUtil.makeCodeTypeName);

Compiler/Script/CevalScriptBackend.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,7 +1916,7 @@ algorithm
19161916

19171917
case (cache,_,"searchClassNames",{Values.STRING(str), Values.BOOL(b)},st as GlobalScript.SYMBOLTABLE(ast=p),_)
19181918
equation
1919-
(_,paths) = Interactive.getClassNamesRecursive(NONE(),p,false,{});
1919+
(_,paths) = Interactive.getClassNamesRecursive(NONE(),p,false,false,{});
19201920
paths = listReverse(paths);
19211921
vals = List.map(paths,ValuesUtil.makeCodeTypeName);
19221922
vals = searchClassNames(vals, str, b, p);
@@ -5204,7 +5204,7 @@ algorithm
52045204
Boolean b;
52055205
case (_,_,Absyn.CLASS(body = Absyn.PARTS(classParts = parts)),b)
52065206
equation
5207-
strlist = Interactive.getClassnamesInParts(parts,b);
5207+
strlist = Interactive.getClassnamesInParts(parts,b,false);
52085208
then
52095209
strlist;
52105210

@@ -5223,7 +5223,7 @@ algorithm
52235223

52245224
case (_,_,Absyn.CLASS(body = Absyn.CLASS_EXTENDS(parts=parts)),b)
52255225
equation
5226-
strlist = Interactive.getClassnamesInParts(parts,b);
5226+
strlist = Interactive.getClassnamesInParts(parts,b,false);
52275227
then strlist;
52285228

52295229
case (_,_,Absyn.CLASS(body = Absyn.PDER(_,_,_)),_)

0 commit comments

Comments
 (0)