Skip to content

Commit

Permalink
rml-file for the cpp-connection
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1385 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x02lucpo committed Jan 11, 2005
1 parent e7ed95d commit 6790ffe
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modeq/runtime/Makefile.in
Expand Up @@ -27,7 +27,7 @@ IDL = idl
CFLAGS += -I$(RMLINCLUDE) -I../../c_runtime $(CORBAINCL)
CXXFLAGS = $(CFLAGS)
SRC = rtopts.c socketimpl.c printimpl.c systemimpl.c
CPPSRC = ptolemyio.cpp daeext.cpp $(CORBASRC)
CPPSRC = ptolemyio.cpp daeext.cpp tornadoext.cpp $(CORBASRC)
OBJ = $(SRC:.c=.o) $(CPPSRC:.cpp=.o) $(CPPSRC:.cc=.o)

all: $(OBJ)
Expand Down
11 changes: 10 additions & 1 deletion modeq/runtime/rtopts.c
Expand Up @@ -146,6 +146,7 @@ RML_BEGIN_LABEL(RTOpts__args)
break;
case 'c':
tornado_cg = 1;
/*modelica_output = 1;*/
break;
case 'm':
modelica_output = 1;
Expand Down Expand Up @@ -227,7 +228,15 @@ RML_END_LABEL

RML_BEGIN_LABEL(RTOpts__modelica_5foutput)
{
rmlA0 = RML_PRIM_MKBOOL(modelica_output);
/* this check is needed for not generating variable of the */
/* form a_b_c. The tornado implementation needs the variable */
/* of the form a.b.c */
if(tornado_cg)
{
rmlA0 = RML_PRIM_MKBOOL(0);
}else{
rmlA0 = RML_PRIM_MKBOOL(modelica_output);
}
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand Down
62 changes: 62 additions & 0 deletions modeq/runtime/tornadoext.cpp
@@ -0,0 +1,62 @@
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <vector>


using namespace std;


extern "C"
{
#include <assert.h>
#include "rml.h"
#include "../absyn_builder/yacclib.h"

map<string,int> alg_state_var_Number;


void TORNADOEXT_5finit(void)
{
}


RML_BEGIN_LABEL(TORNADOEXT__dump_5ftesting)
{
int nvars = RML_UNTAGFIXNUM(rmlA0);
cout << "testing tornadoext" << endl
<< "================" << nvars << endl;

RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(TORNADOEXT__get_5fstate_5falg_5fnumber)
{
int nvars = RML_UNTAGFIXNUM(rmlA0);
char* str = RML_STRINGDATA(rmlA0);
string str_key = string(str);

map<string, int>::const_iterator search;
search = alg_state_var_Number.find(str_key);
int ret_val = 0;
if(search != alg_state_var_Number.end()){
ret_val = static_cast<int>(search->second);
ret_val += 1;
// cout << "\nSTATE_ALG:" << str_key << " " << ret_val << nvars << endl;

} // else {
// cout << "\nNO STATE_ALG:" << str_key << " " << ret_val << nvars << endl;
// }

alg_state_var_Number[str_key] = ret_val;
rmlA0 = (void*) mk_icon(ret_val);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL



} // extern "C"
43 changes: 43 additions & 0 deletions modeq/tornadoext.rml
@@ -0,0 +1,43 @@
(*
Copyright PELAB, Linkoping University

This file is part of Open Source Modelica (OSM).

OSM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

OSM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenModelica; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

*)

(**
** file: tornadoext.rml
** module: TORNADOEXT
**)

(**
** The TORNADOEXT module is an externally implemented module (in file runtime/tornadoext.cpp)
** used for the BLT and index reduction algorithms in 'DAELow'. The implementation
** mainly consists of several bitvectors implemented using std::vector<bool> since
** such functionality is not available in RML.
*)

module TORNADOEXT:


relation dump_testing: (int) => ()
relation get_state_alg_number: (string) => int



end

62 changes: 62 additions & 0 deletions modeq/winruntime/tornadoext.cpp
@@ -0,0 +1,62 @@
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <vector>


using namespace std;


extern "C"
{
#include <assert.h>
#include "rml.h"
#include "../absyn_builder/yacclib.h"

map<string,int> alg_state_var_Number;


void TORNADOEXT_5finit(void)
{
}


RML_BEGIN_LABEL(TORNADOEXT__dump_5ftesting)
{
int nvars = RML_UNTAGFIXNUM(rmlA0);
cout << "testing tornadoext" << endl
<< "================" << nvars << endl;

RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(TORNADOEXT__get_5fstate_5falg_5fnumber)
{
int nvars = RML_UNTAGFIXNUM(rmlA0);
char* str = RML_STRINGDATA(rmlA0);
string str_key = string(str);

map<string, int>::const_iterator search;
search = alg_state_var_Number.find(str_key);
int ret_val = 0;
if(search != alg_state_var_Number.end()){
ret_val = static_cast<int>(search->second);
ret_val += 1;
// cout << "\nSTATE_ALG:" << str_key << " " << ret_val << nvars << endl;

} // else {
// cout << "\nNO STATE_ALG:" << str_key << " " << ret_val << nvars << endl;
// }

alg_state_var_Number[str_key] = ret_val;
rmlA0 = (void*) mk_icon(ret_val);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL



} // extern "C"

0 comments on commit 6790ffe

Please sign in to comment.