Skip to content

Commit

Permalink
Remove unused functions in Interactive (#8177)
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Nov 19, 2021
1 parent 43ceafd commit 7e00424
Show file tree
Hide file tree
Showing 21 changed files with 3,773 additions and 18,690 deletions.
3 changes: 2 additions & 1 deletion OMCompiler/Compiler/Main/Main.mo
Expand Up @@ -71,6 +71,7 @@ import GC;
import Global;
import GlobalScript;
import Interactive;
import InteractiveUtil;
import List;
import Parser;
import Print;
Expand Down Expand Up @@ -192,7 +193,7 @@ algorithm
ast = table.ast;
vars = table.vars;
prog2 = Interactive.addScope(prog, vars);
prog2 = Interactive.updateProgram(prog2, ast);
prog2 = InteractiveUtil.updateProgram(prog2, ast);
if Flags.isSet(Flags.DUMP) then
Debug.trace("\n--------------- Parsed program ---------------\n");
Dump.dump(prog2);
Expand Down
15 changes: 8 additions & 7 deletions OMCompiler/Compiler/Script/Binding.mo
Expand Up @@ -9,6 +9,7 @@ public import Dump;

protected import AbsynToSCode;
protected import Interactive;
protected import InteractiveUtil;
protected import Parser;
protected import GlobalScript;
protected import System;
Expand Down Expand Up @@ -77,14 +78,14 @@ protected
list<SCode.Element> scode_def;
list<Client_e> client_list;
algorithm
model_def := Interactive.getPathedClassInProgram(model_path, env);
model_def := InteractiveUtil.getPathedClassInProgram(model_path, env);
scode_def := AbsynToSCode.translateAbsyn2SCode(env);
// print(SCodeDump.programStr(scode_def));
ms := getMediatorDefsElements(scode_def, {});
client_list := buildInstList(model_def, env, NO_PRED(), ms, {}, {});
out_vmodel := inferBindingClientList(client_list, model_def, env);
print(Dump.unparseClassStr(out_vmodel) + "\n");
out_model_def := Interactive.updateProgram(Absyn.PROGRAM({out_vmodel}, Interactive.buildWithin(model_path)), env);
out_model_def := InteractiveUtil.updateProgram(Absyn.PROGRAM({out_vmodel}, InteractiveUtil.buildWithin(model_path)), env);
end inferBindings;

public function generateVerificationScenarios "@autor lenab : root function called from API "
Expand All @@ -111,7 +112,7 @@ algorithm
scenarios := getAllElementsOfType(scode_def, "VVDRlib.Verification.Scenario", "", {});
// get mediators
ms := getMediatorDefsElements(scode_def, {});
package_def := Interactive.getPathedClassInProgram(package_path, in_env);
package_def := InteractiveUtil.getPathedClassInProgram(package_path, in_env);
autogen_model_list := {};
i:=0;
for s in scenarios loop
Expand All @@ -138,7 +139,7 @@ algorithm
end for;
out_vmodel := updatePackage(package_def, autogen_model_list);
print("******** Autogenerated classes: \n"+ Dump.unparseClassStr(out_vmodel) + "\n");
out_env := Interactive.updateProgram(Absyn.PROGRAM({out_vmodel}, Interactive.buildWithin(package_path)), in_env);
out_env := InteractiveUtil.updateProgram(Absyn.PROGRAM({out_vmodel}, InteractiveUtil.buildWithin(package_path)), in_env);
end generateVerificationScenarios;

public function updatePackage
Expand Down Expand Up @@ -1059,7 +1060,7 @@ algorithm
//print(" VS " +className);
//print ("... \n");
// if Interactive.isPrimitive(AbsynUtil.pathToCref(path), env) then fail(); end if;
def := Interactive.getPathedClassInProgram(path,env); // load the element
def := InteractiveUtil.getPathedClassInProgram(path,env); // load the element
if (AbsynUtil.typeSpecPathString(typeSpec) == className) then
print("... found provider " + className + "\n");
cnew := (components, pathInClass)::in_components;
Expand Down Expand Up @@ -1201,7 +1202,7 @@ algorithm
//print ("... \n");

//if Interactive.isPrimitive(AbsynUtil.pathToCref(path), env) then fail(); end if;
def := Interactive.getPathedClassInProgram(path, env); // load the element
def := InteractiveUtil.getPathedClassInProgram(path, env); // load the element

(isCl, iname, m) := isClient(AbsynUtil.typeSpecPathString(typeSpec), mediators, {});
// TODO: check if it was not already added to the list
Expand Down Expand Up @@ -1269,7 +1270,7 @@ algorithm
//print(Dump.unparseTypeSpec(typeSpec));
//print ("... \n");
//if Interactive.isPrimitive(AbsynUtil.pathToCref(path), env) then fail(); end if;
def := Interactive.getPathedClassInProgram(path, env); // load the element
def := InteractiveUtil.getPathedClassInProgram(path, env); // load the element
(isCl, iname, m) := isClient(AbsynUtil.typeSpecPathString(typeSpec), mediators, {});
// TODO: check if it was not already added to the list
if(isCl) then
Expand Down
38 changes: 19 additions & 19 deletions OMCompiler/Compiler/Script/CevalScript.mo
Expand Up @@ -349,7 +349,7 @@ protected
list<tuple<Absyn.Path,String,list<String>,Boolean>> modelsToLoad;
algorithm
modelsToLoad := if checkUses then Interactive.getUsesAnnotationOrDefault(newp, requireExactVersion) else {};
p := Interactive.updateProgram(newp, p);
p := InteractiveUtil.updateProgram(newp, p);
(p, _) := loadModel(modelsToLoad, modelicaPath, p, false, notifyLoad, checkUses, requireExactVersion, false);
end checkUsesAndUpdateProgram;

Expand Down Expand Up @@ -420,7 +420,7 @@ algorithm
msgTokens := {AbsynUtil.pathString(path), version};
Error.assertionOrAddSourceMessage(b, Error.NOTIFY_NOT_LOADED, msgTokens, AbsynUtil.dummyInfo);
end if;
p := Interactive.updateProgram(pnew, p);
p := InteractiveUtil.updateProgram(pnew, p);

b := true;
if checkUses then
Expand Down Expand Up @@ -461,7 +461,7 @@ algorithm
case (_,_,true,_) then false;
case ((path,requestOrigin,str1::_,_),_,false,_)
equation
cdef = Interactive.getPathedClassInProgram(path,p);
cdef = InteractiveUtil.getPathedClassInProgram(path,p);
ostr2 = AbsynUtil.getNamedAnnotationInClass(cdef,Absyn.IDENT("version"),Interactive.getAnnotationStringValueOrFail);
(withoutConversion,withConversion) = Interactive.getConversionAnnotation(cdef);
checkValidVersion(path,str1,ostr2,requestOrigin=requestOrigin,withConversion=withConversion,withoutConversion=withoutConversion);
Expand Down Expand Up @@ -1183,7 +1183,7 @@ algorithm

case ("getImportedNames",{Values.CODE(Absyn.C_TYPENAME(path))})
algorithm
(vals, cvars) := getImportedNames(Interactive.getPathedClassInProgram(path, SymbolTable.getAbsyn()));
(vals, cvars) := getImportedNames(InteractiveUtil.getPathedClassInProgram(path, SymbolTable.getAbsyn()));
v := Values.TUPLE({ValuesUtil.makeArray(vals),ValuesUtil.makeArray(cvars)});
then
v;
Expand Down Expand Up @@ -1313,7 +1313,7 @@ algorithm
case ("reloadClass",{Values.CODE(Absyn.C_TYPENAME(classpath)),Values.STRING(encoding)})
algorithm
Absyn.CLASS(info=SOURCEINFO(fileName=filename,lastModification=r2)) :=
Interactive.getPathedClassInProgram(classpath, SymbolTable.getAbsyn());
InteractiveUtil.getPathedClassInProgram(classpath, SymbolTable.getAbsyn());
(true,_,r1,_) := System.stat(filename);
if not realEq(r1, r2) then
reloadClass(filename, encoding);
Expand All @@ -1323,7 +1323,7 @@ algorithm

case ("reloadClass",{Values.CODE(Absyn.C_TYPENAME(classpath)),_})
algorithm
failure(_ := Interactive.getPathedClassInProgram(classpath, SymbolTable.getAbsyn()));
failure(_ := InteractiveUtil.getPathedClassInProgram(classpath, SymbolTable.getAbsyn()));
Error.addMessage(Error.LOAD_MODEL_ERROR, {AbsynUtil.pathString(classpath)});
then
Values.BOOL(false);
Expand All @@ -1335,7 +1335,7 @@ algorithm
algorithm
str := if not (encoding == "UTF-8") then System.iconv(str, encoding, "UTF-8") else str;
newp := Parser.parsestring(str,name);
newp := Interactive.updateProgram(newp, SymbolTable.getAbsyn(), mergeAST);
newp := InteractiveUtil.updateProgram(newp, SymbolTable.getAbsyn(), mergeAST);
SymbolTable.setAbsyn(newp);
outCache := FCore.emptyCache();
then
Expand All @@ -1352,7 +1352,7 @@ algorithm
case ("getTimeStamp",{Values.CODE(Absyn.C_TYPENAME(classpath))})
algorithm
Absyn.CLASS(info=SOURCEINFO(lastModification=r)) :=
Interactive.getPathedClassInProgram(classpath,SymbolTable.getAbsyn());
InteractiveUtil.getPathedClassInProgram(classpath,SymbolTable.getAbsyn());
str := System.ctime(r);
then
Values.TUPLE({Values.REAL(r),Values.STRING(str)});
Expand Down Expand Up @@ -2222,9 +2222,9 @@ algorithm

System.freeLibrary(libHandle, print_debug);
// update the build time in the class!
Absyn.CLASS(_,_,_,_,Absyn.R_FUNCTION(_),_,info) := Interactive.getPathedClassInProgram(funcpath, p);
Absyn.CLASS(_,_,_,_,Absyn.R_FUNCTION(_),_,info) := InteractiveUtil.getPathedClassInProgram(funcpath, p);

w := Interactive.buildWithin(funcpath);
w := InteractiveUtil.buildWithin(funcpath);

if Flags.isSet(Flags.DYN_LOAD) then
print("[dynload]: Updating build time for function path: " + AbsynUtil.pathString(funcpath) + " within: " + Dump.unparseWithin(w) + "\n");
Expand Down Expand Up @@ -2749,7 +2749,7 @@ protected
Absyn.Program p,newp;
algorithm
newp := Parser.parse(filename,encoding); /* Don't use the classloader since that can pull in entire directory structures. We only want to reload one single file. */
newp := Interactive.updateProgram(newp, SymbolTable.getAbsyn());
newp := InteractiveUtil.updateProgram(newp, SymbolTable.getAbsyn());
SymbolTable.setAbsyn(newp);
end reloadClass;

Expand Down Expand Up @@ -2781,14 +2781,14 @@ algorithm
case ("modelica://",name,_,_,_)
equation
(name::names) = System.strtok(name,".");
Absyn.CLASS(info=SOURCEINFO(fileName=fileName)) = Interactive.getPathedClassInProgram(Absyn.IDENT(name),program);
Absyn.CLASS(info=SOURCEINFO(fileName=fileName)) = InteractiveUtil.getPathedClassInProgram(Absyn.IDENT(name),program);
mp = System.dirname(fileName);
bp = findModelicaPath2(mp,names,"",true);
then bp;
case ("modelica://",name,_,mp,_)
equation
(name::names) = System.strtok(name,".");
failure(_ = Interactive.getPathedClassInProgram(Absyn.IDENT(name),program));
failure(_ = InteractiveUtil.getPathedClassInProgram(Absyn.IDENT(name),program));
gd = Autoconf.groupDelimiter;
mps = System.strtok(mp, gd);
(mp,name,isDir) = System.getLoadModelPath(name, {"default"}, mps);
Expand Down Expand Up @@ -2978,7 +2978,7 @@ algorithm
false := valueEq(Absyn.IDENT("AllLoadedClasses"),className);
p := SymbolTable.getAbsyn();
scodeP := SymbolTable.getSCode();
absynClass := Interactive.getPathedClassInProgram(className, p);
absynClass := InteractiveUtil.getPathedClassInProgram(className, p);
absynClass := if interface_only then AbsynUtil.getFunctionInterface(absynClass) else absynClass;
absynClass := if short_only then AbsynUtil.getShortClass(absynClass) else absynClass;
p := Absyn.PROGRAM({absynClass},Absyn.TOP());
Expand Down Expand Up @@ -3018,7 +3018,7 @@ algorithm
end match;
// handle encryption
Values.ENUM_LITERAL(index=access) := Interactive.checkAccessAnnotationAndEncryption(path, SymbolTable.getAbsyn());
(absynClass as Absyn.CLASS(restriction=restriction, info=SOURCEINFO(fileName=str))) := Interactive.getPathedClassInProgram(className, SymbolTable.getAbsyn());
(absynClass as Absyn.CLASS(restriction=restriction, info=SOURCEINFO(fileName=str))) := InteractiveUtil.getPathedClassInProgram(className, SymbolTable.getAbsyn());
absynClass := if nested then absynClass else AbsynUtil.filterNestedClasses(absynClass);
/* If the class has Access.packageText annotation or higher
* If the class has Access.nonPackageText annotation or higher and class is not a package
Expand Down Expand Up @@ -3059,19 +3059,19 @@ algorithm
p := SymbolTable.getAbsyn();

if builtin then
p := Interactive.updateProgram(p, FBuiltin.getInitialFunctions());
p := InteractiveUtil.updateProgram(p, FBuiltin.getInitialFunctions());
end if;

if AbsynUtil.pathEqual(path, Absyn.IDENT("AllLoadedClasses")) then
if recursive then
(_, paths) := Interactive.getClassNamesRecursive(NONE(), p, protects, constants, {});
(_, paths) := InteractiveUtil.getClassNamesRecursive(NONE(), p, protects, constants, {});
paths := listReverseInPlace(paths);
else
paths := Interactive.getTopClassnames(p);
end if;
else
if recursive then
(_, paths) := Interactive.getClassNamesRecursive(SOME(path), p, protects, constants, {});
(_, paths) := InteractiveUtil.getClassNamesRecursive(SOME(path), p, protects, constants, {});
paths := listReverseInPlace(paths);
else
paths := Interactive.getClassnamesInPath(path, p, protects, constants);
Expand Down Expand Up @@ -3391,7 +3391,7 @@ protected
list<Absyn.Import> pub_imports_list , pro_imports_list;
String imp_ident;
algorithm
package_class := Interactive.getPathedClassInProgram(Absyn.IDENT(in_package_name), SymbolTable.getAbsyn());
package_class := InteractiveUtil.getPathedClassInProgram(Absyn.IDENT(in_package_name), SymbolTable.getAbsyn());

(pub_imports_list , pro_imports_list) := getImportList(package_class);

Expand Down

0 comments on commit 7e00424

Please sign in to comment.