Commit 63b0d5c3 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Report semantic errors after preprocessing backend

parent 810fe06a
/* Buildsupport is (c) 2008-2015 European Space Agency /* Buildsupport is (c) 2008-2016 European Space Agency
* contact: maxime.perrotin@esa.int * contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */ *
/* * AADL Concurrency view "Unparser"
* AADL Concurrency view "Unparser"
* Generate an interface view AADL file containing the results of the vertical transformation * Generate an interface view AADL file containing the results of the vertical transformation
* *
*/ */
/* TODO : (1) add deadlines /* TODO : (1) add deadlines
(2) add correct WCET (2) add correct WCET
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -24,206 +23,205 @@ ...@@ -24,206 +23,205 @@
void AADL_CV_Unparser () void AADL_CV_Unparser ()
{ {
System *ast = get_system_ast (); System *ast = get_system_ast ();
FILE *aadl = NULL; FILE *aadl = NULL;
int x0 = -200, int x0 = -200,
x1 = 0, x1 = 0,
y0 = 200, y0 = 200,
y1 = 0, y1 = 0,
max_y1 = 0; max_y1 = 0;
Interface_list *all_interfaces = NULL; Interface_list *all_interfaces = NULL;
create_file (OUTPUT_PATH, "Concurrency-View.aadl", &aadl); create_file (OUTPUT_PATH, "Concurrency-View.aadl", &aadl);
assert (NULL != aadl); assert (NULL != aadl);
/* AADL file preamble */ /* AADL file preamble */
fprintf (aadl, "-- TASTE - Warning: This is NOT the real Concurrency view --\n"); fprintf (aadl, "-- TASTE - Warning: This is NOT the real Concurrency view --\n");
fprintf (aadl, "-- This file was automatically generated and should remain read-only\n"); fprintf (aadl, "-- This file was automatically generated and should remain read-only\n");
fprintf (aadl, "-- Open it with TASTE-IV\n"); fprintf (aadl, "-- Open it with TASTE-IV\n");
fprintf (aadl, "-- The only intended use of this file is visualization - not processing.\n"); fprintf (aadl, "-- The only intended use of this file is visualization - not processing.\n");
fprintf (aadl, "\npackage generated_cv::IV::ConcurrencyView\n"); fprintf (aadl, "\npackage generated_cv::IV::ConcurrencyView\n");
fprintf (aadl, "public\n"); fprintf (aadl, "public\n");
fprintf (aadl, "with dataview; \nwith exportedComponent::FV;\nwith taste;\n\n"); fprintf (aadl, "with dataview; \nwith exportedComponent::FV;\nwith taste;\n\n");
/* Insert a comment in the AADL file for graphical display */ /* Insert a comment in the AADL file for graphical display */
fprintf (aadl, " --{ interfaceview obj6480 10 10\n"); fprintf (aadl, " --{ interfaceview obj6480 10 10\n");
fprintf (aadl, " --TASTE-generated concurrency view\n"); fprintf (aadl, " --TASTE-generated concurrency view\n");
fprintf (aadl, " --For visualization purposes.\n"); fprintf (aadl, " --For visualization purposes.\n");
fprintf (aadl, " --}\n\n"); fprintf (aadl, " --}\n\n");
fprintf (aadl, " system exportedComponent\n end exportedComponent;\n\n"); fprintf (aadl, " system exportedComponent\n end exportedComponent;\n\n");
fprintf (aadl, " system implementation exportedComponent.others\n subcomponents\n"); fprintf (aadl, " system implementation exportedComponent.others\n subcomponents\n");
/* Declare each subsystem */ /* Declare each subsystem */
FOREACH (fv, FV, ast->functions, { FOREACH (fv, FV, ast->functions, {
fprintf (aadl, "\t%s : system interfaceview::IV::%s%s.others;\n", fprintf (aadl, "\t%s : system interfaceview::IV::%s%s.others;\n",
fv->name, fv->name,
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_", thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name); fv->name);
}); });
/* Declare all system-level connections */ /* Declare all system-level connections */
fprintf (aadl, " connections\n"); fprintf (aadl, " connections\n");
FOREACH (fv, FV, ast->functions, { FOREACH (fv, FV, ast->functions, {
char *fv_name = NULL; char *fv_name = NULL;
fv_name = make_string ("%s%s", 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);
})
fprintf (aadl, " end exportedComponent.others;\n\n");
/* Define each individual subsystem and its implementation */
FOREACH (fv, FV, ast->functions, {
char *fv_name = NULL;
int nb_pi = 0;
int nb_ri = 0;
int if_x = 0;
int if_y_pi = 0;
int if_y_ri = 0;
/* Compute size and coordinated of subsystems */
FOREACH (interface, Interface, fv->interfaces, {
if (PI == interface->direction) nb_pi ++;
else nb_ri ++;
});
if (nb_ri > nb_pi) nb_pi = nb_ri;
x0 += 400;
if (x0 > 2200) {
x0 = 200;
y0 = 200 + max_y1 + 100;
}
x1 = x0 + 250;
y1 = y0 + (nb_pi*45);
if (y1 > max_y1) max_y1 = y1;
fv_name = make_string ("%s%s",
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_", thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name); fv->name);
FOREACH (interface, Interface, fv->interfaces, { fprintf (aadl, " system %s\n features\n",
fv_name);
if (RI == interface->direction) { if_y_pi = y0 - 30;
FV *distant_fv = NULL; if_y_ri = y0 - 30;
char *distant_fv_name = NULL; FOREACH (interface, Interface, fv->interfaces, {
FOREACH (function, FV, ast->functions, { int if_y = 0;
if (!strcmp (function->name, interface->distant_fv)) if (PI == interface->direction) {
distant_fv = function; if_x = x0;
}); if_y_pi = if_y_pi + 45;
if_y = if_y_pi;
if (NULL != distant_fv) { }
distant_fv_name = make_string ("%s%s", else {
thread_runtime == distant_fv->runtime_nature ? "THREAD_" : "PASSIVE_", if_x = x1;
distant_fv->name); if_y_ri = if_y_ri + 45;
if_y = if_y_ri;
fprintf (aadl, "\t%s_%s : subprogram access %s.%s -> %s.%s;\n", }
RCM_KIND(interface),
interface->distant_name, ADD_TO_SET (Interface, all_interfaces, interface);
distant_fv_name, fprintf (aadl, "\t%s : %s subprogram access exportedComponent::fv::%s.others\n",
interface->distant_name, interface->name,
fv_name, PI == interface->direction ? "provides" : "requires",
interface->name); NULL != interface->distant_name ?
free (distant_fv_name); interface->distant_name:interface->name);
} fprintf (aadl, "\t { taste::Coordinates => \"%d %d %d %d\";\n",
} if_x,
}); if_y,
free (fv_name); if_x,
}) if_y);
fprintf (aadl, "\t taste::RCMoperationKind => %s;\n",
fprintf (aadl, " end exportedComponent.others;\n\n"); RCM_KIND(interface));
fprintf (aadl, "\t taste::RCMperiod => %lld;",
/* Define each individual subsystem and its implementation */ interface->period);
FOREACH (fv, FV, ast->functions, { fprintf (aadl, "};\n");
char *fv_name = NULL; /* TODO add deadline */
int nb_pi = 0;
int nb_ri = 0; });
int if_x = 0; fprintf (aadl, " properties\n\tsource_language => C;\n");
int if_y_pi = 0; fprintf (aadl, "\ttaste::coordinates => \"%d %d %d %d\";\n",
int if_y_ri = 0; x0,
y0,
/* Compute size and coordinated of subsystems */ x1,
FOREACH (interface, Interface, fv->interfaces, { y1);
if (PI == interface->direction) nb_pi ++; fprintf (aadl, "\ttaste::instance_name => \"%s\";\n",
else nb_ri ++;
});
if (nb_ri > nb_pi) nb_pi = nb_ri;
x0 += 400;
if (x0 > 2200) {
x0 = 200;
y0 = 200 + max_y1 + 100;
}
x1 = x0 + 250;
y1 = y0 + (nb_pi*45);
if (y1 > max_y1) max_y1 = y1;
fv_name = make_string ("%s%s",
thread_runtime == fv->runtime_nature ? "THREAD_" : "PASSIVE_",
fv->name); fv->name);
fprintf (aadl, " end %s;\n\n",
fv_name);
fprintf (aadl, " system %s\n features\n", /* Then the system implementation */
fprintf (aadl, " system implementation %s.others\n",
fv_name); fv_name);
if_y_pi = y0 - 30; fprintf (aadl, " subcomponents\n");
if_y_ri = y0 - 30;
FOREACH (interface, Interface, fv->interfaces, { FOREACH (interface, Interface, fv->interfaces, {
fprintf (aadl, "\t%s_impl : subprogram exportedComponent::FV::%s.others\n",
int if_y = 0; interface->name,
if (PI == interface->direction) { NULL != interface->distant_name ? interface->distant_name : interface->name);
if_x = x0; fprintf (aadl, "\t { compute_execution_time => 0ms..0ms;};\n");
if_y_pi = if_y_pi + 45; });
if_y = if_y_pi;
} fprintf (aadl, " connections\n");
else { FOREACH (interface, Interface, fv->interfaces, {
if_x = x1; fprintf (aadl, "\tsubprogram access %s_impl -> %s;\n",
if_y_ri = if_y_ri + 45; interface->name,
if_y = if_y_ri; interface->name);
} });
fprintf (aadl, " end %s.others;\n\n",
ADD_TO_SET (Interface, all_interfaces, interface);
fprintf (aadl, "\t%s : %s subprogram access exportedComponent::fv::%s.others\n",
interface->name,
PI == interface->direction ? "provides" : "requires",
NULL != interface->distant_name ?
interface->distant_name:interface->name);
fprintf (aadl, "\t { taste::Coordinates => \"%d %d %d %d\";\n",
if_x,
if_y,
if_x,
if_y);
fprintf (aadl, "\t taste::RCMoperationKind => %s;\n",
RCM_KIND(interface));
fprintf (aadl, "\t taste::RCMperiod => %lld;",
interface->period);
fprintf (aadl, "};\n");
/* TODO add deadline */
});
fprintf (aadl, " properties\n\tsource_language => C;\n");
fprintf (aadl, "\ttaste::coordinates => \"%d %d %d %d\";\n",
x0,
y0,
x1,
y1);
fprintf (aadl, "\ttaste::instance_name => \"%s\";\n",
fv->name);
fprintf (aadl, " end %s;\n\n",
fv_name); fv_name);
free (fv_name);
});
fprintf (aadl, "properties\n");
fprintf (aadl, " taste::coordinates => \"0 0 2970 2100\";\n\n");
fprintf (aadl, "end generated_cv::IV;\n\n");
/* Functional view */
fprintf (aadl, "package exportedComponent::FV\npublic\n");
fprintf (aadl, "with dataview;\nwith taste;\n\n");
FOREACH (interface, Interface, all_interfaces, {
fprintf (aadl, " subprogram %s\n end %s;\n\n",
NULL != interface->distant_name ? interface->distant_name : interface->name,
NULL != interface->distant_name ? interface->distant_name : interface->name);
});
fprintf (aadl, "end exportedComponent::FV;\n");
/* Then the system implementation */ close_file (&aadl);
fprintf (aadl, " system implementation %s.others\n",
fv_name);
fprintf (aadl, " subcomponents\n");
FOREACH (interface, Interface, fv->interfaces, {
fprintf (aadl, "\t%s_impl : subprogram exportedComponent::FV::%s.others\n",
interface->name,
NULL != interface->distant_name ? interface->distant_name : interface->name);
fprintf (aadl, "\t { compute_execution_time => 0ms..0ms;};\n");
});
fprintf (aadl, " connections\n");
FOREACH (interface, Interface, fv->interfaces, {
fprintf (aadl, "\tsubprogram access %s_impl -> %s;\n",
interface->name,
interface->name);
});
fprintf (aadl, " end %s.others;\n\n",
fv_name);
free (fv_name);
});
fprintf (aadl, "properties\n");
fprintf (aadl, " taste::coordinates => \"0 0 2970 2100\";\n\n");
fprintf (aadl, "end generated_cv::IV;\n\n");
/* Functional view */
fprintf (aadl, "package exportedComponent::FV\npublic\n");
fprintf (aadl, "with dataview;\nwith taste;\n\n");
FOREACH (interface, Interface, all_interfaces, {
fprintf (aadl, " subprogram %s\n end %s;\n\n",
NULL != interface->distant_name ? interface->distant_name : interface->name,
NULL != interface->distant_name ? interface->distant_name : interface->name);
});
fprintf (aadl, "end exportedComponent::FV;\n");
close_file (&aadl);
} }
...@@ -153,6 +153,13 @@ void C_End() ...@@ -153,6 +153,13 @@ void C_End()
if (get_context()->glue) { if (get_context()->glue) {
Preprocessing_Backend(get_system_ast()); Preprocessing_Backend(get_system_ast());
} }
/*
* Preprocessing may have raised some further semantic errors.
*/
if (error_count > 0) {
fprintf(stderr, "\nFound %d errors.. Aborting...\n", error_count);
exit(1);
}
/* /*
* Debug mode (userflag -test) : dump the result of the transformation * Debug mode (userflag -test) : dump the result of the transformation
......
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