Commit c9decad7 authored by Maxime Perrotin's avatar Maxime Perrotin

Fix code to support instances

parent 973d9ed7
......@@ -66,39 +66,41 @@ void AADL_CV_Unparser ()
/* Declare all system-level connections */
fprintf (aadl, " connections\n");
FOREACH (fv, FV, ast->functions, {
char *fv_name = NULL;
fv_name = make_string ("%s%s",
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name);
FOREACH (interface, Interface, fv->interfaces, {
if (RI == interface->direction) {
FV *distant_fv = NULL;
char *distant_fv_name = NULL;
FOREACH (function, FV, ast->functions, {
if (!strcmp (function->name, interface->distant_fv))
distant_fv = function;
});
if (NULL != distant_fv) {
distant_fv_name = make_string ("%s%s",
thread_runtime == distant_fv->runtime_nature ? "THREAD_" : "PASSIVE_",
distant_fv->name);
fprintf (aadl, "\t%s_%s : subprogram access %s.%s -> %s.%s;\n",
RCM_KIND(interface),
interface->distant_name,
distant_fv_name,
interface->distant_name,
fv_name,
interface->name);
free (distant_fv_name);
if (false == fv->is_component_type) {
char *fv_name = NULL;
fv_name = make_string ("%s%s",
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name);
FOREACH (interface, Interface, fv->interfaces, {
if (RI == interface->direction) {
FV *distant_fv = NULL;
char *distant_fv_name = NULL;
FOREACH (function, FV, ast->functions, {
if (!strcmp (function->name, interface->distant_fv))
distant_fv = function;
});
if (NULL != distant_fv) {
distant_fv_name = make_string ("%s%s",
thread_runtime == distant_fv->runtime_nature ? "THREAD_" : "PASSIVE_",
distant_fv->name);
fprintf (aadl, "\t%s_%s : subprogram access %s.%s -> %s.%s;\n",
RCM_KIND(interface),
interface->distant_name,
distant_fv_name,
interface->distant_name,
fv_name,
interface->name);
free (distant_fv_name);
}
}
}
});
free (fv_name);
});
free (fv_name);
}
})
fprintf (aadl, " end exportedComponent.others;\n\n");
......
......@@ -1212,25 +1212,26 @@ FV_list *Find_All_Calling_FV(Interface * i)
FOREACH (function, FV, system_ast->functions, {
match = false;
FOREACH(iface, Interface, function->interfaces, {
if (false == match) {
if (RI == iface->direction) {
if (iface->distant_name == NULL ||
iface->distant_fv == NULL) {
printf("[ERROR] Required Interface %s in function %s is not "
"connected. Glue code cannot be generated.\n",
iface->name, function->name);
add_error();
if (false == function->is_component_type) {
FOREACH(iface, Interface, function->interfaces, {
if (false == match) {
if (RI == iface->direction) {
if (iface->distant_name == NULL || iface->distant_fv == NULL) {
printf("[ERROR] Required Interface %s in function %s is not "
"connected. Glue code cannot be generated.\n",
iface->name, function->name);
add_error();
}
}
if (NULL != iface->distant_name && NULL != i->name &&
NULL != iface->distant_fv && NULL != i->parent_fv &&
RI == iface->direction &&
!strcmp (iface->distant_name, i->name) &&
!strcmp (iface->distant_fv, i->parent_fv->name))
match = true;
}
if (NULL != iface->distant_name && NULL != i->name &&
NULL != iface->distant_fv && NULL != i->parent_fv &&
RI == iface->direction &&
!strcmp (iface->distant_name, i->name) &&
!strcmp (iface->distant_fv, i->parent_fv->name))
match = true;
}
})
})
}
if (true == match) {
APPEND_TO_LIST (FV, result, function);
}
......
......@@ -121,7 +121,7 @@ void C_End()
);
}
if (get_context()->gw && // (false == fv->is_component_type) &&
if (get_context()->gw &&
(NULL == fv->zipfile || get_context()->glue)) {
GW_SDL_Backend(fv);
GW_Simulink_Backend(fv);
......
......@@ -453,7 +453,6 @@ void ProcessArtificial_FV_Creation (Interface *i, RCM rcm)
callers = (FV_list *)Find_All_Calling_FV(i);
/* For each caller of the interface, find its corresponding RI
* and update its "distant_fv" field to point to the newly created FV
*/
......@@ -764,8 +763,8 @@ void Preprocess_FV (FV *fv)
fv->runtime_nature = thread_runtime;
}
else {
printf("unconnected interface %s %s\n", i->name, i->distant_name);
}
printf("Unconnected interface %s %s\n", i->name, i->distant_name);
}
break;
default: break;
}
......@@ -934,45 +933,45 @@ void Add_api(Process *node, FV_list *all_fv)
FOREACH(function, FV, all_fv, {
if (false == function->is_component_type) {
char *decl = NULL;
char *task_id = NULL;
char *port = NULL;
decl = make_string("void %s_PI_%s_has_pending_msg(asn1SccT_Boolean *res)", fv->name, function->name);
fprintf(header, "%s;\n\n", decl);
fprintf(code, "%s {\n"
" /* Check all incoming queues (if any) for a pending message */\n", decl);
/* Naming of ports/task id is different if there is more than 1 active PI */
int active = CountActivePI(function->interfaces);
FOREACH(pi, Interface, function->interfaces, {
if(PI == pi->direction && asynch == pi->synchronism && cyclic != pi->rcm && NULL != Find_All_Calling_FV(pi)) {
if (1 == active) {
task_id = make_string("%s_%s_k", node->name, function->name);
port = make_string("%s_local_inport_%s", function->name, pi->name);
}
else { /* More than one active PI */
task_id = make_string("%s_vt_%s_%s_k", node->name, function->name, pi->name);
port = make_string("vt_%s_%s_local_inport_artificial_%s", function->name, pi->name, pi->name);
char *decl = NULL;
char *task_id = NULL;
char *port = NULL;
decl = make_string("void %s_PI_%s_has_pending_msg(asn1SccT_Boolean *res)", fv->name, function->name);
fprintf(header, "%s;\n\n", decl);
fprintf(code, "%s {\n"
" /* Check all incoming queues (if any) for a pending message */\n", decl);
/* Naming of ports/task id is different if there is more than 1 active PI */
int active = CountActivePI(function->interfaces);
FOREACH(pi, Interface, function->interfaces, {
if(PI == pi->direction && asynch == pi->synchronism && cyclic != pi->rcm && NULL != Find_All_Calling_FV(pi)) {
if (1 == active) {
task_id = make_string("%s_%s_k", node->name, function->name);
port = make_string("%s_local_inport_%s", function->name, pi->name);
}
else { /* More than one active PI */
task_id = make_string("%s_vt_%s_%s_k", node->name, function->name, pi->name);
port = make_string("vt_%s_%s_local_inport_artificial_%s", function->name, pi->name, pi->name);
}
fprintf(code, " *res = 0;\n"
" if (__po_hi_gqueue_get_count(%s, %s)) {\n"
" *res = 1;\n"
" #ifdef __unix__\n"
" if (debugCheckQ) {\n"
" printf (\"[DEBUG] Pending message %s in function %s\\n\");\n"
" }\n"
" #endif\n"
" }\n",
string_to_lower(task_id),
string_to_lower(port),
pi->name,
function->name);
free(task_id);
free(port);
}
fprintf(code, " *res = 0;\n"
" if (__po_hi_gqueue_get_count(%s, %s)) {\n"
" *res = 1;\n"
" #ifdef __unix__\n"
" if (debugCheckQ) {\n"
" printf (\"[DEBUG] Pending message %s in function %s\\n\");\n"
" }\n"
" #endif\n"
" }\n",
string_to_lower(task_id),
string_to_lower(port),
pi->name,
function->name);
free(task_id);
free(port);
}
});
});
fprintf(code, "}\n\n");
free(decl);
fprintf(code, "}\n\n");
free(decl);
}
});
......@@ -1139,11 +1138,9 @@ void Set_Ignore_Params(FV *fv)
FOREACH (remote, FV, Find_All_Calling_FV(i), {
if (strcmp(remote->process->name, fv->process->name)) {
i->ignore_params = false;
//printf("set PI %s->ignore_params to FALSE", i->name);
distant_RI = FindCorrespondingRI(remote, i);
if (NULL != distant_RI) {
distant_RI->ignore_params = false;
//printf("set RI %s->ignore_params to FALSE", i->name);
}
}
});
......@@ -1171,7 +1168,7 @@ void Preprocessing_Backend (System *s)
});
FOREACH (fv, FV, s->functions, {
if (true != fv->is_component_type) {
if (false == fv->is_component_type) {
Preprocess_FV(fv);
}
});
......@@ -1300,9 +1297,11 @@ void Preprocessing_Backend (System *s)
connections_to_remove = NULL;
/* Once all AST transformations are done, set the ignore_params flags
* in all interfaces, if needed
* in all interfaces, if needed
*/
FOREACH (fv, FV, s->functions, {
Set_Ignore_Params(fv);
if (false == fv->is_component_type){
Set_Ignore_Params(fv);
}
});
}
......@@ -148,7 +148,8 @@ bool MultiInstance_SDL_Interface_Check(Interface * i, Interface * j)
/* External interface (the one and unique) */
void Function_Semantic_Check(FV * fv)
{
if (fv->system_ast->context->glue && NULL == fv->process) {
if (fv->system_ast->context->glue && NULL == fv->process
&& false == fv->is_component_type) {
ERROR
("[ERROR] Function \"%s\" is not bound to any partition.\n",
fv->name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment