Skip to content

Commit 7b22ec1

Browse files
committed
Interactive.mo
- run all graphical API commands with checkModel, nogen and noevalfunc ON. - merge graphical API handling functions into one. errorext.cpp - always add the message to the queue even if we run with +showErrorMessages (to get numErrorMessages to be updated correctly) Inst.mo - removed useless System.setPartialInstantiation(false); as is already done before - check balancing only for non-expandable connectors. CevalScript.mo - simplify checkModel - do NOT send the cache to checkModel inside checkAll because after failure of checking some model (in Media.Fluid) ALL others that follow WILL FAIL! git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10304 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent f738129 commit 7b22ec1

File tree

6 files changed

+245
-302
lines changed

6 files changed

+245
-302
lines changed

Compiler/FrontEnd/ConnectUtil.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ algorithm
343343
list<DAE.Var> el, streams, flows;
344344
Sets cs;
345345

346-
case (ClassInf.CONNECTOR(path = class_path), _, _, cs, _)
346+
// check balance of non expandable connectors!
347+
case (ClassInf.CONNECTOR(path = class_path, isExpandable = false), _, _, cs, _)
347348
equation
348349
checkConnectorBalance(inVars, class_path, info);
349350
(flows, streams) = getStreamAndFlowVariables(inVars, {}, {});

Compiler/FrontEnd/Inst.mo

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ algorithm
398398
equation
399399
cname_str = Absyn.pathString(path);
400400
Error.addMessage(Error.ERROR_FLATTENING, {cname_str});
401+
402+
// let the GC collect these as they are used only by Inst!
403+
setGlobalRoot(instHashIndex, emptyInstHashTable());
404+
setGlobalRoot(Types.memoryIndex, Types.createEmptyTypeMemory());
401405
then
402406
fail();
403407
end matchcontinue;
@@ -2827,8 +2831,6 @@ algorithm
28272831
SOME(FUNC_partialInstClassIn( // result for partial instantiation
28282832
inputs,outputs)));
28292833
//Debug.fprintln("cache", "IIIIPARTIAL->added to instCache: " +& Absyn.pathString(fullEnvPathPlusClass));
2830-
2831-
System.setPartialInstantiation(false);
28322834
then
28332835
(cache,env,ih,ci_state);
28342836

Compiler/Script/CevalScript.mo

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,80 +3220,12 @@ algorithm
32203220
BackendDAE.EqSystem syst;
32213221
BackendDAE.Shared shared;
32223222

3223-
// handle partial models
3224-
case (cache,env,className,(st as Interactive.SYMBOLTABLE(ast = p)),msg)
3225-
equation
3226-
ptot = Dependency.getTotalProgram(className,p);
3227-
// see if class is partial
3228-
Absyn.CLASS(partialPrefix = partialPrefix as true, finalPrefix = finalPrefix, encapsulatedPrefix = encapsulatedPrefix, restriction = restriction, info = info) =
3229-
Interactive.getPathedClassInProgram(className, p);
3230-
// this case should not handle functions so here we check anything but functions!
3231-
false = listMember(restriction, {Absyn.R_FUNCTION()});
3232-
Error.clearMessages() "Clear messages";
3233-
Print.clearErrorBuf() "Clear error buffer";
3234-
classNameStr = Absyn.pathString(className);
3235-
/* this part is not needed anymore as when checkModel is active you can normally instantiate partial classes
3236-
I leave it here as we might use it in some other part
3237-
// add a non-partial class to ptot with the same flags (final, encapsulated) and same restriction but instead of partial make it non-partial.
3238-
Absyn.PROGRAM(classes, within_, globalBuildTimes) = ptot;
3239-
classNameStr_dummy = classNameStr +& "_$_non_partial";
3240-
// make a dummy class part containing an element definition as extends given-for-check-partial-class;
3241-
dummyClassPart =
3242-
Absyn.PUBLIC({
3243-
Absyn.ELEMENTITEM(
3244-
Absyn.ELEMENT(false, NONE(), Absyn.NOT_INNER_OUTER(), "extends",
3245-
Absyn.EXTENDS(className, {}, NONE()), // extend the given-for-check partial class
3246-
info, NONE())
3247-
)});
3248-
dummyClass = Absyn.CLASS(classNameStr_dummy,
3249-
false,
3250-
finalPrefix,
3251-
encapsulatedPrefix,
3252-
restriction,
3253-
Absyn.PARTS({dummyClassPart}, NONE()),
3254-
info);
3255-
// add the dummy class to the program
3256-
ptot = Absyn.PROGRAM(dummyClass::classes, within_, globalBuildTimes);
3257-
*/
3258-
// translate the program
3259-
p_1 = SCodeUtil.translateAbsyn2SCode(ptot);
3260-
3261-
//UnitParserExt.clear();
3262-
//UnitAbsynBuilder.registerUnits(ptot);
3263-
//UnitParserExt.commit();
3264-
3265-
// instantiate the partial class nomally as it works during checkModel.
3266-
(cache, env, _, dae) = Inst.instantiateClass(inCache, InnerOuter.emptyInstHierarchy, p_1, className);
3267-
3268-
dae = DAEUtil.transformationsBeforeBackend(cache,dae);
3269-
// adrpo: do not store instantiated class as we don't use it later!
3270-
// ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(className,dae,env));
3271-
funcs = Env.getFunctionTree(cache);
3272-
(dlow as BackendDAE.DAE({syst},shared)) = BackendDAECreate.lower(dae, funcs, false) "no dummy state" ;
3273-
Debug.fcall("dumpdaelow", BackendDump.dump, dlow);
3274-
eqns = BackendEquation.daeEqns(syst);
3275-
eqnSize = BackendDAEUtil.equationSize(eqns);
3276-
vars = BackendVariable.daeVars(syst);
3277-
varSize = BackendVariable.varsSize(vars);
3278-
(eqnSize,varSize) = subtractDummy(vars,eqnSize,varSize);
3279-
(m,_) = BackendDAEUtil.incidenceMatrix(syst,shared, BackendDAE.NORMAL());
3280-
simpleEqnSize = BackendDAEOptimize.countSimpleEquations(dlow,m);
3281-
eqnSizeStr = intString(eqnSize);
3282-
varSizeStr = intString(varSize);
3283-
simpleEqnSizeStr = intString(simpleEqnSize);
3284-
3285-
warnings = Error.printMessagesStr();
3286-
retStr=stringAppendList({"Check of ",classNameStr," completed successfully.\n\n",warnings,"\nClass ",classNameStr," has ",eqnSizeStr," equation(s) and ",
3287-
varSizeStr," variable(s).\n",simpleEqnSizeStr," of these are trivial equation(s).\n"});
3288-
then
3289-
(cache,Values.STRING(retStr),st);
3290-
32913223
// handle normal models
32923224
case (cache,env,className,(st as Interactive.SYMBOLTABLE(ast = p)),msg)
32933225
equation
32943226
ptot = Dependency.getTotalProgram(className,p);
3295-
// non-partial non-functions
3296-
Absyn.CLASS(partialPrefix = false, restriction = restriction) = Interactive.getPathedClassInProgram(className, p);
3227+
// non-functions
3228+
Absyn.CLASS(partialPrefix = _, restriction = restriction) = Interactive.getPathedClassInProgram(className, p);
32973229
// this case should not handle functions so here we check anything but functions!
32983230
false = listMember(restriction, {Absyn.R_FUNCTION()});
32993231
Error.clearMessages() "Clear messages";
@@ -3304,8 +3236,7 @@ algorithm
33043236
//UnitAbsynBuilder.registerUnits(ptot);
33053237
//UnitParserExt.commit();
33063238

3307-
(cache, env, _, dae) =
3308-
Inst.instantiateClass(inCache, InnerOuter.emptyInstHierarchy, p_1, className);
3239+
(cache, env, _, dae) = Inst.instantiateClass(inCache, InnerOuter.emptyInstHierarchy, p_1, className);
33093240
dae = DAEUtil.transformationsBeforeBackend(cache, dae);
33103241
// adrpo: do not store instantiated class as we don't use it later!
33113242
// ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(className,dae,env));
@@ -3344,8 +3275,7 @@ algorithm
33443275
//UnitAbsynBuilder.registerUnits(ptot);
33453276
//UnitParserExt.commit();
33463277

3347-
(cache, env, _) =
3348-
Inst.instantiateFunctionImplicit(inCache, InnerOuter.emptyInstHierarchy, p_1, className);
3278+
(cache, env, _) = Inst.instantiateFunctionImplicit(inCache, InnerOuter.emptyInstHierarchy, p_1, className);
33493279

33503280
// adrpo: do not store instantiated class as we don't use it later!
33513281
// ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(className,dae,env));
@@ -3362,8 +3292,7 @@ algorithm
33623292
classNameStr = Absyn.pathString(className);
33633293
errorMsg = Error.printMessagesStr();
33643294
strEmpty = (stringCompare("",errorMsg)==0);
3365-
errorMsg = Util.if_(strEmpty,"Internal error, check of model failed with no error message.",errorMsg);
3366-
// errorMsg = errorMsg +& selectIfNotEmpty("Error Buffer:\n", Print.getErrorString());
3295+
errorMsg = Util.if_(strEmpty,"Internal error! Check of: " +& classNameStr +& " failed with no error message.", errorMsg);
33673296
then
33683297
(cache,Values.STRING(errorMsg),st);
33693298

@@ -3815,7 +3744,7 @@ algorithm
38153744
print("Checking: " +& Dump.unparseClassAttributesStr(c) +& " " +& Absyn.pathString(className) +& "... ");
38163745
t1 = clock();
38173746
OptManager.setOption("checkModel", true);
3818-
(_,Values.STRING(str),_) = checkModel(cache, env, className, st, msg);
3747+
(_,Values.STRING(str),_) = checkModel(Env.emptyCache(), env, className, st, msg);
38193748
OptManager.setOption("checkModel", false);
38203749
t2 = clock(); elapsedTime = t2 -. t1; s = realString(elapsedTime);
38213750
print (s +& " seconds -> " +& failOrSuccess(str) +& "\n\t");

0 commit comments

Comments
 (0)