Skip to content

Commit

Permalink
- Added MLS 3.2 ModelicaVFormatMessage/Error
Browse files Browse the repository at this point in the history
- Made the DIVISION() macro use testsuite-friendly filenames


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14969 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 28, 2013
1 parent b73c5d9 commit 307a393
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
12 changes: 7 additions & 5 deletions Compiler/BackEnd/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -10075,7 +10075,7 @@ algorithm
then ((e, source ));
case( (e as DAE.BINARY(exp1 = e1, operator = DAE.DIV(ty), exp2 = e2), source))
equation
se = generadeDivExpErrorMsg(e, e2, source);
se = generateDivExpErrorMsg(e, e2, source);
then ((DAE.CALL(Absyn.IDENT("DIVISION"), {e1, e2, DAE.SCONST(se)}, DAE.CALL_ATTR(ty, false, true, DAE.NO_INLINE(), DAE.NO_TAIL())), source ));
/*
case( (e as DAE.BINARY(exp1 = e1, operator = DAE.DIV_ARR(ty), exp2 = e2), dlowmode as (dlow, _)))
Expand All @@ -10089,7 +10089,7 @@ algorithm
then ((e, source ));
case( (e as DAE.BINARY(exp1 = e1, operator = DAE.DIV_ARRAY_SCALAR(ty), exp2 = e2), source))
equation
se = generadeDivExpErrorMsg(e, e2, source);
se = generateDivExpErrorMsg(e, e2, source);
then ((DAE.CALL(Absyn.IDENT("DIVISION_ARRAY_SCALAR"), {e1, e2, DAE.SCONST(se)}, DAE.CALL_ATTR(ty, false, true, DAE.NO_INLINE(), DAE.NO_TAIL())), source ));

case( (e as DAE.BINARY(exp1 = e1, operator = DAE.DIV_SCALAR_ARRAY(ty), exp2 = e2), source))
Expand All @@ -10099,13 +10099,13 @@ algorithm
then ((e, source ));
case( (e as DAE.BINARY(exp1 = e1, operator = DAE.DIV_SCALAR_ARRAY(ty), exp2 = e2), source))
equation
se = generadeDivExpErrorMsg(e, e2, source);
se = generateDivExpErrorMsg(e, e2, source);
then ((DAE.CALL(Absyn.IDENT("DIVISION_SCALAR_ARRAY"), {e1, e2, DAE.SCONST(se)}, DAE.CALL_ATTR(ty, false, true, DAE.NO_INLINE(), DAE.NO_TAIL())), source));
case _ then (inExp);
end matchcontinue;
end traversingDivExpFinder;

protected function generadeDivExpErrorMsg "function generadeDivExpErrorMsg
protected function generateDivExpErrorMsg "function generateDivExpErrorMsg
author: Frenkel TUD 2010-02. varOrigCref"
input DAE.Exp inExp;
input DAE.Exp inDivisor;
Expand All @@ -10115,12 +10115,14 @@ protected
String se, se2, s, fileName;
Integer lns;
algorithm
/* Come on... This is just silly. Why not store an Absyn.Info in the OP_DIVISION()? */
se := ExpressionDump.printExp2Str(inExp, "\"", SOME((BackendDump.componentRef_DIVISION_String, 0)), SOME(BackendDump.printCallFunction2StrDIVISION));
se2 := ExpressionDump.printExp2Str(inDivisor, "\"", SOME((BackendDump.componentRef_DIVISION_String, 0)), SOME(BackendDump.printCallFunction2StrDIVISION));
Absyn.INFO(fileName=fileName, lineNumberStart=lns) := DAEUtil.getElementSourceFileInfo(source);
fileName := Util.testsuiteFriendly(fileName);
s := intString(lns);
outString := stringAppendList({se, " because ", se2, " == 0: File: ", fileName, " Line: ", s});
end generadeDivExpErrorMsg;
end generateDivExpErrorMsg;

protected function addDivExpErrorMsgtosimJac "function addDivExpErrorMsgtosimJac
helper for addDivExpErrorMsgtoSimEqSystem."
Expand Down
5 changes: 5 additions & 0 deletions Compiler/Template/SimCodeTV.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,11 @@ package Util
output list<Type_b> outTypeALst;
replaceable type Type_a subtypeof Any;
end splitTuple212List;

function testsuiteFriendly
input String in;
output String out;
end testsuiteFriendly;
end Util;

package List
Expand Down
19 changes: 13 additions & 6 deletions SimulationRuntime/c/ModelicaExternalC/ModelicaUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "omc_error.h"

void ModelicaMessage(const char* string) {
ModelicaFormatMessage("%s", string);
}

extern void ModelicaVFormatMessage(const char*string, va_list args) {
vfprintf(stdout, string, args);
fflush(stdout);
}

void ModelicaFormatMessage(const char* string,...) {
va_list args;
va_start(args, string);
vfprintf(stdout, string, args);
ModelicaVFormatMessage(string, args);
va_end(args);
fflush(stdout);
}

void ModelicaError(const char* string) {
Expand All @@ -55,13 +58,17 @@ void ModelicaError(const char* string) {
omc_throw();
}

extern void ModelicaVFormatError(const char*string, va_list args) {
vfprintf(stderr, string, args);
fflush(stderr);
omc_throw();
}

void ModelicaFormatError(const char* string, ...) {
va_list args;
va_start(args, string);
vfprintf(stderr, string, args);
ModelicaVFormatError(string, args);
va_end(args);
fflush(stderr);
omc_throw();
}

char* ModelicaAllocateString(size_t len) {
Expand Down
5 changes: 4 additions & 1 deletion SimulationRuntime/c/ModelicaExternalC/ModelicaUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
#define MODELICA_UTILITIES_H

#include <stddef.h>
#include <stdarg.h>
/*
* Utility functions for external functions.
* The functionality is defined in the Modelica 2.x and 3.x specifications.
*/

extern void ModelicaMessage(const char* string);
extern void ModelicaFormatMessage(const char* string,...);
extern void ModelicaFormatMessage(const char* string, ...);
extern void ModelicaError(const char* string);
extern void ModelicaFormatError(const char* string, ...);
extern char* ModelicaAllocateString(size_t len);
extern char* ModelicaAllocateStringWithErrorReturn(size_t len);
extern void ModelicaVFormatMessage(const char*string, va_list);
extern void ModelicaVFormatError(const char*string, va_list);

#endif /* MODELICA_UTILITIES_H */

0 comments on commit 307a393

Please sign in to comment.